@babsey/code-graph 0.9.2 → 0.9.3

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.
@@ -1825,7 +1825,7 @@ class zs extends Ia {
1825
1825
  * Render code of this node.
1826
1826
  */
1827
1827
  renderCode(t) {
1828
- return Object.keys(t.inputs).filter((n) => Array.isArray(t.inputs[n])).forEach((n) => t.inputs[n] = `[${t.inputs[n].join(",")}]`), console.log(t.inputs), ut.render(this.state.codeTemplate, t);
1828
+ return Object.keys(t.inputs).filter((n) => Array.isArray(t.inputs[n])).forEach((n) => t.inputs[n] = `[${t.inputs[n].join(",")}]`), ut.render(this.state.codeTemplate, t);
1829
1829
  }
1830
1830
  /**
1831
1831
  * Update code templates.
@@ -2314,9 +2314,11 @@ class al extends $a {
2314
2314
  l[h] = this.getInterfaceValue(n, k.id);
2315
2315
  }), o.isCodeNode && (o.updateCodeTemplate(), o.updateOutputNames()), this.events.beforeNodeCalculation.emit({ inputValues: l, node: o });
2316
2316
  let u;
2317
- if (o.calculate)
2318
- u = await o.calculate(l, { globalValues: s, engine: this });
2319
- else {
2317
+ if (o.calculate) {
2318
+ if (u = await o.calculate(l, { globalValues: s, engine: this }), a.has(o))
2319
+ for (const [h, k] of Object.entries(u))
2320
+ this.hooks.transferData.execute(u[h], k);
2321
+ } else {
2320
2322
  u = {};
2321
2323
  for (const [h, k] of Object.entries(o.outputs))
2322
2324
  u[h] = this.getInterfaceValue(n, k.id);
@@ -1,4 +1,4 @@
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.title,w.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.title=m.value,o.value.events.titleChanged.emit(o.value.title),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:"Title",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.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.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:1,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:2},[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)],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&&(d.value.state.variableNameNumberAppendix=c.value.state.variableName.length===0,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{_variableName="";codeTemplate;isCodeNode=!0;mask=null;name="";state;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._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):""}set variableName(t){this._variableName=t}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 Object.keys(t.inputs).filter(n=>Array.isArray(t.inputs[n])).forEach(n=>t.inputs[n]=`[${t.inputs[n].join(",")}]`),console.log(t.inputs),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)c=await l.calculate(d,{globalValues:s,engine:this});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.title,w.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.title=m.value,o.value.events.titleChanged.emit(o.value.title),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:"Title",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.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.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:1,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:2},[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)],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&&(d.value.state.variableNameNumberAppendix=c.value.state.variableName.length===0,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{_variableName="";codeTemplate;isCodeNode=!0;mask=null;name="";state;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._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):""}set variableName(t){this._variableName=t}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 Object.keys(t.inputs).filter(n=>Array.isArray(t.inputs[n])).forEach(n=>t.inputs[n]=`[${t.inputs[n].join(",")}]`),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)}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+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",