Current section
Files
Jump to
Current section
Files
priv/static/live_monaco_editor.min.js
var LiveMonacoEditor=(()=>{var v=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var V=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})},Y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of G(t))!J.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(n=K(t,o))||n.enumerable});return e};var Q=e=>Y(v({},"__esModule",{value:!0}),e);var He={};V(He,{CodeEditorHook:()=>F});function X(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(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 y(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?S(Object(r),!0).forEach(function(n){X(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Z(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 P(e,t){if(e==null)return{};var r=Z(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 A(e,t){return ee(e)||te(e,t)||re(e,t)||ne()}function ee(e){if(Array.isArray(e))return e}function te(e,t){if(!(typeof Symbol=="undefined"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,o=!1,i=void 0;try{for(var a=e[Symbol.iterator](),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(t&&r.length===t));n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return!=null&&a.return()}finally{if(o)throw i}}return r}}function re(e,t){if(e){if(typeof e=="string")return E(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 E(e,t)}}function E(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 ne(){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,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function T(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 I(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?T(Object(r),!0).forEach(function(n){oe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(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 s(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 a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return t.apply(r,[].concat(o,c))}}}function h(e){return{}.toString.call(e).includes("Object")}function ae(e){return!Object.keys(e).length}function f(e){return typeof e=="function"}function ue(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ce(e,t){return h(t)||d("changeType"),Object.keys(t).some(function(r){return!ue(e,r)})&&d("changeField"),t}function de(e){f(e)||d("selectorType")}function se(e){f(e)||h(e)||d("handlerType"),h(e)&&Object.values(e).some(function(t){return!f(t)})&&d("handlersType")}function fe(e){e||d("initialIsRequired"),h(e)||d("initialType"),ae(e)&&d("initialContent")}function le(e,t){throw new Error(e[t]||e.default)}var pe={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"},d=s(le)(pe),g={changes:ce,selector:de,handler:se,initial:fe};function ge(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g.initial(e),g.handler(t);var r={current:e},n=s(be)(r,t),o=s(me)(r),i=s(g.changes)(e),a=s(he)(r);function c(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(N){return N};return g.selector(p),p(r.current)}function u(p){ie(n,o,i,a)(p)}return[c,u]}function he(e,t){return f(t)?t(e.current):t}function me(e,t){return e.current=I(I({},e.current),t),t}function be(e,t,r){return f(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 ve={create:ge},_=ve;var ye={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.36.1/min/vs"}},M=ye;function je(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 a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return t.apply(r,[].concat(o,c))}}}var x=je;function Oe(e){return{}.toString.call(e).includes("Object")}var R=Oe;function we(e){return e||C("configIsRequired"),R(e)||C("configType"),e.urls?(ke(),{paths:{vs:e.urls.monacoBase}}):e}function ke(){console.warn(L.deprecation)}function Se(e,t){throw new Error(e[t]||e.default)}var L={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
`},C=x(Se)(L),Ee={config:we},W=Ee;var Pe=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,a){return a(i)},o)}},q=Pe;function D(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],D(e[r],t[r]))}),y(y({},e),t)}var H=D;var Ae={type:"cancelation",msg:"operation is manually canceled"};function Te(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(Ae):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var m=Te;var Ie=_.create({config:M,isInitialized:!1,resolve:null,reject:null,monaco:null}),B=A(Ie,2),l=B[0],b=B[1];function _e(e){var t=W.config(e),r=t.monaco,n=P(t,["monaco"]);b(function(o){return{config:H(o.config,n),monaco:r}})}function Me(){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(b({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),m(j);if(window.monaco&&window.monaco.editor)return z(window.monaco),e.resolve(window.monaco),m(j);q(xe,Ce)(Le)}return m(j)}function xe(e){return document.body.appendChild(e)}function Re(e){var t=document.createElement("script");return e&&(t.src=e),t}function Ce(e){var t=l(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=Re("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function Le(){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){z(r),e.resolve(r)},function(r){e.reject(r)})}function z(e){l().monaco||b({monaco:e})}function We(){return l(function(e){var t=e.monaco;return t})}var j=new Promise(function(e,t){return b({resolve:e,reject:t})}),qe={config:_e,init:Me,__getMonacoInstance:We},O=qe;var w={background:"#282c34",default:"#c4cad6",lightRed:"#e06c75",blue:"#61afef",gray:"#8c92a3",green:"#98c379",purple:"#c678dd",red:"#be5046",teal:"#56b6c2",peach:"#d19a66"},De=e=>[{token:"",foreground:e.default},{token:"variable",foreground:e.lightRed},{token:"constant",foreground:e.blue},{token:"constant.character.escape",foreground:e.blue},{token:"comment",foreground:e.gray},{token:"number",foreground:e.blue},{token:"regexp",foreground:e.lightRed},{token:"type",foreground:e.lightRed},{token:"string",foreground:e.green},{token:"keyword",foreground:e.purple},{token:"operator",foreground:e.peach},{token:"delimiter.bracket.embed",foreground:e.red},{token:"sigil",foreground:e.teal},{token:"function",foreground:e.blue},{token:"function.call",foreground:e.default},{token:"emphasis",fontStyle:"italic"},{token:"strong",fontStyle:"bold"},{token:"keyword.md",foreground:e.lightRed},{token:"keyword.table",foreground:e.lightRed},{token:"string.link.md",foreground:e.blue},{token:"variable.md",foreground:e.teal},{token:"string.md",foreground:e.default},{token:"variable.source.md",foreground:e.default},{token:"tag",foreground:e.lightRed},{token:"metatag",foreground:e.lightRed},{token:"attribute.name",foreground:e.peach},{token:"attribute.value",foreground:e.green},{token:"string.key",foreground:e.lightRed},{token:"keyword.json",foreground:e.blue},{token:"operator.sql",foreground:e.purple}],$={base:"vs-dark",inherit:!1,rules:De(w),colors:{"editor.background":w.background,"editor.foreground":w.default,"editorLineNumber.foreground":"#636d83","editorCursor.foreground":"#636d83","editor.selectionBackground":"#3e4451","editor.findMatchHighlightBackground":"#528bff3d","editorSuggestWidget.background":"#21252b","editorSuggestWidget.border":"#181a1f","editorSuggestWidget.selectedBackground":"#2c313a","input.background":"#1b1d23","input.border":"#181a1f","editorBracketMatch.border":"#282c34","editorBracketMatch.background":"#3e4451"}};var k=class{constructor(t,r,n,o){this.el=t,this.path=r,this.value=n,this.opts=o,this.standalone_code_editor=null,this._onMount=[]}isMounted(){return!!this.standalone_code_editor}mount(){if(this.isMounted())throw new Error("The monaco editor is already mounted");this._mountEditor()}onMount(t){this._onMount.push(t)}dispose(){if(this.isMounted()){let t=this.standalone_code_editor.getModel();t&&t.dispose(),this.standalone_code_editor.dispose()}}_mountEditor(){this.opts.value=this.value,O.init().then(t=>{t.editor.defineTheme("default",$);let r=t.Uri.parse(this.path),n=this.opts.language,o=t.editor.createModel(this.value,n,r);this.opts.language=void 0,this.opts.model=o,this.standalone_code_editor=t.editor.create(this.el,this.opts),this._onMount.forEach(i=>i(t))})}},U=k;var F={mounted(){let e=JSON.parse(this.el.dataset.opts);this.codeEditor=new U(this.el,this.el.dataset.path,this.el.dataset.value,e),this.codeEditor.onMount(t=>{this.el.dispatchEvent(new CustomEvent("lme:editor_mounted",{detail:{hook:this,editor:this.codeEditor},bubbles:!0})),this.handleEvent("lme:change_language:"+this.el.dataset.path,r=>{let n=this.codeEditor.standalone_code_editor.getModel();n.getLanguageId()!==r.mimeTypeOrLanguageId&&t.editor.setModelLanguage(n,r.mimeTypeOrLanguageId)}),this.handleEvent("lme:set_value:"+this.el.dataset.path,r=>{this.codeEditor.standalone_code_editor.setValue(r.value)}),this.el.querySelectorAll("textarea").forEach(r=>{r.setAttribute("name","live_monaco_editor["+this.el.dataset.path+"]")}),this.el.removeAttribute("data-value"),this.el.removeAttribute("data-opts")}),this.codeEditor.isMounted()||this.codeEditor.mount()},destroyed(){this.codeEditor&&this.codeEditor.dispose()}};return Q(He);})();
//# sourceMappingURL=live_monaco_editor.min.js.map