"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4463],{84463($t,ne,E){E.r(ne),E.d(ne,{ReactMonacoEditor:()=>Ut});var we=E(14553);function Oe(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){Oe(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 je(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 Me(e,t){if(e==null)return{};var r=je(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 Ee(e,t){return Se(e)||Pe(e,t)||Ce(e,t)||Re()}function Se(e){if(Array.isArray(e))return e}function Pe(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](),s;!(n=(s=u.next()).done)&&(r.push(s.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 Ce(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 Re(){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 Ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ue(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 ce(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ue(Object(r),!0).forEach(function(n){Ie(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ue(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,s=new Array(u),f=0;f<u;f++)s[f]=arguments[f];return t.apply(r,[].concat(o,s))}}}function V(e){return{}.toString.call(e).includes("Object")}function Ae(e){return!Object.keys(e).length}function T(e){return typeof e=="function"}function Le(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ke(e,t){return V(t)||j("changeType"),Object.keys(t).some(function(r){return!Le(e,r)})&&j("changeField"),t}function De(e){T(e)||j("selectorType")}function ze(e){T(e)||V(e)||j("handlerType"),V(e)&&Object.values(e).some(function(t){return!T(t)})&&j("handlersType")}function Ne(e){e||j("initialIsRequired"),V(e)||j("initialType"),Ae(e)&&j("initialContent")}function Ve(e,t){throw new Error(e[t]||e.default)}var xe={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(Ve)(xe),x={changes:ke,selector:De,handler:ze,initial:Ne};function Fe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};x.initial(e),x.handler(t);var r={current:e},n=I(He)(r,t),o=I(Ue)(r),i=I(x.changes)(e),u=I(Be)(r);function s(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(C){return C};return x.selector(b),b(r.current)}function f(b){Te(n,o,i,u)(b)}return[s,f]}function Be(e,t){return T(t)?t(e.current):t}function Ue(e,t){return e.current=ce(ce({},e.current),t),t}function He(e,t,r){return T(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 $e={create:Fe};const We=$e;var qe={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}};const Ge=qe;function Ye(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,s=new Array(u),f=0;f<u;f++)s[f]=arguments[f];return t.apply(r,[].concat(o,s))}}}const Je=Ye;function Ke(e){return{}.toString.call(e).includes("Object")}const Qe=Ke;function Xe(e){return e||se("configIsRequired"),Qe(e)||se("configType"),e.urls?(Ze(),{paths:{vs:e.urls.monacoBase}}):e}function Ze(){console.warn(le.deprecation)}function _e(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=Je(_e)(le),et={config:Xe};const tt=et;var rt=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 nt=rt;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 ot=fe;var it={type:"cancelation",msg:"operation is manually canceled"};function at(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(it):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}const $=at;var ut=We.create({config:Ge,isInitialized:!1,resolve:null,reject:null,monaco:null}),de=Ee(ut,2),A=de[0],F=de[1];function ct(e){var t=tt.config(e),r=t.monaco,n=Me(t,["monaco"]);F(function(o){return{config:ot(o.config,n),monaco:r}})}function lt(){var e=A(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(F({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);nt(st,dt)(gt)}return $(W)}function st(e){return document.body.appendChild(e)}function ft(e){var t=document.createElement("script");return e&&(t.src=e),t}function dt(e){var t=A(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=ft("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function gt(){var e=A(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){A().monaco||F({monaco:e})}function pt(){return A(function(e){var t=e.monaco;return t})}var W=new Promise(function(e,t){return F({resolve:e,reject:t})}),vt={config:ct,init:lt,__getMonacoInstance:pt};const q=vt;var a=E(55501),ht,pe,mt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},G=mt,bt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},yt=bt;function wt({children:e}){return a.createElement("div",{style:yt.container},e)}var Ot=wt,jt=Ot;function Mt({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:u}){return a.createElement("section",{style:{...G.wrapper,width:e,height:t},...u},!r&&a.createElement(jt,null,n),a.createElement("div",{ref:o,style:{...G.fullWidth,...!r&&G.hide},className:i}))}var Et=Mt,ve=(0,a.memo)(Et);function St(e){(0,a.useEffect)(e,[])}var Y=St;function Pt(e,t,r=!0){let n=(0,a.useRef)(!0);(0,a.useEffect)(n.current||!r?()=>{n.current=!1}:e,t)}var w=Pt;function L(){}function P(e,t,r,n){return Ct(e,n)||Rt(e,t,r,n)}function Ct(e,t){return e.editor.getModel(he(e,t))}function Rt(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 It({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:u,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:f=!1,theme:b="light",loading:C="Loading...",options:O={},height:J="100%",width:K="100%",className:Q,wrapperProps:X={},beforeMount:Z=L,onMount:_=L}){let[y,k]=(0,a.useState)(!1),[D,g]=(0,a.useState)(!0),p=(0,a.useRef)(null),d=(0,a.useRef)(null),z=(0,a.useRef)(null),h=(0,a.useRef)(_),c=(0,a.useRef)(Z),R=(0,a.useRef)(!1);Y(()=>{let l=q.init();return l.then(v=>(d.current=v)&&g(!1)).catch(v=>v?.type!=="cancelation"&&console.error("Monaco initialization: error:",v)),()=>p.current?N():l.cancel()}),w(()=>{if(p.current&&d.current){let l=p.current.getOriginalEditor(),v=P(d.current,e||"",n||r||"text",i||"");v!==l.getModel()&&l.setModel(v)}},[i],y),w(()=>{if(p.current&&d.current){let l=p.current.getModifiedEditor(),v=P(d.current,t||"",o||r||"text",u||"");v!==l.getModel()&&l.setModel(v)}},[u],y),w(()=>{let l=p.current.getModifiedEditor();l.getOption(d.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:v}=p.current.getModel();d.current.editor.setModelLanguage(l,n||r||"text"),d.current.editor.setModelLanguage(v,o||r||"text")},[r,n,o],y),w(()=>{d.current?.editor.setTheme(b)},[b],y),w(()=>{p.current?.updateOptions(O)},[O],y);let U=(0,a.useCallback)(()=>{if(!d.current)return;c.current(d.current);let l=P(d.current,e||"",n||r||"text",i||""),v=P(d.current,t||"",o||r||"text",u||"");p.current?.setModel({original:l,modified:v})},[r,t,o,e,n,i,u]),H=(0,a.useCallback)(()=>{!R.current&&z.current&&(p.current=d.current.editor.createDiffEditor(z.current,{automaticLayout:!0,...O}),U(),d.current?.editor.setTheme(b),k(!0),R.current=!0)},[O,b,U]);(0,a.useEffect)(()=>{y&&h.current(p.current,d.current)},[y]),(0,a.useEffect)(()=>{!D&&!y&&H()},[D,y,H]);function N(){let l=p.current?.getModel();s||l?.original?.dispose(),f||l?.modified?.dispose(),p.current?.dispose()}return a.createElement(ve,{width:K,height:J,isEditorReady:y,loading:C,_ref:z,className:Q,wrapperProps:X})}var Tt=It,Wt=(0,a.memo)(Tt);function qt(){let[e,t]=ht(pe.__getMonacoInstance());return Y(()=>{let r;return e||(r=pe.init(),r.then(n=>{t(n)})),()=>r?.cancel()}),e}var Gt=null;function At(e){let t=(0,a.useRef)();return(0,a.useEffect)(()=>{t.current=e},[e]),t.current}var Lt=At,B=new Map;function kt({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:u="light",line:s,loading:f="Loading...",options:b={},overrideServices:C={},saveViewState:O=!0,keepCurrentModel:J=!1,width:K="100%",height:Q="100%",className:X,wrapperProps:Z={},beforeMount:_=L,onMount:y=L,onChange:k,onValidate:D=L}){let[g,p]=(0,a.useState)(!1),[d,z]=(0,a.useState)(!0),h=(0,a.useRef)(null),c=(0,a.useRef)(null),R=(0,a.useRef)(null),U=(0,a.useRef)(y),H=(0,a.useRef)(_),N=(0,a.useRef)(),l=(0,a.useRef)(n),v=Lt(i),be=(0,a.useRef)(!1),ee=(0,a.useRef)(!1);Y(()=>{let m=q.init();return m.then(M=>(h.current=M)&&z(!1)).catch(M=>M?.type!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>c.current?Ht():m.cancel()}),w(()=>{let m=P(h.current,e||n||"",t||o||"",i||r||"");m!==c.current?.getModel()&&(O&&B.set(v,c.current?.saveViewState()),c.current?.setModel(m),O&&c.current?.restoreViewState(B.get(i)))},[i],g),w(()=>{c.current?.updateOptions(b)},[b],g),w(()=>{!c.current||n===void 0||(c.current.getOption(h.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],g),w(()=>{let m=c.current?.getModel();m&&o&&h.current?.editor.setModelLanguage(m,o)},[o],g),w(()=>{s!==void 0&&c.current?.revealLine(s)},[s],g),w(()=>{h.current?.editor.setTheme(u)},[u],g);let ye=(0,a.useCallback)(()=>{if(!(!R.current||!h.current)&&!be.current){H.current(h.current);let m=i||r,M=P(h.current,n||e||"",t||o||"",m||"");c.current=h.current?.editor.create(R.current,{model:M,automaticLayout:!0,...b},C),O&&c.current.restoreViewState(B.get(m)),h.current.editor.setTheme(u),s!==void 0&&c.current.revealLine(s),p(!0),be.current=!0}},[e,t,r,n,o,i,b,C,O,u,s]);(0,a.useEffect)(()=>{g&&U.current(c.current,h.current)},[g]),(0,a.useEffect)(()=>{!d&&!g&&ye()},[d,g,ye]),l.current=n,(0,a.useEffect)(()=>{g&&k&&(N.current?.dispose(),N.current=c.current?.onDidChangeModelContent(m=>{ee.current||k(c.current.getValue(),m)}))},[g,k]),(0,a.useEffect)(()=>{if(g){let m=h.current.editor.onDidChangeMarkers(M=>{let te=c.current.getModel()?.uri;if(te&&M.find(re=>re.path===te.path)){let re=h.current.editor.getModelMarkers({resource:te});D?.(re)}});return()=>{m?.dispose()}}return()=>{}},[g,D]);function Ht(){N.current?.dispose(),J?O&&B.set(i,c.current.saveViewState()):c.current.getModel()?.dispose(),c.current.dispose()}return a.createElement(ve,{width:K,height:Q,isEditorReady:g,loading:f,_ref:R,className:X,wrapperProps:Z})}var Dt=kt,zt=(0,a.memo)(Dt),Nt=zt,me=E(10858),Vt=E(63142),xt=E(84140);function Ft(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]=S(t[r])}),t}}function S(e){return(0,xt.A)(e).toHexString()}function Bt(e,t){const r=Ft(t);e.editor.defineTheme("grafana-dark",{base:"vs-dark",inherit:!0,colors:r,rules:[{token:"predefined",foreground:S(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:S(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:S(t?.visualization.getColorByName("green"))}]}),e.editor.defineTheme("grafana-light",{base:"vs",inherit:!0,colors:r,rules:[{token:"predefined",foreground:S(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:S(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:S(t?.visualization.getColorByName("green"))}]})}q.config({monaco:me});const Ut=e=>{const{beforeMount:t,onMount:r,options:n,...o}=e,i=(0,Vt.$j)(),u=(0,a.useCallback)(s=>{t?.(s)},[t]);return(0,a.useEffect)(()=>{Bt(me,i)},[i]),(0,we.jsx)(Nt,{...o,options:{...n,fontFamily:i.typography.code.fontFamily},theme:i.isDark?"grafana-dark":"grafana-light",beforeMount:u,onMount:(s,f)=>{document.fonts.ready.then(()=>{f.editor.remeasureFonts()}),r?.(s,f)}})}}}]);

//# sourceMappingURL=4463-react19.b3842877c3b151ecbecf.js.map