You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/static/js/async/3617.de2dc8cd.js

2 lines
14 KiB

"use strict";(self.webpackChunk_coze_studio_app=self.webpackChunk_coze_studio_app||[]).push([["3617"],{257073:function(e,t,r){r.r(t),r.d(t,{DiffEditor:function(){return n.DiffEditor},Editor:function(){return n.default}});var n=r(354428)},354428:function(e,t,r){r.r(t),r.d(t,{useMonaco:()=>H,DiffEditor:()=>G,Editor:()=>Q,loader:()=>_,default:()=>X});function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e){return function t(){for(var r=this,n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(r,[].concat(o,n))}}}function l(e){return({}).toString.call(e).includes("Object")}function s(e){return"function"==typeof e}var f,d,g,p=a(function(e,t){throw Error(e[t]||e.default)})({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"}),h=function(e,t){return!l(t)&&p("changeType"),Object.keys(t).some(function(t){var r,n;return r=e,n=t,!Object.prototype.hasOwnProperty.call(r,n)})&&p("changeField"),t},y=function(e){!s(e)&&p("selectorType")},m=function(e){!(s(e)||l(e))&&p("handlerType"),l(e)&&Object.values(e).some(function(e){return!s(e)})&&p("handlersType")},v=function(e){if(!e&&p("initialIsRequired"),!l(e)&&p("initialType"),!Object.keys(e).length)p("initialContent")};function b(e,t){return s(t)?t(e.current):t}function O(e,t){return e.current=u(u({},e.current),t),t}function w(e,t,r){return s(t)?t(e.current):Object.keys(r).forEach(function(r){var n;return null===(n=t[r])||void 0===n?void 0:n.call(t,e.current[r])}),r}var j={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!\n You are using deprecated way of configuration.\n\n Instead of using\n monaco.config({ urls: { monacoBase: '...' } })\n use\n monaco.config({ paths: { vs: '...' } })\n\n For more please check the link https://github.com/suren-atoyan/monaco-loader#config\n "};var M=(f=function(e,t){throw Error(e[t]||e.default)},function e(){for(var t=this,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return n.length>=f.length?f.apply(this,n):function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.apply(t,[].concat(n,o))}})(j),E=function(e){var t;if(!e&&M("configIsRequired"),t=e,!({}).toString.call(t).includes("Object"))M("configType");return e.urls?(function(){console.warn(j.deprecation)}(),{paths:{vs:e.urls.monacoBase}}):e},P=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}},R={type:"cancelation",msg:"operation is manually canceled"},k=function(e){var t=!1,r=new Promise(function(r,n){e.then(function(e){return t?n(R):r(e)}),e.catch(n)});return r.cancel=function(){return t=!0},r};var S=(g=2,function(e){if(Array.isArray(e))return e}(d=({create:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v(e),m(t);var r={current:e},n=a(w)(r,t),o=a(O)(r),i=a(h)(e),c=a(b)(r);return[function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e};return y(e),e(r.current)},function(e){(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}})(n,o,i,c)(e)}]}}).create({config:{paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}},isInitialized:!1,resolve:null,reject:null,monaco:null}))||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var c,u=e[Symbol.iterator]();!(n=(c=u.next()).done)&&(r.push(c.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{!n&&null!=u.return&&u.return()}finally{if(o)throw i}}return r}}(d,2)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}}(d,g)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),C=S[0],I=S[1];function T(e){return document.body.appendChild(e)}function x(e){var t,r,n=C(function(e){return{config:e.config,reject:e.reject}});var o=(t="".concat(n.config.paths.vs,"/loader.js"),r=document.createElement("script"),t&&(r.src=t),r);return o.onload=function(){return e()},o.onerror=n.reject,o}function D(){var e=C(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(t){A(t),e.resolve(t)},function(t){e.reject(t)})}function A(e){!C().monaco&&I({monaco:e})}var V=new Promise(function(e,t){return I({resolve:e,reject:t})}),_={config:function(e){var t=E(e),r=t.monaco,n=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++){if(r=i[n],!(t.indexOf(r)>=0))Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}}return o}(t,["monaco"]);I(function(e){return{config:function e(t,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&t[n]&&Object.assign(r[n],e(t[n],r[n]))}),o(o({},t),r)}(e.config,n),monaco:r}})},init:function(){var e=C(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(I({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),k(V);if(window.monaco&&window.monaco.editor)return A(window.monaco),e.resolve(window.monaco),k(V);P(T,x)(D)}return k(V)},__getMonacoInstance:function(){return C(function(e){return e.monaco})}},L=r("455069"),z={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},q={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"},N=function({children:e}){return L.createElement("div",{style:q},e)},F=(0,L.memo)(function({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:c}){return L.createElement("section",{style:{...z.wrapper,width:e,height:t},...c},!r&&L.createElement(N,null,n),L.createElement("div",{ref:o,style:{...z.fullWidth,...!r&&z.hide},className:i}))}),U=function(e){(0,L.useEffect)(e,[])},B=function(e,t,r=!0){let n=(0,L.useRef)(!0);(0,L.useEffect)(n.current||!r?()=>{n.current=!1}:e,t)};function W(){}function Y(e,t,r,n){return function(e,t){return e.editor.getModel($(e,t))}(e,n)||function(e,t,r,n){return e.editor.createModel(t,r,n?$(e,n):void 0)}(e,t,r,n)}function $(e,t){return e.Uri.parse(t)}var G=(0,L.memo)(function({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:u=!1,keepCurrentModifiedModel:a=!1,theme:l="light",loading:s="Loading...",options:f={},height:d="100%",width:g="100%",className:p,wrapperProps:h={},beforeMount:y=W,onMount:m=W}){let[v,b]=(0,L.useState)(!1),[O,w]=(0,L.useState)(!0),j=(0,L.useRef)(null),M=(0,L.useRef)(null),E=(0,L.useRef)(null),P=(0,L.useRef)(m),R=(0,L.useRef)(y),k=(0,L.useRef)(!1);U(()=>{let e=_.init();return e.then(e=>(M.current=e)&&w(!1)).catch(e=>e?.type!=="cancelation"&&console.error("Monaco initialization: error:",e)),()=>j.current?function(){let e=j.current?.getModel();u||e?.original?.dispose(),a||e?.modified?.dispose(),j.current?.dispose()}():e.cancel()}),B(()=>{if(j.current&&M.current){let t=j.current.getOriginalEditor(),o=Y(M.current,e||"",n||r||"text",i||"");o!==t.getModel()&&t.setModel(o)}},[i],v),B(()=>{if(j.current&&M.current){let e=j.current.getModifiedEditor(),n=Y(M.current,t||"",o||r||"text",c||"");n!==e.getModel()&&e.setModel(n)}},[c],v),B(()=>{let e=j.current.getModifiedEditor();e.getOption(M.current.editor.EditorOption.readOnly)?e.setValue(t||""):t!==e.getValue()&&(e.executeEdits("",[{range:e.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),B(()=>{j.current?.getModel()?.original.setValue(e||"")},[e],v),B(()=>{let{original:e,modified:t}=j.current.getModel();M.current.editor.setModelLanguage(e,n||r||"text"),M.current.editor.setModelLanguage(t,o||r||"text")},[r,n,o],v),B(()=>{M.current?.editor.setTheme(l)},[l],v),B(()=>{j.current?.updateOptions(f)},[f],v);let S=(0,L.useCallback)(()=>{if(!M.current)return;R.current(M.current);let u=Y(M.current,e||"",n||r||"text",i||""),a=Y(M.current,t||"",o||r||"text",c||"");j.current?.setModel({original:u,modified:a})},[r,t,o,e,n,i,c]),C=(0,L.useCallback)(()=>{!k.current&&E.current&&(j.current=M.current.editor.createDiffEditor(E.current,{automaticLayout:!0,...f}),S(),M.current?.editor.setTheme(l),b(!0),k.current=!0)},[f,l,S]);return(0,L.useEffect)(()=>{v&&P.current(j.current,M.current)},[v]),(0,L.useEffect)(()=>{O||v||C()},[O,v,C]),L.createElement(F,{width:g,height:d,isEditorReady:v,loading:s,_ref:E,className:p,wrapperProps:h})}),H=function(){let[e,t]=(0,L.useState)(_.__getMonacoInstance());return U(()=>{let r;return e||(r=_.init()).then(e=>{t(e)}),()=>r?.cancel()}),e},J=function(e){let t=(0,L.useRef)();return(0,L.useEffect)(()=>{t.current=e},[e]),t.current},K=new Map,Q=(0,L.memo)(function({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:c="light",line:u,loading:a="Loading...",options:l={},overrideServices:s={},saveViewState:f=!0,keepCurrentModel:d=!1,width:g="100%",height:p="100%",className:h,wrapperProps:y={},beforeMount:m=W,onMount:v=W,onChange:b,onValidate:O=W}){let[w,j]=(0,L.useState)(!1),[M,E]=(0,L.useState)(!0),P=(0,L.useRef)(null),R=(0,L.useRef)(null),k=(0,L.useRef)(null),S=(0,L.useRef)(v),C=(0,L.useRef)(m),I=(0,L.useRef)(),T=(0,L.useRef)(n),x=J(i),D=(0,L.useRef)(!1),A=(0,L.useRef)(!1);U(()=>{let e=_.init();return e.then(e=>(P.current=e)&&E(!1)).catch(e=>e?.type!=="cancelation"&&console.error("Monaco initialization: error:",e)),()=>R.current?function(){I.current?.dispose(),d?f&&K.set(i,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}():e.cancel()}),B(()=>{let c=Y(P.current,e||n||"",t||o||"",i||r||"");c!==R.current?.getModel()&&(f&&K.set(x,R.current?.saveViewState()),R.current?.setModel(c),f&&R.current?.restoreViewState(K.get(i)))},[i],w),B(()=>{R.current?.updateOptions(l)},[l],w),B(()=>{R.current&&void 0!==n&&(R.current.getOption(P.current.editor.EditorOption.readOnly)?R.current.setValue(n):n===R.current.getValue()||(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[n],w),B(()=>{let e=R.current?.getModel();e&&o&&P.current?.editor.setModelLanguage(e,o)},[o],w),B(()=>{void 0!==u&&R.current?.revealLine(u)},[u],w),B(()=>{P.current?.editor.setTheme(c)},[c],w);let V=(0,L.useCallback)(()=>{if(!(!k.current||!P.current)&&!D.current){C.current(P.current);let a=i||r,d=Y(P.current,n||e||"",t||o||"",a||"");R.current=P.current?.editor.create(k.current,{model:d,automaticLayout:!0,...l},s),f&&R.current.restoreViewState(K.get(a)),P.current.editor.setTheme(c),void 0!==u&&R.current.revealLine(u),j(!0),D.current=!0}},[e,t,r,n,o,i,l,s,f,c,u]);return(0,L.useEffect)(()=>{w&&S.current(R.current,P.current)},[w]),(0,L.useEffect)(()=>{M||w||V()},[M,w,V]),T.current=n,(0,L.useEffect)(()=>{w&&b&&(I.current?.dispose(),I.current=R.current?.onDidChangeModelContent(e=>{A.current||b(R.current.getValue(),e)}))},[w,b]),(0,L.useEffect)(()=>{if(w){let e=P.current.editor.onDidChangeMarkers(e=>{let t=R.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=P.current.editor.getModelMarkers({resource:t});O?.(e)}});return()=>{e?.dispose()}}return()=>{}},[w,O]),L.createElement(F,{width:g,height:p,isEditorReady:w,loading:a,_ref:k,className:h,wrapperProps:y})}),X=Q}}]);
//# sourceMappingURL=3617.de2dc8cd.js.map