UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

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