"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2462],{23425:(Ht,ne,T)=>{T.r(ne),T.d(ne,{ReactMonacoEditor:()=>_t});function we(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?oe(Object(r),!0).forEach(function(n){we(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Oe(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,i;for(i=0;i<n.length;i++)o=n[i],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}function je(e,t){if(e==null)return{};var r=Oe(e,t),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Me(e,t){return Ee(e)||Se(e,t)||Pe(e,t)||Ce()}function Ee(e){if(Array.isArray(e))return e}function Se(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,o=!1,i=void 0;try{for(var u=e[Symbol.iterator](),g;!(n=(g=u.next()).done)&&(r.push(g.value),!(t&&r.length===t));n=!0);}catch(f){o=!0,i=f}finally{try{!n&&u.return!=null&&u.return()}finally{if(o)throw i}}return r}}function Pe(e,t){if(e){if(typeof e=="string")return ae(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ae(e,t)}}function ae(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ce(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ue(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ce(Object(r),!0).forEach(function(n){Re(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ce(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Te(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,i){return i(o)},n)}}function I(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,g=new Array(u),f=0;f<u;f++)g[f]=arguments[f];return t.apply(r,[].concat(o,g))}}}function x(e){return{}.toString.call(e).includes("Object")}function Ie(e){return!Object.keys(e).length}function A(e){return typeof e=="function"}function Ae(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Le(e,t){return x(t)||j("changeType"),Object.keys(t).some(function(r){return!Ae(e,r)})&&j("changeField"),t}function De(e){A(e)||j("selectorType")}function ke(e){A(e)||x(e)||j("handlerType"),x(e)&&Object.values(e).some(function(t){return!A(t)})&&j("handlersType")}function ze(e){e||j("initialIsRequired"),x(e)||j("initialType"),Ie(e)&&j("initialContent")}function Ne(e,t){throw new Error(e[t]||e.default)}var Ve={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},j=I(Ne)(Ve),B={changes:Le,selector:De,handler:ke,initial:ze};function xe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};B.initial(e),B.handler(t);var r={current:e},n=I(_e)(r,t),o=I(Ue)(r),i=I(B.changes)(e),u=I(Be)(r);function g(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(C){return C};return B.selector(b),b(r.current)}function f(b){Te(n,o,i,u)(b)}return[g,f]}function Be(e,t){return A(t)?t(e.current):t}function Ue(e,t){return e.current=ue(ue({},e.current),t),t}function _e(e,t,r){return A(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var Fe={create:xe};const He=Fe;var $e={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.36.1/min/vs"}};const We=$e;function qe(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,g=new Array(u),f=0;f<u;f++)g[f]=arguments[f];return t.apply(r,[].concat(o,g))}}}const Ge=qe;function Ye(e){return{}.toString.call(e).includes("Object")}const Ze=Ye;function Je(e){return e||se("configIsRequired"),Ze(e)||se("configType"),e.urls?(Ke(),{paths:{vs:e.urls.monacoBase}}):e}function Ke(){console.warn(le.deprecation)}function Qe(e,t){throw new Error(e[t]||e.default)}var le={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
    You are using deprecated way of configuration.

    Instead of using
      monaco.config({ urls: { monacoBase: '...' } })
    use
      monaco.config({ paths: { vs: '...' } })

    For more please check the link https://github.com/suren-atoyan/monaco-loader#config
  `},se=Ge(Qe)(le),Xe={config:Je};const et=Xe;var tt=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,u){return u(i)},o)}};const rt=tt;function fe(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],fe(e[r],t[r]))}),ie(ie({},e),t)}const nt=fe;var ot={type:"cancelation",msg:"operation is manually canceled"};function it(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(ot):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}const $=it;var at=He.create({config:We,isInitialized:!1,resolve:null,reject:null,monaco:null}),de=Me(at,2),L=de[0],U=de[1];function ct(e){var t=et.config(e),r=t.monaco,n=je(t,["monaco"]);U(function(o){return{config:nt(o.config,n),monaco:r}})}function ut(){var e=L(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(U({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),$(W);if(window.monaco&&window.monaco.editor)return ge(window.monaco),e.resolve(window.monaco),$(W);rt(lt,ft)(dt)}return $(W)}function lt(e){return document.body.appendChild(e)}function st(e){var t=document.createElement("script");return e&&(t.src=e),t}function ft(e){var t=L(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=st("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function dt(){var e=L(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){ge(r),e.resolve(r)},function(r){e.reject(r)})}function ge(e){L().monaco||U({monaco:e})}function gt(){return L(function(e){var t=e.monaco;return t})}var W=new Promise(function(e,t){return U({resolve:e,reject:t})}),pt={config:ct,init:ut,__getMonacoInstance:gt};const S=pt;var a=T(27702),ht={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},q=ht,vt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},mt=vt;function bt({children:e}){return a.createElement("div",{style:mt.container},e)}var yt=bt,wt=yt;function Ot({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:u}){return a.createElement("section",{style:{...q.wrapper,width:e,height:t},...u},!r&&a.createElement(wt,null,n),a.createElement("div",{ref:o,style:{...q.fullWidth,...!r&&q.hide},className:i}))}var jt=Ot,pe=(0,a.memo)(jt);function Mt(e){(0,a.useEffect)(e,[])}var G=Mt;function Et(e,t,r=!0){let n=(0,a.useRef)(!0);(0,a.useEffect)(n.current||!r?()=>{n.current=!1}:e,t)}var w=Et;function D(){}function P(e,t,r,n){return St(e,n)||Pt(e,t,r,n)}function St(e,t){return e.editor.getModel(he(e,t))}function Pt(e,t,r,n){return e.editor.createModel(t,r,n?he(e,n):void 0)}function he(e,t){return e.Uri.parse(t)}function Ct({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:u,keepCurrentOriginalModel:g=!1,keepCurrentModifiedModel:f=!1,theme:b="light",loading:C="Loading...",options:O={},height:Y="100%",width:Z="100%",className:J,wrapperProps:K={},beforeMount:Q=D,onMount:X=D}){let[y,k]=(0,a.useState)(!1),[z,d]=(0,a.useState)(!0),p=(0,a.useRef)(null),s=(0,a.useRef)(null),N=(0,a.useRef)(null),v=(0,a.useRef)(X),c=(0,a.useRef)(Q),R=(0,a.useRef)(!1);G(()=>{let l=S.init();return l.then(h=>(s.current=h)&&d(!1)).catch(h=>h?.type!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>p.current?V():l.cancel()}),w(()=>{let l=p.current.getModifiedEditor();l.getOption(s.current.editor.EditorOption.readOnly)?l.setValue(t||""):t!==l.getValue()&&(l.executeEdits("",[{range:l.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),l.pushUndoStop())},[t],y),w(()=>{p.current?.getModel()?.original.setValue(e||"")},[e],y),w(()=>{let{original:l,modified:h}=p.current.getModel();s.current.editor.setModelLanguage(l,n||r||"text"),s.current.editor.setModelLanguage(h,o||r||"text")},[r,n,o],y),w(()=>{s.current?.editor.setTheme(b)},[b],y),w(()=>{p.current?.updateOptions(O)},[O],y);let F=(0,a.useCallback)(()=>{if(!s.current)return;c.current(s.current);let l=P(s.current,e||"",n||r||"text",i||""),h=P(s.current,t||"",o||r||"text",u||"");p.current?.setModel({original:l,modified:h})},[r,t,o,e,n,i,u]),H=(0,a.useCallback)(()=>{!R.current&&N.current&&(p.current=s.current.editor.createDiffEditor(N.current,{automaticLayout:!0,...O}),F(),s.current?.editor.setTheme(b),k(!0),R.current=!0)},[O,b,F]);(0,a.useEffect)(()=>{y&&v.current(p.current,s.current)},[y]),(0,a.useEffect)(()=>{!z&&!y&&H()},[z,y,H]),w(()=>{if(p.current&&s.current){let l=p.current.getOriginalEditor(),h=P(s.current,e||"",n||r||"text",i||"");h!==l.getModel()&&l.setModel(h)}},[i],y),w(()=>{if(p.current&&s.current){let l=p.current.getModifiedEditor(),h=P(s.current,t||"",o||r||"text",u||"");h!==l.getModel()&&l.setModel(h)}},[u],y);function V(){let l=p.current?.getModel();g||l?.original?.dispose(),f||l?.modified?.dispose(),p.current?.dispose()}return a.createElement(pe,{width:Z,height:Y,isEditorReady:y,loading:C,_ref:N,className:J,wrapperProps:K})}var Rt=Ct,$t=(0,a.memo)(Rt);function Tt(){let[e,t]=(0,a.useState)(S.__getMonacoInstance());return G(()=>{let r;return e||(r=S.init(),r.then(n=>{t(n)})),()=>r?.cancel()}),e}var It=Tt;function At(e){let t=(0,a.useRef)();return(0,a.useEffect)(()=>{t.current=e},[e]),t.current}var Lt=At,_=new Map;function Dt({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:u="light",line:g,loading:f="Loading...",options:b={},overrideServices:C={},saveViewState:O=!0,keepCurrentModel:Y=!1,width:Z="100%",height:J="100%",className:K,wrapperProps:Q={},beforeMount:X=D,onMount:y=D,onChange:k,onValidate:z=D}){let[d,p]=(0,a.useState)(!1),[s,N]=(0,a.useState)(!0),v=(0,a.useRef)(null),c=(0,a.useRef)(null),R=(0,a.useRef)(null),F=(0,a.useRef)(y),H=(0,a.useRef)(X),V=(0,a.useRef)(),l=(0,a.useRef)(n),h=Lt(i),be=(0,a.useRef)(!1),ee=(0,a.useRef)(!1);G(()=>{let m=S.init();return m.then(M=>(v.current=M)&&N(!1)).catch(M=>M?.type!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>c.current?Ft():m.cancel()}),w(()=>{let m=P(v.current,e||n||"",t||o||"",i||r||"");m!==c.current?.getModel()&&(O&&_.set(h,c.current?.saveViewState()),c.current?.setModel(m),O&&c.current?.restoreViewState(_.get(i)))},[i],d),w(()=>{c.current?.updateOptions(b)},[b],d),w(()=>{!c.current||n===void 0||(c.current.getOption(v.current.editor.EditorOption.readOnly)?c.current.setValue(n):n!==c.current.getValue()&&(ee.current=!0,c.current.executeEdits("",[{range:c.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),c.current.pushUndoStop(),ee.current=!1))},[n],d),w(()=>{let m=c.current?.getModel();m&&o&&v.current?.editor.setModelLanguage(m,o)},[o],d),w(()=>{g!==void 0&&c.current?.revealLine(g)},[g],d),w(()=>{v.current?.editor.setTheme(u)},[u],d);let ye=(0,a.useCallback)(()=>{if(!(!R.current||!v.current)&&!be.current){H.current(v.current);let m=i||r,M=P(v.current,n||e||"",t||o||"",m||"");c.current=v.current?.editor.create(R.current,{model:M,automaticLayout:!0,...b},C),O&&c.current.restoreViewState(_.get(m)),v.current.editor.setTheme(u),p(!0),be.current=!0}},[e,t,r,n,o,i,b,C,O,u]);(0,a.useEffect)(()=>{d&&F.current(c.current,v.current)},[d]),(0,a.useEffect)(()=>{!s&&!d&&ye()},[s,d,ye]),l.current=n,(0,a.useEffect)(()=>{d&&k&&(V.current?.dispose(),V.current=c.current?.onDidChangeModelContent(m=>{ee.current||k(c.current.getValue(),m)}))},[d,k]),(0,a.useEffect)(()=>{if(d){let m=v.current.editor.onDidChangeMarkers(M=>{let te=c.current.getModel()?.uri;if(te&&M.find(re=>re.path===te.path)){let re=v.current.editor.getModelMarkers({resource:te});z?.(re)}});return()=>{m?.dispose()}}return()=>{}},[d,z]);function Ft(){V.current?.dispose(),Y?O&&_.set(i,c.current.saveViewState()):c.current.getModel()?.dispose(),c.current.dispose()}return a.createElement(pe,{width:Z,height:J,isEditorReady:d,loading:f,_ref:R,className:K,wrapperProps:Q})}var kt=Dt,zt=(0,a.memo)(kt),Nt=zt,Vt=T(66310),xt=T(71685);function Bt(e){if(e===void 0)return{};{const t={"editor.background":e.components.input.background,"minimap.background":e.colors.background.secondary};return Object.keys(t).forEach(r=>{t[r]=E(t[r])}),t}}function E(e){return(0,xt.Z)(e).toHexString()}function ve(e,t){const r=Bt(t);e.editor.defineTheme("grafana-dark",{base:"vs-dark",inherit:!0,colors:r,rules:[{token:"predefined",foreground:E(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:E(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:E(t?.visualization.getColorByName("green"))}]}),e.editor.defineTheme("grafana-light",{base:"vs",inherit:!0,colors:r,rules:[{token:"predefined",foreground:E(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:E(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:E(t?.visualization.getColorByName("green"))}]})}let me=!1;function Ut(){me||(S.config({paths:{vs:(window.__grafana_public_path__??"public/")+"lib/monaco/min/vs"}}),me=!0,S.init().then(e=>{ve(e)}))}const _t=e=>{const t=(0,Vt.l4)(),r=It();(0,a.useEffect)(()=>{r!=null&&ve(r,t)},[r,t]),Ut();const n=t.isDark?"grafana-dark":"grafana-light";return a.createElement(Nt,{theme:n,...e})}}}]);

//# sourceMappingURL=react-monaco-editor.7c9215f40e5d86e0aeaa.js.map