import{m as w,W as E,B as H,P as d,j as B,n as F}from"./index-97b4652c.js";import{E as f,H as Z,s as O,t as n,a as P,b as $,i as D,k as T,c as A,S as J,j as L,d as q}from"./codemirror-0a1db0c7.js";import"./vuetify-52f40ce5.js";import"./overlayscrollbars-44d87bcf.js";import"./echarts-9bc570b0.js";function k(){return k=Object.assign?Object.assign.bind():function(i){for(var e=1;e{var{theme:e,settings:r={},styles:t=[]}=i,o={".cm-gutters":{}},a={};r.background&&(a.backgroundColor=r.background),r.backgroundImage&&(a.backgroundImage=r.backgroundImage),r.foreground&&(a.color=r.foreground),(r.background||r.foreground)&&(o["&"]=a),r.fontFamily&&(o["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(o[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(o[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(o[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(o[".cm-content"]={caretColor:r.caret},o[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var s={};r.gutterActiveForeground&&(s.color=r.gutterActiveForeground),r.lineHighlight&&(o[".cm-activeLine"]={backgroundColor:r.lineHighlight},s.backgroundColor=r.lineHighlight),o[".cm-activeLineGutter"]=s,r.selection&&(o["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(o["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var g=f.theme(o,{dark:e==="dark"}),h=Z.define(t),m=[g,O(h)];return m},W={background:"#1e1e1e",foreground:"#9cdcfe",caret:"#c6c6c6",selection:"#6199ff2f",selectionMatch:"#72a1ff59",lineHighlight:"#ffffff0f",gutterBackground:"#1e1e1e",gutterForeground:"#838383",gutterActiveForeground:"#fff",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace'};function R(i){var{theme:e="dark",settings:r={},styles:t=[]}=i||{};return I({theme:e,settings:k({},W,r),styles:[{tag:[n.keyword,n.operatorKeyword,n.modifier,n.color,n.constant(n.name),n.standard(n.name),n.standard(n.tagName),n.special(n.brace),n.atom,n.bool,n.special(n.variableName)],color:"#569cd6"},{tag:[n.controlKeyword,n.moduleKeyword],color:"#c586c0"},{tag:[n.name,n.deleted,n.character,n.macroName,n.propertyName,n.variableName,n.labelName,n.definition(n.name)],color:"#9cdcfe"},{tag:n.heading,fontWeight:"bold",color:"#9cdcfe"},{tag:[n.typeName,n.className,n.tagName,n.number,n.changed,n.annotation,n.self,n.namespace],color:"#4ec9b0"},{tag:[n.function(n.variableName),n.function(n.propertyName)],color:"#dcdcaa"},{tag:[n.number],color:"#b5cea8"},{tag:[n.operator,n.punctuation,n.separator,n.url,n.escape,n.regexp],color:"#d4d4d4"},{tag:[n.regexp],color:"#d16969"},{tag:[n.special(n.string),n.processingInstruction,n.string,n.inserted],color:"#ce9178"},{tag:[n.angleBracket],color:"#808080"},{tag:n.strong,fontWeight:"bold"},{tag:n.emphasis,fontStyle:"italic"},{tag:n.strikethrough,textDecoration:"line-through"},{tag:[n.meta,n.comment],color:"#6a9955"},{tag:n.link,color:"#6a9955",textDecoration:"underline"},{tag:n.invalid,color:"#ff0000"},...t]})}var K=R();const b={token:function(i,e,r=0){const t=i.peek();if(i.pos===r&&e.klipperMacro&&(e.klipperMacro=!1),i.pos>r&&e.klipperMacro){if(i.eatSpace(),i.match(/^{/))return"tag";if(i.match(/^"[^{]+"/)||i.match(/^'[^{]+'/))return"string";if(i.match(/^[-+]?[0-9]*\.?[0-9]+/))return"number";if(i.match(/^[A-Za-z\d_]+/))return"propertyName";if(r===0&&i.match(/^{[^%]+}/))return"variable"}if([";"].includes(t!=null?t:""))return i.skipToEnd(),"comment";const o=i.pos==r;return o&&i.match(/_?[GMgm][\d.]+/)?"namespace":i.string.substring(r).toLowerCase().startsWith("m117")?(i.skipToEnd(),"string"):i.pos>r&&i.match(/[EPXYZIJ]-?([\d]*\.[\d]+|[\d]+)?/i)?"className":i.pos>r&&i.match(/[Ff]-?([\d]*\.[\d]+|[\d]+)?/)?"string":i.pos>r&&i.match(/[TtSs]-?([\d]*\.[\d]+|[\d]+)?/)?"atom":r===0&&i.pos>r&&i.match(/^{[^%]+}/)?"propertyName":o&&i.match(/^\s*[A-Z_\d]+/)?(e.klipperMacro=!0,"name"):(i.next(),null)},startState:function(){return{klipperMacro:!1}},languageData:{commentTokens:{line:";"}}},V={token:function(i,e){var j,x;const r=["\\+","-","\\/\\/","\\/","%","\\*\\*","\\*","\\(","\\)","==","!=",">=",">","<=","<","=","\\|","~",","],t=new RegExp("^"+r.join("|")),o=["elif","else","endif","if","endfor","for","loop\\.index","loop\\.revindex","loop\\.first","loop\\.last","loop\\.length","loop\\.cycle","loop\\.depth","and","or","not","in","is","endmacro","macro","endcall","call","endfilter","filter","endset","set","extends","block","endblock","include","import","do"],a=["abs","attr","batch","capitalize","center","default","dictsort","escape","filesizeformat","first","float","forceescape","format","groupby","indent","int","join","last","length","list","lower","map","max","min","pprint","random","reject","rejectattr","replace","reverse","round","tojson","safe","select","selectattr","slice","sort","string","striptags","sum","title","trim","truncate","unique","upper","urlencode","urlize","wordcount","wordwrap","xmlattr"],s=["callable","defined","divisibleby","equalto","escaped","even","iterable","lower","mapping","none","number","odd","sameas","sequence","string","undefined","upper"],g=["range","lipsum","dict","cycler","joiner"],h=["\\.reset\\(\\)","\\.next\\(\\)"],m=new RegExp("^"+o.join("\\s+|")+"|"+h.join("|")+"\\s+"),C=new RegExp("^"+a.join("|")+"|"+s.join("|")+"|"+g.join("|")+"\\s+");function v(c){var S;const y=c.match(/^%}/),_=c.match(/^}/);function M(){return e.klipperMacroJinjaBraceStack.length===0&&e.klipperMacroJinjaPctStack.length===0}return y||_?(y?(e.klipperMacroJinjaPctStack.pop(),M()&&(e.klipperMacroJinja=!1)):(e.klipperMacroJinjaBraceStack.pop(),M()&&(e.klipperMacroJinja=!1)),c.eatSpace(),e.gcodeZeroPos=c.pos,"tag"):c.match(new RegExp("^((?{for(var o=t>1?void 0:t?U(e,r):e,a=i.length-1,s;a>=0;a--)(s=i[a])&&(o=(t?s(e,r,o):s(o))||o);return t&&o&&G(e,r,o),o};let u=class extends w(H){constructor(){super(...arguments),this.content="",this.codemirror=null,this.cminstance=null}valueChanged(e){var t,o;const r=(o=(t=this.cminstance)==null?void 0:t.state)==null?void 0:o.doc.toString();e!==r&&this.setCmValue(e)}mounted(){this.initialize()}beforeDestroy(){this.destroy()}destroy(){var e;(e=this.cminstance)==null||e.destroy()}initialize(){this.codemirror=new f({parent:this.$refs.codemirror}),this.cminstance=this.codemirror,this.$nextTick(()=>{this.setCmValue(this.code||this.value||this.content),this.$emit("ready",this.codemirror)})}setCmValue(e){var r;(r=this.cminstance)==null||r.setState(P.create({doc:e,extensions:this.cmExtensions}))}get cmExtensions(){const e=[f.theme({},{dark:!0}),$,K,D.of(" ".repeat(this.tabSize)),T.of([A]),f.updateListener.of(r=>{var t;this.content=(t=r.state)==null?void 0:t.doc.toString(),this.$emit&&this.$emit("input",this.content)})];return["cfg","conf"].includes(this.fileExtension)?e.push(J.define(V)):["gcode"].includes(this.fileExtension)?e.push(J.define(b)):["json"].includes(this.fileExtension)?e.push(L()):["css","scss","sass"].includes(this.fileExtension)&&e.push(q()),e}visibilityChanged(e){var r;e&&((r=this.cminstance)==null||r.focus())}get tabSize(){return this.$store.state.gui.editor.tabSize||2}};p([d({required:!1,default:""})],u.prototype,"code",2);p([d({required:!1,default:""})],u.prototype,"value",2);p([d({required:!1,default:"codemirror"})],u.prototype,"name",2);p([d({required:!1,default:""})],u.prototype,"fileExtension",2);p([E("value")],u.prototype,"valueChanged",1);u=p([B],u);var z=function(){var i=this,e=i.$createElement,r=i._self._c||e;return r("div",{staticClass:"vue-codemirror"},[r("div",{directives:[{name:"observe-visibility",rawName:"v-observe-visibility",value:i.visibilityChanged,expression:"visibilityChanged"}],ref:"codemirror"})])},X=[];const N={};var Y=F(u,z,X,!1,Q,null,null,null);function Q(i){for(let e in N)this[e]=N[e]}const ce=function(){return Y.exports}();export{ce as default};