@babsey/code-graph 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,21 @@
1
- import { AbstractNode, NodeInterfaceType, NodeInterface, ButtonInterfaceComponent, CheckboxInterfaceComponent, IntegerInterfaceComponent, NumberInterfaceComponent, SelectInterfaceComponent, SliderInterfaceComponent, TextInputInterfaceComponent, TextareaInputInterfaceComponent, setType, allowMultipleConnections, IntegerInterface as IntegerInterface$1, TextInputInterface as TextInputInterface$1, displayInSidebar, sortTopologically, useViewModel, useTemporaryConnection, Components, useGraph, GRAPH_NODE_TYPE_PREFIX, useTransform, useNodeCategories, BaklavaEditor, DEFAULT_TOOLBAR_COMMANDS, useBaklava, DependencyEngine, applyResult } from "baklavajs";
2
- import { ButtonInterfaceComponent as ButtonInterfaceComponent2, CheckboxInterfaceComponent as CheckboxInterfaceComponent2, IntegerInterfaceComponent as IntegerInterfaceComponent2, NumberInterfaceComponent as NumberInterfaceComponent2, SelectInterfaceComponent as SelectInterfaceComponent2, SliderInterfaceComponent as SliderInterfaceComponent2, TextInputInterfaceComponent as TextInputInterfaceComponent2, TextareaInputInterfaceComponent as TextareaInputInterfaceComponent2 } from "baklavajs";
3
- import mustache from "mustache";
4
- import { reactive, defineComponent, createElementBlock, openBlock, toDisplayString, markRaw, ref, computed, onMounted, onUpdated, normalizeClass, createCommentVNode, createElementVNode, unref, renderSlot, createStaticVNode, onBeforeUnmount, normalizeStyle, withModifiers, createBlock, withDirectives, Fragment, createTextVNode, createVNode, withKeys, vModelText, renderList, nextTick, toRef, resolveDynamicComponent, inject, Transition, withCtx, onUnmounted, normalizeProps, guardReactiveProps, mergeProps } from "vue";
5
- import toposort from "toposort";
6
- import { v4 } from "uuid";
7
- import { usePointer } from "@vueuse/core";
8
- class AbstractCodeNode extends AbstractNode {
1
+ import { AbstractNode as Be, NodeInterfaceType as P, NodeInterface as Ve, ButtonInterfaceComponent as Le, CheckboxInterfaceComponent as Ge, IntegerInterfaceComponent as Ue, NumberInterfaceComponent as je, SelectInterfaceComponent as Re, SliderInterfaceComponent as Pe, TextInputInterfaceComponent as ge, TextareaInputInterfaceComponent as De, setType as j, allowMultipleConnections as X, IntegerInterface as Ae, TextInputInterface as He, displayInSidebar as Fe, sortTopologically as We, useViewModel as H, useTemporaryConnection as Xe, Components as ve, useGraph as K, GRAPH_NODE_TYPE_PREFIX as J, useTransform as Ye, useNodeCategories as Je, BaklavaEditor as qe, DEFAULT_TOOLBAR_COMMANDS as Qe, useBaklava as Ze, DependencyEngine as Ke, applyResult as et } from "baklavajs";
2
+ import { ButtonInterfaceComponent as an, CheckboxInterfaceComponent as rn, IntegerInterfaceComponent as ln, NumberInterfaceComponent as dn, SelectInterfaceComponent as un, SliderInterfaceComponent as cn, TextInputInterfaceComponent as pn, TextareaInputInterfaceComponent as hn } from "baklavajs";
3
+ import be from "mustache";
4
+ import { reactive as R, defineComponent as G, createElementBlock as r, openBlock as i, toDisplayString as L, markRaw as $, ref as E, computed as f, onMounted as ee, onUpdated as _e, normalizeClass as U, createCommentVNode as N, createElementVNode as l, unref as _, renderSlot as q, createStaticVNode as te, onBeforeUnmount as tt, normalizeStyle as se, withModifiers as D, createBlock as V, withDirectives as ne, Fragment as T, createTextVNode as st, createVNode as S, withKeys as Q, vModelText as oe, renderList as A, nextTick as nt, toRef as ye, resolveDynamicComponent as ot, inject as at, Transition as it, withCtx as W, onUnmounted as rt, normalizeProps as lt, guardReactiveProps as dt, mergeProps as ut } from "vue";
5
+ import ct from "toposort";
6
+ import { v4 as pt } from "uuid";
7
+ import { usePointer as ht } from "@vueuse/core";
8
+ class vt extends Be {
9
9
  state;
10
10
  code;
11
- isCodeNode = true;
11
+ isCodeNode = !0;
12
12
  inputs = {};
13
13
  outputs = {};
14
14
  constructor() {
15
- super();
16
- this.initializeIo();
17
- this.width = 400;
18
- this.twoColumn = true;
19
- this.state = reactive({
15
+ super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state = R({
20
16
  codeTemplate: "{{ &outputs.code }}",
21
- hidden: false,
22
- integrated: false,
17
+ hidden: !1,
18
+ integrated: !1,
23
19
  modules: [],
24
20
  script: "",
25
21
  variableName: ""
@@ -29,7 +25,7 @@ class AbstractCodeNode extends AbstractNode {
29
25
  return this.state.codeTemplate;
30
26
  }
31
27
  get idx() {
32
- return this.code?.codeNodes.filter((node) => !node.state.integrated).indexOf(this) ?? -1;
28
+ return this.code?.codeNodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
33
29
  }
34
30
  get idxByVariableNames() {
35
31
  return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this) ?? -1;
@@ -48,48 +44,43 @@ class AbstractCodeNode extends AbstractNode {
48
44
  * @param type inputs or outputs
49
45
  * @returns code node instances
50
46
  */
51
- getConnectedNodes(type) {
52
- let nodeIds = [];
53
- if (type !== "inputs") {
54
- const targets = this.graph?.connections.filter((c) => c.from.name !== "_node").filter((c) => c.from.nodeId === this.id).map((c) => c.to.nodeId);
55
- if (targets) nodeIds = nodeIds.concat(targets);
47
+ getConnectedNodes(e) {
48
+ let t = [];
49
+ if (e !== "inputs") {
50
+ const s = this.graph?.connections.filter((n) => n.from.name !== "_node").filter((n) => n.from.nodeId === this.id).map((n) => n.to.nodeId);
51
+ s && (t = t.concat(s));
56
52
  }
57
- if (type !== "outputs") {
58
- const sources = this.graph?.connections.filter((c) => c.from.name !== "_node").filter((c) => c.to.nodeId === this.id).map((c) => c.from.nodeId);
59
- if (sources) nodeIds = nodeIds.concat(sources);
53
+ if (e !== "outputs") {
54
+ const s = this.graph?.connections.filter((n) => n.from.name !== "_node").filter((n) => n.to.nodeId === this.id).map((n) => n.from.nodeId);
55
+ s && (t = t.concat(s));
60
56
  }
61
- if (!nodeIds || nodeIds.length == 0) return [];
62
- return nodeIds.map((nodeId) => this.graph?.findNodeById(nodeId));
57
+ return !t || t.length == 0 ? [] : t.map((s) => this.graph?.findNodeById(s));
63
58
  }
64
- registerCode(code) {
65
- this.code = code;
59
+ registerCode(e) {
60
+ this.code = e;
66
61
  }
67
62
  /**
68
63
  * Render code of this node.
69
64
  */
70
65
  renderCode() {
71
- const inputs = {};
72
- Object.keys(this.inputs).forEach((intfKey) => {
73
- if (intfKey === "_node") return;
74
- const intf = this.inputs[intfKey];
75
- const value = intf.isString ? `'${intf.value}'` : intf.value;
76
- if (intf && intf.state) inputs[intfKey] = intf.state.script.length > 0 ? intf.state.script : value;
66
+ const e = {};
67
+ Object.keys(this.inputs).forEach((s) => {
68
+ if (s === "_node") return;
69
+ const n = this.inputs[s], a = n.isString ? `'${n.value}'` : n.value;
70
+ n && n.state && (e[s] = n.state.script.length > 0 ? n.state.script : a);
77
71
  });
78
- const outputs = {};
79
- Object.keys(this.outputs).forEach((intfKey) => {
80
- if (intfKey === "_node") return;
81
- const intf = this.outputs[intfKey];
82
- const value = intf.isString ? `'${intf.value}'` : intf.value;
83
- if (intf && intf.state) outputs[intfKey] = value;
84
- });
85
- this.state.script = mustache.render(this.state.codeTemplate, { inputs, outputs });
86
- if (this.outputs.code) this.outputs.code.state.script = this.state.script;
72
+ const t = {};
73
+ Object.keys(this.outputs).forEach((s) => {
74
+ if (s === "_node") return;
75
+ const n = this.outputs[s], a = n.isString ? `'${n.value}'` : n.value;
76
+ n && n.state && (t[s] = a);
77
+ }), this.state.script = be.render(this.state.codeTemplate, { inputs: e, outputs: t }), this.outputs.code && (this.outputs.code.state.script = this.state.script);
87
78
  }
88
79
  updateOutputVariableName() {
89
- if (this.outputs.code) this.outputs.code.name = this.variableName;
80
+ this.outputs.code && (this.outputs.code.name = this.variableName);
90
81
  }
91
82
  }
92
- class CodeNode extends AbstractCodeNode {
83
+ class we extends vt {
93
84
  /**
94
85
  * The default implementation does nothing.
95
86
  * Overwrite this method to do calculation.
@@ -98,89 +89,63 @@ class CodeNode extends AbstractCodeNode {
98
89
  * @return Values for output interfaces
99
90
  */
100
91
  calculate;
101
- load(state) {
102
- super.load(state);
103
- loadNodeState(this.graph, state);
92
+ load(e) {
93
+ super.load(e), xe(this.graph, e);
104
94
  }
105
95
  save() {
106
- const state = super.save();
107
- saveNodeState(this.graph, state);
108
- return state;
109
- }
110
- updateModules(modules) {
111
- if (modules) {
112
- this.state.modules = modules;
113
- } else if (this.type.includes(".")) {
114
- const modules2 = this.type.split(".");
115
- this.state.modules.push(modules2.slice(0, modules2.length - 1).join("."));
96
+ const e = super.save();
97
+ return mt(this.graph, e), e;
98
+ }
99
+ updateModules(e) {
100
+ if (e)
101
+ this.state.modules = e;
102
+ else if (this.type.includes(".")) {
103
+ const t = this.type.split(".");
104
+ this.state.modules.push(t.slice(0, t.length - 1).join("."));
116
105
  }
117
106
  }
118
107
  }
119
- const loadNodeState = (graph, nodeState) => {
120
- if (!graph) return;
121
- const node = graph.findNodeById(nodeState.id);
122
- if (!node || node.subgraph) return;
123
- const codeNode = node;
124
- if (codeNode.state) {
125
- codeNode.state.integrated = nodeState.integrated;
126
- codeNode.state.modules = nodeState.modules;
127
- codeNode.state.props = nodeState.props;
128
- }
129
- Object.entries(nodeState.inputs).forEach(([inputKey, inputItem]) => {
130
- if (inputKey === "_node") return;
131
- if (codeNode.inputs[inputKey]) codeNode.inputs[inputKey].hidden = inputItem.hidden;
132
- });
133
- Object.entries(nodeState.outputs).forEach(([outputKey, outputItem]) => {
134
- if (outputKey === "_node") return;
135
- if (codeNode.outputs[outputKey]) codeNode.outputs[outputKey].hidden = outputItem.hidden;
136
- });
137
- };
138
- const saveNodeState = (graph, nodeState) => {
139
- if (!graph) return;
140
- const node = graph.findNodeById(nodeState.id);
141
- if (!node || node.subgraph) return;
142
- const codeNode = node;
143
- if (codeNode.state) {
144
- nodeState.integrated = codeNode.state.integrated;
145
- nodeState.modules = codeNode.state.modules;
146
- }
147
- Object.entries(nodeState.inputs).forEach(([inputKey, inputItem]) => {
148
- if (inputKey === "_node") return;
149
- if (codeNode.inputs[inputKey]) inputItem.hidden = codeNode.inputs[inputKey].hidden;
108
+ const xe = (o, e) => {
109
+ if (!o) return;
110
+ const t = o.findNodeById(e.id);
111
+ if (!t || t.subgraph) return;
112
+ const s = t;
113
+ s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([n, a]) => {
114
+ n !== "_node" && s.inputs[n] && (s.inputs[n].hidden = a.hidden);
115
+ }), Object.entries(e.outputs).forEach(([n, a]) => {
116
+ n !== "_node" && s.outputs[n] && (s.outputs[n].hidden = a.hidden);
150
117
  });
151
- Object.entries(nodeState.outputs).forEach(([outputKey, outputItem]) => {
152
- if (outputKey === "_node") return;
153
- if (codeNode.outputs[outputKey]) outputItem.hidden = codeNode.outputs[outputKey].hidden;
118
+ }, mt = (o, e) => {
119
+ if (!o) return;
120
+ const t = o.findNodeById(e.id);
121
+ if (!t || t.subgraph) return;
122
+ const s = t;
123
+ s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([n, a]) => {
124
+ n !== "_node" && s.inputs[n] && (a.hidden = s.inputs[n].hidden);
125
+ }), Object.entries(e.outputs).forEach(([n, a]) => {
126
+ n !== "_node" && s.outputs[n] && (a.hidden = s.outputs[n].hidden);
154
127
  });
155
128
  };
156
- new NodeInterfaceType("boolean");
157
- new NodeInterfaceType("dict");
158
- new NodeInterfaceType("list");
159
- const nodeType = new NodeInterfaceType("node");
160
- const numberType = new NodeInterfaceType("number");
161
- const stringType = new NodeInterfaceType("string");
162
- const _hoisted_1$f = ["title"];
163
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
129
+ new P("boolean");
130
+ new P("dict");
131
+ new P("list");
132
+ const Y = new P("node"), ft = new P("number"), gt = new P("string"), bt = ["title"], ae = /* @__PURE__ */ G({
164
133
  __name: "CodeNodeInterface",
165
134
  props: {
166
135
  intf: {}
167
136
  },
168
- setup(__props) {
169
- return (_ctx, _cache) => {
170
- return openBlock(), createElementBlock("div", {
171
- title: _ctx.intf.state?.script
172
- }, toDisplayString(_ctx.intf.name), 9, _hoisted_1$f);
173
- };
137
+ setup(o) {
138
+ return (e, t) => (i(), r("div", {
139
+ title: e.intf.state?.script
140
+ }, L(e.intf.name), 9, bt));
174
141
  }
175
142
  });
176
- class CodeNodeInterface extends NodeInterface {
177
- optional = false;
143
+ class M extends Ve {
144
+ optional = !1;
178
145
  code;
179
146
  state;
180
- constructor(name, value) {
181
- super(name, value);
182
- this.setComponent(markRaw(_sfc_main$g));
183
- this.state = reactive({
147
+ constructor(e, t) {
148
+ super(e, t), this.setComponent($(ae)), this.state = R({
184
149
  script: ""
185
150
  });
186
151
  }
@@ -195,48 +160,42 @@ class CodeNodeInterface extends NodeInterface {
195
160
  // if (this.name !== '_node') this.setHidden(false);
196
161
  // }
197
162
  }
198
- class ButtonInterface extends CodeNodeInterface {
199
- component = markRaw(ButtonInterfaceComponent);
163
+ class Ps extends M {
164
+ component = $(Le);
200
165
  callback;
201
- constructor(name, callback) {
202
- super(name, void 0);
203
- this.callback = callback;
204
- this.setPort(false);
166
+ constructor(e, t) {
167
+ super(e, void 0), this.callback = t, this.setPort(!1);
205
168
  }
206
169
  }
207
- class CheckboxInterface extends CodeNodeInterface {
208
- component = markRaw(CheckboxInterfaceComponent);
170
+ class Ds extends M {
171
+ component = $(Ge);
209
172
  }
210
- class BaseNumericInterface extends CodeNodeInterface {
173
+ class ie extends M {
211
174
  min;
212
175
  max;
213
- constructor(name, value, min, max) {
214
- super(name, value);
215
- this.min = min;
216
- this.max = max;
176
+ constructor(e, t, s, n) {
177
+ super(e, t), this.min = s, this.max = n;
217
178
  }
218
- validate(v) {
219
- return (this.min === void 0 || v >= this.min) && (this.max === void 0 || v <= this.max);
179
+ validate(e) {
180
+ return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
220
181
  }
221
182
  }
222
- class IntegerInterface extends BaseNumericInterface {
223
- component = markRaw(IntegerInterfaceComponent);
224
- validate(v) {
225
- return Number.isInteger(v) && super.validate(v);
183
+ class As extends ie {
184
+ component = $(Ue);
185
+ validate(e) {
186
+ return Number.isInteger(e) && super.validate(e);
226
187
  }
227
188
  }
228
- class CodeInputInterface extends CodeNodeInterface {
229
- isCodeInput = true;
230
- constructor(name = "", value) {
231
- super(name, value);
232
- this.setComponent(markRaw(_sfc_main$g));
189
+ class Hs extends M {
190
+ isCodeInput = !0;
191
+ constructor(e = "", t) {
192
+ super(e, t), this.setComponent($(ae));
233
193
  }
234
194
  }
235
- class CodeOutputInterface extends CodeNodeInterface {
236
- isCodeOutput = true;
237
- constructor(name = "", value = "") {
238
- super(name, value);
239
- this.setComponent(markRaw(_sfc_main$g));
195
+ class _t extends M {
196
+ isCodeOutput = !0;
197
+ constructor(e = "", t = "") {
198
+ super(e, t), this.setComponent($(ae));
240
199
  }
241
200
  get script() {
242
201
  return this.state.script;
@@ -244,95 +203,77 @@ class CodeOutputInterface extends CodeNodeInterface {
244
203
  get value() {
245
204
  return super.value;
246
205
  }
247
- set value(value) {
248
- super.value = value;
249
- this.state.script = this.name.length > 0 ? this.name : this.value;
206
+ set value(e) {
207
+ super.value = e, this.state.script = this.name.length > 0 ? this.name : this.value;
250
208
  }
251
209
  }
252
- class NumberInterface extends BaseNumericInterface {
253
- component = markRaw(NumberInterfaceComponent);
210
+ class Fs extends ie {
211
+ component = $(je);
254
212
  }
255
- class SelectInterface extends CodeNodeInterface {
256
- component = markRaw(SelectInterfaceComponent);
213
+ class Ws extends M {
214
+ component = $(Re);
257
215
  items;
258
- constructor(name, value, items) {
259
- super(name, value);
260
- this.items = items;
216
+ constructor(e, t, s) {
217
+ super(e, t), this.items = s;
261
218
  }
262
219
  }
263
- class SliderInterface extends BaseNumericInterface {
264
- component = markRaw(SliderInterfaceComponent);
220
+ class Xs extends ie {
221
+ component = $(Pe);
265
222
  min;
266
223
  max;
267
- constructor(name, value, min, max) {
268
- super(name, value, min, max);
269
- this.min = min;
270
- this.max = max;
224
+ constructor(e, t, s, n) {
225
+ super(e, t, s, n), this.min = s, this.max = n;
271
226
  }
272
227
  }
273
- class TextInterface extends CodeNodeInterface {
274
- component = markRaw(TextInputInterfaceComponent);
275
- constructor(name, value) {
276
- super(name, value);
277
- this.setPort(false);
228
+ class Ys extends M {
229
+ component = $(ge);
230
+ constructor(e, t) {
231
+ super(e, t), this.setPort(!1);
278
232
  }
279
233
  }
280
- class TextInputInterface extends CodeNodeInterface {
281
- isString = true;
282
- component = markRaw(TextInputInterfaceComponent);
234
+ class Js extends M {
235
+ isString = !0;
236
+ component = $(ge);
283
237
  }
284
- class TextareaInputInterface extends CodeNodeInterface {
285
- component = markRaw(TextareaInputInterfaceComponent);
238
+ class qs extends M {
239
+ component = $(De);
286
240
  }
287
- function defineCodeNode(definition) {
288
- return class extends CodeNode {
289
- type = definition.type;
241
+ function Qs(o) {
242
+ return class extends we {
243
+ type = o.type;
290
244
  inputs = {};
291
245
  outputs = {};
292
246
  constructor() {
293
- super();
294
- this._title = definition.title ?? definition.type;
295
- this.updateModules(definition.modules);
296
- if (definition.codeTemplate) this.state.codeTemplate = definition.codeTemplate(this);
297
- if (definition.variableName) this.state.variableName = definition.variableName;
298
- this.addInput(
247
+ super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
299
248
  "_node",
300
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
301
- );
302
- this.addOutput(
249
+ new M("", []).use(j, Y).use(X).setHidden(!0)
250
+ ), this.addOutput(
303
251
  "_node",
304
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
305
- );
306
- this.executeFactory("input", definition.inputs);
307
- this.executeFactory("output", definition.outputs);
308
- definition.onCreate?.call(this);
252
+ new M("", []).use(j, Y).use(X).setHidden(!0)
253
+ ), this.executeFactory("input", o.inputs), this.executeFactory("output", o.outputs), o.onCreate?.call(this);
309
254
  }
310
- calculate = definition.calculate ? (inputs, globalValues) => ({
311
- ...definition.calculate.call(this, inputs, globalValues),
255
+ calculate = o.calculate ? (e, t) => ({
256
+ ...o.calculate.call(this, e, t),
312
257
  _node: null
313
258
  }) : void 0;
314
259
  onPlaced() {
315
- definition.onPlaced?.call(this);
260
+ o.onPlaced?.call(this);
316
261
  }
317
262
  onDestroy() {
318
- definition.onDestroy?.call(this);
263
+ o.onDestroy?.call(this);
319
264
  }
320
265
  onCodeUpdate() {
321
- definition.onCodeUpdate?.call(this);
266
+ o.onCodeUpdate?.call(this);
322
267
  }
323
- executeFactory(type, factory) {
324
- Object.keys(factory || {}).forEach((k) => {
325
- const intf = factory[k]();
326
- if (type === "input") {
327
- this.addInput(k, intf);
328
- } else {
329
- this.addOutput(k, intf);
330
- }
268
+ executeFactory(e, t) {
269
+ Object.keys(t || {}).forEach((s) => {
270
+ const n = t[s]();
271
+ e === "input" ? this.addInput(s, n) : this.addOutput(s, n);
331
272
  });
332
273
  }
333
274
  };
334
275
  }
335
- class DynamicCodeNode extends CodeNode {
276
+ class yt extends we {
336
277
  /**
337
278
  * The default implementation does nothing.
338
279
  * Overwrite this method to do calculation.
@@ -342,169 +283,101 @@ class DynamicCodeNode extends CodeNode {
342
283
  */
343
284
  calculate;
344
285
  }
345
- function defineDynamicCodeNode(definition) {
346
- return class extends DynamicCodeNode {
347
- type = definition.type;
286
+ function Zs(o) {
287
+ return class extends yt {
288
+ type = o.type;
348
289
  inputs = {};
349
290
  outputs = {};
350
291
  calculate;
351
- preventUpdate = false;
352
- staticInputKeys = Object.keys(definition.inputs ?? {});
353
- staticOutputKeys = Object.keys(definition.outputs ?? {});
292
+ preventUpdate = !1;
293
+ staticInputKeys = Object.keys(o.inputs ?? {});
294
+ staticOutputKeys = Object.keys(o.outputs ?? {});
354
295
  constructor() {
355
- super();
356
- this._title = definition.title ?? definition.type;
357
- this.updateModules(definition.modules);
358
- if (definition.codeTemplate) this.state.codeTemplate = definition.codeTemplate(this);
359
- if (definition.variableName) this.state.variableName = definition.variableName;
360
- this.addInput(
296
+ super(), this._title = o.title ?? o.type, this.updateModules(o.modules), o.codeTemplate && (this.state.codeTemplate = o.codeTemplate(this)), o.variableName && (this.state.variableName = o.variableName), this.addInput(
361
297
  "_node",
362
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
363
- );
364
- this.addOutput(
298
+ new M("", []).use(j, Y).use(X).setHidden(!0)
299
+ ), this.addOutput(
365
300
  "_node",
366
- new CodeNodeInterface("", []).use(setType, nodeType).use(allowMultipleConnections).setHidden(true)
367
- );
368
- this.staticInputKeys.push("_node");
369
- this.staticOutputKeys.push("_node");
370
- this.executeFactory("input", definition.inputs);
371
- this.executeFactory("output", definition.outputs);
372
- if (definition.calculate) {
373
- this.calculate = (inputs, globalValues) => ({
374
- ...definition.calculate?.call(this, inputs, globalValues),
375
- _node: null
376
- });
377
- }
378
- definition.onCreate?.call(this);
301
+ new M("", []).use(j, Y).use(X).setHidden(!0)
302
+ ), this.staticInputKeys.push("_node"), this.staticOutputKeys.push("_node"), this.executeFactory("input", o.inputs), this.executeFactory("output", o.outputs), o.calculate && (this.calculate = (e, t) => ({
303
+ ...o.calculate?.call(this, e, t),
304
+ _node: null
305
+ })), o.onCreate?.call(this);
379
306
  }
380
307
  onPlaced() {
381
- this.events.update.subscribe(this, (data) => {
382
- if (!data) return;
383
- if (data.type === "input" && this.staticInputKeys.includes(data.name) || data.type === "output" && this.staticOutputKeys.includes(data.name)) {
384
- this.onUpdate();
385
- }
386
- });
387
- this.onUpdate();
388
- definition.onPlaced?.call(this);
308
+ this.events.update.subscribe(this, (e) => {
309
+ e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
310
+ }), this.onUpdate(), o.onPlaced?.call(this);
389
311
  }
390
312
  onDestroy() {
391
- definition.onDestroy?.call(this);
313
+ o.onDestroy?.call(this);
392
314
  }
393
315
  onCodeUpdate() {
394
- definition.onCodeUpdate?.call(this);
316
+ o.onCodeUpdate?.call(this);
395
317
  }
396
- load(state) {
397
- this.preventUpdate = true;
398
- this.hooks.beforeLoad.execute(state);
399
- this.id = state.id;
400
- this.title = state.title;
401
- for (const k of this.staticInputKeys) {
402
- this.inputs[k].load(state.inputs[k]);
403
- this.inputs[k].nodeId = this.id;
404
- if (k === "_node") continue;
405
- this.inputs[k].hidden = state.inputs[k].hidden;
406
- }
407
- for (const k of this.staticOutputKeys) {
408
- this.outputs[k].load(state.outputs[k]);
409
- this.outputs[k].nodeId = this.id;
410
- if (k === "_node") continue;
411
- this.outputs[k].hidden = state.outputs[k].hidden;
412
- }
413
- this.preventUpdate = false;
414
- this.onUpdate();
415
- this.preventUpdate = true;
416
- for (const k of Object.keys(state.inputs)) {
417
- if (this.staticInputKeys.includes(k)) continue;
418
- if (!this.inputs[k]) {
419
- const value = state.inputs[k].value;
420
- let inputInterface;
421
- if (typeof value == "number") {
422
- inputInterface = new IntegerInterface$1(k, value).use(setType, numberType);
423
- } else {
424
- inputInterface = new TextInputInterface$1(k, JSON.stringify(value)).use(setType, stringType);
318
+ load(e) {
319
+ this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
320
+ for (const t of this.staticInputKeys)
321
+ this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id, t !== "_node" && (this.inputs[t].hidden = e.inputs[t].hidden);
322
+ for (const t of this.staticOutputKeys)
323
+ this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id, t !== "_node" && (this.outputs[t].hidden = e.outputs[t].hidden);
324
+ this.preventUpdate = !1, this.onUpdate(), this.preventUpdate = !0;
325
+ for (const t of Object.keys(e.inputs))
326
+ if (!this.staticInputKeys.includes(t)) {
327
+ if (!this.inputs[t]) {
328
+ const s = e.inputs[t].value;
329
+ let n;
330
+ typeof s == "number" ? n = new Ae(t, s).use(j, ft) : n = new He(t, JSON.stringify(s)).use(j, gt), n.use(Fe, !0), this.addInput(t, n);
425
331
  }
426
- inputInterface.use(displayInSidebar, true);
427
- this.addInput(k, inputInterface);
428
- }
429
- if (this.inputs[k]) {
430
- this.inputs[k].load(state.inputs[k]);
431
- this.inputs[k].nodeId = this.id;
332
+ this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
432
333
  }
433
- }
434
- for (const k of Object.keys(state.outputs)) {
435
- if (this.staticOutputKeys.includes(k)) continue;
436
- if (!this.outputs[k]) {
437
- const outputInterface = new CodeOutputInterface(k);
438
- this.addOutput(k, outputInterface);
439
- }
440
- if (this.outputs[k]) {
441
- this.outputs[k].load(state.outputs[k]);
442
- this.outputs[k].nodeId = this.id;
334
+ for (const t of Object.keys(e.outputs))
335
+ if (!this.staticOutputKeys.includes(t)) {
336
+ if (!this.outputs[t]) {
337
+ const s = new _t(t);
338
+ this.addOutput(t, s);
339
+ }
340
+ this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
443
341
  }
444
- }
445
- loadNodeState(this.graph, state);
446
- this.preventUpdate = false;
447
- this.events.loaded.emit(this);
342
+ xe(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
448
343
  }
449
344
  onUpdate() {
450
345
  if (this.preventUpdate) return;
451
- if (this.graph) this.graph.activeTransactions++;
452
- const inputValues = this.getStaticValues(this.staticInputKeys, this.inputs);
453
- const outputValues = this.getStaticValues(this.staticOutputKeys, this.outputs);
454
- const result = definition.onUpdate.call(this, inputValues, outputValues);
455
- this.updateInterfaces("input", result.inputs ?? {}, result.forceUpdateInputs ?? []);
456
- this.updateInterfaces("output", result.outputs ?? {}, result.forceUpdateOutputs ?? []);
457
- if (this.graph) this.graph.activeTransactions--;
346
+ this.graph && this.graph.activeTransactions++;
347
+ const e = this.getStaticValues(this.staticInputKeys, this.inputs), t = this.getStaticValues(this.staticOutputKeys, this.outputs), s = o.onUpdate.call(this, e, t);
348
+ this.updateInterfaces("input", s.inputs ?? {}, s.forceUpdateInputs ?? []), this.updateInterfaces("output", s.outputs ?? {}, s.forceUpdateOutputs ?? []), this.graph && this.graph.activeTransactions--;
458
349
  }
459
- getStaticValues(keys, interfaces) {
460
- const values = {};
461
- for (const k of keys) {
462
- values[k] = interfaces[k].value;
463
- }
464
- return values;
350
+ getStaticValues(e, t) {
351
+ const s = {};
352
+ for (const n of e)
353
+ s[n] = t[n].value;
354
+ return s;
465
355
  }
466
- updateInterfaces(type, newInterfaces, forceUpdates) {
467
- const staticKeys = type === "input" ? this.staticInputKeys : this.staticOutputKeys;
468
- const currentInterfaces = type === "input" ? this.inputs : this.outputs;
469
- for (const k of Object.keys(currentInterfaces)) {
470
- if (staticKeys.includes(k) || newInterfaces[k] && !forceUpdates.includes(k)) continue;
471
- if (type === "input") {
472
- this.removeInput(k);
473
- } else {
474
- this.removeOutput(k);
475
- }
476
- }
477
- for (const k of Object.keys(newInterfaces)) {
478
- if (currentInterfaces[k]) continue;
479
- const intf = newInterfaces[k]();
480
- if (type === "input") {
481
- this.addInput(k, intf);
482
- } else {
483
- this.addOutput(k, intf);
484
- }
356
+ updateInterfaces(e, t, s) {
357
+ const n = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
358
+ for (const u of Object.keys(a))
359
+ n.includes(u) || t[u] && !s.includes(u) || (e === "input" ? this.removeInput(u) : this.removeOutput(u));
360
+ for (const u of Object.keys(t)) {
361
+ if (a[u]) continue;
362
+ const d = t[u]();
363
+ e === "input" ? this.addInput(u, d) : this.addOutput(u, d);
485
364
  }
486
365
  }
487
- executeFactory(type, factory) {
488
- Object.keys(factory || {}).forEach((k) => {
489
- const intf = factory[k]();
490
- if (type === "input") {
491
- this.addInput(k, intf);
492
- } else {
493
- this.addOutput(k, intf);
494
- }
366
+ executeFactory(e, t) {
367
+ Object.keys(t || {}).forEach((s) => {
368
+ const n = t[s]();
369
+ e === "input" ? this.addInput(s, n) : this.addOutput(s, n);
495
370
  });
496
371
  }
497
372
  };
498
373
  }
499
- class Code {
374
+ class wt {
500
375
  _id;
501
376
  _viewModel;
502
377
  _state;
503
- constructor(viewModel) {
504
- this._id = v4();
505
- this._viewModel = viewModel;
506
- this._state = reactive({
507
- autosort: false,
378
+ constructor(e) {
379
+ this._id = pt(), this._viewModel = e, this._state = R({
380
+ autosort: !1,
508
381
  modules: {},
509
382
  script: "",
510
383
  token: null,
@@ -512,13 +385,13 @@ class Code {
512
385
  });
513
386
  }
514
387
  get codeNodes() {
515
- return getCodeNodes(this.graph);
388
+ return Z(this.graph);
516
389
  }
517
390
  get connections() {
518
391
  return this.graph.connections;
519
392
  }
520
- set connections(values) {
521
- this.graph._connections = values;
393
+ set connections(e) {
394
+ this.graph._connections = e;
522
395
  }
523
396
  get graph() {
524
397
  return this.viewModel.displayedGraph;
@@ -527,26 +400,23 @@ class Code {
527
400
  return this._id;
528
401
  }
529
402
  get modules() {
530
- let categories = [];
531
- this.codeNodes.filter((node) => node.state.modules?.length > 0).forEach((node) => {
532
- categories = categories.concat(node.state.modules);
533
- });
534
- if (!categories) return [];
535
- categories.sort();
536
- return Array.from(new Set(categories.map((category) => this.viewModel.state.modules[category])));
403
+ let e = [];
404
+ return this.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => {
405
+ e = e.concat(t.state.modules);
406
+ }), e ? (e.sort(), Array.from(new Set(e.map((t) => this.viewModel.state.modules[t])))) : [];
537
407
  }
538
408
  get nodeIds() {
539
- return this.codeNodes.map((node) => node.id);
409
+ return this.codeNodes.map((e) => e.id);
540
410
  }
541
411
  get nodes() {
542
412
  return this.graph.nodes;
543
413
  }
544
- set nodes(values) {
545
- this.graph._nodes = values;
414
+ set nodes(e) {
415
+ this.graph._nodes = e;
546
416
  }
547
417
  get scriptedCodeNodes() {
548
- return getCodeNodes(this.graph).filter(
549
- (codeNode) => codeNode.state?.script.length > 0
418
+ return Z(this.graph).filter(
419
+ (e) => e.state?.script.length > 0
550
420
  );
551
421
  }
552
422
  get shortId() {
@@ -559,17 +429,15 @@ class Code {
559
429
  return this._viewModel;
560
430
  }
561
431
  get visibleNodes() {
562
- return this.codeNodes.filter((node) => !node.state?.hidden);
432
+ return this.codeNodes.filter((e) => !e.state?.hidden);
563
433
  }
564
434
  /**
565
435
  * Add code node to graph.
566
436
  * @param node code node
567
437
  * @param props optional
568
438
  */
569
- addNode(node, props) {
570
- if (!node.code) node.code = this;
571
- if (props) node.state.props = props;
572
- return this.graph.addNode(node);
439
+ addNode(e, t) {
440
+ return e.code || (e.code = this), t && (e.state.props = t), this.graph.addNode(e);
573
441
  }
574
442
  /**
575
443
  * Add code node at coordinates.
@@ -578,40 +446,33 @@ class Code {
578
446
  * @param props optional
579
447
  * @returns code node
580
448
  */
581
- addNodeAtCoordinates = (node, position = { x: 0, y: 0 }, props) => {
582
- this.addNode(node, props);
583
- if (node.position) node.position = position;
584
- return node;
585
- };
449
+ addNodeAtCoordinates = (e, t = { x: 0, y: 0 }, s) => (this.addNode(e, s), e.position && (e.position = t), e);
586
450
  /**
587
451
  * Add connection of code nodes
588
452
  * @param from code node interface
589
453
  * @param to code node interface
590
454
  */
591
- addConnection(from, to) {
592
- if (from.name !== "_node") from.hidden = false;
593
- if (to.name !== "_node") to.hidden = false;
594
- this.graph.addConnection(from, to);
455
+ addConnection(e, t) {
456
+ e.name !== "_node" && (e.hidden = !1), t.name !== "_node" && (t.hidden = !1), this.graph.addConnection(e, t);
595
457
  }
596
458
  /**
597
459
  * Clear code graph.
598
460
  */
599
461
  clear() {
600
- this.nodes = [];
601
- this.connections = [];
462
+ this.nodes = [], this.connections = [];
602
463
  }
603
- findNodeById(id) {
604
- return this.graph.findNodeById(id);
464
+ findNodeById(e) {
465
+ return this.graph.findNodeById(e);
605
466
  }
606
- findNodeByType(nodeType2) {
607
- return this.codeNodes.find((codeNode) => codeNode.type === nodeType2);
467
+ findNodeByType(e) {
468
+ return this.codeNodes.find((t) => t.type === e);
608
469
  }
609
- getNodesBySameType(type) {
610
- return this.codeNodes.filter((codeNode) => codeNode.type === type);
470
+ getNodesBySameType(e) {
471
+ return this.codeNodes.filter((t) => t.type === e);
611
472
  }
612
- getNodesBySameVariableNames(variableName) {
473
+ getNodesBySameVariableNames(e) {
613
474
  return this.codeNodes.filter(
614
- (codeNode) => codeNode.state.variableName === variableName
475
+ (t) => t.state.variableName === e
615
476
  );
616
477
  }
617
478
  /**
@@ -620,73 +481,68 @@ class Code {
620
481
  * @param to node interface
621
482
  * @returns boolean
622
483
  */
623
- hasConnection(from, to) {
484
+ hasConnection(e, t) {
624
485
  return this.connections.some(
625
- (connection) => connection.from.id === from.id && connection.to.id === to.id
486
+ (s) => s.from.id === e.id && s.to.id === t.id
626
487
  );
627
488
  }
628
489
  /**
629
490
  * Load template from the file.
630
491
  */
631
- loadTemplate(resolve) {
632
- resolve.then((template) => {
633
- this._state.template = template.default ?? "";
492
+ loadTemplate(e) {
493
+ e.then((t) => {
494
+ this._state.template = t.default ?? "";
634
495
  });
635
496
  }
636
497
  onCodeUpdate() {
637
- this.codeNodes.forEach((codeNode) => codeNode.onCodeUpdate());
498
+ this.codeNodes.forEach((e) => e.onCodeUpdate());
638
499
  }
639
500
  /**
640
501
  * Remove connection from the graph
641
502
  * @param connection connection between code nodes
642
503
  */
643
- removeConnection(connection) {
644
- this.graph.removeConnection(connection);
504
+ removeConnection(e) {
505
+ this.graph.removeConnection(e);
645
506
  }
646
507
  /**
647
508
  * Remove node from the graph.
648
509
  * @param codeNode code node
649
510
  */
650
- removeNode(codeNode) {
651
- this.graph.removeNode(codeNode);
511
+ removeNode(e) {
512
+ this.graph.removeNode(e);
652
513
  }
653
514
  /**
654
515
  * Render node codes.
655
516
  */
656
517
  renderNodeCodes() {
657
- if (this.codeNodes.length === 0) return;
658
- this.codeNodes.forEach((node) => node.renderCode());
518
+ this.codeNodes.length !== 0 && this.codeNodes.forEach((e) => e.renderCode());
659
519
  }
660
520
  /**
661
521
  * Render code.
662
522
  */
663
523
  renderCode() {
664
- this.state.script = mustache.render(this.state.template || "", this);
524
+ this.state.script = be.render(this.state.template || "", this);
665
525
  }
666
526
  /**
667
527
  * Save code graph.
668
528
  * @returns graph state
669
529
  */
670
530
  save() {
671
- if (this.state.autosort) this.sortNodes();
672
- const editorState = this.viewModel.editor.save();
673
- editorState.graph.id = this.id;
674
- this.saveNodeStates(editorState.graph.nodes);
675
- return JSON.parse(JSON.stringify(editorState));
531
+ this.state.autosort && this.sortNodes();
532
+ const e = this.viewModel.editor.save();
533
+ return e.graph.id = this.id, this.saveNodeStates(e.graph.nodes), JSON.parse(JSON.stringify(e));
676
534
  }
677
535
  /**
678
536
  * Save node states.
679
537
  * @param nodeStates a list of node state.
680
538
  */
681
- saveNodeStates(nodeStates) {
682
- nodeStates.forEach((nodeState, nodeIdx) => {
683
- const node = this.nodes[nodeIdx];
684
- Object.entries(nodeState.inputs).forEach(([inputKey]) => {
685
- if (nodeState.inputs && node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
686
- });
687
- Object.entries(nodeState.outputs).forEach(([outputKey]) => {
688
- if (nodeState.outputs && node.outputs[outputKey])
689
- nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
539
+ saveNodeStates(e) {
540
+ e.forEach((t, s) => {
541
+ const n = this.nodes[s];
542
+ Object.entries(t.inputs).forEach(([a]) => {
543
+ t.inputs && n.inputs[a] && (t.inputs[a].hidden = n.inputs[a].hidden);
544
+ }), Object.entries(t.outputs).forEach(([a]) => {
545
+ t.outputs && n.outputs[a] && (t.outputs[a].hidden = n.outputs[a].hidden);
690
546
  });
691
547
  });
692
548
  }
@@ -694,124 +550,85 @@ class Code {
694
550
  * Sort code nodes.
695
551
  */
696
552
  sortNodes() {
697
- if (this.nodes.length === 0 || this.connections.length === 0) return;
698
- try {
699
- const edges = this.connections.map((connection) => [
700
- connection.to.nodeId,
701
- connection.from.nodeId
702
- ]);
703
- let nodeIds = [...this.nodeIds];
704
- nodeIds.reverse();
705
- nodeIds = toposort.array(nodeIds, edges);
706
- nodeIds.reverse();
707
- const unconnected = this.graph.nodes.map((node) => node.id).filter((nodeId) => !nodeIds.includes(nodeId));
708
- nodeIds = nodeIds.concat(unconnected);
709
- const nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
710
- if (nodes) this.nodes = nodes;
711
- } catch {
712
- console.warn("Failed to sort nodes.");
713
- }
553
+ if (!(this.nodes.length === 0 || this.connections.length === 0))
554
+ try {
555
+ const e = this.connections.map((a) => [
556
+ a.to.nodeId,
557
+ a.from.nodeId
558
+ ]);
559
+ let t = [...this.nodeIds];
560
+ t.reverse(), t = ct.array(t, e), t.reverse();
561
+ const s = this.graph.nodes.map((a) => a.id).filter((a) => !t.includes(a));
562
+ t = t.concat(s);
563
+ const n = t.map((a) => this.findNodeById(a));
564
+ n && (this.nodes = n);
565
+ } catch {
566
+ console.warn("Failed to sort nodes.");
567
+ }
714
568
  }
715
569
  updateOutputVariableNames() {
716
- this.codeNodes.forEach((codeNode) => codeNode.updateOutputVariableName());
570
+ this.codeNodes.forEach((e) => e.updateOutputVariableName());
717
571
  }
718
572
  }
719
- const getCodeNodes = (graph) => {
720
- let nodes = [];
721
- graph.nodes.forEach((node) => {
722
- if (node.subgraph) {
723
- nodes = nodes.concat(getCodeNodes(node.subgraph));
724
- } else if (node.isCodeNode) {
725
- nodes.push(node);
726
- }
727
- });
728
- return nodes;
729
- };
730
- const getPositionAtColumn = (col = 0, offset = 100) => {
731
- const width = 350;
732
- const padding = 70;
733
- return {
734
- x: col * (width + padding),
735
- y: offset
736
- };
737
- };
738
- const getPositionBeforeNode = (node) => {
739
- const position = { ...node.position };
740
- position.x -= 400;
741
- position.y += 50;
742
- return position;
743
- };
744
- const transferCodeScript = (graph) => {
745
- const { calculationOrder, connectionsFromNode } = sortTopologically(graph);
746
- calculationOrder.forEach((node) => {
747
- if (!node.isCodeNode) return;
748
- const codeNode = node;
749
- if (connectionsFromNode.has(codeNode)) {
750
- connectionsFromNode.get(codeNode).forEach((c) => {
751
- if (c.to.state && c.from.script) c.to.state.script = c.from.script;
752
- });
753
- }
573
+ const Z = (o) => {
574
+ let e = [];
575
+ return o.nodes.forEach((t) => {
576
+ t.subgraph ? e = e.concat(Z(t.subgraph)) : t.isCodeNode && e.push(t);
577
+ }), e;
578
+ }, Ks = (o = 0, e = 100) => ({
579
+ x: o * 420,
580
+ y: e
581
+ }), en = (o) => {
582
+ const e = { ...o.position };
583
+ return e.x -= 400, e.y += 50, e;
584
+ }, xt = (o) => {
585
+ const { calculationOrder: e, connectionsFromNode: t } = We(o);
586
+ e.forEach((s) => {
587
+ if (!s.isCodeNode) return;
588
+ const n = s;
589
+ t.has(n) && t.get(n).forEach((a) => {
590
+ a.to.state && a.from.script && (a.to.state.script = a.from.script);
591
+ });
754
592
  });
755
- };
756
- const _hoisted_1$e = ["id"];
757
- const _hoisted_2$5 = { class: "align-middle" };
758
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
593
+ }, kt = ["id"], Ct = { class: "align-middle" }, me = /* @__PURE__ */ G({
759
594
  __name: "CodeGraphNodeInterface",
760
595
  props: {
761
596
  node: {},
762
597
  intf: {}
763
598
  },
764
- setup(__props) {
765
- const props = __props;
766
- const { viewModel } = useViewModel();
767
- const { hoveredOver, temporaryConnection } = useTemporaryConnection();
768
- const el = ref(null);
769
- const isConnected = computed(() => props.intf.connectionCount > 0);
770
- const classes = computed(() => ({
771
- "--connected": isConnected.value
772
- }));
773
- const startHover = () => {
774
- hoveredOver(props.intf);
599
+ setup(o) {
600
+ const e = o, { viewModel: t } = H(), { hoveredOver: s, temporaryConnection: n } = Xe(), a = E(null), u = f(() => e.intf.connectionCount > 0), d = f(() => ({
601
+ "--connected": u.value
602
+ })), h = () => {
603
+ s(e.intf);
604
+ }, O = () => {
605
+ s(void 0);
606
+ }, x = () => {
607
+ a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
775
608
  };
776
- const endHover = () => {
777
- hoveredOver(void 0);
778
- };
779
- const onRender = () => {
780
- if (el.value) {
781
- viewModel.value.hooks.renderInterface.execute({ intf: props.intf, el: el.value });
782
- }
783
- };
784
- onMounted(onRender);
785
- onUpdated(onRender);
786
- return (_ctx, _cache) => {
787
- return openBlock(), createElementBlock("div", {
788
- id: _ctx.intf.id,
789
- ref_key: "el",
790
- ref: el,
791
- class: normalizeClass(["baklava-node-interface", classes.value])
792
- }, [
793
- _ctx.intf.port ? (openBlock(), createElementBlock("div", {
794
- key: 0,
795
- class: normalizeClass(["__port", { "--selected": unref(temporaryConnection)?.from === _ctx.intf }]),
796
- onPointerover: startHover,
797
- onPointerout: endHover
798
- }, null, 34)) : createCommentVNode("", true),
799
- createElementVNode("span", _hoisted_2$5, [
800
- renderSlot(_ctx.$slots, "default")
801
- ])
802
- ], 10, _hoisted_1$e);
803
- };
804
- }
805
- });
806
- const _export_sfc = (sfc, props) => {
807
- const target = sfc.__vccOpts || sfc;
808
- for (const [key, val] of props) {
809
- target[key] = val;
810
- }
811
- return target;
812
- };
813
- const _sfc_main$e = {};
814
- const _hoisted_1$d = {
609
+ return ee(x), _e(x), (k, B) => (i(), r("div", {
610
+ id: k.intf.id,
611
+ ref_key: "el",
612
+ ref: a,
613
+ class: U(["baklava-node-interface", d.value])
614
+ }, [
615
+ k.intf.port ? (i(), r("div", {
616
+ key: 0,
617
+ class: U(["__port", { "--selected": _(n)?.from === k.intf }]),
618
+ onPointerover: h,
619
+ onPointerout: O
620
+ }, null, 34)) : N("", !0),
621
+ l("span", Ct, [
622
+ q(k.$slots, "default")
623
+ ])
624
+ ], 10, kt));
625
+ }
626
+ }), z = (o, e) => {
627
+ const t = o.__vccOpts || o;
628
+ for (const [s, n] of e)
629
+ t[s] = n;
630
+ return t;
631
+ }, It = {}, Nt = {
815
632
  xmlns: "http://www.w3.org/2000/svg",
816
633
  width: "24",
817
634
  height: "24",
@@ -819,19 +636,17 @@ const _hoisted_1$d = {
819
636
  fill: "currentColor",
820
637
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
821
638
  };
822
- function _sfc_render$9(_ctx, _cache) {
823
- return openBlock(), createElementBlock("svg", _hoisted_1$d, [..._cache[0] || (_cache[0] = [
824
- createElementVNode("path", {
639
+ function Mt(o, e) {
640
+ return i(), r("svg", Nt, [...e[0] || (e[0] = [
641
+ l("path", {
825
642
  stroke: "none",
826
643
  d: "M0 0h24v24H0z",
827
644
  fill: "none"
828
645
  }, null, -1),
829
- createElementVNode("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
646
+ 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)
830
647
  ])]);
831
648
  }
832
- const LayoutSidebarLeftCollapse = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["render", _sfc_render$9]]);
833
- const _sfc_main$d = {};
834
- const _hoisted_1$c = {
649
+ const Ot = /* @__PURE__ */ z(It, [["render", Mt]]), $t = {}, Et = {
835
650
  xmlns: "http://www.w3.org/2000/svg",
836
651
  width: "24",
837
652
  height: "24",
@@ -839,19 +654,17 @@ const _hoisted_1$c = {
839
654
  fill: "currentColor",
840
655
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
841
656
  };
842
- function _sfc_render$8(_ctx, _cache) {
843
- return openBlock(), createElementBlock("svg", _hoisted_1$c, [..._cache[0] || (_cache[0] = [
844
- createElementVNode("path", {
657
+ function Tt(o, e) {
658
+ return i(), r("svg", Et, [...e[0] || (e[0] = [
659
+ l("path", {
845
660
  stroke: "none",
846
661
  d: "M0 0h24v24H0z",
847
662
  fill: "none"
848
663
  }, null, -1),
849
- createElementVNode("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
664
+ 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)
850
665
  ])]);
851
666
  }
852
- const LayoutSidebarLeftExpand = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["render", _sfc_render$8]]);
853
- const _sfc_main$c = {};
854
- const _hoisted_1$b = {
667
+ const St = /* @__PURE__ */ z($t, [["render", Tt]]), zt = {}, Bt = {
855
668
  xmlns: "http://www.w3.org/2000/svg",
856
669
  width: "24",
857
670
  height: "24",
@@ -859,19 +672,17 @@ const _hoisted_1$b = {
859
672
  fill: "currentColor",
860
673
  class: "balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
861
674
  };
862
- function _sfc_render$7(_ctx, _cache) {
863
- return openBlock(), createElementBlock("svg", _hoisted_1$b, [..._cache[0] || (_cache[0] = [
864
- createElementVNode("path", {
675
+ function Vt(o, e) {
676
+ return i(), r("svg", Bt, [...e[0] || (e[0] = [
677
+ l("path", {
865
678
  stroke: "none",
866
679
  d: "M0 0h24v24H0z",
867
680
  fill: "none"
868
681
  }, null, -1),
869
- createElementVNode("path", { d: "M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z" }, null, -1)
682
+ 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)
870
683
  ])]);
871
684
  }
872
- const LayoutSidebarRight = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$7]]);
873
- const _sfc_main$b = {};
874
- const _hoisted_1$a = {
685
+ const Lt = /* @__PURE__ */ z(zt, [["render", Vt]]), Gt = {}, Ut = {
875
686
  xmlns: "http://www.w3.org/2000/svg",
876
687
  width: "24",
877
688
  height: "24",
@@ -879,19 +690,17 @@ const _hoisted_1$a = {
879
690
  fill: "currentColor",
880
691
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
881
692
  };
882
- function _sfc_render$6(_ctx, _cache) {
883
- return openBlock(), createElementBlock("svg", _hoisted_1$a, [..._cache[0] || (_cache[0] = [
884
- createElementVNode("path", {
693
+ function jt(o, e) {
694
+ return i(), r("svg", Ut, [...e[0] || (e[0] = [
695
+ l("path", {
885
696
  stroke: "none",
886
697
  d: "M0 0h24v24H0z",
887
698
  fill: "none"
888
699
  }, null, -1),
889
- createElementVNode("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
700
+ 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)
890
701
  ])]);
891
702
  }
892
- const LayoutSidebarRightCollapse = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$6]]);
893
- const _sfc_main$a = {};
894
- const _hoisted_1$9 = {
703
+ const Rt = /* @__PURE__ */ z(Gt, [["render", jt]]), Pt = {}, Dt = {
895
704
  xmlns: "http://www.w3.org/2000/svg",
896
705
  width: "24",
897
706
  height: "24",
@@ -899,19 +708,17 @@ const _hoisted_1$9 = {
899
708
  fill: "currentColor",
900
709
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
901
710
  };
902
- function _sfc_render$5(_ctx, _cache) {
903
- return openBlock(), createElementBlock("svg", _hoisted_1$9, [..._cache[0] || (_cache[0] = [
904
- createElementVNode("path", {
711
+ function At(o, e) {
712
+ return i(), r("svg", Dt, [...e[0] || (e[0] = [
713
+ l("path", {
905
714
  stroke: "none",
906
715
  d: "M0 0h24v24H0z",
907
716
  fill: "none"
908
717
  }, null, -1),
909
- createElementVNode("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
718
+ 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)
910
719
  ])]);
911
720
  }
912
- const LayoutSidebarRightExpand = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$5]]);
913
- const _sfc_main$9 = {};
914
- const _hoisted_1$8 = {
721
+ const Ht = /* @__PURE__ */ z(Pt, [["render", At]]), Ft = {}, Wt = {
915
722
  xmlns: "http://www.w3.org/2000/svg",
916
723
  class: "baklava-icon",
917
724
  width: "24",
@@ -923,14 +730,12 @@ const _hoisted_1$8 = {
923
730
  "stroke-linecap": "round",
924
731
  "stroke-linejoin": "round"
925
732
  };
926
- function _sfc_render$4(_ctx, _cache) {
927
- return openBlock(), createElementBlock("svg", _hoisted_1$8, [..._cache[0] || (_cache[0] = [
928
- createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>', 8)
733
+ function Xt(o, e) {
734
+ return i(), r("svg", Wt, [...e[0] || (e[0] = [
735
+ te('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>', 8)
929
736
  ])]);
930
737
  }
931
- const Schema = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$4]]);
932
- const _sfc_main$8 = {};
933
- const _hoisted_1$7 = {
738
+ const Yt = /* @__PURE__ */ z(Ft, [["render", Xt]]), Jt = {}, qt = {
934
739
  xmlns: "http://www.w3.org/2000/svg",
935
740
  class: "baklava-icon",
936
741
  width: "24",
@@ -942,14 +747,12 @@ const _hoisted_1$7 = {
942
747
  "stroke-linecap": "round",
943
748
  "stroke-linejoin": "round"
944
749
  };
945
- function _sfc_render$3(_ctx, _cache) {
946
- return openBlock(), createElementBlock("svg", _hoisted_1$7, [..._cache[0] || (_cache[0] = [
947
- createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>', 9)
750
+ function Qt(o, e) {
751
+ return i(), r("svg", qt, [...e[0] || (e[0] = [
752
+ te('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>', 9)
948
753
  ])]);
949
754
  }
950
- const SchemaOff = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$3]]);
951
- const _sfc_main$7 = {};
952
- const _hoisted_1$6 = {
755
+ const Zt = /* @__PURE__ */ z(Jt, [["render", Qt]]), Kt = {}, es = {
953
756
  xmlns: "http://www.w3.org/2000/svg",
954
757
  class: "baklava-icon",
955
758
  width: "24",
@@ -961,14 +764,12 @@ const _hoisted_1$6 = {
961
764
  "stroke-linecap": "round",
962
765
  "stroke-linejoin": "round"
963
766
  };
964
- function _sfc_render$2(_ctx, _cache) {
965
- return openBlock(), createElementBlock("svg", _hoisted_1$6, [..._cache[0] || (_cache[0] = [
966
- createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
767
+ function ts(o, e) {
768
+ return i(), r("svg", es, [...e[0] || (e[0] = [
769
+ te('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
967
770
  ])]);
968
771
  }
969
- const TrashOff = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$2]]);
970
- const _sfc_main$6 = {};
971
- const _hoisted_1$5 = {
772
+ const ss = /* @__PURE__ */ z(Kt, [["render", ts]]), ns = {}, os = {
972
773
  xmlns: "http://www.w3.org/2000/svg",
973
774
  class: "baklava-icon",
974
775
  width: "16",
@@ -980,338 +781,262 @@ const _hoisted_1$5 = {
980
781
  "stroke-linecap": "round",
981
782
  "stroke-linejoin": "round"
982
783
  };
983
- function _sfc_render$1(_ctx, _cache) {
984
- return openBlock(), createElementBlock("svg", _hoisted_1$5, [..._cache[0] || (_cache[0] = [
985
- createElementVNode("path", {
784
+ function as(o, e) {
785
+ return i(), r("svg", os, [...e[0] || (e[0] = [
786
+ l("path", {
986
787
  stroke: "none",
987
788
  d: "M0 0h24v24H0z",
988
789
  fill: "none"
989
790
  }, null, -1),
990
- createElementVNode("circle", {
791
+ l("circle", {
991
792
  cx: "12",
992
793
  cy: "12",
993
794
  r: "1"
994
795
  }, null, -1),
995
- createElementVNode("circle", {
796
+ l("circle", {
996
797
  cx: "12",
997
798
  cy: "19",
998
799
  r: "1"
999
800
  }, null, -1),
1000
- createElementVNode("circle", {
801
+ l("circle", {
1001
802
  cx: "12",
1002
803
  cy: "5",
1003
804
  r: "1"
1004
805
  }, null, -1)
1005
806
  ])]);
1006
807
  }
1007
- const VerticalDots = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]);
1008
- const _hoisted_1$4 = ["id", "data-node-type"];
1009
- const _hoisted_2$4 = {
808
+ const is = /* @__PURE__ */ z(ns, [["render", as]]), rs = ["id", "data-node-type"], ls = {
1010
809
  class: "__title-label",
1011
810
  style: { "flex-grow": "1" }
1012
- };
1013
- const _hoisted_3$2 = { key: 0 };
1014
- const _hoisted_4$1 = {
811
+ }, ds = { key: 0 }, us = {
1015
812
  class: "__menu",
1016
- style: { "display": "flex" }
1017
- };
1018
- const _hoisted_5 = { class: "__outputs" };
1019
- const _hoisted_6 = { key: 0 };
1020
- const _hoisted_7 = ["id", "title"];
1021
- const _hoisted_8 = { class: "__inputs" };
1022
- const _hoisted_9 = { key: 0 };
1023
- const _hoisted_10 = ["id", "title"];
1024
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
813
+ style: { display: "flex" }
814
+ }, cs = { class: "__outputs" }, ps = { key: 0 }, hs = ["id", "title"], vs = { class: "__inputs" }, ms = { key: 0 }, fs = ["id", "title"], gs = /* @__PURE__ */ G({
1025
815
  __name: "CodeGraphNode",
1026
816
  props: {
1027
817
  node: {},
1028
- selected: { type: Boolean, default: false },
818
+ selected: { type: Boolean, default: !1 },
1029
819
  dragging: { type: Boolean }
1030
820
  },
1031
821
  emits: ["select", "start-drag", "update"],
1032
- setup(__props, { emit: __emit }) {
1033
- const ContextMenu = Components.ContextMenu;
1034
- const NodeInterface2 = Components.NodeInterface;
1035
- const props = __props;
1036
- const node = computed(() => props.node);
1037
- const emit = __emit;
1038
- const { viewModel } = useViewModel();
1039
- const { graph, switchGraph } = useGraph();
1040
- const el = ref(null);
1041
- const renaming = ref(false);
1042
- const tempName = ref("");
1043
- const renameInputEl = ref(null);
1044
- const isResizing = ref(false);
1045
- let resizeStartWidth = 0;
1046
- let resizeStartMouseX = 0;
1047
- const showContextMenu = ref(false);
1048
- const contextMenuItems = computed(() => {
1049
- const items = [
822
+ setup(o, { emit: e }) {
823
+ const t = ve.ContextMenu, s = ve.NodeInterface, n = o, a = f(() => n.node), u = e, { viewModel: d } = H(), { graph: h, switchGraph: O } = K(), x = E(null), k = E(!1), B = E(""), y = E(null), m = E(!1);
824
+ let g = 0, b = 0;
825
+ const p = E(!1), w = f(() => {
826
+ const c = [
1050
827
  { value: "edit", label: "Edit" },
1051
828
  { value: "rename", label: "Rename" },
1052
829
  { value: "delete", label: "Delete" }
1053
830
  ];
1054
- if (props.node.type.startsWith(GRAPH_NODE_TYPE_PREFIX)) {
1055
- items.push({ value: "editSubgraph", label: "Edit Subgraph" });
1056
- }
1057
- return items;
1058
- });
1059
- const classes = computed(() => ({
1060
- "--selected": props.selected,
1061
- "--dragging": props.dragging,
1062
- "--two-column": !!props.node.twoColumn,
1063
- "--hidden": node.value.state?.hidden
1064
- }));
1065
- const classesContent = computed(() => ({
1066
- "--reverse-y": props.node.reverseY ?? viewModel.value.settings.nodes.reverseY
1067
- }));
1068
- const styles = computed(() => ({
1069
- "top": `${props.node.position?.y ?? 0}px`,
1070
- "left": `${props.node.position?.x ?? 0}px`,
1071
- "--width": `${props.node.width ?? viewModel.value.settings.nodes.defaultWidth}px`
1072
- }));
1073
- const displayedInputs = computed(() => Object.values(props.node.inputs).filter((ni) => !ni.hidden));
1074
- const displayedOutputs = computed(() => Object.values(props.node.outputs).filter((ni) => !ni.hidden));
1075
- const select = () => {
1076
- emit("select");
1077
- };
1078
- const startDrag = (ev) => {
1079
- if (!props.selected) {
1080
- select();
1081
- }
1082
- emit("start-drag", ev);
1083
- };
1084
- const openContextMenu = () => {
1085
- showContextMenu.value = true;
1086
- };
1087
- const closeSidebar = () => {
1088
- const sidebar = viewModel.value.displayedGraph.sidebar;
1089
- sidebar.nodeId = "";
1090
- sidebar.visible = false;
1091
- };
1092
- const openSidebar = () => {
1093
- const sidebar = viewModel.value.displayedGraph.sidebar;
1094
- sidebar.nodeId = props.node.id;
1095
- sidebar.visible = true;
1096
- };
1097
- const updateSidebar = () => {
1098
- const sidebar = viewModel.value.displayedGraph.sidebar;
1099
- sidebar.nodeId = props.node.id;
1100
- };
1101
- const onContextMenuClick = async (action) => {
1102
- switch (action) {
831
+ return n.node.type.startsWith(J) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
832
+ }), I = f(() => ({
833
+ "--selected": n.selected,
834
+ "--dragging": n.dragging,
835
+ "--two-column": !!n.node.twoColumn,
836
+ "--hidden": a.value.state?.hidden
837
+ })), ke = f(() => ({
838
+ "--reverse-y": n.node.reverseY ?? d.value.settings.nodes.reverseY
839
+ })), Ce = f(() => ({
840
+ top: `${n.node.position?.y ?? 0}px`,
841
+ left: `${n.node.position?.x ?? 0}px`,
842
+ "--width": `${n.node.width ?? d.value.settings.nodes.defaultWidth}px`
843
+ })), Ie = f(() => Object.values(n.node.inputs).filter((c) => !c.hidden)), Ne = f(() => Object.values(n.node.outputs).filter((c) => !c.hidden)), re = () => {
844
+ u("select");
845
+ }, Me = (c) => {
846
+ n.selected || re(), u("start-drag", c);
847
+ }, le = () => {
848
+ p.value = !0;
849
+ }, Oe = () => {
850
+ const c = d.value.displayedGraph.sidebar;
851
+ c.nodeId = "", c.visible = !1;
852
+ }, de = () => {
853
+ const c = d.value.displayedGraph.sidebar;
854
+ c.nodeId = n.node.id, c.visible = !0;
855
+ }, $e = () => {
856
+ const c = d.value.displayedGraph.sidebar;
857
+ c.nodeId = n.node.id;
858
+ }, Ee = async (c) => {
859
+ switch (c) {
1103
860
  case "edit":
1104
- openSidebar();
861
+ de();
1105
862
  break;
1106
863
  case "delete":
1107
- graph.value.removeNode(props.node);
864
+ h.value.removeNode(n.node);
1108
865
  break;
1109
866
  case "rename":
1110
- tempName.value = props.node.title;
1111
- renaming.value = true;
1112
- await nextTick();
1113
- renameInputEl.value?.focus();
867
+ B.value = n.node.title, k.value = !0, await nt(), y.value?.focus();
1114
868
  break;
1115
869
  case "editSubgraph":
1116
- switchGraph(props.node.template);
870
+ O(n.node.template);
1117
871
  break;
1118
872
  }
873
+ }, ue = () => {
874
+ n.node.title = B.value, k.value = !1;
875
+ }, ce = () => {
876
+ x.value && d.value.hooks.renderNode.execute({ node: n.node, el: x.value });
877
+ }, Te = (c) => {
878
+ m.value = !0, g = n.node.width, b = c.clientX, c.preventDefault();
879
+ }, pe = (c) => {
880
+ if (!m.value) return;
881
+ const C = c.clientX - b, v = g + C / h.value.scaling, Se = d.value.settings.nodes.minWidth, ze = d.value.settings.nodes.maxWidth;
882
+ n.node.width = Math.max(Se, Math.min(ze, v));
883
+ }, he = () => {
884
+ m.value = !1;
1119
885
  };
1120
- const doneRenaming = () => {
1121
- props.node.title = tempName.value;
1122
- renaming.value = false;
1123
- };
1124
- const onRender = () => {
1125
- if (el.value) {
1126
- viewModel.value.hooks.renderNode.execute({ node: props.node, el: el.value });
1127
- }
1128
- };
1129
- const startResize = (ev) => {
1130
- isResizing.value = true;
1131
- resizeStartWidth = props.node.width;
1132
- resizeStartMouseX = ev.clientX;
1133
- ev.preventDefault();
1134
- };
1135
- const doResize = (ev) => {
1136
- if (!isResizing.value) return;
1137
- const deltaX = ev.clientX - resizeStartMouseX;
1138
- const newWidth = resizeStartWidth + deltaX / graph.value.scaling;
1139
- const minWidth = viewModel.value.settings.nodes.minWidth;
1140
- const maxWidth = viewModel.value.settings.nodes.maxWidth;
1141
- props.node.width = Math.max(minWidth, Math.min(maxWidth, newWidth));
1142
- };
1143
- const stopResize = () => {
1144
- isResizing.value = false;
1145
- };
1146
- onMounted(() => {
1147
- onRender();
1148
- window.addEventListener("mousemove", doResize);
1149
- window.addEventListener("mouseup", stopResize);
1150
- });
1151
- onUpdated(onRender);
1152
- onBeforeUnmount(() => {
1153
- window.removeEventListener("mousemove", doResize);
1154
- window.removeEventListener("mouseup", stopResize);
1155
- });
1156
- return (_ctx, _cache) => {
1157
- return openBlock(), createElementBlock("div", {
1158
- id: node.value.id,
1159
- ref_key: "el",
1160
- ref: el,
1161
- class: normalizeClass([classes.value, "baklava-node"]),
1162
- "data-node-type": node.value.type,
1163
- style: normalizeStyle(styles.value),
1164
- onPointerdown: select
886
+ return ee(() => {
887
+ ce(), window.addEventListener("mousemove", pe), window.addEventListener("mouseup", he);
888
+ }), _e(ce), tt(() => {
889
+ window.removeEventListener("mousemove", pe), window.removeEventListener("mouseup", he);
890
+ }), (c, C) => (i(), r("div", {
891
+ id: a.value.id,
892
+ ref_key: "el",
893
+ ref: x,
894
+ class: U([I.value, "baklava-node"]),
895
+ "data-node-type": a.value.type,
896
+ style: se(Ce.value),
897
+ onPointerdown: re
898
+ }, [
899
+ _(d).settings.nodes.resizable ? (i(), r("div", {
900
+ key: 0,
901
+ class: "__resize-handle",
902
+ onMousedown: Te
903
+ }, null, 32)) : N("", !0),
904
+ l("div", {
905
+ class: "__title",
906
+ onPointerdown: D(Me, ["self", "stop"]),
907
+ onContextmenu: D(le, ["prevent"])
1165
908
  }, [
1166
- unref(viewModel).settings.nodes.resizable ? (openBlock(), createElementBlock("div", {
909
+ a.value.inputs._node ? (i(), V(me, {
1167
910
  key: 0,
1168
- class: "__resize-handle",
1169
- onMousedown: startResize
1170
- }, null, 32)) : createCommentVNode("", true),
1171
- createElementVNode("div", {
1172
- class: "__title",
1173
- onPointerdown: withModifiers(startDrag, ["self", "stop"]),
1174
- onContextmenu: withModifiers(openContextMenu, ["prevent"])
1175
- }, [
1176
- node.value.inputs._node ? (openBlock(), createBlock(_sfc_main$f, {
1177
- key: 0,
1178
- node: node.value,
1179
- intf: node.value.inputs._node,
1180
- class: "--input",
1181
- "data-interface-type": "node",
1182
- style: { "flex-grow": "0" }
1183
- }, null, 8, ["node", "intf"])) : createCommentVNode("", true),
1184
- !renaming.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1185
- createElementVNode("div", _hoisted_2$4, [
1186
- node.value.idx > -1 ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(node.value.idx + 1) + " - ", 1)) : createCommentVNode("", true),
1187
- createTextVNode(toDisplayString(node.value.title) + " (" + toDisplayString(node.value.shortId) + ") ", 1)
1188
- ]),
1189
- createElementVNode("div", _hoisted_4$1, [
1190
- !node.value.subgraph ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1191
- !unref(viewModel).displayedGraph.sidebar.visible && unref(viewModel).displayedGraph.sidebar.nodeId !== node.value.id ? (openBlock(), createBlock(unref(LayoutSidebarRightExpand), {
1192
- key: 0,
1193
- class: "--clickable mx-1",
1194
- onClick: openSidebar
1195
- })) : unref(viewModel).displayedGraph.sidebar.visible && unref(viewModel).displayedGraph.sidebar.nodeId !== node.value.id ? (openBlock(), createBlock(unref(LayoutSidebarRight), {
1196
- key: 1,
1197
- class: "--clickable mx-1",
1198
- onClick: updateSidebar
1199
- })) : (openBlock(), createBlock(unref(LayoutSidebarRightCollapse), {
1200
- key: 2,
1201
- class: "--clickable mx-1",
1202
- onClick: closeSidebar
1203
- }))
1204
- ], 64)) : createCommentVNode("", true),
1205
- createVNode(unref(VerticalDots), {
1206
- class: "--clickable mx-1",
1207
- onClick: openContextMenu
1208
- }),
1209
- createVNode(unref(ContextMenu), {
1210
- modelValue: showContextMenu.value,
1211
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => showContextMenu.value = $event),
1212
- x: 0,
1213
- y: 0,
1214
- items: contextMenuItems.value,
1215
- onClick: onContextMenuClick
1216
- }, null, 8, ["modelValue", "items"])
1217
- ])
1218
- ], 64)) : withDirectives((openBlock(), createElementBlock("input", {
1219
- key: 2,
1220
- ref_key: "renameInputEl",
1221
- ref: renameInputEl,
1222
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => tempName.value = $event),
1223
- class: "baklava-input",
1224
- placeholder: "Node Name",
1225
- style: { "flex-grow": "1" },
1226
- type: "text",
1227
- onBlur: doneRenaming,
1228
- onKeydown: withKeys(doneRenaming, ["enter"])
1229
- }, null, 544)), [
1230
- [vModelText, tempName.value]
1231
- ]),
1232
- node.value.outputs._node ? (openBlock(), createBlock(_sfc_main$f, {
1233
- key: 3,
1234
- node: node.value,
1235
- intf: node.value.outputs._node,
1236
- class: "--output",
1237
- "data-interface-type": "node"
1238
- }, null, 8, ["node", "intf"])) : createCommentVNode("", true)
1239
- ], 32),
1240
- createElementVNode("div", {
1241
- class: normalizeClass(["__content", classesContent.value]),
1242
- onKeydown: _cache[2] || (_cache[2] = withKeys(withModifiers(() => {
1243
- }, ["stop"]), ["delete"])),
1244
- onContextmenu: _cache[3] || (_cache[3] = withModifiers(() => {
1245
- }, ["prevent"]))
1246
- }, [
1247
- createElementVNode("div", _hoisted_5, [
1248
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayedOutputs.value, (output) => {
1249
- return openBlock(), createElementBlock(Fragment, {
1250
- key: output.id
1251
- }, [
1252
- node.value.state?.hidden ? (openBlock(), createElementBlock("div", _hoisted_6, [
1253
- output.port ? (openBlock(), createElementBlock("div", {
1254
- key: 0,
1255
- id: output.id,
1256
- title: output.name,
1257
- class: "baklava-node-interface --output --connected"
1258
- }, [..._cache[4] || (_cache[4] = [
1259
- createElementVNode("div", { class: "__port" }, null, -1)
1260
- ])], 8, _hoisted_7)) : createCommentVNode("", true)
1261
- ])) : renderSlot(_ctx.$slots, "nodeInterface", {
1262
- key: 1,
1263
- type: "output",
1264
- node: node.value,
1265
- intf: output
1266
- }, () => [
1267
- createVNode(unref(NodeInterface2), {
1268
- node: node.value,
1269
- intf: output
1270
- }, null, 8, ["node", "intf"])
1271
- ])
1272
- ], 64);
1273
- }), 128))
911
+ node: a.value,
912
+ intf: a.value.inputs._node,
913
+ class: "--input",
914
+ "data-interface-type": "node",
915
+ style: { "flex-grow": "0" }
916
+ }, null, 8, ["node", "intf"])) : N("", !0),
917
+ k.value ? ne((i(), r("input", {
918
+ key: 2,
919
+ ref_key: "renameInputEl",
920
+ ref: y,
921
+ "onUpdate:modelValue": C[1] || (C[1] = (v) => B.value = v),
922
+ class: "baklava-input",
923
+ placeholder: "Node Name",
924
+ style: { "flex-grow": "1" },
925
+ type: "text",
926
+ onBlur: ue,
927
+ onKeydown: Q(ue, ["enter"])
928
+ }, null, 544)), [
929
+ [oe, B.value]
930
+ ]) : (i(), r(T, { key: 1 }, [
931
+ l("div", ls, [
932
+ a.value.idx > -1 ? (i(), r("span", ds, L(a.value.idx + 1) + " - ", 1)) : N("", !0),
933
+ st(L(a.value.title) + " (" + L(a.value.shortId) + ") ", 1)
1274
934
  ]),
1275
- createElementVNode("div", _hoisted_8, [
1276
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayedInputs.value, (input) => {
1277
- return openBlock(), createElementBlock(Fragment, {
1278
- key: input.id
1279
- }, [
1280
- node.value.state?.hidden ? (openBlock(), createElementBlock("div", _hoisted_9, [
1281
- input.port ? (openBlock(), createElementBlock("div", {
1282
- key: 0,
1283
- id: input.id,
1284
- title: input.name,
1285
- class: "baklava-node-interface --input --connected"
1286
- }, [..._cache[5] || (_cache[5] = [
1287
- createElementVNode("div", { class: "__port" }, null, -1)
1288
- ])], 8, _hoisted_10)) : createCommentVNode("", true)
1289
- ])) : renderSlot(_ctx.$slots, "nodeInterface", {
1290
- key: 1,
1291
- node: node.value,
1292
- intf: input,
1293
- type: "input"
1294
- }, () => [
1295
- createVNode(unref(NodeInterface2), {
1296
- node: node.value,
1297
- intf: input,
1298
- title: input.name
1299
- }, null, 8, ["node", "intf", "title"])
1300
- ])
1301
- ], 64);
1302
- }), 128))
935
+ l("div", us, [
936
+ a.value.subgraph ? N("", !0) : (i(), r(T, { key: 0 }, [
937
+ !_(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Ht), {
938
+ key: 0,
939
+ class: "--clickable mx-1",
940
+ onClick: de
941
+ })) : _(d).displayedGraph.sidebar.visible && _(d).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), V(_(Lt), {
942
+ key: 1,
943
+ class: "--clickable mx-1",
944
+ onClick: $e
945
+ })) : (i(), V(_(Rt), {
946
+ key: 2,
947
+ class: "--clickable mx-1",
948
+ onClick: Oe
949
+ }))
950
+ ], 64)),
951
+ S(_(is), {
952
+ class: "--clickable mx-1",
953
+ onClick: le
954
+ }),
955
+ S(_(t), {
956
+ modelValue: p.value,
957
+ "onUpdate:modelValue": C[0] || (C[0] = (v) => p.value = v),
958
+ x: 0,
959
+ y: 0,
960
+ items: w.value,
961
+ onClick: Ee
962
+ }, null, 8, ["modelValue", "items"])
1303
963
  ])
1304
- ], 34)
1305
- ], 46, _hoisted_1$4);
1306
- };
964
+ ], 64)),
965
+ a.value.outputs._node ? (i(), V(me, {
966
+ key: 3,
967
+ node: a.value,
968
+ intf: a.value.outputs._node,
969
+ class: "--output",
970
+ "data-interface-type": "node"
971
+ }, null, 8, ["node", "intf"])) : N("", !0)
972
+ ], 32),
973
+ l("div", {
974
+ class: U(["__content", ke.value]),
975
+ onKeydown: C[2] || (C[2] = Q(D(() => {
976
+ }, ["stop"]), ["delete"])),
977
+ onContextmenu: C[3] || (C[3] = D(() => {
978
+ }, ["prevent"]))
979
+ }, [
980
+ l("div", cs, [
981
+ (i(!0), r(T, null, A(Ne.value, (v) => (i(), r(T, {
982
+ key: v.id
983
+ }, [
984
+ a.value.state?.hidden ? (i(), r("div", ps, [
985
+ v.port ? (i(), r("div", {
986
+ key: 0,
987
+ id: v.id,
988
+ title: v.name,
989
+ class: "baklava-node-interface --output --connected"
990
+ }, [...C[4] || (C[4] = [
991
+ l("div", { class: "__port" }, null, -1)
992
+ ])], 8, hs)) : N("", !0)
993
+ ])) : q(c.$slots, "nodeInterface", {
994
+ key: 1,
995
+ type: "output",
996
+ node: a.value,
997
+ intf: v
998
+ }, () => [
999
+ S(_(s), {
1000
+ node: a.value,
1001
+ intf: v
1002
+ }, null, 8, ["node", "intf"])
1003
+ ])
1004
+ ], 64))), 128))
1005
+ ]),
1006
+ l("div", vs, [
1007
+ (i(!0), r(T, null, A(Ie.value, (v) => (i(), r(T, {
1008
+ key: v.id
1009
+ }, [
1010
+ a.value.state?.hidden ? (i(), r("div", ms, [
1011
+ v.port ? (i(), r("div", {
1012
+ key: 0,
1013
+ id: v.id,
1014
+ title: v.name,
1015
+ class: "baklava-node-interface --input --connected"
1016
+ }, [...C[5] || (C[5] = [
1017
+ l("div", { class: "__port" }, null, -1)
1018
+ ])], 8, fs)) : N("", !0)
1019
+ ])) : q(c.$slots, "nodeInterface", {
1020
+ key: 1,
1021
+ node: a.value,
1022
+ intf: v,
1023
+ type: "input"
1024
+ }, () => [
1025
+ S(_(s), {
1026
+ node: a.value,
1027
+ intf: v,
1028
+ title: v.name
1029
+ }, null, 8, ["node", "intf", "title"])
1030
+ ])
1031
+ ], 64))), 128))
1032
+ ])
1033
+ ], 34)
1034
+ ], 46, rs));
1307
1035
  }
1308
- });
1309
- const _hoisted_1$3 = ["title"];
1310
- const _hoisted_2$3 = {
1036
+ }), bs = ["title"], _s = {
1311
1037
  key: 0,
1312
1038
  class: "__label"
1313
- };
1314
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1039
+ }, ys = /* @__PURE__ */ G({
1315
1040
  __name: "Checkbox",
1316
1041
  props: {
1317
1042
  modelValue: { type: Boolean },
@@ -1319,494 +1044,373 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1319
1044
  name: {}
1320
1045
  },
1321
1046
  emits: ["update:modelValue"],
1322
- setup(__props, { emit: __emit }) {
1323
- const emit = __emit;
1324
- return (_ctx, _cache) => {
1325
- return openBlock(), createElementBlock("div", {
1326
- class: normalizeClass(["baklava-checkbox", { "--checked": _ctx.inversed ? !_ctx.modelValue : _ctx.modelValue }]),
1327
- title: _ctx.name,
1328
- onClick: _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", !_ctx.modelValue))
1329
- }, [
1330
- _cache[1] || (_cache[1] = createElementVNode("div", { class: "__checkmark-container" }, [
1331
- createElementVNode("svg", {
1332
- xmlns: "http://www.w3.org/2000/svg",
1333
- width: "18",
1334
- height: "18",
1335
- viewBox: "0 0 18 18"
1336
- }, [
1337
- createElementVNode("path", {
1338
- class: "__checkmark",
1339
- d: "M 6 5 L 6 10 L 16 10",
1340
- transform: "rotate(-45 10 10)"
1341
- })
1342
- ])
1343
- ], -1)),
1344
- _ctx.name ? (openBlock(), createElementBlock("div", _hoisted_2$3, toDisplayString(_ctx.name), 1)) : createCommentVNode("", true)
1345
- ], 10, _hoisted_1$3);
1346
- };
1047
+ setup(o, { emit: e }) {
1048
+ const t = e;
1049
+ return (s, n) => (i(), r("div", {
1050
+ class: U(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue }]),
1051
+ title: s.name,
1052
+ onClick: n[0] || (n[0] = (a) => t("update:modelValue", !s.modelValue))
1053
+ }, [
1054
+ n[1] || (n[1] = l("div", { class: "__checkmark-container" }, [
1055
+ l("svg", {
1056
+ xmlns: "http://www.w3.org/2000/svg",
1057
+ width: "18",
1058
+ height: "18",
1059
+ viewBox: "0 0 18 18"
1060
+ }, [
1061
+ l("path", {
1062
+ class: "__checkmark",
1063
+ d: "M 6 5 L 6 10 L 16 10",
1064
+ transform: "rotate(-45 10 10)"
1065
+ })
1066
+ ])
1067
+ ], -1)),
1068
+ s.name ? (i(), r("div", _s, L(s.name), 1)) : N("", !0)
1069
+ ], 10, bs));
1347
1070
  }
1348
- });
1349
- const _hoisted_1$2 = { class: "__header" };
1350
- const _hoisted_2$2 = { class: "__node-name" };
1351
- const _hoisted_3$1 = { style: { "display": "flex" } };
1352
- const _hoisted_4 = {
1071
+ }), ws = { class: "__header" }, xs = { class: "__node-name" }, ks = { style: { display: "flex" } }, Cs = {
1353
1072
  key: 1,
1354
1073
  class: "__interface"
1355
- };
1356
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1074
+ }, Is = /* @__PURE__ */ G({
1357
1075
  __name: "CodeGraphSidebar",
1358
- setup(__props) {
1359
- const { viewModel } = useViewModel();
1360
- const { graph } = useGraph();
1361
- const el = ref(null);
1362
- const width = toRef(viewModel.value.settings.sidebar, "width");
1363
- const resizable = computed(() => viewModel.value.settings.sidebar.resizable);
1364
- let resizeStartWidth = 0;
1365
- let resizeStartMouseX = 0;
1366
- const node = computed(() => {
1367
- const id = graph.value.sidebar.nodeId;
1368
- return graph.value.nodes.find((x) => x.id === id);
1369
- });
1370
- const codeNode = computed(() => node.value);
1371
- const styles = computed(() => ({
1372
- width: `${width.value}px`
1373
- }));
1374
- const displayedInterfaces = computed(() => {
1375
- if (!node.value) return [];
1376
- const allIntfs = [...Object.values(node.value.inputs), ...Object.values(node.value.outputs)];
1377
- return allIntfs.filter((intf) => intf.displayInSidebar && intf.component);
1378
- });
1379
- const close = () => {
1380
- graph.value.sidebar.visible = false;
1381
- };
1382
- const doneRenaming = () => {
1383
- node.value?.events.update.emit(null);
1384
- };
1385
- const startResize = (event) => {
1386
- resizeStartWidth = width.value;
1387
- resizeStartMouseX = event.clientX;
1388
- window.addEventListener("mousemove", onMouseMove);
1389
- window.addEventListener(
1076
+ setup(o) {
1077
+ const { viewModel: e } = H(), { graph: t } = K(), s = E(null), n = ye(e.value.settings.sidebar, "width"), a = f(() => e.value.settings.sidebar.resizable);
1078
+ let u = 0, d = 0;
1079
+ const h = f(() => {
1080
+ const b = t.value.sidebar.nodeId;
1081
+ return t.value.nodes.find((p) => p.id === b);
1082
+ }), O = f(() => h.value), x = f(() => ({
1083
+ width: `${n.value}px`
1084
+ })), k = f(() => h.value ? [...Object.values(h.value.inputs), ...Object.values(h.value.outputs)].filter((p) => p.displayInSidebar && p.component) : []), B = () => {
1085
+ t.value.sidebar.visible = !1;
1086
+ }, y = () => {
1087
+ h.value?.events.update.emit(null);
1088
+ }, m = (b) => {
1089
+ u = n.value, d = b.clientX, window.addEventListener("mousemove", g), window.addEventListener(
1390
1090
  "mouseup",
1391
1091
  () => {
1392
- window.removeEventListener("mousemove", onMouseMove);
1092
+ window.removeEventListener("mousemove", g);
1393
1093
  },
1394
- { once: true }
1094
+ { once: !0 }
1395
1095
  );
1096
+ }, g = (b) => {
1097
+ const p = s.value?.parentElement?.getBoundingClientRect().width ?? 500, w = b.clientX - d;
1098
+ let I = u - w;
1099
+ I < 300 ? I = 300 : I > 0.9 * p && (I = 0.9 * p), n.value = I;
1396
1100
  };
1397
- const onMouseMove = (event) => {
1398
- const maxwidth = el.value?.parentElement?.getBoundingClientRect().width ?? 500;
1399
- const deltaX = event.clientX - resizeStartMouseX;
1400
- let newWidth = resizeStartWidth - deltaX;
1401
- if (newWidth < 300) {
1402
- newWidth = 300;
1403
- } else if (newWidth > 0.9 * maxwidth) {
1404
- newWidth = 0.9 * maxwidth;
1405
- }
1406
- width.value = newWidth;
1407
- };
1408
- return (_ctx, _cache) => {
1409
- return openBlock(), createElementBlock("div", {
1410
- ref_key: "el",
1411
- ref: el,
1412
- class: normalizeClass(["baklava-sidebar", { "--open": unref(graph).sidebar.visible }]),
1413
- style: normalizeStyle(styles.value)
1101
+ return (b, p) => (i(), r("div", {
1102
+ ref_key: "el",
1103
+ ref: s,
1104
+ class: U(["baklava-sidebar", { "--open": _(t).sidebar.visible }]),
1105
+ style: se(x.value)
1106
+ }, [
1107
+ a.value ? (i(), r("div", {
1108
+ key: 0,
1109
+ class: "__resizer",
1110
+ onMousedown: m
1111
+ }, null, 32)) : N("", !0),
1112
+ l("div", ws, [
1113
+ l("button", {
1114
+ tabindex: "-1",
1115
+ class: "__close",
1116
+ onClick: B
1117
+ }, "×"),
1118
+ l("div", xs, [
1119
+ l("b", null, L(h.value ? h.value.title : ""), 1)
1120
+ ])
1121
+ ]),
1122
+ (i(!0), r(T, null, A(k.value, (w) => (i(), r("div", {
1123
+ key: w.id,
1124
+ class: "__interface"
1414
1125
  }, [
1415
- resizable.value ? (openBlock(), createElementBlock("div", {
1416
- key: 0,
1417
- class: "__resizer",
1418
- onMousedown: startResize
1419
- }, null, 32)) : createCommentVNode("", true),
1420
- createElementVNode("div", _hoisted_1$2, [
1421
- createElementVNode("button", {
1422
- tabindex: "-1",
1423
- class: "__close",
1424
- onClick: close
1425
- }, "×"),
1426
- createElementVNode("div", _hoisted_2$2, [
1427
- createElementVNode("b", null, toDisplayString(node.value ? node.value.title : ""), 1)
1428
- ])
1429
- ]),
1430
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayedInterfaces.value, (intf) => {
1431
- return openBlock(), createElementBlock("div", {
1432
- key: intf.id,
1433
- class: "__interface"
1434
- }, [
1435
- createElementVNode("div", _hoisted_3$1, [
1436
- createVNode(_sfc_main$4, {
1437
- modelValue: intf.hidden,
1438
- "onUpdate:modelValue": [
1439
- ($event) => intf.hidden = $event,
1440
- _cache[0] || (_cache[0] = () => node.value?.events.update.emit(null))
1441
- ],
1442
- inversed: "",
1443
- style: { "margin-right": "8px" }
1444
- }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1445
- (openBlock(), createBlock(resolveDynamicComponent(intf.component), {
1446
- modelValue: intf.value,
1447
- "onUpdate:modelValue": ($event) => intf.value = $event,
1448
- node: node.value,
1449
- intf,
1450
- style: { "width": "100%" }
1451
- }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1452
- ])
1453
- ]);
1454
- }), 128)),
1455
- codeNode.value && codeNode.value.state ? (openBlock(), createElementBlock("div", _hoisted_4, [
1456
- _cache[2] || (_cache[2] = createElementVNode("label", null, "Variable name", -1)),
1457
- withDirectives(createElementVNode("input", {
1458
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => codeNode.value.state.variableName = $event),
1459
- type: "text",
1460
- class: "baklava-input",
1461
- title: "Variable name",
1462
- onBlur: doneRenaming,
1463
- onKeydown: withKeys(doneRenaming, ["enter"])
1464
- }, null, 544), [
1465
- [vModelText, codeNode.value.state.variableName]
1466
- ])
1467
- ])) : createCommentVNode("", true)
1468
- ], 6);
1469
- };
1126
+ l("div", ks, [
1127
+ S(ys, {
1128
+ modelValue: w.hidden,
1129
+ "onUpdate:modelValue": [
1130
+ (I) => w.hidden = I,
1131
+ p[0] || (p[0] = () => h.value?.events.update.emit(null))
1132
+ ],
1133
+ inversed: "",
1134
+ style: { "margin-right": "8px" }
1135
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1136
+ (i(), V(ot(w.component), {
1137
+ modelValue: w.value,
1138
+ "onUpdate:modelValue": (I) => w.value = I,
1139
+ node: h.value,
1140
+ intf: w,
1141
+ style: { width: "100%" }
1142
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1143
+ ])
1144
+ ]))), 128)),
1145
+ O.value && O.value.state ? (i(), r("div", Cs, [
1146
+ p[2] || (p[2] = l("label", null, "Variable name", -1)),
1147
+ ne(l("input", {
1148
+ "onUpdate:modelValue": p[1] || (p[1] = (w) => O.value.state.variableName = w),
1149
+ type: "text",
1150
+ class: "baklava-input",
1151
+ title: "Variable name",
1152
+ onBlur: y,
1153
+ onKeydown: Q(y, ["enter"])
1154
+ }, null, 544), [
1155
+ [oe, O.value.state.variableName]
1156
+ ])
1157
+ ])) : N("", !0)
1158
+ ], 6));
1470
1159
  }
1471
- });
1472
- const _sfc_main$2 = defineComponent({
1160
+ }), Ns = G({
1473
1161
  props: {
1474
1162
  type: {
1475
1163
  type: String,
1476
- required: true
1164
+ required: !0
1477
1165
  },
1478
1166
  title: {
1479
1167
  type: String,
1480
- required: true
1168
+ required: !0
1481
1169
  }
1482
1170
  },
1483
- setup(props) {
1484
- const { viewModel } = useViewModel();
1485
- const { switchGraph } = useGraph();
1486
- const showContextMenu = ref(false);
1487
- const hasContextMenu = computed(() => props.type.startsWith(GRAPH_NODE_TYPE_PREFIX));
1488
- const contextMenuItems = [
1171
+ setup(o) {
1172
+ const { viewModel: e } = H(), { switchGraph: t } = K(), s = E(!1), n = f(() => o.type.startsWith(J));
1173
+ return { showContextMenu: s, hasContextMenu: n, contextMenuItems: [
1489
1174
  { label: "Edit Subgraph", value: "editSubgraph" },
1490
1175
  { label: "Delete Subgraph", value: "deleteSubgraph" }
1491
- ];
1492
- const openContextMenu = () => {
1493
- showContextMenu.value = true;
1494
- };
1495
- const onContextMenuClick = (action) => {
1496
- const graphTemplateId = props.type.substring(GRAPH_NODE_TYPE_PREFIX.length);
1497
- const graphTemplate = viewModel.value.editor.graphTemplates.find((gt) => gt.id === graphTemplateId);
1498
- if (!graphTemplate) {
1499
- return;
1500
- }
1501
- switch (action) {
1502
- case "editSubgraph":
1503
- switchGraph(graphTemplate);
1504
- break;
1505
- case "deleteSubgraph":
1506
- viewModel.value.editor.removeGraphTemplate(graphTemplate);
1507
- break;
1508
- }
1509
- };
1510
- return { showContextMenu, hasContextMenu, contextMenuItems, openContextMenu, onContextMenuClick };
1176
+ ], openContextMenu: () => {
1177
+ s.value = !0;
1178
+ }, onContextMenuClick: (h) => {
1179
+ const O = o.type.substring(J.length), x = e.value.editor.graphTemplates.find((k) => k.id === O);
1180
+ if (x)
1181
+ switch (h) {
1182
+ case "editSubgraph":
1183
+ t(x);
1184
+ break;
1185
+ case "deleteSubgraph":
1186
+ e.value.editor.removeGraphTemplate(x);
1187
+ break;
1188
+ }
1189
+ } };
1511
1190
  }
1512
- });
1513
- const _hoisted_1$1 = ["data-node-type"];
1514
- const _hoisted_2$1 = { class: "__title" };
1515
- const _hoisted_3 = { class: "__title-label" };
1516
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1517
- return openBlock(), createElementBlock("div", {
1191
+ }), Ms = ["data-node-type"], Os = { class: "__title" }, $s = { class: "__title-label" };
1192
+ function Es(o, e, t, s, n, a) {
1193
+ return i(), r("div", {
1518
1194
  class: "baklava-node --palette",
1519
- "data-node-type": _ctx.type
1195
+ "data-node-type": o.type
1520
1196
  }, [
1521
- createElementVNode("div", _hoisted_2$1, [
1522
- createElementVNode("div", _hoisted_3, toDisplayString(_ctx.title), 1)
1197
+ l("div", Os, [
1198
+ l("div", $s, L(o.title), 1)
1523
1199
  ])
1524
- ], 8, _hoisted_1$1);
1200
+ ], 8, Ms);
1525
1201
  }
1526
- const PaletteEntry = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
1527
- const _hoisted_1 = {
1202
+ const fe = /* @__PURE__ */ z(Ns, [["render", Es]]), Ts = {
1528
1203
  class: "baklava-node --palette",
1529
1204
  style: { "margin-top": "-20px", "margin-bottom": "30px" }
1530
- };
1531
- const _hoisted_2 = { key: 0 };
1532
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1205
+ }, Ss = { key: 0 }, zs = /* @__PURE__ */ G({
1533
1206
  __name: "CodeNodePalette",
1534
- setup(__props) {
1535
- const { viewModel } = useViewModel();
1536
- const { x: mouseX, y: mouseY } = usePointer();
1537
- const { transform } = useTransform();
1538
- const categories = useNodeCategories(viewModel);
1539
- const editorEl = inject("editorEl");
1540
- const searchQuery = ref("");
1541
- const draggedNode = ref(null);
1542
- const filterCategoryBySearch = (categories2) => {
1543
- if (searchQuery.value) {
1544
- return categories2.filter(
1545
- (c) => Object.values(c.nodeTypes).some(
1546
- (nodeType2) => nodeType2.title.toLowerCase().includes(searchQuery.value?.toLowerCase())
1547
- )
1548
- );
1549
- }
1550
- return categories2;
1551
- };
1552
- const filterNodesBySearch = (nodeTypes) => {
1553
- if (searchQuery.value) {
1554
- return Object.values(nodeTypes).filter(
1555
- (nt) => nt.title.toLowerCase().includes(searchQuery.value?.toLowerCase())
1556
- );
1557
- }
1558
- return Object.values(nodeTypes);
1559
- };
1560
- const draggedNodeStyles = computed(() => {
1561
- if (!draggedNode.value || !editorEl?.value) return {};
1562
- const { left, top } = editorEl.value.getBoundingClientRect();
1207
+ setup(o) {
1208
+ const { viewModel: e } = H(), { x: t, y: s } = ht(), { transform: n } = Ye(), a = Je(e), u = at("editorEl"), d = E(""), h = E(null), O = (y) => d.value ? y.filter(
1209
+ (m) => Object.values(m.nodeTypes).some(
1210
+ (g) => g.title.toLowerCase().includes(d.value?.toLowerCase())
1211
+ )
1212
+ ) : y, x = (y) => d.value ? Object.values(y).filter(
1213
+ (m) => m.title.toLowerCase().includes(d.value?.toLowerCase())
1214
+ ) : Object.values(y), k = f(() => {
1215
+ if (!h.value || !u?.value) return {};
1216
+ const { left: y, top: m } = u.value.getBoundingClientRect();
1563
1217
  return {
1564
- top: `${mouseY.value - top}px`,
1565
- left: `${mouseX.value - left}px`
1218
+ top: `${s.value - m}px`,
1219
+ left: `${t.value - y}px`
1566
1220
  };
1567
- });
1568
- const onDragStart = (type, nodeInformation) => {
1569
- draggedNode.value = {
1570
- type,
1571
- nodeInformation
1221
+ }), B = (y, m) => {
1222
+ h.value = {
1223
+ type: y,
1224
+ nodeInformation: m
1572
1225
  };
1573
- const onDragEnd = () => {
1574
- const instance = reactive(new nodeInformation.type());
1575
- viewModel.value.displayedGraph.addNode(instance);
1576
- const rect = editorEl.value.getBoundingClientRect();
1577
- const [x, y] = transform(mouseX.value - rect.left, mouseY.value - rect.top);
1578
- instance.position.x = x;
1579
- instance.position.y = y;
1580
- draggedNode.value = null;
1581
- document.removeEventListener("pointerup", onDragEnd);
1226
+ const g = () => {
1227
+ const b = R(new m.type());
1228
+ e.value.displayedGraph.addNode(b);
1229
+ const p = u.value.getBoundingClientRect(), [w, I] = n(t.value - p.left, s.value - p.top);
1230
+ b.position.x = w, b.position.y = I, h.value = null, document.removeEventListener("pointerup", g);
1582
1231
  };
1583
- document.addEventListener("pointerup", onDragEnd);
1232
+ document.addEventListener("pointerup", g);
1584
1233
  };
1585
- return (_ctx, _cache) => {
1586
- return openBlock(), createElementBlock(Fragment, null, [
1587
- createElementVNode("div", {
1588
- class: normalizeClass(["baklava-node-palette", { "--open": unref(viewModel).settings.palette.enabled }]),
1589
- onContextmenu: _cache[1] || (_cache[1] = withModifiers(() => {
1590
- }, ["stop", "prevent"]))
1234
+ return (y, m) => (i(), r(T, null, [
1235
+ l("div", {
1236
+ class: U(["baklava-node-palette", { "--open": _(e).settings.palette.enabled }]),
1237
+ onContextmenu: m[1] || (m[1] = D(() => {
1238
+ }, ["stop", "prevent"]))
1239
+ }, [
1240
+ l("div", Ts, [
1241
+ ne(l("input", {
1242
+ "onUpdate:modelValue": m[0] || (m[0] = (g) => d.value = g),
1243
+ type: "text",
1244
+ class: "baklava-input",
1245
+ title: "Filter node types"
1246
+ }, null, 512), [
1247
+ [oe, d.value]
1248
+ ])
1249
+ ]),
1250
+ (i(!0), r(T, null, A(O(_(a)), (g) => (i(), r("section", {
1251
+ key: g.name
1591
1252
  }, [
1592
- createElementVNode("div", _hoisted_1, [
1593
- withDirectives(createElementVNode("input", {
1594
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
1595
- type: "text",
1596
- class: "baklava-input",
1597
- title: "Filter node types"
1598
- }, null, 512), [
1599
- [vModelText, searchQuery.value]
1600
- ])
1601
- ]),
1602
- (openBlock(true), createElementBlock(Fragment, null, renderList(filterCategoryBySearch(unref(categories)), (c) => {
1603
- return openBlock(), createElementBlock("section", {
1604
- key: c.name
1605
- }, [
1606
- c.name !== "default" ? (openBlock(), createElementBlock("h3", _hoisted_2, toDisplayString(c.name), 1)) : createCommentVNode("", true),
1607
- (openBlock(true), createElementBlock(Fragment, null, renderList(filterNodesBySearch(c.nodeTypes), (ni, nt) => {
1608
- return openBlock(), createBlock(PaletteEntry, {
1609
- key: nt,
1610
- type: nt,
1611
- title: ni.title,
1612
- onPointerdown: ($event) => onDragStart(nt, ni)
1613
- }, null, 8, ["type", "title", "onPointerdown"]);
1614
- }), 128))
1615
- ]);
1616
- }), 128))
1617
- ], 34),
1618
- createVNode(Transition, { name: "fade" }, {
1619
- default: withCtx(() => [
1620
- draggedNode.value ? (openBlock(), createElementBlock("div", {
1621
- key: 0,
1622
- class: "baklava-dragged-node",
1623
- style: normalizeStyle(draggedNodeStyles.value)
1624
- }, [
1625
- createVNode(PaletteEntry, {
1626
- type: draggedNode.value.type,
1627
- title: draggedNode.value.nodeInformation.title
1628
- }, null, 8, ["type", "title"])
1629
- ], 4)) : createCommentVNode("", true)
1630
- ]),
1631
- _: 1
1632
- })
1633
- ], 64);
1634
- };
1253
+ g.name !== "default" ? (i(), r("h3", Ss, L(g.name), 1)) : N("", !0),
1254
+ (i(!0), r(T, null, A(x(g.nodeTypes), (b, p) => (i(), V(fe, {
1255
+ key: p,
1256
+ type: p,
1257
+ title: b.title,
1258
+ onPointerdown: (w) => B(p, b)
1259
+ }, null, 8, ["type", "title", "onPointerdown"]))), 128))
1260
+ ]))), 128))
1261
+ ], 34),
1262
+ S(it, { name: "fade" }, {
1263
+ default: W(() => [
1264
+ h.value ? (i(), r("div", {
1265
+ key: 0,
1266
+ class: "baklava-dragged-node",
1267
+ style: se(k.value)
1268
+ }, [
1269
+ S(fe, {
1270
+ type: h.value.type,
1271
+ title: h.value.nodeInformation.title
1272
+ }, null, 8, ["type", "title"])
1273
+ ], 4)) : N("", !0)
1274
+ ]),
1275
+ _: 1
1276
+ })
1277
+ ], 64));
1635
1278
  }
1636
- });
1637
- const _sfc_main = /* @__PURE__ */ defineComponent({
1279
+ }), tn = /* @__PURE__ */ G({
1638
1280
  __name: "CodeGraphEditor",
1639
1281
  props: {
1640
1282
  viewModel: {}
1641
1283
  },
1642
- setup(__props) {
1643
- const props = __props;
1644
- const viewModel = toRef(props, "viewModel");
1645
- const onUpdate = (node) => node.events.update.emit(null);
1646
- onMounted(() => {
1647
- viewModel.value.subscribe();
1648
- viewModel.value.engine.start();
1649
- });
1650
- onUnmounted(() => {
1651
- viewModel.value.unsubscribe();
1652
- viewModel.value.engine.stop();
1653
- });
1654
- return (_ctx, _cache) => {
1655
- return openBlock(), createBlock(unref(BaklavaEditor), { "view-model": viewModel.value }, {
1656
- palette: withCtx(() => [
1657
- createVNode(_sfc_main$1)
1658
- ]),
1659
- node: withCtx((nodeProps) => [
1660
- createVNode(_sfc_main$5, mergeProps(nodeProps, {
1661
- onUpdate: ($event) => onUpdate(nodeProps.node)
1662
- }), null, 16, ["onUpdate"])
1663
- ]),
1664
- sidebar: withCtx((nodeProps) => [
1665
- createVNode(_sfc_main$3, normalizeProps(guardReactiveProps(nodeProps)), null, 16)
1666
- ]),
1667
- _: 1
1668
- }, 8, ["view-model"]);
1669
- };
1670
- }
1671
- });
1672
- const addToolbarCommands = (viewModel) => {
1673
- const TOGGLE_PALETTE_COMMAND = "TOGGLE_PALETTE";
1674
- viewModel.commandHandler.registerCommand(TOGGLE_PALETTE_COMMAND, {
1675
- execute: () => viewModel.settings.palette.enabled = !viewModel.settings.palette.enabled,
1676
- canExecute: () => true
1284
+ setup(o) {
1285
+ const t = ye(o, "viewModel"), s = (n) => n.events.update.emit(null);
1286
+ return ee(() => {
1287
+ t.value.subscribe(), t.value.engine.start();
1288
+ }), rt(() => {
1289
+ t.value.unsubscribe(), t.value.engine.stop();
1290
+ }), (n, a) => (i(), V(_(qe), { "view-model": t.value }, {
1291
+ palette: W(() => [
1292
+ S(zs)
1293
+ ]),
1294
+ node: W((u) => [
1295
+ S(gs, ut(u, {
1296
+ onUpdate: (d) => s(u.node)
1297
+ }), null, 16, ["onUpdate"])
1298
+ ]),
1299
+ sidebar: W((u) => [
1300
+ S(Is, lt(dt(u)), null, 16)
1301
+ ]),
1302
+ _: 1
1303
+ }, 8, ["view-model"]));
1304
+ }
1305
+ }), Bs = (o) => {
1306
+ const e = "TOGGLE_PALETTE";
1307
+ o.commandHandler.registerCommand(e, {
1308
+ execute: () => o.settings.palette.enabled = !o.settings.palette.enabled,
1309
+ canExecute: () => !0
1677
1310
  });
1678
- const CLEAR_ALL_COMMAND = "CLEAR_ALL";
1679
- viewModel.commandHandler.registerCommand(CLEAR_ALL_COMMAND, {
1680
- execute: () => viewModel.displayedGraph.nodes.forEach((node) => viewModel.displayedGraph.removeNode(node)),
1681
- canExecute: () => viewModel.displayedGraph.nodes.length > 0
1311
+ const t = "CLEAR_ALL";
1312
+ o.commandHandler.registerCommand(t, {
1313
+ execute: () => o.displayedGraph.nodes.forEach((n) => o.displayedGraph.removeNode(n)),
1314
+ canExecute: () => o.displayedGraph.nodes.length > 0
1682
1315
  });
1683
- const TOGGLE_MINIMAP_COMMAND = "TOGGLE_MINIMAP";
1684
- viewModel.commandHandler.registerCommand(TOGGLE_MINIMAP_COMMAND, {
1685
- execute: () => viewModel.settings.enableMinimap = !viewModel.settings.enableMinimap,
1686
- canExecute: () => viewModel.displayedGraph.nodes.length > 1
1687
- });
1688
- viewModel.settings.toolbar.commands = [
1316
+ const s = "TOGGLE_MINIMAP";
1317
+ o.commandHandler.registerCommand(s, {
1318
+ execute: () => o.settings.enableMinimap = !o.settings.enableMinimap,
1319
+ canExecute: () => o.displayedGraph.nodes.length > 1
1320
+ }), o.settings.toolbar.commands = [
1689
1321
  {
1690
- command: TOGGLE_PALETTE_COMMAND,
1322
+ command: e,
1691
1323
  title: "Toggle palette",
1692
1324
  // Tooltip text
1693
- icon: computed(() => viewModel.settings.palette.enabled ? LayoutSidebarLeftCollapse : LayoutSidebarLeftExpand)
1325
+ icon: f(() => o.settings.palette.enabled ? Ot : St)
1694
1326
  },
1695
- ...DEFAULT_TOOLBAR_COMMANDS,
1327
+ ...Qe,
1696
1328
  {
1697
- command: CLEAR_ALL_COMMAND,
1329
+ command: t,
1698
1330
  title: "Clear all",
1699
1331
  // Tooltip text
1700
- icon: TrashOff
1332
+ icon: ss
1701
1333
  },
1702
1334
  {
1703
- command: TOGGLE_MINIMAP_COMMAND,
1335
+ command: s,
1704
1336
  title: "Toggle minimap",
1705
1337
  // Tooltip text
1706
- icon: computed(() => viewModel.settings.enableMinimap ? SchemaOff : Schema)
1338
+ icon: f(() => o.settings.enableMinimap ? Zt : Yt)
1707
1339
  }
1708
1340
  ];
1709
- };
1710
- const DEFAULT_SETTINGS = {
1711
- enableMinimap: false,
1341
+ }, F = {
1342
+ enableMinimap: !1,
1712
1343
  toolbar: {
1713
- enabled: true
1344
+ enabled: !0
1714
1345
  },
1715
1346
  palette: {
1716
- enabled: true
1347
+ enabled: !0
1717
1348
  },
1718
1349
  sidebar: {
1719
- enabled: true,
1720
- resizable: true,
1350
+ enabled: !0,
1351
+ resizable: !0,
1721
1352
  width: 350
1722
1353
  },
1723
- displayValueOnHover: false
1354
+ displayValueOnHover: !1
1724
1355
  };
1725
- function useCodeGraph(props) {
1726
- const viewModel = useBaklava(props?.existingEditor);
1727
- viewModel.code = props?.code ? new props.code(viewModel) : new Code(viewModel);
1728
- addToolbarCommands(viewModel);
1729
- const settings = {};
1730
- Object.keys(DEFAULT_SETTINGS).forEach((K) => {
1731
- settings[K] = typeof DEFAULT_SETTINGS[K] === "object" ? { ...viewModel.settings[K], ...DEFAULT_SETTINGS[K] } : DEFAULT_SETTINGS[K];
1732
- });
1733
- viewModel.settings = reactive({ ...viewModel.settings, ...settings });
1734
- viewModel.settings.nodes.defaultWidth = 350;
1735
- viewModel.state = reactive({
1356
+ function sn(o) {
1357
+ const e = Ze(o?.existingEditor);
1358
+ e.code = o?.code ? new o.code(e) : new wt(e), Bs(e);
1359
+ const t = {};
1360
+ return Object.keys(F).forEach((s) => {
1361
+ t[s] = typeof F[s] == "object" ? { ...e.settings[s], ...F[s] } : F[s];
1362
+ }), e.settings = R({ ...e.settings, ...t }), e.settings.nodes.defaultWidth = 350, e.state = R({
1736
1363
  modules: {},
1737
1364
  token: null
1738
- });
1739
- viewModel.engine = new DependencyEngine(viewModel.editor);
1740
- viewModel.subscribe = () => {
1741
- if (viewModel.state.token) viewModel.unsubscribe();
1742
- const token = Symbol();
1743
- viewModel.displayedGraph.events.addNode.subscribe(token, (node) => node.code = viewModel.code);
1744
- viewModel.engine.events.beforeRun.subscribe(token, () => {
1745
- viewModel.engine.pause();
1746
- if (viewModel.code) {
1747
- viewModel.code.onCodeUpdate();
1748
- viewModel.code.sortNodes();
1749
- viewModel.code.updateOutputVariableNames();
1750
- }
1751
- viewModel.engine.resume();
1752
- });
1753
- viewModel.engine.events.afterRun.subscribe(token, (result) => {
1754
- viewModel.engine.pause();
1755
- applyResult(result, viewModel.editor);
1756
- transferCodeScript(viewModel.displayedGraph);
1757
- if (viewModel.code) {
1758
- viewModel.code.renderNodeCodes();
1759
- viewModel.code.renderCode();
1760
- }
1761
- viewModel.engine.resume();
1762
- });
1763
- viewModel.state.token = token;
1764
- };
1765
- viewModel.unsubscribe = () => {
1766
- if (!viewModel.state.token) return;
1767
- const token = viewModel.state.token;
1768
- viewModel.displayedGraph.events.addNode.unsubscribe(token);
1769
- viewModel.engine.events.beforeRun.unsubscribe(token);
1770
- viewModel.engine.events.afterRun.unsubscribe(token);
1771
- viewModel.state.token = null;
1772
- };
1773
- return viewModel;
1365
+ }), e.engine = new Ke(e.editor), e.subscribe = () => {
1366
+ e.state.token && e.unsubscribe();
1367
+ const s = Symbol();
1368
+ e.displayedGraph.events.addNode.subscribe(s, (n) => n.code = e.code), e.engine.events.beforeRun.subscribe(s, () => {
1369
+ e.engine.pause(), e.code && (e.code.onCodeUpdate(), e.code.sortNodes(), e.code.updateOutputVariableNames()), e.engine.resume();
1370
+ }), e.engine.events.afterRun.subscribe(s, (n) => {
1371
+ e.engine.pause(), et(n, e.editor), xt(e.displayedGraph), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
1372
+ }), e.state.token = s;
1373
+ }, e.unsubscribe = () => {
1374
+ if (!e.state.token) return;
1375
+ const s = e.state.token;
1376
+ e.displayedGraph.events.addNode.unsubscribe(s), e.engine.events.beforeRun.unsubscribe(s), e.engine.events.afterRun.unsubscribe(s), e.state.token = null;
1377
+ }, e;
1774
1378
  }
1775
1379
  export {
1776
- AbstractCodeNode,
1777
- ButtonInterface,
1778
- ButtonInterfaceComponent2 as ButtonInterfaceComponent,
1779
- CheckboxInterface,
1780
- CheckboxInterfaceComponent2 as CheckboxInterfaceComponent,
1781
- Code,
1782
- _sfc_main as CodeGraphEditor,
1783
- CodeInputInterface,
1784
- CodeNode,
1785
- CodeNodeInterface,
1786
- CodeOutputInterface,
1787
- DEFAULT_SETTINGS,
1788
- DynamicCodeNode,
1789
- IntegerInterface,
1790
- IntegerInterfaceComponent2 as IntegerInterfaceComponent,
1791
- NumberInterface,
1792
- NumberInterfaceComponent2 as NumberInterfaceComponent,
1793
- SelectInterface,
1794
- SelectInterfaceComponent2 as SelectInterfaceComponent,
1795
- SliderInterface,
1796
- SliderInterfaceComponent2 as SliderInterfaceComponent,
1797
- TextInputInterface,
1798
- TextInputInterfaceComponent2 as TextInputInterfaceComponent,
1799
- TextInterface,
1800
- TextareaInputInterface,
1801
- TextareaInputInterfaceComponent2 as TextareaInputInterfaceComponent,
1802
- addToolbarCommands,
1803
- defineCodeNode,
1804
- defineDynamicCodeNode,
1805
- getCodeNodes,
1806
- getPositionAtColumn,
1807
- getPositionBeforeNode,
1808
- loadNodeState,
1809
- saveNodeState,
1810
- transferCodeScript,
1811
- useCodeGraph
1380
+ vt as AbstractCodeNode,
1381
+ Ps as ButtonInterface,
1382
+ an as ButtonInterfaceComponent,
1383
+ Ds as CheckboxInterface,
1384
+ rn as CheckboxInterfaceComponent,
1385
+ wt as Code,
1386
+ tn as CodeGraphEditor,
1387
+ Hs as CodeInputInterface,
1388
+ we as CodeNode,
1389
+ M as CodeNodeInterface,
1390
+ _t as CodeOutputInterface,
1391
+ F as DEFAULT_SETTINGS,
1392
+ yt as DynamicCodeNode,
1393
+ As as IntegerInterface,
1394
+ ln as IntegerInterfaceComponent,
1395
+ Fs as NumberInterface,
1396
+ dn as NumberInterfaceComponent,
1397
+ Ws as SelectInterface,
1398
+ un as SelectInterfaceComponent,
1399
+ Xs as SliderInterface,
1400
+ cn as SliderInterfaceComponent,
1401
+ Js as TextInputInterface,
1402
+ pn as TextInputInterfaceComponent,
1403
+ Ys as TextInterface,
1404
+ qs as TextareaInputInterface,
1405
+ hn as TextareaInputInterfaceComponent,
1406
+ Bs as addToolbarCommands,
1407
+ Qs as defineCodeNode,
1408
+ Zs as defineDynamicCodeNode,
1409
+ Z as getCodeNodes,
1410
+ Ks as getPositionAtColumn,
1411
+ en as getPositionBeforeNode,
1412
+ xe as loadNodeState,
1413
+ mt as saveNodeState,
1414
+ xt as transferCodeScript,
1415
+ sn as useCodeGraph
1812
1416
  };