@babsey/code-graph 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1730,7 +1730,7 @@ class zs extends Ia {
1730
1730
  return this.graph.getNodesByType(this.type).indexOf(this) ?? -1;
1731
1731
  }
1732
1732
  get idxByVariableNames() {
1733
- return this.graph.getNodesByVariableName(this.state.variableName ?? this._variableName).filter((t) => !t.state.integrated).indexOf(this) ?? -1;
1733
+ return this.graph.getNodesByVariableName(this.state.variableName || this._variableName).filter((t) => !t.state.integrated).indexOf(this) ?? -1;
1734
1734
  }
1735
1735
  get isSelected() {
1736
1736
  return this.graph.selectedNodeIds.includes(this.id);
@@ -2278,7 +2278,7 @@ class Rn {
2278
2278
  * @param data data for render template.
2279
2279
  */
2280
2280
  renderCode(t) {
2281
- this.state.script = ut.render(this.state.template || "", t ?? {});
2281
+ this.state.script = ut.render(this.state.template ?? "", t ?? {});
2282
2282
  }
2283
2283
  }
2284
2284
  class Fh extends Rn {
@@ -5150,7 +5150,7 @@ class sn extends Ya {
5150
5150
  */
5151
5151
  getNodesByVariableName(t) {
5152
5152
  return this.nodes.filter(
5153
- (n) => n.state?.variableName === t
5153
+ (n) => [n.state.variableName, n._variableName].includes(t)
5154
5154
  );
5155
5155
  }
5156
5156
  /**
@@ -1,9 +1,9 @@
1
- (function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@baklavajs/renderer-vue"),require("@baklavajs/core"),require("@vueuse/core"),require("mustache"),require("uuid"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("toposort"),require("@baklavajs/events")):typeof define=="function"&&define.amd?define(["exports","vue","@baklavajs/renderer-vue","@baklavajs/core","@vueuse/core","mustache","uuid","@baklavajs/interface-types","@baklavajs/engine","toposort","@baklavajs/events"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p["@babsey/code-graph"]={},p.vue,p["@baklavajs/renderer-vue"],p["@baklavajs/core"],p["@vueuse/core"],p.mustache,p.uuid,p["@baklavajs/interface-types"],p["@baklavajs/engine"],p.toposort,p["@baklavajs/events"]))})(this,(function(p,r,S,q,Ya,Le,xe,G,he,Ra,Jn){"use strict";const z=(e,t)=>{const n=e.__vccOpts||e;for(const[s,a]of t)n[s]=a;return n},Pa={},Ba={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"};function Va(e,t){return r.openBlock(),r.createElementBlock("svg",Ba,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const Xn=z(Pa,[["render",Va]]),La={},Aa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"};function Ua(e,t){return r.openBlock(),r.createElementBlock("svg",Aa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"},null,-1)])])}const Qn=z(La,[["render",Ua]]),$a={},Wa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"};function Ha(e,t){return r.openBlock(),r.createElementBlock("svg",Wa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z"},null,-1),r.createElementVNode("path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"},null,-1)])])}const es=z($a,[["render",Ha]]),Fa={},Ga={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"};function ja(e,t){return r.openBlock(),r.createElementBlock("svg",Ga,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const ts=z(Fa,[["render",ja]]),za={},Za={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-download"};function qa(e,t){return r.openBlock(),r.createElementBlock("svg",Za,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 11l5 5l5 -5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ns=z(za,[["render",qa]]),Ka={},Ja={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"};function Xa(e,t){return r.openBlock(),r.createElementBlock("svg",Ja,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const Qa=z(Ka,[["render",Xa]]),er={},tr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"};function nr(e,t){return r.openBlock(),r.createElementBlock("svg",tr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const sr=z(er,[["render",nr]]),ar={},rr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function or(e,t){return r.openBlock(),r.createElementBlock("svg",rr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z"},null,-1)])])}const ir=z(ar,[["render",or]]),lr={},dr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"};function cr(e,t){return r.openBlock(),r.createElementBlock("svg",dr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const ss=z(lr,[["render",cr]]),ur={},hr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"};function fr(e,t){return r.openBlock(),r.createElementBlock("svg",hr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const $t=z(ur,[["render",fr]]),pr={},mr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"};function _r(e,t){return r.openBlock(),r.createElementBlock("svg",mr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>',6)])])}const Wt=z(pr,[["render",_r]]),yr={},gr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"};function kr(e,t){return r.openBlock(),r.createElementBlock("svg",gr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const br=z(yr,[["render",kr]]),wr={},vr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"};function Nr(e,t){return r.openBlock(),r.createElementBlock("svg",vr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 5l0 14"},null,-1),r.createElementVNode("path",{d:"M5 12l14 0"},null,-1)])])}const as=z(wr,[["render",Nr]]),Cr={},Mr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-restore"};function Sr(e,t){return r.openBlock(),r.createElementBlock("svg",Mr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M3.06 13a9 9 0 1 0 .49 -4.087"},null,-1),r.createElementVNode("path",{d:"M3 4.001v5h5"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const rs=z(Cr,[["render",Sr]]),Or={},Er={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"};function Tr(e,t){return r.openBlock(),r.createElementBlock("svg",Er,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>',8)])])}const os=z(Or,[["render",Tr]]),Ir={},Dr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"};function xr(e,t){return r.openBlock(),r.createElementBlock("svg",Dr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>',9)])])}const is=z(Ir,[["render",xr]]),Yr={},Rr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"};function Pr(e,t){return r.openBlock(),r.createElementBlock("svg",Rr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>',5)])])}const ls=z(Yr,[["render",Pr]]),Br={},Vr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-upload"};function Lr(e,t){return r.openBlock(),r.createElementBlock("svg",Vr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 9l5 -5l5 5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ds=z(Br,[["render",Lr]]),Ar={},Ur={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"};function $r(e,t){return r.openBlock(),r.createElementBlock("svg",Ur,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),r.createElementVNode("path",{d:"M6 6l12 12"},null,-1)])])}const cs=z(Ar,[["render",$r]]),Wr=Object.freeze(Object.defineProperty({__proto__:null,Check:Xn,CodeVariable:Qn,Copy:es,DotsVertical:ts,Download:ns,LayoutSidebarLeftCollapse:Qa,LayoutSidebarLeftExpand:sr,LayoutSidebarRight:ir,LayoutSidebarRightCollapse:ss,LayoutSidebarRightExpand:$t,LockCode:Wt,PlayerPlay:br,Plus:as,Restore:rs,Schema:os,SchemaOff:is,TransitionBottom:ls,Upload:ds,X:cs},Symbol.toStringTag,{value:"Module"}));function Hr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ut={exports:{}};var Fr=ut.exports,us;function Gr(){return us||(us=1,(function(e,t){(function(s,a){e.exports=a()})(Fr,function(){return(function(){var n={686:(function(o,i,l){l.d(i,{default:function(){return j}});var d=l(279),c=l.n(d),f=l(370),w=l.n(f),m=l(817),D=l.n(m);function g(b){try{return document.execCommand(b)}catch{return!1}}var M=function(N){var v=D()(N);return g("cut"),v},h=M;function k(b){var N=document.documentElement.getAttribute("dir")==="rtl",v=document.createElement("textarea");v.style.fontSize="12pt",v.style.border="0",v.style.padding="0",v.style.margin="0",v.style.position="absolute",v.style[N?"right":"left"]="-9999px";var E=window.pageYOffset||document.documentElement.scrollTop;return v.style.top="".concat(E,"px"),v.setAttribute("readonly",""),v.value=b,v}var A=function(N,v){var E=k(N);v.container.appendChild(E);var I=D()(E);return g("copy"),E.remove(),I},V=function(N){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},E="";return typeof N=="string"?E=A(N,v):N instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(N?.type)?E=A(N.value,v):(E=D()(N),g("copy")),E},H=V;function Oe(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(v){return typeof v}:Oe=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},Oe(b)}var Ee=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=N.action,E=v===void 0?"copy":v,I=N.container,R=N.target,ue=N.text;if(E!=="copy"&&E!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(R!==void 0)if(R&&Oe(R)==="object"&&R.nodeType===1){if(E==="copy"&&R.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(E==="cut"&&(R.hasAttribute("readonly")||R.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ue)return H(ue,{container:I});if(R)return E==="cut"?h(R):H(R,{container:I})},dt=Ee;function ye(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ye=function(v){return typeof v}:ye=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},ye(b)}function O(b,N){if(!(b instanceof N))throw new TypeError("Cannot call a class as a function")}function J(b,N){for(var v=0;v<N.length;v++){var E=N[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}function te(b,N,v){return N&&J(b.prototype,N),v&&J(b,v),b}function qn(b,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(N&&N.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),N&&ct(b,N)}function ct(b,N){return ct=Object.setPrototypeOf||function(E,I){return E.__proto__=I,E},ct(b,N)}function Vt(b){var N=At();return function(){var E=Ve(b),I;if(N){var R=Ve(this).constructor;I=Reflect.construct(E,arguments,R)}else I=E.apply(this,arguments);return Lt(this,I)}}function Lt(b,N){return N&&(ye(N)==="object"||typeof N=="function")?N:Kn(b)}function Kn(b){if(b===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b}function At(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ve(b){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},Ve(b)}function qe(b,N){var v="data-clipboard-".concat(b);if(N.hasAttribute(v))return N.getAttribute(v)}var U=(function(b){qn(v,b);var N=Vt(v);function v(E,I){var R;return O(this,v),R=N.call(this),R.resolveOptions(I),R.listenClick(E),R}return te(v,[{key:"resolveOptions",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=ye(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var R=this;this.listener=w()(I,"click",function(ue){return R.onClick(ue)})}},{key:"onClick",value:function(I){var R=I.delegateTarget||I.currentTarget,ue=this.action(R)||"copy",Ut=dt({action:ue,container:this.container,target:this.target(R),text:this.text(R)});this.emit(Ut?"success":"error",{action:ue,text:Ut,trigger:R,clearSelection:function(){R&&R.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return qe("action",I)}},{key:"defaultTarget",value:function(I){var R=qe("target",I);if(R)return document.querySelector(R)}},{key:"defaultText",value:function(I){return qe("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return H(I,R)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],R=typeof I=="string"?[I]:I,ue=!!document.queryCommandSupported;return R.forEach(function(Ut){ue=ue&&!!document.queryCommandSupported(Ut)}),ue}}]),v})(c()),j=U}),828:(function(o){var i=9;if(typeof Element<"u"&&!Element.prototype.matches){var l=Element.prototype;l.matches=l.matchesSelector||l.mozMatchesSelector||l.msMatchesSelector||l.oMatchesSelector||l.webkitMatchesSelector}function d(c,f){for(;c&&c.nodeType!==i;){if(typeof c.matches=="function"&&c.matches(f))return c;c=c.parentNode}}o.exports=d}),438:(function(o,i,l){var d=l(828);function c(m,D,g,M,h){var k=w.apply(this,arguments);return m.addEventListener(g,k,h),{destroy:function(){m.removeEventListener(g,k,h)}}}function f(m,D,g,M,h){return typeof m.addEventListener=="function"?c.apply(null,arguments):typeof g=="function"?c.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(k){return c(k,D,g,M,h)}))}function w(m,D,g,M){return function(h){h.delegateTarget=d(h.target,D),h.delegateTarget&&M.call(m,h)}}o.exports=f}),879:(function(o,i){i.node=function(l){return l!==void 0&&l instanceof HTMLElement&&l.nodeType===1},i.nodeList=function(l){var d=Object.prototype.toString.call(l);return l!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in l&&(l.length===0||i.node(l[0]))},i.string=function(l){return typeof l=="string"||l instanceof String},i.fn=function(l){var d=Object.prototype.toString.call(l);return d==="[object Function]"}}),370:(function(o,i,l){var d=l(879),c=l(438);function f(g,M,h){if(!g&&!M&&!h)throw new Error("Missing required arguments");if(!d.string(M))throw new TypeError("Second argument must be a String");if(!d.fn(h))throw new TypeError("Third argument must be a Function");if(d.node(g))return w(g,M,h);if(d.nodeList(g))return m(g,M,h);if(d.string(g))return D(g,M,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function w(g,M,h){return g.addEventListener(M,h),{destroy:function(){g.removeEventListener(M,h)}}}function m(g,M,h){return Array.prototype.forEach.call(g,function(k){k.addEventListener(M,h)}),{destroy:function(){Array.prototype.forEach.call(g,function(k){k.removeEventListener(M,h)})}}}function D(g,M,h){return c(document.body,g,M,h)}o.exports=f}),817:(function(o){function i(l){var d;if(l.nodeName==="SELECT")l.focus(),d=l.value;else if(l.nodeName==="INPUT"||l.nodeName==="TEXTAREA"){var c=l.hasAttribute("readonly");c||l.setAttribute("readonly",""),l.select(),l.setSelectionRange(0,l.value.length),c||l.removeAttribute("readonly"),d=l.value}else{l.hasAttribute("contenteditable")&&l.focus();var f=window.getSelection(),w=document.createRange();w.selectNodeContents(l),f.removeAllRanges(),f.addRange(w),d=f.toString()}return d}o.exports=i}),279:(function(o){function i(){}i.prototype={on:function(l,d,c){var f=this.e||(this.e={});return(f[l]||(f[l]=[])).push({fn:d,ctx:c}),this},once:function(l,d,c){var f=this;function w(){f.off(l,w),d.apply(c,arguments)}return w._=d,this.on(l,w,c)},emit:function(l){var d=[].slice.call(arguments,1),c=((this.e||(this.e={}))[l]||[]).slice(),f=0,w=c.length;for(f;f<w;f++)c[f].fn.apply(c[f].ctx,d);return this},off:function(l,d){var c=this.e||(this.e={}),f=c[l],w=[];if(f&&d)for(var m=0,D=f.length;m<D;m++)f[m].fn!==d&&f[m].fn._!==d&&w.push(f[m]);return w.length?c[l]=w:delete c[l],this}},o.exports=i,o.exports.TinyEmitter=i})},s={};function a(o){if(s[o])return s[o].exports;var i=s[o]={exports:{}};return n[o](i,i.exports,a),i.exports}return(function(){a.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return a.d(i,{a:i}),i}})(),(function(){a.d=function(o,i){for(var l in i)a.o(i,l)&&!a.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:i[l]})}})(),(function(){a.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)}})(),a(686)})().default})})(ut)),ut.exports}var jr=Gr();const zr=Hr(jr),Zr=e=>({toClipboard(t,n){return new Promise((s,a)=>{const o=document.createElement("button"),i=new zr(o,{text:()=>t,action:()=>"copy",container:n!==void 0?n:document.body});i.on("success",l=>{i.destroy(),s(l)}),i.on("error",l=>{i.destroy(),a(l)}),document.body.appendChild(o),o.click(),document.body.removeChild(o)})}}),qr={key:0,class:"baklava-button"},hs=r.defineComponent({__name:"CopyToClipboard",props:{text:String},setup(e){const{toClipboard:t}=Zr(),n=e,s=r.toRef(n,"text"),a=r.ref(!1),o=async()=>{try{await t(s.value),a.value=!0,setTimeout(()=>a.value=!1,1500),console.log("Copied to clipboard")}catch(i){console.error(i)}};return(i,l)=>(r.openBlock(),r.createElementBlock("div",null,[a.value?(r.openBlock(),r.createElementBlock("button",qr,[r.createVNode(r.unref(Xn))])):(r.openBlock(),r.createElementBlock("button",{key:1,onClick:o,class:"baklava-button"},[r.createVNode(r.unref(es))]))]))}}),Kr={class:"code-editor"},Jr={class:"code-buttons"},Xr=r.defineComponent({__name:"CodeEditor",props:r.mergeModels({locked:{type:Boolean},extensions:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:r.mergeModels(["update:locked"],["update:modelValue"]),setup(e,{emit:t}){const n=r.useModel(e,"modelValue"),s=t,a=o=>s("update:locked",o);return(o,i)=>{const l=r.resolveComponent("codemirror");return r.openBlock(),r.createElementBlock("div",Kr,[r.createElementVNode("div",Jr,[e.locked?(r.openBlock(),r.createElementBlock("button",{key:0,class:"baklava-button",title:"The code is locked.",onClick:i[0]||(i[0]=d=>a(!1))},[r.createVNode(r.unref(Wt))])):r.createCommentVNode("",!0),r.createVNode(hs,{text:e.modelValue},null,8,["text"])]),r.createVNode(l,{modelValue:n.value,"onUpdate:modelValue":i[1]||(i[1]=d=>n.value=d),extensions:e.extensions,class:"codemirror",style:{height:"100%"},onKeydown:i[2]||(i[2]=d=>a(!0))},null,8,["modelValue","extensions"])])}}}),Qr=r.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(e){const t=e,n=r.toRef(t,"viewModel"),s=a=>a.events.update.emit(null);return r.onMounted(n.value.onMounted),r.onBeforeUnmount(n.value.onBeforeUnmount),r.watch(n,(a,o)=>{o&&o.onBeforeUnmount(),a&&a.onMounted()}),(a,o)=>(r.openBlock(),r.createBlock(r.unref(S.BaklavaEditor),{viewModel:n.value},{palette:r.withCtx(()=>[r.createVNode(r.unref(ms))]),node:r.withCtx(i=>[r.createVNode(r.unref(fs),r.mergeProps(i,{onUpdate:l=>s(i.node)}),null,16,["onUpdate"])]),sidebar:r.withCtx(i=>[r.createVNode(r.unref(ps),r.normalizeProps(r.guardReactiveProps(i)),{codeEditor:r.withCtx(({node:l})=>[r.renderSlot(a.$slots,"sidebarCodeEditor",{node:l})]),_:3},16)]),_:3},8,["viewModel"]))}}),eo={class:"code-graph-info"},to=r.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",eo,[r.createElementVNode("div",null,"Editor graph: "+r.toDisplayString(e.viewModel.editor.graph.shortId),1),r.createElementVNode("div",null,"Displayed graph: "+r.toDisplayString(e.viewModel.displayedGraph.shortId),1),r.createElementVNode("div",null,"Graphs: "+r.toDisplayString(e.viewModel.editor.graphIds),1),r.createElementVNode("div",null,"Graph templates: "+r.toDisplayString(e.viewModel.editor.graphTemplateIds),1),r.createElementVNode("div",null,"Engine status: "+r.toDisplayString(e.viewModel.engine?.status),1)]))}}),no=["data-node-type","id"],so={class:"__title-label",style:{"flex-grow":"1"}},ao={key:0},ro={class:"__menu",style:{display:"flex"}},oo={class:"__outputs"},io={key:0},lo=["id","title"],co={class:"__inputs"},uo={key:0},ho=["id","title"],fs=r.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(e,{emit:t}){const n=S.Components.ContextMenu,s=S.Components.NodeInterface,a=e,o=r.computed(()=>a.node),i=t,{viewModel:l}=S.useViewModel(),{graph:d,switchGraph:c}=S.useGraph(),f=r.ref(null),w=r.ref(!1),m=r.ref(""),D=r.ref(null),g=r.ref(!1);let M=0,h=0;const k=r.ref(!1),A=r.computed(()=>{const U=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return a.node.type.startsWith(q.GRAPH_NODE_TYPE_PREFIX)&&U.push({value:"editSubgraph",label:"Edit Subgraph"}),U}),V=r.computed(()=>({"--selected":a.selected,"--dragging":a.dragging,"--two-column":!!a.node.twoColumn,"--hidden":o.value.state?.hidden})),H=r.computed(()=>({"--reverse-y":a.node.reverseY??l.value.settings.nodes.reverseY})),Oe=r.computed(()=>({top:`${a.node.position?.y??0}px`,left:`${a.node.position?.x??0}px`,"--width":`${a.node.width??l.value.settings.nodes.defaultWidth}px`})),Ee=r.computed(()=>Object.values(a.node.inputs).filter(U=>!U.hidden)),dt=r.computed(()=>Object.values(a.node.outputs).filter(U=>!U.hidden)),ye=()=>{qn(),i("select")},O=U=>{a.selected||ye(),i("start-drag",U)},J=()=>{k.value=!0},te=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id,U.visible=!0},qn=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id},ct=async U=>{switch(U){case"edit":te();break;case"delete":d.value.removeNode(a.node);break;case"rename":m.value=a.node.state.variableName,w.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.state.variableName=m.value,o.value.events.titleChanged.emit(o.value.state.variableName),w.value=!1},Lt=()=>{f.value&&l.value.hooks.renderNode.execute({node:a.node,el:f.value})},Kn=U=>{g.value=!0,M=a.node.width,h=U.clientX,U.preventDefault()},At=U=>{o.value.state&&(o.value.state.integrated=U,i("update"))},Ve=U=>{if(!g.value)return;const j=U.clientX-h,b=M+j/d.value.scaling,N=l.value.settings.nodes.minWidth,v=l.value.settings.nodes.maxWidth;o.value.width=Math.max(N,Math.min(v,b))},qe=()=>{g.value=!1};return r.onMounted(()=>{Lt(),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",qe)}),r.onUpdated(Lt),r.onBeforeUnmount(()=>{window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",qe)}),(U,j)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([V.value,"baklava-node"]),"data-node-type":o.value.type,id:o.value.id,style:r.normalizeStyle(Oe.value),ref_key:"el",ref:f,onPointerdown:ye},[r.unref(l).settings.nodes.resizable?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Kn},null,32)):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"__title",onPointerdown:r.withModifiers(O,["self","stop"]),onContextmenu:r.withModifiers(J,["prevent"])},[o.value.inputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:0,intf:o.value.inputs._code,node:o.value,title:o.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["intf","node","title"])):r.createCommentVNode("",!0),w.value?r.withDirectives((r.openBlock(),r.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:D,"onUpdate:modelValue":j[4]||(j[4]=b=>m.value=b),class:"baklava-input",placeholder:"Variable name",style:{"flex-grow":"1"},type:"text",onBlur:Vt,onKeydown:r.withKeys(Vt,["enter"])},null,544)),[[r.vModelText,m.value]]):(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",so,[o.value.idx>-1?(r.openBlock(),r.createElementBlock("span",ao,r.toDisplayString(o.value.idx+1)+" > ",1)):r.createCommentVNode("",!0),r.createTextVNode(" "+r.toDisplayString(o.value.state.variableName.length>0?o.value.state.variableName:o.value.title),1)]),r.createElementVNode("div",ro,[o.value.isCodeNode?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[o.value.state.lockCode?(r.openBlock(),r.createBlock(r.unref(Wt),{key:0,class:"--clickable mx-1",onClick:j[0]||(j[0]=b=>o.value.lockCode=!1)})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[o.value.state.integrated?(r.openBlock(),r.createBlock(r.unref(Qn),{key:1,class:"--clickable mx-1",onClick:j[2]||(j[2]=b=>At(!1))})):(r.openBlock(),r.createBlock(r.unref(ls),{key:0,class:"--clickable mx-1",onClick:j[1]||(j[1]=b=>At(!0))}))],64)):r.createCommentVNode("",!0),o.value.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:2,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0)],64)):r.createCommentVNode("",!0),r.createVNode(r.unref(ts),{class:"--clickable mx-1",onClick:J}),r.createVNode(r.unref(n),{modelValue:k.value,"onUpdate:modelValue":j[3]||(j[3]=b=>k.value=b),x:0,y:0,items:A.value,onClick:ct},null,8,["modelValue","items"])])],64)),o.value.outputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:3,node:o.value,intf:o.value.outputs._code,class:"--output",title:o.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):r.createCommentVNode("",!0)],32),r.createElementVNode("div",{class:r.normalizeClass(["__content",H.value]),onKeydown:j[5]||(j[5]=r.withKeys(r.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:j[6]||(j[6]=r.withModifiers(()=>{},["prevent"]))},[r.createElementVNode("div",oo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(dt.value,b=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:b.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",io,[b.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:b.id,title:b.name,class:"baklava-node-interface --output --connected"},[...j[7]||(j[7]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,lo)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,type:"output",node:o.value,intf:b},()=>[r.createVNode(r.unref(s),{node:o.value,intf:b,title:b.value},null,8,["node","intf","title"])])],64))),128))]),r.createElementVNode("div",co,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Ee.value,b=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:b.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",uo,[b.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:b.id,title:b.name,class:"baklava-node-interface --input --connected"},[...j[8]||(j[8]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,ho)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,node:o.value,intf:b,type:"input"},()=>[r.createVNode(r.unref(s),{node:o.value,intf:b,title:b.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,no))}}),fo=["id"],po={class:"align-middle"},Ht=r.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(e){const t=e,{viewModel:n}=S.useViewModel(),{hoveredOver:s,temporaryConnection:a}=S.useTemporaryConnection(),o=r.ref(null),i=r.computed(()=>t.intf.connectionCount>0),l=r.computed(()=>({"--connected":i.value})),d=()=>{s(t.intf)},c=()=>{s(void 0)},f=()=>{o.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:o.value})};return r.onMounted(f),r.onUpdated(f),(w,m)=>(r.openBlock(),r.createElementBlock("div",{id:e.intf.id,ref_key:"el",ref:o,class:r.normalizeClass(["baklava-node-interface",l.value])},[e.intf.port?(r.openBlock(),r.createElementBlock("div",{key:0,class:r.normalizeClass([{"--selected":r.unref(a)?.from===e.intf},"__port"]),onPointerover:d,onPointerout:c},null,34)):r.createCommentVNode("",!0),r.createElementVNode("span",po,[r.renderSlot(w.$slots,"default")])],10,fo))}}),mo=["title"],_o={key:0,class:"__label"},Ft=r.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;return(s,a)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["baklava-checkbox",{"--checked":e.inversed?!e.modelValue:e.modelValue,"--disabled":e.disabled}]),title:e.name,onClick:a[0]||(a[0]=o=>n("update:modelValue",!e.modelValue))},[a[1]||(a[1]=r.createElementVNode("div",{class:"__checkmark-container"},[r.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[r.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),e.name?(r.openBlock(),r.createElementBlock("div",_o,r.toDisplayString(e.name),1)):r.createCommentVNode("",!0)],10,mo))}}),yo={class:"__header"},go={class:"__node-name"},ko={class:"__interfaces"},bo={class:"__inputs"},wo={style:{display:"flex"}},vo={class:"__outputs"},No={key:0,class:"__interface"},Co=["placeholder"],Mo={style:{display:"flex"}},ps=r.defineComponent({__name:"CodeGraphSidebar",setup(e){const{viewModel:t}=S.useViewModel(),{graph:n}=S.useGraph(),s=r.ref(null),a=r.toRef(t.value.settings.sidebar,"width"),o=r.computed(()=>t.value.settings.sidebar.resizable);let i=0,l=0;const d=r.computed(()=>{const k=n.value.sidebar.nodeId;return n.value.nodes.find(A=>A.id===k)}),c=r.computed(()=>d.value),f=r.computed(()=>({width:`${a.value}px`})),w=r.computed(()=>c.value?Object.values(c.value.inputs).filter(k=>k.displayInSidebar&&k.component):[]),m=r.computed(()=>c.value?Object.values(c.value.outputs).filter(k=>k.displayInSidebar&&k.component):[]),D=()=>{n.value.sidebar.visible=!1},g=()=>{d.value?.events.update.emit(null)},M=k=>{i=a.value,l=k.clientX,window.addEventListener("mousemove",h),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",h)},{once:!0})},h=k=>{const A=s.value?.parentElement?.getBoundingClientRect().width??500,V=k.clientX-l;let H=i-V;H<300?H=300:H>.9*A&&(H=.9*A),a.value=H};return(k,A)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([{"--open":r.unref(n).sidebar.visible},"baklava-sidebar"]),style:r.normalizeStyle(f.value),ref_key:"el",ref:s},[o.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resizer",onMousedown:M},null,32)):r.createCommentVNode("",!0),d.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",yo,[r.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:D},"×"),r.createElementVNode("div",go,[r.createElementVNode("b",null,r.toDisplayString(d.value.title),1)])]),r.createElementVNode("div",ko,[r.createElementVNode("div",bo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(w.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",wo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[0]||(A[0]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),r.createElementVNode("div",vo,[c.value&&c.value.state?(r.openBlock(),r.createElementBlock("div",No,[A[3]||(A[3]=r.createElementVNode("label",null,"Variable name",-1)),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=V=>c.value.state.variableName=V),placeholder:c.value.variableName,type:"text",class:"baklava-input",title:"Variable name",onBlur:g,onKeydown:r.withKeys(g,["enter"])},null,40,Co),[[r.vModelText,c.value.state.variableName]])])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(m.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",Mo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[2]||(A[2]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),r.renderSlot(k.$slots,"codeEditor",{node:d.value})],64)):r.createCommentVNode("",!0)],6))}});function So(e,t){return Object.fromEntries(Object.entries(e).filter(t))}function Oo(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s)]))}const Eo={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},To={key:0,style:{display:"flex","justify-content":"space-between"}},Io=["onClick"],Do={key:0,style:{margin:"auto 0","font-size":"12px"}},ms=r.defineComponent({__name:"CodeNodePalette",setup(e){const t=S.Components.PaletteEntry,{viewModel:n}=S.useViewModel(),{x:s,y:a}=Ya.usePointer(),{transform:o}=S.useTransform(),i=S.useNodeCategories(n),l=r.inject("editorEl"),d=r.ref(""),c=r.ref(null),f=()=>d.value?i.value.filter(g=>g.name.toLowerCase().includes(d.value.toLowerCase())||Object.values(g.nodeTypes).some(M=>M.title.toLowerCase().includes(d.value.toLowerCase()))):i.value,w=g=>d.value?So(g,M=>{const h=M[1];return h.category.includes(d.value.toLowerCase())||h.title?.toLowerCase().includes(d.value.toLowerCase())}):g,m=r.computed(()=>{if(!c.value||!l?.value)return{};const{left:g,top:M}=l.value.getBoundingClientRect();return{top:`${a.value-M}px`,left:`${s.value-g}px`}}),D=(g,M)=>{c.value={type:g,nodeInformation:M};const h=()=>{const k=r.reactive(new M.type);n.value.displayedGraph.addNode(k);const A=l.value.getBoundingClientRect(),[V,H]=o(s.value-A.left,a.value-A.top);k.position.x=V,k.position.y=H,c.value=null,document.removeEventListener("pointerup",h)};document.addEventListener("pointerup",h)};return(g,M)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.createElementVNode("div",{class:r.normalizeClass([{"--open":r.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:M[1]||(M[1]=r.withModifiers(()=>{},["stop","prevent"]))},[r.createElementVNode("div",Eo,[r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":M[0]||(M[0]=h=>d.value=h),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:f},null,544),[[r.vModelText,d.value]])]),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(f(),h=>(r.openBlock(),r.createElementBlock("section",{key:h.name},[h.name!=="default"?(r.openBlock(),r.createElementBlock("h3",To,[r.createElementVNode("div",{onClick:k=>d.value=h.name,style:{cursor:"pointer"}},r.toDisplayString(h.name),9,Io),Object.keys(w(h.nodeTypes)).length<Object.values(h.nodeTypes).length?(r.openBlock(),r.createElementBlock("div",Do," ( "+r.toDisplayString(Object.keys(w(h.nodeTypes)).length)+" / "+r.toDisplayString(Object.values(h.nodeTypes).length)+" ) ",1)):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(w(h.nodeTypes),(k,A)=>(r.openBlock(),r.createBlock(r.unref(t),{key:A,title:k.title,type:A,onPointerdown:V=>D(A,k)},null,8,["title","type","onPointerdown"]))),128))]))),128))],34),r.createVNode(r.Transition,{name:"fade"},{default:r.withCtx(()=>[c.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:r.normalizeStyle(m.value)},[r.createVNode(r.unref(t),{type:c.value.type,title:c.value.nodeInformation.title},null,8,["type","title"])],4)):r.createCommentVNode("",!0)]),_:1})],64))}}),xo={},Yo={class:"prependIcon"},Ro={class:"appendIcon"};function Po(e,t){const n=r.resolveComponent("router-link");return r.openBlock(),r.createBlock(n,{class:"navItem"},{default:r.withCtx(()=>[r.createElementVNode("span",Yo,[r.renderSlot(e.$slots,"prependIcon")]),r.renderSlot(e.$slots,"default"),r.createElementVNode("span",Ro,[r.renderSlot(e.$slots,"appendIcon")])]),_:3})}const Gt=z(xo,[["render",Po]]),Bo={class:"navbar"},Vo=["onClick"],Lo=r.defineComponent({__name:"NavBar",props:{viewModel:{},editorStates:{},routes:{}},emits:["click:remove"],setup(e,{emit:t}){const n=t,s=a=>{n("click:remove",a)};return(a,o)=>(r.openBlock(),r.createElementBlock("nav",Bo,[r.renderSlot(a.$slots,"prepend"),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.editorStates,i=>(r.openBlock(),r.createBlock(Gt,{key:i.graph.id,class:r.normalizeClass({active:i.graph.id===e.viewModel.displayedGraph.id}),to:{name:e.routes?.edit??"edit",params:{editorId:i.graph.id}}},{appendIcon:r.withCtx(()=>[r.createElementVNode("button",{class:"remove",onClick:r.withModifiers(l=>s(i.graph.id),["prevent"])},[r.createVNode(r.unref(cs))],8,Vo)]),default:r.withCtx(()=>[r.createTextVNode(r.toDisplayString(i.graph.id.slice(0,6))+" ",1)]),_:2},1032,["class","to"]))),128)),r.renderSlot(a.$slots,"append",{},()=>[r.createVNode(Gt,{to:{name:e.routes?.new??"new"},class:"navItem"},{default:r.withCtx(()=>[r.createVNode(r.unref(as),{class:"plus"})]),_:1},8,["to"])])]))}}),Ao=r.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(e,{emit:t}){return{v:r.computed({get:()=>e.modelValue,set:s=>{t("update:modelValue",s)}})}}}),Uo={style:{position:"relative"}},$o={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},Wo=["placeholder","title"];function Ho(e,t,n,s,a,o){return r.openBlock(),r.createElementBlock("div",Uo,[r.createElementVNode("label",$o,r.toDisplayString(e.intf.name),1),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>e.v=i),type:"text",class:"baklava-input",placeholder:e.intf.name,title:e.intf.name},null,8,Wo),[[r.vModelText,e.v]])])}const jt=z(Ao,[["render",Ho]]),Fo=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Xr,CodeGraphEditor:Qr,CodeGraphInfo:to,CodeGraphNode:fs,CodeGraphNodeInterface:Ht,CodeGraphSidebar:ps,CodeNodePalette:ms,CopyToClipboard:hs,NavBar:Lo,NavItem:Gt,SidebarCheckbox:Ft,TextInputInterface:jt},Symbol.toStringTag,{value:"Module"}));Le.escape=e=>e;class zt extends q.AbstractNode{codeTemplate;isCodeNode=!0;mask=null;name="";state;_variableName="";inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=r.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:""}),this.codeTemplate=function(){return`${this.name}(${_s(this.codeNodeInputs).join(", ")})`}}get code(){return this.graph.code}get codeNodeInputs(){return Object.fromEntries(Object.entries(this.inputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get codeNodeOutputs(){return Object.fromEntries(Object.entries(this.outputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get graph(){return super.graph}get hasConnectedOutputNodes(){return this.getConnectedNodes("outputs").length>0}get idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByType(){return this.graph.getNodesByType(this.type).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesByVariableName(this.state.variableName??this._variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}get isSelected(){return this.graph.selectedNodeIds.includes(this.id)}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.events.update.emit(null)}get optionalInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>t[1].optional))}get requiredInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>!t[1].optional))}get script(){return this.outputs._code?.value??""}set script(t){this.outputs._code&&(this.outputs._code.value=t),this.events.update.emit(null)}get shortId(){return this.id.slice(0,6)}get subgraph(){}get variableName(){return this.state.variableName||this._variableName?this.state.variableName||this._variableName+(this.idxByVariableNames+1):""}getConnectedNodeByInterface(t,n){const s=this.getConnectedNodesByInterface(t,n);return s.length>0?s[0]:null}getConnectedNodes(t){let n=[];if(t!=="inputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.from.nodeId===this.id).map(a=>a.to.nodeId);s&&(n=n.concat(s))}if(t!=="outputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.to.nodeId===this.id).map(a=>a.from.nodeId);s&&(n=n.concat(s))}return!n||n.length==0?[]:n.map(s=>this.graph.findNodeById(s))}getConnectedNodesByInterface(t,n){let s=[];if(n!=="outputs"&&this.inputs[t]){const a=this.graph.connections.filter(o=>o.to.id===this.inputs[t]?.id||o.from.id===this.inputs[t]?.id).map(o=>o.from.nodeId);a&&(s=s.concat(a))}if(n!=="inputs"&&this.outputs[t]){const a=this.graph.connections.filter(o=>o.from.id===this.outputs[t]?.id||o.from.id===this.outputs[t]?.id).map(o=>o.to.nodeId);a&&(s=s.concat(a))}return!s||s.length==0?[]:s.map(a=>this.graph.findNodeById(a))}remove(){this.graph?.removeNode(this)}renderCode(t){return Le.render(this.state.codeTemplate,t)}updateCodeTemplate(){this.state.codeTemplate=this.codeTemplate.call(this)}updateModules(t){if(t)this.state.modules=t;else if(this.type.includes(".")){const n=this.type.split(".");this.state.modules.push(n.slice(0,n.length-1).join("."))}}updateOutputNames(){Object.values(this.codeNodeOutputs).forEach(t=>{t.name=this.state.integrated?"":this.variableName+t.suffix})}updateOutputValues(t){Object.keys(this.outputs).forEach(n=>{n!=="_code"&&(t[n]=this.state.integrated?t._code:this.outputs[n].name)})}updateProps(t){this.state.props=t}updateInputValues(t){const n=Object.keys(this.inputs);Object.keys(t).forEach(s=>{!n.includes(s)||!this.inputs[s]||(this.inputs[s].value=t[s],this.inputs[s].setHidden(!1))})}}class ht extends zt{calculate=(t,n)=>{const s={};return this.lockCode||(s._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(s),s};executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}load(t){super.load(t),this.afterLoaded()}}const _s=(e,t=!0)=>{const n=[],s=Object.keys(e);return s.forEach(a=>{if(e[a]?.hidden)return;const i=t&&n.length<s.indexOf(a)?`${a}=`:"";n.push(`${i}{{ inputs.${a} }}`)}),n},ys=(e,t)=>{switch(e){case"CheckBoxInterface":return new ks(t.id,t.value);case"IntegerInterface":return new en(t.id,t.value,t.min,t.max);case"NumberInterface":return new ws(t.id,t.value,t.min,t.max);case"SelectInterface":return new vs(t.id,t.value,t.items);default:return new nn(t.id,t.value)}},Go=["title"],ft=r.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",{title:e.intf.value},r.toDisplayString(e.intf.name),9,Go))}});class Q extends q.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(r.markRaw(ft)),this.state=r.reactive({optional:!1})}get optional(){return this.state.optional}get shortId(){return this.id.slice(0,6)}getValue=()=>`${this.value??"None"}`;load(t){this.id=t.id,this.templateId=t.templateId,this.name!=="_code"&&(t.optional&&(this.state.optional=t.optional),this.value=t.value,this.hooks.load.execute(t),this.hidden=t.hidden)}save(){const t={id:this.id,templateId:this.templateId,value:this.value,hidden:this.hidden};return this.state.optional&&(t.optional=this.state.optional),this.hooks.save.execute(t)}setOptional(t){return this.state.optional=t,this.setHidden(t),this}}class Ae extends Q{constructor(t="",n){super(t,n),this.setComponent(r.markRaw(ft)),this.use(S.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const Zt=new G.NodeInterfaceType("boolean"),gs=new G.NodeInterfaceType("dict"),qt=new G.NodeInterfaceType("list"),se=new G.NodeInterfaceType("node"),Kt=new G.NodeInterfaceType("number"),Jt=new G.NodeInterfaceType("string"),Xt=new G.NodeInterfaceType("tuple"),jo=e=>{new G.BaklavaInterfaceTypes(e.editor,{viewPlugin:e}).addTypes(Zt,gs,qt,se,Kt,Jt,Xt)};class ks extends Ae{constructor(t,n){super(t,n),this.setComponent(r.markRaw(S.CheckboxInterfaceComponent)),this.use(G.setType,Zt)}getValue=()=>this.value?"True":"False"}class bs extends Q{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(r.markRaw(ft))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=S.useGraph();return t.value.findNodeById(this.nodeId)}}class Qt extends Ae{min;max;constructor(t,n,s,a){super(t,n),this.min=s,this.max=a,this.use(G.setType,Kt)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class en extends Qt{component=r.markRaw(S.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class zo extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,qt)}getValue=()=>`[${this.value}]`}class ws extends Qt{component=r.markRaw(S.NumberInterfaceComponent)}class tn extends Ae{constructor(t,n){super(t,n),this.use(G.setType,Jt)}getValue=()=>`"${this.value}"`}class vs extends tn{component=r.markRaw(S.SelectInterfaceComponent);items;constructor(t,n,s){super(t,n),this.items=s}}class Zo extends Qt{component=r.markRaw(S.SliderInterfaceComponent);min;max;constructor(t,n,s,a){super(t,n,s,a),this.min=s,this.max=a}getValue=()=>`${Math.round(this.value*1e3)/1e3}`}class nn extends tn{component=r.markRaw(jt)}class qo extends tn{component=r.markRaw(S.TextareaInputInterfaceComponent)}class Ko extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Xt)}getValue=()=>`(${this.value})`}function Jo(e){return class extends ht{type=e.type;inputs={};outputs={};constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName!=null&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0))}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}}}class Ns extends ht{}function Xo(e){return class extends Ns{type=e.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(e.inputs??{});staticOutputKeys=Object.keys(e.outputs??{});constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate?.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){this.events.update.subscribe(this,t=>{t&&(t.type==="input"&&this.staticInputKeys.includes(t.name)||t.type==="output"&&this.staticOutputKeys.includes(t.name))&&this.onUpdate()}),this.onUpdate(),e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}load(t){this.preventUpdate=!0,this.hooks.beforeLoad.execute(t),this.id=t.id,this.title=t.title;for(const n of this.staticInputKeys)this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id;for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id;this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!(this.staticInputKeys.includes(n)||!t.inputs[n])){if(!this.inputs[n]){const s=t.inputs[n],a=s.value;let o;s.component?o=ys(s.component,{...s,id:n}):typeof a=="number"?o=new en(n,a):o=new nn(n,JSON.stringify(a)),o.use(S.displayInSidebar,!0),this.addInput(n,o)}this.inputs[n]&&(this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id)}for(const n of Object.keys(t.outputs))if(!(this.staticOutputKeys.includes(n)||!t.outputs[n])){if(!this.outputs[n]){const s=new bs(n);this.addOutput(n,s)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(!e.onUpdate||this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),s=e.onUpdate.call(this,t,n);this.updateInterfaces("input",s.inputs??{},s.forceUpdateInputs??[]),this.updateInterfaces("output",s.outputs??{},s.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const s={};for(const a of t)s[a]=n[a].value;return s}updateInputInterfaces(t={},n=[]){this.updateInterfaces("input",t,n)}updateInterfaces(t,n={},s=[]){const a=t==="input"?this.staticInputKeys:this.staticOutputKeys,o=t==="input"?this.inputs:this.outputs;for(const i of Object.keys(o))a.includes(i)||n[i]&&!s.includes(i)||(t==="input"?this.removeInput(i):this.removeOutput(i));for(const i of Object.keys(n)){if(o[i])continue;const l=n[i]();t==="input"?this.addInput(i,l):this.addOutput(i,l)}}updateProps(t){this.state.props=t,this.onUpdate()}}}Le.escape=e=>e;class pt{_id;_state;viewModel;constructor(){this._id=xe.v4(),this._state=r.reactive({lockCode:!1,modules:{},script:"",template:""})}get engine(){return this.viewModel?.engine}get graph(){return this.viewModel?.editor.graph}get id(){return this._id}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.engine?.runOnce(null)}get modules(){const t=[];return this.graph?.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>t.push(...n.state.modules)),t?(t.sort(),Array.from(new Set(t.map(n=>this.state.modules[n])))):[]}get script(){return this.state.script}set script(t){this.state.script=t,this.engine?.runOnce(null)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}clear(){this.state.script=""}async loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}registerViewModel(t){this.viewModel=t}renderCode(t){this.state.script=Le.render(this.state.template||"",t??{})}}class Qo extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>hu))}}class ei extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>fu))}}const ti=e=>{e.allowMultipleConnections=!0};class Cs extends he.BaseEngine{order=new Map;constructor(t){super(t)}start(){super.start(),this.recalculateOrder=!0,this.calculateWithoutData()}async runGraph(t,n,s){this.order.has(t.id)||this.order.set(t.id,he.sortTopologically(t));const{calculationOrder:a,connectionsFromNode:o}=this.order.get(t.id),i=new Map;for(const l of a){const d={};Object.entries(l.inputs).forEach(([f,w])=>{d[f]=this.getInterfaceValue(n,w.id)}),l.isCodeNode&&(l.updateCodeTemplate(),l.updateOutputNames()),this.events.beforeNodeCalculation.emit({inputValues:d,node:l});let c;if(l.calculate){if(c=await l.calculate(d,{globalValues:s,engine:this}),o.has(l))for(const[f,w]of Object.entries(c))this.hooks.transferData.execute(c[f],w),o.get(l).forEach(m=>n.set(m.to.id,w))}else{c={};for(const[f,w]of Object.entries(l.outputs))c[f]=this.getInterfaceValue(n,w.id)}this.events.afterNodeCalculation.emit({outputValues:c,node:l}),i.set(l.id,new Map(Object.entries(c))),o.has(l)&&o.get(l).forEach(f=>{const w=Object.entries(l.outputs).find(([,D])=>D.id===f.from.id)?.[0];if(!w)throw new Error(`Could not find key for interface ${f.from.id}
1
+ (function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@baklavajs/renderer-vue"),require("@baklavajs/core"),require("@vueuse/core"),require("mustache"),require("uuid"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("toposort"),require("@baklavajs/events")):typeof define=="function"&&define.amd?define(["exports","vue","@baklavajs/renderer-vue","@baklavajs/core","@vueuse/core","mustache","uuid","@baklavajs/interface-types","@baklavajs/engine","toposort","@baklavajs/events"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p["@babsey/code-graph"]={},p.vue,p["@baklavajs/renderer-vue"],p["@baklavajs/core"],p["@vueuse/core"],p.mustache,p.uuid,p["@baklavajs/interface-types"],p["@baklavajs/engine"],p.toposort,p["@baklavajs/events"]))})(this,(function(p,r,S,q,Ya,Le,xe,G,he,Ra,Jn){"use strict";const z=(e,t)=>{const n=e.__vccOpts||e;for(const[s,a]of t)n[s]=a;return n},Pa={},Ba={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"};function Va(e,t){return r.openBlock(),r.createElementBlock("svg",Ba,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const Xn=z(Pa,[["render",Va]]),La={},Aa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"};function Ua(e,t){return r.openBlock(),r.createElementBlock("svg",Aa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"},null,-1)])])}const Qn=z(La,[["render",Ua]]),$a={},Wa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"};function Ha(e,t){return r.openBlock(),r.createElementBlock("svg",Wa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z"},null,-1),r.createElementVNode("path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"},null,-1)])])}const es=z($a,[["render",Ha]]),Fa={},Ga={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"};function ja(e,t){return r.openBlock(),r.createElementBlock("svg",Ga,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const ts=z(Fa,[["render",ja]]),za={},Za={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-download"};function qa(e,t){return r.openBlock(),r.createElementBlock("svg",Za,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 11l5 5l5 -5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ns=z(za,[["render",qa]]),Ka={},Ja={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"};function Xa(e,t){return r.openBlock(),r.createElementBlock("svg",Ja,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const Qa=z(Ka,[["render",Xa]]),er={},tr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"};function nr(e,t){return r.openBlock(),r.createElementBlock("svg",tr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const sr=z(er,[["render",nr]]),ar={},rr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function or(e,t){return r.openBlock(),r.createElementBlock("svg",rr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z"},null,-1)])])}const ir=z(ar,[["render",or]]),lr={},dr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"};function cr(e,t){return r.openBlock(),r.createElementBlock("svg",dr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const ss=z(lr,[["render",cr]]),ur={},hr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"};function fr(e,t){return r.openBlock(),r.createElementBlock("svg",hr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const $t=z(ur,[["render",fr]]),pr={},mr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"};function _r(e,t){return r.openBlock(),r.createElementBlock("svg",mr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>',6)])])}const Wt=z(pr,[["render",_r]]),yr={},gr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"};function kr(e,t){return r.openBlock(),r.createElementBlock("svg",gr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const br=z(yr,[["render",kr]]),wr={},vr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"};function Nr(e,t){return r.openBlock(),r.createElementBlock("svg",vr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 5l0 14"},null,-1),r.createElementVNode("path",{d:"M5 12l14 0"},null,-1)])])}const as=z(wr,[["render",Nr]]),Cr={},Mr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-restore"};function Sr(e,t){return r.openBlock(),r.createElementBlock("svg",Mr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M3.06 13a9 9 0 1 0 .49 -4.087"},null,-1),r.createElementVNode("path",{d:"M3 4.001v5h5"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const rs=z(Cr,[["render",Sr]]),Or={},Er={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"};function Tr(e,t){return r.openBlock(),r.createElementBlock("svg",Er,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>',8)])])}const os=z(Or,[["render",Tr]]),Ir={},Dr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"};function xr(e,t){return r.openBlock(),r.createElementBlock("svg",Dr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>',9)])])}const is=z(Ir,[["render",xr]]),Yr={},Rr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"};function Pr(e,t){return r.openBlock(),r.createElementBlock("svg",Rr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>',5)])])}const ls=z(Yr,[["render",Pr]]),Br={},Vr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-upload"};function Lr(e,t){return r.openBlock(),r.createElementBlock("svg",Vr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 9l5 -5l5 5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ds=z(Br,[["render",Lr]]),Ar={},Ur={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"};function $r(e,t){return r.openBlock(),r.createElementBlock("svg",Ur,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),r.createElementVNode("path",{d:"M6 6l12 12"},null,-1)])])}const cs=z(Ar,[["render",$r]]),Wr=Object.freeze(Object.defineProperty({__proto__:null,Check:Xn,CodeVariable:Qn,Copy:es,DotsVertical:ts,Download:ns,LayoutSidebarLeftCollapse:Qa,LayoutSidebarLeftExpand:sr,LayoutSidebarRight:ir,LayoutSidebarRightCollapse:ss,LayoutSidebarRightExpand:$t,LockCode:Wt,PlayerPlay:br,Plus:as,Restore:rs,Schema:os,SchemaOff:is,TransitionBottom:ls,Upload:ds,X:cs},Symbol.toStringTag,{value:"Module"}));function Hr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ut={exports:{}};var Fr=ut.exports,us;function Gr(){return us||(us=1,(function(e,t){(function(s,a){e.exports=a()})(Fr,function(){return(function(){var n={686:(function(o,i,l){l.d(i,{default:function(){return j}});var d=l(279),c=l.n(d),f=l(370),w=l.n(f),m=l(817),D=l.n(m);function g(b){try{return document.execCommand(b)}catch{return!1}}var M=function(N){var v=D()(N);return g("cut"),v},h=M;function k(b){var N=document.documentElement.getAttribute("dir")==="rtl",v=document.createElement("textarea");v.style.fontSize="12pt",v.style.border="0",v.style.padding="0",v.style.margin="0",v.style.position="absolute",v.style[N?"right":"left"]="-9999px";var E=window.pageYOffset||document.documentElement.scrollTop;return v.style.top="".concat(E,"px"),v.setAttribute("readonly",""),v.value=b,v}var A=function(N,v){var E=k(N);v.container.appendChild(E);var I=D()(E);return g("copy"),E.remove(),I},V=function(N){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},E="";return typeof N=="string"?E=A(N,v):N instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(N?.type)?E=A(N.value,v):(E=D()(N),g("copy")),E},H=V;function Oe(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(v){return typeof v}:Oe=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},Oe(b)}var Ee=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=N.action,E=v===void 0?"copy":v,I=N.container,R=N.target,ue=N.text;if(E!=="copy"&&E!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(R!==void 0)if(R&&Oe(R)==="object"&&R.nodeType===1){if(E==="copy"&&R.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(E==="cut"&&(R.hasAttribute("readonly")||R.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ue)return H(ue,{container:I});if(R)return E==="cut"?h(R):H(R,{container:I})},dt=Ee;function ye(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ye=function(v){return typeof v}:ye=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},ye(b)}function O(b,N){if(!(b instanceof N))throw new TypeError("Cannot call a class as a function")}function J(b,N){for(var v=0;v<N.length;v++){var E=N[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}function te(b,N,v){return N&&J(b.prototype,N),v&&J(b,v),b}function qn(b,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(N&&N.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),N&&ct(b,N)}function ct(b,N){return ct=Object.setPrototypeOf||function(E,I){return E.__proto__=I,E},ct(b,N)}function Vt(b){var N=At();return function(){var E=Ve(b),I;if(N){var R=Ve(this).constructor;I=Reflect.construct(E,arguments,R)}else I=E.apply(this,arguments);return Lt(this,I)}}function Lt(b,N){return N&&(ye(N)==="object"||typeof N=="function")?N:Kn(b)}function Kn(b){if(b===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b}function At(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ve(b){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},Ve(b)}function qe(b,N){var v="data-clipboard-".concat(b);if(N.hasAttribute(v))return N.getAttribute(v)}var U=(function(b){qn(v,b);var N=Vt(v);function v(E,I){var R;return O(this,v),R=N.call(this),R.resolveOptions(I),R.listenClick(E),R}return te(v,[{key:"resolveOptions",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=ye(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var R=this;this.listener=w()(I,"click",function(ue){return R.onClick(ue)})}},{key:"onClick",value:function(I){var R=I.delegateTarget||I.currentTarget,ue=this.action(R)||"copy",Ut=dt({action:ue,container:this.container,target:this.target(R),text:this.text(R)});this.emit(Ut?"success":"error",{action:ue,text:Ut,trigger:R,clearSelection:function(){R&&R.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return qe("action",I)}},{key:"defaultTarget",value:function(I){var R=qe("target",I);if(R)return document.querySelector(R)}},{key:"defaultText",value:function(I){return qe("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return H(I,R)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],R=typeof I=="string"?[I]:I,ue=!!document.queryCommandSupported;return R.forEach(function(Ut){ue=ue&&!!document.queryCommandSupported(Ut)}),ue}}]),v})(c()),j=U}),828:(function(o){var i=9;if(typeof Element<"u"&&!Element.prototype.matches){var l=Element.prototype;l.matches=l.matchesSelector||l.mozMatchesSelector||l.msMatchesSelector||l.oMatchesSelector||l.webkitMatchesSelector}function d(c,f){for(;c&&c.nodeType!==i;){if(typeof c.matches=="function"&&c.matches(f))return c;c=c.parentNode}}o.exports=d}),438:(function(o,i,l){var d=l(828);function c(m,D,g,M,h){var k=w.apply(this,arguments);return m.addEventListener(g,k,h),{destroy:function(){m.removeEventListener(g,k,h)}}}function f(m,D,g,M,h){return typeof m.addEventListener=="function"?c.apply(null,arguments):typeof g=="function"?c.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(k){return c(k,D,g,M,h)}))}function w(m,D,g,M){return function(h){h.delegateTarget=d(h.target,D),h.delegateTarget&&M.call(m,h)}}o.exports=f}),879:(function(o,i){i.node=function(l){return l!==void 0&&l instanceof HTMLElement&&l.nodeType===1},i.nodeList=function(l){var d=Object.prototype.toString.call(l);return l!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in l&&(l.length===0||i.node(l[0]))},i.string=function(l){return typeof l=="string"||l instanceof String},i.fn=function(l){var d=Object.prototype.toString.call(l);return d==="[object Function]"}}),370:(function(o,i,l){var d=l(879),c=l(438);function f(g,M,h){if(!g&&!M&&!h)throw new Error("Missing required arguments");if(!d.string(M))throw new TypeError("Second argument must be a String");if(!d.fn(h))throw new TypeError("Third argument must be a Function");if(d.node(g))return w(g,M,h);if(d.nodeList(g))return m(g,M,h);if(d.string(g))return D(g,M,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function w(g,M,h){return g.addEventListener(M,h),{destroy:function(){g.removeEventListener(M,h)}}}function m(g,M,h){return Array.prototype.forEach.call(g,function(k){k.addEventListener(M,h)}),{destroy:function(){Array.prototype.forEach.call(g,function(k){k.removeEventListener(M,h)})}}}function D(g,M,h){return c(document.body,g,M,h)}o.exports=f}),817:(function(o){function i(l){var d;if(l.nodeName==="SELECT")l.focus(),d=l.value;else if(l.nodeName==="INPUT"||l.nodeName==="TEXTAREA"){var c=l.hasAttribute("readonly");c||l.setAttribute("readonly",""),l.select(),l.setSelectionRange(0,l.value.length),c||l.removeAttribute("readonly"),d=l.value}else{l.hasAttribute("contenteditable")&&l.focus();var f=window.getSelection(),w=document.createRange();w.selectNodeContents(l),f.removeAllRanges(),f.addRange(w),d=f.toString()}return d}o.exports=i}),279:(function(o){function i(){}i.prototype={on:function(l,d,c){var f=this.e||(this.e={});return(f[l]||(f[l]=[])).push({fn:d,ctx:c}),this},once:function(l,d,c){var f=this;function w(){f.off(l,w),d.apply(c,arguments)}return w._=d,this.on(l,w,c)},emit:function(l){var d=[].slice.call(arguments,1),c=((this.e||(this.e={}))[l]||[]).slice(),f=0,w=c.length;for(f;f<w;f++)c[f].fn.apply(c[f].ctx,d);return this},off:function(l,d){var c=this.e||(this.e={}),f=c[l],w=[];if(f&&d)for(var m=0,D=f.length;m<D;m++)f[m].fn!==d&&f[m].fn._!==d&&w.push(f[m]);return w.length?c[l]=w:delete c[l],this}},o.exports=i,o.exports.TinyEmitter=i})},s={};function a(o){if(s[o])return s[o].exports;var i=s[o]={exports:{}};return n[o](i,i.exports,a),i.exports}return(function(){a.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return a.d(i,{a:i}),i}})(),(function(){a.d=function(o,i){for(var l in i)a.o(i,l)&&!a.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:i[l]})}})(),(function(){a.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)}})(),a(686)})().default})})(ut)),ut.exports}var jr=Gr();const zr=Hr(jr),Zr=e=>({toClipboard(t,n){return new Promise((s,a)=>{const o=document.createElement("button"),i=new zr(o,{text:()=>t,action:()=>"copy",container:n!==void 0?n:document.body});i.on("success",l=>{i.destroy(),s(l)}),i.on("error",l=>{i.destroy(),a(l)}),document.body.appendChild(o),o.click(),document.body.removeChild(o)})}}),qr={key:0,class:"baklava-button"},hs=r.defineComponent({__name:"CopyToClipboard",props:{text:String},setup(e){const{toClipboard:t}=Zr(),n=e,s=r.toRef(n,"text"),a=r.ref(!1),o=async()=>{try{await t(s.value),a.value=!0,setTimeout(()=>a.value=!1,1500),console.log("Copied to clipboard")}catch(i){console.error(i)}};return(i,l)=>(r.openBlock(),r.createElementBlock("div",null,[a.value?(r.openBlock(),r.createElementBlock("button",qr,[r.createVNode(r.unref(Xn))])):(r.openBlock(),r.createElementBlock("button",{key:1,onClick:o,class:"baklava-button"},[r.createVNode(r.unref(es))]))]))}}),Kr={class:"code-editor"},Jr={class:"code-buttons"},Xr=r.defineComponent({__name:"CodeEditor",props:r.mergeModels({locked:{type:Boolean},extensions:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:r.mergeModels(["update:locked"],["update:modelValue"]),setup(e,{emit:t}){const n=r.useModel(e,"modelValue"),s=t,a=o=>s("update:locked",o);return(o,i)=>{const l=r.resolveComponent("codemirror");return r.openBlock(),r.createElementBlock("div",Kr,[r.createElementVNode("div",Jr,[e.locked?(r.openBlock(),r.createElementBlock("button",{key:0,class:"baklava-button",title:"The code is locked.",onClick:i[0]||(i[0]=d=>a(!1))},[r.createVNode(r.unref(Wt))])):r.createCommentVNode("",!0),r.createVNode(hs,{text:e.modelValue},null,8,["text"])]),r.createVNode(l,{modelValue:n.value,"onUpdate:modelValue":i[1]||(i[1]=d=>n.value=d),extensions:e.extensions,class:"codemirror",style:{height:"100%"},onKeydown:i[2]||(i[2]=d=>a(!0))},null,8,["modelValue","extensions"])])}}}),Qr=r.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(e){const t=e,n=r.toRef(t,"viewModel"),s=a=>a.events.update.emit(null);return r.onMounted(n.value.onMounted),r.onBeforeUnmount(n.value.onBeforeUnmount),r.watch(n,(a,o)=>{o&&o.onBeforeUnmount(),a&&a.onMounted()}),(a,o)=>(r.openBlock(),r.createBlock(r.unref(S.BaklavaEditor),{viewModel:n.value},{palette:r.withCtx(()=>[r.createVNode(r.unref(ms))]),node:r.withCtx(i=>[r.createVNode(r.unref(fs),r.mergeProps(i,{onUpdate:l=>s(i.node)}),null,16,["onUpdate"])]),sidebar:r.withCtx(i=>[r.createVNode(r.unref(ps),r.normalizeProps(r.guardReactiveProps(i)),{codeEditor:r.withCtx(({node:l})=>[r.renderSlot(a.$slots,"sidebarCodeEditor",{node:l})]),_:3},16)]),_:3},8,["viewModel"]))}}),eo={class:"code-graph-info"},to=r.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",eo,[r.createElementVNode("div",null,"Editor graph: "+r.toDisplayString(e.viewModel.editor.graph.shortId),1),r.createElementVNode("div",null,"Displayed graph: "+r.toDisplayString(e.viewModel.displayedGraph.shortId),1),r.createElementVNode("div",null,"Graphs: "+r.toDisplayString(e.viewModel.editor.graphIds),1),r.createElementVNode("div",null,"Graph templates: "+r.toDisplayString(e.viewModel.editor.graphTemplateIds),1),r.createElementVNode("div",null,"Engine status: "+r.toDisplayString(e.viewModel.engine?.status),1)]))}}),no=["data-node-type","id"],so={class:"__title-label",style:{"flex-grow":"1"}},ao={key:0},ro={class:"__menu",style:{display:"flex"}},oo={class:"__outputs"},io={key:0},lo=["id","title"],co={class:"__inputs"},uo={key:0},ho=["id","title"],fs=r.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(e,{emit:t}){const n=S.Components.ContextMenu,s=S.Components.NodeInterface,a=e,o=r.computed(()=>a.node),i=t,{viewModel:l}=S.useViewModel(),{graph:d,switchGraph:c}=S.useGraph(),f=r.ref(null),w=r.ref(!1),m=r.ref(""),D=r.ref(null),g=r.ref(!1);let M=0,h=0;const k=r.ref(!1),A=r.computed(()=>{const U=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return a.node.type.startsWith(q.GRAPH_NODE_TYPE_PREFIX)&&U.push({value:"editSubgraph",label:"Edit Subgraph"}),U}),V=r.computed(()=>({"--selected":a.selected,"--dragging":a.dragging,"--two-column":!!a.node.twoColumn,"--hidden":o.value.state?.hidden})),H=r.computed(()=>({"--reverse-y":a.node.reverseY??l.value.settings.nodes.reverseY})),Oe=r.computed(()=>({top:`${a.node.position?.y??0}px`,left:`${a.node.position?.x??0}px`,"--width":`${a.node.width??l.value.settings.nodes.defaultWidth}px`})),Ee=r.computed(()=>Object.values(a.node.inputs).filter(U=>!U.hidden)),dt=r.computed(()=>Object.values(a.node.outputs).filter(U=>!U.hidden)),ye=()=>{qn(),i("select")},O=U=>{a.selected||ye(),i("start-drag",U)},J=()=>{k.value=!0},te=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id,U.visible=!0},qn=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id},ct=async U=>{switch(U){case"edit":te();break;case"delete":d.value.removeNode(a.node);break;case"rename":m.value=a.node.state.variableName,w.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.state.variableName=m.value,o.value.events.titleChanged.emit(o.value.state.variableName),w.value=!1},Lt=()=>{f.value&&l.value.hooks.renderNode.execute({node:a.node,el:f.value})},Kn=U=>{g.value=!0,M=a.node.width,h=U.clientX,U.preventDefault()},At=U=>{o.value.state&&(o.value.state.integrated=U,i("update"))},Ve=U=>{if(!g.value)return;const j=U.clientX-h,b=M+j/d.value.scaling,N=l.value.settings.nodes.minWidth,v=l.value.settings.nodes.maxWidth;o.value.width=Math.max(N,Math.min(v,b))},qe=()=>{g.value=!1};return r.onMounted(()=>{Lt(),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",qe)}),r.onUpdated(Lt),r.onBeforeUnmount(()=>{window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",qe)}),(U,j)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([V.value,"baklava-node"]),"data-node-type":o.value.type,id:o.value.id,style:r.normalizeStyle(Oe.value),ref_key:"el",ref:f,onPointerdown:ye},[r.unref(l).settings.nodes.resizable?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Kn},null,32)):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"__title",onPointerdown:r.withModifiers(O,["self","stop"]),onContextmenu:r.withModifiers(J,["prevent"])},[o.value.inputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:0,intf:o.value.inputs._code,node:o.value,title:o.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["intf","node","title"])):r.createCommentVNode("",!0),w.value?r.withDirectives((r.openBlock(),r.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:D,"onUpdate:modelValue":j[4]||(j[4]=b=>m.value=b),class:"baklava-input",placeholder:"Variable name",style:{"flex-grow":"1"},type:"text",onBlur:Vt,onKeydown:r.withKeys(Vt,["enter"])},null,544)),[[r.vModelText,m.value]]):(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",so,[o.value.idx>-1?(r.openBlock(),r.createElementBlock("span",ao,r.toDisplayString(o.value.idx+1)+" > ",1)):r.createCommentVNode("",!0),r.createTextVNode(" "+r.toDisplayString(o.value.state.variableName.length>0?o.value.state.variableName:o.value.title),1)]),r.createElementVNode("div",ro,[o.value.isCodeNode?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[o.value.state.lockCode?(r.openBlock(),r.createBlock(r.unref(Wt),{key:0,class:"--clickable mx-1",onClick:j[0]||(j[0]=b=>o.value.lockCode=!1)})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[o.value.state.integrated?(r.openBlock(),r.createBlock(r.unref(Qn),{key:1,class:"--clickable mx-1",onClick:j[2]||(j[2]=b=>At(!1))})):(r.openBlock(),r.createBlock(r.unref(ls),{key:0,class:"--clickable mx-1",onClick:j[1]||(j[1]=b=>At(!0))}))],64)):r.createCommentVNode("",!0),o.value.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:2,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0)],64)):r.createCommentVNode("",!0),r.createVNode(r.unref(ts),{class:"--clickable mx-1",onClick:J}),r.createVNode(r.unref(n),{modelValue:k.value,"onUpdate:modelValue":j[3]||(j[3]=b=>k.value=b),x:0,y:0,items:A.value,onClick:ct},null,8,["modelValue","items"])])],64)),o.value.outputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:3,node:o.value,intf:o.value.outputs._code,class:"--output",title:o.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):r.createCommentVNode("",!0)],32),r.createElementVNode("div",{class:r.normalizeClass(["__content",H.value]),onKeydown:j[5]||(j[5]=r.withKeys(r.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:j[6]||(j[6]=r.withModifiers(()=>{},["prevent"]))},[r.createElementVNode("div",oo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(dt.value,b=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:b.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",io,[b.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:b.id,title:b.name,class:"baklava-node-interface --output --connected"},[...j[7]||(j[7]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,lo)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,type:"output",node:o.value,intf:b},()=>[r.createVNode(r.unref(s),{node:o.value,intf:b,title:b.value},null,8,["node","intf","title"])])],64))),128))]),r.createElementVNode("div",co,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Ee.value,b=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:b.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",uo,[b.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:b.id,title:b.name,class:"baklava-node-interface --input --connected"},[...j[8]||(j[8]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,ho)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,node:o.value,intf:b,type:"input"},()=>[r.createVNode(r.unref(s),{node:o.value,intf:b,title:b.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,no))}}),fo=["id"],po={class:"align-middle"},Ht=r.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(e){const t=e,{viewModel:n}=S.useViewModel(),{hoveredOver:s,temporaryConnection:a}=S.useTemporaryConnection(),o=r.ref(null),i=r.computed(()=>t.intf.connectionCount>0),l=r.computed(()=>({"--connected":i.value})),d=()=>{s(t.intf)},c=()=>{s(void 0)},f=()=>{o.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:o.value})};return r.onMounted(f),r.onUpdated(f),(w,m)=>(r.openBlock(),r.createElementBlock("div",{id:e.intf.id,ref_key:"el",ref:o,class:r.normalizeClass(["baklava-node-interface",l.value])},[e.intf.port?(r.openBlock(),r.createElementBlock("div",{key:0,class:r.normalizeClass([{"--selected":r.unref(a)?.from===e.intf},"__port"]),onPointerover:d,onPointerout:c},null,34)):r.createCommentVNode("",!0),r.createElementVNode("span",po,[r.renderSlot(w.$slots,"default")])],10,fo))}}),mo=["title"],_o={key:0,class:"__label"},Ft=r.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;return(s,a)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["baklava-checkbox",{"--checked":e.inversed?!e.modelValue:e.modelValue,"--disabled":e.disabled}]),title:e.name,onClick:a[0]||(a[0]=o=>n("update:modelValue",!e.modelValue))},[a[1]||(a[1]=r.createElementVNode("div",{class:"__checkmark-container"},[r.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[r.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),e.name?(r.openBlock(),r.createElementBlock("div",_o,r.toDisplayString(e.name),1)):r.createCommentVNode("",!0)],10,mo))}}),yo={class:"__header"},go={class:"__node-name"},ko={class:"__interfaces"},bo={class:"__inputs"},wo={style:{display:"flex"}},vo={class:"__outputs"},No={key:0,class:"__interface"},Co=["placeholder"],Mo={style:{display:"flex"}},ps=r.defineComponent({__name:"CodeGraphSidebar",setup(e){const{viewModel:t}=S.useViewModel(),{graph:n}=S.useGraph(),s=r.ref(null),a=r.toRef(t.value.settings.sidebar,"width"),o=r.computed(()=>t.value.settings.sidebar.resizable);let i=0,l=0;const d=r.computed(()=>{const k=n.value.sidebar.nodeId;return n.value.nodes.find(A=>A.id===k)}),c=r.computed(()=>d.value),f=r.computed(()=>({width:`${a.value}px`})),w=r.computed(()=>c.value?Object.values(c.value.inputs).filter(k=>k.displayInSidebar&&k.component):[]),m=r.computed(()=>c.value?Object.values(c.value.outputs).filter(k=>k.displayInSidebar&&k.component):[]),D=()=>{n.value.sidebar.visible=!1},g=()=>{d.value?.events.update.emit(null)},M=k=>{i=a.value,l=k.clientX,window.addEventListener("mousemove",h),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",h)},{once:!0})},h=k=>{const A=s.value?.parentElement?.getBoundingClientRect().width??500,V=k.clientX-l;let H=i-V;H<300?H=300:H>.9*A&&(H=.9*A),a.value=H};return(k,A)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([{"--open":r.unref(n).sidebar.visible},"baklava-sidebar"]),style:r.normalizeStyle(f.value),ref_key:"el",ref:s},[o.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resizer",onMousedown:M},null,32)):r.createCommentVNode("",!0),d.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",yo,[r.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:D},"×"),r.createElementVNode("div",go,[r.createElementVNode("b",null,r.toDisplayString(d.value.title),1)])]),r.createElementVNode("div",ko,[r.createElementVNode("div",bo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(w.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",wo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[0]||(A[0]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),r.createElementVNode("div",vo,[c.value&&c.value.state?(r.openBlock(),r.createElementBlock("div",No,[A[3]||(A[3]=r.createElementVNode("label",null,"Variable name",-1)),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=V=>c.value.state.variableName=V),placeholder:c.value.variableName,type:"text",class:"baklava-input",title:"Variable name",onBlur:g,onKeydown:r.withKeys(g,["enter"])},null,40,Co),[[r.vModelText,c.value.state.variableName]])])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(m.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",Mo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[2]||(A[2]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),r.renderSlot(k.$slots,"codeEditor",{node:d.value})],64)):r.createCommentVNode("",!0)],6))}});function So(e,t){return Object.fromEntries(Object.entries(e).filter(t))}function Oo(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s)]))}const Eo={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},To={key:0,style:{display:"flex","justify-content":"space-between"}},Io=["onClick"],Do={key:0,style:{margin:"auto 0","font-size":"12px"}},ms=r.defineComponent({__name:"CodeNodePalette",setup(e){const t=S.Components.PaletteEntry,{viewModel:n}=S.useViewModel(),{x:s,y:a}=Ya.usePointer(),{transform:o}=S.useTransform(),i=S.useNodeCategories(n),l=r.inject("editorEl"),d=r.ref(""),c=r.ref(null),f=()=>d.value?i.value.filter(g=>g.name.toLowerCase().includes(d.value.toLowerCase())||Object.values(g.nodeTypes).some(M=>M.title.toLowerCase().includes(d.value.toLowerCase()))):i.value,w=g=>d.value?So(g,M=>{const h=M[1];return h.category.includes(d.value.toLowerCase())||h.title?.toLowerCase().includes(d.value.toLowerCase())}):g,m=r.computed(()=>{if(!c.value||!l?.value)return{};const{left:g,top:M}=l.value.getBoundingClientRect();return{top:`${a.value-M}px`,left:`${s.value-g}px`}}),D=(g,M)=>{c.value={type:g,nodeInformation:M};const h=()=>{const k=r.reactive(new M.type);n.value.displayedGraph.addNode(k);const A=l.value.getBoundingClientRect(),[V,H]=o(s.value-A.left,a.value-A.top);k.position.x=V,k.position.y=H,c.value=null,document.removeEventListener("pointerup",h)};document.addEventListener("pointerup",h)};return(g,M)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.createElementVNode("div",{class:r.normalizeClass([{"--open":r.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:M[1]||(M[1]=r.withModifiers(()=>{},["stop","prevent"]))},[r.createElementVNode("div",Eo,[r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":M[0]||(M[0]=h=>d.value=h),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:f},null,544),[[r.vModelText,d.value]])]),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(f(),h=>(r.openBlock(),r.createElementBlock("section",{key:h.name},[h.name!=="default"?(r.openBlock(),r.createElementBlock("h3",To,[r.createElementVNode("div",{onClick:k=>d.value=h.name,style:{cursor:"pointer"}},r.toDisplayString(h.name),9,Io),Object.keys(w(h.nodeTypes)).length<Object.values(h.nodeTypes).length?(r.openBlock(),r.createElementBlock("div",Do," ( "+r.toDisplayString(Object.keys(w(h.nodeTypes)).length)+" / "+r.toDisplayString(Object.values(h.nodeTypes).length)+" ) ",1)):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(w(h.nodeTypes),(k,A)=>(r.openBlock(),r.createBlock(r.unref(t),{key:A,title:k.title,type:A,onPointerdown:V=>D(A,k)},null,8,["title","type","onPointerdown"]))),128))]))),128))],34),r.createVNode(r.Transition,{name:"fade"},{default:r.withCtx(()=>[c.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:r.normalizeStyle(m.value)},[r.createVNode(r.unref(t),{type:c.value.type,title:c.value.nodeInformation.title},null,8,["type","title"])],4)):r.createCommentVNode("",!0)]),_:1})],64))}}),xo={},Yo={class:"prependIcon"},Ro={class:"appendIcon"};function Po(e,t){const n=r.resolveComponent("router-link");return r.openBlock(),r.createBlock(n,{class:"navItem"},{default:r.withCtx(()=>[r.createElementVNode("span",Yo,[r.renderSlot(e.$slots,"prependIcon")]),r.renderSlot(e.$slots,"default"),r.createElementVNode("span",Ro,[r.renderSlot(e.$slots,"appendIcon")])]),_:3})}const Gt=z(xo,[["render",Po]]),Bo={class:"navbar"},Vo=["onClick"],Lo=r.defineComponent({__name:"NavBar",props:{viewModel:{},editorStates:{},routes:{}},emits:["click:remove"],setup(e,{emit:t}){const n=t,s=a=>{n("click:remove",a)};return(a,o)=>(r.openBlock(),r.createElementBlock("nav",Bo,[r.renderSlot(a.$slots,"prepend"),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.editorStates,i=>(r.openBlock(),r.createBlock(Gt,{key:i.graph.id,class:r.normalizeClass({active:i.graph.id===e.viewModel.displayedGraph.id}),to:{name:e.routes?.edit??"edit",params:{editorId:i.graph.id}}},{appendIcon:r.withCtx(()=>[r.createElementVNode("button",{class:"remove",onClick:r.withModifiers(l=>s(i.graph.id),["prevent"])},[r.createVNode(r.unref(cs))],8,Vo)]),default:r.withCtx(()=>[r.createTextVNode(r.toDisplayString(i.graph.id.slice(0,6))+" ",1)]),_:2},1032,["class","to"]))),128)),r.renderSlot(a.$slots,"append",{},()=>[r.createVNode(Gt,{to:{name:e.routes?.new??"new"},class:"navItem"},{default:r.withCtx(()=>[r.createVNode(r.unref(as),{class:"plus"})]),_:1},8,["to"])])]))}}),Ao=r.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(e,{emit:t}){return{v:r.computed({get:()=>e.modelValue,set:s=>{t("update:modelValue",s)}})}}}),Uo={style:{position:"relative"}},$o={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},Wo=["placeholder","title"];function Ho(e,t,n,s,a,o){return r.openBlock(),r.createElementBlock("div",Uo,[r.createElementVNode("label",$o,r.toDisplayString(e.intf.name),1),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>e.v=i),type:"text",class:"baklava-input",placeholder:e.intf.name,title:e.intf.name},null,8,Wo),[[r.vModelText,e.v]])])}const jt=z(Ao,[["render",Ho]]),Fo=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:Xr,CodeGraphEditor:Qr,CodeGraphInfo:to,CodeGraphNode:fs,CodeGraphNodeInterface:Ht,CodeGraphSidebar:ps,CodeNodePalette:ms,CopyToClipboard:hs,NavBar:Lo,NavItem:Gt,SidebarCheckbox:Ft,TextInputInterface:jt},Symbol.toStringTag,{value:"Module"}));Le.escape=e=>e;class zt extends q.AbstractNode{codeTemplate;isCodeNode=!0;mask=null;name="";state;_variableName="";inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=r.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:""}),this.codeTemplate=function(){return`${this.name}(${_s(this.codeNodeInputs).join(", ")})`}}get code(){return this.graph.code}get codeNodeInputs(){return Object.fromEntries(Object.entries(this.inputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get codeNodeOutputs(){return Object.fromEntries(Object.entries(this.outputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get graph(){return super.graph}get hasConnectedOutputNodes(){return this.getConnectedNodes("outputs").length>0}get idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByType(){return this.graph.getNodesByType(this.type).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesByVariableName(this.state.variableName||this._variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}get isSelected(){return this.graph.selectedNodeIds.includes(this.id)}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.events.update.emit(null)}get optionalInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>t[1].optional))}get requiredInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>!t[1].optional))}get script(){return this.outputs._code?.value??""}set script(t){this.outputs._code&&(this.outputs._code.value=t),this.events.update.emit(null)}get shortId(){return this.id.slice(0,6)}get subgraph(){}get variableName(){return this.state.variableName||this._variableName?this.state.variableName||this._variableName+(this.idxByVariableNames+1):""}getConnectedNodeByInterface(t,n){const s=this.getConnectedNodesByInterface(t,n);return s.length>0?s[0]:null}getConnectedNodes(t){let n=[];if(t!=="inputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.from.nodeId===this.id).map(a=>a.to.nodeId);s&&(n=n.concat(s))}if(t!=="outputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.to.nodeId===this.id).map(a=>a.from.nodeId);s&&(n=n.concat(s))}return!n||n.length==0?[]:n.map(s=>this.graph.findNodeById(s))}getConnectedNodesByInterface(t,n){let s=[];if(n!=="outputs"&&this.inputs[t]){const a=this.graph.connections.filter(o=>o.to.id===this.inputs[t]?.id||o.from.id===this.inputs[t]?.id).map(o=>o.from.nodeId);a&&(s=s.concat(a))}if(n!=="inputs"&&this.outputs[t]){const a=this.graph.connections.filter(o=>o.from.id===this.outputs[t]?.id||o.from.id===this.outputs[t]?.id).map(o=>o.to.nodeId);a&&(s=s.concat(a))}return!s||s.length==0?[]:s.map(a=>this.graph.findNodeById(a))}remove(){this.graph?.removeNode(this)}renderCode(t){return Le.render(this.state.codeTemplate,t)}updateCodeTemplate(){this.state.codeTemplate=this.codeTemplate.call(this)}updateModules(t){if(t)this.state.modules=t;else if(this.type.includes(".")){const n=this.type.split(".");this.state.modules.push(n.slice(0,n.length-1).join("."))}}updateOutputNames(){Object.values(this.codeNodeOutputs).forEach(t=>{t.name=this.state.integrated?"":this.variableName+t.suffix})}updateOutputValues(t){Object.keys(this.outputs).forEach(n=>{n!=="_code"&&(t[n]=this.state.integrated?t._code:this.outputs[n].name)})}updateProps(t){this.state.props=t}updateInputValues(t){const n=Object.keys(this.inputs);Object.keys(t).forEach(s=>{!n.includes(s)||!this.inputs[s]||(this.inputs[s].value=t[s],this.inputs[s].setHidden(!1))})}}class ht extends zt{calculate=(t,n)=>{const s={};return this.lockCode||(s._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(s),s};executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}load(t){super.load(t),this.afterLoaded()}}const _s=(e,t=!0)=>{const n=[],s=Object.keys(e);return s.forEach(a=>{if(e[a]?.hidden)return;const i=t&&n.length<s.indexOf(a)?`${a}=`:"";n.push(`${i}{{ inputs.${a} }}`)}),n},ys=(e,t)=>{switch(e){case"CheckBoxInterface":return new ks(t.id,t.value);case"IntegerInterface":return new en(t.id,t.value,t.min,t.max);case"NumberInterface":return new ws(t.id,t.value,t.min,t.max);case"SelectInterface":return new vs(t.id,t.value,t.items);default:return new nn(t.id,t.value)}},Go=["title"],ft=r.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",{title:e.intf.value},r.toDisplayString(e.intf.name),9,Go))}});class Q extends q.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(r.markRaw(ft)),this.state=r.reactive({optional:!1})}get optional(){return this.state.optional}get shortId(){return this.id.slice(0,6)}getValue=()=>`${this.value??"None"}`;load(t){this.id=t.id,this.templateId=t.templateId,this.name!=="_code"&&(t.optional&&(this.state.optional=t.optional),this.value=t.value,this.hooks.load.execute(t),this.hidden=t.hidden)}save(){const t={id:this.id,templateId:this.templateId,value:this.value,hidden:this.hidden};return this.state.optional&&(t.optional=this.state.optional),this.hooks.save.execute(t)}setOptional(t){return this.state.optional=t,this.setHidden(t),this}}class Ae extends Q{constructor(t="",n){super(t,n),this.setComponent(r.markRaw(ft)),this.use(S.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const Zt=new G.NodeInterfaceType("boolean"),gs=new G.NodeInterfaceType("dict"),qt=new G.NodeInterfaceType("list"),se=new G.NodeInterfaceType("node"),Kt=new G.NodeInterfaceType("number"),Jt=new G.NodeInterfaceType("string"),Xt=new G.NodeInterfaceType("tuple"),jo=e=>{new G.BaklavaInterfaceTypes(e.editor,{viewPlugin:e}).addTypes(Zt,gs,qt,se,Kt,Jt,Xt)};class ks extends Ae{constructor(t,n){super(t,n),this.setComponent(r.markRaw(S.CheckboxInterfaceComponent)),this.use(G.setType,Zt)}getValue=()=>this.value?"True":"False"}class bs extends Q{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(r.markRaw(ft))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=S.useGraph();return t.value.findNodeById(this.nodeId)}}class Qt extends Ae{min;max;constructor(t,n,s,a){super(t,n),this.min=s,this.max=a,this.use(G.setType,Kt)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class en extends Qt{component=r.markRaw(S.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class zo extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,qt)}getValue=()=>`[${this.value}]`}class ws extends Qt{component=r.markRaw(S.NumberInterfaceComponent)}class tn extends Ae{constructor(t,n){super(t,n),this.use(G.setType,Jt)}getValue=()=>`"${this.value}"`}class vs extends tn{component=r.markRaw(S.SelectInterfaceComponent);items;constructor(t,n,s){super(t,n),this.items=s}}class Zo extends Qt{component=r.markRaw(S.SliderInterfaceComponent);min;max;constructor(t,n,s,a){super(t,n,s,a),this.min=s,this.max=a}getValue=()=>`${Math.round(this.value*1e3)/1e3}`}class nn extends tn{component=r.markRaw(jt)}class qo extends tn{component=r.markRaw(S.TextareaInputInterfaceComponent)}class Ko extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Xt)}getValue=()=>`(${this.value})`}function Jo(e){return class extends ht{type=e.type;inputs={};outputs={};constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName!=null&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0))}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}}}class Ns extends ht{}function Xo(e){return class extends Ns{type=e.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(e.inputs??{});staticOutputKeys=Object.keys(e.outputs??{});constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate?.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){this.events.update.subscribe(this,t=>{t&&(t.type==="input"&&this.staticInputKeys.includes(t.name)||t.type==="output"&&this.staticOutputKeys.includes(t.name))&&this.onUpdate()}),this.onUpdate(),e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}load(t){this.preventUpdate=!0,this.hooks.beforeLoad.execute(t),this.id=t.id,this.title=t.title;for(const n of this.staticInputKeys)this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id;for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id;this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!(this.staticInputKeys.includes(n)||!t.inputs[n])){if(!this.inputs[n]){const s=t.inputs[n],a=s.value;let o;s.component?o=ys(s.component,{...s,id:n}):typeof a=="number"?o=new en(n,a):o=new nn(n,JSON.stringify(a)),o.use(S.displayInSidebar,!0),this.addInput(n,o)}this.inputs[n]&&(this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id)}for(const n of Object.keys(t.outputs))if(!(this.staticOutputKeys.includes(n)||!t.outputs[n])){if(!this.outputs[n]){const s=new bs(n);this.addOutput(n,s)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(!e.onUpdate||this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),s=e.onUpdate.call(this,t,n);this.updateInterfaces("input",s.inputs??{},s.forceUpdateInputs??[]),this.updateInterfaces("output",s.outputs??{},s.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const s={};for(const a of t)s[a]=n[a].value;return s}updateInputInterfaces(t={},n=[]){this.updateInterfaces("input",t,n)}updateInterfaces(t,n={},s=[]){const a=t==="input"?this.staticInputKeys:this.staticOutputKeys,o=t==="input"?this.inputs:this.outputs;for(const i of Object.keys(o))a.includes(i)||n[i]&&!s.includes(i)||(t==="input"?this.removeInput(i):this.removeOutput(i));for(const i of Object.keys(n)){if(o[i])continue;const l=n[i]();t==="input"?this.addInput(i,l):this.addOutput(i,l)}}updateProps(t){this.state.props=t,this.onUpdate()}}}Le.escape=e=>e;class pt{_id;_state;viewModel;constructor(){this._id=xe.v4(),this._state=r.reactive({lockCode:!1,modules:{},script:"",template:""})}get engine(){return this.viewModel?.engine}get graph(){return this.viewModel?.editor.graph}get id(){return this._id}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.engine?.runOnce(null)}get modules(){const t=[];return this.graph?.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>t.push(...n.state.modules)),t?(t.sort(),Array.from(new Set(t.map(n=>this.state.modules[n])))):[]}get script(){return this.state.script}set script(t){this.state.script=t,this.engine?.runOnce(null)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}clear(){this.state.script=""}async loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}registerViewModel(t){this.viewModel=t}renderCode(t){this.state.script=Le.render(this.state.template??"",t??{})}}class Qo extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>hu))}}class ei extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>fu))}}const ti=e=>{e.allowMultipleConnections=!0};class Cs extends he.BaseEngine{order=new Map;constructor(t){super(t)}start(){super.start(),this.recalculateOrder=!0,this.calculateWithoutData()}async runGraph(t,n,s){this.order.has(t.id)||this.order.set(t.id,he.sortTopologically(t));const{calculationOrder:a,connectionsFromNode:o}=this.order.get(t.id),i=new Map;for(const l of a){const d={};Object.entries(l.inputs).forEach(([f,w])=>{d[f]=this.getInterfaceValue(n,w.id)}),l.isCodeNode&&(l.updateCodeTemplate(),l.updateOutputNames()),this.events.beforeNodeCalculation.emit({inputValues:d,node:l});let c;if(l.calculate){if(c=await l.calculate(d,{globalValues:s,engine:this}),o.has(l))for(const[f,w]of Object.entries(c))this.hooks.transferData.execute(c[f],w),o.get(l).forEach(m=>n.set(m.to.id,w))}else{c={};for(const[f,w]of Object.entries(l.outputs))c[f]=this.getInterfaceValue(n,w.id)}this.events.afterNodeCalculation.emit({outputValues:c,node:l}),i.set(l.id,new Map(Object.entries(c))),o.has(l)&&o.get(l).forEach(f=>{const w=Object.entries(l.outputs).find(([,D])=>D.id===f.from.id)?.[0];if(!w)throw new Error(`Could not find key for interface ${f.from.id}
2
2
  This is likely an internal issue. Please report it on GitHub.`);const m=this.hooks.transferData.execute(c[w],f);w!=="_code"&&(f.to.allowMultipleConnections?n.has(f.to.id)?n.get(f.to.id).push(m):n.set(f.to.id,[m]):n.set(f.to.id,m))})}return i}async execute(t){this.recalculateOrder&&(this.order.clear(),this.recalculateOrder=!1);const n=this.getInputValues(this.editor.graph);return await this.runGraph(this.editor.graph,n,t)}getInputValues(t){const n=new Map;for(const s of t.nodes)Object.values(s.inputs).forEach(a=>{a.connectionCount===0&&n.set(a.id,a.getValue?a.getValue():a.value)}),s.calculate||Object.values(s.outputs).forEach(a=>{n.set(a.id,a.getValue?a.getValue():a.value)});return n}onChange(t){this.recalculateOrder=t||this.recalculateOrder,this.calculateWithoutData()}getInterfaceValue(t,n){if(!t.has(n))throw new Error(`Could not find value for interface ${n}
3
3
  This is likely an internal issue. Please report it on GitHub.`);return t.get(n)}}var Ms;function _(){return Ms.apply(null,arguments)}function ni(e){Ms=e}function ie(e){return e instanceof Array||Object.prototype.toString.call(e)==="[object Array]"}function Ye(e){return e!=null&&Object.prototype.toString.call(e)==="[object Object]"}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sn(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;var t;for(t in e)if(P(e,t))return!1;return!0}function ee(e){return e===void 0}function ge(e){return typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]"}function Ke(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function Ss(e,t){var n=[],s,a=e.length;for(s=0;s<a;++s)n.push(t(e[s],s));return n}function Te(e,t){for(var n in t)P(t,n)&&(e[n]=t[n]);return P(t,"toString")&&(e.toString=t.toString),P(t,"valueOf")&&(e.valueOf=t.valueOf),e}function fe(e,t,n,s){return Qs(e,t,n,s,!0).utc()}function si(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function T(e){return e._pf==null&&(e._pf=si()),e._pf}var an;Array.prototype.some?an=Array.prototype.some:an=function(e){var t=Object(this),n=t.length>>>0,s;for(s=0;s<n;s++)if(s in t&&e.call(this,t[s],s,t))return!0;return!1};function rn(e){var t=null,n=!1,s=e._d&&!isNaN(e._d.getTime());if(s&&(t=T(e),n=an.call(t.parsedDateParts,function(a){return a!=null}),s=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&n),e._strict&&(s=s&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(e))e._isValid=s;else return s;return e._isValid}function mt(e){var t=fe(NaN);return e!=null?Te(T(t),e):T(t).userInvalidated=!0,t}var Os=_.momentProperties=[],on=!1;function ln(e,t){var n,s,a,o=Os.length;if(ee(t._isAMomentObject)||(e._isAMomentObject=t._isAMomentObject),ee(t._i)||(e._i=t._i),ee(t._f)||(e._f=t._f),ee(t._l)||(e._l=t._l),ee(t._strict)||(e._strict=t._strict),ee(t._tzm)||(e._tzm=t._tzm),ee(t._isUTC)||(e._isUTC=t._isUTC),ee(t._offset)||(e._offset=t._offset),ee(t._pf)||(e._pf=T(t)),ee(t._locale)||(e._locale=t._locale),o>0)for(n=0;n<o;n++)s=Os[n],a=t[s],ee(a)||(e[s]=a);return e}function Je(e){ln(this,e),this._d=new Date(e._d!=null?e._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),on===!1&&(on=!0,_.updateOffset(this),on=!1)}function le(e){return e instanceof Je||e!=null&&e._isAMomentObject!=null}function Es(e){_.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+e)}function ae(e,t){var n=!0;return Te(function(){if(_.deprecationHandler!=null&&_.deprecationHandler(null,e),n){var s=[],a,o,i,l=arguments.length;for(o=0;o<l;o++){if(a="",typeof arguments[o]=="object"){a+=`
4
4
  [`+o+"] ";for(i in arguments[0])P(arguments[0],i)&&(a+=i+": "+arguments[0][i]+", ");a=a.slice(0,-2)}else a=arguments[o];s.push(a)}Es(e+`
5
5
  Arguments: `+Array.prototype.slice.call(s).join("")+`
6
- `+new Error().stack),n=!1}return t.apply(this,arguments)},t)}var Ts={};function Is(e,t){_.deprecationHandler!=null&&_.deprecationHandler(e,t),Ts[e]||(Es(t),Ts[e]=!0)}_.suppressDeprecationWarnings=!1,_.deprecationHandler=null;function pe(e){return typeof Function<"u"&&e instanceof Function||Object.prototype.toString.call(e)==="[object Function]"}function ai(e){var t,n;for(n in e)P(e,n)&&(t=e[n],pe(t)?this[n]=t:this["_"+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function dn(e,t){var n=Te({},e),s;for(s in t)P(t,s)&&(Ye(e[s])&&Ye(t[s])?(n[s]={},Te(n[s],e[s]),Te(n[s],t[s])):t[s]!=null?n[s]=t[s]:delete n[s]);for(s in e)P(e,s)&&!P(t,s)&&Ye(e[s])&&(n[s]=Te({},n[s]));return n}function cn(e){e!=null&&this.set(e)}var un;Object.keys?un=Object.keys:un=function(e){var t,n=[];for(t in e)P(e,t)&&n.push(t);return n};var ri={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function oi(e,t,n){var s=this._calendar[e]||this._calendar.sameElse;return pe(s)?s.call(t,n):s}function me(e,t,n){var s=""+Math.abs(e),a=t-s.length,o=e>=0;return(o?n?"+":"":"-")+Math.pow(10,Math.max(0,a)).toString().substr(1)+s}var hn=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,_t=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,fn={},Ue={};function C(e,t,n,s){var a=s;typeof s=="string"&&(a=function(){return this[s]()}),e&&(Ue[e]=a),t&&(Ue[t[0]]=function(){return me(a.apply(this,arguments),t[1],t[2])}),n&&(Ue[n]=function(){return this.localeData().ordinal(a.apply(this,arguments),e)})}function ii(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function li(e){var t=e.match(hn),n,s;for(n=0,s=t.length;n<s;n++)Ue[t[n]]?t[n]=Ue[t[n]]:t[n]=ii(t[n]);return function(a){var o="",i;for(i=0;i<s;i++)o+=pe(t[i])?t[i].call(a,e):t[i];return o}}function yt(e,t){return e.isValid()?(t=Ds(t,e.localeData()),fn[t]=fn[t]||li(t),fn[t](e)):e.localeData().invalidDate()}function Ds(e,t){var n=5;function s(a){return t.longDateFormat(a)||a}for(_t.lastIndex=0;n>=0&&_t.test(e);)e=e.replace(_t,s),_t.lastIndex=0,n-=1;return e}var di={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function ci(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(hn).map(function(s){return s==="MMMM"||s==="MM"||s==="DD"||s==="dddd"?s.slice(1):s}).join(""),this._longDateFormat[e])}var ui="Invalid date";function hi(){return this._invalidDate}var fi="%d",pi=/\d{1,2}/;function mi(e){return this._ordinal.replace("%d",e)}var _i={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function yi(e,t,n,s){var a=this._relativeTime[n];return pe(a)?a(e,t,n,s):a.replace(/%d/i,e)}function gi(e,t){var n=this._relativeTime[e>0?"future":"past"];return pe(n)?n(t):n.replace(/%s/i,t)}var xs={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function re(e){return typeof e=="string"?xs[e]||xs[e.toLowerCase()]:void 0}function pn(e){var t={},n,s;for(s in e)P(e,s)&&(n=re(s),n&&(t[n]=e[s]));return t}var ki={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function bi(e){var t=[],n;for(n in e)P(e,n)&&t.push({unit:n,priority:ki[n]});return t.sort(function(s,a){return s.priority-a.priority}),t}var Ys=/\d/,ne=/\d\d/,Rs=/\d{3}/,mn=/\d{4}/,gt=/[+-]?\d{6}/,$=/\d\d?/,Ps=/\d\d\d\d?/,Bs=/\d\d\d\d\d\d?/,kt=/\d{1,3}/,_n=/\d{1,4}/,bt=/[+-]?\d{1,6}/,$e=/\d+/,wt=/[+-]?\d+/,wi=/Z|[+-]\d\d:?\d\d/gi,vt=/Z|[+-]\d\d(?::?\d\d)?/gi,vi=/[+-]?\d+(\.\d{1,3})?/,Xe=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,We=/^[1-9]\d?/,yn=/^([1-9]\d|\d)/,Nt;Nt={};function y(e,t,n){Nt[e]=pe(t)?t:function(s,a){return s&&n?n:t}}function Ni(e,t){return P(Nt,e)?Nt[e](t._strict,t._locale):new RegExp(Ci(e))}function Ci(e){return ke(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,n,s,a,o){return n||s||a||o}))}function ke(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function oe(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function x(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=oe(t)),n}var gn={};function L(e,t){var n,s=t,a;for(typeof e=="string"&&(e=[e]),ge(t)&&(s=function(o,i){i[t]=x(o)}),a=e.length,n=0;n<a;n++)gn[e[n]]=s}function Qe(e,t){L(e,function(n,s,a,o){a._w=a._w||{},t(n,a._w,a,o)})}function Mi(e,t,n){t!=null&&P(gn,e)&&gn[e](t,n._a,n,e)}function Ct(e){return e%4===0&&e%100!==0||e%400===0}var X=0,be=1,_e=2,K=3,de=4,we=5,Re=6,Si=7,Oi=8;C("Y",0,0,function(){var e=this.year();return e<=9999?me(e,4):"+"+e}),C(0,["YY",2],0,function(){return this.year()%100}),C(0,["YYYY",4],0,"year"),C(0,["YYYYY",5],0,"year"),C(0,["YYYYYY",6,!0],0,"year"),y("Y",wt),y("YY",$,ne),y("YYYY",_n,mn),y("YYYYY",bt,gt),y("YYYYYY",bt,gt),L(["YYYYY","YYYYYY"],X),L("YYYY",function(e,t){t[X]=e.length===2?_.parseTwoDigitYear(e):x(e)}),L("YY",function(e,t){t[X]=_.parseTwoDigitYear(e)}),L("Y",function(e,t){t[X]=parseInt(e,10)});function et(e){return Ct(e)?366:365}_.parseTwoDigitYear=function(e){return x(e)+(x(e)>68?1900:2e3)};var Vs=He("FullYear",!0);function Ei(){return Ct(this.year())}function He(e,t){return function(n){return n!=null?(Ls(this,e,n),_.updateOffset(this,t),this):tt(this,e)}}function tt(e,t){if(!e.isValid())return NaN;var n=e._d,s=e._isUTC;switch(t){case"Milliseconds":return s?n.getUTCMilliseconds():n.getMilliseconds();case"Seconds":return s?n.getUTCSeconds():n.getSeconds();case"Minutes":return s?n.getUTCMinutes():n.getMinutes();case"Hours":return s?n.getUTCHours():n.getHours();case"Date":return s?n.getUTCDate():n.getDate();case"Day":return s?n.getUTCDay():n.getDay();case"Month":return s?n.getUTCMonth():n.getMonth();case"FullYear":return s?n.getUTCFullYear():n.getFullYear();default:return NaN}}function Ls(e,t,n){var s,a,o,i,l;if(!(!e.isValid()||isNaN(n))){switch(s=e._d,a=e._isUTC,t){case"Milliseconds":return void(a?s.setUTCMilliseconds(n):s.setMilliseconds(n));case"Seconds":return void(a?s.setUTCSeconds(n):s.setSeconds(n));case"Minutes":return void(a?s.setUTCMinutes(n):s.setMinutes(n));case"Hours":return void(a?s.setUTCHours(n):s.setHours(n));case"Date":return void(a?s.setUTCDate(n):s.setDate(n));case"FullYear":break;default:return}o=n,i=e.month(),l=e.date(),l=l===29&&i===1&&!Ct(o)?28:l,a?s.setUTCFullYear(o,i,l):s.setFullYear(o,i,l)}}function Ti(e){return e=re(e),pe(this[e])?this[e]():this}function Ii(e,t){if(typeof e=="object"){e=pn(e);var n=bi(e),s,a=n.length;for(s=0;s<a;s++)this[n[s].unit](e[n[s].unit])}else if(e=re(e),pe(this[e]))return this[e](t);return this}function Di(e,t){return(e%t+t)%t}var Z;Array.prototype.indexOf?Z=Array.prototype.indexOf:Z=function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function kn(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=Di(t,12);return e+=(t-n)/12,n===1?Ct(e)?29:28:31-n%7%2}C("M",["MM",2],"Mo",function(){return this.month()+1}),C("MMM",0,0,function(e){return this.localeData().monthsShort(this,e)}),C("MMMM",0,0,function(e){return this.localeData().months(this,e)}),y("M",$,We),y("MM",$,ne),y("MMM",function(e,t){return t.monthsShortRegex(e)}),y("MMMM",function(e,t){return t.monthsRegex(e)}),L(["M","MM"],function(e,t){t[be]=x(e)-1}),L(["MMM","MMMM"],function(e,t,n,s){var a=n._locale.monthsParse(e,s,n._strict);a!=null?t[be]=a:T(n).invalidMonth=e});var xi="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),As="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Us=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Yi=Xe,Ri=Xe;function Pi(e,t){return e?ie(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Us).test(t)?"format":"standalone"][e.month()]:ie(this._months)?this._months:this._months.standalone}function Bi(e,t){return e?ie(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Us.test(t)?"format":"standalone"][e.month()]:ie(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Vi(e,t,n){var s,a,o,i=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],s=0;s<12;++s)o=fe([2e3,s]),this._shortMonthsParse[s]=this.monthsShort(o,"").toLocaleLowerCase(),this._longMonthsParse[s]=this.months(o,"").toLocaleLowerCase();return n?t==="MMM"?(a=Z.call(this._shortMonthsParse,i),a!==-1?a:null):(a=Z.call(this._longMonthsParse,i),a!==-1?a:null):t==="MMM"?(a=Z.call(this._shortMonthsParse,i),a!==-1?a:(a=Z.call(this._longMonthsParse,i),a!==-1?a:null)):(a=Z.call(this._longMonthsParse,i),a!==-1?a:(a=Z.call(this._shortMonthsParse,i),a!==-1?a:null))}function Li(e,t,n){var s,a,o;if(this._monthsParseExact)return Vi.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),s=0;s<12;s++){if(a=fe([2e3,s]),n&&!this._longMonthsParse[s]&&(this._longMonthsParse[s]=new RegExp("^"+this.months(a,"").replace(".","")+"$","i"),this._shortMonthsParse[s]=new RegExp("^"+this.monthsShort(a,"").replace(".","")+"$","i")),!n&&!this._monthsParse[s]&&(o="^"+this.months(a,"")+"|^"+this.monthsShort(a,""),this._monthsParse[s]=new RegExp(o.replace(".",""),"i")),n&&t==="MMMM"&&this._longMonthsParse[s].test(e))return s;if(n&&t==="MMM"&&this._shortMonthsParse[s].test(e))return s;if(!n&&this._monthsParse[s].test(e))return s}}function $s(e,t){if(!e.isValid())return e;if(typeof t=="string"){if(/^\d+$/.test(t))t=x(t);else if(t=e.localeData().monthsParse(t),!ge(t))return e}var n=t,s=e.date();return s=s<29?s:Math.min(s,kn(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,s):e._d.setMonth(n,s),e}function Ws(e){return e!=null?($s(this,e),_.updateOffset(this,!0),this):tt(this,"Month")}function Ai(){return kn(this.year(),this.month())}function Ui(e){return this._monthsParseExact?(P(this,"_monthsRegex")||Hs.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(P(this,"_monthsShortRegex")||(this._monthsShortRegex=Yi),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function $i(e){return this._monthsParseExact?(P(this,"_monthsRegex")||Hs.call(this),e?this._monthsStrictRegex:this._monthsRegex):(P(this,"_monthsRegex")||(this._monthsRegex=Ri),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Hs(){function e(d,c){return c.length-d.length}var t=[],n=[],s=[],a,o,i,l;for(a=0;a<12;a++)o=fe([2e3,a]),i=ke(this.monthsShort(o,"")),l=ke(this.months(o,"")),t.push(i),n.push(l),s.push(l),s.push(i);t.sort(e),n.sort(e),s.sort(e),this._monthsRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function Wi(e,t,n,s,a,o,i){var l;return e<100&&e>=0?(l=new Date(e+400,t,n,s,a,o,i),isFinite(l.getFullYear())&&l.setFullYear(e)):l=new Date(e,t,n,s,a,o,i),l}function nt(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Mt(e,t,n){var s=7+t-n,a=(7+nt(e,0,s).getUTCDay()-t)%7;return-a+s-1}function Fs(e,t,n,s,a){var o=(7+n-s)%7,i=Mt(e,s,a),l=1+7*(t-1)+o+i,d,c;return l<=0?(d=e-1,c=et(d)+l):l>et(e)?(d=e+1,c=l-et(e)):(d=e,c=l),{year:d,dayOfYear:c}}function st(e,t,n){var s=Mt(e.year(),t,n),a=Math.floor((e.dayOfYear()-s-1)/7)+1,o,i;return a<1?(i=e.year()-1,o=a+ve(i,t,n)):a>ve(e.year(),t,n)?(o=a-ve(e.year(),t,n),i=e.year()+1):(i=e.year(),o=a),{week:o,year:i}}function ve(e,t,n){var s=Mt(e,t,n),a=Mt(e+1,t,n);return(et(e)-s+a)/7}C("w",["ww",2],"wo","week"),C("W",["WW",2],"Wo","isoWeek"),y("w",$,We),y("ww",$,ne),y("W",$,We),y("WW",$,ne),Qe(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=x(e)});function Hi(e){return st(e,this._week.dow,this._week.doy).week}var Fi={dow:0,doy:6};function Gi(){return this._week.dow}function ji(){return this._week.doy}function zi(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,"d")}function Zi(e){var t=st(this,1,4).week;return e==null?t:this.add((e-t)*7,"d")}C("d",0,"do","day"),C("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),C("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),C("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),C("e",0,0,"weekday"),C("E",0,0,"isoWeekday"),y("d",$),y("e",$),y("E",$),y("dd",function(e,t){return t.weekdaysMinRegex(e)}),y("ddd",function(e,t){return t.weekdaysShortRegex(e)}),y("dddd",function(e,t){return t.weekdaysRegex(e)}),Qe(["dd","ddd","dddd"],function(e,t,n,s){var a=n._locale.weekdaysParse(e,s,n._strict);a!=null?t.d=a:T(n).invalidWeekday=e}),Qe(["d","e","E"],function(e,t,n,s){t[s]=x(e)});function qi(e,t){return typeof e!="string"?e:isNaN(e)?(e=t.weekdaysParse(e),typeof e=="number"?e:null):parseInt(e,10)}function Ki(e,t){return typeof e=="string"?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function bn(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Ji="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Gs="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Xi="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Qi=Xe,el=Xe,tl=Xe;function nl(e,t){var n=ie(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return e===!0?bn(n,this._week.dow):e?n[e.day()]:n}function sl(e){return e===!0?bn(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function al(e){return e===!0?bn(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rl(e,t,n){var s,a,o,i=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],s=0;s<7;++s)o=fe([2e3,1]).day(s),this._minWeekdaysParse[s]=this.weekdaysMin(o,"").toLocaleLowerCase(),this._shortWeekdaysParse[s]=this.weekdaysShort(o,"").toLocaleLowerCase(),this._weekdaysParse[s]=this.weekdays(o,"").toLocaleLowerCase();return n?t==="dddd"?(a=Z.call(this._weekdaysParse,i),a!==-1?a:null):t==="ddd"?(a=Z.call(this._shortWeekdaysParse,i),a!==-1?a:null):(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null):t==="dddd"?(a=Z.call(this._weekdaysParse,i),a!==-1||(a=Z.call(this._shortWeekdaysParse,i),a!==-1)?a:(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null)):t==="ddd"?(a=Z.call(this._shortWeekdaysParse,i),a!==-1||(a=Z.call(this._weekdaysParse,i),a!==-1)?a:(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null)):(a=Z.call(this._minWeekdaysParse,i),a!==-1||(a=Z.call(this._weekdaysParse,i),a!==-1)?a:(a=Z.call(this._shortWeekdaysParse,i),a!==-1?a:null))}function ol(e,t,n){var s,a,o;if(this._weekdaysParseExact)return rl.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),s=0;s<7;s++){if(a=fe([2e3,1]).day(s),n&&!this._fullWeekdaysParse[s]&&(this._fullWeekdaysParse[s]=new RegExp("^"+this.weekdays(a,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[s]=new RegExp("^"+this.weekdaysShort(a,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[s]=new RegExp("^"+this.weekdaysMin(a,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[s]||(o="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[s]=new RegExp(o.replace(".",""),"i")),n&&t==="dddd"&&this._fullWeekdaysParse[s].test(e))return s;if(n&&t==="ddd"&&this._shortWeekdaysParse[s].test(e))return s;if(n&&t==="dd"&&this._minWeekdaysParse[s].test(e))return s;if(!n&&this._weekdaysParse[s].test(e))return s}}function il(e){if(!this.isValid())return e!=null?this:NaN;var t=tt(this,"Day");return e!=null?(e=qi(e,this.localeData()),this.add(e-t,"d")):t}function ll(e){if(!this.isValid())return e!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,"d")}function dl(e){if(!this.isValid())return e!=null?this:NaN;if(e!=null){var t=Ki(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function cl(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(P(this,"_weekdaysRegex")||(this._weekdaysRegex=Qi),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function ul(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(P(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=el),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function hl(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(P(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=tl),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function wn(){function e(f,w){return w.length-f.length}var t=[],n=[],s=[],a=[],o,i,l,d,c;for(o=0;o<7;o++)i=fe([2e3,1]).day(o),l=ke(this.weekdaysMin(i,"")),d=ke(this.weekdaysShort(i,"")),c=ke(this.weekdays(i,"")),t.push(l),n.push(d),s.push(c),a.push(l),a.push(d),a.push(c);t.sort(e),n.sort(e),s.sort(e),a.sort(e),this._weekdaysRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function vn(){return this.hours()%12||12}function fl(){return this.hours()||24}C("H",["HH",2],0,"hour"),C("h",["hh",2],0,vn),C("k",["kk",2],0,fl),C("hmm",0,0,function(){return""+vn.apply(this)+me(this.minutes(),2)}),C("hmmss",0,0,function(){return""+vn.apply(this)+me(this.minutes(),2)+me(this.seconds(),2)}),C("Hmm",0,0,function(){return""+this.hours()+me(this.minutes(),2)}),C("Hmmss",0,0,function(){return""+this.hours()+me(this.minutes(),2)+me(this.seconds(),2)});function js(e,t){C(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}js("a",!0),js("A",!1);function zs(e,t){return t._meridiemParse}y("a",zs),y("A",zs),y("H",$,yn),y("h",$,We),y("k",$,We),y("HH",$,ne),y("hh",$,ne),y("kk",$,ne),y("hmm",Ps),y("hmmss",Bs),y("Hmm",Ps),y("Hmmss",Bs),L(["H","HH"],K),L(["k","kk"],function(e,t,n){var s=x(e);t[K]=s===24?0:s}),L(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),L(["h","hh"],function(e,t,n){t[K]=x(e),T(n).bigHour=!0}),L("hmm",function(e,t,n){var s=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s)),T(n).bigHour=!0}),L("hmmss",function(e,t,n){var s=e.length-4,a=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s,2)),t[we]=x(e.substr(a)),T(n).bigHour=!0}),L("Hmm",function(e,t,n){var s=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s))}),L("Hmmss",function(e,t,n){var s=e.length-4,a=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s,2)),t[we]=x(e.substr(a))});function pl(e){return(e+"").toLowerCase().charAt(0)==="p"}var ml=/[ap]\.?m?\.?/i,_l=He("Hours",!0);function yl(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"}var Zs={calendar:ri,longDateFormat:di,invalidDate:ui,ordinal:fi,dayOfMonthOrdinalParse:pi,relativeTime:_i,months:xi,monthsShort:As,week:Fi,weekdays:Ji,weekdaysMin:Xi,weekdaysShort:Gs,meridiemParse:ml},F={},at={},rt;function gl(e,t){var n,s=Math.min(e.length,t.length);for(n=0;n<s;n+=1)if(e[n]!==t[n])return n;return s}function qs(e){return e&&e.toLowerCase().replace("_","-")}function kl(e){for(var t=0,n,s,a,o;t<e.length;){for(o=qs(e[t]).split("-"),n=o.length,s=qs(e[t+1]),s=s?s.split("-"):null;n>0;){if(a=St(o.slice(0,n).join("-")),a)return a;if(s&&s.length>=n&&gl(o,s)>=n-1)break;n--}t++}return rt}function bl(e){return!!(e&&e.match("^[^/\\\\]*$"))}function St(e){var t=null,n;if(F[e]===void 0&&typeof module<"u"&&module&&module.exports&&bl(e))try{t=rt._abbr,n=require,n("./locale/"+e),Ie(t)}catch{F[e]=null}return F[e]}function Ie(e,t){var n;return e&&(ee(t)?n=Ne(e):n=Nn(e,t),n?rt=n:typeof console<"u"&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),rt._abbr}function Nn(e,t){if(t!==null){var n,s=Zs;if(t.abbr=e,F[e]!=null)Is("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=F[e]._config;else if(t.parentLocale!=null)if(F[t.parentLocale]!=null)s=F[t.parentLocale]._config;else if(n=St(t.parentLocale),n!=null)s=n._config;else return at[t.parentLocale]||(at[t.parentLocale]=[]),at[t.parentLocale].push({name:e,config:t}),null;return F[e]=new cn(dn(s,t)),at[e]&&at[e].forEach(function(a){Nn(a.name,a.config)}),Ie(e),F[e]}else return delete F[e],null}function wl(e,t){if(t!=null){var n,s,a=Zs;F[e]!=null&&F[e].parentLocale!=null?F[e].set(dn(F[e]._config,t)):(s=St(e),s!=null&&(a=s._config),t=dn(a,t),s==null&&(t.abbr=e),n=new cn(t),n.parentLocale=F[e],F[e]=n),Ie(e)}else F[e]!=null&&(F[e].parentLocale!=null?(F[e]=F[e].parentLocale,e===Ie()&&Ie(e)):F[e]!=null&&delete F[e]);return F[e]}function Ne(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return rt;if(!ie(e)){if(t=St(e),t)return t;e=[e]}return kl(e)}function vl(){return un(F)}function Cn(e){var t,n=e._a;return n&&T(e).overflow===-2&&(t=n[be]<0||n[be]>11?be:n[_e]<1||n[_e]>kn(n[X],n[be])?_e:n[K]<0||n[K]>24||n[K]===24&&(n[de]!==0||n[we]!==0||n[Re]!==0)?K:n[de]<0||n[de]>59?de:n[we]<0||n[we]>59?we:n[Re]<0||n[Re]>999?Re:-1,T(e)._overflowDayOfYear&&(t<X||t>_e)&&(t=_e),T(e)._overflowWeeks&&t===-1&&(t=Si),T(e)._overflowWeekday&&t===-1&&(t=Oi),T(e).overflow=t),e}var Nl=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Cl=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ml=/Z|[+-]\d\d(?::?\d\d)?/,Ot=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Mn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Sl=/^\/?Date\((-?\d+)/i,Ol=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,El={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Ks(e){var t,n,s=e._i,a=Nl.exec(s)||Cl.exec(s),o,i,l,d,c=Ot.length,f=Mn.length;if(a){for(T(e).iso=!0,t=0,n=c;t<n;t++)if(Ot[t][1].exec(a[1])){i=Ot[t][0],o=Ot[t][2]!==!1;break}if(i==null){e._isValid=!1;return}if(a[3]){for(t=0,n=f;t<n;t++)if(Mn[t][1].exec(a[3])){l=(a[2]||" ")+Mn[t][0];break}if(l==null){e._isValid=!1;return}}if(!o&&l!=null){e._isValid=!1;return}if(a[4])if(Ml.exec(a[4]))d="Z";else{e._isValid=!1;return}e._f=i+(l||"")+(d||""),On(e)}else e._isValid=!1}function Tl(e,t,n,s,a,o){var i=[Il(e),As.indexOf(t),parseInt(n,10),parseInt(s,10),parseInt(a,10)];return o&&i.push(parseInt(o,10)),i}function Il(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Dl(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function xl(e,t,n){if(e){var s=Gs.indexOf(e),a=new Date(t[0],t[1],t[2]).getDay();if(s!==a)return T(n).weekdayMismatch=!0,n._isValid=!1,!1}return!0}function Yl(e,t,n){if(e)return El[e];if(t)return 0;var s=parseInt(n,10),a=s%100,o=(s-a)/100;return o*60+a}function Js(e){var t=Ol.exec(Dl(e._i)),n;if(t){if(n=Tl(t[4],t[3],t[2],t[5],t[6],t[7]),!xl(t[1],n,e))return;e._a=n,e._tzm=Yl(t[8],t[9],t[10]),e._d=nt.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),T(e).rfc2822=!0}else e._isValid=!1}function Rl(e){var t=Sl.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Ks(e),e._isValid===!1)delete e._isValid;else return;if(Js(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:_.createFromInputFallback(e)}_.createFromInputFallback=ae("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(e){e._d=new Date(e._i+(e._useUTC?" UTC":""))});function Fe(e,t,n){return e??t??n}function Pl(e){var t=new Date(_.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function Sn(e){var t,n,s=[],a,o,i;if(!e._d){for(a=Pl(e),e._w&&e._a[_e]==null&&e._a[be]==null&&Bl(e),e._dayOfYear!=null&&(i=Fe(e._a[X],a[X]),(e._dayOfYear>et(i)||e._dayOfYear===0)&&(T(e)._overflowDayOfYear=!0),n=nt(i,0,e._dayOfYear),e._a[be]=n.getUTCMonth(),e._a[_e]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=s[t]=a[t];for(;t<7;t++)e._a[t]=s[t]=e._a[t]==null?t===2?1:0:e._a[t];e._a[K]===24&&e._a[de]===0&&e._a[we]===0&&e._a[Re]===0&&(e._nextDay=!0,e._a[K]=0),e._d=(e._useUTC?nt:Wi).apply(null,s),o=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[K]=24),e._w&&typeof e._w.d<"u"&&e._w.d!==o&&(T(e).weekdayMismatch=!0)}}function Bl(e){var t,n,s,a,o,i,l,d,c;t=e._w,t.GG!=null||t.W!=null||t.E!=null?(o=1,i=4,n=Fe(t.GG,e._a[X],st(W(),1,4).year),s=Fe(t.W,1),a=Fe(t.E,1),(a<1||a>7)&&(d=!0)):(o=e._locale._week.dow,i=e._locale._week.doy,c=st(W(),o,i),n=Fe(t.gg,e._a[X],c.year),s=Fe(t.w,c.week),t.d!=null?(a=t.d,(a<0||a>6)&&(d=!0)):t.e!=null?(a=t.e+o,(t.e<0||t.e>6)&&(d=!0)):a=o),s<1||s>ve(n,o,i)?T(e)._overflowWeeks=!0:d!=null?T(e)._overflowWeekday=!0:(l=Fs(n,s,a,o,i),e._a[X]=l.year,e._dayOfYear=l.dayOfYear)}_.ISO_8601=function(){},_.RFC_2822=function(){};function On(e){if(e._f===_.ISO_8601){Ks(e);return}if(e._f===_.RFC_2822){Js(e);return}e._a=[],T(e).empty=!0;var t=""+e._i,n,s,a,o,i,l=t.length,d=0,c,f;for(a=Ds(e._f,e._locale).match(hn)||[],f=a.length,n=0;n<f;n++)o=a[n],s=(t.match(Ni(o,e))||[])[0],s&&(i=t.substr(0,t.indexOf(s)),i.length>0&&T(e).unusedInput.push(i),t=t.slice(t.indexOf(s)+s.length),d+=s.length),Ue[o]?(s?T(e).empty=!1:T(e).unusedTokens.push(o),Mi(o,s,e)):e._strict&&!s&&T(e).unusedTokens.push(o);T(e).charsLeftOver=l-d,t.length>0&&T(e).unusedInput.push(t),e._a[K]<=12&&T(e).bigHour===!0&&e._a[K]>0&&(T(e).bigHour=void 0),T(e).parsedDateParts=e._a.slice(0),T(e).meridiem=e._meridiem,e._a[K]=Vl(e._locale,e._a[K],e._meridiem),c=T(e).era,c!==null&&(e._a[X]=e._locale.erasConvertYear(c,e._a[X])),Sn(e),Cn(e)}function Vl(e,t,n){var s;return n==null?t:e.meridiemHour!=null?e.meridiemHour(t,n):(e.isPM!=null&&(s=e.isPM(n),s&&t<12&&(t+=12),!s&&t===12&&(t=0)),t)}function Ll(e){var t,n,s,a,o,i,l=!1,d=e._f.length;if(d===0){T(e).invalidFormat=!0,e._d=new Date(NaN);return}for(a=0;a<d;a++)o=0,i=!1,t=ln({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[a],On(t),rn(t)&&(i=!0),o+=T(t).charsLeftOver,o+=T(t).unusedTokens.length*10,T(t).score=o,l?o<s&&(s=o,n=t):(s==null||o<s||i)&&(s=o,n=t,i&&(l=!0));Te(e,n||t)}function Al(e){if(!e._d){var t=pn(e._i),n=t.day===void 0?t.date:t.day;e._a=Ss([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(s){return s&&parseInt(s,10)}),Sn(e)}}function Ul(e){var t=new Je(Cn(Xs(e)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function Xs(e){var t=e._i,n=e._f;return e._locale=e._locale||Ne(e._l),t===null||n===void 0&&t===""?mt({nullInput:!0}):(typeof t=="string"&&(e._i=t=e._locale.preparse(t)),le(t)?new Je(Cn(t)):(Ke(t)?e._d=t:ie(n)?Ll(e):n?On(e):$l(e),rn(e)||(e._d=null),e))}function $l(e){var t=e._i;ee(t)?e._d=new Date(_.now()):Ke(t)?e._d=new Date(t.valueOf()):typeof t=="string"?Rl(e):ie(t)?(e._a=Ss(t.slice(0),function(n){return parseInt(n,10)}),Sn(e)):Ye(t)?Al(e):ge(t)?e._d=new Date(t):_.createFromInputFallback(e)}function Qs(e,t,n,s,a){var o={};return(t===!0||t===!1)&&(s=t,t=void 0),(n===!0||n===!1)&&(s=n,n=void 0),(Ye(e)&&sn(e)||ie(e)&&e.length===0)&&(e=void 0),o._isAMomentObject=!0,o._useUTC=o._isUTC=a,o._l=n,o._i=e,o._f=t,o._strict=s,Ul(o)}function W(e,t,n,s){return Qs(e,t,n,s,!1)}var Wl=ae("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var e=W.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:mt()}),Hl=ae("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var e=W.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:mt()});function ea(e,t){var n,s;if(t.length===1&&ie(t[0])&&(t=t[0]),!t.length)return W();for(n=t[0],s=1;s<t.length;++s)(!t[s].isValid()||t[s][e](n))&&(n=t[s]);return n}function Fl(){var e=[].slice.call(arguments,0);return ea("isBefore",e)}function Gl(){var e=[].slice.call(arguments,0);return ea("isAfter",e)}var jl=function(){return Date.now?Date.now():+new Date},ot=["year","quarter","month","week","day","hour","minute","second","millisecond"];function zl(e){var t,n=!1,s,a=ot.length;for(t in e)if(P(e,t)&&!(Z.call(ot,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(s=0;s<a;++s)if(e[ot[s]]){if(n)return!1;parseFloat(e[ot[s]])!==x(e[ot[s]])&&(n=!0)}return!0}function Zl(){return this._isValid}function ql(){return ce(NaN)}function Et(e){var t=pn(e),n=t.year||0,s=t.quarter||0,a=t.month||0,o=t.week||t.isoWeek||0,i=t.day||0,l=t.hour||0,d=t.minute||0,c=t.second||0,f=t.millisecond||0;this._isValid=zl(t),this._milliseconds=+f+c*1e3+d*6e4+l*1e3*60*60,this._days=+i+o*7,this._months=+a+s*3+n*12,this._data={},this._locale=Ne(),this._bubble()}function Tt(e){return e instanceof Et}function En(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Kl(e,t,n){var s=Math.min(e.length,t.length),a=Math.abs(e.length-t.length),o=0,i;for(i=0;i<s;i++)x(e[i])!==x(t[i])&&o++;return o+a}function ta(e,t){C(e,0,0,function(){var n=this.utcOffset(),s="+";return n<0&&(n=-n,s="-"),s+me(~~(n/60),2)+t+me(~~n%60,2)})}ta("Z",":"),ta("ZZ",""),y("Z",vt),y("ZZ",vt),L(["Z","ZZ"],function(e,t,n){n._useUTC=!0,n._tzm=Tn(vt,e)});var Jl=/([\+\-]|\d\d)/gi;function Tn(e,t){var n=(t||"").match(e),s,a,o;return n===null?null:(s=n[n.length-1]||[],a=(s+"").match(Jl)||["-",0,0],o=+(a[1]*60)+x(a[2]),o===0?0:a[0]==="+"?o:-o)}function In(e,t){var n,s;return t._isUTC?(n=t.clone(),s=(le(e)||Ke(e)?e.valueOf():W(e).valueOf())-n.valueOf(),n._d.setTime(n._d.valueOf()+s),_.updateOffset(n,!1),n):W(e).local()}function Dn(e){return-Math.round(e._d.getTimezoneOffset())}_.updateOffset=function(){};function Xl(e,t,n){var s=this._offset||0,a;if(!this.isValid())return e!=null?this:NaN;if(e!=null){if(typeof e=="string"){if(e=Tn(vt,e),e===null)return this}else Math.abs(e)<16&&!n&&(e=e*60);return!this._isUTC&&t&&(a=Dn(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,"m"),s!==e&&(!t||this._changeInProgress?ra(this,ce(e-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,_.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?s:Dn(this)}function Ql(e,t){return e!=null?(typeof e!="string"&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()}function ed(e){return this.utcOffset(0,e)}function td(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Dn(this),"m")),this}function nd(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var e=Tn(wi,this._i);e!=null?this.utcOffset(e):this.utcOffset(0,!0)}return this}function sd(e){return this.isValid()?(e=e?W(e).utcOffset():0,(this.utcOffset()-e)%60===0):!1}function ad(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function rd(){if(!ee(this._isDSTShifted))return this._isDSTShifted;var e={},t;return ln(e,this),e=Xs(e),e._a?(t=e._isUTC?fe(e._a):W(e._a),this._isDSTShifted=this.isValid()&&Kl(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function od(){return this.isValid()?!this._isUTC:!1}function id(){return this.isValid()?this._isUTC:!1}function na(){return this.isValid()?this._isUTC&&this._offset===0:!1}var ld=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,dd=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function ce(e,t){var n=e,s=null,a,o,i;return Tt(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:ge(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(s=ld.exec(e))?(a=s[1]==="-"?-1:1,n={y:0,d:x(s[_e])*a,h:x(s[K])*a,m:x(s[de])*a,s:x(s[we])*a,ms:x(En(s[Re]*1e3))*a}):(s=dd.exec(e))?(a=s[1]==="-"?-1:1,n={y:Pe(s[2],a),M:Pe(s[3],a),w:Pe(s[4],a),d:Pe(s[5],a),h:Pe(s[6],a),m:Pe(s[7],a),s:Pe(s[8],a)}):n==null?n={}:typeof n=="object"&&("from"in n||"to"in n)&&(i=cd(W(n.from),W(n.to)),n={},n.ms=i.milliseconds,n.M=i.months),o=new Et(n),Tt(e)&&P(e,"_locale")&&(o._locale=e._locale),Tt(e)&&P(e,"_isValid")&&(o._isValid=e._isValid),o}ce.fn=Et.prototype,ce.invalid=ql;function Pe(e,t){var n=e&&parseFloat(e.replace(",","."));return(isNaN(n)?0:n)*t}function sa(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,"M").isAfter(t)&&--n.months,n.milliseconds=+t-+e.clone().add(n.months,"M"),n}function cd(e,t){var n;return e.isValid()&&t.isValid()?(t=In(t,e),e.isBefore(t)?n=sa(e,t):(n=sa(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function aa(e,t){return function(n,s){var a,o;return s!==null&&!isNaN(+s)&&(Is(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),o=n,n=s,s=o),a=ce(n,s),ra(this,a,e),this}}function ra(e,t,n,s){var a=t._milliseconds,o=En(t._days),i=En(t._months);e.isValid()&&(s=s??!0,i&&$s(e,tt(e,"Month")+i*n),o&&Ls(e,"Date",tt(e,"Date")+o*n),a&&e._d.setTime(e._d.valueOf()+a*n),s&&_.updateOffset(e,o||i))}var ud=aa(1,"add"),hd=aa(-1,"subtract");function oa(e){return typeof e=="string"||e instanceof String}function fd(e){return le(e)||Ke(e)||oa(e)||ge(e)||md(e)||pd(e)||e===null||e===void 0}function pd(e){var t=Ye(e)&&!sn(e),n=!1,s=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],a,o,i=s.length;for(a=0;a<i;a+=1)o=s[a],n=n||P(e,o);return t&&n}function md(e){var t=ie(e),n=!1;return t&&(n=e.filter(function(s){return!ge(s)&&oa(e)}).length===0),t&&n}function _d(e){var t=Ye(e)&&!sn(e),n=!1,s=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],a,o;for(a=0;a<s.length;a+=1)o=s[a],n=n||P(e,o);return t&&n}function yd(e,t){var n=e.diff(t,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"}function gd(e,t){arguments.length===1&&(arguments[0]?fd(arguments[0])?(e=arguments[0],t=void 0):_d(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var n=e||W(),s=In(n,this).startOf("day"),a=_.calendarFormat(this,s)||"sameElse",o=t&&(pe(t[a])?t[a].call(this,n):t[a]);return this.format(o||this.localeData().calendar(a,this,W(n)))}function kd(){return new Je(this)}function bd(e,t){var n=le(e)?e:W(e);return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function wd(e,t){var n=le(e)?e:W(e);return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function vd(e,t,n,s){var a=le(e)?e:W(e),o=le(t)?t:W(t);return this.isValid()&&a.isValid()&&o.isValid()?(s=s||"()",(s[0]==="("?this.isAfter(a,n):!this.isBefore(a,n))&&(s[1]===")"?this.isBefore(o,n):!this.isAfter(o,n))):!1}function Nd(e,t){var n=le(e)?e:W(e),s;return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()===n.valueOf():(s=n.valueOf(),this.clone().startOf(t).valueOf()<=s&&s<=this.clone().endOf(t).valueOf())):!1}function Cd(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function Md(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function Sd(e,t,n){var s,a,o;if(!this.isValid())return NaN;if(s=In(e,this),!s.isValid())return NaN;switch(a=(s.utcOffset()-this.utcOffset())*6e4,t=re(t),t){case"year":o=It(this,s)/12;break;case"month":o=It(this,s);break;case"quarter":o=It(this,s)/3;break;case"second":o=(this-s)/1e3;break;case"minute":o=(this-s)/6e4;break;case"hour":o=(this-s)/36e5;break;case"day":o=(this-s-a)/864e5;break;case"week":o=(this-s-a)/6048e5;break;default:o=this-s}return n?o:oe(o)}function It(e,t){if(e.date()<t.date())return-It(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),s=e.clone().add(n,"months"),a,o;return t-s<0?(a=e.clone().add(n-1,"months"),o=(t-s)/(s-a)):(a=e.clone().add(n+1,"months"),o=(t-s)/(a-s)),-(n+o)||0}_.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",_.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function Od(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Ed(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?yt(n,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):pe(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",yt(n,"Z")):yt(n,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Td(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e="moment",t="",n,s,a,o;return this.isLocal()||(e=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),n="["+e+'("]',s=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",a="-MM-DD[T]HH:mm:ss.SSS",o=t+'[")]',this.format(n+s+a+o)}function Id(e){e||(e=this.isUtc()?_.defaultFormatUtc:_.defaultFormat);var t=yt(this,e);return this.localeData().postformat(t)}function Dd(e,t){return this.isValid()&&(le(e)&&e.isValid()||W(e).isValid())?ce({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function xd(e){return this.from(W(),e)}function Yd(e,t){return this.isValid()&&(le(e)&&e.isValid()||W(e).isValid())?ce({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Rd(e){return this.to(W(),e)}function ia(e){var t;return e===void 0?this._locale._abbr:(t=Ne(e),t!=null&&(this._locale=t),this)}var la=ae("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(e){return e===void 0?this.localeData():this.locale(e)});function da(){return this._locale}var Dt=1e3,Ge=60*Dt,xt=60*Ge,ca=(365*400+97)*24*xt;function je(e,t){return(e%t+t)%t}function ua(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-ca:new Date(e,t,n).valueOf()}function ha(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-ca:Date.UTC(e,t,n)}function Pd(e){var t,n;if(e=re(e),e===void 0||e==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?ha:ua,e){case"year":t=n(this.year(),0,1);break;case"quarter":t=n(this.year(),this.month()-this.month()%3,1);break;case"month":t=n(this.year(),this.month(),1);break;case"week":t=n(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=n(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=je(t+(this._isUTC?0:this.utcOffset()*Ge),xt);break;case"minute":t=this._d.valueOf(),t-=je(t,Ge);break;case"second":t=this._d.valueOf(),t-=je(t,Dt);break}return this._d.setTime(t),_.updateOffset(this,!0),this}function Bd(e){var t,n;if(e=re(e),e===void 0||e==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?ha:ua,e){case"year":t=n(this.year()+1,0,1)-1;break;case"quarter":t=n(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=n(this.year(),this.month()+1,1)-1;break;case"week":t=n(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=n(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=xt-je(t+(this._isUTC?0:this.utcOffset()*Ge),xt)-1;break;case"minute":t=this._d.valueOf(),t+=Ge-je(t,Ge)-1;break;case"second":t=this._d.valueOf(),t+=Dt-je(t,Dt)-1;break}return this._d.setTime(t),_.updateOffset(this,!0),this}function Vd(){return this._d.valueOf()-(this._offset||0)*6e4}function Ld(){return Math.floor(this.valueOf()/1e3)}function Ad(){return new Date(this.valueOf())}function Ud(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function $d(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Wd(){return this.isValid()?this.toISOString():null}function Hd(){return rn(this)}function Fd(){return Te({},T(this))}function Gd(){return T(this).overflow}function jd(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}C("N",0,0,"eraAbbr"),C("NN",0,0,"eraAbbr"),C("NNN",0,0,"eraAbbr"),C("NNNN",0,0,"eraName"),C("NNNNN",0,0,"eraNarrow"),C("y",["y",1],"yo","eraYear"),C("y",["yy",2],0,"eraYear"),C("y",["yyy",3],0,"eraYear"),C("y",["yyyy",4],0,"eraYear"),y("N",xn),y("NN",xn),y("NNN",xn),y("NNNN",sc),y("NNNNN",ac),L(["N","NN","NNN","NNNN","NNNNN"],function(e,t,n,s){var a=n._locale.erasParse(e,s,n._strict);a?T(n).era=a:T(n).invalidEra=e}),y("y",$e),y("yy",$e),y("yyy",$e),y("yyyy",$e),y("yo",rc),L(["y","yy","yyy","yyyy"],X),L(["yo"],function(e,t,n,s){var a;n._locale._eraYearOrdinalRegex&&(a=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[X]=n._locale.eraYearOrdinalParse(e,a):t[X]=parseInt(e,10)});function zd(e,t){var n,s,a,o=this._eras||Ne("en")._eras;for(n=0,s=o.length;n<s;++n)switch(typeof o[n].since==="string"&&(a=_(o[n].since).startOf("day"),o[n].since=a.valueOf()),typeof o[n].until){case"undefined":o[n].until=1/0;break;case"string":a=_(o[n].until).startOf("day").valueOf(),o[n].until=a.valueOf();break}return o}function Zd(e,t,n){var s,a,o=this.eras(),i,l,d;for(e=e.toUpperCase(),s=0,a=o.length;s<a;++s)if(i=o[s].name.toUpperCase(),l=o[s].abbr.toUpperCase(),d=o[s].narrow.toUpperCase(),n)switch(t){case"N":case"NN":case"NNN":if(l===e)return o[s];break;case"NNNN":if(i===e)return o[s];break;case"NNNNN":if(d===e)return o[s];break}else if([i,l,d].indexOf(e)>=0)return o[s]}function qd(e,t){var n=e.since<=e.until?1:-1;return t===void 0?_(e.since).year():_(e.since).year()+(t-e.offset)*n}function Kd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].name;return""}function Jd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].narrow;return""}function Xd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].abbr;return""}function Qd(){var e,t,n,s,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(n=a[e].since<=a[e].until?1:-1,s=this.clone().startOf("day").valueOf(),a[e].since<=s&&s<=a[e].until||a[e].until<=s&&s<=a[e].since)return(this.year()-_(a[e].since).year())*n+a[e].offset;return this.year()}function ec(e){return P(this,"_erasNameRegex")||Yn.call(this),e?this._erasNameRegex:this._erasRegex}function tc(e){return P(this,"_erasAbbrRegex")||Yn.call(this),e?this._erasAbbrRegex:this._erasRegex}function nc(e){return P(this,"_erasNarrowRegex")||Yn.call(this),e?this._erasNarrowRegex:this._erasRegex}function xn(e,t){return t.erasAbbrRegex(e)}function sc(e,t){return t.erasNameRegex(e)}function ac(e,t){return t.erasNarrowRegex(e)}function rc(e,t){return t._eraYearOrdinalRegex||$e}function Yn(){var e=[],t=[],n=[],s=[],a,o,i,l,d,c=this.eras();for(a=0,o=c.length;a<o;++a)i=ke(c[a].name),l=ke(c[a].abbr),d=ke(c[a].narrow),t.push(i),e.push(l),n.push(d),s.push(i),s.push(l),s.push(d);this._erasRegex=new RegExp("^("+s.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+e.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+n.join("|")+")","i")}C(0,["gg",2],0,function(){return this.weekYear()%100}),C(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Yt(e,t){C(0,[e,e.length],0,t)}Yt("gggg","weekYear"),Yt("ggggg","weekYear"),Yt("GGGG","isoWeekYear"),Yt("GGGGG","isoWeekYear"),y("G",wt),y("g",wt),y("GG",$,ne),y("gg",$,ne),y("GGGG",_n,mn),y("gggg",_n,mn),y("GGGGG",bt,gt),y("ggggg",bt,gt),Qe(["gggg","ggggg","GGGG","GGGGG"],function(e,t,n,s){t[s.substr(0,2)]=x(e)}),Qe(["gg","GG"],function(e,t,n,s){t[s]=_.parseTwoDigitYear(e)});function oc(e){return fa.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ic(e){return fa.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function lc(){return ve(this.year(),1,4)}function dc(){return ve(this.isoWeekYear(),1,4)}function cc(){var e=this.localeData()._week;return ve(this.year(),e.dow,e.doy)}function uc(){var e=this.localeData()._week;return ve(this.weekYear(),e.dow,e.doy)}function fa(e,t,n,s,a){var o;return e==null?st(this,s,a).year:(o=ve(e,s,a),t>o&&(t=o),hc.call(this,e,t,n,s,a))}function hc(e,t,n,s,a){var o=Fs(e,t,n,s,a),i=nt(o.year,0,o.dayOfYear);return this.year(i.getUTCFullYear()),this.month(i.getUTCMonth()),this.date(i.getUTCDate()),this}C("Q",0,"Qo","quarter"),y("Q",Ys),L("Q",function(e,t){t[be]=(x(e)-1)*3});function fc(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}C("D",["DD",2],"Do","date"),y("D",$,We),y("DD",$,ne),y("Do",function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),L(["D","DD"],_e),L("Do",function(e,t){t[_e]=x(e.match($)[0])});var pa=He("Date",!0);C("DDD",["DDDD",3],"DDDo","dayOfYear"),y("DDD",kt),y("DDDD",Rs),L(["DDD","DDDD"],function(e,t,n){n._dayOfYear=x(e)});function pc(e){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return e==null?t:this.add(e-t,"d")}C("m",["mm",2],0,"minute"),y("m",$,yn),y("mm",$,ne),L(["m","mm"],de);var mc=He("Minutes",!1);C("s",["ss",2],0,"second"),y("s",$,yn),y("ss",$,ne),L(["s","ss"],we);var _c=He("Seconds",!1);C("S",0,0,function(){return~~(this.millisecond()/100)}),C(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),C(0,["SSS",3],0,"millisecond"),C(0,["SSSS",4],0,function(){return this.millisecond()*10}),C(0,["SSSSS",5],0,function(){return this.millisecond()*100}),C(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),C(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),C(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),C(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),y("S",kt,Ys),y("SS",kt,ne),y("SSS",kt,Rs);var De,ma;for(De="SSSS";De.length<=9;De+="S")y(De,$e);function yc(e,t){t[Re]=x(("0."+e)*1e3)}for(De="S";De.length<=9;De+="S")L(De,yc);ma=He("Milliseconds",!1),C("z",0,0,"zoneAbbr"),C("zz",0,0,"zoneName");function gc(){return this._isUTC?"UTC":""}function kc(){return this._isUTC?"Coordinated Universal Time":""}var u=Je.prototype;u.add=ud,u.calendar=gd,u.clone=kd,u.diff=Sd,u.endOf=Bd,u.format=Id,u.from=Dd,u.fromNow=xd,u.to=Yd,u.toNow=Rd,u.get=Ti,u.invalidAt=Gd,u.isAfter=bd,u.isBefore=wd,u.isBetween=vd,u.isSame=Nd,u.isSameOrAfter=Cd,u.isSameOrBefore=Md,u.isValid=Hd,u.lang=la,u.locale=ia,u.localeData=da,u.max=Hl,u.min=Wl,u.parsingFlags=Fd,u.set=Ii,u.startOf=Pd,u.subtract=hd,u.toArray=Ud,u.toObject=$d,u.toDate=Ad,u.toISOString=Ed,u.inspect=Td,typeof Symbol<"u"&&Symbol.for!=null&&(u[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),u.toJSON=Wd,u.toString=Od,u.unix=Ld,u.valueOf=Vd,u.creationData=jd,u.eraName=Kd,u.eraNarrow=Jd,u.eraAbbr=Xd,u.eraYear=Qd,u.year=Vs,u.isLeapYear=Ei,u.weekYear=oc,u.isoWeekYear=ic,u.quarter=u.quarters=fc,u.month=Ws,u.daysInMonth=Ai,u.week=u.weeks=zi,u.isoWeek=u.isoWeeks=Zi,u.weeksInYear=cc,u.weeksInWeekYear=uc,u.isoWeeksInYear=lc,u.isoWeeksInISOWeekYear=dc,u.date=pa,u.day=u.days=il,u.weekday=ll,u.isoWeekday=dl,u.dayOfYear=pc,u.hour=u.hours=_l,u.minute=u.minutes=mc,u.second=u.seconds=_c,u.millisecond=u.milliseconds=ma,u.utcOffset=Xl,u.utc=ed,u.local=td,u.parseZone=nd,u.hasAlignedHourOffset=sd,u.isDST=ad,u.isLocal=od,u.isUtcOffset=id,u.isUtc=na,u.isUTC=na,u.zoneAbbr=gc,u.zoneName=kc,u.dates=ae("dates accessor is deprecated. Use date instead.",pa),u.months=ae("months accessor is deprecated. Use month instead",Ws),u.years=ae("years accessor is deprecated. Use year instead",Vs),u.zone=ae("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Ql),u.isDSTShifted=ae("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",rd);function bc(e){return W(e*1e3)}function wc(){return W.apply(null,arguments).parseZone()}function _a(e){return e}var B=cn.prototype;B.calendar=oi,B.longDateFormat=ci,B.invalidDate=hi,B.ordinal=mi,B.preparse=_a,B.postformat=_a,B.relativeTime=yi,B.pastFuture=gi,B.set=ai,B.eras=zd,B.erasParse=Zd,B.erasConvertYear=qd,B.erasAbbrRegex=tc,B.erasNameRegex=ec,B.erasNarrowRegex=nc,B.months=Pi,B.monthsShort=Bi,B.monthsParse=Li,B.monthsRegex=$i,B.monthsShortRegex=Ui,B.week=Hi,B.firstDayOfYear=ji,B.firstDayOfWeek=Gi,B.weekdays=nl,B.weekdaysMin=al,B.weekdaysShort=sl,B.weekdaysParse=ol,B.weekdaysRegex=cl,B.weekdaysShortRegex=ul,B.weekdaysMinRegex=hl,B.isPM=pl,B.meridiem=yl;function Rt(e,t,n,s){var a=Ne(),o=fe().set(s,t);return a[n](o,e)}function ya(e,t,n){if(ge(e)&&(t=e,e=void 0),e=e||"",t!=null)return Rt(e,t,n,"month");var s,a=[];for(s=0;s<12;s++)a[s]=Rt(e,s,n,"month");return a}function Rn(e,t,n,s){typeof e=="boolean"?(ge(t)&&(n=t,t=void 0),t=t||""):(t=e,n=t,e=!1,ge(t)&&(n=t,t=void 0),t=t||"");var a=Ne(),o=e?a._week.dow:0,i,l=[];if(n!=null)return Rt(t,(n+o)%7,s,"day");for(i=0;i<7;i++)l[i]=Rt(t,(i+o)%7,s,"day");return l}function vc(e,t){return ya(e,t,"months")}function Nc(e,t){return ya(e,t,"monthsShort")}function Cc(e,t,n){return Rn(e,t,n,"weekdays")}function Mc(e,t,n){return Rn(e,t,n,"weekdaysShort")}function Sc(e,t,n){return Rn(e,t,n,"weekdaysMin")}Ie("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10,n=x(e%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return e+n}}),_.lang=ae("moment.lang is deprecated. Use moment.locale instead.",Ie),_.langData=ae("moment.langData is deprecated. Use moment.localeData instead.",Ne);var Ce=Math.abs;function Oc(){var e=this._data;return this._milliseconds=Ce(this._milliseconds),this._days=Ce(this._days),this._months=Ce(this._months),e.milliseconds=Ce(e.milliseconds),e.seconds=Ce(e.seconds),e.minutes=Ce(e.minutes),e.hours=Ce(e.hours),e.months=Ce(e.months),e.years=Ce(e.years),this}function ga(e,t,n,s){var a=ce(t,n);return e._milliseconds+=s*a._milliseconds,e._days+=s*a._days,e._months+=s*a._months,e._bubble()}function Ec(e,t){return ga(this,e,t,1)}function Tc(e,t){return ga(this,e,t,-1)}function ka(e){return e<0?Math.floor(e):Math.ceil(e)}function Ic(){var e=this._milliseconds,t=this._days,n=this._months,s=this._data,a,o,i,l,d;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=ka(Pn(n)+t)*864e5,t=0,n=0),s.milliseconds=e%1e3,a=oe(e/1e3),s.seconds=a%60,o=oe(a/60),s.minutes=o%60,i=oe(o/60),s.hours=i%24,t+=oe(i/24),d=oe(ba(t)),n+=d,t-=ka(Pn(d)),l=oe(n/12),n%=12,s.days=t,s.months=n,s.years=l,this}function ba(e){return e*4800/146097}function Pn(e){return e*146097/4800}function Dc(e){if(!this.isValid())return NaN;var t,n,s=this._milliseconds;if(e=re(e),e==="month"||e==="quarter"||e==="year")switch(t=this._days+s/864e5,n=this._months+ba(t),e){case"month":return n;case"quarter":return n/3;case"year":return n/12}else switch(t=this._days+Math.round(Pn(this._months)),e){case"week":return t/7+s/6048e5;case"day":return t+s/864e5;case"hour":return t*24+s/36e5;case"minute":return t*1440+s/6e4;case"second":return t*86400+s/1e3;case"millisecond":return Math.floor(t*864e5)+s;default:throw new Error("Unknown unit "+e)}}function Me(e){return function(){return this.as(e)}}var wa=Me("ms"),xc=Me("s"),Yc=Me("m"),Rc=Me("h"),Pc=Me("d"),Bc=Me("w"),Vc=Me("M"),Lc=Me("Q"),Ac=Me("y"),Uc=wa;function $c(){return ce(this)}function Wc(e){return e=re(e),this.isValid()?this[e+"s"]():NaN}function Be(e){return function(){return this.isValid()?this._data[e]:NaN}}var Hc=Be("milliseconds"),Fc=Be("seconds"),Gc=Be("minutes"),jc=Be("hours"),zc=Be("days"),Zc=Be("months"),qc=Be("years");function Kc(){return oe(this.days()/7)}var Se=Math.round,ze={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Jc(e,t,n,s,a){return a.relativeTime(t||1,!!n,e,s)}function Xc(e,t,n,s){var a=ce(e).abs(),o=Se(a.as("s")),i=Se(a.as("m")),l=Se(a.as("h")),d=Se(a.as("d")),c=Se(a.as("M")),f=Se(a.as("w")),w=Se(a.as("y")),m=o<=n.ss&&["s",o]||o<n.s&&["ss",o]||i<=1&&["m"]||i<n.m&&["mm",i]||l<=1&&["h"]||l<n.h&&["hh",l]||d<=1&&["d"]||d<n.d&&["dd",d];return n.w!=null&&(m=m||f<=1&&["w"]||f<n.w&&["ww",f]),m=m||c<=1&&["M"]||c<n.M&&["MM",c]||w<=1&&["y"]||["yy",w],m[2]=t,m[3]=+e>0,m[4]=s,Jc.apply(null,m)}function Qc(e){return e===void 0?Se:typeof e=="function"?(Se=e,!0):!1}function eu(e,t){return ze[e]===void 0?!1:t===void 0?ze[e]:(ze[e]=t,e==="s"&&(ze.ss=t-1),!0)}function tu(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,s=ze,a,o;return typeof e=="object"&&(t=e,e=!1),typeof e=="boolean"&&(n=e),typeof t=="object"&&(s=Object.assign({},ze,t),t.s!=null&&t.ss==null&&(s.ss=t.s-1)),a=this.localeData(),o=Xc(this,!n,s,a),n&&(o=a.pastFuture(+this,o)),a.postformat(o)}var Bn=Math.abs;function Ze(e){return(e>0)-(e<0)||+e}function Pt(){if(!this.isValid())return this.localeData().invalidDate();var e=Bn(this._milliseconds)/1e3,t=Bn(this._days),n=Bn(this._months),s,a,o,i,l=this.asSeconds(),d,c,f,w;return l?(s=oe(e/60),a=oe(s/60),e%=60,s%=60,o=oe(n/12),n%=12,i=e?e.toFixed(3).replace(/\.?0+$/,""):"",d=l<0?"-":"",c=Ze(this._months)!==Ze(l)?"-":"",f=Ze(this._days)!==Ze(l)?"-":"",w=Ze(this._milliseconds)!==Ze(l)?"-":"",d+"P"+(o?c+o+"Y":"")+(n?c+n+"M":"")+(t?f+t+"D":"")+(a||s||e?"T":"")+(a?w+a+"H":"")+(s?w+s+"M":"")+(e?w+i+"S":"")):"P0D"}var Y=Et.prototype;Y.isValid=Zl,Y.abs=Oc,Y.add=Ec,Y.subtract=Tc,Y.as=Dc,Y.asMilliseconds=wa,Y.asSeconds=xc,Y.asMinutes=Yc,Y.asHours=Rc,Y.asDays=Pc,Y.asWeeks=Bc,Y.asMonths=Vc,Y.asQuarters=Lc,Y.asYears=Ac,Y.valueOf=Uc,Y._bubble=Ic,Y.clone=$c,Y.get=Wc,Y.milliseconds=Hc,Y.seconds=Fc,Y.minutes=Gc,Y.hours=jc,Y.days=zc,Y.weeks=Kc,Y.months=Zc,Y.years=qc,Y.humanize=tu,Y.toISOString=Pt,Y.toString=Pt,Y.toJSON=Pt,Y.locale=ia,Y.localeData=da,Y.toIsoString=ae("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Pt),Y.lang=la,C("X",0,0,"unix"),C("x",0,0,"valueOf"),y("x",wt),y("X",vi),L("X",function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),L("x",function(e,t,n){n._d=new Date(x(e))});_.version="2.30.1",ni(W),_.fn=u,_.min=Fl,_.max=Gl,_.now=jl,_.utc=fe,_.unix=bc,_.months=vc,_.isDate=Ke,_.locale=Ie,_.invalid=mt,_.duration=ce,_.isMoment=le,_.weekdays=Cc,_.parseZone=wc,_.localeData=Ne,_.isDuration=Tt,_.monthsShort=Nc,_.weekdaysMin=Sc,_.defineLocale=Nn,_.updateLocale=wl,_.locales=vl,_.weekdaysShort=Mc,_.normalizeUnits=re,_.relativeTimeRounding=Qc,_.relativeTimeThreshold=eu,_.calendarFormat=yd,_.prototype=u,_.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};const nu="code-graph",su=(e,t="",n="json")=>{const s=document.createElement("a");s.setAttribute("href",`data:text/${n};charset=UTF-8,${encodeURIComponent(e)}`);const a=_().format("YYMMDD_HHMMSS");s.setAttribute("download",`${nu}_${a}_${t}.${n}`),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)},au=(e="json")=>{const t=document.createElement("input");return t.setAttribute("type","file"),t.setAttribute("id","fileElem"),t.setAttribute("multiple","true"),t.setAttribute("accept",`${e}/*`),t.style.display="none",document.body.appendChild(t),t.click(),t},Vn="CLEAR_ALL",Ln="DOWNLOAD_EDITOR_STATE",va="RUN_ENGINE",An="TOGGLE_MINIMAP",Un="TOGGLE_PALETTE",$n="UPLOAD_EDITOR_STATE",Na=(e,t,n)=>{const s=n.zoomToFit.paddingLeft;t.registerCommand(Vn,{execute:()=>{t.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),t.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.value.clear(),e.value.editor.code.clear()},canExecute:()=>e.value.nodes.length>0}),t.registerCommand(Ln,{execute:()=>{const a=e.value.editor.save();su(JSON.stringify(a,null,2),e.value.shortId)},canExecute:()=>e.value.nodes.length>0}),t.registerCommand(An,{execute:()=>n.enableMinimap=!n.enableMinimap,canExecute:()=>e.value.nodes.length>1}),t.registerCommand(Un,{execute:()=>{n.palette.enabled=!n.palette.enabled,n.zoomToFit.paddingLeft=n.palette.enabled?s:50},canExecute:()=>!0}),t.registerCommand($n,{execute:()=>{const a=au();a.addEventListener("change",()=>{document.body.removeChild(a);const o=a.files;if(!o||o.length<=0)return!1;const i=new FileReader;i.onload=l=>{if(l.target?.result){const d=l.target.result;if(d.length===0)return;const c=JSON.parse(d);e.value.editor.load(c),e.value.code?.engine?.runOnce(null)}},i.readAsText(o.item(0))})},canExecute:()=>!0})},Ca=e=>{const t={command:Vn,title:"Clear all",icon:r.computed(()=>rs)},n={command:Ln,title:"Download editor state",icon:r.computed(()=>ns)},s={command:An,title:"Toggle minimap",icon:r.computed(()=>e.enableMinimap?is:os)},a={command:Un,title:"Toggle palette",icon:r.computed(()=>e.palette.enabled?ss:$t)},o={command:$n,title:"Upload editor state",icon:r.computed(()=>ds)};e.toolbar.commands=[a,t,o,n,...S.DEFAULT_TOOLBAR_COMMANDS,s]},Ma=(e,t,n)=>{n.registerCommand(va,{execute:()=>t.runOnce(null),canExecute:()=>e.nodes.length>0})};function Sa(e){const t=Symbol("CodeEngineToken");e.engine=new Cs(e.editor),Ma(e.editor.graph,e.engine,e.commandHandler),e.loadEditor=n=>{e.engine?.pause(),e.displayedGraph.clear(),e.editor.load(n),e.commandHandler.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),e.commandHandler.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.engine?.resume(),e.engine?.runOnce(null)},e.newGraph=()=>{e.engine?.pause(),e.displayedGraph.clear(),e.commandHandler.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),e.commandHandler.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.displayedGraph.id=xe.v4(),e.engine?.resume(),e.engine?.runOnce(null)},e.subscribe=()=>{e.displayedGraph.nodeEvents.titleChanged.subscribe(t,()=>{e.engine?.runOnce(null)}),e.displayedGraph.events.addConnection.subscribe(t,n=>{const s=e.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onConnected();const a=e.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onConnected()}),e.displayedGraph.events.removeConnection.subscribe(t,n=>{const s=e.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onUnconnected();const a=e.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onUnconnected()}),e.engine?.events.beforeRun.subscribe(t,()=>{e.displayedGraph.onUpdate(),e.engine?.pause(),e.displayedGraph.sortNodes(),e.engine?.resume()}),e.engine?.events.afterRun.subscribe(t,n=>{e.engine?.pause(),he.applyResult(n,e.editor),e.code.state.lockCode||e.code.renderCode({nodes:e.editor.graph.scriptedCodeNodes,modules:e.editor.code.modules}),e.engine?.resume()})},e.unsubscribe=()=>{e.displayedGraph.events.addConnection.unsubscribe(t),e.displayedGraph.events.removeConnection.unsubscribe(t),e.engine?.events.beforeRun.unsubscribe(t),e.engine?.events.afterRun.unsubscribe(t)}}const Bt=350;class it extends q.Graph{code=null;editor;_state=r.reactive({codeTemplate:"{{ #nodes }}{{ script }}{{ /nodes }}",lockCode:!1});constructor(t,n){super(t,n),this.editor=t,this.template=n,t.code&&(this.code=t.code)}get codeNodes(){return Wn(this)}get connections(){return super.connections}set connections(t){this._connections=t}get nodeIds(){return this.nodes.map(t=>t.id)}get nodes(){return super.nodes}set nodes(t){this._nodes=t}get scriptedCodeNodes(){return this.nodes.filter(t=>!t.state?.integrated)}get selectedNodeIds(){return this.selectedNodes.map(t=>t.id)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get visibleNodes(){return this.nodes.filter(t=>!t.state?.hidden)}addNode(t,n){return t.state&&n&&(t.state.props=n),super.addNode(t)}addNodeAtCoordinates=(t,n={x:0,y:0},s)=>(this.addNode(t,s),t.position&&(t.position=n),t);addConnection(t,n){t&&t?.name!=="_code"&&(t.hidden=!1),n&&n?.name!=="_code"&&(n.hidden=!1),super.addConnection(t,n)}clear(){this.selectedNodes=[],this._nodes=[],this._connections=[]}findNodeByType(t){return this.nodes.find(n=>n.type===t)}getNodesByType(t){return this.nodes.filter(n=>n.type===t)}getNodesByVariableName(t){return this.nodes.filter(n=>n.state?.variableName===t)}hasConnection(t,n){return this.connections.some(s=>s.from.id===t.id&&s.to.id===n.id)}load(t){const n=super.load(t);return this.nodes.forEach(s=>s.afterGraphLoaded()),n}onUpdate(){this.nodes.forEach(t=>t.onGraphUpdate())}renderCode(t){return Le.render(this.state?.codeTemplate||"",t)}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{let t=this.nodeIds;const n=this.connections.filter(o=>t.includes(o.to.nodeId)&&t.includes(o.from.nodeId)).map(o=>[o.to.nodeId,o.from.nodeId]);t.reverse(),t=Ra.array(t,n),t.reverse();const s=this.nodes.map(o=>o.id).filter(o=>!t.includes(o));t=[...t,...s];const a=t.map(o=>this.findNodeById(o));a&&(this.nodes=a)}catch{console.warn("Failed to sort nodes.")}}}const Wn=e=>{const t=[];return e.nodes.length===0||e.nodes.forEach(n=>{n&&(n.hasOwnProperty("subgraph")?t.push(...Wn(n.subgraph)):n.hasOwnProperty("isCodeNode")&&t.push(n))}),t},ru=(e=0,t=100)=>({x:e*(Bt+70),y:t}),ou=e=>{const t={...e.position};return t.x-=Bt+70,t.y+=50,t},Hn="__baklava_SubgraphInputNode",Fn="__baklava_SubgraphOutputNode";class Oa extends ht{graphInterfaceId;constructor(){super(),this.graphInterfaceId=xe.v4()}onPlaced(){super.onPlaced(),this.initializeIo()}load(t){super.load(t),this.graphInterfaceId=t.graphInterfaceId}save(){return{...super.save(),graphInterfaceId:this.graphInterfaceId}}update(){}}class Gn extends Oa{static isGraphInputNode(t){return t.type===Hn}type=Hn;inputs={name:new q.NodeInterface("Name","Input")};outputs={placeholder:new q.NodeInterface("Value",void 0)}}class jn extends Oa{static isGraphOutputNode(t){return t.type===Fn}type=Fn;inputs={name:new q.NodeInterface("Name","Output"),placeholder:new q.NodeInterface("Value",void 0)};outputs={output:new q.NodeInterface("Output",void 0).setHidden(!0)};calculate=({placeholder:t})=>({output:t})}const iu=["component","connectionCount","events","hidden","hooks","id","isCodeNode","isInput","name","nodeId","port","templateId","value"];function Ea(e){return class extends zt{type=q.getGraphNodeTypeString(e);get title(){return this._title}set title(n){this.template.name=n}inputs={};outputs={};template=e;subgraph;update(){}onConnected(){}onUnconnected(){}calculate=async(n,s)=>{if(!this.subgraph)throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);if(!s.engine||typeof s.engine!="object")throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);const a=s.engine.getInputValues(this.subgraph);for(const l of this.subgraph.inputs)a.set(l.nodeInterfaceId,n[l.id]);const o=await s.engine.runGraph(this.subgraph,a,s.globalValues);s.engine.pause(),he.applyResult(o,s.engine.editor),s.engine.resume();const i={};for(const l of this.subgraph.outputs)i[l.id]=o.get(l.nodeId)?.get("output");return i._calculationResults=o,this.lockCode||(i._code=this.renderCode({inputs:n,...s.globalValues})),this.updateOutputValues(i),i};load(n){if(!this.subgraph)throw new Error("Cannot load a graph node without a graph");if(!this.template)throw new Error("Unable to load graph node without graph template");this.subgraph.load(n.graphState),super.load(n)}save(){if(!this.subgraph)throw new Error("Cannot save a graph node without a graph");return{...super.save(),graphState:this.subgraph.save()}}onPlaced(){this.template.events.updated.subscribe(this,()=>this.initialize()),this.template.events.nameChanged.subscribe(this,n=>{this._title=n}),this.initialize()}onDestroy(){this.template.events.updated.unsubscribe(this),this.template.events.nameChanged.unsubscribe(this),this.subgraph?.destroy()}initialize(){this.subgraph&&this.subgraph.destroy(),this.subgraph=this.template.createGraph(),this._title=this.template.name,this.updateInterfaces(),this.state.codeTemplate=`{{ #nodes }}{{ script }}
6
+ `+new Error().stack),n=!1}return t.apply(this,arguments)},t)}var Ts={};function Is(e,t){_.deprecationHandler!=null&&_.deprecationHandler(e,t),Ts[e]||(Es(t),Ts[e]=!0)}_.suppressDeprecationWarnings=!1,_.deprecationHandler=null;function pe(e){return typeof Function<"u"&&e instanceof Function||Object.prototype.toString.call(e)==="[object Function]"}function ai(e){var t,n;for(n in e)P(e,n)&&(t=e[n],pe(t)?this[n]=t:this["_"+n]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)}function dn(e,t){var n=Te({},e),s;for(s in t)P(t,s)&&(Ye(e[s])&&Ye(t[s])?(n[s]={},Te(n[s],e[s]),Te(n[s],t[s])):t[s]!=null?n[s]=t[s]:delete n[s]);for(s in e)P(e,s)&&!P(t,s)&&Ye(e[s])&&(n[s]=Te({},n[s]));return n}function cn(e){e!=null&&this.set(e)}var un;Object.keys?un=Object.keys:un=function(e){var t,n=[];for(t in e)P(e,t)&&n.push(t);return n};var ri={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};function oi(e,t,n){var s=this._calendar[e]||this._calendar.sameElse;return pe(s)?s.call(t,n):s}function me(e,t,n){var s=""+Math.abs(e),a=t-s.length,o=e>=0;return(o?n?"+":"":"-")+Math.pow(10,Math.max(0,a)).toString().substr(1)+s}var hn=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,_t=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,fn={},Ue={};function C(e,t,n,s){var a=s;typeof s=="string"&&(a=function(){return this[s]()}),e&&(Ue[e]=a),t&&(Ue[t[0]]=function(){return me(a.apply(this,arguments),t[1],t[2])}),n&&(Ue[n]=function(){return this.localeData().ordinal(a.apply(this,arguments),e)})}function ii(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function li(e){var t=e.match(hn),n,s;for(n=0,s=t.length;n<s;n++)Ue[t[n]]?t[n]=Ue[t[n]]:t[n]=ii(t[n]);return function(a){var o="",i;for(i=0;i<s;i++)o+=pe(t[i])?t[i].call(a,e):t[i];return o}}function yt(e,t){return e.isValid()?(t=Ds(t,e.localeData()),fn[t]=fn[t]||li(t),fn[t](e)):e.localeData().invalidDate()}function Ds(e,t){var n=5;function s(a){return t.longDateFormat(a)||a}for(_t.lastIndex=0;n>=0&&_t.test(e);)e=e.replace(_t,s),_t.lastIndex=0,n-=1;return e}var di={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function ci(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toUpperCase()];return t||!n?t:(this._longDateFormat[e]=n.match(hn).map(function(s){return s==="MMMM"||s==="MM"||s==="DD"||s==="dddd"?s.slice(1):s}).join(""),this._longDateFormat[e])}var ui="Invalid date";function hi(){return this._invalidDate}var fi="%d",pi=/\d{1,2}/;function mi(e){return this._ordinal.replace("%d",e)}var _i={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function yi(e,t,n,s){var a=this._relativeTime[n];return pe(a)?a(e,t,n,s):a.replace(/%d/i,e)}function gi(e,t){var n=this._relativeTime[e>0?"future":"past"];return pe(n)?n(t):n.replace(/%s/i,t)}var xs={D:"date",dates:"date",date:"date",d:"day",days:"day",day:"day",e:"weekday",weekdays:"weekday",weekday:"weekday",E:"isoWeekday",isoweekdays:"isoWeekday",isoweekday:"isoWeekday",DDD:"dayOfYear",dayofyears:"dayOfYear",dayofyear:"dayOfYear",h:"hour",hours:"hour",hour:"hour",ms:"millisecond",milliseconds:"millisecond",millisecond:"millisecond",m:"minute",minutes:"minute",minute:"minute",M:"month",months:"month",month:"month",Q:"quarter",quarters:"quarter",quarter:"quarter",s:"second",seconds:"second",second:"second",gg:"weekYear",weekyears:"weekYear",weekyear:"weekYear",GG:"isoWeekYear",isoweekyears:"isoWeekYear",isoweekyear:"isoWeekYear",w:"week",weeks:"week",week:"week",W:"isoWeek",isoweeks:"isoWeek",isoweek:"isoWeek",y:"year",years:"year",year:"year"};function re(e){return typeof e=="string"?xs[e]||xs[e.toLowerCase()]:void 0}function pn(e){var t={},n,s;for(s in e)P(e,s)&&(n=re(s),n&&(t[n]=e[s]));return t}var ki={date:9,day:11,weekday:11,isoWeekday:11,dayOfYear:4,hour:13,millisecond:16,minute:14,month:8,quarter:7,second:15,weekYear:1,isoWeekYear:1,week:5,isoWeek:5,year:1};function bi(e){var t=[],n;for(n in e)P(e,n)&&t.push({unit:n,priority:ki[n]});return t.sort(function(s,a){return s.priority-a.priority}),t}var Ys=/\d/,ne=/\d\d/,Rs=/\d{3}/,mn=/\d{4}/,gt=/[+-]?\d{6}/,$=/\d\d?/,Ps=/\d\d\d\d?/,Bs=/\d\d\d\d\d\d?/,kt=/\d{1,3}/,_n=/\d{1,4}/,bt=/[+-]?\d{1,6}/,$e=/\d+/,wt=/[+-]?\d+/,wi=/Z|[+-]\d\d:?\d\d/gi,vt=/Z|[+-]\d\d(?::?\d\d)?/gi,vi=/[+-]?\d+(\.\d{1,3})?/,Xe=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,We=/^[1-9]\d?/,yn=/^([1-9]\d|\d)/,Nt;Nt={};function y(e,t,n){Nt[e]=pe(t)?t:function(s,a){return s&&n?n:t}}function Ni(e,t){return P(Nt,e)?Nt[e](t._strict,t._locale):new RegExp(Ci(e))}function Ci(e){return ke(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,n,s,a,o){return n||s||a||o}))}function ke(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function oe(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function x(e){var t=+e,n=0;return t!==0&&isFinite(t)&&(n=oe(t)),n}var gn={};function L(e,t){var n,s=t,a;for(typeof e=="string"&&(e=[e]),ge(t)&&(s=function(o,i){i[t]=x(o)}),a=e.length,n=0;n<a;n++)gn[e[n]]=s}function Qe(e,t){L(e,function(n,s,a,o){a._w=a._w||{},t(n,a._w,a,o)})}function Mi(e,t,n){t!=null&&P(gn,e)&&gn[e](t,n._a,n,e)}function Ct(e){return e%4===0&&e%100!==0||e%400===0}var X=0,be=1,_e=2,K=3,de=4,we=5,Re=6,Si=7,Oi=8;C("Y",0,0,function(){var e=this.year();return e<=9999?me(e,4):"+"+e}),C(0,["YY",2],0,function(){return this.year()%100}),C(0,["YYYY",4],0,"year"),C(0,["YYYYY",5],0,"year"),C(0,["YYYYYY",6,!0],0,"year"),y("Y",wt),y("YY",$,ne),y("YYYY",_n,mn),y("YYYYY",bt,gt),y("YYYYYY",bt,gt),L(["YYYYY","YYYYYY"],X),L("YYYY",function(e,t){t[X]=e.length===2?_.parseTwoDigitYear(e):x(e)}),L("YY",function(e,t){t[X]=_.parseTwoDigitYear(e)}),L("Y",function(e,t){t[X]=parseInt(e,10)});function et(e){return Ct(e)?366:365}_.parseTwoDigitYear=function(e){return x(e)+(x(e)>68?1900:2e3)};var Vs=He("FullYear",!0);function Ei(){return Ct(this.year())}function He(e,t){return function(n){return n!=null?(Ls(this,e,n),_.updateOffset(this,t),this):tt(this,e)}}function tt(e,t){if(!e.isValid())return NaN;var n=e._d,s=e._isUTC;switch(t){case"Milliseconds":return s?n.getUTCMilliseconds():n.getMilliseconds();case"Seconds":return s?n.getUTCSeconds():n.getSeconds();case"Minutes":return s?n.getUTCMinutes():n.getMinutes();case"Hours":return s?n.getUTCHours():n.getHours();case"Date":return s?n.getUTCDate():n.getDate();case"Day":return s?n.getUTCDay():n.getDay();case"Month":return s?n.getUTCMonth():n.getMonth();case"FullYear":return s?n.getUTCFullYear():n.getFullYear();default:return NaN}}function Ls(e,t,n){var s,a,o,i,l;if(!(!e.isValid()||isNaN(n))){switch(s=e._d,a=e._isUTC,t){case"Milliseconds":return void(a?s.setUTCMilliseconds(n):s.setMilliseconds(n));case"Seconds":return void(a?s.setUTCSeconds(n):s.setSeconds(n));case"Minutes":return void(a?s.setUTCMinutes(n):s.setMinutes(n));case"Hours":return void(a?s.setUTCHours(n):s.setHours(n));case"Date":return void(a?s.setUTCDate(n):s.setDate(n));case"FullYear":break;default:return}o=n,i=e.month(),l=e.date(),l=l===29&&i===1&&!Ct(o)?28:l,a?s.setUTCFullYear(o,i,l):s.setFullYear(o,i,l)}}function Ti(e){return e=re(e),pe(this[e])?this[e]():this}function Ii(e,t){if(typeof e=="object"){e=pn(e);var n=bi(e),s,a=n.length;for(s=0;s<a;s++)this[n[s].unit](e[n[s].unit])}else if(e=re(e),pe(this[e]))return this[e](t);return this}function Di(e,t){return(e%t+t)%t}var Z;Array.prototype.indexOf?Z=Array.prototype.indexOf:Z=function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1};function kn(e,t){if(isNaN(e)||isNaN(t))return NaN;var n=Di(t,12);return e+=(t-n)/12,n===1?Ct(e)?29:28:31-n%7%2}C("M",["MM",2],"Mo",function(){return this.month()+1}),C("MMM",0,0,function(e){return this.localeData().monthsShort(this,e)}),C("MMMM",0,0,function(e){return this.localeData().months(this,e)}),y("M",$,We),y("MM",$,ne),y("MMM",function(e,t){return t.monthsShortRegex(e)}),y("MMMM",function(e,t){return t.monthsRegex(e)}),L(["M","MM"],function(e,t){t[be]=x(e)-1}),L(["MMM","MMMM"],function(e,t,n,s){var a=n._locale.monthsParse(e,s,n._strict);a!=null?t[be]=a:T(n).invalidMonth=e});var xi="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),As="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Us=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,Yi=Xe,Ri=Xe;function Pi(e,t){return e?ie(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Us).test(t)?"format":"standalone"][e.month()]:ie(this._months)?this._months:this._months.standalone}function Bi(e,t){return e?ie(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Us.test(t)?"format":"standalone"][e.month()]:ie(this._monthsShort)?this._monthsShort:this._monthsShort.standalone}function Vi(e,t,n){var s,a,o,i=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],s=0;s<12;++s)o=fe([2e3,s]),this._shortMonthsParse[s]=this.monthsShort(o,"").toLocaleLowerCase(),this._longMonthsParse[s]=this.months(o,"").toLocaleLowerCase();return n?t==="MMM"?(a=Z.call(this._shortMonthsParse,i),a!==-1?a:null):(a=Z.call(this._longMonthsParse,i),a!==-1?a:null):t==="MMM"?(a=Z.call(this._shortMonthsParse,i),a!==-1?a:(a=Z.call(this._longMonthsParse,i),a!==-1?a:null)):(a=Z.call(this._longMonthsParse,i),a!==-1?a:(a=Z.call(this._shortMonthsParse,i),a!==-1?a:null))}function Li(e,t,n){var s,a,o;if(this._monthsParseExact)return Vi.call(this,e,t,n);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),s=0;s<12;s++){if(a=fe([2e3,s]),n&&!this._longMonthsParse[s]&&(this._longMonthsParse[s]=new RegExp("^"+this.months(a,"").replace(".","")+"$","i"),this._shortMonthsParse[s]=new RegExp("^"+this.monthsShort(a,"").replace(".","")+"$","i")),!n&&!this._monthsParse[s]&&(o="^"+this.months(a,"")+"|^"+this.monthsShort(a,""),this._monthsParse[s]=new RegExp(o.replace(".",""),"i")),n&&t==="MMMM"&&this._longMonthsParse[s].test(e))return s;if(n&&t==="MMM"&&this._shortMonthsParse[s].test(e))return s;if(!n&&this._monthsParse[s].test(e))return s}}function $s(e,t){if(!e.isValid())return e;if(typeof t=="string"){if(/^\d+$/.test(t))t=x(t);else if(t=e.localeData().monthsParse(t),!ge(t))return e}var n=t,s=e.date();return s=s<29?s:Math.min(s,kn(e.year(),n)),e._isUTC?e._d.setUTCMonth(n,s):e._d.setMonth(n,s),e}function Ws(e){return e!=null?($s(this,e),_.updateOffset(this,!0),this):tt(this,"Month")}function Ai(){return kn(this.year(),this.month())}function Ui(e){return this._monthsParseExact?(P(this,"_monthsRegex")||Hs.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(P(this,"_monthsShortRegex")||(this._monthsShortRegex=Yi),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)}function $i(e){return this._monthsParseExact?(P(this,"_monthsRegex")||Hs.call(this),e?this._monthsStrictRegex:this._monthsRegex):(P(this,"_monthsRegex")||(this._monthsRegex=Ri),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)}function Hs(){function e(d,c){return c.length-d.length}var t=[],n=[],s=[],a,o,i,l;for(a=0;a<12;a++)o=fe([2e3,a]),i=ke(this.monthsShort(o,"")),l=ke(this.months(o,"")),t.push(i),n.push(l),s.push(l),s.push(i);t.sort(e),n.sort(e),s.sort(e),this._monthsRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+t.join("|")+")","i")}function Wi(e,t,n,s,a,o,i){var l;return e<100&&e>=0?(l=new Date(e+400,t,n,s,a,o,i),isFinite(l.getFullYear())&&l.setFullYear(e)):l=new Date(e,t,n,s,a,o,i),l}function nt(e){var t,n;return e<100&&e>=0?(n=Array.prototype.slice.call(arguments),n[0]=e+400,t=new Date(Date.UTC.apply(null,n)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Mt(e,t,n){var s=7+t-n,a=(7+nt(e,0,s).getUTCDay()-t)%7;return-a+s-1}function Fs(e,t,n,s,a){var o=(7+n-s)%7,i=Mt(e,s,a),l=1+7*(t-1)+o+i,d,c;return l<=0?(d=e-1,c=et(d)+l):l>et(e)?(d=e+1,c=l-et(e)):(d=e,c=l),{year:d,dayOfYear:c}}function st(e,t,n){var s=Mt(e.year(),t,n),a=Math.floor((e.dayOfYear()-s-1)/7)+1,o,i;return a<1?(i=e.year()-1,o=a+ve(i,t,n)):a>ve(e.year(),t,n)?(o=a-ve(e.year(),t,n),i=e.year()+1):(i=e.year(),o=a),{week:o,year:i}}function ve(e,t,n){var s=Mt(e,t,n),a=Mt(e+1,t,n);return(et(e)-s+a)/7}C("w",["ww",2],"wo","week"),C("W",["WW",2],"Wo","isoWeek"),y("w",$,We),y("ww",$,ne),y("W",$,We),y("WW",$,ne),Qe(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=x(e)});function Hi(e){return st(e,this._week.dow,this._week.doy).week}var Fi={dow:0,doy:6};function Gi(){return this._week.dow}function ji(){return this._week.doy}function zi(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,"d")}function Zi(e){var t=st(this,1,4).week;return e==null?t:this.add((e-t)*7,"d")}C("d",0,"do","day"),C("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),C("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),C("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),C("e",0,0,"weekday"),C("E",0,0,"isoWeekday"),y("d",$),y("e",$),y("E",$),y("dd",function(e,t){return t.weekdaysMinRegex(e)}),y("ddd",function(e,t){return t.weekdaysShortRegex(e)}),y("dddd",function(e,t){return t.weekdaysRegex(e)}),Qe(["dd","ddd","dddd"],function(e,t,n,s){var a=n._locale.weekdaysParse(e,s,n._strict);a!=null?t.d=a:T(n).invalidWeekday=e}),Qe(["d","e","E"],function(e,t,n,s){t[s]=x(e)});function qi(e,t){return typeof e!="string"?e:isNaN(e)?(e=t.weekdaysParse(e),typeof e=="number"?e:null):parseInt(e,10)}function Ki(e,t){return typeof e=="string"?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}function bn(e,t){return e.slice(t,7).concat(e.slice(0,t))}var Ji="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Gs="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Xi="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Qi=Xe,el=Xe,tl=Xe;function nl(e,t){var n=ie(this._weekdays)?this._weekdays:this._weekdays[e&&e!==!0&&this._weekdays.isFormat.test(t)?"format":"standalone"];return e===!0?bn(n,this._week.dow):e?n[e.day()]:n}function sl(e){return e===!0?bn(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function al(e){return e===!0?bn(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function rl(e,t,n){var s,a,o,i=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],s=0;s<7;++s)o=fe([2e3,1]).day(s),this._minWeekdaysParse[s]=this.weekdaysMin(o,"").toLocaleLowerCase(),this._shortWeekdaysParse[s]=this.weekdaysShort(o,"").toLocaleLowerCase(),this._weekdaysParse[s]=this.weekdays(o,"").toLocaleLowerCase();return n?t==="dddd"?(a=Z.call(this._weekdaysParse,i),a!==-1?a:null):t==="ddd"?(a=Z.call(this._shortWeekdaysParse,i),a!==-1?a:null):(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null):t==="dddd"?(a=Z.call(this._weekdaysParse,i),a!==-1||(a=Z.call(this._shortWeekdaysParse,i),a!==-1)?a:(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null)):t==="ddd"?(a=Z.call(this._shortWeekdaysParse,i),a!==-1||(a=Z.call(this._weekdaysParse,i),a!==-1)?a:(a=Z.call(this._minWeekdaysParse,i),a!==-1?a:null)):(a=Z.call(this._minWeekdaysParse,i),a!==-1||(a=Z.call(this._weekdaysParse,i),a!==-1)?a:(a=Z.call(this._shortWeekdaysParse,i),a!==-1?a:null))}function ol(e,t,n){var s,a,o;if(this._weekdaysParseExact)return rl.call(this,e,t,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),s=0;s<7;s++){if(a=fe([2e3,1]).day(s),n&&!this._fullWeekdaysParse[s]&&(this._fullWeekdaysParse[s]=new RegExp("^"+this.weekdays(a,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[s]=new RegExp("^"+this.weekdaysShort(a,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[s]=new RegExp("^"+this.weekdaysMin(a,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[s]||(o="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[s]=new RegExp(o.replace(".",""),"i")),n&&t==="dddd"&&this._fullWeekdaysParse[s].test(e))return s;if(n&&t==="ddd"&&this._shortWeekdaysParse[s].test(e))return s;if(n&&t==="dd"&&this._minWeekdaysParse[s].test(e))return s;if(!n&&this._weekdaysParse[s].test(e))return s}}function il(e){if(!this.isValid())return e!=null?this:NaN;var t=tt(this,"Day");return e!=null?(e=qi(e,this.localeData()),this.add(e-t,"d")):t}function ll(e){if(!this.isValid())return e!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,"d")}function dl(e){if(!this.isValid())return e!=null?this:NaN;if(e!=null){var t=Ki(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function cl(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(P(this,"_weekdaysRegex")||(this._weekdaysRegex=Qi),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)}function ul(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(P(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=el),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function hl(e){return this._weekdaysParseExact?(P(this,"_weekdaysRegex")||wn.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(P(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=tl),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function wn(){function e(f,w){return w.length-f.length}var t=[],n=[],s=[],a=[],o,i,l,d,c;for(o=0;o<7;o++)i=fe([2e3,1]).day(o),l=ke(this.weekdaysMin(i,"")),d=ke(this.weekdaysShort(i,"")),c=ke(this.weekdays(i,"")),t.push(l),n.push(d),s.push(c),a.push(l),a.push(d),a.push(c);t.sort(e),n.sort(e),s.sort(e),a.sort(e),this._weekdaysRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+n.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function vn(){return this.hours()%12||12}function fl(){return this.hours()||24}C("H",["HH",2],0,"hour"),C("h",["hh",2],0,vn),C("k",["kk",2],0,fl),C("hmm",0,0,function(){return""+vn.apply(this)+me(this.minutes(),2)}),C("hmmss",0,0,function(){return""+vn.apply(this)+me(this.minutes(),2)+me(this.seconds(),2)}),C("Hmm",0,0,function(){return""+this.hours()+me(this.minutes(),2)}),C("Hmmss",0,0,function(){return""+this.hours()+me(this.minutes(),2)+me(this.seconds(),2)});function js(e,t){C(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}js("a",!0),js("A",!1);function zs(e,t){return t._meridiemParse}y("a",zs),y("A",zs),y("H",$,yn),y("h",$,We),y("k",$,We),y("HH",$,ne),y("hh",$,ne),y("kk",$,ne),y("hmm",Ps),y("hmmss",Bs),y("Hmm",Ps),y("Hmmss",Bs),L(["H","HH"],K),L(["k","kk"],function(e,t,n){var s=x(e);t[K]=s===24?0:s}),L(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),L(["h","hh"],function(e,t,n){t[K]=x(e),T(n).bigHour=!0}),L("hmm",function(e,t,n){var s=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s)),T(n).bigHour=!0}),L("hmmss",function(e,t,n){var s=e.length-4,a=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s,2)),t[we]=x(e.substr(a)),T(n).bigHour=!0}),L("Hmm",function(e,t,n){var s=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s))}),L("Hmmss",function(e,t,n){var s=e.length-4,a=e.length-2;t[K]=x(e.substr(0,s)),t[de]=x(e.substr(s,2)),t[we]=x(e.substr(a))});function pl(e){return(e+"").toLowerCase().charAt(0)==="p"}var ml=/[ap]\.?m?\.?/i,_l=He("Hours",!0);function yl(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"}var Zs={calendar:ri,longDateFormat:di,invalidDate:ui,ordinal:fi,dayOfMonthOrdinalParse:pi,relativeTime:_i,months:xi,monthsShort:As,week:Fi,weekdays:Ji,weekdaysMin:Xi,weekdaysShort:Gs,meridiemParse:ml},F={},at={},rt;function gl(e,t){var n,s=Math.min(e.length,t.length);for(n=0;n<s;n+=1)if(e[n]!==t[n])return n;return s}function qs(e){return e&&e.toLowerCase().replace("_","-")}function kl(e){for(var t=0,n,s,a,o;t<e.length;){for(o=qs(e[t]).split("-"),n=o.length,s=qs(e[t+1]),s=s?s.split("-"):null;n>0;){if(a=St(o.slice(0,n).join("-")),a)return a;if(s&&s.length>=n&&gl(o,s)>=n-1)break;n--}t++}return rt}function bl(e){return!!(e&&e.match("^[^/\\\\]*$"))}function St(e){var t=null,n;if(F[e]===void 0&&typeof module<"u"&&module&&module.exports&&bl(e))try{t=rt._abbr,n=require,n("./locale/"+e),Ie(t)}catch{F[e]=null}return F[e]}function Ie(e,t){var n;return e&&(ee(t)?n=Ne(e):n=Nn(e,t),n?rt=n:typeof console<"u"&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),rt._abbr}function Nn(e,t){if(t!==null){var n,s=Zs;if(t.abbr=e,F[e]!=null)Is("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=F[e]._config;else if(t.parentLocale!=null)if(F[t.parentLocale]!=null)s=F[t.parentLocale]._config;else if(n=St(t.parentLocale),n!=null)s=n._config;else return at[t.parentLocale]||(at[t.parentLocale]=[]),at[t.parentLocale].push({name:e,config:t}),null;return F[e]=new cn(dn(s,t)),at[e]&&at[e].forEach(function(a){Nn(a.name,a.config)}),Ie(e),F[e]}else return delete F[e],null}function wl(e,t){if(t!=null){var n,s,a=Zs;F[e]!=null&&F[e].parentLocale!=null?F[e].set(dn(F[e]._config,t)):(s=St(e),s!=null&&(a=s._config),t=dn(a,t),s==null&&(t.abbr=e),n=new cn(t),n.parentLocale=F[e],F[e]=n),Ie(e)}else F[e]!=null&&(F[e].parentLocale!=null?(F[e]=F[e].parentLocale,e===Ie()&&Ie(e)):F[e]!=null&&delete F[e]);return F[e]}function Ne(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return rt;if(!ie(e)){if(t=St(e),t)return t;e=[e]}return kl(e)}function vl(){return un(F)}function Cn(e){var t,n=e._a;return n&&T(e).overflow===-2&&(t=n[be]<0||n[be]>11?be:n[_e]<1||n[_e]>kn(n[X],n[be])?_e:n[K]<0||n[K]>24||n[K]===24&&(n[de]!==0||n[we]!==0||n[Re]!==0)?K:n[de]<0||n[de]>59?de:n[we]<0||n[we]>59?we:n[Re]<0||n[Re]>999?Re:-1,T(e)._overflowDayOfYear&&(t<X||t>_e)&&(t=_e),T(e)._overflowWeeks&&t===-1&&(t=Si),T(e)._overflowWeekday&&t===-1&&(t=Oi),T(e).overflow=t),e}var Nl=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Cl=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ml=/Z|[+-]\d\d(?::?\d\d)?/,Ot=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],Mn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Sl=/^\/?Date\((-?\d+)/i,Ol=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,El={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Ks(e){var t,n,s=e._i,a=Nl.exec(s)||Cl.exec(s),o,i,l,d,c=Ot.length,f=Mn.length;if(a){for(T(e).iso=!0,t=0,n=c;t<n;t++)if(Ot[t][1].exec(a[1])){i=Ot[t][0],o=Ot[t][2]!==!1;break}if(i==null){e._isValid=!1;return}if(a[3]){for(t=0,n=f;t<n;t++)if(Mn[t][1].exec(a[3])){l=(a[2]||" ")+Mn[t][0];break}if(l==null){e._isValid=!1;return}}if(!o&&l!=null){e._isValid=!1;return}if(a[4])if(Ml.exec(a[4]))d="Z";else{e._isValid=!1;return}e._f=i+(l||"")+(d||""),On(e)}else e._isValid=!1}function Tl(e,t,n,s,a,o){var i=[Il(e),As.indexOf(t),parseInt(n,10),parseInt(s,10),parseInt(a,10)];return o&&i.push(parseInt(o,10)),i}function Il(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function Dl(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function xl(e,t,n){if(e){var s=Gs.indexOf(e),a=new Date(t[0],t[1],t[2]).getDay();if(s!==a)return T(n).weekdayMismatch=!0,n._isValid=!1,!1}return!0}function Yl(e,t,n){if(e)return El[e];if(t)return 0;var s=parseInt(n,10),a=s%100,o=(s-a)/100;return o*60+a}function Js(e){var t=Ol.exec(Dl(e._i)),n;if(t){if(n=Tl(t[4],t[3],t[2],t[5],t[6],t[7]),!xl(t[1],n,e))return;e._a=n,e._tzm=Yl(t[8],t[9],t[10]),e._d=nt.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),T(e).rfc2822=!0}else e._isValid=!1}function Rl(e){var t=Sl.exec(e._i);if(t!==null){e._d=new Date(+t[1]);return}if(Ks(e),e._isValid===!1)delete e._isValid;else return;if(Js(e),e._isValid===!1)delete e._isValid;else return;e._strict?e._isValid=!1:_.createFromInputFallback(e)}_.createFromInputFallback=ae("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(e){e._d=new Date(e._i+(e._useUTC?" UTC":""))});function Fe(e,t,n){return e??t??n}function Pl(e){var t=new Date(_.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function Sn(e){var t,n,s=[],a,o,i;if(!e._d){for(a=Pl(e),e._w&&e._a[_e]==null&&e._a[be]==null&&Bl(e),e._dayOfYear!=null&&(i=Fe(e._a[X],a[X]),(e._dayOfYear>et(i)||e._dayOfYear===0)&&(T(e)._overflowDayOfYear=!0),n=nt(i,0,e._dayOfYear),e._a[be]=n.getUTCMonth(),e._a[_e]=n.getUTCDate()),t=0;t<3&&e._a[t]==null;++t)e._a[t]=s[t]=a[t];for(;t<7;t++)e._a[t]=s[t]=e._a[t]==null?t===2?1:0:e._a[t];e._a[K]===24&&e._a[de]===0&&e._a[we]===0&&e._a[Re]===0&&(e._nextDay=!0,e._a[K]=0),e._d=(e._useUTC?nt:Wi).apply(null,s),o=e._useUTC?e._d.getUTCDay():e._d.getDay(),e._tzm!=null&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[K]=24),e._w&&typeof e._w.d<"u"&&e._w.d!==o&&(T(e).weekdayMismatch=!0)}}function Bl(e){var t,n,s,a,o,i,l,d,c;t=e._w,t.GG!=null||t.W!=null||t.E!=null?(o=1,i=4,n=Fe(t.GG,e._a[X],st(W(),1,4).year),s=Fe(t.W,1),a=Fe(t.E,1),(a<1||a>7)&&(d=!0)):(o=e._locale._week.dow,i=e._locale._week.doy,c=st(W(),o,i),n=Fe(t.gg,e._a[X],c.year),s=Fe(t.w,c.week),t.d!=null?(a=t.d,(a<0||a>6)&&(d=!0)):t.e!=null?(a=t.e+o,(t.e<0||t.e>6)&&(d=!0)):a=o),s<1||s>ve(n,o,i)?T(e)._overflowWeeks=!0:d!=null?T(e)._overflowWeekday=!0:(l=Fs(n,s,a,o,i),e._a[X]=l.year,e._dayOfYear=l.dayOfYear)}_.ISO_8601=function(){},_.RFC_2822=function(){};function On(e){if(e._f===_.ISO_8601){Ks(e);return}if(e._f===_.RFC_2822){Js(e);return}e._a=[],T(e).empty=!0;var t=""+e._i,n,s,a,o,i,l=t.length,d=0,c,f;for(a=Ds(e._f,e._locale).match(hn)||[],f=a.length,n=0;n<f;n++)o=a[n],s=(t.match(Ni(o,e))||[])[0],s&&(i=t.substr(0,t.indexOf(s)),i.length>0&&T(e).unusedInput.push(i),t=t.slice(t.indexOf(s)+s.length),d+=s.length),Ue[o]?(s?T(e).empty=!1:T(e).unusedTokens.push(o),Mi(o,s,e)):e._strict&&!s&&T(e).unusedTokens.push(o);T(e).charsLeftOver=l-d,t.length>0&&T(e).unusedInput.push(t),e._a[K]<=12&&T(e).bigHour===!0&&e._a[K]>0&&(T(e).bigHour=void 0),T(e).parsedDateParts=e._a.slice(0),T(e).meridiem=e._meridiem,e._a[K]=Vl(e._locale,e._a[K],e._meridiem),c=T(e).era,c!==null&&(e._a[X]=e._locale.erasConvertYear(c,e._a[X])),Sn(e),Cn(e)}function Vl(e,t,n){var s;return n==null?t:e.meridiemHour!=null?e.meridiemHour(t,n):(e.isPM!=null&&(s=e.isPM(n),s&&t<12&&(t+=12),!s&&t===12&&(t=0)),t)}function Ll(e){var t,n,s,a,o,i,l=!1,d=e._f.length;if(d===0){T(e).invalidFormat=!0,e._d=new Date(NaN);return}for(a=0;a<d;a++)o=0,i=!1,t=ln({},e),e._useUTC!=null&&(t._useUTC=e._useUTC),t._f=e._f[a],On(t),rn(t)&&(i=!0),o+=T(t).charsLeftOver,o+=T(t).unusedTokens.length*10,T(t).score=o,l?o<s&&(s=o,n=t):(s==null||o<s||i)&&(s=o,n=t,i&&(l=!0));Te(e,n||t)}function Al(e){if(!e._d){var t=pn(e._i),n=t.day===void 0?t.date:t.day;e._a=Ss([t.year,t.month,n,t.hour,t.minute,t.second,t.millisecond],function(s){return s&&parseInt(s,10)}),Sn(e)}}function Ul(e){var t=new Je(Cn(Xs(e)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function Xs(e){var t=e._i,n=e._f;return e._locale=e._locale||Ne(e._l),t===null||n===void 0&&t===""?mt({nullInput:!0}):(typeof t=="string"&&(e._i=t=e._locale.preparse(t)),le(t)?new Je(Cn(t)):(Ke(t)?e._d=t:ie(n)?Ll(e):n?On(e):$l(e),rn(e)||(e._d=null),e))}function $l(e){var t=e._i;ee(t)?e._d=new Date(_.now()):Ke(t)?e._d=new Date(t.valueOf()):typeof t=="string"?Rl(e):ie(t)?(e._a=Ss(t.slice(0),function(n){return parseInt(n,10)}),Sn(e)):Ye(t)?Al(e):ge(t)?e._d=new Date(t):_.createFromInputFallback(e)}function Qs(e,t,n,s,a){var o={};return(t===!0||t===!1)&&(s=t,t=void 0),(n===!0||n===!1)&&(s=n,n=void 0),(Ye(e)&&sn(e)||ie(e)&&e.length===0)&&(e=void 0),o._isAMomentObject=!0,o._useUTC=o._isUTC=a,o._l=n,o._i=e,o._f=t,o._strict=s,Ul(o)}function W(e,t,n,s){return Qs(e,t,n,s,!1)}var Wl=ae("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var e=W.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:mt()}),Hl=ae("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var e=W.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:mt()});function ea(e,t){var n,s;if(t.length===1&&ie(t[0])&&(t=t[0]),!t.length)return W();for(n=t[0],s=1;s<t.length;++s)(!t[s].isValid()||t[s][e](n))&&(n=t[s]);return n}function Fl(){var e=[].slice.call(arguments,0);return ea("isBefore",e)}function Gl(){var e=[].slice.call(arguments,0);return ea("isAfter",e)}var jl=function(){return Date.now?Date.now():+new Date},ot=["year","quarter","month","week","day","hour","minute","second","millisecond"];function zl(e){var t,n=!1,s,a=ot.length;for(t in e)if(P(e,t)&&!(Z.call(ot,t)!==-1&&(e[t]==null||!isNaN(e[t]))))return!1;for(s=0;s<a;++s)if(e[ot[s]]){if(n)return!1;parseFloat(e[ot[s]])!==x(e[ot[s]])&&(n=!0)}return!0}function Zl(){return this._isValid}function ql(){return ce(NaN)}function Et(e){var t=pn(e),n=t.year||0,s=t.quarter||0,a=t.month||0,o=t.week||t.isoWeek||0,i=t.day||0,l=t.hour||0,d=t.minute||0,c=t.second||0,f=t.millisecond||0;this._isValid=zl(t),this._milliseconds=+f+c*1e3+d*6e4+l*1e3*60*60,this._days=+i+o*7,this._months=+a+s*3+n*12,this._data={},this._locale=Ne(),this._bubble()}function Tt(e){return e instanceof Et}function En(e){return e<0?Math.round(-1*e)*-1:Math.round(e)}function Kl(e,t,n){var s=Math.min(e.length,t.length),a=Math.abs(e.length-t.length),o=0,i;for(i=0;i<s;i++)x(e[i])!==x(t[i])&&o++;return o+a}function ta(e,t){C(e,0,0,function(){var n=this.utcOffset(),s="+";return n<0&&(n=-n,s="-"),s+me(~~(n/60),2)+t+me(~~n%60,2)})}ta("Z",":"),ta("ZZ",""),y("Z",vt),y("ZZ",vt),L(["Z","ZZ"],function(e,t,n){n._useUTC=!0,n._tzm=Tn(vt,e)});var Jl=/([\+\-]|\d\d)/gi;function Tn(e,t){var n=(t||"").match(e),s,a,o;return n===null?null:(s=n[n.length-1]||[],a=(s+"").match(Jl)||["-",0,0],o=+(a[1]*60)+x(a[2]),o===0?0:a[0]==="+"?o:-o)}function In(e,t){var n,s;return t._isUTC?(n=t.clone(),s=(le(e)||Ke(e)?e.valueOf():W(e).valueOf())-n.valueOf(),n._d.setTime(n._d.valueOf()+s),_.updateOffset(n,!1),n):W(e).local()}function Dn(e){return-Math.round(e._d.getTimezoneOffset())}_.updateOffset=function(){};function Xl(e,t,n){var s=this._offset||0,a;if(!this.isValid())return e!=null?this:NaN;if(e!=null){if(typeof e=="string"){if(e=Tn(vt,e),e===null)return this}else Math.abs(e)<16&&!n&&(e=e*60);return!this._isUTC&&t&&(a=Dn(this)),this._offset=e,this._isUTC=!0,a!=null&&this.add(a,"m"),s!==e&&(!t||this._changeInProgress?ra(this,ce(e-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,_.updateOffset(this,!0),this._changeInProgress=null)),this}else return this._isUTC?s:Dn(this)}function Ql(e,t){return e!=null?(typeof e!="string"&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()}function ed(e){return this.utcOffset(0,e)}function td(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Dn(this),"m")),this}function nd(){if(this._tzm!=null)this.utcOffset(this._tzm,!1,!0);else if(typeof this._i=="string"){var e=Tn(wi,this._i);e!=null?this.utcOffset(e):this.utcOffset(0,!0)}return this}function sd(e){return this.isValid()?(e=e?W(e).utcOffset():0,(this.utcOffset()-e)%60===0):!1}function ad(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function rd(){if(!ee(this._isDSTShifted))return this._isDSTShifted;var e={},t;return ln(e,this),e=Xs(e),e._a?(t=e._isUTC?fe(e._a):W(e._a),this._isDSTShifted=this.isValid()&&Kl(e._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}function od(){return this.isValid()?!this._isUTC:!1}function id(){return this.isValid()?this._isUTC:!1}function na(){return this.isValid()?this._isUTC&&this._offset===0:!1}var ld=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,dd=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function ce(e,t){var n=e,s=null,a,o,i;return Tt(e)?n={ms:e._milliseconds,d:e._days,M:e._months}:ge(e)||!isNaN(+e)?(n={},t?n[t]=+e:n.milliseconds=+e):(s=ld.exec(e))?(a=s[1]==="-"?-1:1,n={y:0,d:x(s[_e])*a,h:x(s[K])*a,m:x(s[de])*a,s:x(s[we])*a,ms:x(En(s[Re]*1e3))*a}):(s=dd.exec(e))?(a=s[1]==="-"?-1:1,n={y:Pe(s[2],a),M:Pe(s[3],a),w:Pe(s[4],a),d:Pe(s[5],a),h:Pe(s[6],a),m:Pe(s[7],a),s:Pe(s[8],a)}):n==null?n={}:typeof n=="object"&&("from"in n||"to"in n)&&(i=cd(W(n.from),W(n.to)),n={},n.ms=i.milliseconds,n.M=i.months),o=new Et(n),Tt(e)&&P(e,"_locale")&&(o._locale=e._locale),Tt(e)&&P(e,"_isValid")&&(o._isValid=e._isValid),o}ce.fn=Et.prototype,ce.invalid=ql;function Pe(e,t){var n=e&&parseFloat(e.replace(",","."));return(isNaN(n)?0:n)*t}function sa(e,t){var n={};return n.months=t.month()-e.month()+(t.year()-e.year())*12,e.clone().add(n.months,"M").isAfter(t)&&--n.months,n.milliseconds=+t-+e.clone().add(n.months,"M"),n}function cd(e,t){var n;return e.isValid()&&t.isValid()?(t=In(t,e),e.isBefore(t)?n=sa(e,t):(n=sa(t,e),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function aa(e,t){return function(n,s){var a,o;return s!==null&&!isNaN(+s)&&(Is(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),o=n,n=s,s=o),a=ce(n,s),ra(this,a,e),this}}function ra(e,t,n,s){var a=t._milliseconds,o=En(t._days),i=En(t._months);e.isValid()&&(s=s??!0,i&&$s(e,tt(e,"Month")+i*n),o&&Ls(e,"Date",tt(e,"Date")+o*n),a&&e._d.setTime(e._d.valueOf()+a*n),s&&_.updateOffset(e,o||i))}var ud=aa(1,"add"),hd=aa(-1,"subtract");function oa(e){return typeof e=="string"||e instanceof String}function fd(e){return le(e)||Ke(e)||oa(e)||ge(e)||md(e)||pd(e)||e===null||e===void 0}function pd(e){var t=Ye(e)&&!sn(e),n=!1,s=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],a,o,i=s.length;for(a=0;a<i;a+=1)o=s[a],n=n||P(e,o);return t&&n}function md(e){var t=ie(e),n=!1;return t&&(n=e.filter(function(s){return!ge(s)&&oa(e)}).length===0),t&&n}function _d(e){var t=Ye(e)&&!sn(e),n=!1,s=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"],a,o;for(a=0;a<s.length;a+=1)o=s[a],n=n||P(e,o);return t&&n}function yd(e,t){var n=e.diff(t,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"}function gd(e,t){arguments.length===1&&(arguments[0]?fd(arguments[0])?(e=arguments[0],t=void 0):_d(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var n=e||W(),s=In(n,this).startOf("day"),a=_.calendarFormat(this,s)||"sameElse",o=t&&(pe(t[a])?t[a].call(this,n):t[a]);return this.format(o||this.localeData().calendar(a,this,W(n)))}function kd(){return new Je(this)}function bd(e,t){var n=le(e)?e:W(e);return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()>n.valueOf():n.valueOf()<this.clone().startOf(t).valueOf()):!1}function wd(e,t){var n=le(e)?e:W(e);return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()<n.valueOf():this.clone().endOf(t).valueOf()<n.valueOf()):!1}function vd(e,t,n,s){var a=le(e)?e:W(e),o=le(t)?t:W(t);return this.isValid()&&a.isValid()&&o.isValid()?(s=s||"()",(s[0]==="("?this.isAfter(a,n):!this.isBefore(a,n))&&(s[1]===")"?this.isBefore(o,n):!this.isAfter(o,n))):!1}function Nd(e,t){var n=le(e)?e:W(e),s;return this.isValid()&&n.isValid()?(t=re(t)||"millisecond",t==="millisecond"?this.valueOf()===n.valueOf():(s=n.valueOf(),this.clone().startOf(t).valueOf()<=s&&s<=this.clone().endOf(t).valueOf())):!1}function Cd(e,t){return this.isSame(e,t)||this.isAfter(e,t)}function Md(e,t){return this.isSame(e,t)||this.isBefore(e,t)}function Sd(e,t,n){var s,a,o;if(!this.isValid())return NaN;if(s=In(e,this),!s.isValid())return NaN;switch(a=(s.utcOffset()-this.utcOffset())*6e4,t=re(t),t){case"year":o=It(this,s)/12;break;case"month":o=It(this,s);break;case"quarter":o=It(this,s)/3;break;case"second":o=(this-s)/1e3;break;case"minute":o=(this-s)/6e4;break;case"hour":o=(this-s)/36e5;break;case"day":o=(this-s-a)/864e5;break;case"week":o=(this-s-a)/6048e5;break;default:o=this-s}return n?o:oe(o)}function It(e,t){if(e.date()<t.date())return-It(t,e);var n=(t.year()-e.year())*12+(t.month()-e.month()),s=e.clone().add(n,"months"),a,o;return t-s<0?(a=e.clone().add(n-1,"months"),o=(t-s)/(s-a)):(a=e.clone().add(n+1,"months"),o=(t-s)/(a-s)),-(n+o)||0}_.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",_.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";function Od(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function Ed(e){if(!this.isValid())return null;var t=e!==!0,n=t?this.clone().utc():this;return n.year()<0||n.year()>9999?yt(n,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):pe(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",yt(n,"Z")):yt(n,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function Td(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e="moment",t="",n,s,a,o;return this.isLocal()||(e=this.utcOffset()===0?"moment.utc":"moment.parseZone",t="Z"),n="["+e+'("]',s=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",a="-MM-DD[T]HH:mm:ss.SSS",o=t+'[")]',this.format(n+s+a+o)}function Id(e){e||(e=this.isUtc()?_.defaultFormatUtc:_.defaultFormat);var t=yt(this,e);return this.localeData().postformat(t)}function Dd(e,t){return this.isValid()&&(le(e)&&e.isValid()||W(e).isValid())?ce({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function xd(e){return this.from(W(),e)}function Yd(e,t){return this.isValid()&&(le(e)&&e.isValid()||W(e).isValid())?ce({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function Rd(e){return this.to(W(),e)}function ia(e){var t;return e===void 0?this._locale._abbr:(t=Ne(e),t!=null&&(this._locale=t),this)}var la=ae("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(e){return e===void 0?this.localeData():this.locale(e)});function da(){return this._locale}var Dt=1e3,Ge=60*Dt,xt=60*Ge,ca=(365*400+97)*24*xt;function je(e,t){return(e%t+t)%t}function ua(e,t,n){return e<100&&e>=0?new Date(e+400,t,n)-ca:new Date(e,t,n).valueOf()}function ha(e,t,n){return e<100&&e>=0?Date.UTC(e+400,t,n)-ca:Date.UTC(e,t,n)}function Pd(e){var t,n;if(e=re(e),e===void 0||e==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?ha:ua,e){case"year":t=n(this.year(),0,1);break;case"quarter":t=n(this.year(),this.month()-this.month()%3,1);break;case"month":t=n(this.year(),this.month(),1);break;case"week":t=n(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=n(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=je(t+(this._isUTC?0:this.utcOffset()*Ge),xt);break;case"minute":t=this._d.valueOf(),t-=je(t,Ge);break;case"second":t=this._d.valueOf(),t-=je(t,Dt);break}return this._d.setTime(t),_.updateOffset(this,!0),this}function Bd(e){var t,n;if(e=re(e),e===void 0||e==="millisecond"||!this.isValid())return this;switch(n=this._isUTC?ha:ua,e){case"year":t=n(this.year()+1,0,1)-1;break;case"quarter":t=n(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=n(this.year(),this.month()+1,1)-1;break;case"week":t=n(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=n(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=n(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=xt-je(t+(this._isUTC?0:this.utcOffset()*Ge),xt)-1;break;case"minute":t=this._d.valueOf(),t+=Ge-je(t,Ge)-1;break;case"second":t=this._d.valueOf(),t+=Dt-je(t,Dt)-1;break}return this._d.setTime(t),_.updateOffset(this,!0),this}function Vd(){return this._d.valueOf()-(this._offset||0)*6e4}function Ld(){return Math.floor(this.valueOf()/1e3)}function Ad(){return new Date(this.valueOf())}function Ud(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function $d(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Wd(){return this.isValid()?this.toISOString():null}function Hd(){return rn(this)}function Fd(){return Te({},T(this))}function Gd(){return T(this).overflow}function jd(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}C("N",0,0,"eraAbbr"),C("NN",0,0,"eraAbbr"),C("NNN",0,0,"eraAbbr"),C("NNNN",0,0,"eraName"),C("NNNNN",0,0,"eraNarrow"),C("y",["y",1],"yo","eraYear"),C("y",["yy",2],0,"eraYear"),C("y",["yyy",3],0,"eraYear"),C("y",["yyyy",4],0,"eraYear"),y("N",xn),y("NN",xn),y("NNN",xn),y("NNNN",sc),y("NNNNN",ac),L(["N","NN","NNN","NNNN","NNNNN"],function(e,t,n,s){var a=n._locale.erasParse(e,s,n._strict);a?T(n).era=a:T(n).invalidEra=e}),y("y",$e),y("yy",$e),y("yyy",$e),y("yyyy",$e),y("yo",rc),L(["y","yy","yyy","yyyy"],X),L(["yo"],function(e,t,n,s){var a;n._locale._eraYearOrdinalRegex&&(a=e.match(n._locale._eraYearOrdinalRegex)),n._locale.eraYearOrdinalParse?t[X]=n._locale.eraYearOrdinalParse(e,a):t[X]=parseInt(e,10)});function zd(e,t){var n,s,a,o=this._eras||Ne("en")._eras;for(n=0,s=o.length;n<s;++n)switch(typeof o[n].since==="string"&&(a=_(o[n].since).startOf("day"),o[n].since=a.valueOf()),typeof o[n].until){case"undefined":o[n].until=1/0;break;case"string":a=_(o[n].until).startOf("day").valueOf(),o[n].until=a.valueOf();break}return o}function Zd(e,t,n){var s,a,o=this.eras(),i,l,d;for(e=e.toUpperCase(),s=0,a=o.length;s<a;++s)if(i=o[s].name.toUpperCase(),l=o[s].abbr.toUpperCase(),d=o[s].narrow.toUpperCase(),n)switch(t){case"N":case"NN":case"NNN":if(l===e)return o[s];break;case"NNNN":if(i===e)return o[s];break;case"NNNNN":if(d===e)return o[s];break}else if([i,l,d].indexOf(e)>=0)return o[s]}function qd(e,t){var n=e.since<=e.until?1:-1;return t===void 0?_(e.since).year():_(e.since).year()+(t-e.offset)*n}function Kd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].name;return""}function Jd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].narrow;return""}function Xd(){var e,t,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return s[e].abbr;return""}function Qd(){var e,t,n,s,a=this.localeData().eras();for(e=0,t=a.length;e<t;++e)if(n=a[e].since<=a[e].until?1:-1,s=this.clone().startOf("day").valueOf(),a[e].since<=s&&s<=a[e].until||a[e].until<=s&&s<=a[e].since)return(this.year()-_(a[e].since).year())*n+a[e].offset;return this.year()}function ec(e){return P(this,"_erasNameRegex")||Yn.call(this),e?this._erasNameRegex:this._erasRegex}function tc(e){return P(this,"_erasAbbrRegex")||Yn.call(this),e?this._erasAbbrRegex:this._erasRegex}function nc(e){return P(this,"_erasNarrowRegex")||Yn.call(this),e?this._erasNarrowRegex:this._erasRegex}function xn(e,t){return t.erasAbbrRegex(e)}function sc(e,t){return t.erasNameRegex(e)}function ac(e,t){return t.erasNarrowRegex(e)}function rc(e,t){return t._eraYearOrdinalRegex||$e}function Yn(){var e=[],t=[],n=[],s=[],a,o,i,l,d,c=this.eras();for(a=0,o=c.length;a<o;++a)i=ke(c[a].name),l=ke(c[a].abbr),d=ke(c[a].narrow),t.push(i),e.push(l),n.push(d),s.push(i),s.push(l),s.push(d);this._erasRegex=new RegExp("^("+s.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+t.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+e.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+n.join("|")+")","i")}C(0,["gg",2],0,function(){return this.weekYear()%100}),C(0,["GG",2],0,function(){return this.isoWeekYear()%100});function Yt(e,t){C(0,[e,e.length],0,t)}Yt("gggg","weekYear"),Yt("ggggg","weekYear"),Yt("GGGG","isoWeekYear"),Yt("GGGGG","isoWeekYear"),y("G",wt),y("g",wt),y("GG",$,ne),y("gg",$,ne),y("GGGG",_n,mn),y("gggg",_n,mn),y("GGGGG",bt,gt),y("ggggg",bt,gt),Qe(["gggg","ggggg","GGGG","GGGGG"],function(e,t,n,s){t[s.substr(0,2)]=x(e)}),Qe(["gg","GG"],function(e,t,n,s){t[s]=_.parseTwoDigitYear(e)});function oc(e){return fa.call(this,e,this.week(),this.weekday()+this.localeData()._week.dow,this.localeData()._week.dow,this.localeData()._week.doy)}function ic(e){return fa.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}function lc(){return ve(this.year(),1,4)}function dc(){return ve(this.isoWeekYear(),1,4)}function cc(){var e=this.localeData()._week;return ve(this.year(),e.dow,e.doy)}function uc(){var e=this.localeData()._week;return ve(this.weekYear(),e.dow,e.doy)}function fa(e,t,n,s,a){var o;return e==null?st(this,s,a).year:(o=ve(e,s,a),t>o&&(t=o),hc.call(this,e,t,n,s,a))}function hc(e,t,n,s,a){var o=Fs(e,t,n,s,a),i=nt(o.year,0,o.dayOfYear);return this.year(i.getUTCFullYear()),this.month(i.getUTCMonth()),this.date(i.getUTCDate()),this}C("Q",0,"Qo","quarter"),y("Q",Ys),L("Q",function(e,t){t[be]=(x(e)-1)*3});function fc(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}C("D",["DD",2],"Do","date"),y("D",$,We),y("DD",$,ne),y("Do",function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),L(["D","DD"],_e),L("Do",function(e,t){t[_e]=x(e.match($)[0])});var pa=He("Date",!0);C("DDD",["DDDD",3],"DDDo","dayOfYear"),y("DDD",kt),y("DDDD",Rs),L(["DDD","DDDD"],function(e,t,n){n._dayOfYear=x(e)});function pc(e){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return e==null?t:this.add(e-t,"d")}C("m",["mm",2],0,"minute"),y("m",$,yn),y("mm",$,ne),L(["m","mm"],de);var mc=He("Minutes",!1);C("s",["ss",2],0,"second"),y("s",$,yn),y("ss",$,ne),L(["s","ss"],we);var _c=He("Seconds",!1);C("S",0,0,function(){return~~(this.millisecond()/100)}),C(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),C(0,["SSS",3],0,"millisecond"),C(0,["SSSS",4],0,function(){return this.millisecond()*10}),C(0,["SSSSS",5],0,function(){return this.millisecond()*100}),C(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),C(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),C(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),C(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),y("S",kt,Ys),y("SS",kt,ne),y("SSS",kt,Rs);var De,ma;for(De="SSSS";De.length<=9;De+="S")y(De,$e);function yc(e,t){t[Re]=x(("0."+e)*1e3)}for(De="S";De.length<=9;De+="S")L(De,yc);ma=He("Milliseconds",!1),C("z",0,0,"zoneAbbr"),C("zz",0,0,"zoneName");function gc(){return this._isUTC?"UTC":""}function kc(){return this._isUTC?"Coordinated Universal Time":""}var u=Je.prototype;u.add=ud,u.calendar=gd,u.clone=kd,u.diff=Sd,u.endOf=Bd,u.format=Id,u.from=Dd,u.fromNow=xd,u.to=Yd,u.toNow=Rd,u.get=Ti,u.invalidAt=Gd,u.isAfter=bd,u.isBefore=wd,u.isBetween=vd,u.isSame=Nd,u.isSameOrAfter=Cd,u.isSameOrBefore=Md,u.isValid=Hd,u.lang=la,u.locale=ia,u.localeData=da,u.max=Hl,u.min=Wl,u.parsingFlags=Fd,u.set=Ii,u.startOf=Pd,u.subtract=hd,u.toArray=Ud,u.toObject=$d,u.toDate=Ad,u.toISOString=Ed,u.inspect=Td,typeof Symbol<"u"&&Symbol.for!=null&&(u[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),u.toJSON=Wd,u.toString=Od,u.unix=Ld,u.valueOf=Vd,u.creationData=jd,u.eraName=Kd,u.eraNarrow=Jd,u.eraAbbr=Xd,u.eraYear=Qd,u.year=Vs,u.isLeapYear=Ei,u.weekYear=oc,u.isoWeekYear=ic,u.quarter=u.quarters=fc,u.month=Ws,u.daysInMonth=Ai,u.week=u.weeks=zi,u.isoWeek=u.isoWeeks=Zi,u.weeksInYear=cc,u.weeksInWeekYear=uc,u.isoWeeksInYear=lc,u.isoWeeksInISOWeekYear=dc,u.date=pa,u.day=u.days=il,u.weekday=ll,u.isoWeekday=dl,u.dayOfYear=pc,u.hour=u.hours=_l,u.minute=u.minutes=mc,u.second=u.seconds=_c,u.millisecond=u.milliseconds=ma,u.utcOffset=Xl,u.utc=ed,u.local=td,u.parseZone=nd,u.hasAlignedHourOffset=sd,u.isDST=ad,u.isLocal=od,u.isUtcOffset=id,u.isUtc=na,u.isUTC=na,u.zoneAbbr=gc,u.zoneName=kc,u.dates=ae("dates accessor is deprecated. Use date instead.",pa),u.months=ae("months accessor is deprecated. Use month instead",Ws),u.years=ae("years accessor is deprecated. Use year instead",Vs),u.zone=ae("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Ql),u.isDSTShifted=ae("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",rd);function bc(e){return W(e*1e3)}function wc(){return W.apply(null,arguments).parseZone()}function _a(e){return e}var B=cn.prototype;B.calendar=oi,B.longDateFormat=ci,B.invalidDate=hi,B.ordinal=mi,B.preparse=_a,B.postformat=_a,B.relativeTime=yi,B.pastFuture=gi,B.set=ai,B.eras=zd,B.erasParse=Zd,B.erasConvertYear=qd,B.erasAbbrRegex=tc,B.erasNameRegex=ec,B.erasNarrowRegex=nc,B.months=Pi,B.monthsShort=Bi,B.monthsParse=Li,B.monthsRegex=$i,B.monthsShortRegex=Ui,B.week=Hi,B.firstDayOfYear=ji,B.firstDayOfWeek=Gi,B.weekdays=nl,B.weekdaysMin=al,B.weekdaysShort=sl,B.weekdaysParse=ol,B.weekdaysRegex=cl,B.weekdaysShortRegex=ul,B.weekdaysMinRegex=hl,B.isPM=pl,B.meridiem=yl;function Rt(e,t,n,s){var a=Ne(),o=fe().set(s,t);return a[n](o,e)}function ya(e,t,n){if(ge(e)&&(t=e,e=void 0),e=e||"",t!=null)return Rt(e,t,n,"month");var s,a=[];for(s=0;s<12;s++)a[s]=Rt(e,s,n,"month");return a}function Rn(e,t,n,s){typeof e=="boolean"?(ge(t)&&(n=t,t=void 0),t=t||""):(t=e,n=t,e=!1,ge(t)&&(n=t,t=void 0),t=t||"");var a=Ne(),o=e?a._week.dow:0,i,l=[];if(n!=null)return Rt(t,(n+o)%7,s,"day");for(i=0;i<7;i++)l[i]=Rt(t,(i+o)%7,s,"day");return l}function vc(e,t){return ya(e,t,"months")}function Nc(e,t){return ya(e,t,"monthsShort")}function Cc(e,t,n){return Rn(e,t,n,"weekdays")}function Mc(e,t,n){return Rn(e,t,n,"weekdaysShort")}function Sc(e,t,n){return Rn(e,t,n,"weekdaysMin")}Ie("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10,n=x(e%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return e+n}}),_.lang=ae("moment.lang is deprecated. Use moment.locale instead.",Ie),_.langData=ae("moment.langData is deprecated. Use moment.localeData instead.",Ne);var Ce=Math.abs;function Oc(){var e=this._data;return this._milliseconds=Ce(this._milliseconds),this._days=Ce(this._days),this._months=Ce(this._months),e.milliseconds=Ce(e.milliseconds),e.seconds=Ce(e.seconds),e.minutes=Ce(e.minutes),e.hours=Ce(e.hours),e.months=Ce(e.months),e.years=Ce(e.years),this}function ga(e,t,n,s){var a=ce(t,n);return e._milliseconds+=s*a._milliseconds,e._days+=s*a._days,e._months+=s*a._months,e._bubble()}function Ec(e,t){return ga(this,e,t,1)}function Tc(e,t){return ga(this,e,t,-1)}function ka(e){return e<0?Math.floor(e):Math.ceil(e)}function Ic(){var e=this._milliseconds,t=this._days,n=this._months,s=this._data,a,o,i,l,d;return e>=0&&t>=0&&n>=0||e<=0&&t<=0&&n<=0||(e+=ka(Pn(n)+t)*864e5,t=0,n=0),s.milliseconds=e%1e3,a=oe(e/1e3),s.seconds=a%60,o=oe(a/60),s.minutes=o%60,i=oe(o/60),s.hours=i%24,t+=oe(i/24),d=oe(ba(t)),n+=d,t-=ka(Pn(d)),l=oe(n/12),n%=12,s.days=t,s.months=n,s.years=l,this}function ba(e){return e*4800/146097}function Pn(e){return e*146097/4800}function Dc(e){if(!this.isValid())return NaN;var t,n,s=this._milliseconds;if(e=re(e),e==="month"||e==="quarter"||e==="year")switch(t=this._days+s/864e5,n=this._months+ba(t),e){case"month":return n;case"quarter":return n/3;case"year":return n/12}else switch(t=this._days+Math.round(Pn(this._months)),e){case"week":return t/7+s/6048e5;case"day":return t+s/864e5;case"hour":return t*24+s/36e5;case"minute":return t*1440+s/6e4;case"second":return t*86400+s/1e3;case"millisecond":return Math.floor(t*864e5)+s;default:throw new Error("Unknown unit "+e)}}function Me(e){return function(){return this.as(e)}}var wa=Me("ms"),xc=Me("s"),Yc=Me("m"),Rc=Me("h"),Pc=Me("d"),Bc=Me("w"),Vc=Me("M"),Lc=Me("Q"),Ac=Me("y"),Uc=wa;function $c(){return ce(this)}function Wc(e){return e=re(e),this.isValid()?this[e+"s"]():NaN}function Be(e){return function(){return this.isValid()?this._data[e]:NaN}}var Hc=Be("milliseconds"),Fc=Be("seconds"),Gc=Be("minutes"),jc=Be("hours"),zc=Be("days"),Zc=Be("months"),qc=Be("years");function Kc(){return oe(this.days()/7)}var Se=Math.round,ze={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Jc(e,t,n,s,a){return a.relativeTime(t||1,!!n,e,s)}function Xc(e,t,n,s){var a=ce(e).abs(),o=Se(a.as("s")),i=Se(a.as("m")),l=Se(a.as("h")),d=Se(a.as("d")),c=Se(a.as("M")),f=Se(a.as("w")),w=Se(a.as("y")),m=o<=n.ss&&["s",o]||o<n.s&&["ss",o]||i<=1&&["m"]||i<n.m&&["mm",i]||l<=1&&["h"]||l<n.h&&["hh",l]||d<=1&&["d"]||d<n.d&&["dd",d];return n.w!=null&&(m=m||f<=1&&["w"]||f<n.w&&["ww",f]),m=m||c<=1&&["M"]||c<n.M&&["MM",c]||w<=1&&["y"]||["yy",w],m[2]=t,m[3]=+e>0,m[4]=s,Jc.apply(null,m)}function Qc(e){return e===void 0?Se:typeof e=="function"?(Se=e,!0):!1}function eu(e,t){return ze[e]===void 0?!1:t===void 0?ze[e]:(ze[e]=t,e==="s"&&(ze.ss=t-1),!0)}function tu(e,t){if(!this.isValid())return this.localeData().invalidDate();var n=!1,s=ze,a,o;return typeof e=="object"&&(t=e,e=!1),typeof e=="boolean"&&(n=e),typeof t=="object"&&(s=Object.assign({},ze,t),t.s!=null&&t.ss==null&&(s.ss=t.s-1)),a=this.localeData(),o=Xc(this,!n,s,a),n&&(o=a.pastFuture(+this,o)),a.postformat(o)}var Bn=Math.abs;function Ze(e){return(e>0)-(e<0)||+e}function Pt(){if(!this.isValid())return this.localeData().invalidDate();var e=Bn(this._milliseconds)/1e3,t=Bn(this._days),n=Bn(this._months),s,a,o,i,l=this.asSeconds(),d,c,f,w;return l?(s=oe(e/60),a=oe(s/60),e%=60,s%=60,o=oe(n/12),n%=12,i=e?e.toFixed(3).replace(/\.?0+$/,""):"",d=l<0?"-":"",c=Ze(this._months)!==Ze(l)?"-":"",f=Ze(this._days)!==Ze(l)?"-":"",w=Ze(this._milliseconds)!==Ze(l)?"-":"",d+"P"+(o?c+o+"Y":"")+(n?c+n+"M":"")+(t?f+t+"D":"")+(a||s||e?"T":"")+(a?w+a+"H":"")+(s?w+s+"M":"")+(e?w+i+"S":"")):"P0D"}var Y=Et.prototype;Y.isValid=Zl,Y.abs=Oc,Y.add=Ec,Y.subtract=Tc,Y.as=Dc,Y.asMilliseconds=wa,Y.asSeconds=xc,Y.asMinutes=Yc,Y.asHours=Rc,Y.asDays=Pc,Y.asWeeks=Bc,Y.asMonths=Vc,Y.asQuarters=Lc,Y.asYears=Ac,Y.valueOf=Uc,Y._bubble=Ic,Y.clone=$c,Y.get=Wc,Y.milliseconds=Hc,Y.seconds=Fc,Y.minutes=Gc,Y.hours=jc,Y.days=zc,Y.weeks=Kc,Y.months=Zc,Y.years=qc,Y.humanize=tu,Y.toISOString=Pt,Y.toString=Pt,Y.toJSON=Pt,Y.locale=ia,Y.localeData=da,Y.toIsoString=ae("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Pt),Y.lang=la,C("X",0,0,"unix"),C("x",0,0,"valueOf"),y("x",wt),y("X",vi),L("X",function(e,t,n){n._d=new Date(parseFloat(e)*1e3)}),L("x",function(e,t,n){n._d=new Date(x(e))});_.version="2.30.1",ni(W),_.fn=u,_.min=Fl,_.max=Gl,_.now=jl,_.utc=fe,_.unix=bc,_.months=vc,_.isDate=Ke,_.locale=Ie,_.invalid=mt,_.duration=ce,_.isMoment=le,_.weekdays=Cc,_.parseZone=wc,_.localeData=Ne,_.isDuration=Tt,_.monthsShort=Nc,_.weekdaysMin=Sc,_.defineLocale=Nn,_.updateLocale=wl,_.locales=vl,_.weekdaysShort=Mc,_.normalizeUnits=re,_.relativeTimeRounding=Qc,_.relativeTimeThreshold=eu,_.calendarFormat=yd,_.prototype=u,_.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"};const nu="code-graph",su=(e,t="",n="json")=>{const s=document.createElement("a");s.setAttribute("href",`data:text/${n};charset=UTF-8,${encodeURIComponent(e)}`);const a=_().format("YYMMDD_HHMMSS");s.setAttribute("download",`${nu}_${a}_${t}.${n}`),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)},au=(e="json")=>{const t=document.createElement("input");return t.setAttribute("type","file"),t.setAttribute("id","fileElem"),t.setAttribute("multiple","true"),t.setAttribute("accept",`${e}/*`),t.style.display="none",document.body.appendChild(t),t.click(),t},Vn="CLEAR_ALL",Ln="DOWNLOAD_EDITOR_STATE",va="RUN_ENGINE",An="TOGGLE_MINIMAP",Un="TOGGLE_PALETTE",$n="UPLOAD_EDITOR_STATE",Na=(e,t,n)=>{const s=n.zoomToFit.paddingLeft;t.registerCommand(Vn,{execute:()=>{t.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),t.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.value.clear(),e.value.editor.code.clear()},canExecute:()=>e.value.nodes.length>0}),t.registerCommand(Ln,{execute:()=>{const a=e.value.editor.save();su(JSON.stringify(a,null,2),e.value.shortId)},canExecute:()=>e.value.nodes.length>0}),t.registerCommand(An,{execute:()=>n.enableMinimap=!n.enableMinimap,canExecute:()=>e.value.nodes.length>1}),t.registerCommand(Un,{execute:()=>{n.palette.enabled=!n.palette.enabled,n.zoomToFit.paddingLeft=n.palette.enabled?s:50},canExecute:()=>!0}),t.registerCommand($n,{execute:()=>{const a=au();a.addEventListener("change",()=>{document.body.removeChild(a);const o=a.files;if(!o||o.length<=0)return!1;const i=new FileReader;i.onload=l=>{if(l.target?.result){const d=l.target.result;if(d.length===0)return;const c=JSON.parse(d);e.value.editor.load(c),e.value.code?.engine?.runOnce(null)}},i.readAsText(o.item(0))})},canExecute:()=>!0})},Ca=e=>{const t={command:Vn,title:"Clear all",icon:r.computed(()=>rs)},n={command:Ln,title:"Download editor state",icon:r.computed(()=>ns)},s={command:An,title:"Toggle minimap",icon:r.computed(()=>e.enableMinimap?is:os)},a={command:Un,title:"Toggle palette",icon:r.computed(()=>e.palette.enabled?ss:$t)},o={command:$n,title:"Upload editor state",icon:r.computed(()=>ds)};e.toolbar.commands=[a,t,o,n,...S.DEFAULT_TOOLBAR_COMMANDS,s]},Ma=(e,t,n)=>{n.registerCommand(va,{execute:()=>t.runOnce(null),canExecute:()=>e.nodes.length>0})};function Sa(e){const t=Symbol("CodeEngineToken");e.engine=new Cs(e.editor),Ma(e.editor.graph,e.engine,e.commandHandler),e.loadEditor=n=>{e.engine?.pause(),e.displayedGraph.clear(),e.editor.load(n),e.commandHandler.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),e.commandHandler.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.engine?.resume(),e.engine?.runOnce(null)},e.newGraph=()=>{e.engine?.pause(),e.displayedGraph.clear(),e.commandHandler.executeCommand(S.Commands.CLEAR_CLIPBOARD_COMMAND),e.commandHandler.executeCommand(S.Commands.CLEAR_HISTORY_COMMAND),e.displayedGraph.id=xe.v4(),e.engine?.resume(),e.engine?.runOnce(null)},e.subscribe=()=>{e.displayedGraph.nodeEvents.titleChanged.subscribe(t,()=>{e.engine?.runOnce(null)}),e.displayedGraph.events.addConnection.subscribe(t,n=>{const s=e.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onConnected();const a=e.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onConnected()}),e.displayedGraph.events.removeConnection.subscribe(t,n=>{const s=e.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onUnconnected();const a=e.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onUnconnected()}),e.engine?.events.beforeRun.subscribe(t,()=>{e.displayedGraph.onUpdate(),e.engine?.pause(),e.displayedGraph.sortNodes(),e.engine?.resume()}),e.engine?.events.afterRun.subscribe(t,n=>{e.engine?.pause(),he.applyResult(n,e.editor),e.code.state.lockCode||e.code.renderCode({nodes:e.editor.graph.scriptedCodeNodes,modules:e.editor.code.modules}),e.engine?.resume()})},e.unsubscribe=()=>{e.displayedGraph.events.addConnection.unsubscribe(t),e.displayedGraph.events.removeConnection.unsubscribe(t),e.engine?.events.beforeRun.unsubscribe(t),e.engine?.events.afterRun.unsubscribe(t)}}const Bt=350;class it extends q.Graph{code=null;editor;_state=r.reactive({codeTemplate:"{{ #nodes }}{{ script }}{{ /nodes }}",lockCode:!1});constructor(t,n){super(t,n),this.editor=t,this.template=n,t.code&&(this.code=t.code)}get codeNodes(){return Wn(this)}get connections(){return super.connections}set connections(t){this._connections=t}get nodeIds(){return this.nodes.map(t=>t.id)}get nodes(){return super.nodes}set nodes(t){this._nodes=t}get scriptedCodeNodes(){return this.nodes.filter(t=>!t.state?.integrated)}get selectedNodeIds(){return this.selectedNodes.map(t=>t.id)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get visibleNodes(){return this.nodes.filter(t=>!t.state?.hidden)}addNode(t,n){return t.state&&n&&(t.state.props=n),super.addNode(t)}addNodeAtCoordinates=(t,n={x:0,y:0},s)=>(this.addNode(t,s),t.position&&(t.position=n),t);addConnection(t,n){t&&t?.name!=="_code"&&(t.hidden=!1),n&&n?.name!=="_code"&&(n.hidden=!1),super.addConnection(t,n)}clear(){this.selectedNodes=[],this._nodes=[],this._connections=[]}findNodeByType(t){return this.nodes.find(n=>n.type===t)}getNodesByType(t){return this.nodes.filter(n=>n.type===t)}getNodesByVariableName(t){return this.nodes.filter(n=>[n.state.variableName,n._variableName].includes(t))}hasConnection(t,n){return this.connections.some(s=>s.from.id===t.id&&s.to.id===n.id)}load(t){const n=super.load(t);return this.nodes.forEach(s=>s.afterGraphLoaded()),n}onUpdate(){this.nodes.forEach(t=>t.onGraphUpdate())}renderCode(t){return Le.render(this.state?.codeTemplate||"",t)}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{let t=this.nodeIds;const n=this.connections.filter(o=>t.includes(o.to.nodeId)&&t.includes(o.from.nodeId)).map(o=>[o.to.nodeId,o.from.nodeId]);t.reverse(),t=Ra.array(t,n),t.reverse();const s=this.nodes.map(o=>o.id).filter(o=>!t.includes(o));t=[...t,...s];const a=t.map(o=>this.findNodeById(o));a&&(this.nodes=a)}catch{console.warn("Failed to sort nodes.")}}}const Wn=e=>{const t=[];return e.nodes.length===0||e.nodes.forEach(n=>{n&&(n.hasOwnProperty("subgraph")?t.push(...Wn(n.subgraph)):n.hasOwnProperty("isCodeNode")&&t.push(n))}),t},ru=(e=0,t=100)=>({x:e*(Bt+70),y:t}),ou=e=>{const t={...e.position};return t.x-=Bt+70,t.y+=50,t},Hn="__baklava_SubgraphInputNode",Fn="__baklava_SubgraphOutputNode";class Oa extends ht{graphInterfaceId;constructor(){super(),this.graphInterfaceId=xe.v4()}onPlaced(){super.onPlaced(),this.initializeIo()}load(t){super.load(t),this.graphInterfaceId=t.graphInterfaceId}save(){return{...super.save(),graphInterfaceId:this.graphInterfaceId}}update(){}}class Gn extends Oa{static isGraphInputNode(t){return t.type===Hn}type=Hn;inputs={name:new q.NodeInterface("Name","Input")};outputs={placeholder:new q.NodeInterface("Value",void 0)}}class jn extends Oa{static isGraphOutputNode(t){return t.type===Fn}type=Fn;inputs={name:new q.NodeInterface("Name","Output"),placeholder:new q.NodeInterface("Value",void 0)};outputs={output:new q.NodeInterface("Output",void 0).setHidden(!0)};calculate=({placeholder:t})=>({output:t})}const iu=["component","connectionCount","events","hidden","hooks","id","isCodeNode","isInput","name","nodeId","port","templateId","value"];function Ea(e){return class extends zt{type=q.getGraphNodeTypeString(e);get title(){return this._title}set title(n){this.template.name=n}inputs={};outputs={};template=e;subgraph;update(){}onConnected(){}onUnconnected(){}calculate=async(n,s)=>{if(!this.subgraph)throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);if(!s.engine||typeof s.engine!="object")throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);const a=s.engine.getInputValues(this.subgraph);for(const l of this.subgraph.inputs)a.set(l.nodeInterfaceId,n[l.id]);const o=await s.engine.runGraph(this.subgraph,a,s.globalValues);s.engine.pause(),he.applyResult(o,s.engine.editor),s.engine.resume();const i={};for(const l of this.subgraph.outputs)i[l.id]=o.get(l.nodeId)?.get("output");return i._calculationResults=o,this.lockCode||(i._code=this.renderCode({inputs:n,...s.globalValues})),this.updateOutputValues(i),i};load(n){if(!this.subgraph)throw new Error("Cannot load a graph node without a graph");if(!this.template)throw new Error("Unable to load graph node without graph template");this.subgraph.load(n.graphState),super.load(n)}save(){if(!this.subgraph)throw new Error("Cannot save a graph node without a graph");return{...super.save(),graphState:this.subgraph.save()}}onPlaced(){this.template.events.updated.subscribe(this,()=>this.initialize()),this.template.events.nameChanged.subscribe(this,n=>{this._title=n}),this.initialize()}onDestroy(){this.template.events.updated.unsubscribe(this),this.template.events.nameChanged.unsubscribe(this),this.subgraph?.destroy()}initialize(){this.subgraph&&this.subgraph.destroy(),this.subgraph=this.template.createGraph(),this._title=this.template.name,this.updateInterfaces(),this.state.codeTemplate=`{{ #nodes }}{{ script }}
7
7
  {{ /nodes }}`,this.events.update.emit(null)}renderCode(n){return this.subgraph?this.subgraph.renderCode({nodes:this.subgraph.scriptedCodeNodes}):Le.render(this.state.codeTemplate,n)}updateInterfaces(){if(!this.subgraph)throw new Error("Trying to update interfaces without graph instance");for(const n of this.subgraph.inputs)n.id in this.inputs?this.inputs[n.id].name=n.name:this.addInput(n.id,this.createProxyInterface(n,!0));for(const n of Object.keys(this.inputs))this.subgraph.inputs.some(s=>s.id===n)||this.removeInput(n);for(const n of this.subgraph.outputs)n.id in this.outputs?this.outputs[n.id].name=n.name:this.addOutput(n.id,this.createProxyInterface(n,!1));for(const n of Object.keys(this.outputs))this.subgraph.outputs.some(s=>s.id===n)||this.removeOutput(n);this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_calculationResults",new q.NodeInterface("_calculationResults",void 0).setHidden(!0))}createProxyInterface(n,s){const a=new Q(n.name,void 0);return new Proxy(a,{get:(o,i)=>{if(iu.includes(i)||i in o||typeof i=="string"&&i.startsWith("__v_"))return Reflect.get(o,i);let l;s?l=this.subgraph?.nodes.find(w=>Gn.isGraphInputNode(w)&&w.graphInterfaceId===n.id)?.outputs.placeholder.id:l=this.subgraph?.nodes.find(w=>jn.isGraphOutputNode(w)&&w.graphInterfaceId===n.id)?.inputs.placeholder.id;const d=this.subgraph?.connections.find(f=>l===(s?f.from:f.to)?.id),c=s?d?.to:d?.from;if(c)return Reflect.get(c,i)}})}}}class lt extends q.GraphTemplate{static fromGraph(t,n){return new lt(t.save(),n)}constructor(t,n){super(t,n)}get shortId(){return this.id.slice(0,6)}createGraph(t){const n=new Map,s=m=>{const D=xe.v4();return n.set(m,D),D},a=m=>{const D=n.get(m);if(!D)throw new Error(`Unable to create graph from template: Could not map old id ${m} to new id`);return D},o=m=>Oo(m,D=>({id:s(D.id),templateId:D.id,value:D.value})),i=this.nodes.map(m=>({...m,id:s(m.id),inputs:o(m.inputs),outputs:o(m.outputs)})),l=this.connections.map(m=>({id:s(m.id),from:a(m.from),to:a(m.to)})),d=this.inputs.map(m=>({id:m.id,name:m.name,nodeId:a(m.nodeId),nodeInterfaceId:a(m.nodeInterfaceId)})),c=this.outputs.map(m=>({id:m.id,name:m.name,nodeId:a(m.nodeId),nodeInterfaceId:a(m.nodeInterfaceId)})),f={id:xe.v4(),nodes:i,connections:l,inputs:d,outputs:c};return t||(t=new it(this.editor)),t.load(f).forEach(m=>console.warn(m)),t.template=this,t}}const lu=e=>!(e instanceof it);function Ta(e,t){return{switchGraph:s=>{let a;if(lu(s))a=new it(e.value),s.createGraph(a);else{if(s!==e.value.graph)throw new Error("Can only switch using 'Graph' instance when it is the root graph. Otherwise a 'GraphTemplate' must be used.");a=s}t.value&&t.value!==e.value.graph&&t.value.destroy(),a.panning=a.panning??s.panning??{x:0,y:0},a.scaling=a.scaling??s.scaling??1,a.selectedNodes=a.selectedNodes??[],a.sidebar=a.sidebar??{visible:!1,nodeId:"",optionName:""},t.value=a,a.code?.engine?.runOnce(null)}}}class zn extends Gn{_title="Subgraph Input";inputs={_code:new Q("_code","").use(G.setType,se).setHidden(!0),name:new S.TextInputInterface("Name","Input").setPort(!1)};outputs={_code:new Q("_code","").use(G.setType,se).setHidden(!0),placeholder:new q.NodeInterface("Connection",void 0)}}class Zn extends jn{_title="Subgraph Output";inputs={_code:new Q("_code","").use(G.setType,se).setHidden(!0),name:new S.TextInputInterface("Name","Output").setPort(!1),placeholder:new q.NodeInterface("Connection",void 0)};outputs={_code:new Q("_code","").use(G.setType,se).setHidden(!0),output:new q.NodeInterface("Output",void 0).setHidden(!0)}}const Ia="CREATE_SUBGRAPH",Da=[q.GRAPH_INPUT_NODE_TYPE,q.GRAPH_OUTPUT_NODE_TYPE];function xa(e,t,n){const s=()=>e.value.selectedNodes.filter(o=>!Da.includes(o.type)).length>0,a=()=>{const{viewModel:o}=S.useViewModel(),i=e.value,l=e.value.editor;if(i.selectedNodes.length===0)return;const d=i.selectedNodes.filter(O=>!Da.includes(O.type)),c=d.flatMap(O=>Object.values(O.inputs)),f=d.flatMap(O=>Object.values(O.outputs)),w=i.connections.filter(O=>!f.includes(O.from)&&c.includes(O.to)),m=i.connections.filter(O=>f.includes(O.from)&&!c.includes(O.to)),D=i.connections.filter(O=>f.includes(O.from)&&c.includes(O.to)),g=d.map(O=>O.save()),M=D.map(O=>({id:O.id,from:O.from.id,to:O.to.id})),h=new Map,{xLeft:k,xRight:A,yTop:V}=du(d);for(const[O,J]of w.entries()){const te=new zn;te.inputs.name.value=J.to.name,g.push({...te.save(),position:{x:A-o.value.settings.nodes.defaultWidth-100,y:V+O*200}}),M.push({id:xe.v4(),from:te.outputs.placeholder.id,to:J.to.id}),h.set(J.to.id,te.graphInterfaceId)}for(const[O,J]of m.entries()){const te=new Zn;te.inputs.name.value=J.from.name,g.push({...te.save(),position:{x:k+100,y:V+O*200}}),M.push({id:xe.v4(),from:J.from.id,to:te.inputs.placeholder.id}),h.set(J.from.id,te.graphInterfaceId)}const H=r.reactive(new lt({connections:M,nodes:g,inputs:[],outputs:[]},l));l.addGraphTemplate(H);const Oe=l.nodeTypes.get(q.getGraphNodeTypeString(H));if(!Oe)throw new Error("Unable to create subgraph: Could not find corresponding graph node type");i.activeTransactions++;const Ee=r.reactive(new Oe.type);i.addNode(Ee);const dt=Math.round(d.map(O=>O.position.x).reduce((O,J)=>O+J,0)/d.length),ye=Math.round(d.map(O=>O.position.y).reduce((O,J)=>O+J,0)/d.length);Ee.position.x=dt,Ee.position.y=ye,w.forEach(O=>{i.removeConnection(O),i.addConnection(O.from,Ee.inputs[h.get(O.to.id)])}),m.forEach(O=>{i.removeConnection(O),i.addConnection(Ee.outputs[h.get(O.from.id)],O.to)}),d.forEach(O=>i.removeNode(O)),i.activeTransactions--,t.canExecuteCommand(S.Commands.SAVE_SUBGRAPH_COMMAND)&&t.executeCommand(S.Commands.SAVE_SUBGRAPH_COMMAND),n(H),e.value.panning={...i.panning},e.value.scaling=i.scaling};t.registerCommand(Ia,{canExecute:s,execute:a})}function du(e){const t=e.reduce((a,o)=>{const i=o.position.x;return i<a?i:a},1/0),n=e.reduce((a,o)=>{const i=o.position.y;return i<a?i:a},1/0);return{xLeft:e.reduce((a,o)=>{const i=o.position.x+o.width;return i>a?i:a},-1/0),xRight:t,yTop:n}}class cu extends q.Editor{code;graph;constructor(t){super(),this.code=t,this.graph=new it(this)}get graphIds(){const t=[];return this.graphs.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}get graphTemplateIds(){const t=[];return this.graphTemplates.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}addGraphTemplate(t){if(this.events.beforeAddGraphTemplate.emit(t).prevented)return;this._graphTemplates.push(t),this.graphTemplateEvents.addTarget(t.events),this.graphTemplateHooks.addTarget(t.hooks);const n=Ea(t);this.registerNodeType(n,{category:"Subgraphs",title:t.name}),this.events.addGraphTemplate.emit(t)}load(t){try{for(super._loading=!0,t=this.hooks.load.execute(t);this.graphTemplates.length>0;)this.removeGraphTemplate(this.graphTemplates[0]);t.graphTemplates.forEach(s=>{const a=new lt(s,this);this.addGraphTemplate(a)});const n=this.graph.load(t.graph);return this.events.loaded.emit(),n.forEach(s=>console.warn(s)),n}finally{super._loading=!1}}registerCategoryModule(t,n){this.code.state.modules[t]=n}}function uu(e){const t=r.ref(e?.code??new pt),n=r.ref(e?.existingEditor??new cu(t.value)),s=Symbol("ViewModelToken"),a=r.ref(null),o=r.shallowReadonly(a),{switchGraph:i}=Ta(n,a),l=r.computed(()=>o.value&&o.value!==n.value.graph),d=r.reactive(S.DEFAULT_SETTINGS());d.nodes.defaultWidth=Bt;const c=S.useCommandHandler(),f=S.useHistory(o,c),w=S.useClipboard(o,n,c),m={renderNode:new Jn.SequentialHook(null),renderInterface:new Jn.SequentialHook(null)},D=r.reactive({clipboard:w,code:t,commandHandler:c,displayedGraph:o,editor:n,history:f,hooks:m,isReady:!1,isSubgraph:l,onBeforeUnmount:()=>{},onMounted:()=>{},settings:d,switchGraph:i});return t.value.registerViewModel(D),Sa(D),S.registerDeleteNodesCommand(o,c),xa(o,c,i),S.registerSaveSubgraphCommand(o,c),S.registerSwitchToMainGraphCommand(o,c,i),S.registerSidebarCommands(o,c),S.registerZoomToFitCommands(o,c,d),Na(o,c,d),Ca(d),r.watch(n,(g,M)=>{M&&(M.events.registerGraph.unsubscribe(s),M.graphEvents.beforeAddNode.unsubscribe(s),g.nodeHooks.beforeLoad.unsubscribe(s),g.nodeHooks.afterSave.unsubscribe(s),g.graphTemplateHooks.beforeLoad.unsubscribe(s),g.graphTemplateHooks.afterSave.unsubscribe(s),g.graph.hooks.load.unsubscribe(s),g.graph.hooks.save.unsubscribe(s)),g&&(g.nodeHooks.beforeLoad.subscribe(s,(h,k)=>(k.position=h.position??{x:0,y:0},k.state&&(k.state.integrated=h.integrated,h.props&&(k.state.props=h.props),h.variableName&&(k.state.variableName=h.variableName)),h)),g.nodeHooks.afterSave.subscribe(s,(h,k)=>(h.position=k.position,k.state&&(h.integrated=k.state.integrated,k.state.props&&(h.props=k.state.props),k.state.variableName&&(h.variableName=k.state.variableName)),h)),g.graphTemplateHooks.beforeLoad.subscribe(s,(h,k)=>(k.panning=h.panning,k.scaling=h.scaling,h)),g.graphTemplateHooks.afterSave.subscribe(s,(h,k)=>(h.panning=k.panning,h.scaling=k.scaling,h)),g.graph.hooks.load.subscribe(s,(h,k)=>(k.panning=h.panning,k.scaling=h.scaling,h)),g.graph.hooks.save.subscribe(s,(h,k)=>(h.panning=k.panning,h.scaling=k.scaling,h)),g.graphEvents.beforeAddNode.subscribe(s,h=>S.setViewNodeProperties(h,{defaultWidth:d.nodes.defaultWidth})),n.value.registerNodeType(zn,{category:"Subgraphs"}),n.value.registerNodeType(Zn,{category:"Subgraphs"}),i(g.graph))},{immediate:!0}),r.nextTick(()=>D.isReady=!0),D}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:`{{ #modules }}
8
8
  {{ . }}
9
9
  {{ /modules }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",