import{r as a,W as P}from"./index.3e026b47.js";function me(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){me(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 be(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 we(e,t){if(e==null)return{};var r=be(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 ye(e,t){return Oe(e)||je(e,t)||Me(e,t)||xe()}function Oe(e){if(Array.isArray(e))return e}function je(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,o=!1,i=void 0;try{for(var c=e[Symbol.iterator](),p;!(n=(p=c.next()).done)&&(r.push(p.value),!(t&&r.length===t));n=!0);}catch(f){o=!0,i=f}finally{try{!n&&c.return!=null&&c.return()}finally{if(o)throw i}}return r}}function Me(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 xe(){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 Ee(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){Ee(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 Se(){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 A(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 c=arguments.length,p=new Array(c),f=0;f<c;f++)p[f]=arguments[f];return t.apply(r,[].concat(o,p))}}}function z(e){return{}.toString.call(e).includes("Object")}function Pe(e){return!Object.keys(e).length}function D(e){return typeof e=="function"}function Re(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ie(e,t){return z(t)||M("changeType"),Object.keys(t).some(function(r){return!Re(e,r)})&&M("changeField"),t}function Ce(e){D(e)||M("selectorType")}function Te(e){D(e)||z(e)||M("handlerType"),z(e)&&Object.values(e).some(function(t){return!D(t)})&&M("handlersType")}function Ae(e){e||M("initialIsRequired"),z(e)||M("initialType"),Pe(e)&&M("initialContent")}function Le(e,t){throw new Error(e[t]||e.default)}var De={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"},M=A(Le)(De),U={changes:Ie,selector:Ce,handler:Te,initial:Ae};function $e(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};U.initial(e),U.handler(t);var r={current:e},n=A(Ue)(r,t),o=A(Ne)(r),i=A(U.changes)(e),c=A(Ve)(r);function p(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(x){return x};return U.selector(b),b(r.current)}function f(b){Se(n,o,i,c)(b)}return[p,f]}function Ve(e,t){return D(t)?t(e.current):t}function Ne(e,t){return e.current=ce(ce({},e.current),t),t}function Ue(e,t,r){return D(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 qe={create:$e},ze={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.36.1/min/vs"}};function Fe(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 c=arguments.length,p=new Array(c),f=0;f<c;f++)p[f]=arguments[f];return t.apply(r,[].concat(o,p))}}}function We(e){return{}.toString.call(e).includes("Object")}function He(e){return e||se("configIsRequired"),We(e)||se("configType"),e.urls?(Be(),{paths:{vs:e.urls.monacoBase}}):e}function Be(){console.warn(le.deprecation)}function Ge(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=Fe(Ge)(le),Ke={config:He},Ye=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,c){return c(i)},o)}};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)}var _e={type:"cancelation",msg:"operation is manually canceled"};function Z(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(_e):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var Je=qe.create({config:ze,isInitialized:!1,resolve:null,reject:null,monaco:null}),de=ye(Je,2),$=de[0],W=de[1];function Qe(e){var t=Ke.config(e),r=t.monaco,n=we(t,["monaco"]);W(function(o){return{config:fe(o.config,n),monaco:r}})}function Xe(){var e=$(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(W({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Z(k);if(window.monaco&&window.monaco.editor)return pe(window.monaco),e.resolve(window.monaco),Z(k);Ye(Ze,et)(tt)}return Z(k)}function Ze(e){return document.body.appendChild(e)}function ke(e){var t=document.createElement("script");return e&&(t.src=e),t}function et(e){var t=$(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=ke("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function tt(){var e=$(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){pe(r),e.resolve(r)},function(r){e.reject(r)})}function pe(e){$().monaco||W({monaco:e})}function rt(){return $(function(e){var t=e.monaco;return t})}var k=new Promise(function(e,t){return W({resolve:e,reject:t})}),nt={config:Qe,init:Xe,__getMonacoInstance:rt};const F=nt;var ot={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ee=ot,it={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},at=it;function ut({children:e}){return P.createElement("div",{style:at.container},e)}var ct=ut,st=ct;function lt({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:c}){return P.createElement("section",{style:{...ee.wrapper,width:e,height:t},...c},!r&&P.createElement(st,null,n),P.createElement("div",{ref:o,style:{...ee.fullWidth,...!r&&ee.hide},className:i}))}var ft=lt,ge=a.exports.memo(ft);function dt(e){a.exports.useEffect(e,[])}var te=dt;function pt(e,t,r=!0){let n=a.exports.useRef(!0);a.exports.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var y=pt;function L(){}function S(e,t,r,n){return gt(e,n)||ht(e,t,r,n)}function gt(e,t){return e.editor.getModel(he(e,t))}function ht(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 vt({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:p=!1,keepCurrentModifiedModel:f=!1,theme:b="light",loading:x="Loading...",options:O={},height:H="100%",width:B="100%",className:G,wrapperProps:K={},beforeMount:Y=L,onMount:_=L}){let[w,R]=a.exports.useState(!1),[I,d]=a.exports.useState(!0),g=a.exports.useRef(null),l=a.exports.useRef(null),C=a.exports.useRef(null),v=a.exports.useRef(_),u=a.exports.useRef(Y),E=a.exports.useRef(!1);te(()=>{let s=F.init();return s.then(h=>(l.current=h)&&d(!1)).catch(h=>h?.type!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>g.current?T():s.cancel()}),y(()=>{let s=g.current.getModifiedEditor();s.getOption(l.current.editor.EditorOption.readOnly)?s.setValue(t||""):t!==s.getValue()&&(s.executeEdits("",[{range:s.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),s.pushUndoStop())},[t],w),y(()=>{g.current?.getModel()?.original.setValue(e||"")},[e],w),y(()=>{let{original:s,modified:h}=g.current.getModel();l.current.editor.setModelLanguage(s,n||r||"text"),l.current.editor.setModelLanguage(h,o||r||"text")},[r,n,o],w),y(()=>{l.current?.editor.setTheme(b)},[b],w),y(()=>{g.current?.updateOptions(O)},[O],w);let V=a.exports.useCallback(()=>{if(!l.current)return;u.current(l.current);let s=S(l.current,e||"",n||r||"text",i||""),h=S(l.current,t||"",o||r||"text",c||"");g.current?.setModel({original:s,modified:h})},[r,t,o,e,n,i,c]),N=a.exports.useCallback(()=>{!E.current&&C.current&&(g.current=l.current.editor.createDiffEditor(C.current,{automaticLayout:!0,...O}),V(),l.current?.editor.setTheme(b),R(!0),E.current=!0)},[O,b,V]);a.exports.useEffect(()=>{w&&v.current(g.current,l.current)},[w]),a.exports.useEffect(()=>{!I&&!w&&N()},[I,w,N]),y(()=>{if(g.current&&l.current){let s=g.current.getOriginalEditor(),h=S(l.current,e||"",n||r||"text",i||"");h!==s.getModel()&&s.setModel(h)}},[i],w),y(()=>{if(g.current&&l.current){let s=g.current.getModifiedEditor(),h=S(l.current,t||"",o||r||"text",c||"");h!==s.getModel()&&s.setModel(h)}},[c],w);function T(){let s=g.current?.getModel();p||s?.original?.dispose(),f||s?.modified?.dispose(),g.current?.dispose()}return P.createElement(ge,{width:B,height:H,isEditorReady:w,loading:x,_ref:C,className:G,wrapperProps:K})}var mt=vt,Et=a.exports.memo(mt);function bt(){let[e,t]=a.exports.useState(F.__getMonacoInstance());return te(()=>{let r;return e||(r=F.init(),r.then(n=>{t(n)})),()=>r?.cancel()}),e}var St=bt;function wt(e){let t=a.exports.useRef();return a.exports.useEffect(()=>{t.current=e},[e]),t.current}var yt=wt,q=new Map;function Ot({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:c="light",line:p,loading:f="Loading...",options:b={},overrideServices:x={},saveViewState:O=!0,keepCurrentModel:H=!1,width:B="100%",height:G="100%",className:K,wrapperProps:Y={},beforeMount:_=L,onMount:w=L,onChange:R,onValidate:I=L}){let[d,g]=a.exports.useState(!1),[l,C]=a.exports.useState(!0),v=a.exports.useRef(null),u=a.exports.useRef(null),E=a.exports.useRef(null),V=a.exports.useRef(w),N=a.exports.useRef(_),T=a.exports.useRef(),s=a.exports.useRef(n),h=yt(i),re=a.exports.useRef(!1),J=a.exports.useRef(!1);te(()=>{let m=F.init();return m.then(j=>(v.current=j)&&C(!1)).catch(j=>j?.type!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>u.current?ve():m.cancel()}),y(()=>{let m=S(v.current,e||n||"",t||o||"",i||r||"");m!==u.current?.getModel()&&(O&&q.set(h,u.current?.saveViewState()),u.current?.setModel(m),O&&u.current?.restoreViewState(q.get(i)))},[i],d),y(()=>{u.current?.updateOptions(b)},[b],d),y(()=>{!u.current||n===void 0||(u.current.getOption(v.current.editor.EditorOption.readOnly)?u.current.setValue(n):n!==u.current.getValue()&&(J.current=!0,u.current.executeEdits("",[{range:u.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),u.current.pushUndoStop(),J.current=!1))},[n],d),y(()=>{let m=u.current?.getModel();m&&o&&v.current?.editor.setModelLanguage(m,o)},[o],d),y(()=>{p!==void 0&&u.current?.revealLine(p)},[p],d),y(()=>{v.current?.editor.setTheme(c)},[c],d);let ne=a.exports.useCallback(()=>{if(!(!E.current||!v.current)&&!re.current){N.current(v.current);let m=i||r,j=S(v.current,n||e||"",t||o||"",m||"");u.current=v.current?.editor.create(E.current,{model:j,automaticLayout:!0,...b},x),O&&u.current.restoreViewState(q.get(m)),v.current.editor.setTheme(c),g(!0),re.current=!0}},[e,t,r,n,o,i,b,x,O,c]);a.exports.useEffect(()=>{d&&V.current(u.current,v.current)},[d]),a.exports.useEffect(()=>{!l&&!d&&ne()},[l,d,ne]),s.current=n,a.exports.useEffect(()=>{d&&R&&(T.current?.dispose(),T.current=u.current?.onDidChangeModelContent(m=>{J.current||R(u.current.getValue(),m)}))},[d,R]),a.exports.useEffect(()=>{if(d){let m=v.current.editor.onDidChangeMarkers(j=>{let Q=u.current.getModel()?.uri;if(Q&&j.find(X=>X.path===Q.path)){let X=v.current.editor.getModelMarkers({resource:Q});I?.(X)}});return()=>{m?.dispose()}}return()=>{}},[d,I]);function ve(){T.current?.dispose(),H?O&&q.set(i,u.current.saveViewState()):u.current.getModel()?.dispose(),u.current.dispose()}return P.createElement(ge,{width:B,height:G,isEditorReady:d,loading:f,_ref:E,className:K,wrapperProps:Y})}var jt=Ot,Mt=a.exports.memo(jt),Pt=Mt;export{Et as DiffEditor,Mt as Editor,Pt as default,F as loader,St as useMonaco};
//# sourceMappingURL=index.3570819b.js.map
