@babsey/code-graph 0.2.3 → 0.3.1

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.
Files changed (54) hide show
  1. package/dist/code-graph.css +1 -1
  2. package/dist/code-graph.js +1448 -1108
  3. package/dist/code-graph.umd.cjs +4 -1
  4. package/package.json +7 -7
  5. package/dist/code.d.ts +0 -158
  6. package/dist/codeNode/codeGraphNode.d.ts +0 -11
  7. package/dist/codeNode/codeNode.d.ts +0 -111
  8. package/dist/codeNode/defineCodeNode.d.ts +0 -18
  9. package/dist/codeNode/dynamicCodeNode.d.ts +0 -38
  10. package/dist/codeNode/index.d.ts +0 -4
  11. package/dist/codeNodeInterfaces/baseNumericInterface.d.ts +0 -23
  12. package/dist/codeNodeInterfaces/baseStringInterface.d.ts +0 -5
  13. package/dist/codeNodeInterfaces/checkbox/checkboxInterface.d.ts +0 -5
  14. package/dist/codeNodeInterfaces/codeNode/CodeNodeInterface.vue.d.ts +0 -7
  15. package/dist/codeNodeInterfaces/codeNode/codeNodeInterface.d.ts +0 -23
  16. package/dist/codeNodeInterfaces/codeNodeInput/codeNodeInputInterface.d.ts +0 -7
  17. package/dist/codeNodeInterfaces/codeNodeOutput/codeNodeOutputInterface.d.ts +0 -6
  18. package/dist/codeNodeInterfaces/index.d.ts +0 -12
  19. package/dist/codeNodeInterfaces/integer/integerInterface.d.ts +0 -6
  20. package/dist/codeNodeInterfaces/listInput/listInputInterface.d.ts +0 -5
  21. package/dist/codeNodeInterfaces/number/numberInterface.d.ts +0 -5
  22. package/dist/codeNodeInterfaces/select/selectInterface.d.ts +0 -12
  23. package/dist/codeNodeInterfaces/slider/sliderInterface.d.ts +0 -9
  24. package/dist/codeNodeInterfaces/textInput/TextInputInterface.vue.d.ts +0 -26
  25. package/dist/codeNodeInterfaces/textInput/textInputInterface.d.ts +0 -7
  26. package/dist/codeNodeInterfaces/textareaInput/textareaInputInterface.d.ts +0 -5
  27. package/dist/codeNodeInterfaces/tupleInput/tupleInputInterface.d.ts +0 -5
  28. package/dist/components/CodeGraphEditor.vue.d.ts +0 -19
  29. package/dist/components/index.d.ts +0 -1
  30. package/dist/components/node/CodeGraphNode.vue.d.ts +0 -39
  31. package/dist/components/nodeInterface/CodeGraphNodeInterface.vue.d.ts +0 -19
  32. package/dist/components/nodePalette/CodeNodePalette.vue.d.ts +0 -3
  33. package/dist/components/nodePalette/PaletteEntry.vue.d.ts +0 -31
  34. package/dist/components/sidebar/Checkbox.vue.d.ts +0 -13
  35. package/dist/components/sidebar/CodeGraphSidebar.vue.d.ts +0 -15
  36. package/dist/icons/CodeVariable.vue.d.ts +0 -3
  37. package/dist/icons/DotsVertical.vue.d.ts +0 -3
  38. package/dist/icons/LayoutSidebarLeftCollapse.vue.d.ts +0 -3
  39. package/dist/icons/LayoutSidebarLeftExpand.vue.d.ts +0 -3
  40. package/dist/icons/LayoutSidebarRight.vue.d.ts +0 -3
  41. package/dist/icons/LayoutSidebarRightCollapse.vue.d.ts +0 -3
  42. package/dist/icons/LayoutSidebarRightExpand.vue.d.ts +0 -3
  43. package/dist/icons/LockCode.vue.d.ts +0 -3
  44. package/dist/icons/Schema.vue.d.ts +0 -3
  45. package/dist/icons/SchemaOff.vue.d.ts +0 -3
  46. package/dist/icons/TransitionBottom.vue.d.ts +0 -3
  47. package/dist/icons/TrashOff.vue.d.ts +0 -3
  48. package/dist/icons/index.d.ts +0 -12
  49. package/dist/index.d.ts +0 -11
  50. package/dist/interfaceTypes/default.d.ts +0 -9
  51. package/dist/interfaceTypes/index.d.ts +0 -1
  52. package/dist/settings.d.ts +0 -11
  53. package/dist/utils.d.ts +0 -5
  54. package/dist/viewModel.d.ts +0 -20
