@babsey/code-graph 0.0.10 → 0.0.12

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.
@@ -1,7 +1,7 @@
1
- import { AbstractNode as Le, NodeInterfaceType as P, BaklavaInterfaceTypes as Ge, NodeInterface as Ue, ButtonInterfaceComponent as je, CheckboxInterfaceComponent as Re, IntegerInterfaceComponent as Pe, NumberInterfaceComponent as De, SelectInterfaceComponent as Ae, SliderInterfaceComponent as He, TextInputInterfaceComponent as ge, TextareaInputInterfaceComponent as Fe, setType as j, allowMultipleConnections as Y, IntegerInterface as We, TextInputInterface as Xe, displayInSidebar as Ye, sortTopologically as Je, useViewModel as F, useTemporaryConnection as qe, Components as ve, useGraph as K, GRAPH_NODE_TYPE_PREFIX as J, useTransform as Qe, useNodeCategories as Ze, BaklavaEditor as Ke, DEFAULT_TOOLBAR_COMMANDS as et, useBaklava as tt, DependencyEngine as st, applyResult as nt } from "baklavajs";
1
+ import { AbstractNode as Le, NodeInterface as Ge, ButtonInterfaceComponent as Ue, CheckboxInterfaceComponent as je, IntegerInterfaceComponent as Re, NumberInterfaceComponent as Pe, SelectInterfaceComponent as De, SliderInterfaceComponent as Ae, TextInputInterfaceComponent as ge, TextareaInputInterfaceComponent as He, NodeInterfaceType as P, BaklavaInterfaceTypes as Fe, setType as j, allowMultipleConnections as Y, IntegerInterface as We, TextInputInterface as Xe, displayInSidebar as Ye, sortTopologically as Je, useViewModel as F, useTemporaryConnection as qe, Components as ve, useGraph as K, GRAPH_NODE_TYPE_PREFIX as J, useTransform as Qe, useNodeCategories as Ze, BaklavaEditor as Ke, DEFAULT_TOOLBAR_COMMANDS as et, useBaklava as tt, DependencyEngine as st, applyResult as nt } from "baklavajs";
2
2
  import { ButtonInterfaceComponent as cn, CheckboxInterfaceComponent as pn, IntegerInterfaceComponent as hn, NumberInterfaceComponent as vn, SelectInterfaceComponent as mn, SliderInterfaceComponent as fn, TextInputInterfaceComponent as gn, TextareaInputInterfaceComponent as bn } from "baklavajs";
3
3
  import be from "mustache";
4
- import { reactive as R, defineComponent as G, createElementBlock as r, openBlock as i, toDisplayString as L, markRaw as $, ref as E, computed as f, onMounted as ee, onUpdated as _e, normalizeClass as U, createCommentVNode as N, createElementVNode as l, unref as _, renderSlot as q, createStaticVNode as te, onBeforeUnmount as ot, normalizeStyle as se, withModifiers as D, createBlock as V, withDirectives as ne, Fragment as T, createTextVNode as at, createVNode as S, withKeys as Q, vModelText as oe, renderList as A, nextTick as it, toRef as ye, resolveDynamicComponent as rt, inject as lt, Transition as dt, withCtx as X, onUnmounted as ut, normalizeProps as ct, guardReactiveProps as pt, mergeProps as ht } from "vue";
4
+ import { reactive as R, defineComponent as G, createElementBlock as l, openBlock as i, toDisplayString as L, markRaw as T, ref as $, computed as f, onMounted as ee, onUpdated as _e, normalizeClass as U, createCommentVNode as N, createElementVNode as r, unref as _, renderSlot as q, createStaticVNode as te, onBeforeUnmount as ot, normalizeStyle as se, withModifiers as D, createBlock as V, withDirectives as ne, Fragment as E, createTextVNode as at, createVNode as S, withKeys as Q, vModelText as oe, renderList as A, nextTick as it, toRef as ye, resolveDynamicComponent as lt, inject as rt, Transition as dt, withCtx as X, onUnmounted as ut, normalizeProps as ct, guardReactiveProps as pt, mergeProps as ht } from "vue";
5
5
  import vt from "toposort";
6
6
  import { v4 as mt } from "uuid";
7
7
  import { usePointer as ft } from "@vueuse/core";
@@ -9,6 +9,7 @@ class gt extends Le {
9
9
  state;
10
10
  code;
11
11
  isCodeNode = !0;
12
+ codeTemplate = () => "";
12
13
  inputs = {};
13
14
  outputs = {};
14
15
  constructor() {
@@ -21,9 +22,6 @@ class gt extends Le {
21
22
  variableName: ""
22
23
  });
23
24
  }
24
- get codeTemplate() {
25
- return this.state.codeTemplate;
26
- }
27
25
  get idx() {
28
26
  return this.code?.codeNodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
29
27
  }
@@ -63,6 +61,7 @@ class gt extends Le {
63
61
  * Render code of this node.
64
62
  */
65
63
  renderCode() {
64
+ this.state.codeTemplate = this.codeTemplate.call(this);
66
65
  const e = {};
67
66
  Object.keys(this.inputs).forEach((s) => {
68
67
  if (s === "_node") return;
@@ -125,25 +124,23 @@ const xe = (o, e) => {
125
124
  }), Object.entries(e.outputs).forEach(([n, a]) => {
126
125
  n !== "_node" && s.outputs[n] && (a.hidden = s.outputs[n].hidden);
127
126
  });
128
- }, _t = new P("boolean"), yt = new P("dict"), wt = new P("list"), H = new P("node"), ke = new P("number"), Ce = new P("string"), Fs = (o) => {
129
- new Ge(o.editor, { viewPlugin: o }).addTypes(Ce, H, ke, _t, yt, wt);
130
- }, xt = ["title"], ae = /* @__PURE__ */ G({
127
+ }, _t = ["title"], ae = /* @__PURE__ */ G({
131
128
  __name: "CodeNodeInterface",
132
129
  props: {
133
130
  intf: {}
134
131
  },
135
132
  setup(o) {
136
- return (e, t) => (i(), r("div", {
133
+ return (e, t) => (i(), l("div", {
137
134
  title: e.intf.state?.script
138
- }, L(e.intf.name), 9, xt));
135
+ }, L(e.intf.name), 9, _t));
139
136
  }
140
137
  });
141
- class M extends Ue {
138
+ class M extends Ge {
142
139
  optional = !1;
143
140
  code;
144
141
  state;
145
142
  constructor(e, t) {
146
- super(e, t), this.setComponent($(ae)), this.state = R({
143
+ super(e, t), this.setComponent(T(ae)), this.state = R({
147
144
  script: ""
148
145
  });
149
146
  }
@@ -158,15 +155,15 @@ class M extends Ue {
158
155
  // if (this.name !== '_node') this.setHidden(false);
159
156
  // }
160
157
  }
161
- class Ws extends M {
162
- component = $(je);
158
+ class Fs extends M {
159
+ component = T(Ue);
163
160
  callback;
164
161
  constructor(e, t) {
165
162
  super(e, void 0), this.callback = t, this.setPort(!1);
166
163
  }
167
164
  }
168
- class Xs extends M {
169
- component = $(Re);
165
+ class Ws extends M {
166
+ component = T(je);
170
167
  }
171
168
  class ie extends M {
172
169
  min;
@@ -178,22 +175,22 @@ class ie extends M {
178
175
  return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
179
176
  }
180
177
  }
181
- class Ys extends ie {
182
- component = $(Pe);
178
+ class Xs extends ie {
179
+ component = T(Re);
183
180
  validate(e) {
184
181
  return Number.isInteger(e) && super.validate(e);
185
182
  }
186
183
  }
187
- class Js extends M {
184
+ class Ys extends M {
188
185
  isCodeInput = !0;
189
186
  constructor(e = "", t) {
190
- super(e, t), this.setComponent($(ae));
187
+ super(e, t), this.setComponent(T(ae));
191
188
  }
192
189
  }
193
- class kt extends M {
190
+ class yt extends M {
194
191
  isCodeOutput = !0;
195
192
  constructor(e = "", t = "") {
196
- super(e, t), this.setComponent($(ae));
193
+ super(e, t), this.setComponent(T(ae));
197
194
  }
198
195
  get script() {
199
196
  return this.state.script;
@@ -205,44 +202,47 @@ class kt extends M {
205
202
  super.value = e, this.state.script = this.name.length > 0 ? this.name : this.value;
206
203
  }
207
204
  }
208
- class qs extends ie {
209
- component = $(De);
205
+ class Js extends ie {
206
+ component = T(Pe);
210
207
  }
211
- class Qs extends M {
212
- component = $(Ae);
208
+ class qs extends M {
209
+ component = T(De);
213
210
  items;
214
211
  constructor(e, t, s) {
215
212
  super(e, t), this.items = s;
216
213
  }
217
214
  }
218
- class Zs extends ie {
219
- component = $(He);
215
+ class Qs extends ie {
216
+ component = T(Ae);
220
217
  min;
221
218
  max;
222
219
  constructor(e, t, s, n) {
223
220
  super(e, t, s, n), this.min = s, this.max = n;
224
221
  }
225
222
  }
226
- class Ks extends M {
227
- component = $(ge);
223
+ class Zs extends M {
224
+ component = T(ge);
228
225
  constructor(e, t) {
229
226
  super(e, t), this.setPort(!1);
230
227
  }
231
228
  }
232
- class en extends M {
229
+ class Ks extends M {
233
230
  isString = !0;
234
- component = $(ge);
231
+ component = T(ge);
235
232
  }
236
- class tn extends M {
237
- component = $(Fe);
233
+ class en extends M {
234
+ component = T(He);
238
235
  }
236
+ const wt = new P("boolean"), xt = new P("dict"), kt = new P("list"), H = new P("node"), ke = new P("number"), Ce = new P("string"), tn = (o) => {
237
+ new Fe(o.editor, { viewPlugin: o }).addTypes(Ce, H, ke, wt, xt, kt);
238
+ };
239
239
  function sn(o) {
240
240
  return class extends we {
241
241
  type = o.type;
242
242
  inputs = {};
243
243
  outputs = {};
244
244
  constructor() {
245
- super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
245
+ super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.variableName && (this.state.variableName = o.variableName), o.codeTemplate && (this.codeTemplate = o.codeTemplate), this.addInput(
246
246
  "_node",
247
247
  new M("", []).use(j, H).use(Y).setHidden(!0)
248
248
  ), this.addOutput(
@@ -291,7 +291,7 @@ function nn(o) {
291
291
  staticInputKeys = Object.keys(o.inputs ?? {});
292
292
  staticOutputKeys = Object.keys(o.outputs ?? {});
293
293
  constructor() {
294
- super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
294
+ super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.codeTemplate = o.codeTemplate), o.variableName && (this.state.variableName = o.variableName), this.addInput(
295
295
  "_node",
296
296
  new M("", []).use(j, H).use(Y).setHidden(!0)
297
297
  ), this.addOutput(
@@ -332,7 +332,7 @@ function nn(o) {
332
332
  for (const t of Object.keys(e.outputs))
333
333
  if (!this.staticOutputKeys.includes(t)) {
334
334
  if (!this.outputs[t]) {
335
- const s = new kt(t);
335
+ const s = new yt(t);
336
336
  this.addOutput(t, s);
337
337
  }
338
338
  this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
@@ -595,7 +595,7 @@ const Z = (o) => {
595
595
  intf: {}
596
596
  },
597
597
  setup(o) {
598
- const e = o, { viewModel: t } = F(), { hoveredOver: s, temporaryConnection: n } = qe(), a = E(null), u = f(() => e.intf.connectionCount > 0), d = f(() => ({
598
+ const e = o, { viewModel: t } = F(), { hoveredOver: s, temporaryConnection: n } = qe(), a = $(null), u = f(() => e.intf.connectionCount > 0), d = f(() => ({
599
599
  "--connected": u.value
600
600
  })), h = () => {
601
601
  s(e.intf);
@@ -604,19 +604,19 @@ const Z = (o) => {
604
604
  }, x = () => {
605
605
  a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
606
606
  };
607
- return ee(x), _e(x), (k, B) => (i(), r("div", {
607
+ return ee(x), _e(x), (k, B) => (i(), l("div", {
608
608
  id: k.intf.id,
609
609
  ref_key: "el",
610
610
  ref: a,
611
611
  class: U(["baklava-node-interface", d.value])
612
612
  }, [
613
- k.intf.port ? (i(), r("div", {
613
+ k.intf.port ? (i(), l("div", {
614
614
  key: 0,
615
615
  class: U(["__port", { "--selected": _(n)?.from === k.intf }]),
616
616
  onPointerover: h,
617
617
  onPointerout: O
618
618
  }, null, 34)) : N("", !0),
619
- l("span", Ot, [
619
+ r("span", Ot, [
620
620
  q(k.$slots, "default")
621
621
  ])
622
622
  ], 10, Mt));
@@ -626,7 +626,7 @@ const Z = (o) => {
626
626
  for (const [s, n] of e)
627
627
  t[s] = n;
628
628
  return t;
629
- }, $t = {}, Et = {
629
+ }, Tt = {}, $t = {
630
630
  xmlns: "http://www.w3.org/2000/svg",
631
631
  width: "24",
632
632
  height: "24",
@@ -634,17 +634,17 @@ const Z = (o) => {
634
634
  fill: "currentColor",
635
635
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
636
636
  };
637
- function Tt(o, e) {
638
- return i(), r("svg", Et, [...e[0] || (e[0] = [
639
- l("path", {
637
+ function Et(o, e) {
638
+ return i(), l("svg", $t, [...e[0] || (e[0] = [
639
+ r("path", {
640
640
  stroke: "none",
641
641
  d: "M0 0h24v24H0z",
642
642
  fill: "none"
643
643
  }, null, -1),
644
- l("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)
644
+ r("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)
645
645
  ])]);
646
646
  }
647
- const St = /* @__PURE__ */ z($t, [["render", Tt]]), zt = {}, Bt = {
647
+ const St = /* @__PURE__ */ z(Tt, [["render", Et]]), zt = {}, Bt = {
648
648
  xmlns: "http://www.w3.org/2000/svg",
649
649
  width: "24",
650
650
  height: "24",
@@ -653,13 +653,13 @@ const St = /* @__PURE__ */ z($t, [["render", Tt]]), zt = {}, Bt = {
653
653
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
654
654
  };
655
655
  function Vt(o, e) {
656
- return i(), r("svg", Bt, [...e[0] || (e[0] = [
657
- l("path", {
656
+ return i(), l("svg", Bt, [...e[0] || (e[0] = [
657
+ r("path", {
658
658
  stroke: "none",
659
659
  d: "M0 0h24v24H0z",
660
660
  fill: "none"
661
661
  }, null, -1),
662
- l("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)
662
+ r("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)
663
663
  ])]);
664
664
  }
665
665
  const Lt = /* @__PURE__ */ z(zt, [["render", Vt]]), Gt = {}, Ut = {
@@ -671,13 +671,13 @@ const Lt = /* @__PURE__ */ z(zt, [["render", Vt]]), Gt = {}, Ut = {
671
671
  class: "balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
672
672
  };
673
673
  function jt(o, e) {
674
- return i(), r("svg", Ut, [...e[0] || (e[0] = [
675
- l("path", {
674
+ return i(), l("svg", Ut, [...e[0] || (e[0] = [
675
+ r("path", {
676
676
  stroke: "none",
677
677
  d: "M0 0h24v24H0z",
678
678
  fill: "none"
679
679
  }, null, -1),
680
- l("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)
680
+ r("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)
681
681
  ])]);
682
682
  }
683
683
  const Rt = /* @__PURE__ */ z(Gt, [["render", jt]]), Pt = {}, Dt = {
@@ -689,13 +689,13 @@ const Rt = /* @__PURE__ */ z(Gt, [["render", jt]]), Pt = {}, Dt = {
689
689
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
690
690
  };
691
691
  function At(o, e) {
692
- return i(), r("svg", Dt, [...e[0] || (e[0] = [
693
- l("path", {
692
+ return i(), l("svg", Dt, [...e[0] || (e[0] = [
693
+ r("path", {
694
694
  stroke: "none",
695
695
  d: "M0 0h24v24H0z",
696
696
  fill: "none"
697
697
  }, null, -1),
698
- l("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)
698
+ r("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)
699
699
  ])]);
700
700
  }
701
701
  const Ht = /* @__PURE__ */ z(Pt, [["render", At]]), Ft = {}, Wt = {
@@ -707,13 +707,13 @@ const Ht = /* @__PURE__ */ z(Pt, [["render", At]]), Ft = {}, Wt = {
707
707
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
708
708
  };
709
709
  function Xt(o, e) {
710
- return i(), r("svg", Wt, [...e[0] || (e[0] = [
711
- l("path", {
710
+ return i(), l("svg", Wt, [...e[0] || (e[0] = [
711
+ r("path", {
712
712
  stroke: "none",
713
713
  d: "M0 0h24v24H0z",
714
714
  fill: "none"
715
715
  }, null, -1),
716
- l("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)
716
+ r("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)
717
717
  ])]);
718
718
  }
719
719
  const Yt = /* @__PURE__ */ z(Ft, [["render", Xt]]), Jt = {}, qt = {
@@ -729,7 +729,7 @@ const Yt = /* @__PURE__ */ z(Ft, [["render", Xt]]), Jt = {}, qt = {
729
729
  "stroke-linejoin": "round"
730
730
  };
731
731
  function Qt(o, e) {
732
- return i(), r("svg", qt, [...e[0] || (e[0] = [
732
+ return i(), l("svg", qt, [...e[0] || (e[0] = [
733
733
  te('<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)
734
734
  ])]);
735
735
  }
@@ -746,7 +746,7 @@ const Zt = /* @__PURE__ */ z(Jt, [["render", Qt]]), Kt = {}, es = {
746
746
  "stroke-linejoin": "round"
747
747
  };
748
748
  function ts(o, e) {
749
- return i(), r("svg", es, [...e[0] || (e[0] = [
749
+ return i(), l("svg", es, [...e[0] || (e[0] = [
750
750
  te('<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)
751
751
  ])]);
752
752
  }
@@ -763,11 +763,11 @@ const ss = /* @__PURE__ */ z(Kt, [["render", ts]]), ns = {}, os = {
763
763
  "stroke-linejoin": "round"
764
764
  };
765
765
  function as(o, e) {
766
- return i(), r("svg", os, [...e[0] || (e[0] = [
766
+ return i(), l("svg", os, [...e[0] || (e[0] = [
767
767
  te('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
768
768
  ])]);
769
769
  }
770
- const is = /* @__PURE__ */ z(ns, [["render", as]]), rs = {}, ls = {
770
+ const is = /* @__PURE__ */ z(ns, [["render", as]]), ls = {}, rs = {
771
771
  xmlns: "http://www.w3.org/2000/svg",
772
772
  class: "baklava-icon",
773
773
  width: "16",
@@ -780,30 +780,30 @@ const is = /* @__PURE__ */ z(ns, [["render", as]]), rs = {}, ls = {
780
780
  "stroke-linejoin": "round"
781
781
  };
782
782
  function ds(o, e) {
783
- return i(), r("svg", ls, [...e[0] || (e[0] = [
784
- l("path", {
783
+ return i(), l("svg", rs, [...e[0] || (e[0] = [
784
+ r("path", {
785
785
  stroke: "none",
786
786
  d: "M0 0h24v24H0z",
787
787
  fill: "none"
788
788
  }, null, -1),
789
- l("circle", {
789
+ r("circle", {
790
790
  cx: "12",
791
791
  cy: "12",
792
792
  r: "1"
793
793
  }, null, -1),
794
- l("circle", {
794
+ r("circle", {
795
795
  cx: "12",
796
796
  cy: "19",
797
797
  r: "1"
798
798
  }, null, -1),
799
- l("circle", {
799
+ r("circle", {
800
800
  cx: "12",
801
801
  cy: "5",
802
802
  r: "1"
803
803
  }, null, -1)
804
804
  ])]);
805
805
  }
806
- const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"], ps = {
806
+ const us = /* @__PURE__ */ z(ls, [["render", ds]]), cs = ["id", "data-node-type"], ps = {
807
807
  class: "__title-label",
808
808
  style: { "flex-grow": "1" }
809
809
  }, hs = { key: 0 }, vs = {
@@ -818,9 +818,9 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
818
818
  },
819
819
  emits: ["select", "start-drag", "update"],
820
820
  setup(o, { emit: e }) {
821
- const t = ve.ContextMenu, s = ve.NodeInterface, n = o, a = f(() => n.node), u = e, { viewModel: d } = F(), { graph: h, switchGraph: O } = K(), x = E(null), k = E(!1), B = E(""), y = E(null), m = E(!1);
821
+ const t = ve.ContextMenu, s = ve.NodeInterface, n = o, a = f(() => n.node), u = e, { viewModel: d } = F(), { graph: h, switchGraph: O } = K(), x = $(null), k = $(!1), B = $(""), y = $(null), m = $(!1);
822
822
  let g = 0, b = 0;
823
- const p = E(!1), w = f(() => {
823
+ const p = $(!1), w = f(() => {
824
824
  const c = [
825
825
  { value: "edit", label: "Edit" },
826
826
  { value: "rename", label: "Rename" },
@@ -838,19 +838,19 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
838
838
  top: `${n.node.position?.y ?? 0}px`,
839
839
  left: `${n.node.position?.x ?? 0}px`,
840
840
  "--width": `${n.node.width ?? d.value.settings.nodes.defaultWidth}px`
841
- })), Me = f(() => Object.values(n.node.inputs).filter((c) => !c.hidden)), Oe = f(() => Object.values(n.node.outputs).filter((c) => !c.hidden)), re = () => {
841
+ })), Me = f(() => Object.values(n.node.inputs).filter((c) => !c.hidden)), Oe = f(() => Object.values(n.node.outputs).filter((c) => !c.hidden)), le = () => {
842
842
  u("select");
843
- }, $e = (c) => {
844
- n.selected || re(), u("start-drag", c);
845
- }, le = () => {
843
+ }, Te = (c) => {
844
+ n.selected || le(), u("start-drag", c);
845
+ }, re = () => {
846
846
  p.value = !0;
847
- }, Ee = () => {
847
+ }, $e = () => {
848
848
  const c = d.value.displayedGraph.sidebar;
849
849
  c.nodeId = "", c.visible = !1;
850
850
  }, de = () => {
851
851
  const c = d.value.displayedGraph.sidebar;
852
852
  c.nodeId = n.node.id, c.visible = !0;
853
- }, Te = () => {
853
+ }, Ee = () => {
854
854
  const c = d.value.displayedGraph.sidebar;
855
855
  c.nodeId = n.node.id;
856
856
  }, Se = async (c) => {
@@ -885,24 +885,24 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
885
885
  ce(), window.addEventListener("mousemove", pe), window.addEventListener("mouseup", he);
886
886
  }), _e(ce), ot(() => {
887
887
  window.removeEventListener("mousemove", pe), window.removeEventListener("mouseup", he);
888
- }), (c, C) => (i(), r("div", {
888
+ }), (c, C) => (i(), l("div", {
889
889
  id: a.value.id,
890
890
  ref_key: "el",
891
891
  ref: x,
892
892
  class: U([I.value, "baklava-node"]),
893
893
  "data-node-type": a.value.type,
894
894
  style: se(Ne.value),
895
- onPointerdown: re
895
+ onPointerdown: le
896
896
  }, [
897
- _(d).settings.nodes.resizable ? (i(), r("div", {
897
+ _(d).settings.nodes.resizable ? (i(), l("div", {
898
898
  key: 0,
899
899
  class: "__resize-handle",
900
900
  onMousedown: ze
901
901
  }, null, 32)) : N("", !0),
902
- l("div", {
902
+ r("div", {
903
903
  class: "__title",
904
- onPointerdown: D($e, ["self", "stop"]),
905
- onContextmenu: D(le, ["prevent"])
904
+ onPointerdown: D(Te, ["self", "stop"]),
905
+ onContextmenu: D(re, ["prevent"])
906
906
  }, [
907
907
  a.value.inputs._node ? (i(), V(me, {
908
908
  key: 0,
@@ -912,7 +912,7 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
912
912
  "data-interface-type": "node",
913
913
  style: { "flex-grow": "0" }
914
914
  }, null, 8, ["node", "intf"])) : N("", !0),
915
- k.value ? ne((i(), r("input", {
915
+ k.value ? ne((i(), l("input", {
916
916
  key: 2,
917
917
  ref_key: "renameInputEl",
918
918
  ref: y,
@@ -925,13 +925,13 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
925
925
  onKeydown: Q(ue, ["enter"])
926
926
  }, null, 544)), [
927
927
  [oe, B.value]
928
- ]) : (i(), r(T, { key: 1 }, [
929
- l("div", ps, [
930
- a.value.idx > -1 ? (i(), r("span", hs, L(a.value.idx + 1) + " - ", 1)) : N("", !0),
928
+ ]) : (i(), l(E, { key: 1 }, [
929
+ r("div", ps, [
930
+ a.value.idx > -1 ? (i(), l("span", hs, L(a.value.idx + 1) + " - ", 1)) : N("", !0),
931
931
  at(L(a.value.title) + " (" + L(a.value.shortId) + ") ", 1)
932
932
  ]),
933
- l("div", vs, [
934
- a.value.subgraph ? N("", !0) : (i(), r(T, { key: 0 }, [
933
+ r("div", vs, [
934
+ a.value.subgraph ? N("", !0) : (i(), l(E, { key: 0 }, [
935
935
  !_(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Yt), {
936
936
  key: 0,
937
937
  class: "--clickable mx-1",
@@ -939,16 +939,16 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
939
939
  })) : _(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Rt), {
940
940
  key: 1,
941
941
  class: "--clickable mx-1",
942
- onClick: Te
942
+ onClick: Ee
943
943
  })) : (i(), V(_(Ht), {
944
944
  key: 2,
945
945
  class: "--clickable mx-1",
946
- onClick: Ee
946
+ onClick: $e
947
947
  }))
948
948
  ], 64)),
949
949
  S(_(us), {
950
950
  class: "--clickable mx-1",
951
- onClick: le
951
+ onClick: re
952
952
  }),
953
953
  S(_(t), {
954
954
  modelValue: p.value,
@@ -968,25 +968,25 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
968
968
  "data-interface-type": "node"
969
969
  }, null, 8, ["node", "intf"])) : N("", !0)
970
970
  ], 32),
971
- l("div", {
971
+ r("div", {
972
972
  class: U(["__content", Ie.value]),
973
973
  onKeydown: C[2] || (C[2] = Q(D(() => {
974
974
  }, ["stop"]), ["delete"])),
975
975
  onContextmenu: C[3] || (C[3] = D(() => {
976
976
  }, ["prevent"]))
977
977
  }, [
978
- l("div", ms, [
979
- (i(!0), r(T, null, A(Oe.value, (v) => (i(), r(T, {
978
+ r("div", ms, [
979
+ (i(!0), l(E, null, A(Oe.value, (v) => (i(), l(E, {
980
980
  key: v.id
981
981
  }, [
982
- a.value.state?.hidden ? (i(), r("div", fs, [
983
- v.port ? (i(), r("div", {
982
+ a.value.state?.hidden ? (i(), l("div", fs, [
983
+ v.port ? (i(), l("div", {
984
984
  key: 0,
985
985
  id: v.id,
986
986
  title: v.name,
987
987
  class: "baklava-node-interface --output --connected"
988
988
  }, [...C[4] || (C[4] = [
989
- l("div", { class: "__port" }, null, -1)
989
+ r("div", { class: "__port" }, null, -1)
990
990
  ])], 8, gs)) : N("", !0)
991
991
  ])) : q(c.$slots, "nodeInterface", {
992
992
  key: 1,
@@ -1001,18 +1001,18 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1001
1001
  ])
1002
1002
  ], 64))), 128))
1003
1003
  ]),
1004
- l("div", bs, [
1005
- (i(!0), r(T, null, A(Me.value, (v) => (i(), r(T, {
1004
+ r("div", bs, [
1005
+ (i(!0), l(E, null, A(Me.value, (v) => (i(), l(E, {
1006
1006
  key: v.id
1007
1007
  }, [
1008
- a.value.state?.hidden ? (i(), r("div", _s, [
1009
- v.port ? (i(), r("div", {
1008
+ a.value.state?.hidden ? (i(), l("div", _s, [
1009
+ v.port ? (i(), l("div", {
1010
1010
  key: 0,
1011
1011
  id: v.id,
1012
1012
  title: v.name,
1013
1013
  class: "baklava-node-interface --input --connected"
1014
1014
  }, [...C[5] || (C[5] = [
1015
- l("div", { class: "__port" }, null, -1)
1015
+ r("div", { class: "__port" }, null, -1)
1016
1016
  ])], 8, ys)) : N("", !0)
1017
1017
  ])) : q(c.$slots, "nodeInterface", {
1018
1018
  key: 1,
@@ -1044,35 +1044,35 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1044
1044
  emits: ["update:modelValue"],
1045
1045
  setup(o, { emit: e }) {
1046
1046
  const t = e;
1047
- return (s, n) => (i(), r("div", {
1047
+ return (s, n) => (i(), l("div", {
1048
1048
  class: U(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue }]),
1049
1049
  title: s.name,
1050
1050
  onClick: n[0] || (n[0] = (a) => t("update:modelValue", !s.modelValue))
1051
1051
  }, [
1052
- n[1] || (n[1] = l("div", { class: "__checkmark-container" }, [
1053
- l("svg", {
1052
+ n[1] || (n[1] = r("div", { class: "__checkmark-container" }, [
1053
+ r("svg", {
1054
1054
  xmlns: "http://www.w3.org/2000/svg",
1055
1055
  width: "18",
1056
1056
  height: "18",
1057
1057
  viewBox: "0 0 18 18"
1058
1058
  }, [
1059
- l("path", {
1059
+ r("path", {
1060
1060
  class: "__checkmark",
1061
1061
  d: "M 6 5 L 6 10 L 16 10",
1062
1062
  transform: "rotate(-45 10 10)"
1063
1063
  })
1064
1064
  ])
1065
1065
  ], -1)),
1066
- s.name ? (i(), r("div", ks, L(s.name), 1)) : N("", !0)
1066
+ s.name ? (i(), l("div", ks, L(s.name), 1)) : N("", !0)
1067
1067
  ], 10, xs));
1068
1068
  }
1069
1069
  }), Is = { class: "__header" }, Ns = { class: "__node-name" }, Ms = { style: { display: "flex" } }, Os = {
1070
1070
  key: 1,
1071
1071
  class: "__interface"
1072
- }, $s = /* @__PURE__ */ G({
1072
+ }, Ts = /* @__PURE__ */ G({
1073
1073
  __name: "CodeGraphSidebar",
1074
1074
  setup(o) {
1075
- const { viewModel: e } = F(), { graph: t } = K(), s = E(null), n = ye(e.value.settings.sidebar, "width"), a = f(() => e.value.settings.sidebar.resizable);
1075
+ const { viewModel: e } = F(), { graph: t } = K(), s = $(null), n = ye(e.value.settings.sidebar, "width"), a = f(() => e.value.settings.sidebar.resizable);
1076
1076
  let u = 0, d = 0;
1077
1077
  const h = f(() => {
1078
1078
  const b = t.value.sidebar.nodeId;
@@ -1096,32 +1096,32 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1096
1096
  let I = u - w;
1097
1097
  I < 300 ? I = 300 : I > 0.9 * p && (I = 0.9 * p), n.value = I;
1098
1098
  };
1099
- return (b, p) => (i(), r("div", {
1099
+ return (b, p) => (i(), l("div", {
1100
1100
  ref_key: "el",
1101
1101
  ref: s,
1102
1102
  class: U(["baklava-sidebar", { "--open": _(t).sidebar.visible }]),
1103
1103
  style: se(x.value)
1104
1104
  }, [
1105
- a.value ? (i(), r("div", {
1105
+ a.value ? (i(), l("div", {
1106
1106
  key: 0,
1107
1107
  class: "__resizer",
1108
1108
  onMousedown: m
1109
1109
  }, null, 32)) : N("", !0),
1110
- l("div", Is, [
1111
- l("button", {
1110
+ r("div", Is, [
1111
+ r("button", {
1112
1112
  tabindex: "-1",
1113
1113
  class: "__close",
1114
1114
  onClick: B
1115
1115
  }, "×"),
1116
- l("div", Ns, [
1117
- l("b", null, L(h.value ? h.value.title : ""), 1)
1116
+ r("div", Ns, [
1117
+ r("b", null, L(h.value ? h.value.title : ""), 1)
1118
1118
  ])
1119
1119
  ]),
1120
- (i(!0), r(T, null, A(k.value, (w) => (i(), r("div", {
1120
+ (i(!0), l(E, null, A(k.value, (w) => (i(), l("div", {
1121
1121
  key: w.id,
1122
1122
  class: "__interface"
1123
1123
  }, [
1124
- l("div", Ms, [
1124
+ r("div", Ms, [
1125
1125
  S(Cs, {
1126
1126
  modelValue: w.hidden,
1127
1127
  "onUpdate:modelValue": [
@@ -1131,7 +1131,7 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1131
1131
  inversed: "",
1132
1132
  style: { "margin-right": "8px" }
1133
1133
  }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1134
- (i(), V(rt(w.component), {
1134
+ (i(), V(lt(w.component), {
1135
1135
  modelValue: w.value,
1136
1136
  "onUpdate:modelValue": (I) => w.value = I,
1137
1137
  node: h.value,
@@ -1140,9 +1140,9 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1140
1140
  }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1141
1141
  ])
1142
1142
  ]))), 128)),
1143
- O.value && O.value.state ? (i(), r("div", Os, [
1144
- p[2] || (p[2] = l("label", null, "Variable name", -1)),
1145
- ne(l("input", {
1143
+ O.value && O.value.state ? (i(), l("div", Os, [
1144
+ p[2] || (p[2] = r("label", null, "Variable name", -1)),
1145
+ ne(r("input", {
1146
1146
  "onUpdate:modelValue": p[1] || (p[1] = (w) => O.value.state.variableName = w),
1147
1147
  type: "text",
1148
1148
  class: "baklava-input",
@@ -1155,7 +1155,7 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1155
1155
  ])) : N("", !0)
1156
1156
  ], 6));
1157
1157
  }
1158
- }), Es = G({
1158
+ }), $s = G({
1159
1159
  props: {
1160
1160
  type: {
1161
1161
  type: String,
@@ -1167,7 +1167,7 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1167
1167
  }
1168
1168
  },
1169
1169
  setup(o) {
1170
- const { viewModel: e } = F(), { switchGraph: t } = K(), s = E(!1), n = f(() => o.type.startsWith(J));
1170
+ const { viewModel: e } = F(), { switchGraph: t } = K(), s = $(!1), n = f(() => o.type.startsWith(J));
1171
1171
  return { showContextMenu: s, hasContextMenu: n, contextMenuItems: [
1172
1172
  { label: "Edit Subgraph", value: "editSubgraph" },
1173
1173
  { label: "Delete Subgraph", value: "deleteSubgraph" }
@@ -1186,24 +1186,24 @@ const us = /* @__PURE__ */ z(rs, [["render", ds]]), cs = ["id", "data-node-type"
1186
1186
  }
1187
1187
  } };
1188
1188
  }
1189
- }), Ts = ["data-node-type"], Ss = { class: "__title" }, zs = { class: "__title-label" };
1189
+ }), Es = ["data-node-type"], Ss = { class: "__title" }, zs = { class: "__title-label" };
1190
1190
  function Bs(o, e, t, s, n, a) {
1191
- return i(), r("div", {
1191
+ return i(), l("div", {
1192
1192
  class: "baklava-node --palette",
1193
1193
  "data-node-type": o.type
1194
1194
  }, [
1195
- l("div", Ss, [
1196
- l("div", zs, L(o.title), 1)
1195
+ r("div", Ss, [
1196
+ r("div", zs, L(o.title), 1)
1197
1197
  ])
1198
- ], 8, Ts);
1198
+ ], 8, Es);
1199
1199
  }
1200
- const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1200
+ const fe = /* @__PURE__ */ z($s, [["render", Bs]]), Vs = {
1201
1201
  class: "baklava-node --palette",
1202
1202
  style: { "margin-top": "-20px", "margin-bottom": "30px" }
1203
1203
  }, Ls = { key: 0 }, Gs = /* @__PURE__ */ G({
1204
1204
  __name: "CodeNodePalette",
1205
1205
  setup(o) {
1206
- const { viewModel: e } = F(), { x: t, y: s } = ft(), { transform: n } = Qe(), a = Ze(e), u = lt("editorEl"), d = E(""), h = E(null), O = (y) => d.value ? y.filter(
1206
+ const { viewModel: e } = F(), { x: t, y: s } = ft(), { transform: n } = Qe(), a = Ze(e), u = rt("editorEl"), d = $(""), h = $(null), O = (y) => d.value ? y.filter(
1207
1207
  (m) => Object.values(m.nodeTypes).some(
1208
1208
  (g) => g.title.toLowerCase().includes(d.value?.toLowerCase())
1209
1209
  )
@@ -1229,14 +1229,14 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1229
1229
  };
1230
1230
  document.addEventListener("pointerup", g);
1231
1231
  };
1232
- return (y, m) => (i(), r(T, null, [
1233
- l("div", {
1232
+ return (y, m) => (i(), l(E, null, [
1233
+ r("div", {
1234
1234
  class: U(["baklava-node-palette", { "--open": _(e).settings.palette.enabled }]),
1235
1235
  onContextmenu: m[1] || (m[1] = D(() => {
1236
1236
  }, ["stop", "prevent"]))
1237
1237
  }, [
1238
- l("div", Vs, [
1239
- ne(l("input", {
1238
+ r("div", Vs, [
1239
+ ne(r("input", {
1240
1240
  "onUpdate:modelValue": m[0] || (m[0] = (g) => d.value = g),
1241
1241
  type: "text",
1242
1242
  class: "baklava-input",
@@ -1245,11 +1245,11 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1245
1245
  [oe, d.value]
1246
1246
  ])
1247
1247
  ]),
1248
- (i(!0), r(T, null, A(O(_(a)), (g) => (i(), r("section", {
1248
+ (i(!0), l(E, null, A(O(_(a)), (g) => (i(), l("section", {
1249
1249
  key: g.name
1250
1250
  }, [
1251
- g.name !== "default" ? (i(), r("h3", Ls, L(g.name), 1)) : N("", !0),
1252
- (i(!0), r(T, null, A(x(g.nodeTypes), (b, p) => (i(), V(fe, {
1251
+ g.name !== "default" ? (i(), l("h3", Ls, L(g.name), 1)) : N("", !0),
1252
+ (i(!0), l(E, null, A(x(g.nodeTypes), (b, p) => (i(), V(fe, {
1253
1253
  key: p,
1254
1254
  type: p,
1255
1255
  title: b.title,
@@ -1259,7 +1259,7 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1259
1259
  ], 34),
1260
1260
  S(dt, { name: "fade" }, {
1261
1261
  default: X(() => [
1262
- h.value ? (i(), r("div", {
1262
+ h.value ? (i(), l("div", {
1263
1263
  key: 0,
1264
1264
  class: "baklava-dragged-node",
1265
1265
  style: se(k.value)
@@ -1274,7 +1274,7 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1274
1274
  })
1275
1275
  ], 64));
1276
1276
  }
1277
- }), rn = /* @__PURE__ */ G({
1277
+ }), ln = /* @__PURE__ */ G({
1278
1278
  __name: "CodeGraphEditor",
1279
1279
  props: {
1280
1280
  viewModel: {}
@@ -1295,7 +1295,7 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1295
1295
  }), null, 16, ["onUpdate"])
1296
1296
  ]),
1297
1297
  sidebar: X((u) => [
1298
- S($s, ct(pt(u)), null, 16)
1298
+ S(Ts, ct(pt(u)), null, 16)
1299
1299
  ]),
1300
1300
  _: 1
1301
1301
  }, 8, ["view-model"]));
@@ -1351,7 +1351,7 @@ const fe = /* @__PURE__ */ z(Es, [["render", Bs]]), Vs = {
1351
1351
  },
1352
1352
  displayValueOnHover: !1
1353
1353
  };
1354
- function ln(o) {
1354
+ function rn(o) {
1355
1355
  const e = tt(o?.existingEditor);
1356
1356
  e.code = o?.code ? new o.code(e) : new It(e), Us(e);
1357
1357
  const t = {};
@@ -1376,46 +1376,46 @@ function ln(o) {
1376
1376
  }
1377
1377
  export {
1378
1378
  gt as AbstractCodeNode,
1379
- Ws as ButtonInterface,
1379
+ Fs as ButtonInterface,
1380
1380
  cn as ButtonInterfaceComponent,
1381
- Xs as CheckboxInterface,
1381
+ Ws as CheckboxInterface,
1382
1382
  pn as CheckboxInterfaceComponent,
1383
1383
  It as Code,
1384
- rn as CodeGraphEditor,
1385
- Js as CodeInputInterface,
1384
+ ln as CodeGraphEditor,
1385
+ Ys as CodeInputInterface,
1386
1386
  we as CodeNode,
1387
1387
  M as CodeNodeInterface,
1388
- kt as CodeOutputInterface,
1388
+ yt as CodeOutputInterface,
1389
1389
  W as DEFAULT_SETTINGS,
1390
1390
  Ct as DynamicCodeNode,
1391
- Ys as IntegerInterface,
1391
+ Xs as IntegerInterface,
1392
1392
  hn as IntegerInterfaceComponent,
1393
- qs as NumberInterface,
1393
+ Js as NumberInterface,
1394
1394
  vn as NumberInterfaceComponent,
1395
- Qs as SelectInterface,
1395
+ qs as SelectInterface,
1396
1396
  mn as SelectInterfaceComponent,
1397
- Zs as SliderInterface,
1397
+ Qs as SliderInterface,
1398
1398
  fn as SliderInterfaceComponent,
1399
- en as TextInputInterface,
1399
+ Ks as TextInputInterface,
1400
1400
  gn as TextInputInterfaceComponent,
1401
- Ks as TextInterface,
1402
- tn as TextareaInputInterface,
1401
+ Zs as TextInterface,
1402
+ en as TextareaInputInterface,
1403
1403
  bn as TextareaInputInterfaceComponent,
1404
- Fs as addDefaultTypes,
1404
+ tn as addDefaultTypes,
1405
1405
  Us as addToolbarCommands,
1406
- _t as booleanType,
1406
+ wt as booleanType,
1407
1407
  sn as defineCodeNode,
1408
1408
  nn as defineDynamicCodeNode,
1409
- yt as dictType,
1409
+ xt as dictType,
1410
1410
  Z as getCodeNodes,
1411
1411
  on as getPositionAtColumn,
1412
1412
  an as getPositionBeforeNode,
1413
- wt as listType,
1413
+ kt as listType,
1414
1414
  xe as loadNodeState,
1415
1415
  H as nodeType,
1416
1416
  ke as numberType,
1417
1417
  bt as saveNodeState,
1418
1418
  Ce as stringType,
1419
1419
  Nt as transferCodeScript,
1420
- ln as useCodeGraph
1420
+ rn as useCodeGraph
1421
1421
  };
@@ -1 +1 @@
1
- (function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("baklavajs"),require("mustache"),require("vue"),require("toposort"),require("uuid"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","baklavajs","mustache","vue","toposort","uuid","@vueuse/core"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l["@babsey/code-graph"]={},l.baklavajs,l.mustache,l.Vue,l.toposort,l.uuid,l["@vueuse/core"]))})(this,(function(l,i,L,e,oe,se,ae){"use strict";class P extends i.AbstractNode{state;code;isCodeNode=!0;inputs={};outputs={};constructor(){super(),this.initializeIo(),this.width=400,this.twoColumn=!0,this.state=e.reactive({codeTemplate:"{{ &outputs.code }}",hidden:!1,integrated:!1,modules:[],script:"",variableName:""})}get codeTemplate(){return this.state.codeTemplate}get idx(){return this.code?.codeNodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByVariableNames(){return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this)??-1}get script(){return this.state.script}get shortId(){return this.id.slice(0,6)}get variableName(){return this.state.variableName?this.state.variableName+(this.idxByVariableNames+1):""}getConnectedNodes(t){let n=[];if(t!=="inputs"){const o=this.graph?.connections.filter(s=>s.from.name!=="_node").filter(s=>s.from.nodeId===this.id).map(s=>s.to.nodeId);o&&(n=n.concat(o))}if(t!=="outputs"){const o=this.graph?.connections.filter(s=>s.from.name!=="_node").filter(s=>s.to.nodeId===this.id).map(s=>s.from.nodeId);o&&(n=n.concat(o))}return!n||n.length==0?[]:n.map(o=>this.graph?.findNodeById(o))}registerCode(t){this.code=t}renderCode(){const t={};Object.keys(this.inputs).forEach(o=>{if(o==="_node")return;const s=this.inputs[o],r=s.isString?`'${s.value}'`:s.value;s&&s.state&&(t[o]=s.state.script.length>0?s.state.script:r)});const n={};Object.keys(this.outputs).forEach(o=>{if(o==="_node")return;const s=this.outputs[o],r=s.isString?`'${s.value}'`:s.value;s&&s.state&&(n[o]=r)}),this.state.script=L.render(this.state.codeTemplate,{inputs:t,outputs:n}),this.outputs.code&&(this.outputs.code.state.script=this.state.script)}updateOutputVariableName(){this.outputs.code&&(this.outputs.code.name=this.variableName)}}class O extends P{calculate;load(t){super.load(t),S(this.graph,t)}save(){const t=super.save();return G(this.graph,t),t}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("."))}}}const S=(a,t)=>{if(!a)return;const n=a.findNodeById(t.id);if(!n||n.subgraph)return;const o=n;o.state&&(o.state.integrated=t.integrated,o.state.modules=t.modules,o.state.props=t.props),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_node"&&o.inputs[s]&&(o.inputs[s].hidden=r.hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_node"&&o.outputs[s]&&(o.outputs[s].hidden=r.hidden)})},G=(a,t)=>{if(!a)return;const n=a.findNodeById(t.id);if(!n||n.subgraph)return;const o=n;o.state&&(t.integrated=o.state.integrated,t.modules=o.state.modules),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_node"&&o.inputs[s]&&(r.hidden=o.inputs[s].hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_node"&&o.outputs[s]&&(r.hidden=o.outputs[s].hidden)})},D=new i.NodeInterfaceType("boolean"),U=new i.NodeInterfaceType("dict"),A=new i.NodeInterfaceType("list"),V=new i.NodeInterfaceType("node"),$=new i.NodeInterfaceType("number"),z=new i.NodeInterfaceType("string"),re=a=>{new i.BaklavaInterfaceTypes(a.editor,{viewPlugin:a}).addTypes(z,V,$,D,U,A)},ie=["title"],v=e.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(a){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{title:t.intf.state?.script},e.toDisplayString(t.intf.name),9,ie))}});class b extends i.NodeInterface{optional=!1;code;state;constructor(t,n){super(t,n),this.setComponent(e.markRaw(v)),this.state=e.reactive({script:""})}get shortId(){return this.id.slice(0,6)}}class le extends b{component=e.markRaw(i.ButtonInterfaceComponent);callback;constructor(t,n){super(t,void 0),this.callback=n,this.setPort(!1)}}class de extends b{component=e.markRaw(i.CheckboxInterfaceComponent)}class R extends b{min;max;constructor(t,n,o,s){super(t,n),this.min=o,this.max=s}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class ce extends R{component=e.markRaw(i.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class pe extends b{isCodeInput=!0;constructor(t="",n){super(t,n),this.setComponent(e.markRaw(v))}}class F extends b{isCodeOutput=!0;constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw(v))}get script(){return this.state.script}get value(){return super.value}set value(t){super.value=t,this.state.script=this.name.length>0?this.name:this.value}}class ue extends R{component=e.markRaw(i.NumberInterfaceComponent)}class he extends b{component=e.markRaw(i.SelectInterfaceComponent);items;constructor(t,n,o){super(t,n),this.items=o}}class me extends R{component=e.markRaw(i.SliderInterfaceComponent);min;max;constructor(t,n,o,s){super(t,n,o,s),this.min=o,this.max=s}}class fe extends b{component=e.markRaw(i.TextInputInterfaceComponent);constructor(t,n){super(t,n),this.setPort(!1)}}class ge extends b{isString=!0;component=e.markRaw(i.TextInputInterfaceComponent)}class ye extends b{component=e.markRaw(i.TextareaInputInterfaceComponent)}function _e(a){return class extends O{type=a.type;inputs={};outputs={};constructor(){super(),this._title=a.title??a.type,this.updateModules(a.modules),a.codeTemplate&&(this.state.codeTemplate=a.codeTemplate(this)),a.variableName&&(this.state.variableName=a.variableName),this.addInput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.addOutput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.executeFactory("input",a.inputs),this.executeFactory("output",a.outputs),a.onCreate?.call(this)}calculate=a.calculate?(t,n)=>({...a.calculate.call(this,t,n),_node:null}):void 0;onPlaced(){a.onPlaced?.call(this)}onDestroy(){a.onDestroy?.call(this)}onCodeUpdate(){a.onCodeUpdate?.call(this)}executeFactory(t,n){Object.keys(n||{}).forEach(o=>{const s=n[o]();t==="input"?this.addInput(o,s):this.addOutput(o,s)})}}}class H extends O{calculate}function Ne(a){return class extends H{type=a.type;inputs={};outputs={};calculate;preventUpdate=!1;staticInputKeys=Object.keys(a.inputs??{});staticOutputKeys=Object.keys(a.outputs??{});constructor(){super(),this._title=a.title??a.type,this.updateModules(a.modules),a.codeTemplate&&(this.state.codeTemplate=a.codeTemplate(this)),a.variableName&&(this.state.variableName=a.variableName),this.addInput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.addOutput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_node"),this.staticOutputKeys.push("_node"),this.executeFactory("input",a.inputs),this.executeFactory("output",a.outputs),a.calculate&&(this.calculate=(t,n)=>({...a.calculate?.call(this,t,n),_node:null})),a.onCreate?.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(),a.onPlaced?.call(this)}onDestroy(){a.onDestroy?.call(this)}onCodeUpdate(){a.onCodeUpdate?.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,n!=="_node"&&(this.inputs[n].hidden=t.inputs[n].hidden);for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id,n!=="_node"&&(this.outputs[n].hidden=t.outputs[n].hidden);this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!this.staticInputKeys.includes(n)){if(!this.inputs[n]){const o=t.inputs[n].value;let s;typeof o=="number"?s=new i.IntegerInterface(n,o).use(i.setType,$):s=new i.TextInputInterface(n,JSON.stringify(o)).use(i.setType,z),s.use(i.displayInSidebar,!0),this.addInput(n,s)}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)){if(!this.outputs[n]){const o=new F(n);this.addOutput(n,o)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}S(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),o=a.onUpdate.call(this,t,n);this.updateInterfaces("input",o.inputs??{},o.forceUpdateInputs??[]),this.updateInterfaces("output",o.outputs??{},o.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const o={};for(const s of t)o[s]=n[s].value;return o}updateInterfaces(t,n,o){const s=t==="input"?this.staticInputKeys:this.staticOutputKeys,r=t==="input"?this.inputs:this.outputs;for(const c of Object.keys(r))s.includes(c)||n[c]&&!o.includes(c)||(t==="input"?this.removeInput(c):this.removeOutput(c));for(const c of Object.keys(n)){if(r[c])continue;const d=n[c]();t==="input"?this.addInput(c,d):this.addOutput(c,d)}}executeFactory(t,n){Object.keys(n||{}).forEach(o=>{const s=n[o]();t==="input"?this.addInput(o,s):this.addOutput(o,s)})}}}class W{_id;_viewModel;_state;constructor(t){this._id=se.v4(),this._viewModel=t,this._state=e.reactive({autosort:!1,modules:{},script:"",token:null,template:""})}get codeNodes(){return T(this.graph)}get connections(){return this.graph.connections}set connections(t){this.graph._connections=t}get graph(){return this.viewModel.displayedGraph}get id(){return this._id}get modules(){let t=[];return this.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>{t=t.concat(n.state.modules)}),t?(t.sort(),Array.from(new Set(t.map(n=>this.viewModel.state.modules[n])))):[]}get nodeIds(){return this.codeNodes.map(t=>t.id)}get nodes(){return this.graph.nodes}set nodes(t){this.graph._nodes=t}get scriptedCodeNodes(){return T(this.graph).filter(t=>t.state?.script.length>0)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get viewModel(){return this._viewModel}get visibleNodes(){return this.codeNodes.filter(t=>!t.state?.hidden)}addNode(t,n){return t.code||(t.code=this),n&&(t.state.props=n),this.graph.addNode(t)}addNodeAtCoordinates=(t,n={x:0,y:0},o)=>(this.addNode(t,o),t.position&&(t.position=n),t);addConnection(t,n){t.name!=="_node"&&(t.hidden=!1),n.name!=="_node"&&(n.hidden=!1),this.graph.addConnection(t,n)}clear(){this.nodes=[],this.connections=[]}findNodeById(t){return this.graph.findNodeById(t)}findNodeByType(t){return this.codeNodes.find(n=>n.type===t)}getNodesBySameType(t){return this.codeNodes.filter(n=>n.type===t)}getNodesBySameVariableNames(t){return this.codeNodes.filter(n=>n.state.variableName===t)}hasConnection(t,n){return this.connections.some(o=>o.from.id===t.id&&o.to.id===n.id)}loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}onCodeUpdate(){this.codeNodes.forEach(t=>t.onCodeUpdate())}removeConnection(t){this.graph.removeConnection(t)}removeNode(t){this.graph.removeNode(t)}renderNodeCodes(){this.codeNodes.length!==0&&this.codeNodes.forEach(t=>t.renderCode())}renderCode(){this.state.script=L.render(this.state.template||"",this)}save(){this.state.autosort&&this.sortNodes();const t=this.viewModel.editor.save();return t.graph.id=this.id,this.saveNodeStates(t.graph.nodes),JSON.parse(JSON.stringify(t))}saveNodeStates(t){t.forEach((n,o)=>{const s=this.nodes[o];Object.entries(n.inputs).forEach(([r])=>{n.inputs&&s.inputs[r]&&(n.inputs[r].hidden=s.inputs[r].hidden)}),Object.entries(n.outputs).forEach(([r])=>{n.outputs&&s.outputs[r]&&(n.outputs[r].hidden=s.outputs[r].hidden)})})}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{const t=this.connections.map(r=>[r.to.nodeId,r.from.nodeId]);let n=[...this.nodeIds];n.reverse(),n=oe.array(n,t),n.reverse();const o=this.graph.nodes.map(r=>r.id).filter(r=>!n.includes(r));n=n.concat(o);const s=n.map(r=>this.findNodeById(r));s&&(this.nodes=s)}catch{console.warn("Failed to sort nodes.")}}updateOutputVariableNames(){this.codeNodes.forEach(t=>t.updateOutputVariableName())}}const T=a=>{let t=[];return a.nodes.forEach(n=>{n.subgraph?t=t.concat(T(n.subgraph)):n.isCodeNode&&t.push(n)}),t},be=(a=0,t=100)=>({x:a*420,y:t}),Ce=a=>{const t={...a.position};return t.x-=400,t.y+=50,t},X=a=>{const{calculationOrder:t,connectionsFromNode:n}=i.sortTopologically(a);t.forEach(o=>{if(!o.isCodeNode)return;const s=o;n.has(s)&&n.get(s).forEach(r=>{r.to.state&&r.from.script&&(r.to.state.script=r.from.script)})})},ke=["id"],we={class:"align-middle"},q=e.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(a){const t=a,{viewModel:n}=i.useViewModel(),{hoveredOver:o,temporaryConnection:s}=i.useTemporaryConnection(),r=e.ref(null),c=e.computed(()=>t.intf.connectionCount>0),d=e.computed(()=>({"--connected":c.value})),h=()=>{o(t.intf)},E=()=>{o(void 0)},C=()=>{r.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:r.value})};return e.onMounted(C),e.onUpdated(C),(k,x)=>(e.openBlock(),e.createElementBlock("div",{id:k.intf.id,ref_key:"el",ref:r,class:e.normalizeClass(["baklava-node-interface",d.value])},[k.intf.port?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["__port",{"--selected":e.unref(s)?.from===k.intf}]),onPointerover:h,onPointerout:E},null,34)):e.createCommentVNode("",!0),e.createElementVNode("span",we,[e.renderSlot(k.$slots,"default")])],10,ke))}}),B=(a,t)=>{const n=a.__vccOpts||a;for(const[o,s]of t)n[o]=s;return n},Ie={},Ee={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 Be(a,t){return e.openBlock(),e.createElementBlock("svg",Ee,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 xe=B(Ie,[["render",Be]]),Ve={},Me={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 Te(a,t){return e.openBlock(),e.createElementBlock("svg",Me,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Oe=B(Ve,[["render",Te]]),Se={},$e={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function ze(a,t){return e.openBlock(),e.createElementBlock("svg",$e,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 ve=B(Se,[["render",ze]]),Re={},Le={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 Pe(a,t){return e.openBlock(),e.createElementBlock("svg",Le,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Ge=B(Re,[["render",Pe]]),De={},Ue={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 Ae(a,t){return e.openBlock(),e.createElementBlock("svg",Ue,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Fe=B(De,[["render",Ae]]),He={},We={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Xe(a,t){return e.openBlock(),e.createElementBlock("svg",We,[...t[0]||(t[0]=[e.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 qe=B(He,[["render",Xe]]),Ye={},Je={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Ke(a,t){return e.openBlock(),e.createElementBlock("svg",Je,[...t[0]||(t[0]=[e.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 Qe=B(Ye,[["render",Ke]]),Ze={},je={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function et(a,t){return e.openBlock(),e.createElementBlock("svg",je,[...t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>',8)])])}const tt=B(Ze,[["render",et]]),nt={},ot={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"16",height:"16",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"};function st(a,t){return e.openBlock(),e.createElementBlock("svg",ot,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"5",r:"1"},null,-1)])])}const at=B(nt,[["render",st]]),rt=["id","data-node-type"],it={class:"__title-label",style:{"flex-grow":"1"}},lt={key:0},dt={class:"__menu",style:{display:"flex"}},ct={class:"__outputs"},pt={key:0},ut=["id","title"],ht={class:"__inputs"},mt={key:0},ft=["id","title"],gt=e.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(a,{emit:t}){const n=i.Components.ContextMenu,o=i.Components.NodeInterface,s=a,r=e.computed(()=>s.node),c=t,{viewModel:d}=i.useViewModel(),{graph:h,switchGraph:E}=i.useGraph(),C=e.ref(null),k=e.ref(!1),x=e.ref(""),_=e.ref(null),f=e.ref(!1);let g=0,y=0;const u=e.ref(!1),N=e.computed(()=>{const p=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return s.node.type.startsWith(i.GRAPH_NODE_TYPE_PREFIX)&&p.push({value:"editSubgraph",label:"Edit Subgraph"}),p}),I=e.computed(()=>({"--selected":s.selected,"--dragging":s.dragging,"--two-column":!!s.node.twoColumn,"--hidden":r.value.state?.hidden})),vt=e.computed(()=>({"--reverse-y":s.node.reverseY??d.value.settings.nodes.reverseY})),Rt=e.computed(()=>({top:`${s.node.position?.y??0}px`,left:`${s.node.position?.x??0}px`,"--width":`${s.node.width??d.value.settings.nodes.defaultWidth}px`})),Lt=e.computed(()=>Object.values(s.node.inputs).filter(p=>!p.hidden)),Pt=e.computed(()=>Object.values(s.node.outputs).filter(p=>!p.hidden)),K=()=>{c("select")},Gt=p=>{s.selected||K(),c("start-drag",p)},Q=()=>{u.value=!0},Dt=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId="",p.visible=!1},Z=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId=s.node.id,p.visible=!0},Ut=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId=s.node.id},At=async p=>{switch(p){case"edit":Z();break;case"delete":h.value.removeNode(s.node);break;case"rename":x.value=s.node.title,k.value=!0,await e.nextTick(),_.value?.focus();break;case"editSubgraph":E(s.node.template);break}},j=()=>{s.node.title=x.value,k.value=!1},ee=()=>{C.value&&d.value.hooks.renderNode.execute({node:s.node,el:C.value})},Ft=p=>{f.value=!0,g=s.node.width,y=p.clientX,p.preventDefault()},te=p=>{if(!f.value)return;const w=p.clientX-y,m=g+w/h.value.scaling,Ht=d.value.settings.nodes.minWidth,Wt=d.value.settings.nodes.maxWidth;s.node.width=Math.max(Ht,Math.min(Wt,m))},ne=()=>{f.value=!1};return e.onMounted(()=>{ee(),window.addEventListener("mousemove",te),window.addEventListener("mouseup",ne)}),e.onUpdated(ee),e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",ne)}),(p,w)=>(e.openBlock(),e.createElementBlock("div",{id:r.value.id,ref_key:"el",ref:C,class:e.normalizeClass([I.value,"baklava-node"]),"data-node-type":r.value.type,style:e.normalizeStyle(Rt.value),onPointerdown:K},[e.unref(d).settings.nodes.resizable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Ft},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"__title",onPointerdown:e.withModifiers(Gt,["self","stop"]),onContextmenu:e.withModifiers(Q,["prevent"])},[r.value.inputs._node?(e.openBlock(),e.createBlock(q,{key:0,node:r.value,intf:r.value.inputs._node,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["node","intf"])):e.createCommentVNode("",!0),k.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:_,"onUpdate:modelValue":w[1]||(w[1]=m=>x.value=m),class:"baklava-input",placeholder:"Node Name",style:{"flex-grow":"1"},type:"text",onBlur:j,onKeydown:e.withKeys(j,["enter"])},null,544)),[[e.vModelText,x.value]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",it,[r.value.idx>-1?(e.openBlock(),e.createElementBlock("span",lt,e.toDisplayString(r.value.idx+1)+" - ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(r.value.title)+" ("+e.toDisplayString(r.value.shortId)+") ",1)]),e.createElementVNode("div",dt,[r.value.subgraph?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[!e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(Fe),{key:0,class:"--clickable mx-1",onClick:Z})):e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(ve),{key:1,class:"--clickable mx-1",onClick:Ut})):(e.openBlock(),e.createBlock(e.unref(Ge),{key:2,class:"--clickable mx-1",onClick:Dt}))],64)),e.createVNode(e.unref(at),{class:"--clickable mx-1",onClick:Q}),e.createVNode(e.unref(n),{modelValue:u.value,"onUpdate:modelValue":w[0]||(w[0]=m=>u.value=m),x:0,y:0,items:N.value,onClick:At},null,8,["modelValue","items"])])],64)),r.value.outputs._node?(e.openBlock(),e.createBlock(q,{key:3,node:r.value,intf:r.value.outputs._node,class:"--output","data-interface-type":"node"},null,8,["node","intf"])):e.createCommentVNode("",!0)],32),e.createElementVNode("div",{class:e.normalizeClass(["__content",vt.value]),onKeydown:w[2]||(w[2]=e.withKeys(e.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:w[3]||(w[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Pt.value,m=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",pt,[m.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:m.id,title:m.name,class:"baklava-node-interface --output --connected"},[...w[4]||(w[4]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,ut)):e.createCommentVNode("",!0)])):e.renderSlot(p.$slots,"nodeInterface",{key:1,type:"output",node:r.value,intf:m},()=>[e.createVNode(e.unref(o),{node:r.value,intf:m},null,8,["node","intf"])])],64))),128))]),e.createElementVNode("div",ht,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Lt.value,m=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",mt,[m.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:m.id,title:m.name,class:"baklava-node-interface --input --connected"},[...w[5]||(w[5]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,ft)):e.createCommentVNode("",!0)])):e.renderSlot(p.$slots,"nodeInterface",{key:1,node:r.value,intf:m,type:"input"},()=>[e.createVNode(e.unref(o),{node:r.value,intf:m,title:m.name},null,8,["node","intf","title"])])],64))),128))])],34)],46,rt))}}),yt=["title"],_t={key:0,class:"__label"},Nt=e.defineComponent({__name:"Checkbox",props:{modelValue:{type:Boolean},inversed:{type:Boolean},name:{}},emits:["update:modelValue"],setup(a,{emit:t}){const n=t;return(o,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["baklava-checkbox",{"--checked":o.inversed?!o.modelValue:o.modelValue}]),title:o.name,onClick:s[0]||(s[0]=r=>n("update:modelValue",!o.modelValue))},[s[1]||(s[1]=e.createElementVNode("div",{class:"__checkmark-container"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[e.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),o.name?(e.openBlock(),e.createElementBlock("div",_t,e.toDisplayString(o.name),1)):e.createCommentVNode("",!0)],10,yt))}}),bt={class:"__header"},Ct={class:"__node-name"},kt={style:{display:"flex"}},wt={key:1,class:"__interface"},It=e.defineComponent({__name:"CodeGraphSidebar",setup(a){const{viewModel:t}=i.useViewModel(),{graph:n}=i.useGraph(),o=e.ref(null),s=e.toRef(t.value.settings.sidebar,"width"),r=e.computed(()=>t.value.settings.sidebar.resizable);let c=0,d=0;const h=e.computed(()=>{const y=n.value.sidebar.nodeId;return n.value.nodes.find(u=>u.id===y)}),E=e.computed(()=>h.value),C=e.computed(()=>({width:`${s.value}px`})),k=e.computed(()=>h.value?[...Object.values(h.value.inputs),...Object.values(h.value.outputs)].filter(u=>u.displayInSidebar&&u.component):[]),x=()=>{n.value.sidebar.visible=!1},_=()=>{h.value?.events.update.emit(null)},f=y=>{c=s.value,d=y.clientX,window.addEventListener("mousemove",g),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",g)},{once:!0})},g=y=>{const u=o.value?.parentElement?.getBoundingClientRect().width??500,N=y.clientX-d;let I=c-N;I<300?I=300:I>.9*u&&(I=.9*u),s.value=I};return(y,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:o,class:e.normalizeClass(["baklava-sidebar",{"--open":e.unref(n).sidebar.visible}]),style:e.normalizeStyle(C.value)},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resizer",onMousedown:f},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",bt,[e.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:x},"×"),e.createElementVNode("div",Ct,[e.createElementVNode("b",null,e.toDisplayString(h.value?h.value.title:""),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,N=>(e.openBlock(),e.createElementBlock("div",{key:N.id,class:"__interface"},[e.createElementVNode("div",kt,[e.createVNode(Nt,{modelValue:N.hidden,"onUpdate:modelValue":[I=>N.hidden=I,u[0]||(u[0]=()=>h.value?.events.update.emit(null))],inversed:"",style:{"margin-right":"8px"}},null,8,["modelValue","onUpdate:modelValue"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(N.component),{modelValue:N.value,"onUpdate:modelValue":I=>N.value=I,node:h.value,intf:N,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128)),E.value&&E.value.state?(e.openBlock(),e.createElementBlock("div",wt,[u[2]||(u[2]=e.createElementVNode("label",null,"Variable name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[1]||(u[1]=N=>E.value.state.variableName=N),type:"text",class:"baklava-input",title:"Variable name",onBlur:_,onKeydown:e.withKeys(_,["enter"])},null,544),[[e.vModelText,E.value.state.variableName]])])):e.createCommentVNode("",!0)],6))}}),Et=e.defineComponent({props:{type:{type:String,required:!0},title:{type:String,required:!0}},setup(a){const{viewModel:t}=i.useViewModel(),{switchGraph:n}=i.useGraph(),o=e.ref(!1),s=e.computed(()=>a.type.startsWith(i.GRAPH_NODE_TYPE_PREFIX));return{showContextMenu:o,hasContextMenu:s,contextMenuItems:[{label:"Edit Subgraph",value:"editSubgraph"},{label:"Delete Subgraph",value:"deleteSubgraph"}],openContextMenu:()=>{o.value=!0},onContextMenuClick:h=>{const E=a.type.substring(i.GRAPH_NODE_TYPE_PREFIX.length),C=t.value.editor.graphTemplates.find(k=>k.id===E);if(C)switch(h){case"editSubgraph":n(C);break;case"deleteSubgraph":t.value.editor.removeGraphTemplate(C);break}}}}}),Bt=["data-node-type"],xt={class:"__title"},Vt={class:"__title-label"};function Mt(a,t,n,o,s,r){return e.openBlock(),e.createElementBlock("div",{class:"baklava-node --palette","data-node-type":a.type},[e.createElementVNode("div",xt,[e.createElementVNode("div",Vt,e.toDisplayString(a.title),1)])],8,Bt)}const Y=B(Et,[["render",Mt]]),Tt={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"30px"}},Ot={key:0},St=e.defineComponent({__name:"CodeNodePalette",setup(a){const{viewModel:t}=i.useViewModel(),{x:n,y:o}=ae.usePointer(),{transform:s}=i.useTransform(),r=i.useNodeCategories(t),c=e.inject("editorEl"),d=e.ref(""),h=e.ref(null),E=_=>d.value?_.filter(f=>Object.values(f.nodeTypes).some(g=>g.title.toLowerCase().includes(d.value?.toLowerCase()))):_,C=_=>d.value?Object.values(_).filter(f=>f.title.toLowerCase().includes(d.value?.toLowerCase())):Object.values(_),k=e.computed(()=>{if(!h.value||!c?.value)return{};const{left:_,top:f}=c.value.getBoundingClientRect();return{top:`${o.value-f}px`,left:`${n.value-_}px`}}),x=(_,f)=>{h.value={type:_,nodeInformation:f};const g=()=>{const y=e.reactive(new f.type);t.value.displayedGraph.addNode(y);const u=c.value.getBoundingClientRect(),[N,I]=s(n.value-u.left,o.value-u.top);y.position.x=N,y.position.y=I,h.value=null,document.removeEventListener("pointerup",g)};document.addEventListener("pointerup",g)};return(_,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["baklava-node-palette",{"--open":e.unref(t).settings.palette.enabled}]),onContextmenu:f[1]||(f[1]=e.withModifiers(()=>{},["stop","prevent"]))},[e.createElementVNode("div",Tt,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=g=>d.value=g),type:"text",class:"baklava-input",title:"Filter node types"},null,512),[[e.vModelText,d.value]])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E(e.unref(r)),g=>(e.openBlock(),e.createElementBlock("section",{key:g.name},[g.name!=="default"?(e.openBlock(),e.createElementBlock("h3",Ot,e.toDisplayString(g.name),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C(g.nodeTypes),(y,u)=>(e.openBlock(),e.createBlock(Y,{key:u,type:u,title:y.title,onPointerdown:N=>x(u,y)},null,8,["type","title","onPointerdown"]))),128))]))),128))],34),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:e.normalizeStyle(k.value)},[e.createVNode(Y,{type:h.value.type,title:h.value.nodeInformation.title},null,8,["type","title"])],4)):e.createCommentVNode("",!0)]),_:1})],64))}}),$t=e.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(a){const t=a,n=e.toRef(t,"viewModel"),o=s=>s.events.update.emit(null);return e.onMounted(()=>{n.value.subscribe(),n.value.engine.start()}),e.onUnmounted(()=>{n.value.unsubscribe(),n.value.engine.stop()}),(s,r)=>(e.openBlock(),e.createBlock(e.unref(i.BaklavaEditor),{"view-model":n.value},{palette:e.withCtx(()=>[e.createVNode(St)]),node:e.withCtx(c=>[e.createVNode(gt,e.mergeProps(c,{onUpdate:d=>o(c.node)}),null,16,["onUpdate"])]),sidebar:e.withCtx(c=>[e.createVNode(It,e.normalizeProps(e.guardReactiveProps(c)),null,16)]),_:1},8,["view-model"]))}}),J=a=>{const t="TOGGLE_PALETTE";a.commandHandler.registerCommand(t,{execute:()=>a.settings.palette.enabled=!a.settings.palette.enabled,canExecute:()=>!0});const n="CLEAR_ALL";a.commandHandler.registerCommand(n,{execute:()=>a.displayedGraph.nodes.forEach(s=>a.displayedGraph.removeNode(s)),canExecute:()=>a.displayedGraph.nodes.length>0});const o="TOGGLE_MINIMAP";a.commandHandler.registerCommand(o,{execute:()=>a.settings.enableMinimap=!a.settings.enableMinimap,canExecute:()=>a.displayedGraph.nodes.length>1}),a.settings.toolbar.commands=[{command:t,title:"Toggle palette",icon:e.computed(()=>a.settings.palette.enabled?xe:Oe)},...i.DEFAULT_TOOLBAR_COMMANDS,{command:n,title:"Clear all",icon:tt},{command:o,title:"Toggle minimap",icon:e.computed(()=>a.settings.enableMinimap?Qe:qe)}]},M={enableMinimap:!1,toolbar:{enabled:!0},palette:{enabled:!0},sidebar:{enabled:!0,resizable:!0,width:350},displayValueOnHover:!1};function zt(a){const t=i.useBaklava(a?.existingEditor);t.code=a?.code?new a.code(t):new W(t),J(t);const n={};return Object.keys(M).forEach(o=>{n[o]=typeof M[o]=="object"?{...t.settings[o],...M[o]}:M[o]}),t.settings=e.reactive({...t.settings,...n}),t.settings.nodes.defaultWidth=350,t.state=e.reactive({modules:{},token:null}),t.engine=new i.DependencyEngine(t.editor),t.subscribe=()=>{t.state.token&&t.unsubscribe();const o=Symbol();t.displayedGraph.events.addNode.subscribe(o,s=>s.code=t.code),t.engine.events.beforeRun.subscribe(o,()=>{t.engine.pause(),t.code&&(t.code.onCodeUpdate(),t.code.sortNodes(),t.code.updateOutputVariableNames()),t.engine.resume()}),t.engine.events.afterRun.subscribe(o,s=>{t.engine.pause(),i.applyResult(s,t.editor),X(t.displayedGraph),t.code&&(t.code.renderNodeCodes(),t.code.renderCode()),t.engine.resume()}),t.state.token=o},t.unsubscribe=()=>{if(!t.state.token)return;const o=t.state.token;t.displayedGraph.events.addNode.unsubscribe(o),t.engine.events.beforeRun.unsubscribe(o),t.engine.events.afterRun.unsubscribe(o),t.state.token=null},t}Object.defineProperty(l,"ButtonInterfaceComponent",{enumerable:!0,get:()=>i.ButtonInterfaceComponent}),Object.defineProperty(l,"CheckboxInterfaceComponent",{enumerable:!0,get:()=>i.CheckboxInterfaceComponent}),Object.defineProperty(l,"IntegerInterfaceComponent",{enumerable:!0,get:()=>i.IntegerInterfaceComponent}),Object.defineProperty(l,"NumberInterfaceComponent",{enumerable:!0,get:()=>i.NumberInterfaceComponent}),Object.defineProperty(l,"SelectInterfaceComponent",{enumerable:!0,get:()=>i.SelectInterfaceComponent}),Object.defineProperty(l,"SliderInterfaceComponent",{enumerable:!0,get:()=>i.SliderInterfaceComponent}),Object.defineProperty(l,"TextInputInterfaceComponent",{enumerable:!0,get:()=>i.TextInputInterfaceComponent}),Object.defineProperty(l,"TextareaInputInterfaceComponent",{enumerable:!0,get:()=>i.TextareaInputInterfaceComponent}),l.AbstractCodeNode=P,l.ButtonInterface=le,l.CheckboxInterface=de,l.Code=W,l.CodeGraphEditor=$t,l.CodeInputInterface=pe,l.CodeNode=O,l.CodeNodeInterface=b,l.CodeOutputInterface=F,l.DEFAULT_SETTINGS=M,l.DynamicCodeNode=H,l.IntegerInterface=ce,l.NumberInterface=ue,l.SelectInterface=he,l.SliderInterface=me,l.TextInputInterface=ge,l.TextInterface=fe,l.TextareaInputInterface=ye,l.addDefaultTypes=re,l.addToolbarCommands=J,l.booleanType=D,l.defineCodeNode=_e,l.defineDynamicCodeNode=Ne,l.dictType=U,l.getCodeNodes=T,l.getPositionAtColumn=be,l.getPositionBeforeNode=Ce,l.listType=A,l.loadNodeState=S,l.nodeType=V,l.numberType=$,l.saveNodeState=G,l.stringType=z,l.transferCodeScript=X,l.useCodeGraph=zt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("baklavajs"),require("mustache"),require("vue"),require("toposort"),require("uuid"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","baklavajs","mustache","vue","toposort","uuid","@vueuse/core"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l["@babsey/code-graph"]={},l.baklavajs,l.mustache,l.Vue,l.toposort,l.uuid,l["@vueuse/core"]))})(this,(function(l,i,L,e,oe,se,ae){"use strict";class P extends i.AbstractNode{state;code;isCodeNode=!0;codeTemplate=()=>"";inputs={};outputs={};constructor(){super(),this.initializeIo(),this.width=400,this.twoColumn=!0,this.state=e.reactive({codeTemplate:"{{ &outputs.code }}",hidden:!1,integrated:!1,modules:[],script:"",variableName:""})}get idx(){return this.code?.codeNodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByVariableNames(){return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this)??-1}get script(){return this.state.script}get shortId(){return this.id.slice(0,6)}get variableName(){return this.state.variableName?this.state.variableName+(this.idxByVariableNames+1):""}getConnectedNodes(t){let n=[];if(t!=="inputs"){const o=this.graph?.connections.filter(s=>s.from.name!=="_node").filter(s=>s.from.nodeId===this.id).map(s=>s.to.nodeId);o&&(n=n.concat(o))}if(t!=="outputs"){const o=this.graph?.connections.filter(s=>s.from.name!=="_node").filter(s=>s.to.nodeId===this.id).map(s=>s.from.nodeId);o&&(n=n.concat(o))}return!n||n.length==0?[]:n.map(o=>this.graph?.findNodeById(o))}registerCode(t){this.code=t}renderCode(){this.state.codeTemplate=this.codeTemplate.call(this);const t={};Object.keys(this.inputs).forEach(o=>{if(o==="_node")return;const s=this.inputs[o],r=s.isString?`'${s.value}'`:s.value;s&&s.state&&(t[o]=s.state.script.length>0?s.state.script:r)});const n={};Object.keys(this.outputs).forEach(o=>{if(o==="_node")return;const s=this.outputs[o],r=s.isString?`'${s.value}'`:s.value;s&&s.state&&(n[o]=r)}),this.state.script=L.render(this.state.codeTemplate,{inputs:t,outputs:n}),this.outputs.code&&(this.outputs.code.state.script=this.state.script)}updateOutputVariableName(){this.outputs.code&&(this.outputs.code.name=this.variableName)}}class O extends P{calculate;load(t){super.load(t),S(this.graph,t)}save(){const t=super.save();return G(this.graph,t),t}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("."))}}}const S=(a,t)=>{if(!a)return;const n=a.findNodeById(t.id);if(!n||n.subgraph)return;const o=n;o.state&&(o.state.integrated=t.integrated,o.state.modules=t.modules,o.state.props=t.props),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_node"&&o.inputs[s]&&(o.inputs[s].hidden=r.hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_node"&&o.outputs[s]&&(o.outputs[s].hidden=r.hidden)})},G=(a,t)=>{if(!a)return;const n=a.findNodeById(t.id);if(!n||n.subgraph)return;const o=n;o.state&&(t.integrated=o.state.integrated,t.modules=o.state.modules),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_node"&&o.inputs[s]&&(r.hidden=o.inputs[s].hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_node"&&o.outputs[s]&&(r.hidden=o.outputs[s].hidden)})},re=["title"],$=e.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(a){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{title:t.intf.state?.script},e.toDisplayString(t.intf.name),9,re))}});class b extends i.NodeInterface{optional=!1;code;state;constructor(t,n){super(t,n),this.setComponent(e.markRaw($)),this.state=e.reactive({script:""})}get shortId(){return this.id.slice(0,6)}}class ie extends b{component=e.markRaw(i.ButtonInterfaceComponent);callback;constructor(t,n){super(t,void 0),this.callback=n,this.setPort(!1)}}class le extends b{component=e.markRaw(i.CheckboxInterfaceComponent)}class z extends b{min;max;constructor(t,n,o,s){super(t,n),this.min=o,this.max=s}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class de extends z{component=e.markRaw(i.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class ce extends b{isCodeInput=!0;constructor(t="",n){super(t,n),this.setComponent(e.markRaw($))}}class D extends b{isCodeOutput=!0;constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw($))}get script(){return this.state.script}get value(){return super.value}set value(t){super.value=t,this.state.script=this.name.length>0?this.name:this.value}}class pe extends z{component=e.markRaw(i.NumberInterfaceComponent)}class ue extends b{component=e.markRaw(i.SelectInterfaceComponent);items;constructor(t,n,o){super(t,n),this.items=o}}class he extends z{component=e.markRaw(i.SliderInterfaceComponent);min;max;constructor(t,n,o,s){super(t,n,o,s),this.min=o,this.max=s}}class me extends b{component=e.markRaw(i.TextInputInterfaceComponent);constructor(t,n){super(t,n),this.setPort(!1)}}class fe extends b{isString=!0;component=e.markRaw(i.TextInputInterfaceComponent)}class ge extends b{component=e.markRaw(i.TextareaInputInterfaceComponent)}const U=new i.NodeInterfaceType("boolean"),A=new i.NodeInterfaceType("dict"),F=new i.NodeInterfaceType("list"),V=new i.NodeInterfaceType("node"),v=new i.NodeInterfaceType("number"),R=new i.NodeInterfaceType("string"),ye=a=>{new i.BaklavaInterfaceTypes(a.editor,{viewPlugin:a}).addTypes(R,V,v,U,A,F)};function _e(a){return class extends O{type=a.type;inputs={};outputs={};constructor(){super(),this._title=a.title??a.type,this.updateModules(a.modules),a.variableName&&(this.state.variableName=a.variableName),a.codeTemplate&&(this.codeTemplate=a.codeTemplate),this.addInput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.addOutput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.executeFactory("input",a.inputs),this.executeFactory("output",a.outputs),a.onCreate?.call(this)}calculate=a.calculate?(t,n)=>({...a.calculate.call(this,t,n),_node:null}):void 0;onPlaced(){a.onPlaced?.call(this)}onDestroy(){a.onDestroy?.call(this)}onCodeUpdate(){a.onCodeUpdate?.call(this)}executeFactory(t,n){Object.keys(n||{}).forEach(o=>{const s=n[o]();t==="input"?this.addInput(o,s):this.addOutput(o,s)})}}}class H extends O{calculate}function Ne(a){return class extends H{type=a.type;inputs={};outputs={};calculate;preventUpdate=!1;staticInputKeys=Object.keys(a.inputs??{});staticOutputKeys=Object.keys(a.outputs??{});constructor(){super(),this._title=a.title??a.type,this.updateModules(a.modules),a.codeTemplate&&(this.codeTemplate=a.codeTemplate),a.variableName&&(this.state.variableName=a.variableName),this.addInput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.addOutput("_node",new b("",[]).use(i.setType,V).use(i.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_node"),this.staticOutputKeys.push("_node"),this.executeFactory("input",a.inputs),this.executeFactory("output",a.outputs),a.calculate&&(this.calculate=(t,n)=>({...a.calculate?.call(this,t,n),_node:null})),a.onCreate?.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(),a.onPlaced?.call(this)}onDestroy(){a.onDestroy?.call(this)}onCodeUpdate(){a.onCodeUpdate?.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,n!=="_node"&&(this.inputs[n].hidden=t.inputs[n].hidden);for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id,n!=="_node"&&(this.outputs[n].hidden=t.outputs[n].hidden);this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!this.staticInputKeys.includes(n)){if(!this.inputs[n]){const o=t.inputs[n].value;let s;typeof o=="number"?s=new i.IntegerInterface(n,o).use(i.setType,v):s=new i.TextInputInterface(n,JSON.stringify(o)).use(i.setType,R),s.use(i.displayInSidebar,!0),this.addInput(n,s)}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)){if(!this.outputs[n]){const o=new D(n);this.addOutput(n,o)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}S(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),o=a.onUpdate.call(this,t,n);this.updateInterfaces("input",o.inputs??{},o.forceUpdateInputs??[]),this.updateInterfaces("output",o.outputs??{},o.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const o={};for(const s of t)o[s]=n[s].value;return o}updateInterfaces(t,n,o){const s=t==="input"?this.staticInputKeys:this.staticOutputKeys,r=t==="input"?this.inputs:this.outputs;for(const c of Object.keys(r))s.includes(c)||n[c]&&!o.includes(c)||(t==="input"?this.removeInput(c):this.removeOutput(c));for(const c of Object.keys(n)){if(r[c])continue;const d=n[c]();t==="input"?this.addInput(c,d):this.addOutput(c,d)}}executeFactory(t,n){Object.keys(n||{}).forEach(o=>{const s=n[o]();t==="input"?this.addInput(o,s):this.addOutput(o,s)})}}}class W{_id;_viewModel;_state;constructor(t){this._id=se.v4(),this._viewModel=t,this._state=e.reactive({autosort:!1,modules:{},script:"",token:null,template:""})}get codeNodes(){return T(this.graph)}get connections(){return this.graph.connections}set connections(t){this.graph._connections=t}get graph(){return this.viewModel.displayedGraph}get id(){return this._id}get modules(){let t=[];return this.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>{t=t.concat(n.state.modules)}),t?(t.sort(),Array.from(new Set(t.map(n=>this.viewModel.state.modules[n])))):[]}get nodeIds(){return this.codeNodes.map(t=>t.id)}get nodes(){return this.graph.nodes}set nodes(t){this.graph._nodes=t}get scriptedCodeNodes(){return T(this.graph).filter(t=>t.state?.script.length>0)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get viewModel(){return this._viewModel}get visibleNodes(){return this.codeNodes.filter(t=>!t.state?.hidden)}addNode(t,n){return t.code||(t.code=this),n&&(t.state.props=n),this.graph.addNode(t)}addNodeAtCoordinates=(t,n={x:0,y:0},o)=>(this.addNode(t,o),t.position&&(t.position=n),t);addConnection(t,n){t.name!=="_node"&&(t.hidden=!1),n.name!=="_node"&&(n.hidden=!1),this.graph.addConnection(t,n)}clear(){this.nodes=[],this.connections=[]}findNodeById(t){return this.graph.findNodeById(t)}findNodeByType(t){return this.codeNodes.find(n=>n.type===t)}getNodesBySameType(t){return this.codeNodes.filter(n=>n.type===t)}getNodesBySameVariableNames(t){return this.codeNodes.filter(n=>n.state.variableName===t)}hasConnection(t,n){return this.connections.some(o=>o.from.id===t.id&&o.to.id===n.id)}loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}onCodeUpdate(){this.codeNodes.forEach(t=>t.onCodeUpdate())}removeConnection(t){this.graph.removeConnection(t)}removeNode(t){this.graph.removeNode(t)}renderNodeCodes(){this.codeNodes.length!==0&&this.codeNodes.forEach(t=>t.renderCode())}renderCode(){this.state.script=L.render(this.state.template||"",this)}save(){this.state.autosort&&this.sortNodes();const t=this.viewModel.editor.save();return t.graph.id=this.id,this.saveNodeStates(t.graph.nodes),JSON.parse(JSON.stringify(t))}saveNodeStates(t){t.forEach((n,o)=>{const s=this.nodes[o];Object.entries(n.inputs).forEach(([r])=>{n.inputs&&s.inputs[r]&&(n.inputs[r].hidden=s.inputs[r].hidden)}),Object.entries(n.outputs).forEach(([r])=>{n.outputs&&s.outputs[r]&&(n.outputs[r].hidden=s.outputs[r].hidden)})})}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{const t=this.connections.map(r=>[r.to.nodeId,r.from.nodeId]);let n=[...this.nodeIds];n.reverse(),n=oe.array(n,t),n.reverse();const o=this.graph.nodes.map(r=>r.id).filter(r=>!n.includes(r));n=n.concat(o);const s=n.map(r=>this.findNodeById(r));s&&(this.nodes=s)}catch{console.warn("Failed to sort nodes.")}}updateOutputVariableNames(){this.codeNodes.forEach(t=>t.updateOutputVariableName())}}const T=a=>{let t=[];return a.nodes.forEach(n=>{n.subgraph?t=t.concat(T(n.subgraph)):n.isCodeNode&&t.push(n)}),t},be=(a=0,t=100)=>({x:a*420,y:t}),Ce=a=>{const t={...a.position};return t.x-=400,t.y+=50,t},X=a=>{const{calculationOrder:t,connectionsFromNode:n}=i.sortTopologically(a);t.forEach(o=>{if(!o.isCodeNode)return;const s=o;n.has(s)&&n.get(s).forEach(r=>{r.to.state&&r.from.script&&(r.to.state.script=r.from.script)})})},ke=["id"],we={class:"align-middle"},q=e.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(a){const t=a,{viewModel:n}=i.useViewModel(),{hoveredOver:o,temporaryConnection:s}=i.useTemporaryConnection(),r=e.ref(null),c=e.computed(()=>t.intf.connectionCount>0),d=e.computed(()=>({"--connected":c.value})),h=()=>{o(t.intf)},E=()=>{o(void 0)},C=()=>{r.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:r.value})};return e.onMounted(C),e.onUpdated(C),(k,x)=>(e.openBlock(),e.createElementBlock("div",{id:k.intf.id,ref_key:"el",ref:r,class:e.normalizeClass(["baklava-node-interface",d.value])},[k.intf.port?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["__port",{"--selected":e.unref(s)?.from===k.intf}]),onPointerover:h,onPointerout:E},null,34)):e.createCommentVNode("",!0),e.createElementVNode("span",we,[e.renderSlot(k.$slots,"default")])],10,ke))}}),B=(a,t)=>{const n=a.__vccOpts||a;for(const[o,s]of t)n[o]=s;return n},Ie={},Ee={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 Be(a,t){return e.openBlock(),e.createElementBlock("svg",Ee,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 xe=B(Ie,[["render",Be]]),Ve={},Me={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 Te(a,t){return e.openBlock(),e.createElementBlock("svg",Me,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Oe=B(Ve,[["render",Te]]),Se={},$e={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function ze(a,t){return e.openBlock(),e.createElementBlock("svg",$e,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 ve=B(Se,[["render",ze]]),Re={},Le={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 Pe(a,t){return e.openBlock(),e.createElementBlock("svg",Le,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Ge=B(Re,[["render",Pe]]),De={},Ue={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 Ae(a,t){return e.openBlock(),e.createElementBlock("svg",Ue,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Fe=B(De,[["render",Ae]]),He={},We={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Xe(a,t){return e.openBlock(),e.createElementBlock("svg",We,[...t[0]||(t[0]=[e.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 qe=B(He,[["render",Xe]]),Ye={},Je={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Ke(a,t){return e.openBlock(),e.createElementBlock("svg",Je,[...t[0]||(t[0]=[e.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 Qe=B(Ye,[["render",Ke]]),Ze={},je={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function et(a,t){return e.openBlock(),e.createElementBlock("svg",je,[...t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>',8)])])}const tt=B(Ze,[["render",et]]),nt={},ot={xmlns:"http://www.w3.org/2000/svg",class:"baklava-icon",width:"16",height:"16",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"};function st(a,t){return e.openBlock(),e.createElementBlock("svg",ot,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"12",r:"1"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"19",r:"1"},null,-1),e.createElementVNode("circle",{cx:"12",cy:"5",r:"1"},null,-1)])])}const at=B(nt,[["render",st]]),rt=["id","data-node-type"],it={class:"__title-label",style:{"flex-grow":"1"}},lt={key:0},dt={class:"__menu",style:{display:"flex"}},ct={class:"__outputs"},pt={key:0},ut=["id","title"],ht={class:"__inputs"},mt={key:0},ft=["id","title"],gt=e.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(a,{emit:t}){const n=i.Components.ContextMenu,o=i.Components.NodeInterface,s=a,r=e.computed(()=>s.node),c=t,{viewModel:d}=i.useViewModel(),{graph:h,switchGraph:E}=i.useGraph(),C=e.ref(null),k=e.ref(!1),x=e.ref(""),_=e.ref(null),f=e.ref(!1);let g=0,y=0;const u=e.ref(!1),N=e.computed(()=>{const p=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return s.node.type.startsWith(i.GRAPH_NODE_TYPE_PREFIX)&&p.push({value:"editSubgraph",label:"Edit Subgraph"}),p}),I=e.computed(()=>({"--selected":s.selected,"--dragging":s.dragging,"--two-column":!!s.node.twoColumn,"--hidden":r.value.state?.hidden})),vt=e.computed(()=>({"--reverse-y":s.node.reverseY??d.value.settings.nodes.reverseY})),Rt=e.computed(()=>({top:`${s.node.position?.y??0}px`,left:`${s.node.position?.x??0}px`,"--width":`${s.node.width??d.value.settings.nodes.defaultWidth}px`})),Lt=e.computed(()=>Object.values(s.node.inputs).filter(p=>!p.hidden)),Pt=e.computed(()=>Object.values(s.node.outputs).filter(p=>!p.hidden)),K=()=>{c("select")},Gt=p=>{s.selected||K(),c("start-drag",p)},Q=()=>{u.value=!0},Dt=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId="",p.visible=!1},Z=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId=s.node.id,p.visible=!0},Ut=()=>{const p=d.value.displayedGraph.sidebar;p.nodeId=s.node.id},At=async p=>{switch(p){case"edit":Z();break;case"delete":h.value.removeNode(s.node);break;case"rename":x.value=s.node.title,k.value=!0,await e.nextTick(),_.value?.focus();break;case"editSubgraph":E(s.node.template);break}},j=()=>{s.node.title=x.value,k.value=!1},ee=()=>{C.value&&d.value.hooks.renderNode.execute({node:s.node,el:C.value})},Ft=p=>{f.value=!0,g=s.node.width,y=p.clientX,p.preventDefault()},te=p=>{if(!f.value)return;const w=p.clientX-y,m=g+w/h.value.scaling,Ht=d.value.settings.nodes.minWidth,Wt=d.value.settings.nodes.maxWidth;s.node.width=Math.max(Ht,Math.min(Wt,m))},ne=()=>{f.value=!1};return e.onMounted(()=>{ee(),window.addEventListener("mousemove",te),window.addEventListener("mouseup",ne)}),e.onUpdated(ee),e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",ne)}),(p,w)=>(e.openBlock(),e.createElementBlock("div",{id:r.value.id,ref_key:"el",ref:C,class:e.normalizeClass([I.value,"baklava-node"]),"data-node-type":r.value.type,style:e.normalizeStyle(Rt.value),onPointerdown:K},[e.unref(d).settings.nodes.resizable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Ft},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"__title",onPointerdown:e.withModifiers(Gt,["self","stop"]),onContextmenu:e.withModifiers(Q,["prevent"])},[r.value.inputs._node?(e.openBlock(),e.createBlock(q,{key:0,node:r.value,intf:r.value.inputs._node,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["node","intf"])):e.createCommentVNode("",!0),k.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:_,"onUpdate:modelValue":w[1]||(w[1]=m=>x.value=m),class:"baklava-input",placeholder:"Node Name",style:{"flex-grow":"1"},type:"text",onBlur:j,onKeydown:e.withKeys(j,["enter"])},null,544)),[[e.vModelText,x.value]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",it,[r.value.idx>-1?(e.openBlock(),e.createElementBlock("span",lt,e.toDisplayString(r.value.idx+1)+" - ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(r.value.title)+" ("+e.toDisplayString(r.value.shortId)+") ",1)]),e.createElementVNode("div",dt,[r.value.subgraph?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[!e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(Fe),{key:0,class:"--clickable mx-1",onClick:Z})):e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(ve),{key:1,class:"--clickable mx-1",onClick:Ut})):(e.openBlock(),e.createBlock(e.unref(Ge),{key:2,class:"--clickable mx-1",onClick:Dt}))],64)),e.createVNode(e.unref(at),{class:"--clickable mx-1",onClick:Q}),e.createVNode(e.unref(n),{modelValue:u.value,"onUpdate:modelValue":w[0]||(w[0]=m=>u.value=m),x:0,y:0,items:N.value,onClick:At},null,8,["modelValue","items"])])],64)),r.value.outputs._node?(e.openBlock(),e.createBlock(q,{key:3,node:r.value,intf:r.value.outputs._node,class:"--output","data-interface-type":"node"},null,8,["node","intf"])):e.createCommentVNode("",!0)],32),e.createElementVNode("div",{class:e.normalizeClass(["__content",vt.value]),onKeydown:w[2]||(w[2]=e.withKeys(e.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:w[3]||(w[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",ct,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Pt.value,m=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",pt,[m.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:m.id,title:m.name,class:"baklava-node-interface --output --connected"},[...w[4]||(w[4]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,ut)):e.createCommentVNode("",!0)])):e.renderSlot(p.$slots,"nodeInterface",{key:1,type:"output",node:r.value,intf:m},()=>[e.createVNode(e.unref(o),{node:r.value,intf:m},null,8,["node","intf"])])],64))),128))]),e.createElementVNode("div",ht,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Lt.value,m=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",mt,[m.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:m.id,title:m.name,class:"baklava-node-interface --input --connected"},[...w[5]||(w[5]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,ft)):e.createCommentVNode("",!0)])):e.renderSlot(p.$slots,"nodeInterface",{key:1,node:r.value,intf:m,type:"input"},()=>[e.createVNode(e.unref(o),{node:r.value,intf:m,title:m.name},null,8,["node","intf","title"])])],64))),128))])],34)],46,rt))}}),yt=["title"],_t={key:0,class:"__label"},Nt=e.defineComponent({__name:"Checkbox",props:{modelValue:{type:Boolean},inversed:{type:Boolean},name:{}},emits:["update:modelValue"],setup(a,{emit:t}){const n=t;return(o,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["baklava-checkbox",{"--checked":o.inversed?!o.modelValue:o.modelValue}]),title:o.name,onClick:s[0]||(s[0]=r=>n("update:modelValue",!o.modelValue))},[s[1]||(s[1]=e.createElementVNode("div",{class:"__checkmark-container"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[e.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),o.name?(e.openBlock(),e.createElementBlock("div",_t,e.toDisplayString(o.name),1)):e.createCommentVNode("",!0)],10,yt))}}),bt={class:"__header"},Ct={class:"__node-name"},kt={style:{display:"flex"}},wt={key:1,class:"__interface"},It=e.defineComponent({__name:"CodeGraphSidebar",setup(a){const{viewModel:t}=i.useViewModel(),{graph:n}=i.useGraph(),o=e.ref(null),s=e.toRef(t.value.settings.sidebar,"width"),r=e.computed(()=>t.value.settings.sidebar.resizable);let c=0,d=0;const h=e.computed(()=>{const y=n.value.sidebar.nodeId;return n.value.nodes.find(u=>u.id===y)}),E=e.computed(()=>h.value),C=e.computed(()=>({width:`${s.value}px`})),k=e.computed(()=>h.value?[...Object.values(h.value.inputs),...Object.values(h.value.outputs)].filter(u=>u.displayInSidebar&&u.component):[]),x=()=>{n.value.sidebar.visible=!1},_=()=>{h.value?.events.update.emit(null)},f=y=>{c=s.value,d=y.clientX,window.addEventListener("mousemove",g),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",g)},{once:!0})},g=y=>{const u=o.value?.parentElement?.getBoundingClientRect().width??500,N=y.clientX-d;let I=c-N;I<300?I=300:I>.9*u&&(I=.9*u),s.value=I};return(y,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:o,class:e.normalizeClass(["baklava-sidebar",{"--open":e.unref(n).sidebar.visible}]),style:e.normalizeStyle(C.value)},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resizer",onMousedown:f},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",bt,[e.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:x},"×"),e.createElementVNode("div",Ct,[e.createElementVNode("b",null,e.toDisplayString(h.value?h.value.title:""),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,N=>(e.openBlock(),e.createElementBlock("div",{key:N.id,class:"__interface"},[e.createElementVNode("div",kt,[e.createVNode(Nt,{modelValue:N.hidden,"onUpdate:modelValue":[I=>N.hidden=I,u[0]||(u[0]=()=>h.value?.events.update.emit(null))],inversed:"",style:{"margin-right":"8px"}},null,8,["modelValue","onUpdate:modelValue"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(N.component),{modelValue:N.value,"onUpdate:modelValue":I=>N.value=I,node:h.value,intf:N,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128)),E.value&&E.value.state?(e.openBlock(),e.createElementBlock("div",wt,[u[2]||(u[2]=e.createElementVNode("label",null,"Variable name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[1]||(u[1]=N=>E.value.state.variableName=N),type:"text",class:"baklava-input",title:"Variable name",onBlur:_,onKeydown:e.withKeys(_,["enter"])},null,544),[[e.vModelText,E.value.state.variableName]])])):e.createCommentVNode("",!0)],6))}}),Et=e.defineComponent({props:{type:{type:String,required:!0},title:{type:String,required:!0}},setup(a){const{viewModel:t}=i.useViewModel(),{switchGraph:n}=i.useGraph(),o=e.ref(!1),s=e.computed(()=>a.type.startsWith(i.GRAPH_NODE_TYPE_PREFIX));return{showContextMenu:o,hasContextMenu:s,contextMenuItems:[{label:"Edit Subgraph",value:"editSubgraph"},{label:"Delete Subgraph",value:"deleteSubgraph"}],openContextMenu:()=>{o.value=!0},onContextMenuClick:h=>{const E=a.type.substring(i.GRAPH_NODE_TYPE_PREFIX.length),C=t.value.editor.graphTemplates.find(k=>k.id===E);if(C)switch(h){case"editSubgraph":n(C);break;case"deleteSubgraph":t.value.editor.removeGraphTemplate(C);break}}}}}),Bt=["data-node-type"],xt={class:"__title"},Vt={class:"__title-label"};function Mt(a,t,n,o,s,r){return e.openBlock(),e.createElementBlock("div",{class:"baklava-node --palette","data-node-type":a.type},[e.createElementVNode("div",xt,[e.createElementVNode("div",Vt,e.toDisplayString(a.title),1)])],8,Bt)}const Y=B(Et,[["render",Mt]]),Tt={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"30px"}},Ot={key:0},St=e.defineComponent({__name:"CodeNodePalette",setup(a){const{viewModel:t}=i.useViewModel(),{x:n,y:o}=ae.usePointer(),{transform:s}=i.useTransform(),r=i.useNodeCategories(t),c=e.inject("editorEl"),d=e.ref(""),h=e.ref(null),E=_=>d.value?_.filter(f=>Object.values(f.nodeTypes).some(g=>g.title.toLowerCase().includes(d.value?.toLowerCase()))):_,C=_=>d.value?Object.values(_).filter(f=>f.title.toLowerCase().includes(d.value?.toLowerCase())):Object.values(_),k=e.computed(()=>{if(!h.value||!c?.value)return{};const{left:_,top:f}=c.value.getBoundingClientRect();return{top:`${o.value-f}px`,left:`${n.value-_}px`}}),x=(_,f)=>{h.value={type:_,nodeInformation:f};const g=()=>{const y=e.reactive(new f.type);t.value.displayedGraph.addNode(y);const u=c.value.getBoundingClientRect(),[N,I]=s(n.value-u.left,o.value-u.top);y.position.x=N,y.position.y=I,h.value=null,document.removeEventListener("pointerup",g)};document.addEventListener("pointerup",g)};return(_,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass(["baklava-node-palette",{"--open":e.unref(t).settings.palette.enabled}]),onContextmenu:f[1]||(f[1]=e.withModifiers(()=>{},["stop","prevent"]))},[e.createElementVNode("div",Tt,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=g=>d.value=g),type:"text",class:"baklava-input",title:"Filter node types"},null,512),[[e.vModelText,d.value]])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E(e.unref(r)),g=>(e.openBlock(),e.createElementBlock("section",{key:g.name},[g.name!=="default"?(e.openBlock(),e.createElementBlock("h3",Ot,e.toDisplayString(g.name),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C(g.nodeTypes),(y,u)=>(e.openBlock(),e.createBlock(Y,{key:u,type:u,title:y.title,onPointerdown:N=>x(u,y)},null,8,["type","title","onPointerdown"]))),128))]))),128))],34),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:e.normalizeStyle(k.value)},[e.createVNode(Y,{type:h.value.type,title:h.value.nodeInformation.title},null,8,["type","title"])],4)):e.createCommentVNode("",!0)]),_:1})],64))}}),$t=e.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(a){const t=a,n=e.toRef(t,"viewModel"),o=s=>s.events.update.emit(null);return e.onMounted(()=>{n.value.subscribe(),n.value.engine.start()}),e.onUnmounted(()=>{n.value.unsubscribe(),n.value.engine.stop()}),(s,r)=>(e.openBlock(),e.createBlock(e.unref(i.BaklavaEditor),{"view-model":n.value},{palette:e.withCtx(()=>[e.createVNode(St)]),node:e.withCtx(c=>[e.createVNode(gt,e.mergeProps(c,{onUpdate:d=>o(c.node)}),null,16,["onUpdate"])]),sidebar:e.withCtx(c=>[e.createVNode(It,e.normalizeProps(e.guardReactiveProps(c)),null,16)]),_:1},8,["view-model"]))}}),J=a=>{const t="TOGGLE_PALETTE";a.commandHandler.registerCommand(t,{execute:()=>a.settings.palette.enabled=!a.settings.palette.enabled,canExecute:()=>!0});const n="CLEAR_ALL";a.commandHandler.registerCommand(n,{execute:()=>a.displayedGraph.nodes.forEach(s=>a.displayedGraph.removeNode(s)),canExecute:()=>a.displayedGraph.nodes.length>0});const o="TOGGLE_MINIMAP";a.commandHandler.registerCommand(o,{execute:()=>a.settings.enableMinimap=!a.settings.enableMinimap,canExecute:()=>a.displayedGraph.nodes.length>1}),a.settings.toolbar.commands=[{command:t,title:"Toggle palette",icon:e.computed(()=>a.settings.palette.enabled?xe:Oe)},...i.DEFAULT_TOOLBAR_COMMANDS,{command:n,title:"Clear all",icon:tt},{command:o,title:"Toggle minimap",icon:e.computed(()=>a.settings.enableMinimap?Qe:qe)}]},M={enableMinimap:!1,toolbar:{enabled:!0},palette:{enabled:!0},sidebar:{enabled:!0,resizable:!0,width:350},displayValueOnHover:!1};function zt(a){const t=i.useBaklava(a?.existingEditor);t.code=a?.code?new a.code(t):new W(t),J(t);const n={};return Object.keys(M).forEach(o=>{n[o]=typeof M[o]=="object"?{...t.settings[o],...M[o]}:M[o]}),t.settings=e.reactive({...t.settings,...n}),t.settings.nodes.defaultWidth=350,t.state=e.reactive({modules:{},token:null}),t.engine=new i.DependencyEngine(t.editor),t.subscribe=()=>{t.state.token&&t.unsubscribe();const o=Symbol();t.displayedGraph.events.addNode.subscribe(o,s=>s.code=t.code),t.engine.events.beforeRun.subscribe(o,()=>{t.engine.pause(),t.code&&(t.code.onCodeUpdate(),t.code.sortNodes(),t.code.updateOutputVariableNames()),t.engine.resume()}),t.engine.events.afterRun.subscribe(o,s=>{t.engine.pause(),i.applyResult(s,t.editor),X(t.displayedGraph),t.code&&(t.code.renderNodeCodes(),t.code.renderCode()),t.engine.resume()}),t.state.token=o},t.unsubscribe=()=>{if(!t.state.token)return;const o=t.state.token;t.displayedGraph.events.addNode.unsubscribe(o),t.engine.events.beforeRun.unsubscribe(o),t.engine.events.afterRun.unsubscribe(o),t.state.token=null},t}Object.defineProperty(l,"ButtonInterfaceComponent",{enumerable:!0,get:()=>i.ButtonInterfaceComponent}),Object.defineProperty(l,"CheckboxInterfaceComponent",{enumerable:!0,get:()=>i.CheckboxInterfaceComponent}),Object.defineProperty(l,"IntegerInterfaceComponent",{enumerable:!0,get:()=>i.IntegerInterfaceComponent}),Object.defineProperty(l,"NumberInterfaceComponent",{enumerable:!0,get:()=>i.NumberInterfaceComponent}),Object.defineProperty(l,"SelectInterfaceComponent",{enumerable:!0,get:()=>i.SelectInterfaceComponent}),Object.defineProperty(l,"SliderInterfaceComponent",{enumerable:!0,get:()=>i.SliderInterfaceComponent}),Object.defineProperty(l,"TextInputInterfaceComponent",{enumerable:!0,get:()=>i.TextInputInterfaceComponent}),Object.defineProperty(l,"TextareaInputInterfaceComponent",{enumerable:!0,get:()=>i.TextareaInputInterfaceComponent}),l.AbstractCodeNode=P,l.ButtonInterface=ie,l.CheckboxInterface=le,l.Code=W,l.CodeGraphEditor=$t,l.CodeInputInterface=ce,l.CodeNode=O,l.CodeNodeInterface=b,l.CodeOutputInterface=D,l.DEFAULT_SETTINGS=M,l.DynamicCodeNode=H,l.IntegerInterface=de,l.NumberInterface=pe,l.SelectInterface=ue,l.SliderInterface=he,l.TextInputInterface=fe,l.TextInterface=me,l.TextareaInputInterface=ge,l.addDefaultTypes=ye,l.addToolbarCommands=J,l.booleanType=U,l.defineCodeNode=_e,l.defineDynamicCodeNode=Ne,l.dictType=A,l.getCodeNodes=T,l.getPositionAtColumn=be,l.getPositionBeforeNode=Ce,l.listType=F,l.loadNodeState=S,l.nodeType=V,l.numberType=v,l.saveNodeState=G,l.stringType=R,l.transferCodeScript=X,l.useCodeGraph=zt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
@@ -14,10 +14,10 @@ export declare abstract class AbstractCodeNode extends AbstractNode {
14
14
  state: UnwrapRef<IAbstractCodeNodeState>;
15
15
  code: Code | undefined;
16
16
  isCodeNode: boolean;
17
+ codeTemplate: () => string;
17
18
  inputs: Record<string, NodeInterface<unknown>>;
18
19
  outputs: Record<string, NodeInterface<unknown>>;
19
20
  constructor();
20
- get codeTemplate(): string;
21
21
  get idx(): number;
22
22
  get idxByVariableNames(): number;
23
23
  get script(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",