@@ -1,20 +1,23 @@
1
- import Y from "mustache";
2
- import Ye from "toposort";
3
- import { AbstractNode as Ke, sortTopologically as qe, NodeInterface as Je, displayInSidebar as xe, NodeInterfaceType as H, BaklavaInterfaceTypes as Qe, CheckboxInterfaceComponent as Ze, setType as T, IntegerInterfaceComponent as et, TextInputInterfaceComponent as Me, NumberInterfaceComponent as tt, SelectInterfaceComponent as st, SliderInterfaceComponent as nt, TextareaInputInterfaceComponent as ot, allowMultipleConnections as A, IntegerInterface as at, TextInputInterface as it, getGraphNodeTypeString as rt, GraphInputNode as dt, GraphOutputNode as lt, Commands as Z, useViewModel as K, useTemporaryConnection as ut, Components as Ce, useGraph as ae, GRAPH_NODE_TYPE_PREFIX as se, useTransform as ct, useNodeCategories as pt, BaklavaEditor as ht, useBaklava as mt, DependencyEngine as vt, DEFAULT_TOOLBAR_COMMANDS as ft } from "baklavajs";
4
- import { reactive as q, defineComponent as R, createElementBlock as d, openBlock as i, toDisplayString as j, markRaw as B, computed as b, createElementVNode as l, withDirectives as ee, vModelText as te, ref as V, onMounted as ie, onUpdated as Oe, normalizeClass as P, createCommentVNode as N, unref as k, renderSlot as X, createStaticVNode as J, onBeforeUnmount as gt, normalizeStyle as re, withModifiers as F, createBlock as E, Fragment as S, createTextVNode as bt, createVNode as z, withKeys as ne, renderList as D, nextTick as _t, toRef as $e, resolveDynamicComponent as ke, inject as yt, Transition as Ct, withCtx as W, onUnmounted as kt, normalizeProps as wt, guardReactiveProps as It, mergeProps as Nt } from "vue";
5
- import { v4 as Te } from "uuid";
6
- import { usePointer as xt } from "@vueuse/core";
7
- Y.escape = (s) => s;
8
- class Ee extends Ke {
1
+ import Z from "mustache";
2
+ import { reactive as D, defineComponent as F, createElementBlock as p, openBlock as d, toDisplayString as G, markRaw as z, computed as O, createElementVNode as u, withDirectives as de, vModelText as le, createStaticVNode as se, toRef as Be, onMounted as fe, onBeforeUnmount as ze, watch as He, createBlock as j, unref as w, withCtx as ee, createVNode as L, normalizeProps as pt, guardReactiveProps as ht, renderSlot as ne, mergeProps as mt, ref as V, onUpdated as Le, normalizeStyle as ve, normalizeClass as Y, createCommentVNode as M, withModifiers as te, Fragment as B, createTextVNode as ft, withKeys as he, renderList as J, nextTick as vt, inject as gt, Transition as bt, resolveDynamicComponent as Me, shallowReadonly as _t } from "vue";
3
+ import { v4 as K } from "uuid";
4
+ import { AbstractNode as yt, NodeInterface as A, getGraphNodeTypeString as Ue, Graph as Ct, GraphTemplate as It, GRAPH_NODE_TYPE_PREFIX as wt, GRAPH_INPUT_NODE_TYPE as kt, GRAPH_OUTPUT_NODE_TYPE as Nt, Editor as xt } from "@baklavajs/core";
5
+ import { NodeInterfaceType as X, BaklavaInterfaceTypes as Ot, setType as $ } from "@baklavajs/interface-types";
6
+ import { allowMultipleConnections as Q, applyResult as Ae, BaseEngine as Tt, sortTopologically as Et } from "@baklavajs/engine";
7
+ import { displayInSidebar as De, CheckboxInterfaceComponent as $t, useGraph as ge, IntegerInterfaceComponent as Mt, TextInputInterfaceComponent as Fe, NumberInterfaceComponent as Gt, SelectInterfaceComponent as St, SliderInterfaceComponent as Pt, TextareaInputInterfaceComponent as Vt, IntegerInterface as Rt, TextInputInterface as be, DEFAULT_TOOLBAR_COMMANDS as jt, Commands as q, BaklavaEditor as Bt, Components as me, useViewModel as oe, useTemporaryConnection as zt, useTransform as Ht, useNodeCategories as Lt, DEFAULT_SETTINGS as Ut, useCommandHandler as At, useHistory as Dt, useClipboard as Ft, registerDeleteNodesCommand as Wt, registerSaveSubgraphCommand as Yt, registerSwitchToMainGraphCommand as Kt, registerSidebarCommands as Xt, registerZoomToFitCommands as qt, setViewNodeProperties as Jt } from "@baklavajs/renderer-vue";
8
+ import Qt from "toposort";
9
+ import { SequentialHook as Ge } from "@baklavajs/events";
10
+ import { usePointer as Zt } from "@vueuse/core";
11
+ Z.escape = (n) => n;
12
+ class We extends yt {
9
13
  state;
10
- code;
11
14
  isCodeNode = !0;
12
15
  name = "";
13
16
  codeTemplate;
14
17
  inputs = {};
15
18
  outputs = {};
16
19
  constructor() {
17
- super(), this.initializeIo(), this.twoColumn = !0, this.state = q({
20
+ super(), this.initializeIo(), this.twoColumn = !0, this.state = D({
18
21
  codeTemplate: "",
19
22
  hidden: !1,
20
23
  integrated: !1,
@@ -22,26 +25,36 @@ class Ee extends Ke {
22
25
  modules: [],
23
26
  props: null,
24
27
  script: "",
25
- variableName: "x"
28
+ variableName: "a"
26
29
  }), this.codeTemplate = function() {
27
- return `${this.name}(${Mt(this.codeNodeInputs).join(", ")})`;
30
+ return `${this.name}(${en(this.codeNodeInputs).join(", ")})`;
28
31
  };
29
32
  }
33
+ get code() {
34
+ return this.graph.code;
35
+ }
30
36
  get codeNodeInputs() {
31
37
  return Object.fromEntries(
32
- Object.entries(this.inputs).filter((e) => e[1].type != "node")
38
+ Object.entries(this.inputs).filter(
39
+ (e) => e[1].isCodeNode && e[1].type != "node"
40
+ )
33
41
  );
34
42
  }
35
43
  get codeNodeOutputs() {
36
44
  return Object.fromEntries(
37
- Object.entries(this.outputs).filter((e) => e[1].type != "node")
45
+ Object.entries(this.outputs).filter(
46
+ (e) => e[1].isCodeNode && e[1].type != "node"
47
+ )
38
48
  );
39
49
  }
50
+ get graph() {
51
+ return super.graph;
52
+ }
40
53
  get idx() {
41
- return this.code?.codeNodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
54
+ return this.graph.nodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
42
55
  }
43
56
  get idxByVariableNames() {
44
- return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this) ?? -1;
57
+ return this.graph.getNodesBySameVariableNames(this.state.variableName).filter((e) => !e.state.integrated).indexOf(this) ?? -1;
45
58
  }
46
59
  get lockCode() {
47
60
  return this.state.lockCode;
@@ -60,10 +73,10 @@ class Ee extends Ke {
60
73
  );
61
74
  }
62
75
  get script() {
63
- return this.state.script;
76
+ return this.outputs._code?.value ?? "";
64
77
  }
65
78
  set script(e) {
66
- this.state.script = e, this.events.update.emit(null);
79
+ this.outputs._code && (this.outputs._code.value = e), this.events.update.emit(null);
67
80
  }
68
81
  get shortId() {
69
82
  return this.id.slice(0, 6);
@@ -79,8 +92,8 @@ class Ee extends Ke {
79
92
  * @returns code node instance or null
80
93
  */
81
94
  getConnectedNodeByInterface(e, t) {
82
- const n = this.getConnectedNodesByInterface(e, t);
83
- return n.length > 0 ? n[0] : null;
95
+ const s = this.getConnectedNodesByInterface(e, t);
96
+ return s.length > 0 ? s[0] : null;
84
97
  }
85
98
  /**
86
99
  * Get connected nodes to the node.
@@ -90,14 +103,14 @@ class Ee extends Ke {
90
103
  getConnectedNodes(e) {
91
104
  let t = [];
92
105
  if (e !== "inputs") {
93
- const n = this.graph?.connections.filter((o) => o.from.name !== "_code").filter((o) => o.from.nodeId === this.id).map((o) => o.to.nodeId);
94
- n && (t = t.concat(n));
106
+ const s = this.graph.connections.filter((o) => o.from.name !== "_code").filter((o) => o.from.nodeId === this.id).map((o) => o.to.nodeId);
107
+ s && (t = t.concat(s));
95
108
  }
96
109
  if (e !== "outputs") {
97
- const n = this.graph?.connections.filter((o) => o.from.name !== "_code").filter((o) => o.to.nodeId === this.id).map((o) => o.from.nodeId);
98
- n && (t = t.concat(n));
110
+ const s = this.graph.connections.filter((o) => o.from.name !== "_code").filter((o) => o.to.nodeId === this.id).map((o) => o.from.nodeId);
111
+ s && (t = t.concat(s));
99
112
  }
100
- return !t || t.length == 0 ? [] : t.map((n) => this.graph?.findNodeById(n));
113
+ return !t || t.length == 0 ? [] : t.map((s) => this.graph.findNodeById(s));
101
114
  }
102
115
  /**
103
116
  * Get connected nodes to the node interface.
@@ -105,20 +118,20 @@ class Ee extends Ke {
105
118
  * @returns code node instances
106
119
  */
107
120
  getConnectedNodesByInterface(e, t) {
108
- let n = [];
121
+ let s = [];
109
122
  if (t !== "outputs" && this.inputs[e]) {
110
- const o = this.graph?.connections.filter(
123
+ const o = this.graph.connections.filter(
111
124
  (a) => a.to.id === this.inputs[e]?.id || a.from.id === this.inputs[e]?.id
112
125
  ).map((a) => a.from.nodeId);
113
- o && (n = n.concat(o));
126
+ o && (s = s.concat(o));
114
127
  }
115
128
  if (t !== "inputs" && this.outputs[e]) {
116
- const o = this.graph?.connections.filter(
129
+ const o = this.graph.connections.filter(
117
130
  (a) => a.from.id === this.outputs[e]?.id || a.from.id === this.outputs[e]?.id
118
131
  ).map((a) => a.to.nodeId);
119
- o && (n = n.concat(o));
132
+ o && (s = s.concat(o));
120
133
  }
121
- return !n || n.length == 0 ? [] : n.map((o) => this.graph?.findNodeById(o));
134
+ return !s || s.length == 0 ? [] : s.map((o) => this.graph.findNodeById(o));
122
135
  }
123
136
  /**
124
137
  * Register code
@@ -130,53 +143,53 @@ class Ee extends Ke {
130
143
  /**
131
144
  * Render code of this node.
132
145
  */
133
- renderCode() {
134
- if (!this.lockCode) {
135
- const e = {};
136
- Object.keys(this.inputs).forEach((n) => {
137
- if (n === "_code") return;
138
- const o = this.inputs[n];
139
- o && o.state && (e[n] = o.state.script.length > 0 ? o.state.script : o.getValue());
140
- });
141
- const t = {};
142
- Object.keys(this.outputs).forEach((n) => {
143
- if (n === "_code") return;
144
- const o = this.outputs[n];
145
- o && o.state && (t[n] = o.getValue());
146
- }), this.state.script = Y.render(this.state.codeTemplate, { inputs: e, outputs: t });
147
- }
148
- this.outputs.out && (this.outputs.out.state.script = this.script);
146
+ renderCode(e) {
147
+ return Z.render(this.state.codeTemplate, e);
149
148
  }
150
149
  /**
151
- * Reset script of input interfaces.
150
+ * Update code templates.
152
151
  */
153
- resetInputInterfaceScript() {
154
- Object.values(this.codeNodeInputs).forEach((e) => e.resetScript());
155
- }
156
152
  updateCodeTemplate() {
157
153
  this.state.codeTemplate = this.codeTemplate.call(this);
158
154
  }
159
- updateConnectedInputInterfaces() {
160
- if (!this.graph) return;
161
- const { connectionsFromNode: e } = qe(this.graph);
162
- if (!e.has(this)) return;
163
- const t = e.get(this);
164
- t && t.forEach((n) => {
165
- if (!n.from.isCodeNode || !n.to.isCodeNode) return;
166
- const o = this.graph?.findNodeById(n.from.nodeId);
167
- o && (o.renderCode(), n.to.script = n.from.script);
168
- });
155
+ /**
156
+ * Update modules.
157
+ * @param modules a list of modules
158
+ */
159
+ updateModules(e) {
160
+ if (e)
161
+ this.state.modules = e;
162
+ else if (this.type.includes(".")) {
163
+ const t = this.type.split(".");
164
+ this.state.modules.push(t.slice(0, t.length - 1).join("."));
165
+ }
169
166
  }
167
+ /**
168
+ * Update output names.
169
+ */
170
170
  updateOutputNames() {
171
171
  Object.values(this.codeNodeOutputs).forEach((e) => {
172
- e.name = this.state.integrated ? "" : this.variableName + e.value;
172
+ e.name = this.state.integrated ? "" : this.variableName + e.suffix;
173
+ });
174
+ }
175
+ /**
176
+ * Update output values.
177
+ * @param output return data of calculate function
178
+ */
179
+ updateOutputValues(e) {
180
+ Object.keys(this.outputs).forEach((t) => {
181
+ t !== "_code" && (e[t] = this.state.integrated ? e._code : this.outputs[t].name);
173
182
  });
174
183
  }
184
+ /**
185
+ * Update state props.
186
+ * @param props
187
+ */
175
188
  updateProps(e) {
176
189
  this.state.props = e;
177
190
  }
178
191
  }
179
- class Se extends Ee {
192
+ class _e extends We {
180
193
  /**
181
194
  * The default implementation does nothing.
182
195
  * Overwrite this method to do calculation.
@@ -184,100 +197,80 @@ class Se extends Ee {
184
197
  * @param globalValues Set of values passed to every node by the engine plugin
185
198
  * @return Values for output interfaces
186
199
  */
187
- calculate;
200
+ calculate = (e, t) => {
201
+ const s = {};
202
+ return this.lockCode || (s._code = this.renderCode({ inputs: e, ...t })), this.updateOutputValues(s), s;
203
+ };
188
204
  load(e) {
189
- super.load(e), Be(this.graph, e);
205
+ super.load(e), Ye(this.graph, e);
190
206
  }
191
207
  save() {
192
208
  const e = super.save();
193
- return Ot(this.graph, e), e;
194
- }
195
- updateModules(e) {
196
- if (e)
197
- this.state.modules = e;
198
- else if (this.type.includes(".")) {
199
- const t = this.type.split(".");
200
- this.state.modules.push(t.slice(0, t.length - 1).join("."));
201
- }
209
+ return tn(this.graph, e), e;
202
210
  }
203
211
  }
204
- const Mt = (s, e = !0) => {
205
- const t = [], n = Object.keys(s);
206
- return n.forEach((o) => {
207
- if (s[o]?.hidden) return;
208
- const r = e && t.length < n.indexOf(o) ? `${o}=` : "";
209
- t.push(`${r}{{ inputs.${o} }}`);
212
+ const en = (n, e = !0) => {
213
+ const t = [], s = Object.keys(n);
214
+ return s.forEach((o) => {
215
+ if (n[o]?.hidden) return;
216
+ const i = e && t.length < s.indexOf(o) ? `${o}=` : "";
217
+ t.push(`${i}{{ inputs.${o} }}`);
210
218
  }), t;
211
- }, Be = (s, e) => {
212
- if (!s) return;
213
- const t = s.findNodeById(e.id);
219
+ }, Ye = (n, e) => {
220
+ if (!n) return;
221
+ const t = n.findNodeById(e.id);
214
222
  if (!t || t.subgraph) return;
215
- const n = t;
216
- n.state && (n.state.integrated = e.integrated, n.state.modules = e.modules, n.state.props = e.props), Object.entries(e.inputs).forEach(([o, a]) => {
217
- o !== "_code" && n.inputs[o] && (n.inputs[o].hidden = a.hidden);
223
+ const s = t;
224
+ s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([o, a]) => {
225
+ o !== "_code" && s.inputs[o] && (s.inputs[o].hidden = a.hidden);
218
226
  }), Object.entries(e.outputs).forEach(([o, a]) => {
219
- o !== "_code" && n.outputs[o] && (n.outputs[o].hidden = a.hidden);
227
+ o !== "_code" && s.outputs[o] && (s.outputs[o].hidden = a.hidden);
220
228
  });
221
- }, Ot = (s, e) => {
222
- if (!s) return;
223
- const t = s.findNodeById(e.id);
229
+ }, tn = (n, e) => {
230
+ if (!n) return;
231
+ const t = n.findNodeById(e.id);
224
232
  if (!t || t.subgraph) return;
225
- const n = t;
226
- n.state && (e.integrated = n.state.integrated, e.modules = n.state.modules), Object.entries(e.inputs).forEach(([o, a]) => {
227
- o !== "_code" && n.inputs[o] && (a.hidden = n.inputs[o].hidden);
233
+ const s = t;
234
+ s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([o, a]) => {
235
+ o !== "_code" && s.inputs[o] && (a.hidden = s.inputs[o].hidden);
228
236
  }), Object.entries(e.outputs).forEach(([o, a]) => {
229
- o !== "_code" && n.outputs[o] && (a.hidden = n.outputs[o].hidden);
237
+ o !== "_code" && s.outputs[o] && (a.hidden = s.outputs[o].hidden);
230
238
  });
231
- }, $t = ["title"], de = /* @__PURE__ */ R({
239
+ }, nn = ["title"], ye = /* @__PURE__ */ F({
232
240
  __name: "CodeNodeInterface",
233
241
  props: {
234
242
  intf: {}
235
243
  },
236
- setup(s) {
237
- return (e, t) => (i(), d("div", {
238
- title: s.intf.state?.script
239
- }, j(s.intf.name), 9, $t));
244
+ setup(n) {
245
+ return (e, t) => (d(), p("div", {
246
+ title: n.intf.value
247
+ }, G(n.intf.name), 9, nn));
240
248
  }
241
249
  });
242
- class G extends Je {
250
+ class R extends A {
243
251
  isCodeNode = !0;
244
252
  code;
245
253
  state;
246
254
  type = null;
247
255
  constructor(e, t) {
248
- super(e, t), this.setComponent(B(de)), this.state = q({
249
- optional: !1,
250
- script: ""
256
+ super(e, t), this.setComponent(z(ye)), this.state = D({
257
+ optional: !1
251
258
  });
252
259
  }
253
260
  get optional() {
254
261
  return this.state.optional;
255
262
  }
256
- get script() {
257
- return this.state.script;
258
- }
259
- set script(e) {
260
- this.state.script = e;
261
- }
262
263
  get shortId() {
263
264
  return this.id.slice(0, 6);
264
265
  }
265
266
  getValue = () => `${this.value ?? "None"}`;
266
- resetScript = () => this.state.script = "";
267
267
  setOptional(e) {
268
268
  return this.state.optional = e, this.setHidden(e), this;
269
269
  }
270
270
  }
271
- class Q extends G {
271
+ class ae extends R {
272
272
  constructor(e = "", t) {
273
- super(e, t), this.setComponent(B(de)), this.use(xe, !0);
274
- }
275
- set script(e) {
276
- if (this.state.script && this.allowMultipleConnections) {
277
- const t = this.state.script;
278
- t.startsWith("[") && t.endsWith("]") ? e = JSON.stringify([e, ...JSON.parse(t)]) : e = [e, t].join(", ");
279
- }
280
- this.state.script = e;
273
+ super(e, t), this.setComponent(z(ye)), this.use(De, !0);
281
274
  }
282
275
  get value() {
283
276
  return super.value;
@@ -286,72 +279,77 @@ class Q extends G {
286
279
  super.value = e, this.name !== "_code" && this.setHidden(!1);
287
280
  }
288
281
  }
289
- const Ve = new H("boolean"), Tt = new H("dict"), ze = new H("list"), U = new H("node"), le = new H("number"), ue = new H("string"), je = new H("tuple"), Nn = (s) => {
290
- new Qe(s.editor, { viewPlugin: s }).addTypes(Ve, Tt, ze, U, le, ue, je);
282
+ const Ke = new X("boolean"), sn = new X("dict"), Xe = new X("list"), U = new X("node"), Ce = new X("number"), Ie = new X("string"), qe = new X("tuple"), mo = (n) => {
283
+ new Ot(n.editor, { viewPlugin: n }).addTypes(Ke, sn, Xe, U, Ce, Ie, qe);
291
284
  };
292
- class xn extends Q {
285
+ class fo extends ae {
293
286
  constructor(e, t) {
294
- super(e, t), this.setComponent(B(Ze)), this.use(T, Ve);
287
+ super(e, t), this.setComponent(z($t)), this.use($, Ke);
295
288
  }
296
289
  getValue = () => this.value ? "True" : "False";
297
290
  }
298
- class Le extends G {
291
+ class on extends R {
299
292
  isCodeNodeOutput = !0;
293
+ suffix = "";
300
294
  constructor(e = "", t = "") {
301
- super(e, t), this.setComponent(B(de));
295
+ super(e, ""), this.suffix = t, this.setComponent(z(ye));
302
296
  }
303
- get script() {
304
- return this.name ? this.name : this.state.script;
297
+ get codeValue() {
298
+ return this.node?.outputs._code.value ?? "";
299
+ }
300
+ get node() {
301
+ const { graph: e } = ge();
302
+ return e.value.findNodeById(this.nodeId);
305
303
  }
306
304
  }
307
- class ce extends Q {
305
+ class we extends ae {
308
306
  min;
309
307
  max;
310
- constructor(e, t, n, o) {
311
- super(e, t), this.min = n, this.max = o, this.use(T, le);
308
+ constructor(e, t, s, o) {
309
+ super(e, t), this.min = s, this.max = o, this.use($, Ce);
312
310
  }
313
311
  validate(e) {
314
312
  return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
315
313
  }
316
314
  }
317
- class Mn extends ce {
318
- component = B(et);
315
+ class vo extends we {
316
+ component = z(Mt);
319
317
  validate(e) {
320
318
  return Number.isInteger(e) && super.validate(e);
321
319
  }
322
320
  }
323
- class On extends Q {
321
+ class go extends ae {
324
322
  constructor(e = "", t = "") {
325
- super(e, t), this.setComponent(B(Me)), this.use(T, ze);
323
+ super(e, t), this.setComponent(z(Fe)), this.use($, Xe);
326
324
  }
327
325
  getValue = () => `[${this.value}]`;
328
326
  }
329
- class $n extends ce {
330
- component = B(tt);
327
+ class bo extends we {
328
+ component = z(Gt);
331
329
  }
332
- class pe extends Q {
330
+ class ke extends ae {
333
331
  constructor(e, t) {
334
- super(e, t), this.use(T, ue);
332
+ super(e, t), this.use($, Ie);
335
333
  }
336
334
  getValue = () => `"${this.value}"`;
337
335
  }
338
- class Tn extends pe {
339
- component = B(st);
336
+ class _o extends ke {
337
+ component = z(St);
340
338
  items;
341
- constructor(e, t, n) {
342
- super(e, t), this.items = n;
339
+ constructor(e, t, s) {
340
+ super(e, t), this.items = s;
343
341
  }
344
342
  }
345
- class En extends ce {
346
- component = B(nt);
343
+ class yo extends we {
344
+ component = z(Pt);
347
345
  min;
348
346
  max;
349
- constructor(e, t, n, o) {
350
- super(e, t, n, o), this.min = n, this.max = o;
347
+ constructor(e, t, s, o) {
348
+ super(e, t, s, o), this.min = s, this.max = o;
351
349
  }
352
350
  getValue = () => `${Math.round(this.value * 1e3) / 1e3}`;
353
351
  }
354
- const Et = R({
352
+ const an = F({
355
353
  props: {
356
354
  intf: {
357
355
  type: Object,
@@ -363,127 +361,119 @@ const Et = R({
363
361
  }
364
362
  },
365
363
  emits: ["update:modelValue"],
366
- setup(s, { emit: e }) {
367
- return { v: b({
368
- get: () => s.modelValue,
369
- set: (n) => {
370
- e("update:modelValue", n);
364
+ setup(n, { emit: e }) {
365
+ return { v: O({
366
+ get: () => n.modelValue,
367
+ set: (s) => {
368
+ e("update:modelValue", s);
371
369
  }
372
370
  }) };
373
371
  }
374
- }), O = (s, e) => {
375
- const t = s.__vccOpts || s;
376
- for (const [n, o] of e)
377
- t[n] = o;
372
+ }), P = (n, e) => {
373
+ const t = n.__vccOpts || n;
374
+ for (const [s, o] of e)
375
+ t[s] = o;
378
376
  return t;
379
- }, St = { style: { position: "relative" } }, Bt = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, Vt = ["placeholder", "title"];
380
- function zt(s, e, t, n, o, a) {
381
- return i(), d("div", St, [
382
- l("label", Bt, j(s.intf.name), 1),
383
- ee(l("input", {
384
- "onUpdate:modelValue": e[0] || (e[0] = (r) => s.v = r),
377
+ }, rn = { style: { position: "relative" } }, dn = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, ln = ["placeholder", "title"];
378
+ function un(n, e, t, s, o, a) {
379
+ return d(), p("div", rn, [
380
+ u("label", dn, G(n.intf.name), 1),
381
+ de(u("input", {
382
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => n.v = i),
385
383
  type: "text",
386
384
  class: "baklava-input",
387
- placeholder: s.intf.name,
388
- title: s.intf.name
389
- }, null, 8, Vt), [
390
- [te, s.v]
385
+ placeholder: n.intf.name,
386
+ title: n.intf.name
387
+ }, null, 8, ln), [
388
+ [le, n.v]
391
389
  ])
392
390
  ]);
393
391
  }
394
- const jt = /* @__PURE__ */ O(Et, [["render", zt]]);
395
- class Sn extends pe {
396
- component = B(jt);
392
+ const cn = /* @__PURE__ */ P(an, [["render", un]]);
393
+ class Co extends ke {
394
+ component = z(cn);
397
395
  }
398
- class Bn extends pe {
399
- component = B(ot);
396
+ class Io extends ke {
397
+ component = z(Vt);
400
398
  }
401
- class Vn extends Q {
399
+ class wo extends ae {
402
400
  constructor(e = "", t = "") {
403
- super(e, t), this.setComponent(B(Me)), this.use(T, je);
401
+ super(e, t), this.setComponent(z(Fe)), this.use($, qe);
404
402
  }
405
403
  getValue = () => `(${this.value})`;
406
404
  }
407
- function zn(s) {
408
- return class extends Se {
409
- type = s.type;
405
+ function ko(n) {
406
+ return class extends _e {
407
+ type = n.type;
410
408
  inputs = {};
411
409
  outputs = {};
412
410
  constructor() {
413
- super(), this._title = s.title ?? s.type, this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this), this.name = s.name ?? s.type, this.updateModules(s.modules), s.variableName != null && (this.state.variableName = s.variableName), s.codeTemplate && (this.codeTemplate = s.codeTemplate), this.addInput(
411
+ super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate.call(this, { inputs: e, ...t })), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.variableName != null && (this.state.variableName = n.variableName), n.codeTemplate && (this.codeTemplate = n.codeTemplate), this.addInput(
414
412
  "_code",
415
- new G("", []).use(T, U).use(A).setHidden(!0)
413
+ new R("", []).use($, U).use(Q).setHidden(!0)
416
414
  ), this.addOutput(
417
415
  "_code",
418
- new G("", []).use(T, U).use(A).setHidden(!0)
416
+ new R("", []).use($, U).use(Q).setHidden(!0)
419
417
  );
420
418
  }
421
419
  onPlaced() {
422
- s.onPlaced?.call(this);
420
+ n.onPlaced?.call(this);
423
421
  }
424
422
  onConnected() {
425
- s.onConnected?.call(this);
423
+ n.onConnected?.call(this);
426
424
  }
427
425
  onDestroy() {
428
- s.onDestroy?.call(this);
426
+ n.onDestroy?.call(this);
429
427
  }
430
428
  onUnconnected() {
431
- s.onUnconnected?.call(this);
429
+ n.onUnconnected?.call(this);
432
430
  }
433
431
  update() {
434
- s.update?.call(this);
432
+ n.update?.call(this);
435
433
  }
436
434
  executeFactory(e, t) {
437
- Object.keys(t || {}).forEach((n) => {
438
- const o = t[n]();
439
- e === "input" ? this.addInput(n, o) : this.addOutput(n, o);
435
+ Object.keys(t || {}).forEach((s) => {
436
+ const o = t[s]();
437
+ e === "input" ? this.addInput(s, o) : this.addOutput(s, o);
440
438
  });
441
439
  }
442
440
  };
443
441
  }
444
- class Lt extends Se {
445
- /**
446
- * The default implementation does nothing.
447
- * Overwrite this method to do calculation.
448
- * @param inputs Values of all input interfaces
449
- * @param globalValues Set of values passed to every node by the engine plugin
450
- * @return Values for output interfaces
451
- */
452
- calculate;
442
+ class pn extends _e {
453
443
  }
454
- function jn(s) {
455
- return class extends Lt {
456
- type = s.type;
444
+ function No(n) {
445
+ return class extends pn {
446
+ type = n.type;
457
447
  inputs = {};
458
448
  outputs = {};
459
449
  preventUpdate = !1;
460
- staticInputKeys = Object.keys(s.inputs ?? {});
461
- staticOutputKeys = Object.keys(s.outputs ?? {});
450
+ staticInputKeys = Object.keys(n.inputs ?? {});
451
+ staticOutputKeys = Object.keys(n.outputs ?? {});
462
452
  constructor() {
463
- super(), this._title = s.title ?? s.type, this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this), this.name = s.name ?? s.type, this.updateModules(s.modules), s.codeTemplate && (this.codeTemplate = s.codeTemplate), s.variableName && (this.state.variableName = s.variableName), this.addInput(
453
+ super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate?.call(this, e, t)), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.codeTemplate && (this.codeTemplate = n.codeTemplate), n.variableName && (this.state.variableName = n.variableName), this.addInput(
464
454
  "_code",
465
- new G("", []).use(T, U).use(A).setHidden(!0)
455
+ new R("", []).use($, U).use(Q).setHidden(!0)
466
456
  ), this.addOutput(
467
457
  "_code",
468
- new G("", []).use(T, U).use(A).setHidden(!0)
458
+ new R("", []).use($, U).use(Q).setHidden(!0)
469
459
  ), this.staticInputKeys.push("_code"), this.staticOutputKeys.push("_code");
470
460
  }
471
461
  onPlaced() {
472
462
  this.events.update.subscribe(this, (e) => {
473
463
  e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
474
- }), this.onUpdate(), s.onPlaced?.call(this);
464
+ }), this.onUpdate(), n.onPlaced?.call(this);
475
465
  }
476
466
  onConnected() {
477
- s.onConnected?.call(this);
467
+ n.onConnected?.call(this);
478
468
  }
479
469
  onDestroy() {
480
- s.onDestroy?.call(this);
470
+ n.onDestroy?.call(this);
481
471
  }
482
472
  onUnconnected() {
483
- s.onUnconnected?.call(this);
473
+ n.onUnconnected?.call(this);
484
474
  }
485
475
  update() {
486
- s.update?.call(this);
476
+ n.update?.call(this);
487
477
  }
488
478
  load(e) {
489
479
  this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
@@ -495,56 +485,105 @@ function jn(s) {
495
485
  for (const t of Object.keys(e.inputs))
496
486
  if (!this.staticInputKeys.includes(t)) {
497
487
  if (!this.inputs[t]) {
498
- const n = e.inputs[t].value;
488
+ const s = e.inputs[t].value;
499
489
  let o;
500
- typeof n == "number" ? o = new at(t, n).use(T, le) : o = new it(t, JSON.stringify(n)).use(T, ue), o.use(xe, !0), this.addInput(t, o);
490
+ typeof s == "number" ? o = new Rt(t, s).use($, Ce) : o = new be(t, JSON.stringify(s)).use($, Ie), o.use(De, !0), this.addInput(t, o);
501
491
  }
502
492
  this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
503
493
  }
504
494
  for (const t of Object.keys(e.outputs))
505
495
  if (!this.staticOutputKeys.includes(t)) {
506
496
  if (!this.outputs[t]) {
507
- const n = new Le(t);
508
- this.addOutput(t, n);
497
+ const s = new on(t);
498
+ this.addOutput(t, s);
509
499
  }
510
500
  this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
511
501
  }
512
- Be(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
502
+ Ye(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
513
503
  }
514
504
  onUpdate() {
515
505
  if (this.preventUpdate) return;
516
506
  this.graph && this.graph.activeTransactions++;
517
- const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), n = s.onUpdate.call(this, e, t);
518
- this.updateInterfaces("input", n.inputs ?? {}, n.forceUpdateInputs ?? []), this.updateInterfaces("output", n.outputs ?? {}, n.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
507
+ const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), s = n.onUpdate.call(this, e, t);
508
+ this.updateInterfaces("input", s.inputs ?? {}, s.forceUpdateInputs ?? []), this.updateInterfaces("output", s.outputs ?? {}, s.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
519
509
  }
520
510
  getStaticValues(e, t) {
521
- const n = {};
511
+ const s = {};
522
512
  for (const o of e)
523
- n[o] = t[o].value;
524
- return n;
513
+ s[o] = t[o].value;
514
+ return s;
525
515
  }
526
- updateInterfaces(e, t, n) {
516
+ updateInterfaces(e, t, s) {
527
517
  const o = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
528
- for (const r of Object.keys(a))
529
- o.includes(r) || t[r] && !n.includes(r) || (e === "input" ? this.removeInput(r) : this.removeOutput(r));
530
- for (const r of Object.keys(t)) {
531
- if (a[r]) continue;
532
- const u = t[r]();
533
- e === "input" ? this.addInput(r, u) : this.addOutput(r, u);
518
+ for (const i of Object.keys(a))
519
+ o.includes(i) || t[i] && !s.includes(i) || (e === "input" ? this.removeInput(i) : this.removeOutput(i));
520
+ for (const i of Object.keys(t)) {
521
+ if (a[i]) continue;
522
+ const r = t[i]();
523
+ e === "input" ? this.addInput(i, r) : this.addOutput(i, r);
534
524
  }
535
525
  }
536
526
  updateProps(e) {
537
527
  this.state.props = e, this.onUpdate();
538
528
  }
539
529
  executeFactory(e, t) {
540
- Object.keys(t || {}).forEach((n) => {
541
- const o = t[n]();
542
- e === "input" ? this.addInput(n, o) : this.addOutput(n, o);
530
+ Object.keys(t || {}).forEach((s) => {
531
+ const o = t[s]();
532
+ e === "input" ? this.addInput(s, o) : this.addOutput(s, o);
543
533
  });
544
534
  }
545
535
  };
546
536
  }
547
- const Ln = "__baklava_GraphNode-", Gt = [
537
+ const Se = "__baklava_SubgraphInputNode", Pe = "__baklava_SubgraphOutputNode";
538
+ class Je extends _e {
539
+ graphInterfaceId;
540
+ constructor() {
541
+ super(), this.graphInterfaceId = K();
542
+ }
543
+ onPlaced() {
544
+ super.onPlaced(), this.initializeIo();
545
+ }
546
+ load(e) {
547
+ super.load(e), this.graphInterfaceId = e.graphInterfaceId;
548
+ }
549
+ save() {
550
+ return {
551
+ ...super.save(),
552
+ graphInterfaceId: this.graphInterfaceId
553
+ };
554
+ }
555
+ update() {
556
+ }
557
+ }
558
+ class Qe extends Je {
559
+ static isGraphInputNode(e) {
560
+ return e.type === Se;
561
+ }
562
+ type = Se;
563
+ inputs = {
564
+ name: new A("Name", "Input")
565
+ };
566
+ outputs = {
567
+ placeholder: new A("Value", void 0)
568
+ };
569
+ }
570
+ class Ze extends Je {
571
+ static isGraphOutputNode(e) {
572
+ return e.type === Pe;
573
+ }
574
+ type = Pe;
575
+ inputs = {
576
+ name: new A("Name", "Output"),
577
+ placeholder: new A("Value", void 0)
578
+ };
579
+ outputs = {
580
+ output: new A("Output", void 0).setHidden(!0)
581
+ };
582
+ calculate = ({ placeholder: e }) => ({
583
+ output: e
584
+ });
585
+ }
586
+ const hn = [
548
587
  "component",
549
588
  "connectionCount",
550
589
  "events",
@@ -559,9 +598,9 @@ const Ln = "__baklava_GraphNode-", Gt = [
559
598
  "templateId",
560
599
  "value"
561
600
  ];
562
- function Rt(s) {
563
- return class extends Ee {
564
- type = rt(s);
601
+ function mn(n) {
602
+ return class extends We {
603
+ type = Ue(n);
565
604
  get title() {
566
605
  return this._title;
567
606
  }
@@ -570,55 +609,39 @@ function Rt(s) {
570
609
  }
571
610
  inputs = {};
572
611
  outputs = {};
573
- template = s;
612
+ template = n;
574
613
  subgraph;
575
- // public override calculate: CalculateFunction<Record<string, unknown>, Record<string, unknown>> = async (
576
- // inputs,
577
- // context,
578
- // ) => {
579
- // if (!this.subgraph) {
580
- // throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`)
581
- // }
582
- // if (!context.engine || typeof context.engine !== 'object') {
583
- // throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`)
584
- // }
585
- // const graphInputs = context.engine.getInputValues(this.subgraph)
586
- // // fill subgraph input placeholders
587
- // for (const input of this.subgraph.inputs) {
588
- // graphInputs.set(input.nodeInterfaceId, inputs[input.id])
589
- // }
590
- // const result: Map<string, Map<string, unknown>> = await context.engine.runGraph(
591
- // this.subgraph,
592
- // graphInputs,
593
- // context.globalValues,
594
- // )
595
- // const outputs: Record<string, unknown> = {}
596
- // for (const output of this.subgraph.outputs) {
597
- // outputs[output.id] = result.get(output.nodeId)?.get('output')
598
- // }
599
- // outputs._calculationResults = result
600
- // outputs['_code'] = inputs['_code']
601
- // return outputs
602
- // }
603
- /**
604
- * Render code script of code nodes.
605
- */
606
- renderCodes() {
607
- if (!this.subgraph) return;
608
- this.subgraph.nodes.filter((n) => n.isCodeNode).forEach((n) => n.renderCode());
609
- const t = this.subgraph.nodes;
610
- this.state.script = Y.render(this.code.state.template || "", { nodes: t });
614
+ update() {
615
+ }
616
+ onConnected() {
617
+ }
618
+ onUnconnected() {
611
619
  }
620
+ calculate = async (t, s) => {
621
+ if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
622
+ if (!s.engine || typeof s.engine != "object")
623
+ throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
624
+ const o = s.engine.getInputValues(this.subgraph);
625
+ for (const r of this.subgraph.inputs)
626
+ o.set(r.nodeInterfaceId, t[r.id]);
627
+ const a = await s.engine.runGraph(
628
+ this.subgraph,
629
+ o,
630
+ s.globalValues
631
+ );
632
+ s.engine.pause(), Ae(a, s.engine.editor), s.engine.resume();
633
+ const i = {};
634
+ for (const r of this.subgraph.outputs)
635
+ i[r.id] = a.get(r.nodeId)?.get("output");
636
+ return i._calculationResults = a, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
637
+ };
612
638
  load(t) {
613
- if (!this.subgraph)
614
- throw new Error("Cannot load a graph node without a graph");
615
- if (!this.template)
616
- throw new Error("Unable to load graph node without graph template");
639
+ if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
640
+ if (!this.template) throw new Error("Unable to load graph node without graph template");
617
641
  this.subgraph.load(t.graphState), super.load(t);
618
642
  }
619
643
  save() {
620
- if (!this.subgraph)
621
- throw new Error("Cannot save a graph node without a graph");
644
+ if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
622
645
  return {
623
646
  ...super.save(),
624
647
  graphState: this.subgraph.save()
@@ -629,92 +652,79 @@ function Rt(s) {
629
652
  this._title = t;
630
653
  }), this.initialize();
631
654
  }
632
- onConnected() {
633
- }
634
655
  onDestroy() {
635
656
  this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
636
657
  }
637
- onUnconnected() {
638
- }
639
658
  initialize() {
640
- this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.events.update.emit(null);
659
+ this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
660
+ {{ /nodes }}`, this.events.update.emit(null);
661
+ }
662
+ /**
663
+ * Render code of this node.
664
+ */
665
+ renderCode(t) {
666
+ return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : Z.render(this.state.codeTemplate, t);
641
667
  }
642
668
  updateInterfaces() {
643
- if (!this.subgraph)
644
- throw new Error("Trying to update interfaces without graph instance");
669
+ if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
645
670
  for (const t of this.subgraph.inputs)
646
671
  t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
647
672
  for (const t of Object.keys(this.inputs))
648
- this.subgraph.inputs.some((n) => n.id === t) || this.removeInput(t);
673
+ this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
649
674
  for (const t of this.subgraph.outputs)
650
675
  t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
651
676
  for (const t of Object.keys(this.outputs))
652
- this.subgraph.outputs.some((n) => n.id === t) || this.removeOutput(t);
677
+ this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
653
678
  this.addInput(
654
679
  "_code",
655
- new G("", []).use(T, U).use(A).setHidden(!0)
680
+ new R("", []).use($, U).use(Q).setHidden(!0)
656
681
  ), this.addOutput(
657
682
  "_code",
658
- new G("", []).use(T, U).use(A).setHidden(!0)
659
- ), this.addOutput(
660
- "_calculationResults",
661
- new Le("_calculationResults", void 0).setHidden(!0)
662
- );
683
+ new R("", []).use($, U).use(Q).setHidden(!0)
684
+ ), this.addOutput("_calculationResults", new A("_calculationResults", void 0).setHidden(!0));
663
685
  }
664
686
  /**
665
687
  * When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
666
688
  * For example, the `type` property or the `allowMultipleConnections` property.
667
689
  * These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
668
690
  */
669
- createProxyInterface(t, n) {
670
- const o = new G(t.name, void 0);
691
+ createProxyInterface(t, s) {
692
+ const o = new R(t.name, void 0);
671
693
  return new Proxy(o, {
672
- get: (a, r) => {
673
- if (Gt.includes(r) || r in a || typeof r == "string" && r.startsWith("__v_"))
674
- return Reflect.get(a, r);
675
- let u;
676
- n ? u = this.subgraph?.nodes.find(
677
- (I) => dt.isGraphInputNode(I) && I.graphInterfaceId === t.id
678
- )?.outputs.placeholder.id : u = this.subgraph?.nodes.find(
679
- (I) => lt.isGraphOutputNode(I) && I.graphInterfaceId === t.id
694
+ get: (a, i) => {
695
+ if (hn.includes(i) || i in a || typeof i == "string" && i.startsWith("__v_"))
696
+ return Reflect.get(a, i);
697
+ let r;
698
+ s ? r = this.subgraph?.nodes.find(
699
+ (_) => Qe.isGraphInputNode(_) && _.graphInterfaceId === t.id
700
+ )?.outputs.placeholder.id : r = this.subgraph?.nodes.find(
701
+ (_) => Ze.isGraphOutputNode(_) && _.graphInterfaceId === t.id
680
702
  )?.inputs.placeholder.id;
681
- const p = this.subgraph?.connections.find((g) => u === (n ? g.from : g.to)?.id), _ = n ? p?.to : p?.from;
682
- if (_)
683
- return Reflect.get(_, r);
703
+ const c = this.subgraph?.connections.find((g) => r === (s ? g.from : g.to)?.id), h = s ? c?.to : c?.from;
704
+ if (h) return Reflect.get(h, i);
684
705
  }
685
706
  });
686
707
  }
687
708
  };
688
709
  }
689
- Y.escape = (s) => s;
690
- class Pt {
710
+ Z.escape = (n) => n;
711
+ class fn {
691
712
  _id;
692
- _viewModel;
693
713
  _state;
694
- constructor(e) {
695
- this._id = Te(), this._viewModel = e, this._state = q({
696
- autosort: !1,
714
+ viewModel;
715
+ constructor() {
716
+ this._id = K(), this._state = D({
697
717
  lockCode: !1,
698
718
  modules: {},
699
719
  script: "",
700
- template: "",
701
- token: null
720
+ template: ""
702
721
  });
703
722
  }
704
- get codeNodes() {
705
- return oe(this.graph);
706
- }
707
- get codeNodeIds() {
708
- return this.codeNodes.map((e) => e.id);
709
- }
710
- get connections() {
711
- return this.graph.connections;
712
- }
713
- set connections(e) {
714
- this.graph._connections = e;
723
+ get engine() {
724
+ return this.viewModel?.engine;
715
725
  }
716
726
  get graph() {
717
- return this.viewModel.displayedGraph;
727
+ return this.viewModel?.editor.graph;
718
728
  }
719
729
  get id() {
720
730
  return this._id;
@@ -723,33 +733,17 @@ class Pt {
723
733
  return this.state.lockCode;
724
734
  }
725
735
  set lockCode(e) {
726
- this.state.lockCode = e, this.viewModel.engine.runOnce(null);
736
+ this.state.lockCode = e, this.engine?.runOnce(null);
727
737
  }
728
738
  get modules() {
729
739
  const e = [];
730
- return this.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => e.push(...t.state.modules)), e ? (e.sort(), Array.from(
731
- new Set(e.map((t) => this.viewModel.state.modules[t]))
732
- )) : [];
733
- }
734
- get nodeIds() {
735
- return this.nodes.map((e) => e.id);
736
- }
737
- get nodes() {
738
- return this.graph.nodes;
739
- }
740
- set nodes(e) {
741
- this.graph._nodes = e;
740
+ return this.graph?.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => e.push(...t.state.modules)), e ? (e.sort(), Array.from(new Set(e.map((t) => this.state.modules[t])))) : [];
742
741
  }
743
742
  get script() {
744
743
  return this.state.script;
745
744
  }
746
745
  set script(e) {
747
- this.state.script = e;
748
- }
749
- get scriptedCodeNodes() {
750
- return oe(this.graph).filter(
751
- (e) => !e.state?.integrated
752
- );
746
+ this.state.script = e, this.engine?.runOnce(null);
753
747
  }
754
748
  get shortId() {
755
749
  return this.id.slice(0, 6);
@@ -757,86 +751,11 @@ class Pt {
757
751
  get state() {
758
752
  return this._state;
759
753
  }
760
- get viewModel() {
761
- return this._viewModel;
762
- }
763
- get visibleNodes() {
764
- return this.codeNodes.filter((e) => !e.state?.hidden);
765
- }
766
- /**
767
- * Add code node to graph.
768
- * @param node code node
769
- * @param props optional
770
- */
771
- addNode(e, t) {
772
- return e.code || (e.code = this), t && (e.state.props = t), this.graph.addNode(e);
773
- }
774
- /**
775
- * Add code node at coordinates.
776
- * @param node code node
777
- * @param position position
778
- * @param props optional
779
- * @returns code node
780
- */
781
- addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, n) => (this.addNode(e, n), e.position && (e.position = t), e);
782
- /**
783
- * Add connection of code nodes
784
- * @param from code node interface
785
- * @param to code node interface
786
- */
787
- addConnection(e, t) {
788
- e.name !== "_code" && (e.hidden = !1), t.name !== "_code" && (t.hidden = !1), this.graph.addConnection(e, t);
789
- }
790
754
  /**
791
- * Clear code graph.
755
+ * Clear code.
792
756
  */
793
757
  clear() {
794
- this.viewModel.commandHandler.executeCommand(Z.CLEAR_CLIPBOARD_COMMAND), this.viewModel.commandHandler.executeCommand(Z.CLEAR_HISTORY_COMMAND), this.state.modules = {}, this.nodes = [], this.connections = [], this.state.script = "";
795
- }
796
- /**
797
- * Find node by ID.
798
- * @param id node ID
799
- * @returns node instance
800
- */
801
- findNodeById(e) {
802
- return this.graph.findNodeById(e);
803
- }
804
- /**
805
- * Find node by type.
806
- * @param nodeType node type
807
- * @returns node instance
808
- */
809
- findNodeByType(e) {
810
- return this.codeNodes.find((t) => t.type === e);
811
- }
812
- /**
813
- * Get nodes of the same type.
814
- * @param type node type
815
- * @returns a list of node instances
816
- */
817
- getNodesBySameType(e) {
818
- return this.codeNodes.filter((t) => t.type === e);
819
- }
820
- /**
821
- * Get nodes of the same variable name.
822
- * @param variableName variable name
823
- * @returns a list of node instances
824
- */
825
- getNodesBySameVariableNames(e) {
826
- return this.codeNodes.filter(
827
- (t) => t.state.variableName === e
828
- );
829
- }
830
- /**
831
- * Check whether the graph has this connection.
832
- * @param from node interface
833
- * @param to node interface
834
- * @returns boolean
835
- */
836
- hasConnection(e, t) {
837
- return this.connections.some(
838
- (n) => n.from.id === e.id && n.to.id === t.id
839
- );
758
+ this.state.script = "";
840
759
  }
841
760
  /**
842
761
  * Load template from the file.
@@ -848,116 +767,91 @@ class Pt {
848
767
  });
849
768
  }
850
769
  /**
851
- * Remove connection from the graph
852
- * @param connection connection between code nodes
770
+ * Register code view model instance.
771
+ * @param viewModel view model
853
772
  */
854
- removeConnection(e) {
855
- this.graph.removeConnection(e);
856
- }
857
- /**
858
- * Remove node from the graph.
859
- * @param codeNode code node
860
- */
861
- removeNode(e) {
862
- this.graph.removeNode(e);
863
- }
864
- /**
865
- * Render code script of code nodes.
866
- */
867
- renderNodeCodes() {
868
- this.state.lockCode || this.codeNodes.length === 0 || this.codeNodes.forEach((e) => e.renderCode());
773
+ registerViewModel(e) {
774
+ this.viewModel = e;
869
775
  }
870
776
  /**
871
777
  * Render code script.
872
778
  */
873
- renderCode() {
874
- if (this.state.lockCode) return;
875
- const e = this.scriptedCodeNodes, t = this.modules;
876
- this.state.script = Y.render(this.state.template || "", { nodes: e, modules: t });
877
- }
878
- /**
879
- * Reset scripts of intput interfaces.
880
- */
881
- resetInputInterfaceScript() {
882
- this.codeNodes.forEach((e) => e.resetInputInterfaceScript());
779
+ renderCode(e) {
780
+ this.state.script = Z.render(this.state.template || "", e);
883
781
  }
884
- /**
885
- * Sort code nodes.
886
- */
887
- sortNodes() {
888
- if (!(this.nodes.length === 0 || this.connections.length === 0))
889
- try {
890
- let e = this.nodeIds;
891
- const t = this.connections.filter(
892
- (a) => e.includes(a.to.nodeId) && e.includes(a.from.nodeId)
893
- ).map((a) => [a.to.nodeId, a.from.nodeId]);
894
- e.reverse(), e = Ye.array(e, t), e.reverse();
895
- const n = this.graph.nodes.map((a) => a.id).filter((a) => !e.includes(a));
896
- e = [...e, ...n];
897
- const o = e.map((a) => this.findNodeById(a));
898
- o && (this.nodes = o);
899
- } catch {
900
- console.warn("Failed to sort nodes.");
782
+ }
783
+ const Oo = (n) => {
784
+ n.allowMultipleConnections = !0;
785
+ };
786
+ class vn extends Tt {
787
+ order = /* @__PURE__ */ new Map();
788
+ constructor(e) {
789
+ super(e);
790
+ }
791
+ start() {
792
+ super.start(), this.recalculateOrder = !0, this.calculateWithoutData();
793
+ }
794
+ async runGraph(e, t, s) {
795
+ this.order.has(e.id) || this.order.set(e.id, Et(e));
796
+ const { calculationOrder: o, connectionsFromNode: a } = this.order.get(e.id), i = /* @__PURE__ */ new Map();
797
+ for (const r of o) {
798
+ const c = {};
799
+ Object.entries(r.inputs).forEach(([g, _]) => {
800
+ c[g] = this.getInterfaceValue(t, _.id);
801
+ }), r.isCodeNode && (r.updateCodeTemplate(), r.updateOutputNames()), this.events.beforeNodeCalculation.emit({ inputValues: c, node: r });
802
+ let h;
803
+ if (r.calculate) {
804
+ if (h = await r.calculate(c, { globalValues: s, engine: this }), a.has(r))
805
+ for (const [g, _] of Object.entries(h))
806
+ this.hooks.transferData.execute(h[g], _), a.get(r).forEach((m) => {
807
+ t.set(m.to.id, _);
808
+ });
809
+ } else {
810
+ h = {};
811
+ for (const [g, _] of Object.entries(r.outputs))
812
+ h[g] = this.getInterfaceValue(t, _.id);
901
813
  }
814
+ this.events.afterNodeCalculation.emit({ outputValues: h, node: r }), i.set(r.id, new Map(Object.entries(h))), a.has(r) && a.get(r).forEach((g) => {
815
+ const _ = Object.entries(r.outputs).find(([, k]) => k.id === g.from.id)?.[0];
816
+ if (!_)
817
+ throw new Error(
818
+ `Could not find key for interface ${g.from.id}
819
+ This is likely an internal issue. Please report it on GitHub.`
820
+ );
821
+ const m = this.hooks.transferData.execute(h[_], g);
822
+ g.to.allowMultipleConnections ? t.has(g.to.id) ? t.get(g.to.id).push(m) : t.set(g.to.id, [m]) : t.set(g.to.id, m);
823
+ });
824
+ }
825
+ return i;
826
+ }
827
+ async execute(e) {
828
+ this.recalculateOrder && (this.order.clear(), this.recalculateOrder = !1);
829
+ const t = this.getInputValues(this.editor.graph);
830
+ return await this.runGraph(this.editor.graph, t, e);
831
+ }
832
+ getInputValues(e) {
833
+ const t = /* @__PURE__ */ new Map();
834
+ for (const s of e.nodes)
835
+ Object.values(s.inputs).forEach((o) => {
836
+ o.connectionCount === 0 && t.set(o.id, o.getValue ? o.getValue() : o.value);
837
+ }), s.calculate || Object.values(s.outputs).forEach((o) => {
838
+ t.set(o.id, o.getValue ? o.getValue() : o.value);
839
+ });
840
+ return t;
902
841
  }
903
- /**
904
- * Update code nodes.
905
- */
906
- updateCodeNodes() {
907
- this.codeNodes.forEach((e) => e.update());
842
+ onChange(e) {
843
+ this.recalculateOrder = e || this.recalculateOrder, this.calculateWithoutData();
908
844
  }
909
- /**
910
- * Update code templates.
911
- */
912
- updateCodeTemplates() {
913
- this.codeNodes.forEach((e) => e.updateCodeTemplate());
845
+ getInterfaceValue(e, t) {
846
+ if (!e.has(t))
847
+ throw new Error(
848
+ `Could not find value for interface ${t}
849
+ This is likely an internal issue. Please report it on GitHub.`
850
+ );
851
+ return e.get(t);
914
852
  }
915
853
  }
916
- const oe = (s) => {
917
- const e = [];
918
- return s.nodes.length === 0 || s.nodes.forEach((t) => {
919
- t && (t.hasOwnProperty("subgraph") ? e.push(...oe(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
920
- }), e;
921
- }, Rn = (s = 0, e = 100) => ({
922
- x: s * 420,
923
- y: e
924
- }), Pn = (s) => {
925
- const e = { ...s.position };
926
- return e.x -= 440, e.y += 50, e;
927
- }, Ut = ["id"], Ht = { class: "align-middle" }, we = /* @__PURE__ */ R({
928
- __name: "CodeGraphNodeInterface",
929
- props: {
930
- node: {},
931
- intf: {}
932
- },
933
- setup(s) {
934
- const e = s, { viewModel: t } = K(), { hoveredOver: n, temporaryConnection: o } = ut(), a = V(null), r = b(() => e.intf.connectionCount > 0), u = b(() => ({
935
- "--connected": r.value
936
- })), p = () => {
937
- n(e.intf);
938
- }, _ = () => {
939
- n(void 0);
940
- }, g = () => {
941
- a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
942
- };
943
- return ie(g), Oe(g), (I, L) => (i(), d("div", {
944
- id: s.intf.id,
945
- ref_key: "el",
946
- ref: a,
947
- class: P(["baklava-node-interface", u.value])
948
- }, [
949
- s.intf.port ? (i(), d("div", {
950
- key: 0,
951
- class: P(["__port", { "--selected": k(o)?.from === s.intf }]),
952
- onPointerover: p,
953
- onPointerout: _
954
- }, null, 34)) : N("", !0),
955
- l("span", Ht, [
956
- X(I.$slots, "default")
957
- ])
958
- ], 10, Ut));
959
- }
960
- }), At = {}, Dt = {
854
+ const gn = {}, bn = {
961
855
  xmlns: "http://www.w3.org/2000/svg",
962
856
  width: "24",
963
857
  height: "24",
@@ -969,17 +863,17 @@ const oe = (s) => {
969
863
  "stroke-linejoin": "round",
970
864
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
971
865
  };
972
- function Ft(s, e) {
973
- return i(), d("svg", Dt, [...e[0] || (e[0] = [
974
- l("path", {
866
+ function _n(n, e) {
867
+ return d(), p("svg", bn, [...e[0] || (e[0] = [
868
+ u("path", {
975
869
  stroke: "none",
976
870
  d: "M0 0h24v24H0z",
977
871
  fill: "none"
978
872
  }, null, -1),
979
- l("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
873
+ u("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
980
874
  ])]);
981
875
  }
982
- const Wt = /* @__PURE__ */ O(At, [["render", Ft]]), Xt = {}, Yt = {
876
+ const yn = /* @__PURE__ */ P(gn, [["render", _n]]), Cn = {}, In = {
983
877
  xmlns: "http://www.w3.org/2000/svg",
984
878
  width: "24",
985
879
  height: "24",
@@ -991,19 +885,19 @@ const Wt = /* @__PURE__ */ O(At, [["render", Ft]]), Xt = {}, Yt = {
991
885
  "stroke-linejoin": "round",
992
886
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
993
887
  };
994
- function Kt(s, e) {
995
- return i(), d("svg", Yt, [...e[0] || (e[0] = [
996
- l("path", {
888
+ function wn(n, e) {
889
+ return d(), p("svg", In, [...e[0] || (e[0] = [
890
+ u("path", {
997
891
  stroke: "none",
998
892
  d: "M0 0h24v24H0z",
999
893
  fill: "none"
1000
894
  }, null, -1),
1001
- l("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
1002
- l("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
1003
- l("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
895
+ u("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
896
+ u("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
897
+ u("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
1004
898
  ])]);
1005
899
  }
1006
- const qt = /* @__PURE__ */ O(Xt, [["render", Kt]]), Jt = {}, Qt = {
900
+ const kn = /* @__PURE__ */ P(Cn, [["render", wn]]), Nn = {}, xn = {
1007
901
  xmlns: "http://www.w3.org/2000/svg",
1008
902
  width: "24",
1009
903
  height: "24",
@@ -1011,17 +905,17 @@ const qt = /* @__PURE__ */ O(Xt, [["render", Kt]]), Jt = {}, Qt = {
1011
905
  fill: "currentColor",
1012
906
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
1013
907
  };
1014
- function Zt(s, e) {
1015
- return i(), d("svg", Qt, [...e[0] || (e[0] = [
1016
- l("path", {
908
+ function On(n, e) {
909
+ return d(), p("svg", xn, [...e[0] || (e[0] = [
910
+ u("path", {
1017
911
  stroke: "none",
1018
912
  d: "M0 0h24v24H0z",
1019
913
  fill: "none"
1020
914
  }, null, -1),
1021
- 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)
915
+ u("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)
1022
916
  ])]);
1023
917
  }
1024
- const es = /* @__PURE__ */ O(Jt, [["render", Zt]]), ts = {}, ss = {
918
+ const Tn = /* @__PURE__ */ P(Nn, [["render", On]]), En = {}, $n = {
1025
919
  xmlns: "http://www.w3.org/2000/svg",
1026
920
  width: "24",
1027
921
  height: "24",
@@ -1029,17 +923,17 @@ const es = /* @__PURE__ */ O(Jt, [["render", Zt]]), ts = {}, ss = {
1029
923
  fill: "currentColor",
1030
924
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
1031
925
  };
1032
- function ns(s, e) {
1033
- return i(), d("svg", ss, [...e[0] || (e[0] = [
1034
- l("path", {
926
+ function Mn(n, e) {
927
+ return d(), p("svg", $n, [...e[0] || (e[0] = [
928
+ u("path", {
1035
929
  stroke: "none",
1036
930
  d: "M0 0h24v24H0z",
1037
931
  fill: "none"
1038
932
  }, null, -1),
1039
- 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)
933
+ u("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)
1040
934
  ])]);
1041
935
  }
1042
- const os = /* @__PURE__ */ O(ts, [["render", ns]]), as = {}, is = {
936
+ const Gn = /* @__PURE__ */ P(En, [["render", Mn]]), Sn = {}, Pn = {
1043
937
  xmlns: "http://www.w3.org/2000/svg",
1044
938
  width: "24",
1045
939
  height: "24",
@@ -1047,17 +941,17 @@ const os = /* @__PURE__ */ O(ts, [["render", ns]]), as = {}, is = {
1047
941
  fill: "currentColor",
1048
942
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
1049
943
  };
1050
- function rs(s, e) {
1051
- return i(), d("svg", is, [...e[0] || (e[0] = [
1052
- l("path", {
944
+ function Vn(n, e) {
945
+ return d(), p("svg", Pn, [...e[0] || (e[0] = [
946
+ u("path", {
1053
947
  stroke: "none",
1054
948
  d: "M0 0h24v24H0z",
1055
949
  fill: "none"
1056
950
  }, null, -1),
1057
- 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)
951
+ u("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)
1058
952
  ])]);
1059
953
  }
1060
- const ds = /* @__PURE__ */ O(as, [["render", rs]]), ls = {}, us = {
954
+ const Rn = /* @__PURE__ */ P(Sn, [["render", Vn]]), jn = {}, Bn = {
1061
955
  xmlns: "http://www.w3.org/2000/svg",
1062
956
  width: "24",
1063
957
  height: "24",
@@ -1065,17 +959,17 @@ const ds = /* @__PURE__ */ O(as, [["render", rs]]), ls = {}, us = {
1065
959
  fill: "currentColor",
1066
960
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
1067
961
  };
1068
- function cs(s, e) {
1069
- return i(), d("svg", us, [...e[0] || (e[0] = [
1070
- l("path", {
962
+ function zn(n, e) {
963
+ return d(), p("svg", Bn, [...e[0] || (e[0] = [
964
+ u("path", {
1071
965
  stroke: "none",
1072
966
  d: "M0 0h24v24H0z",
1073
967
  fill: "none"
1074
968
  }, null, -1),
1075
- 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)
969
+ u("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)
1076
970
  ])]);
1077
971
  }
1078
- const ps = /* @__PURE__ */ O(ls, [["render", cs]]), hs = {}, ms = {
972
+ const Hn = /* @__PURE__ */ P(jn, [["render", zn]]), Ln = {}, Un = {
1079
973
  xmlns: "http://www.w3.org/2000/svg",
1080
974
  width: "24",
1081
975
  height: "24",
@@ -1083,17 +977,17 @@ const ps = /* @__PURE__ */ O(ls, [["render", cs]]), hs = {}, ms = {
1083
977
  fill: "currentColor",
1084
978
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
1085
979
  };
1086
- function vs(s, e) {
1087
- return i(), d("svg", ms, [...e[0] || (e[0] = [
1088
- l("path", {
980
+ function An(n, e) {
981
+ return d(), p("svg", Un, [...e[0] || (e[0] = [
982
+ u("path", {
1089
983
  stroke: "none",
1090
984
  d: "M0 0h24v24H0z",
1091
985
  fill: "none"
1092
986
  }, null, -1),
1093
- 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)
987
+ u("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)
1094
988
  ])]);
1095
989
  }
1096
- const fs = /* @__PURE__ */ O(hs, [["render", vs]]), gs = {}, bs = {
990
+ const Dn = /* @__PURE__ */ P(Ln, [["render", An]]), Fn = {}, Wn = {
1097
991
  xmlns: "http://www.w3.org/2000/svg",
1098
992
  width: "24",
1099
993
  height: "24",
@@ -1105,12 +999,34 @@ const fs = /* @__PURE__ */ O(hs, [["render", vs]]), gs = {}, bs = {
1105
999
  "stroke-linejoin": "round",
1106
1000
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"
1107
1001
  };
1108
- function _s(s, e) {
1109
- return i(), d("svg", bs, [...e[0] || (e[0] = [
1110
- J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>', 6)
1002
+ function Yn(n, e) {
1003
+ return d(), p("svg", Wn, [...e[0] || (e[0] = [
1004
+ se('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>', 6)
1005
+ ])]);
1006
+ }
1007
+ const Kn = /* @__PURE__ */ P(Fn, [["render", Yn]]), Xn = {}, qn = {
1008
+ xmlns: "http://www.w3.org/2000/svg",
1009
+ width: "24",
1010
+ height: "24",
1011
+ viewBox: "0 0 24 24",
1012
+ fill: "none",
1013
+ stroke: "currentColor",
1014
+ "stroke-width": "2",
1015
+ "stroke-linecap": "round",
1016
+ "stroke-linejoin": "round",
1017
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"
1018
+ };
1019
+ function Jn(n, e) {
1020
+ return d(), p("svg", qn, [...e[0] || (e[0] = [
1021
+ u("path", {
1022
+ stroke: "none",
1023
+ d: "M0 0h24v24H0z",
1024
+ fill: "none"
1025
+ }, null, -1),
1026
+ u("path", { d: "M7 4v16l13 -8z" }, null, -1)
1111
1027
  ])]);
1112
1028
  }
1113
- const ys = /* @__PURE__ */ O(gs, [["render", _s]]), Cs = {}, ks = {
1029
+ const Qn = /* @__PURE__ */ P(Xn, [["render", Jn]]), Zn = {}, es = {
1114
1030
  xmlns: "http://www.w3.org/2000/svg",
1115
1031
  width: "24",
1116
1032
  height: "24",
@@ -1122,12 +1038,12 @@ const ys = /* @__PURE__ */ O(gs, [["render", _s]]), Cs = {}, ks = {
1122
1038
  "stroke-linejoin": "round",
1123
1039
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
1124
1040
  };
1125
- function ws(s, e) {
1126
- return i(), d("svg", ks, [...e[0] || (e[0] = [
1127
- J('<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)
1041
+ function ts(n, e) {
1042
+ return d(), p("svg", es, [...e[0] || (e[0] = [
1043
+ se('<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)
1128
1044
  ])]);
1129
1045
  }
1130
- const Is = /* @__PURE__ */ O(Cs, [["render", ws]]), Ns = {}, xs = {
1046
+ const ns = /* @__PURE__ */ P(Zn, [["render", ts]]), ss = {}, os = {
1131
1047
  xmlns: "http://www.w3.org/2000/svg",
1132
1048
  width: "24",
1133
1049
  height: "24",
@@ -1139,12 +1055,12 @@ const Is = /* @__PURE__ */ O(Cs, [["render", ws]]), Ns = {}, xs = {
1139
1055
  "stroke-linejoin": "round",
1140
1056
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
1141
1057
  };
1142
- function Ms(s, e) {
1143
- return i(), d("svg", xs, [...e[0] || (e[0] = [
1144
- J('<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)
1058
+ function as(n, e) {
1059
+ return d(), p("svg", os, [...e[0] || (e[0] = [
1060
+ se('<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)
1145
1061
  ])]);
1146
1062
  }
1147
- const Os = /* @__PURE__ */ O(Ns, [["render", Ms]]), $s = {}, Ts = {
1063
+ const is = /* @__PURE__ */ P(ss, [["render", as]]), rs = {}, ds = {
1148
1064
  xmlns: "http://www.w3.org/2000/svg",
1149
1065
  width: "24",
1150
1066
  height: "24",
@@ -1156,12 +1072,12 @@ const Os = /* @__PURE__ */ O(Ns, [["render", Ms]]), $s = {}, Ts = {
1156
1072
  "stroke-linejoin": "round",
1157
1073
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
1158
1074
  };
1159
- function Es(s, e) {
1160
- return i(), d("svg", Ts, [...e[0] || (e[0] = [
1161
- J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
1075
+ function ls(n, e) {
1076
+ return d(), p("svg", ds, [...e[0] || (e[0] = [
1077
+ se('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
1162
1078
  ])]);
1163
1079
  }
1164
- const Ss = /* @__PURE__ */ O($s, [["render", Es]]), Bs = {}, Vs = {
1080
+ const us = /* @__PURE__ */ P(rs, [["render", ls]]), cs = {}, ps = {
1165
1081
  xmlns: "http://www.w3.org/2000/svg",
1166
1082
  width: "24",
1167
1083
  height: "24",
@@ -1173,115 +1089,458 @@ const Ss = /* @__PURE__ */ O($s, [["render", Es]]), Bs = {}, Vs = {
1173
1089
  "stroke-linejoin": "round",
1174
1090
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
1175
1091
  };
1176
- function zs(s, e) {
1177
- return i(), d("svg", Vs, [...e[0] || (e[0] = [
1178
- J('<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)
1092
+ function hs(n, e) {
1093
+ return d(), p("svg", ps, [...e[0] || (e[0] = [
1094
+ se('<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)
1179
1095
  ])]);
1180
1096
  }
1181
- const js = /* @__PURE__ */ O(Bs, [["render", zs]]), Ls = ["id", "data-node-type"], Gs = {
1182
- class: "__title-label",
1183
- style: { "flex-grow": "1" }
1184
- }, Rs = { key: 0 }, Ps = {
1185
- class: "__menu",
1186
- style: { display: "flex" }
1187
- }, Us = { class: "__outputs" }, Hs = { key: 0 }, As = ["id", "title"], Ds = { class: "__inputs" }, Fs = { key: 0 }, Ws = ["id", "title"], Xs = /* @__PURE__ */ R({
1188
- __name: "CodeGraphNode",
1189
- props: {
1190
- node: {},
1191
- selected: { type: Boolean, default: !1 },
1192
- dragging: { type: Boolean }
1193
- },
1194
- emits: ["select", "start-drag", "update"],
1195
- setup(s, { emit: e }) {
1196
- const t = Ce.ContextMenu, n = Ce.NodeInterface, o = s, a = b(() => o.node), r = e, { viewModel: u } = K(), { graph: p, switchGraph: _ } = ae(), g = V(null), I = V(!1), L = V(""), x = V(null), y = V(!1);
1197
- let f = 0, $ = 0;
1198
- const m = V(!1), w = b(() => {
1199
- const c = [
1200
- { value: "edit", label: "Edit" },
1201
- { value: "rename", label: "Rename" },
1202
- { value: "delete", label: "Delete" }
1203
- ];
1204
- return o.node.type.startsWith(se) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
1205
- }), h = b(() => ({
1206
- "--selected": o.selected,
1207
- "--dragging": o.dragging,
1208
- "--two-column": !!o.node.twoColumn,
1209
- "--hidden": a.value.state?.hidden
1210
- })), M = b(() => ({
1211
- "--reverse-y": o.node.reverseY ?? u.value.settings.nodes.reverseY
1212
- })), Ge = b(() => ({
1097
+ const ms = /* @__PURE__ */ P(cs, [["render", hs]]), et = "CLEAR_ALL", tt = "RUN_ENGINE", nt = "TOGGLE_MINIMAP", st = "TOGGLE_PALETTE", fs = (n, e, t) => {
1098
+ const s = t.zoomToFit.paddingLeft;
1099
+ e.registerCommand(st, {
1100
+ execute: () => {
1101
+ t.palette.enabled = !t.palette.enabled, t.zoomToFit.paddingLeft = t.palette.enabled ? s : 50;
1102
+ },
1103
+ canExecute: () => !0
1104
+ }), e.registerCommand(et, {
1105
+ execute: () => n.value.clear(),
1106
+ canExecute: () => n.value.nodes.length > 0
1107
+ }), e.registerCommand(nt, {
1108
+ execute: () => t.enableMinimap = !t.enableMinimap,
1109
+ canExecute: () => n.value.nodes.length > 1
1110
+ });
1111
+ }, vs = (n) => {
1112
+ const e = {
1113
+ command: tt,
1114
+ title: "Run",
1115
+ // Tooltip text
1116
+ icon: O(() => Qn)
1117
+ }, t = {
1118
+ command: st,
1119
+ title: "Toggle palette",
1120
+ // Tooltip text
1121
+ icon: O(() => n.palette.enabled ? Tn : Gn)
1122
+ }, s = {
1123
+ command: et,
1124
+ title: "Clear all",
1125
+ // Tooltip text
1126
+ icon: O(() => ms)
1127
+ }, o = {
1128
+ command: nt,
1129
+ title: "Toggle minimap",
1130
+ // Tooltip text
1131
+ icon: O(() => n.enableMinimap ? is : ns)
1132
+ };
1133
+ n.toolbar.commands = [t, e, ...jt, s, o];
1134
+ }, gs = (n, e) => {
1135
+ e.registerCommand(tt, {
1136
+ execute: () => n.runOnce(null),
1137
+ canExecute: () => !0
1138
+ });
1139
+ };
1140
+ function bs(n) {
1141
+ const e = Symbol("CodeEngineToken");
1142
+ n.engine = new vn(n.editor), gs(n.engine, n.commandHandler), n.loadEditor = (t) => {
1143
+ n.engine?.pause(), n.displayedGraph.clear(), n.editor.load(t), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.engine?.resume(), n.engine?.runOnce(null);
1144
+ }, n.newGraph = () => {
1145
+ n.engine?.pause(), n.displayedGraph.clear(), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.displayedGraph.id = K(), n.engine?.resume(), n.engine?.runOnce(null);
1146
+ }, n.subscribe = () => {
1147
+ n.displayedGraph.events.addConnection.subscribe(e, (t) => {
1148
+ const s = n.displayedGraph.findNodeById(t.to.nodeId);
1149
+ s && s.isCodeNode && s.onConnected();
1150
+ const o = n.displayedGraph.findNodeById(t.from.nodeId);
1151
+ o && o.isCodeNode && o.onConnected();
1152
+ }), n.displayedGraph.events.removeConnection.subscribe(e, (t) => {
1153
+ const s = n.displayedGraph.findNodeById(t.to.nodeId);
1154
+ s && s.isCodeNode && s.onUnconnected();
1155
+ const o = n.displayedGraph.findNodeById(t.from.nodeId);
1156
+ o && o.isCodeNode && o.onUnconnected();
1157
+ }), n.engine?.events.beforeRun.subscribe(e, () => {
1158
+ n.engine?.pause(), n.displayedGraph.sortNodes(), n.engine?.resume();
1159
+ }), n.engine?.events.afterRun.subscribe(e, (t) => {
1160
+ n.engine?.pause(), Ae(t, n.editor), n.code.state.lockCode || n.code.renderCode({
1161
+ nodes: n.editor.graph.scriptedCodeNodes,
1162
+ modules: n.editor.graph.modules
1163
+ }), n.engine?.resume();
1164
+ });
1165
+ }, n.unsubscribe = () => {
1166
+ n.displayedGraph.events.addConnection.unsubscribe(e), n.displayedGraph.events.removeConnection.unsubscribe(e), n.engine?.events.beforeRun.unsubscribe(e), n.engine?.events.afterRun.unsubscribe(e);
1167
+ };
1168
+ }
1169
+ class ue extends Ct {
1170
+ code = null;
1171
+ editor;
1172
+ _state = D({
1173
+ codeTemplate: "{{ #nodes }}{{ script }}{{ /nodes }}",
1174
+ lockCode: !1
1175
+ });
1176
+ constructor(e, t) {
1177
+ super(e, t), this.editor = e, this.template = t, e.code && (this.code = e.code);
1178
+ }
1179
+ get codeNodes() {
1180
+ return ot(this);
1181
+ }
1182
+ get connections() {
1183
+ return super.connections;
1184
+ }
1185
+ set connections(e) {
1186
+ this._connections = e;
1187
+ }
1188
+ get nodeIds() {
1189
+ return this.nodes.map((e) => e.id);
1190
+ }
1191
+ get nodes() {
1192
+ return super.nodes;
1193
+ }
1194
+ set nodes(e) {
1195
+ this._nodes = e;
1196
+ }
1197
+ get scriptedCodeNodes() {
1198
+ return this.nodes.filter((e) => !e.state?.integrated);
1199
+ }
1200
+ get shortId() {
1201
+ return this.id.slice(0, 6);
1202
+ }
1203
+ get state() {
1204
+ return this._state;
1205
+ }
1206
+ get visibleNodes() {
1207
+ return this.nodes.filter((e) => !e.state?.hidden);
1208
+ }
1209
+ // /**
1210
+ // * Add code node to graph.
1211
+ // * @param node code node
1212
+ // * @param props optional
1213
+ // */
1214
+ // public override addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined {
1215
+ // if (node.state && props) node.state.props = props;
1216
+ // return super.addNode(node as AbstractNode) as AbstractCodeNode;
1217
+ // }
1218
+ /**
1219
+ * Add code node at coordinates.
1220
+ * @param node code node
1221
+ * @param position position
1222
+ * @param props optional
1223
+ * @returns code node
1224
+ */
1225
+ addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, s) => (this.addNode(e, s), e.position && (e.position = t), e);
1226
+ /**
1227
+ * Add connection of code nodes
1228
+ * @param from code node interface
1229
+ * @param to code node interface
1230
+ */
1231
+ addConnection(e, t) {
1232
+ e?.name !== "_code" && (e.hidden = !1), t?.name !== "_code" && (t.hidden = !1), super.addConnection(e, t);
1233
+ }
1234
+ /**
1235
+ * Clear code graph.
1236
+ */
1237
+ clear() {
1238
+ this.selectedNodes = [], this._nodes = [], this._connections = [];
1239
+ }
1240
+ /**
1241
+ * Find node by type.
1242
+ * @param nodeType node type
1243
+ * @returns node instance
1244
+ */
1245
+ findNodeByType(e) {
1246
+ return this.nodes.find((t) => t.type === e);
1247
+ }
1248
+ /**
1249
+ * Get nodes of the same type.
1250
+ * @param type node type
1251
+ * @returns a list of node instances
1252
+ */
1253
+ getNodesBySameType(e) {
1254
+ return this.nodes.filter((t) => t.type === e);
1255
+ }
1256
+ /**
1257
+ * Get nodes of the same variable name.
1258
+ * @param variableName variable name
1259
+ * @returns a list of node instances
1260
+ */
1261
+ getNodesBySameVariableNames(e) {
1262
+ return this.nodes.filter(
1263
+ (t) => t.state?.variableName === e
1264
+ );
1265
+ }
1266
+ /**
1267
+ * Check whether the graph has this connection.
1268
+ * @param from node interface
1269
+ * @param to node interface
1270
+ * @returns boolean
1271
+ */
1272
+ hasConnection(e, t) {
1273
+ return this.connections.some(
1274
+ (s) => s.from.id === e.id && s.to.id === t.id
1275
+ );
1276
+ }
1277
+ /**
1278
+ * Render code script.
1279
+ */
1280
+ renderCode(e) {
1281
+ return Z.render(this.state?.codeTemplate || "", e);
1282
+ }
1283
+ /**
1284
+ * Sort code nodes.
1285
+ */
1286
+ sortNodes() {
1287
+ if (!(this.nodes.length === 0 || this.connections.length === 0))
1288
+ try {
1289
+ let e = this.nodeIds;
1290
+ const t = this.connections.filter(
1291
+ (a) => e.includes(a.to.nodeId) && e.includes(a.from.nodeId)
1292
+ ).map((a) => [a.to.nodeId, a.from.nodeId]);
1293
+ e.reverse(), e = Qt.array(e, t), e.reverse();
1294
+ const s = this.nodes.map((a) => a.id).filter((a) => !e.includes(a));
1295
+ e = [...e, ...s];
1296
+ const o = e.map((a) => this.findNodeById(a));
1297
+ o && (this.nodes = o);
1298
+ } catch {
1299
+ console.warn("Failed to sort nodes.");
1300
+ }
1301
+ }
1302
+ }
1303
+ const ot = (n) => {
1304
+ const e = [];
1305
+ return n.nodes.length === 0 || n.nodes.forEach((t) => {
1306
+ t && (t.hasOwnProperty("subgraph") ? e.push(...ot(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
1307
+ }), e;
1308
+ }, To = (n = 0, e = 100) => ({
1309
+ x: n * 420,
1310
+ y: e
1311
+ }), Eo = (n) => {
1312
+ const e = { ...n.position };
1313
+ return e.x -= 440, e.y += 50, e;
1314
+ };
1315
+ function _s(n, e) {
1316
+ return Object.fromEntries(Object.entries(n).filter(e));
1317
+ }
1318
+ function ys(n, e) {
1319
+ return Object.fromEntries(Object.entries(n).map(([t, s]) => [t, e(s)]));
1320
+ }
1321
+ class ce extends It {
1322
+ /** Create a new GraphTemplate from the nodes and connections inside the graph instance */
1323
+ static fromGraph(e, t) {
1324
+ return new ce(e.save(), t);
1325
+ }
1326
+ constructor(e, t) {
1327
+ super(e, t);
1328
+ }
1329
+ get shortId() {
1330
+ return this.id.slice(0, 6);
1331
+ }
1332
+ /**
1333
+ * Create a new graph instance from this template
1334
+ * or load the state into the provided graph instance.
1335
+ */
1336
+ createGraph(e) {
1337
+ const t = /* @__PURE__ */ new Map(), s = (m) => {
1338
+ const k = K();
1339
+ return t.set(m, k), k;
1340
+ }, o = (m) => {
1341
+ const k = t.get(m);
1342
+ if (!k) throw new Error(`Unable to create graph from template: Could not map old id ${m} to new id`);
1343
+ return k;
1344
+ }, a = (m) => ys(m, (k) => ({
1345
+ id: s(k.id),
1346
+ templateId: k.id,
1347
+ value: k.value
1348
+ })), i = this.nodes.map((m) => ({
1349
+ ...m,
1350
+ id: s(m.id),
1351
+ inputs: a(m.inputs),
1352
+ outputs: a(m.outputs)
1353
+ })), r = this.connections.map((m) => ({
1354
+ id: s(m.id),
1355
+ from: o(m.from),
1356
+ to: o(m.to)
1357
+ })), c = this.inputs.map((m) => ({
1358
+ id: m.id,
1359
+ name: m.name,
1360
+ nodeId: o(m.nodeId),
1361
+ nodeInterfaceId: o(m.nodeInterfaceId)
1362
+ })), h = this.outputs.map((m) => ({
1363
+ id: m.id,
1364
+ name: m.name,
1365
+ nodeId: o(m.nodeId),
1366
+ nodeInterfaceId: o(m.nodeInterfaceId)
1367
+ })), g = {
1368
+ id: K(),
1369
+ nodes: i,
1370
+ connections: r,
1371
+ inputs: c,
1372
+ outputs: h
1373
+ };
1374
+ return e || (e = new ue(this.editor)), e.load(g).forEach((m) => console.warn(m)), e.template = this, e;
1375
+ }
1376
+ }
1377
+ const Cs = (n) => !(n instanceof ue);
1378
+ function Is(n, e) {
1379
+ return { switchGraph: (s) => {
1380
+ let o;
1381
+ if (Cs(s))
1382
+ o = new ue(n.value), s.createGraph(o);
1383
+ else {
1384
+ if (s !== n.value.graph)
1385
+ throw new Error(
1386
+ "Can only switch using 'Graph' instance when it is the root graph. Otherwise a 'GraphTemplate' must be used."
1387
+ );
1388
+ o = s;
1389
+ }
1390
+ e.value && e.value !== n.value.graph && e.value.destroy(), o.panning = o.panning ?? s.panning ?? { x: 0, y: 0 }, o.scaling = o.scaling ?? s.scaling ?? 1, o.selectedNodes = o.selectedNodes ?? [], o.sidebar = o.sidebar ?? { visible: !1, nodeId: "", optionName: "" }, e.value = o, o.code?.engine?.runOnce(null);
1391
+ } };
1392
+ }
1393
+ const $o = /* @__PURE__ */ F({
1394
+ __name: "CodeGraphEditor",
1395
+ props: {
1396
+ viewModel: {}
1397
+ },
1398
+ setup(n) {
1399
+ const t = Be(n, "viewModel"), s = (o) => o.events.update.emit(null);
1400
+ return fe(() => {
1401
+ t.value.subscribe && t.value.subscribe(), t.value.engine?.start();
1402
+ }), ze(() => {
1403
+ t.value.unsubscribe && t.value.unsubscribe(), t.value.engine?.stop();
1404
+ }), He(t, (o, a) => {
1405
+ a && a.unsubscribe(), o && o.subscribe();
1406
+ }), (o, a) => (d(), j(w(Bt), { viewModel: t.value }, {
1407
+ palette: ee(() => [
1408
+ L(w(Ls))
1409
+ ]),
1410
+ node: ee((i) => [
1411
+ L(w(Ps), mt(i, {
1412
+ onUpdate: (r) => s(i.node)
1413
+ }), null, 16, ["onUpdate"])
1414
+ ]),
1415
+ sidebar: ee((i) => [
1416
+ L(w(Qs), pt(ht(i)), {
1417
+ codeEditor: ee(({ node: r }) => [
1418
+ ne(o.$slots, "sidebarCodeEditor", { node: r })
1419
+ ]),
1420
+ _: 3
1421
+ }, 16)
1422
+ ]),
1423
+ _: 3
1424
+ }, 8, ["viewModel"]));
1425
+ }
1426
+ }), ws = { class: "code-graph-info" }, Mo = /* @__PURE__ */ F({
1427
+ __name: "CodeGraphInfo",
1428
+ props: {
1429
+ viewModel: {}
1430
+ },
1431
+ setup(n) {
1432
+ return (e, t) => (d(), p("div", ws, [
1433
+ u("div", null, "Editor graph: " + G(n.viewModel.editor.graph.shortId), 1),
1434
+ u("div", null, "Displayed graph: " + G(n.viewModel.displayedGraph.shortId), 1),
1435
+ u("div", null, "Graphs: " + G(n.viewModel.editor.graphIds), 1),
1436
+ u("div", null, "Graph templates: " + G(n.viewModel.editor.graphTemplateIds), 1),
1437
+ u("div", null, "Engine status: " + G(n.viewModel.engine?.status), 1)
1438
+ ]));
1439
+ }
1440
+ }), ks = ["id", "data-node-type"], Ns = {
1441
+ class: "__title-label",
1442
+ style: { "flex-grow": "1" }
1443
+ }, xs = { key: 0 }, Os = {
1444
+ class: "__menu",
1445
+ style: { display: "flex" }
1446
+ }, Ts = { class: "__outputs" }, Es = { key: 0 }, $s = ["id", "title"], Ms = { class: "__inputs" }, Gs = { key: 0 }, Ss = ["id", "title"], Ps = /* @__PURE__ */ F({
1447
+ __name: "CodeGraphNode",
1448
+ props: {
1449
+ node: {},
1450
+ selected: { type: Boolean, default: !1 },
1451
+ dragging: { type: Boolean }
1452
+ },
1453
+ emits: ["select", "start-drag", "update"],
1454
+ setup(n, { emit: e }) {
1455
+ const t = me.ContextMenu, s = me.NodeInterface, o = n, a = O(() => o.node), i = e, { viewModel: r } = oe(), { graph: c, switchGraph: h } = ge(), g = V(null), _ = V(!1), m = V(""), k = V(null), b = V(!1);
1456
+ let I = 0, l = 0;
1457
+ const f = V(!1), N = O(() => {
1458
+ const C = [
1459
+ { value: "edit", label: "Edit" },
1460
+ { value: "rename", label: "Rename" },
1461
+ { value: "delete", label: "Delete" }
1462
+ ];
1463
+ return o.node.type.startsWith(wt) && C.push({ value: "editSubgraph", label: "Edit Subgraph" }), C;
1464
+ }), y = O(() => ({
1465
+ "--selected": o.selected,
1466
+ "--dragging": o.dragging,
1467
+ "--two-column": !!o.node.twoColumn,
1468
+ "--hidden": a.value.state?.hidden
1469
+ })), T = O(() => ({
1470
+ "--reverse-y": o.node.reverseY ?? r.value.settings.nodes.reverseY
1471
+ })), ie = O(() => ({
1213
1472
  top: `${o.node.position?.y ?? 0}px`,
1214
1473
  left: `${o.node.position?.x ?? 0}px`,
1215
- "--width": `${o.node.width ?? u.value.settings.nodes.defaultWidth}px`
1216
- })), Re = b(() => Object.values(o.node.inputs).filter((c) => !c.hidden)), Pe = b(() => Object.values(o.node.outputs).filter((c) => !c.hidden)), he = () => {
1217
- r("select");
1218
- }, Ue = (c) => {
1219
- o.selected || he(), r("start-drag", c);
1220
- }, me = () => {
1221
- m.value = !0;
1222
- }, He = () => {
1223
- const c = u.value.displayedGraph.sidebar;
1224
- c.nodeId = "", c.visible = !1;
1225
- }, ve = () => {
1226
- const c = u.value.displayedGraph.sidebar;
1227
- c.nodeId = o.node.id, c.visible = !0;
1228
- }, Ae = () => {
1229
- const c = u.value.displayedGraph.sidebar;
1230
- c.nodeId = o.node.id;
1231
- }, De = async (c) => {
1232
- switch (c) {
1474
+ "--width": `${o.node.width ?? r.value.settings.nodes.defaultWidth}px`
1475
+ })), W = O(() => Object.values(o.node.inputs).filter((C) => !C.hidden)), pe = O(() => Object.values(o.node.outputs).filter((C) => !C.hidden)), re = () => {
1476
+ i("select");
1477
+ }, v = (C) => {
1478
+ o.selected || re(), i("start-drag", C);
1479
+ }, S = () => {
1480
+ f.value = !0;
1481
+ }, H = () => {
1482
+ const C = r.value.displayedGraph.sidebar;
1483
+ C.nodeId = "", C.visible = !1;
1484
+ }, Ne = () => {
1485
+ const C = r.value.displayedGraph.sidebar;
1486
+ C.nodeId = o.node.id, C.visible = !0;
1487
+ }, rt = () => {
1488
+ const C = r.value.displayedGraph.sidebar;
1489
+ C.nodeId = o.node.id;
1490
+ }, dt = async (C) => {
1491
+ switch (C) {
1233
1492
  case "edit":
1234
- ve();
1493
+ Ne();
1235
1494
  break;
1236
1495
  case "delete":
1237
- p.value.removeNode(o.node);
1496
+ c.value.removeNode(o.node);
1238
1497
  break;
1239
1498
  case "rename":
1240
- L.value = o.node.title, I.value = !0, await _t(), x.value?.focus();
1499
+ m.value = o.node.title, _.value = !0, await vt(), k.value?.focus();
1241
1500
  break;
1242
1501
  case "editSubgraph":
1243
- _(o.node.template);
1502
+ h(o.node.template);
1244
1503
  break;
1245
1504
  }
1246
- }, fe = () => {
1247
- a.value.title = L.value, I.value = !1;
1248
- }, ge = () => {
1249
- g.value && u.value.hooks.renderNode.execute({ node: o.node, el: g.value });
1250
- }, Fe = (c) => {
1251
- y.value = !0, f = o.node.width, $ = c.clientX, c.preventDefault();
1252
- }, be = (c) => {
1253
- a.value.state && (a.value.state.integrated = c, r("update"));
1254
- }, _e = (c) => {
1255
- if (!y.value) return;
1256
- const C = c.clientX - $, v = f + C / p.value.scaling, We = u.value.settings.nodes.minWidth, Xe = u.value.settings.nodes.maxWidth;
1257
- a.value.width = Math.max(We, Math.min(Xe, v));
1258
- }, ye = () => {
1259
- y.value = !1;
1505
+ }, xe = () => {
1506
+ a.value.title = m.value, _.value = !1;
1507
+ }, Oe = () => {
1508
+ g.value && r.value.hooks.renderNode.execute({ node: o.node, el: g.value });
1509
+ }, lt = (C) => {
1510
+ b.value = !0, I = o.node.width, l = C.clientX, C.preventDefault();
1511
+ }, Te = (C) => {
1512
+ a.value.state && (a.value.state.integrated = C, i("update"));
1513
+ }, Ee = (C) => {
1514
+ if (!b.value) return;
1515
+ const E = C.clientX - l, x = I + E / c.value.scaling, ut = r.value.settings.nodes.minWidth, ct = r.value.settings.nodes.maxWidth;
1516
+ a.value.width = Math.max(ut, Math.min(ct, x));
1517
+ }, $e = () => {
1518
+ b.value = !1;
1260
1519
  };
1261
- return ie(() => {
1262
- ge(), window.addEventListener("mousemove", _e), window.addEventListener("mouseup", ye);
1263
- }), Oe(ge), gt(() => {
1264
- window.removeEventListener("mousemove", _e), window.removeEventListener("mouseup", ye);
1265
- }), (c, C) => (i(), d("div", {
1520
+ return fe(() => {
1521
+ Oe(), window.addEventListener("mousemove", Ee), window.addEventListener("mouseup", $e);
1522
+ }), Le(Oe), ze(() => {
1523
+ window.removeEventListener("mousemove", Ee), window.removeEventListener("mouseup", $e);
1524
+ }), (C, E) => (d(), p("div", {
1266
1525
  id: a.value.id,
1267
1526
  ref_key: "el",
1268
1527
  ref: g,
1269
- class: P([h.value, "baklava-node"]),
1528
+ class: Y([y.value, "baklava-node"]),
1270
1529
  "data-node-type": a.value.type,
1271
- style: re(Ge.value),
1272
- onPointerdown: he
1530
+ style: ve(ie.value),
1531
+ onPointerdown: re
1273
1532
  }, [
1274
- k(u).settings.nodes.resizable ? (i(), d("div", {
1533
+ w(r).settings.nodes.resizable ? (d(), p("div", {
1275
1534
  key: 0,
1276
1535
  class: "__resize-handle",
1277
- onMousedown: Fe
1278
- }, null, 32)) : N("", !0),
1279
- l("div", {
1536
+ onMousedown: lt
1537
+ }, null, 32)) : M("", !0),
1538
+ u("div", {
1280
1539
  class: "__title",
1281
- onPointerdown: F(Ue, ["self", "stop"]),
1282
- onContextmenu: F(me, ["prevent"])
1540
+ onPointerdown: te(v, ["self", "stop"]),
1541
+ onContextmenu: te(S, ["prevent"])
1283
1542
  }, [
1284
- a.value.inputs._code ? (i(), E(we, {
1543
+ a.value.inputs._code ? (d(), j(w(Ve), {
1285
1544
  key: 0,
1286
1545
  node: a.value,
1287
1546
  intf: a.value.inputs._code,
@@ -1289,147 +1548,271 @@ const js = /* @__PURE__ */ O(Bs, [["render", zs]]), Ls = ["id", "data-node-type"
1289
1548
  class: "--input",
1290
1549
  "data-interface-type": "node",
1291
1550
  style: { "flex-grow": "0" }
1292
- }, null, 8, ["node", "intf", "title"])) : N("", !0),
1293
- I.value ? ee((i(), d("input", {
1551
+ }, null, 8, ["node", "intf", "title"])) : M("", !0),
1552
+ _.value ? de((d(), p("input", {
1294
1553
  key: 2,
1295
1554
  ref_key: "renameInputEl",
1296
- ref: x,
1297
- "onUpdate:modelValue": C[4] || (C[4] = (v) => L.value = v),
1555
+ ref: k,
1556
+ "onUpdate:modelValue": E[4] || (E[4] = (x) => m.value = x),
1298
1557
  class: "baklava-input",
1299
1558
  placeholder: "Node Name",
1300
1559
  style: { "flex-grow": "1" },
1301
1560
  type: "text",
1302
- onBlur: fe,
1303
- onKeydown: ne(fe, ["enter"])
1561
+ onBlur: xe,
1562
+ onKeydown: he(xe, ["enter"])
1304
1563
  }, null, 544)), [
1305
- [te, L.value]
1306
- ]) : (i(), d(S, { key: 1 }, [
1307
- l("div", Gs, [
1308
- a.value.idx > -1 ? (i(), d("span", Rs, j(a.value.idx + 1) + " - ", 1)) : N("", !0),
1309
- bt(j(a.value.title), 1)
1564
+ [le, m.value]
1565
+ ]) : (d(), p(B, { key: 1 }, [
1566
+ u("div", Ns, [
1567
+ a.value.idx > -1 ? (d(), p("span", xs, G(a.value.idx + 1) + " - ", 1)) : M("", !0),
1568
+ ft(G(a.value.title) + " " + G(a.value.graph.shortId) + " " + G(a.value.shortId), 1)
1310
1569
  ]),
1311
- l("div", Ps, [
1312
- a.value.isCodeNode ? (i(), d(S, { key: 0 }, [
1313
- a.value.state.lockCode ? (i(), E(k(ys), {
1570
+ u("div", Os, [
1571
+ a.value.isCodeNode ? (d(), p(B, { key: 0 }, [
1572
+ a.value.state.lockCode ? (d(), j(w(Kn), {
1314
1573
  key: 0,
1315
1574
  class: "--clickable mx-1",
1316
- onClick: C[0] || (C[0] = (v) => a.value.lockCode = !1)
1317
- })) : N("", !0),
1318
- a.value.state.integrated ? (i(), E(k(Wt), {
1575
+ onClick: E[0] || (E[0] = (x) => a.value.lockCode = !1)
1576
+ })) : M("", !0),
1577
+ a.value.state.integrated ? (d(), j(w(yn), {
1319
1578
  key: 1,
1320
1579
  class: "--clickable mx-1",
1321
- onClick: C[1] || (C[1] = (v) => be(!1))
1322
- })) : (i(), E(k(Ss), {
1580
+ onClick: E[1] || (E[1] = (x) => Te(!1))
1581
+ })) : (d(), j(w(us), {
1323
1582
  key: 2,
1324
1583
  class: "--clickable mx-1",
1325
- onClick: C[2] || (C[2] = (v) => be(!0))
1584
+ onClick: E[2] || (E[2] = (x) => Te(!0))
1326
1585
  })),
1327
- !k(u).displayedGraph.sidebar.visible && k(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), E(k(fs), {
1586
+ !w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Dn), {
1328
1587
  key: 3,
1329
1588
  class: "--clickable mx-1",
1330
- onClick: ve
1331
- })) : k(u).displayedGraph.sidebar.visible && k(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), E(k(ds), {
1589
+ onClick: Ne
1590
+ })) : w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Rn), {
1332
1591
  key: 4,
1333
1592
  class: "--clickable mx-1",
1334
- onClick: Ae
1335
- })) : (i(), E(k(ps), {
1593
+ onClick: rt
1594
+ })) : (d(), j(w(Hn), {
1336
1595
  key: 5,
1337
1596
  class: "--clickable mx-1",
1338
- onClick: He
1597
+ onClick: H
1339
1598
  }))
1340
- ], 64)) : N("", !0),
1341
- z(k(qt), {
1599
+ ], 64)) : M("", !0),
1600
+ L(w(kn), {
1342
1601
  class: "--clickable mx-1",
1343
- onClick: me
1602
+ onClick: S
1344
1603
  }),
1345
- z(k(t), {
1346
- modelValue: m.value,
1347
- "onUpdate:modelValue": C[3] || (C[3] = (v) => m.value = v),
1604
+ L(w(t), {
1605
+ modelValue: f.value,
1606
+ "onUpdate:modelValue": E[3] || (E[3] = (x) => f.value = x),
1348
1607
  x: 0,
1349
1608
  y: 0,
1350
- items: w.value,
1351
- onClick: De
1609
+ items: N.value,
1610
+ onClick: dt
1352
1611
  }, null, 8, ["modelValue", "items"])
1353
1612
  ])
1354
1613
  ], 64)),
1355
- a.value.outputs._code ? (i(), E(we, {
1614
+ a.value.outputs._code ? (d(), j(w(Ve), {
1356
1615
  key: 3,
1357
1616
  node: a.value,
1358
1617
  intf: a.value.outputs._code,
1359
1618
  class: "--output",
1360
1619
  title: a.value.outputs._code.value,
1361
1620
  "data-interface-type": "node"
1362
- }, null, 8, ["node", "intf", "title"])) : N("", !0)
1621
+ }, null, 8, ["node", "intf", "title"])) : M("", !0)
1363
1622
  ], 32),
1364
- l("div", {
1365
- class: P(["__content", M.value]),
1366
- onKeydown: C[5] || (C[5] = ne(F(() => {
1623
+ u("div", {
1624
+ class: Y(["__content", T.value]),
1625
+ onKeydown: E[5] || (E[5] = he(te(() => {
1367
1626
  }, ["stop"]), ["delete"])),
1368
- onContextmenu: C[6] || (C[6] = F(() => {
1627
+ onContextmenu: E[6] || (E[6] = te(() => {
1369
1628
  }, ["prevent"]))
1370
1629
  }, [
1371
- l("div", Us, [
1372
- (i(!0), d(S, null, D(Pe.value, (v) => (i(), d(S, {
1373
- key: v.id
1630
+ u("div", Ts, [
1631
+ (d(!0), p(B, null, J(pe.value, (x) => (d(), p(B, {
1632
+ key: x.id
1374
1633
  }, [
1375
- a.value.state?.hidden ? (i(), d("div", Hs, [
1376
- v.port ? (i(), d("div", {
1634
+ a.value.state?.hidden ? (d(), p("div", Es, [
1635
+ x.port ? (d(), p("div", {
1377
1636
  key: 0,
1378
- id: v.id,
1379
- title: v.name,
1637
+ id: x.id,
1638
+ title: x.name,
1380
1639
  class: "baklava-node-interface --output --connected"
1381
- }, [...C[7] || (C[7] = [
1382
- l("div", { class: "__port" }, null, -1)
1383
- ])], 8, As)) : N("", !0)
1384
- ])) : X(c.$slots, "nodeInterface", {
1640
+ }, [...E[7] || (E[7] = [
1641
+ u("div", { class: "__port" }, null, -1)
1642
+ ])], 8, $s)) : M("", !0)
1643
+ ])) : ne(C.$slots, "nodeInterface", {
1385
1644
  key: 1,
1386
1645
  type: "output",
1387
1646
  node: a.value,
1388
- intf: v
1647
+ intf: x
1389
1648
  }, () => [
1390
- z(k(n), {
1649
+ L(w(s), {
1391
1650
  node: a.value,
1392
- intf: v,
1393
- title: v.type
1651
+ intf: x,
1652
+ title: x.value
1394
1653
  }, null, 8, ["node", "intf", "title"])
1395
1654
  ])
1396
1655
  ], 64))), 128))
1397
1656
  ]),
1398
- l("div", Ds, [
1399
- (i(!0), d(S, null, D(Re.value, (v) => (i(), d(S, {
1400
- key: v.id
1657
+ u("div", Ms, [
1658
+ (d(!0), p(B, null, J(W.value, (x) => (d(), p(B, {
1659
+ key: x.id
1401
1660
  }, [
1402
- a.value.state?.hidden ? (i(), d("div", Fs, [
1403
- v.port ? (i(), d("div", {
1661
+ a.value.state?.hidden ? (d(), p("div", Gs, [
1662
+ x.port ? (d(), p("div", {
1404
1663
  key: 0,
1405
- id: v.id,
1406
- title: v.name,
1664
+ id: x.id,
1665
+ title: x.name,
1407
1666
  class: "baklava-node-interface --input --connected"
1408
- }, [...C[8] || (C[8] = [
1409
- l("div", { class: "__port" }, null, -1)
1410
- ])], 8, Ws)) : N("", !0)
1411
- ])) : X(c.$slots, "nodeInterface", {
1667
+ }, [...E[8] || (E[8] = [
1668
+ u("div", { class: "__port" }, null, -1)
1669
+ ])], 8, Ss)) : M("", !0)
1670
+ ])) : ne(C.$slots, "nodeInterface", {
1412
1671
  key: 1,
1413
1672
  node: a.value,
1414
- intf: v,
1673
+ intf: x,
1415
1674
  type: "input"
1416
1675
  }, () => [
1417
- z(k(n), {
1676
+ L(w(s), {
1418
1677
  node: a.value,
1419
- intf: v,
1420
- title: v.type
1678
+ intf: x,
1679
+ title: x.value
1421
1680
  }, null, 8, ["node", "intf", "title"])
1422
1681
  ])
1423
1682
  ], 64))), 128))
1424
1683
  ])
1425
1684
  ], 34)
1426
- ], 46, Ls));
1685
+ ], 46, ks));
1686
+ }
1687
+ }), Vs = ["id"], Rs = { class: "align-middle" }, Ve = /* @__PURE__ */ F({
1688
+ __name: "CodeGraphNodeInterface",
1689
+ props: {
1690
+ node: {},
1691
+ intf: {}
1692
+ },
1693
+ setup(n) {
1694
+ const e = n, { viewModel: t } = oe(), { hoveredOver: s, temporaryConnection: o } = zt(), a = V(null), i = O(() => e.intf.connectionCount > 0), r = O(() => ({
1695
+ "--connected": i.value
1696
+ })), c = () => {
1697
+ s(e.intf);
1698
+ }, h = () => {
1699
+ s(void 0);
1700
+ }, g = () => {
1701
+ a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
1702
+ };
1703
+ return fe(g), Le(g), (_, m) => (d(), p("div", {
1704
+ id: n.intf.id,
1705
+ ref_key: "el",
1706
+ ref: a,
1707
+ class: Y(["baklava-node-interface", r.value])
1708
+ }, [
1709
+ n.intf.port ? (d(), p("div", {
1710
+ key: 0,
1711
+ class: Y(["__port", { "--selected": w(o)?.from === n.intf }]),
1712
+ onPointerover: c,
1713
+ onPointerout: h
1714
+ }, null, 34)) : M("", !0),
1715
+ u("span", Rs, [
1716
+ ne(_.$slots, "default")
1717
+ ])
1718
+ ], 10, Vs));
1427
1719
  }
1428
- }), Ys = ["title"], Ks = {
1720
+ }), js = {
1721
+ class: "baklava-node --palette",
1722
+ style: { "margin-top": "-20px", "margin-bottom": "20px" }
1723
+ }, Bs = {
1724
+ key: 0,
1725
+ style: { display: "flex", "justify-content": "space-between" }
1726
+ }, zs = ["onClick"], Hs = {
1727
+ key: 0,
1728
+ style: { margin: "auto 0", "font-size": "12px" }
1729
+ }, Ls = /* @__PURE__ */ F({
1730
+ __name: "CodeNodePalette",
1731
+ setup(n) {
1732
+ const e = me.PaletteEntry, { viewModel: t } = oe(), { x: s, y: o } = Zt(), { transform: a } = Ht(), i = Lt(t), r = gt("editorEl"), c = V(""), h = V(null), g = () => c.value ? i.value.filter(
1733
+ (b) => b.name.toLowerCase().includes(c.value.toLowerCase()) || Object.values(b.nodeTypes).some(
1734
+ (I) => I.title.toLowerCase().includes(c.value.toLowerCase())
1735
+ )
1736
+ ) : i.value, _ = (b) => c.value ? _s(b, (I) => {
1737
+ const l = I[1];
1738
+ return l.category.includes(c.value.toLowerCase()) || l.title?.toLowerCase().includes(c.value.toLowerCase());
1739
+ }) : b, m = O(() => {
1740
+ if (!h.value || !r?.value) return {};
1741
+ const { left: b, top: I } = r.value.getBoundingClientRect();
1742
+ return {
1743
+ top: `${o.value - I}px`,
1744
+ left: `${s.value - b}px`
1745
+ };
1746
+ }), k = (b, I) => {
1747
+ h.value = {
1748
+ type: b,
1749
+ nodeInformation: I
1750
+ };
1751
+ const l = () => {
1752
+ const f = D(new I.type());
1753
+ t.value.displayedGraph.addNode(f);
1754
+ const N = r.value.getBoundingClientRect(), [y, T] = a(s.value - N.left, o.value - N.top);
1755
+ f.position.x = y, f.position.y = T, h.value = null, document.removeEventListener("pointerup", l);
1756
+ };
1757
+ document.addEventListener("pointerup", l);
1758
+ };
1759
+ return (b, I) => (d(), p(B, null, [
1760
+ u("div", {
1761
+ class: Y([{ "--open": w(t).settings.palette.enabled }, "baklava-node-palette"]),
1762
+ onContextmenu: I[1] || (I[1] = te(() => {
1763
+ }, ["stop", "prevent"]))
1764
+ }, [
1765
+ u("div", js, [
1766
+ de(u("input", {
1767
+ "onUpdate:modelValue": I[0] || (I[0] = (l) => c.value = l),
1768
+ type: "text",
1769
+ class: "baklava-input",
1770
+ title: "Filter nodes",
1771
+ onKeyup: g
1772
+ }, null, 544), [
1773
+ [le, c.value]
1774
+ ])
1775
+ ]),
1776
+ (d(!0), p(B, null, J(g(), (l) => (d(), p("section", {
1777
+ key: l.name
1778
+ }, [
1779
+ l.name !== "default" ? (d(), p("h3", Bs, [
1780
+ u("div", {
1781
+ onClick: (f) => c.value = l.name,
1782
+ style: { cursor: "pointer" }
1783
+ }, G(l.name), 9, zs),
1784
+ Object.keys(_(l.nodeTypes)).length < Object.values(l.nodeTypes).length ? (d(), p("div", Hs, " ( " + G(Object.keys(_(l.nodeTypes)).length) + " / " + G(Object.values(l.nodeTypes).length) + " ) ", 1)) : M("", !0)
1785
+ ])) : M("", !0),
1786
+ (d(!0), p(B, null, J(_(l.nodeTypes), (f, N) => (d(), j(w(e), {
1787
+ key: N,
1788
+ type: N,
1789
+ title: f.title,
1790
+ onPointerdown: (y) => k(N, f)
1791
+ }, null, 8, ["type", "title", "onPointerdown"]))), 128))
1792
+ ]))), 128))
1793
+ ], 34),
1794
+ L(bt, { name: "fade" }, {
1795
+ default: ee(() => [
1796
+ h.value ? (d(), p("div", {
1797
+ key: 0,
1798
+ class: "baklava-dragged-node",
1799
+ style: ve(m.value)
1800
+ }, [
1801
+ L(w(e), {
1802
+ type: h.value.type,
1803
+ title: h.value.nodeInformation.title
1804
+ }, null, 8, ["type", "title"])
1805
+ ], 4)) : M("", !0)
1806
+ ]),
1807
+ _: 1
1808
+ })
1809
+ ], 64));
1810
+ }
1811
+ }), Us = ["title"], As = {
1429
1812
  key: 0,
1430
1813
  class: "__label"
1431
- }, Ie = /* @__PURE__ */ R({
1432
- __name: "Checkbox",
1814
+ }, Re = /* @__PURE__ */ F({
1815
+ __name: "SidebarCheckbox",
1433
1816
  props: {
1434
1817
  disabled: { type: Boolean },
1435
1818
  inversed: { type: Boolean },
@@ -1437,456 +1820,413 @@ const js = /* @__PURE__ */ O(Bs, [["render", zs]]), Ls = ["id", "data-node-type"
1437
1820
  name: {}
1438
1821
  },
1439
1822
  emits: ["update:modelValue"],
1440
- setup(s, { emit: e }) {
1823
+ setup(n, { emit: e }) {
1441
1824
  const t = e;
1442
- return (n, o) => (i(), d("div", {
1443
- class: P(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue, "--disabled": s.disabled }]),
1444
- title: s.name,
1445
- onClick: o[0] || (o[0] = (a) => t("update:modelValue", !s.modelValue))
1825
+ return (s, o) => (d(), p("div", {
1826
+ class: Y(["baklava-checkbox", { "--checked": n.inversed ? !n.modelValue : n.modelValue, "--disabled": n.disabled }]),
1827
+ title: n.name,
1828
+ onClick: o[0] || (o[0] = (a) => t("update:modelValue", !n.modelValue))
1446
1829
  }, [
1447
- o[1] || (o[1] = l("div", { class: "__checkmark-container" }, [
1448
- l("svg", {
1830
+ o[1] || (o[1] = u("div", { class: "__checkmark-container" }, [
1831
+ u("svg", {
1449
1832
  xmlns: "http://www.w3.org/2000/svg",
1450
1833
  width: "18",
1451
1834
  height: "18",
1452
1835
  viewBox: "0 0 18 18"
1453
1836
  }, [
1454
- l("path", {
1837
+ u("path", {
1455
1838
  class: "__checkmark",
1456
1839
  d: "M 6 5 L 6 10 L 16 10",
1457
1840
  transform: "rotate(-45 10 10)"
1458
1841
  })
1459
1842
  ])
1460
1843
  ], -1)),
1461
- s.name ? (i(), d("div", Ks, j(s.name), 1)) : N("", !0)
1462
- ], 10, Ys));
1844
+ n.name ? (d(), p("div", As, G(n.name), 1)) : M("", !0)
1845
+ ], 10, Us));
1463
1846
  }
1464
- }), qs = { class: "__header" }, Js = { class: "__node-name" }, Qs = { class: "__interfaces" }, Zs = { class: "__inputs" }, en = { style: { display: "flex" } }, tn = { class: "__outputs" }, sn = {
1847
+ }), Ds = { class: "__header" }, Fs = { class: "__node-name" }, Ws = { class: "__interfaces" }, Ys = { class: "__inputs" }, Ks = { style: { display: "flex" } }, Xs = { class: "__outputs" }, qs = {
1465
1848
  key: 0,
1466
1849
  class: "__interface"
1467
- }, nn = { style: { display: "flex" } }, on = /* @__PURE__ */ R({
1850
+ }, Js = { style: { display: "flex" } }, Qs = /* @__PURE__ */ F({
1468
1851
  __name: "CodeGraphSidebar",
1469
- setup(s) {
1470
- const { viewModel: e } = K(), { graph: t } = ae(), n = V(null), o = $e(e.value.settings.sidebar, "width"), a = b(() => e.value.settings.sidebar.resizable);
1471
- let r = 0, u = 0;
1472
- const p = b(() => {
1473
- const m = t.value.sidebar.nodeId;
1474
- return t.value.nodes.find((w) => w.id === m);
1475
- }), _ = b(() => p.value), g = b(() => ({
1852
+ setup(n) {
1853
+ const { viewModel: e } = oe(), { graph: t } = ge(), s = V(null), o = Be(e.value.settings.sidebar, "width"), a = O(() => e.value.settings.sidebar.resizable);
1854
+ let i = 0, r = 0;
1855
+ const c = O(() => {
1856
+ const f = t.value.sidebar.nodeId;
1857
+ return t.value.nodes.find((N) => N.id === f);
1858
+ }), h = O(() => c.value), g = O(() => ({
1476
1859
  width: `${o.value}px`
1477
- })), I = b(() => _.value ? Object.values(_.value.inputs).filter((m) => m.displayInSidebar && m.component) : []), L = b(() => _.value ? Object.values(_.value.outputs).filter((m) => m.displayInSidebar && m.component) : []), x = () => {
1860
+ })), _ = O(() => h.value ? Object.values(h.value.inputs).filter((f) => f.displayInSidebar && f.component) : []), m = O(() => h.value ? Object.values(h.value.outputs).filter((f) => f.displayInSidebar && f.component) : []), k = () => {
1478
1861
  t.value.sidebar.visible = !1;
1479
- }, y = () => {
1480
- p.value?.events.update.emit(null);
1481
- }, f = (m) => {
1482
- r = o.value, u = m.clientX, window.addEventListener("mousemove", $), window.addEventListener(
1862
+ }, b = () => {
1863
+ c.value?.events.update.emit(null);
1864
+ }, I = (f) => {
1865
+ i = o.value, r = f.clientX, window.addEventListener("mousemove", l), window.addEventListener(
1483
1866
  "mouseup",
1484
1867
  () => {
1485
- window.removeEventListener("mousemove", $);
1868
+ window.removeEventListener("mousemove", l);
1486
1869
  },
1487
1870
  { once: !0 }
1488
1871
  );
1489
- }, $ = (m) => {
1490
- const w = n.value?.parentElement?.getBoundingClientRect().width ?? 500, h = m.clientX - u;
1491
- let M = r - h;
1492
- M < 300 ? M = 300 : M > 0.9 * w && (M = 0.9 * w), o.value = M;
1872
+ }, l = (f) => {
1873
+ const N = s.value?.parentElement?.getBoundingClientRect().width ?? 500, y = f.clientX - r;
1874
+ let T = i - y;
1875
+ T < 300 ? T = 300 : T > 0.9 * N && (T = 0.9 * N), o.value = T;
1493
1876
  };
1494
- return (m, w) => (i(), d("div", {
1495
- class: P([{ "--open": k(t).sidebar.visible }, "baklava-sidebar"]),
1496
- style: re(g.value),
1877
+ return (f, N) => (d(), p("div", {
1878
+ class: Y([{ "--open": w(t).sidebar.visible }, "baklava-sidebar"]),
1879
+ style: ve(g.value),
1497
1880
  ref_key: "el",
1498
- ref: n
1881
+ ref: s
1499
1882
  }, [
1500
- a.value ? (i(), d("div", {
1883
+ a.value ? (d(), p("div", {
1501
1884
  key: 0,
1502
1885
  class: "__resizer",
1503
- onMousedown: f
1504
- }, null, 32)) : N("", !0),
1505
- p.value ? (i(), d(S, { key: 1 }, [
1506
- l("div", qs, [
1507
- l("button", {
1886
+ onMousedown: I
1887
+ }, null, 32)) : M("", !0),
1888
+ c.value ? (d(), p(B, { key: 1 }, [
1889
+ u("div", Ds, [
1890
+ u("button", {
1508
1891
  tabindex: "-1",
1509
1892
  class: "__close",
1510
- onClick: x
1893
+ onClick: k
1511
1894
  }, "×"),
1512
- l("div", Js, [
1513
- l("b", null, j(p.value.title), 1)
1895
+ u("div", Fs, [
1896
+ u("b", null, G(c.value.title), 1)
1514
1897
  ])
1515
1898
  ]),
1516
- l("div", Qs, [
1517
- l("div", Zs, [
1518
- (i(!0), d(S, null, D(I.value, (h) => (i(), d("div", {
1519
- key: h.id,
1899
+ u("div", Ws, [
1900
+ u("div", Ys, [
1901
+ (d(!0), p(B, null, J(_.value, (y) => (d(), p("div", {
1902
+ key: y.id,
1520
1903
  class: "__interface"
1521
1904
  }, [
1522
- l("div", en, [
1523
- z(Ie, {
1524
- modelValue: h.hidden,
1905
+ u("div", Ks, [
1906
+ L(Re, {
1907
+ modelValue: y.hidden,
1525
1908
  "onUpdate:modelValue": [
1526
- (M) => h.hidden = M,
1527
- w[0] || (w[0] = () => p.value?.events.update.emit(null))
1909
+ (T) => y.hidden = T,
1910
+ N[0] || (N[0] = () => c.value?.events.update.emit(null))
1528
1911
  ],
1529
- disabled: !h.optional,
1912
+ disabled: !y.optional,
1530
1913
  inversed: "",
1531
1914
  style: { "padding-right": "8px" }
1532
1915
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1533
- (i(), E(ke(h.component), {
1534
- modelValue: h.value,
1535
- "onUpdate:modelValue": (M) => h.value = M,
1536
- node: p.value,
1537
- intf: h,
1916
+ (d(), j(Me(y.component), {
1917
+ modelValue: y.value,
1918
+ "onUpdate:modelValue": (T) => y.value = T,
1919
+ node: c.value,
1920
+ intf: y,
1538
1921
  style: { width: "100%" }
1539
1922
  }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1540
1923
  ])
1541
1924
  ]))), 128))
1542
1925
  ]),
1543
- l("div", tn, [
1544
- _.value && _.value.state ? (i(), d("div", sn, [
1545
- w[3] || (w[3] = l("label", null, "Variable name", -1)),
1546
- ee(l("input", {
1547
- "onUpdate:modelValue": w[1] || (w[1] = (h) => _.value.state.variableName = h),
1926
+ u("div", Xs, [
1927
+ h.value && h.value.state ? (d(), p("div", qs, [
1928
+ N[3] || (N[3] = u("label", null, "Variable name", -1)),
1929
+ de(u("input", {
1930
+ "onUpdate:modelValue": N[1] || (N[1] = (y) => h.value.state.variableName = y),
1548
1931
  type: "text",
1549
1932
  class: "baklava-input",
1550
1933
  title: "Variable name",
1551
- onBlur: y,
1552
- onKeydown: ne(y, ["enter"])
1934
+ onBlur: b,
1935
+ onKeydown: he(b, ["enter"])
1553
1936
  }, null, 544), [
1554
- [te, _.value.state.variableName]
1937
+ [le, h.value.state.variableName]
1555
1938
  ])
1556
- ])) : N("", !0),
1557
- (i(!0), d(S, null, D(L.value, (h) => (i(), d("div", {
1558
- key: h.id,
1939
+ ])) : M("", !0),
1940
+ (d(!0), p(B, null, J(m.value, (y) => (d(), p("div", {
1941
+ key: y.id,
1559
1942
  class: "__interface"
1560
1943
  }, [
1561
- l("div", nn, [
1562
- z(Ie, {
1563
- modelValue: h.hidden,
1944
+ u("div", Js, [
1945
+ L(Re, {
1946
+ modelValue: y.hidden,
1564
1947
  "onUpdate:modelValue": [
1565
- (M) => h.hidden = M,
1566
- w[2] || (w[2] = () => p.value?.events.update.emit(null))
1948
+ (T) => y.hidden = T,
1949
+ N[2] || (N[2] = () => c.value?.events.update.emit(null))
1567
1950
  ],
1568
- disabled: !h.optional,
1951
+ disabled: !y.optional,
1569
1952
  inversed: "",
1570
1953
  style: { "padding-right": "8px" }
1571
1954
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1572
- (i(), E(ke(h.component), {
1573
- modelValue: h.value,
1574
- "onUpdate:modelValue": (M) => h.value = M,
1575
- node: p.value,
1576
- intf: h,
1955
+ (d(), j(Me(y.component), {
1956
+ modelValue: y.value,
1957
+ "onUpdate:modelValue": (T) => y.value = T,
1958
+ node: c.value,
1959
+ intf: y,
1577
1960
  style: { width: "100%" }
1578
1961
  }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1579
1962
  ])
1580
1963
  ]))), 128))
1581
1964
  ])
1582
1965
  ]),
1583
- X(m.$slots, "codeEditor", { node: p.value })
1584
- ], 64)) : N("", !0)
1966
+ ne(f.$slots, "codeEditor", { node: c.value })
1967
+ ], 64)) : M("", !0)
1585
1968
  ], 6));
1586
1969
  }
1587
1970
  });
1588
- function an(s, e) {
1589
- return Object.fromEntries(Object.entries(s).filter(e));
1971
+ class at extends Qe {
1972
+ _title = "Subgraph Input";
1973
+ inputs = {
1974
+ _code: new R("", "").use($, U).setHidden(!0),
1975
+ name: new be("Name", "Input").setPort(!1)
1976
+ };
1977
+ outputs = {
1978
+ _code: new R("", "").use($, U).setHidden(!0),
1979
+ placeholder: new A("Connection", void 0)
1980
+ };
1590
1981
  }
1591
- const rn = R({
1592
- props: {
1593
- type: {
1594
- type: String,
1595
- required: !0
1596
- },
1597
- title: {
1598
- type: String,
1599
- required: !0
1600
- }
1601
- },
1602
- setup(s) {
1603
- const { viewModel: e } = K(), { switchGraph: t } = ae(), n = V(!1), o = b(() => s.type.startsWith(se));
1604
- return { showContextMenu: n, hasContextMenu: o, contextMenuItems: [
1605
- { label: "Edit Subgraph", value: "editSubgraph" },
1606
- { label: "Delete Subgraph", value: "deleteSubgraph" }
1607
- ], openContextMenu: () => {
1608
- n.value = !0;
1609
- }, onContextMenuClick: (p) => {
1610
- const _ = s.type.substring(se.length), g = e.value.editor.graphTemplates.find((I) => I.id === _);
1611
- if (g)
1612
- switch (p) {
1613
- case "editSubgraph":
1614
- t(g);
1615
- break;
1616
- case "deleteSubgraph":
1617
- e.value.editor.removeGraphTemplate(g);
1618
- break;
1619
- }
1620
- } };
1621
- }
1622
- }), dn = ["data-node-type"], ln = { class: "__title" }, un = { class: "__title-label" };
1623
- function cn(s, e, t, n, o, a) {
1624
- return i(), d("div", {
1625
- class: "baklava-node --palette",
1626
- "data-node-type": s.type
1627
- }, [
1628
- l("div", ln, [
1629
- l("div", un, j(s.title), 1)
1630
- ])
1631
- ], 8, dn);
1982
+ class it extends Ze {
1983
+ _title = "Subgraph Output";
1984
+ inputs = {
1985
+ _code: new R("", "").use($, U).setHidden(!0),
1986
+ name: new be("Name", "Output").setPort(!1),
1987
+ placeholder: new A("Connection", void 0)
1988
+ };
1989
+ outputs = {
1990
+ _code: new R("", "").use($, U).setHidden(!0),
1991
+ output: new A("Output", void 0).setHidden(!0)
1992
+ };
1632
1993
  }
1633
- const Ne = /* @__PURE__ */ O(rn, [["render", cn]]), pn = {
1634
- class: "baklava-node --palette",
1635
- style: { "margin-top": "-20px", "margin-bottom": "20px" }
1636
- }, hn = {
1637
- key: 0,
1638
- style: { display: "flex", "justify-content": "space-between" }
1639
- }, mn = ["onClick"], vn = {
1640
- key: 0,
1641
- style: { margin: "auto 0", "font-size": "12px" }
1642
- }, fn = /* @__PURE__ */ R({
1643
- __name: "CodeNodePalette",
1644
- setup(s) {
1645
- const { viewModel: e } = K(), { x: t, y: n } = xt(), { transform: o } = ct(), a = pt(e), r = yt("editorEl"), u = V(""), p = V(null), _ = () => u.value ? a.value.filter(
1646
- (x) => x.name.toLowerCase().includes(u.value.toLowerCase()) || Object.values(x.nodeTypes).some(
1647
- (y) => y.title.toLowerCase().includes(u.value.toLowerCase())
1994
+ const Zs = "CREATE_SUBGRAPH", je = [kt, Nt];
1995
+ function eo(n, e, t) {
1996
+ const s = () => n.value.selectedNodes.filter((a) => !je.includes(a.type)).length > 0, o = () => {
1997
+ const { viewModel: a } = oe(), i = n.value, r = n.value.editor;
1998
+ if (i.selectedNodes.length === 0) return;
1999
+ const c = i.selectedNodes.filter((v) => !je.includes(v.type)), h = c.flatMap((v) => Object.values(v.inputs)), g = c.flatMap((v) => Object.values(v.outputs)), _ = i.connections.filter(
2000
+ (v) => !g.includes(v.from) && h.includes(v.to)
2001
+ ), m = i.connections.filter(
2002
+ (v) => g.includes(v.from) && !h.includes(v.to)
2003
+ ), k = i.connections.filter(
2004
+ (v) => g.includes(v.from) && h.includes(v.to)
2005
+ ), b = c.map((v) => v.save()), I = k.map((v) => ({
2006
+ id: v.id,
2007
+ from: v.from.id,
2008
+ to: v.to.id
2009
+ })), l = /* @__PURE__ */ new Map(), { xLeft: f, xRight: N, yTop: y } = to(c);
2010
+ for (const [v, S] of _.entries()) {
2011
+ const H = new at();
2012
+ H.inputs.name.value = S.to.name, b.push({
2013
+ ...H.save(),
2014
+ position: { x: N - a.value.settings.nodes.defaultWidth - 100, y: y + v * 200 }
2015
+ }), I.push({ id: K(), from: H.outputs.placeholder.id, to: S.to.id }), l.set(S.to.id, H.graphInterfaceId);
2016
+ }
2017
+ for (const [v, S] of m.entries()) {
2018
+ const H = new it();
2019
+ H.inputs.name.value = S.from.name, b.push({
2020
+ ...H.save(),
2021
+ position: { x: f + 100, y: y + v * 200 }
2022
+ }), I.push({ id: K(), from: S.from.id, to: H.inputs.placeholder.id }), l.set(S.from.id, H.graphInterfaceId);
2023
+ }
2024
+ const T = D(
2025
+ new ce(
2026
+ {
2027
+ connections: I,
2028
+ nodes: b,
2029
+ // ignored, but still providing to make TS happy
2030
+ inputs: [],
2031
+ outputs: []
2032
+ },
2033
+ r
1648
2034
  )
1649
- ) : a.value, g = (x) => u.value ? an(x, (y) => {
1650
- const f = y[1];
1651
- return f.category.includes(u.value.toLowerCase()) || f.title?.toLowerCase().includes(u.value.toLowerCase());
1652
- }) : x, I = b(() => {
1653
- if (!p.value || !r?.value) return {};
1654
- const { left: x, top: y } = r.value.getBoundingClientRect();
1655
- return {
1656
- top: `${n.value - y}px`,
1657
- left: `${t.value - x}px`
1658
- };
1659
- }), L = (x, y) => {
1660
- p.value = {
1661
- type: x,
1662
- nodeInformation: y
1663
- };
1664
- const f = () => {
1665
- const $ = q(new y.type());
1666
- e.value.displayedGraph.addNode($);
1667
- const m = r.value.getBoundingClientRect(), [w, h] = o(t.value - m.left, n.value - m.top);
1668
- $.position.x = w, $.position.y = h, p.value = null, document.removeEventListener("pointerup", f);
1669
- };
1670
- document.addEventListener("pointerup", f);
1671
- };
1672
- return (x, y) => (i(), d(S, null, [
1673
- l("div", {
1674
- class: P([{ "--open": k(e).settings.palette.enabled }, "baklava-node-palette"]),
1675
- onContextmenu: y[1] || (y[1] = F(() => {
1676
- }, ["stop", "prevent"]))
1677
- }, [
1678
- l("div", pn, [
1679
- ee(l("input", {
1680
- "onUpdate:modelValue": y[0] || (y[0] = (f) => u.value = f),
1681
- type: "text",
1682
- class: "baklava-input",
1683
- title: "Filter nodes",
1684
- onKeyup: _
1685
- }, null, 544), [
1686
- [te, u.value]
1687
- ])
1688
- ]),
1689
- (i(!0), d(S, null, D(_(), (f) => (i(), d("section", {
1690
- key: f.name
1691
- }, [
1692
- f.name !== "default" ? (i(), d("h3", hn, [
1693
- l("div", {
1694
- onClick: ($) => u.value = f.name,
1695
- style: { cursor: "pointer" }
1696
- }, j(f.name), 9, mn),
1697
- Object.keys(g(f.nodeTypes)).length < Object.values(f.nodeTypes).length ? (i(), d("div", vn, " ( " + j(Object.keys(g(f.nodeTypes)).length) + " / " + j(Object.values(f.nodeTypes).length) + " ) ", 1)) : N("", !0)
1698
- ])) : N("", !0),
1699
- (i(!0), d(S, null, D(g(f.nodeTypes), ($, m) => (i(), E(Ne, {
1700
- key: m,
1701
- type: m,
1702
- title: $.title,
1703
- onPointerdown: (w) => L(m, $)
1704
- }, null, 8, ["type", "title", "onPointerdown"]))), 128))
1705
- ]))), 128))
1706
- ], 34),
1707
- z(Ct, { name: "fade" }, {
1708
- default: W(() => [
1709
- p.value ? (i(), d("div", {
1710
- key: 0,
1711
- class: "baklava-dragged-node",
1712
- style: re(I.value)
1713
- }, [
1714
- z(Ne, {
1715
- type: p.value.type,
1716
- title: p.value.nodeInformation.title
1717
- }, null, 8, ["type", "title"])
1718
- ], 4)) : N("", !0)
1719
- ]),
1720
- _: 1
1721
- })
1722
- ], 64));
2035
+ );
2036
+ r.addGraphTemplate(T);
2037
+ const ie = r.nodeTypes.get(Ue(T));
2038
+ if (!ie) throw new Error("Unable to create subgraph: Could not find corresponding graph node type");
2039
+ i.activeTransactions++;
2040
+ const W = D(new ie.type());
2041
+ i.addNode(W);
2042
+ const pe = Math.round(
2043
+ c.map((v) => v.position.x).reduce((v, S) => v + S, 0) / c.length
2044
+ ), re = Math.round(
2045
+ c.map((v) => v.position.y).reduce((v, S) => v + S, 0) / c.length
2046
+ );
2047
+ W.position.x = pe, W.position.y = re, _.forEach((v) => {
2048
+ i.removeConnection(v), i.addConnection(v.from, W.inputs[l.get(v.to.id)]);
2049
+ }), m.forEach((v) => {
2050
+ i.removeConnection(v), i.addConnection(W.outputs[l.get(v.from.id)], v.to);
2051
+ }), c.forEach((v) => i.removeNode(v)), i.activeTransactions--, e.canExecuteCommand(q.SAVE_SUBGRAPH_COMMAND) && e.executeCommand(q.SAVE_SUBGRAPH_COMMAND), t(T), n.value.panning = { ...i.panning }, n.value.scaling = i.scaling;
2052
+ };
2053
+ e.registerCommand(Zs, {
2054
+ canExecute: s,
2055
+ execute: o
2056
+ });
2057
+ }
2058
+ function to(n) {
2059
+ const e = n.reduce((o, a) => {
2060
+ const i = a.position.x;
2061
+ return i < o ? i : o;
2062
+ }, 1 / 0), t = n.reduce((o, a) => {
2063
+ const i = a.position.y;
2064
+ return i < o ? i : o;
2065
+ }, 1 / 0);
2066
+ return { xLeft: n.reduce((o, a) => {
2067
+ const i = a.position.x + a.width;
2068
+ return i > o ? i : o;
2069
+ }, -1 / 0), xRight: e, yTop: t };
2070
+ }
2071
+ class no extends xt {
2072
+ code;
2073
+ graph;
2074
+ constructor(e) {
2075
+ super(), this.code = e, this.graph = new ue(this);
1723
2076
  }
1724
- }), Un = /* @__PURE__ */ R({
1725
- __name: "CodeGraphEditor",
1726
- props: {
1727
- viewModel: {}
1728
- },
1729
- setup(s) {
1730
- const t = $e(s, "viewModel"), n = (o) => o.events.update.emit(null);
1731
- return ie(() => {
1732
- t.value.subscribe(), t.value.engine.start();
1733
- }), kt(() => {
1734
- t.value.unsubscribe(), t.value.engine.stop();
1735
- }), (o, a) => (i(), E(k(ht), { "view-model": t.value }, {
1736
- palette: W(() => [
1737
- z(fn)
1738
- ]),
1739
- node: W((r) => [
1740
- z(Xs, Nt(r, {
1741
- onUpdate: (u) => n(r.node)
1742
- }), null, 16, ["onUpdate"])
1743
- ]),
1744
- sidebar: W((r) => [
1745
- z(on, wt(It(r)), {
1746
- codeEditor: W(({ node: u }) => [
1747
- X(o.$slots, "sidebarCodeEditor", { node: u })
1748
- ]),
1749
- _: 3
1750
- }, 16)
1751
- ]),
1752
- _: 3
1753
- }, 8, ["view-model"]));
2077
+ get graphIds() {
2078
+ const e = [];
2079
+ return this.graphs.forEach((t) => e.push(t.id)), e.map((t) => t.slice(0, 6)).join(", ");
2080
+ }
2081
+ get graphTemplateIds() {
2082
+ const e = [];
2083
+ return this.graphTemplates.forEach((t) => e.push(t.id)), e.map((t) => t.slice(0, 6)).join(", ");
2084
+ }
2085
+ /**
2086
+ * Add code graph template.
2087
+ * @param template code graph template
2088
+ */
2089
+ addGraphTemplate(e) {
2090
+ if (this.events.beforeAddGraphTemplate.emit(e).prevented) return;
2091
+ this._graphTemplates.push(e), this.graphTemplateEvents.addTarget(e.events), this.graphTemplateHooks.addTarget(e.hooks);
2092
+ const t = mn(e);
2093
+ this.registerNodeType(t, { category: "Subgraphs", title: e.name }), this.events.addGraphTemplate.emit(e);
2094
+ }
2095
+ /**
2096
+ * Load a state
2097
+ * @param state State to load
2098
+ * @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
2099
+ */
2100
+ load(e) {
2101
+ try {
2102
+ for (super._loading = !0, e = this.hooks.load.execute(e); this.graphTemplates.length > 0; )
2103
+ this.removeGraphTemplate(this.graphTemplates[0]);
2104
+ e.graphTemplates.forEach((s) => {
2105
+ const o = new ce(s, this);
2106
+ this.addGraphTemplate(o);
2107
+ });
2108
+ const t = this.graph.load(e.graph);
2109
+ return this.events.loaded.emit(), t.forEach((s) => console.warn(s)), t;
2110
+ } finally {
2111
+ super._loading = !1;
2112
+ }
2113
+ }
2114
+ /**
2115
+ * Register category module
2116
+ * @param category string
2117
+ * @param module string
2118
+ */
2119
+ registerCategoryModule(e, t) {
2120
+ this.code.state.modules[e] = t;
1754
2121
  }
1755
- });
1756
- function Hn(s) {
1757
- const e = mt(s?.existingEditor);
1758
- return e.code = s?.code ? new s.code(e) : new Pt(e), e.editor.addGraphTemplate = function(t) {
1759
- if (this.events.beforeAddGraphTemplate.emit(t).prevented)
1760
- return;
1761
- this._graphTemplates.push(t), this.graphTemplateEvents.addTarget(t.events), this.graphTemplateHooks.addTarget(t.hooks);
1762
- const n = Rt(t);
1763
- this.registerNodeType(n, { category: "Subgraphs", title: t.name }), this.events.addGraphTemplate.emit(t);
1764
- }, gn(e), bn(e), e.state = q({
1765
- modules: {},
1766
- token: null
1767
- }), e.init = () => {
1768
- e.unsubscribe(), e.engine = new vt(e.editor);
1769
- }, e.loadEditor = (t) => {
1770
- e.engine?.pause(), e.code.clear(), e.editor.load(t), e.commandHandler.executeCommand(Z.CLEAR_CLIPBOARD_COMMAND), e.commandHandler.executeCommand(Z.CLEAR_HISTORY_COMMAND), e.engine?.resume(), e.engine?.runOnce(void 0);
1771
- }, e.newGraph = () => {
1772
- e.engine?.pause(), e.code.clear(), e.editor.graph.id = Te(), e.engine?.resume(), e.engine?.runOnce(void 0);
1773
- }, e.subscribe = () => {
1774
- e.state.token && e.unsubscribe();
1775
- const t = Symbol(), n = e.displayedGraph;
1776
- n.events.addNode.subscribe(t, (o) => {
1777
- !o.subgraph && o.isCodeNode && (o.code = e.code);
1778
- }), n.events.addConnection.subscribe(t, (o) => {
1779
- const a = e.code.findNodeById(o.to.nodeId);
1780
- a && a.isCodeNode && a.onConnected();
1781
- const r = e.code.findNodeById(o.from.nodeId);
1782
- r && r.isCodeNode && r.onConnected();
1783
- }), n.events.removeConnection.subscribe(t, (o) => {
1784
- const a = e.code.findNodeById(o.to.nodeId);
1785
- a && a.isCodeNode && a.onUnconnected();
1786
- const r = e.code.findNodeById(o.from.nodeId);
1787
- r && r.isCodeNode && r.onUnconnected();
1788
- }), e.engine.events.beforeRun.subscribe(t, () => {
1789
- e.engine.pause(), e.code && (e.code.updateCodeNodes(), e.code.sortNodes(), e.code.updateCodeTemplates(), e.code.resetInputInterfaceScript()), e.engine.resume();
1790
- }), e.engine.events.beforeNodeCalculation.subscribe(t, (o) => {
1791
- e.engine.pause();
1792
- const a = o.node;
1793
- a.isCodeNode && (a.updateOutputNames(), a.updateConnectedInputInterfaces()), e.engine.resume();
1794
- }), e.engine.events.afterRun.subscribe(t, () => {
1795
- e.engine.pause(), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
1796
- }), e.state.token = t;
1797
- }, e.unsubscribe = () => {
1798
- if (!e.state.token) return;
1799
- const t = e.state.token;
1800
- e.displayedGraph.events.addNode.unsubscribe(t), e.displayedGraph.events.addConnection.unsubscribe(t), e.engine.events.beforeRun.unsubscribe(t), e.engine.events.beforeNodeCalculation.unsubscribe(t), e.engine.events.afterRun.unsubscribe(t), e.state.token = null;
1801
- }, e;
1802
2122
  }
1803
- const gn = (s) => {
1804
- const e = "TOGGLE_PALETTE";
1805
- s.commandHandler.registerCommand(e, {
1806
- execute: () => s.settings.palette.enabled = !s.settings.palette.enabled,
1807
- canExecute: () => !0
1808
- });
1809
- const t = {
1810
- command: e,
1811
- title: "Toggle palette",
1812
- // Tooltip text
1813
- icon: b(() => s.settings.palette.enabled ? es : os)
1814
- }, n = "CLEAR_ALL";
1815
- s.commandHandler.registerCommand(n, {
1816
- execute: () => s.code.clear(),
1817
- canExecute: () => s.displayedGraph.nodes.length > 0
2123
+ function Go(n) {
2124
+ const e = V(n?.code ?? new fn()), t = V(n?.existingEditor ?? new no(e.value)), s = Symbol("ViewModelToken"), o = V(null), a = _t(o), { switchGraph: i } = Is(t, o), r = O(() => a.value && a.value !== t.value.graph), c = D(Ut());
2125
+ c.nodes.defaultWidth = 400;
2126
+ const h = At(), g = Dt(a, h), _ = Ft(a, t, h), m = {
2127
+ /** Called whenever a node is rendered */
2128
+ renderNode: new Ge(null),
2129
+ /** Called whenever an interface is rendered */
2130
+ renderInterface: new Ge(null)
2131
+ }, k = D({
2132
+ clipboard: _,
2133
+ code: e,
2134
+ commandHandler: h,
2135
+ displayedGraph: a,
2136
+ editor: t,
2137
+ history: g,
2138
+ hooks: m,
2139
+ isSubgraph: r,
2140
+ settings: c,
2141
+ switchGraph: i
1818
2142
  });
1819
- const o = {
1820
- command: n,
1821
- title: "Clear all",
1822
- // Tooltip text
1823
- icon: b(() => js)
1824
- }, a = "TOGGLE_MINIMAP";
1825
- s.commandHandler.registerCommand(a, {
1826
- execute: () => s.settings.enableMinimap = !s.settings.enableMinimap,
1827
- canExecute: () => s.displayedGraph.nodes.length > 1
1828
- });
1829
- const r = {
1830
- command: a,
1831
- title: "Toggle minimap",
1832
- // Tooltip text
1833
- icon: b(() => s.settings.enableMinimap ? Os : Is)
1834
- };
1835
- s.settings.toolbar.commands = [t, ...ft, o, r];
1836
- }, bn = (s) => {
1837
- s.settings.nodes.defaultWidth = 400;
1838
- };
2143
+ return e.value.registerViewModel(k), bs(k), Wt(a, h), eo(a, h, i), Yt(a, h), Kt(a, h, i), Xt(a, h), qt(a, h, c), fs(a, h, c), vs(c), He(
2144
+ t,
2145
+ (b, I) => {
2146
+ I && (I.events.registerGraph.unsubscribe(s), I.graphEvents.beforeAddNode.unsubscribe(s), b.nodeHooks.beforeLoad.unsubscribe(s), b.nodeHooks.afterSave.unsubscribe(s), b.graphTemplateHooks.beforeLoad.unsubscribe(s), b.graphTemplateHooks.afterSave.unsubscribe(s), b.graph.hooks.load.unsubscribe(s), b.graph.hooks.save.unsubscribe(s)), b && (b.nodeHooks.beforeLoad.subscribe(s, (l, f) => (f.position = l.position ?? { x: 0, y: 0 }, f.width = l.width ?? c.nodes.defaultWidth, f.twoColumn = l.twoColumn ?? !1, l)), b.nodeHooks.afterSave.subscribe(s, (l, f) => (l.position = f.position, l.width = f.width, l.twoColumn = f.twoColumn, l)), b.graphTemplateHooks.beforeLoad.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graphTemplateHooks.afterSave.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graph.hooks.load.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graph.hooks.save.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graphEvents.beforeAddNode.subscribe(
2147
+ s,
2148
+ (l) => Jt(l, { defaultWidth: c.nodes.defaultWidth })
2149
+ ), t.value.registerNodeType(at, { category: "Subgraphs" }), t.value.registerNodeType(it, { category: "Subgraphs" }), i(b.graph));
2150
+ },
2151
+ { immediate: !0 }
2152
+ ), k;
2153
+ }
1839
2154
  export {
1840
- Ee as AbstractCodeNode,
1841
- xn as CheckboxInterface,
1842
- Pt as Code,
1843
- Un as CodeGraphEditor,
1844
- Se as CodeNode,
1845
- Q as CodeNodeInputInterface,
1846
- G as CodeNodeInterface,
1847
- de as CodeNodeInterfaceComponent,
1848
- Le as CodeNodeOutputInterface,
1849
- Wt as CodeVariable,
1850
- qt as DotsVertical,
1851
- Lt as DynamicCodeNode,
1852
- Ln as GRAPH_NODE_TYPE_PREFIX,
1853
- Mn as IntegerInterface,
1854
- es as LayoutSidebarLeftCollapse,
1855
- os as LayoutSidebarLeftExpand,
1856
- ds as LayoutSidebarRight,
1857
- ps as LayoutSidebarRightCollapse,
1858
- fs as LayoutSidebarRightExpand,
1859
- On as ListInputInterface,
1860
- ys as LockCode,
1861
- $n as NumberInterface,
1862
- Is as Schema,
1863
- Os as SchemaOff,
1864
- Tn as SelectInterface,
1865
- En as SliderInterface,
1866
- Sn as TextInputInterface,
1867
- jt as TextInputInterfaceComponent,
1868
- Bn as TextareaInputInterface,
1869
- Ss as TransitionBottom,
1870
- js as TrashOff,
1871
- Vn as TupleInputInterface,
1872
- Nn as addDefaultInterfaceTypes,
1873
- gn as addToolbarCommands,
1874
- Ve as booleanType,
1875
- Rt as createCodeGraphNodeType,
1876
- zn as defineCodeNode,
1877
- jn as defineDynamicCodeNode,
1878
- Tt as dictType,
1879
- Mt as formatInputs,
1880
- oe as getCodeNodes,
1881
- Rn as getPositionAtColumn,
1882
- Pn as getPositionBeforeNode,
1883
- ze as listType,
1884
- Be as loadNodeState,
2155
+ We as AbstractCodeNode,
2156
+ et as CLEAR_ALL_COMMAND,
2157
+ Zs as CREATE_SUBGRAPH_COMMAND,
2158
+ fo as CheckboxInterface,
2159
+ fn as Code,
2160
+ vn as CodeEngine,
2161
+ ue as CodeGraph,
2162
+ $o as CodeGraphEditor,
2163
+ Mo as CodeGraphInfo,
2164
+ Qe as CodeGraphInputNode,
2165
+ Ps as CodeGraphNode,
2166
+ Ve as CodeGraphNodeInterface,
2167
+ Ze as CodeGraphOutputNode,
2168
+ Qs as CodeGraphSidebar,
2169
+ ce as CodeGraphTemplate,
2170
+ _e as CodeNode,
2171
+ ae as CodeNodeInputInterface,
2172
+ R as CodeNodeInterface,
2173
+ ye as CodeNodeInterfaceComponent,
2174
+ on as CodeNodeOutputInterface,
2175
+ Ls as CodeNodePalette,
2176
+ yn as CodeVariable,
2177
+ kn as DotsVertical,
2178
+ pn as DynamicCodeNode,
2179
+ Se as GRAPH_INPUT_NODE_TYPE,
2180
+ Pe as GRAPH_OUTPUT_NODE_TYPE,
2181
+ vo as IntegerInterface,
2182
+ Tn as LayoutSidebarLeftCollapse,
2183
+ Gn as LayoutSidebarLeftExpand,
2184
+ Rn as LayoutSidebarRight,
2185
+ Hn as LayoutSidebarRightCollapse,
2186
+ Dn as LayoutSidebarRightExpand,
2187
+ go as ListInputInterface,
2188
+ Kn as LockCode,
2189
+ bo as NumberInterface,
2190
+ Qn as PlayerPlay,
2191
+ tt as RUN_ENGINE_COMMAND,
2192
+ ns as Schema,
2193
+ is as SchemaOff,
2194
+ _o as SelectInterface,
2195
+ Re as SidebarCheckbox,
2196
+ yo as SliderInterface,
2197
+ at as SubgraphInputNode,
2198
+ it as SubgraphOutputNode,
2199
+ nt as TOGGLE_MINIMAP_COMMAND,
2200
+ st as TOGGLE_PALETTE_COMMAND,
2201
+ Co as TextInputInterface,
2202
+ cn as TextInputInterfaceComponent,
2203
+ Io as TextareaInputInterface,
2204
+ us as TransitionBottom,
2205
+ ms as TrashOff,
2206
+ wo as TupleInputInterface,
2207
+ mo as addDefaultInterfaceTypes,
2208
+ Oo as allowMultipleConnections,
2209
+ Ke as booleanType,
2210
+ mn as createCodeGraphNodeType,
2211
+ ko as defineCodeNode,
2212
+ No as defineDynamicCodeNode,
2213
+ sn as dictType,
2214
+ en as formatInputs,
2215
+ ot as getCodeNodes,
2216
+ To as getPositionAtColumn,
2217
+ Eo as getPositionBeforeNode,
2218
+ Xe as listType,
2219
+ Ye as loadNodeState,
1885
2220
  U as nodeType,
1886
- le as numberType,
1887
- Ot as saveNodeState,
1888
- ue as stringType,
1889
- je as tupleType,
1890
- bn as updateSettings,
1891
- Hn as useCodeGraph
2221
+ Ce as numberType,
2222
+ bs as registerCodeEngine,
2223
+ eo as registerCreateSubgraphCommand,
2224
+ fs as registerCustomCommands,
2225
+ gs as registerRunEngineCommands,
2226
+ tn as saveNodeState,
2227
+ Ie as stringType,
2228
+ qe as tupleType,
2229
+ vs as updateToolbarItems,
2230
+ Go as useCodeGraph,
2231
+ Is as useSwitchCodeGraph
1892
2232
  };