@babsey/code-graph 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,20 @@
1
1
  import ce from "mustache";
2
2
  import { reactive as te, defineComponent as F, createElementBlock as b, openBlock as p, toDisplayString as L, markRaw as W, computed as P, createElementVNode as m, withDirectives as ke, vModelText as xe, createStaticVNode as fe, toRef as Me, ref as H, createVNode as G, unref as O, mergeModels as Ue, useModel as xt, resolveComponent as Ze, createCommentVNode as j, onMounted as Se, onBeforeUnmount as et, watch as tt, createBlock as B, withCtx as ee, normalizeProps as It, guardReactiveProps as Nt, renderSlot as q, mergeProps as Et, onUpdated as nt, normalizeStyle as Pe, normalizeClass as ne, withModifiers as le, Fragment as U, createTextVNode as ot, withKeys as Oe, renderList as se, nextTick as Tt, resolveDynamicComponent as De, inject as Ot, Transition as $t, shallowReadonly as Mt } from "vue";
3
3
  import { v4 as re } from "uuid";
4
- import { AbstractNode as St, NodeInterface as J, getGraphNodeTypeString as st, Graph as Pt, GraphTemplate as Gt, GRAPH_NODE_TYPE_PREFIX as At, GRAPH_INPUT_NODE_TYPE as Rt, GRAPH_OUTPUT_NODE_TYPE as jt, Editor as Lt } from "@baklavajs/core";
4
+ import { AbstractNode as St, NodeInterface as J, Graph as Pt, getGraphNodeTypeString as st, GraphTemplate as Gt, GRAPH_NODE_TYPE_PREFIX as At, GRAPH_INPUT_NODE_TYPE as Rt, GRAPH_OUTPUT_NODE_TYPE as jt, Editor as Lt } from "@baklavajs/core";
5
5
  import { NodeInterfaceType as ae, BaklavaInterfaceTypes as Vt, setType as V } from "@baklavajs/interface-types";
6
- import { allowMultipleConnections as de, applyResult as rt, BaseEngine as Bt, sortTopologically as Ht } from "@baklavajs/engine";
6
+ import { allowMultipleConnections as de, BaseEngine as Bt, sortTopologically as Ht, applyResult as rt } from "@baklavajs/engine";
7
7
  import { displayInSidebar as at, CheckboxInterfaceComponent as zt, useGraph as Ge, IntegerInterfaceComponent as Ut, TextInputInterfaceComponent as it, NumberInterfaceComponent as Dt, SelectInterfaceComponent as Ft, SliderInterfaceComponent as Wt, TextareaInputInterfaceComponent as Yt, IntegerInterface as Xt, TextInputInterface as Ae, DEFAULT_TOOLBAR_COMMANDS as Kt, Commands as ue, BaklavaEditor as qt, Components as $e, useViewModel as me, useTemporaryConnection as Jt, useTransform as Qt, useNodeCategories as Zt, DEFAULT_SETTINGS as en, useCommandHandler as tn, useHistory as nn, useClipboard as on, registerDeleteNodesCommand as sn, registerSaveSubgraphCommand as rn, registerSwitchToMainGraphCommand as an, registerSidebarCommands as ln, registerZoomToFitCommands as un, setViewNodeProperties as dn } from "@baklavajs/renderer-vue";
8
8
  import cn from "toposort";
9
9
  import { SequentialHook as Fe } from "@baklavajs/events";
10
10
  import { usePointer as pn } from "@vueuse/core";
11
11
  ce.escape = (n) => n;
12
12
  class lt extends St {
13
- state;
13
+ codeTemplate;
14
14
  isCodeNode = !0;
15
+ mask = null;
15
16
  name = "";
16
- codeTemplate;
17
+ state;
17
18
  inputs = {};
18
19
  outputs = {};
19
20
  constructor() {
@@ -133,13 +134,6 @@ class lt extends St {
133
134
  }
134
135
  return !s || s.length == 0 ? [] : s.map((o) => this.graph.findNodeById(o));
135
136
  }
136
- /**
137
- * Register code
138
- * @param code
139
- */
140
- registerCode(e) {
141
- this.code = e;
142
- }
143
137
  /**
144
138
  * Render code of this node.
145
139
  */
@@ -534,179 +528,6 @@ function fr(n) {
534
528
  }
535
529
  };
536
530
  }
537
- const We = "__baklava_SubgraphInputNode", Ye = "__baklava_SubgraphOutputNode";
538
- class ht extends Re {
539
- graphInterfaceId;
540
- constructor() {
541
- super(), this.graphInterfaceId = re();
542
- }
543
- onPlaced() {
544
- super.onPlaced(), this.initializeIo();
545
- }
546
- load(e) {
547
- super.load(e), this.graphInterfaceId = e.graphInterfaceId;
548
- }
549
- save() {
550
- return {
551
- ...super.save(),
552
- graphInterfaceId: this.graphInterfaceId
553
- };
554
- }
555
- update() {
556
- }
557
- }
558
- class ft extends ht {
559
- static isGraphInputNode(e) {
560
- return e.type === We;
561
- }
562
- type = We;
563
- inputs = {
564
- name: new J("Name", "Input")
565
- };
566
- outputs = {
567
- placeholder: new J("Value", void 0)
568
- };
569
- }
570
- class mt extends ht {
571
- static isGraphOutputNode(e) {
572
- return e.type === Ye;
573
- }
574
- type = Ye;
575
- inputs = {
576
- name: new J("Name", "Output"),
577
- placeholder: new J("Value", void 0)
578
- };
579
- outputs = {
580
- output: new J("Output", void 0).setHidden(!0)
581
- };
582
- calculate = ({ placeholder: e }) => ({
583
- output: e
584
- });
585
- }
586
- const In = [
587
- "component",
588
- "connectionCount",
589
- "events",
590
- "hidden",
591
- "hooks",
592
- "id",
593
- "isCodeNode",
594
- "isInput",
595
- "name",
596
- "nodeId",
597
- "port",
598
- "templateId",
599
- "value"
600
- ];
601
- function Nn(n) {
602
- return class extends lt {
603
- type = st(n);
604
- get title() {
605
- return this._title;
606
- }
607
- set title(t) {
608
- this.template.name = t;
609
- }
610
- inputs = {};
611
- outputs = {};
612
- template = n;
613
- subgraph;
614
- update() {
615
- }
616
- onConnected() {
617
- }
618
- onUnconnected() {
619
- }
620
- calculate = async (t, s) => {
621
- if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
622
- if (!s.engine || typeof s.engine != "object")
623
- throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
624
- const o = s.engine.getInputValues(this.subgraph);
625
- for (const a of this.subgraph.inputs)
626
- o.set(a.nodeInterfaceId, t[a.id]);
627
- const r = await s.engine.runGraph(
628
- this.subgraph,
629
- o,
630
- s.globalValues
631
- );
632
- s.engine.pause(), rt(r, s.engine.editor), s.engine.resume();
633
- const i = {};
634
- for (const a of this.subgraph.outputs)
635
- i[a.id] = r.get(a.nodeId)?.get("output");
636
- return i._calculationResults = r, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
637
- };
638
- load(t) {
639
- if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
640
- if (!this.template) throw new Error("Unable to load graph node without graph template");
641
- this.subgraph.load(t.graphState), super.load(t);
642
- }
643
- save() {
644
- if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
645
- return {
646
- ...super.save(),
647
- graphState: this.subgraph.save()
648
- };
649
- }
650
- onPlaced() {
651
- this.template.events.updated.subscribe(this, () => this.initialize()), this.template.events.nameChanged.subscribe(this, (t) => {
652
- this._title = t;
653
- }), this.initialize();
654
- }
655
- onDestroy() {
656
- this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
657
- }
658
- initialize() {
659
- this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
660
- {{ /nodes }}`, this.events.update.emit(null);
661
- }
662
- /**
663
- * Render code of this node.
664
- */
665
- renderCode(t) {
666
- return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : ce.render(this.state.codeTemplate, t);
667
- }
668
- updateInterfaces() {
669
- if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
670
- for (const t of this.subgraph.inputs)
671
- t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
672
- for (const t of Object.keys(this.inputs))
673
- this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
674
- for (const t of this.subgraph.outputs)
675
- t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
676
- for (const t of Object.keys(this.outputs))
677
- this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
678
- this.addInput(
679
- "_code",
680
- new D("", []).use(V, X).use(de).setHidden(!0)
681
- ), this.addOutput(
682
- "_code",
683
- new D("", []).use(V, X).use(de).setHidden(!0)
684
- ), this.addOutput("_calculationResults", new J("_calculationResults", void 0).setHidden(!0));
685
- }
686
- /**
687
- * When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
688
- * For example, the `type` property or the `allowMultipleConnections` property.
689
- * These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
690
- */
691
- createProxyInterface(t, s) {
692
- const o = new D(t.name, void 0);
693
- return new Proxy(o, {
694
- get: (r, i) => {
695
- if (In.includes(i) || i in r || typeof i == "string" && i.startsWith("__v_"))
696
- return Reflect.get(r, i);
697
- let a;
698
- s ? a = this.subgraph?.nodes.find(
699
- (C) => ft.isGraphInputNode(C) && C.graphInterfaceId === t.id
700
- )?.outputs.placeholder.id : a = this.subgraph?.nodes.find(
701
- (C) => mt.isGraphOutputNode(C) && C.graphInterfaceId === t.id
702
- )?.inputs.placeholder.id;
703
- const l = this.subgraph?.connections.find((f) => a === (s ? f.from : f.to)?.id), d = s ? l?.to : l?.from;
704
- if (d) return Reflect.get(d, i);
705
- }
706
- });
707
- }
708
- };
709
- }
710
531
  ce.escape = (n) => n;
711
532
  class ze {
712
533
  _id;
@@ -780,20 +601,20 @@ class ze {
780
601
  this.state.script = ce.render(this.state.template || "", e);
781
602
  }
782
603
  }
783
- class vr extends ze {
604
+ class mr extends ze {
784
605
  constructor() {
785
606
  super(), this.loadTemplate(import("./python-CKuCd7tg.js"));
786
607
  }
787
608
  }
788
- class gr extends ze {
609
+ class vr extends ze {
789
610
  constructor() {
790
611
  super(), this.loadTemplate(import("./javascript-DK1c6Ap1.js"));
791
612
  }
792
613
  }
793
- const br = (n) => {
614
+ const gr = (n) => {
794
615
  n.allowMultipleConnections = !0;
795
616
  };
796
- class En extends Bt {
617
+ class In extends Bt {
797
618
  order = /* @__PURE__ */ new Map();
798
619
  constructor(e) {
799
620
  super(e);
@@ -859,7 +680,7 @@ This is likely an internal issue. Please report it on GitHub.`
859
680
  return e.get(t);
860
681
  }
861
682
  }
862
- const Tn = {}, On = {
683
+ const Nn = {}, En = {
863
684
  xmlns: "http://www.w3.org/2000/svg",
864
685
  width: "24",
865
686
  height: "24",
@@ -871,8 +692,8 @@ const Tn = {}, On = {
871
692
  "stroke-linejoin": "round",
872
693
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"
873
694
  };
874
- function $n(n, e) {
875
- return p(), b("svg", On, [...e[0] || (e[0] = [
695
+ function Tn(n, e) {
696
+ return p(), b("svg", En, [...e[0] || (e[0] = [
876
697
  m("path", {
877
698
  stroke: "none",
878
699
  d: "M0 0h24v24H0z",
@@ -881,7 +702,7 @@ function $n(n, e) {
881
702
  m("path", { d: "M5 12l5 5l10 -10" }, null, -1)
882
703
  ])]);
883
704
  }
884
- const Mn = /* @__PURE__ */ A(Tn, [["render", $n]]), Sn = {}, Pn = {
705
+ const On = /* @__PURE__ */ A(Nn, [["render", Tn]]), $n = {}, Mn = {
885
706
  xmlns: "http://www.w3.org/2000/svg",
886
707
  width: "24",
887
708
  height: "24",
@@ -893,8 +714,8 @@ const Mn = /* @__PURE__ */ A(Tn, [["render", $n]]), Sn = {}, Pn = {
893
714
  "stroke-linejoin": "round",
894
715
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
895
716
  };
896
- function Gn(n, e) {
897
- return p(), b("svg", Pn, [...e[0] || (e[0] = [
717
+ function Sn(n, e) {
718
+ return p(), b("svg", Mn, [...e[0] || (e[0] = [
898
719
  m("path", {
899
720
  stroke: "none",
900
721
  d: "M0 0h24v24H0z",
@@ -903,7 +724,7 @@ function Gn(n, e) {
903
724
  m("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
904
725
  ])]);
905
726
  }
906
- const An = /* @__PURE__ */ A(Sn, [["render", Gn]]), Rn = {}, jn = {
727
+ const Pn = /* @__PURE__ */ A($n, [["render", Sn]]), Gn = {}, An = {
907
728
  xmlns: "http://www.w3.org/2000/svg",
908
729
  width: "24",
909
730
  height: "24",
@@ -915,8 +736,8 @@ const An = /* @__PURE__ */ A(Sn, [["render", Gn]]), Rn = {}, jn = {
915
736
  "stroke-linejoin": "round",
916
737
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"
917
738
  };
918
- function Ln(n, e) {
919
- return p(), b("svg", jn, [...e[0] || (e[0] = [
739
+ function Rn(n, e) {
740
+ return p(), b("svg", An, [...e[0] || (e[0] = [
920
741
  m("path", {
921
742
  stroke: "none",
922
743
  d: "M0 0h24v24H0z",
@@ -926,7 +747,7 @@ function Ln(n, e) {
926
747
  m("path", { d: "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" }, null, -1)
927
748
  ])]);
928
749
  }
929
- const Vn = /* @__PURE__ */ A(Rn, [["render", Ln]]), Bn = {}, Hn = {
750
+ const jn = /* @__PURE__ */ A(Gn, [["render", Rn]]), Ln = {}, Vn = {
930
751
  xmlns: "http://www.w3.org/2000/svg",
931
752
  width: "24",
932
753
  height: "24",
@@ -938,8 +759,8 @@ const Vn = /* @__PURE__ */ A(Rn, [["render", Ln]]), Bn = {}, Hn = {
938
759
  "stroke-linejoin": "round",
939
760
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
940
761
  };
941
- function zn(n, e) {
942
- return p(), b("svg", Hn, [...e[0] || (e[0] = [
762
+ function Bn(n, e) {
763
+ return p(), b("svg", Vn, [...e[0] || (e[0] = [
943
764
  m("path", {
944
765
  stroke: "none",
945
766
  d: "M0 0h24v24H0z",
@@ -950,7 +771,7 @@ function zn(n, e) {
950
771
  m("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
951
772
  ])]);
952
773
  }
953
- const Un = /* @__PURE__ */ A(Bn, [["render", zn]]), Dn = {}, Fn = {
774
+ const Hn = /* @__PURE__ */ A(Ln, [["render", Bn]]), zn = {}, Un = {
954
775
  xmlns: "http://www.w3.org/2000/svg",
955
776
  width: "24",
956
777
  height: "24",
@@ -958,8 +779,8 @@ const Un = /* @__PURE__ */ A(Bn, [["render", zn]]), Dn = {}, Fn = {
958
779
  fill: "currentColor",
959
780
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
960
781
  };
961
- function Wn(n, e) {
962
- return p(), b("svg", Fn, [...e[0] || (e[0] = [
782
+ function Dn(n, e) {
783
+ return p(), b("svg", Un, [...e[0] || (e[0] = [
963
784
  m("path", {
964
785
  stroke: "none",
965
786
  d: "M0 0h24v24H0z",
@@ -968,7 +789,7 @@ function Wn(n, e) {
968
789
  m("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)
969
790
  ])]);
970
791
  }
971
- const Yn = /* @__PURE__ */ A(Dn, [["render", Wn]]), Xn = {}, Kn = {
792
+ const Fn = /* @__PURE__ */ A(zn, [["render", Dn]]), Wn = {}, Yn = {
972
793
  xmlns: "http://www.w3.org/2000/svg",
973
794
  width: "24",
974
795
  height: "24",
@@ -976,8 +797,8 @@ const Yn = /* @__PURE__ */ A(Dn, [["render", Wn]]), Xn = {}, Kn = {
976
797
  fill: "currentColor",
977
798
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
978
799
  };
979
- function qn(n, e) {
980
- return p(), b("svg", Kn, [...e[0] || (e[0] = [
800
+ function Xn(n, e) {
801
+ return p(), b("svg", Yn, [...e[0] || (e[0] = [
981
802
  m("path", {
982
803
  stroke: "none",
983
804
  d: "M0 0h24v24H0z",
@@ -986,7 +807,7 @@ function qn(n, e) {
986
807
  m("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)
987
808
  ])]);
988
809
  }
989
- const Jn = /* @__PURE__ */ A(Xn, [["render", qn]]), Qn = {}, Zn = {
810
+ const Kn = /* @__PURE__ */ A(Wn, [["render", Xn]]), qn = {}, Jn = {
990
811
  xmlns: "http://www.w3.org/2000/svg",
991
812
  width: "24",
992
813
  height: "24",
@@ -994,8 +815,8 @@ const Jn = /* @__PURE__ */ A(Xn, [["render", qn]]), Qn = {}, Zn = {
994
815
  fill: "currentColor",
995
816
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
996
817
  };
997
- function eo(n, e) {
998
- return p(), b("svg", Zn, [...e[0] || (e[0] = [
818
+ function Qn(n, e) {
819
+ return p(), b("svg", Jn, [...e[0] || (e[0] = [
999
820
  m("path", {
1000
821
  stroke: "none",
1001
822
  d: "M0 0h24v24H0z",
@@ -1004,7 +825,7 @@ function eo(n, e) {
1004
825
  m("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)
1005
826
  ])]);
1006
827
  }
1007
- const to = /* @__PURE__ */ A(Qn, [["render", eo]]), no = {}, oo = {
828
+ const Zn = /* @__PURE__ */ A(qn, [["render", Qn]]), eo = {}, to = {
1008
829
  xmlns: "http://www.w3.org/2000/svg",
1009
830
  width: "24",
1010
831
  height: "24",
@@ -1012,8 +833,8 @@ const to = /* @__PURE__ */ A(Qn, [["render", eo]]), no = {}, oo = {
1012
833
  fill: "currentColor",
1013
834
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
1014
835
  };
1015
- function so(n, e) {
1016
- return p(), b("svg", oo, [...e[0] || (e[0] = [
836
+ function no(n, e) {
837
+ return p(), b("svg", to, [...e[0] || (e[0] = [
1017
838
  m("path", {
1018
839
  stroke: "none",
1019
840
  d: "M0 0h24v24H0z",
@@ -1022,7 +843,7 @@ function so(n, e) {
1022
843
  m("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)
1023
844
  ])]);
1024
845
  }
1025
- const ro = /* @__PURE__ */ A(no, [["render", so]]), ao = {}, io = {
846
+ const oo = /* @__PURE__ */ A(eo, [["render", no]]), so = {}, ro = {
1026
847
  xmlns: "http://www.w3.org/2000/svg",
1027
848
  width: "24",
1028
849
  height: "24",
@@ -1030,8 +851,8 @@ const ro = /* @__PURE__ */ A(no, [["render", so]]), ao = {}, io = {
1030
851
  fill: "currentColor",
1031
852
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
1032
853
  };
1033
- function lo(n, e) {
1034
- return p(), b("svg", io, [...e[0] || (e[0] = [
854
+ function ao(n, e) {
855
+ return p(), b("svg", ro, [...e[0] || (e[0] = [
1035
856
  m("path", {
1036
857
  stroke: "none",
1037
858
  d: "M0 0h24v24H0z",
@@ -1040,7 +861,7 @@ function lo(n, e) {
1040
861
  m("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)
1041
862
  ])]);
1042
863
  }
1043
- const uo = /* @__PURE__ */ A(ao, [["render", lo]]), co = {}, po = {
864
+ const io = /* @__PURE__ */ A(so, [["render", ao]]), lo = {}, uo = {
1044
865
  xmlns: "http://www.w3.org/2000/svg",
1045
866
  width: "24",
1046
867
  height: "24",
@@ -1052,12 +873,12 @@ const uo = /* @__PURE__ */ A(ao, [["render", lo]]), co = {}, po = {
1052
873
  "stroke-linejoin": "round",
1053
874
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"
1054
875
  };
1055
- function ho(n, e) {
1056
- return p(), b("svg", po, [...e[0] || (e[0] = [
876
+ function co(n, e) {
877
+ return p(), b("svg", uo, [...e[0] || (e[0] = [
1057
878
  fe('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>', 6)
1058
879
  ])]);
1059
880
  }
1060
- const vt = /* @__PURE__ */ A(co, [["render", ho]]), fo = {}, mo = {
881
+ const ht = /* @__PURE__ */ A(lo, [["render", co]]), po = {}, ho = {
1061
882
  xmlns: "http://www.w3.org/2000/svg",
1062
883
  width: "24",
1063
884
  height: "24",
@@ -1069,8 +890,8 @@ const vt = /* @__PURE__ */ A(co, [["render", ho]]), fo = {}, mo = {
1069
890
  "stroke-linejoin": "round",
1070
891
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"
1071
892
  };
1072
- function vo(n, e) {
1073
- return p(), b("svg", mo, [...e[0] || (e[0] = [
893
+ function fo(n, e) {
894
+ return p(), b("svg", ho, [...e[0] || (e[0] = [
1074
895
  m("path", {
1075
896
  stroke: "none",
1076
897
  d: "M0 0h24v24H0z",
@@ -1079,7 +900,7 @@ function vo(n, e) {
1079
900
  m("path", { d: "M7 4v16l13 -8z" }, null, -1)
1080
901
  ])]);
1081
902
  }
1082
- const go = /* @__PURE__ */ A(fo, [["render", vo]]), bo = {}, yo = {
903
+ const mo = /* @__PURE__ */ A(po, [["render", fo]]), vo = {}, go = {
1083
904
  xmlns: "http://www.w3.org/2000/svg",
1084
905
  width: "24",
1085
906
  height: "24",
@@ -1091,8 +912,8 @@ const go = /* @__PURE__ */ A(fo, [["render", vo]]), bo = {}, yo = {
1091
912
  "stroke-linejoin": "round",
1092
913
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"
1093
914
  };
1094
- function _o(n, e) {
1095
- return p(), b("svg", yo, [...e[0] || (e[0] = [
915
+ function bo(n, e) {
916
+ return p(), b("svg", go, [...e[0] || (e[0] = [
1096
917
  m("path", {
1097
918
  stroke: "none",
1098
919
  d: "M0 0h24v24H0z",
@@ -1102,7 +923,7 @@ function _o(n, e) {
1102
923
  m("path", { d: "M5 12l14 0" }, null, -1)
1103
924
  ])]);
1104
925
  }
1105
- const Co = /* @__PURE__ */ A(bo, [["render", _o]]), wo = {}, ko = {
926
+ const yo = /* @__PURE__ */ A(vo, [["render", bo]]), _o = {}, Co = {
1106
927
  xmlns: "http://www.w3.org/2000/svg",
1107
928
  width: "24",
1108
929
  height: "24",
@@ -1114,12 +935,12 @@ const Co = /* @__PURE__ */ A(bo, [["render", _o]]), wo = {}, ko = {
1114
935
  "stroke-linejoin": "round",
1115
936
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
1116
937
  };
1117
- function xo(n, e) {
1118
- return p(), b("svg", ko, [...e[0] || (e[0] = [
938
+ function wo(n, e) {
939
+ return p(), b("svg", Co, [...e[0] || (e[0] = [
1119
940
  fe('<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)
1120
941
  ])]);
1121
942
  }
1122
- const Io = /* @__PURE__ */ A(wo, [["render", xo]]), No = {}, Eo = {
943
+ const ko = /* @__PURE__ */ A(_o, [["render", wo]]), xo = {}, Io = {
1123
944
  xmlns: "http://www.w3.org/2000/svg",
1124
945
  width: "24",
1125
946
  height: "24",
@@ -1131,12 +952,12 @@ const Io = /* @__PURE__ */ A(wo, [["render", xo]]), No = {}, Eo = {
1131
952
  "stroke-linejoin": "round",
1132
953
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
1133
954
  };
1134
- function To(n, e) {
1135
- return p(), b("svg", Eo, [...e[0] || (e[0] = [
955
+ function No(n, e) {
956
+ return p(), b("svg", Io, [...e[0] || (e[0] = [
1136
957
  fe('<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)
1137
958
  ])]);
1138
959
  }
1139
- const Oo = /* @__PURE__ */ A(No, [["render", To]]), $o = {}, Mo = {
960
+ const Eo = /* @__PURE__ */ A(xo, [["render", No]]), To = {}, Oo = {
1140
961
  xmlns: "http://www.w3.org/2000/svg",
1141
962
  width: "24",
1142
963
  height: "24",
@@ -1148,12 +969,12 @@ const Oo = /* @__PURE__ */ A(No, [["render", To]]), $o = {}, Mo = {
1148
969
  "stroke-linejoin": "round",
1149
970
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
1150
971
  };
1151
- function So(n, e) {
1152
- return p(), b("svg", Mo, [...e[0] || (e[0] = [
972
+ function $o(n, e) {
973
+ return p(), b("svg", Oo, [...e[0] || (e[0] = [
1153
974
  fe('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
1154
975
  ])]);
1155
976
  }
1156
- const Po = /* @__PURE__ */ A($o, [["render", So]]), Go = {}, Ao = {
977
+ const Mo = /* @__PURE__ */ A(To, [["render", $o]]), So = {}, Po = {
1157
978
  xmlns: "http://www.w3.org/2000/svg",
1158
979
  width: "24",
1159
980
  height: "24",
@@ -1165,12 +986,12 @@ const Po = /* @__PURE__ */ A($o, [["render", So]]), Go = {}, Ao = {
1165
986
  "stroke-linejoin": "round",
1166
987
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
1167
988
  };
1168
- function Ro(n, e) {
1169
- return p(), b("svg", Ao, [...e[0] || (e[0] = [
989
+ function Go(n, e) {
990
+ return p(), b("svg", Po, [...e[0] || (e[0] = [
1170
991
  fe('<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)
1171
992
  ])]);
1172
993
  }
1173
- const jo = /* @__PURE__ */ A(Go, [["render", Ro]]), Lo = {}, Vo = {
994
+ const Ao = /* @__PURE__ */ A(So, [["render", Go]]), Ro = {}, jo = {
1174
995
  xmlns: "http://www.w3.org/2000/svg",
1175
996
  width: "24",
1176
997
  height: "24",
@@ -1182,8 +1003,8 @@ const jo = /* @__PURE__ */ A(Go, [["render", Ro]]), Lo = {}, Vo = {
1182
1003
  "stroke-linejoin": "round",
1183
1004
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"
1184
1005
  };
1185
- function Bo(n, e) {
1186
- return p(), b("svg", Vo, [...e[0] || (e[0] = [
1006
+ function Lo(n, e) {
1007
+ return p(), b("svg", jo, [...e[0] || (e[0] = [
1187
1008
  m("path", {
1188
1009
  stroke: "none",
1189
1010
  d: "M0 0h24v24H0z",
@@ -1193,52 +1014,52 @@ function Bo(n, e) {
1193
1014
  m("path", { d: "M6 6l12 12" }, null, -1)
1194
1015
  ])]);
1195
1016
  }
1196
- const Ho = /* @__PURE__ */ A(Lo, [["render", Bo]]), gt = "CLEAR_ALL", bt = "RUN_ENGINE", yt = "TOGGLE_MINIMAP", _t = "TOGGLE_PALETTE", zo = (n, e, t) => {
1017
+ const Vo = /* @__PURE__ */ A(Ro, [["render", Lo]]), ft = "CLEAR_ALL", mt = "RUN_ENGINE", vt = "TOGGLE_MINIMAP", gt = "TOGGLE_PALETTE", Bo = (n, e, t) => {
1197
1018
  const s = t.zoomToFit.paddingLeft;
1198
- e.registerCommand(_t, {
1019
+ e.registerCommand(gt, {
1199
1020
  execute: () => {
1200
1021
  t.palette.enabled = !t.palette.enabled, t.zoomToFit.paddingLeft = t.palette.enabled ? s : 50;
1201
1022
  },
1202
1023
  canExecute: () => !0
1203
- }), e.registerCommand(gt, {
1024
+ }), e.registerCommand(ft, {
1204
1025
  execute: () => n.value.clear(),
1205
1026
  canExecute: () => n.value.nodes.length > 0
1206
- }), e.registerCommand(yt, {
1027
+ }), e.registerCommand(vt, {
1207
1028
  execute: () => t.enableMinimap = !t.enableMinimap,
1208
1029
  canExecute: () => n.value.nodes.length > 1
1209
1030
  });
1210
- }, Uo = (n) => {
1031
+ }, Ho = (n) => {
1211
1032
  const e = {
1212
- command: bt,
1033
+ command: mt,
1213
1034
  title: "Run",
1214
1035
  // Tooltip text
1215
- icon: P(() => go)
1036
+ icon: P(() => mo)
1216
1037
  }, t = {
1217
- command: _t,
1038
+ command: gt,
1218
1039
  title: "Toggle palette",
1219
1040
  // Tooltip text
1220
- icon: P(() => n.palette.enabled ? Yn : Jn)
1041
+ icon: P(() => n.palette.enabled ? Fn : Kn)
1221
1042
  }, s = {
1222
- command: gt,
1043
+ command: ft,
1223
1044
  title: "Clear all",
1224
1045
  // Tooltip text
1225
- icon: P(() => jo)
1046
+ icon: P(() => Ao)
1226
1047
  }, o = {
1227
- command: yt,
1048
+ command: vt,
1228
1049
  title: "Toggle minimap",
1229
1050
  // Tooltip text
1230
- icon: P(() => n.enableMinimap ? Oo : Io)
1051
+ icon: P(() => n.enableMinimap ? Eo : ko)
1231
1052
  };
1232
1053
  n.toolbar.commands = [t, e, ...Kt, s, o];
1233
- }, Do = (n, e) => {
1234
- e.registerCommand(bt, {
1054
+ }, zo = (n, e) => {
1055
+ e.registerCommand(mt, {
1235
1056
  execute: () => n.runOnce(null),
1236
1057
  canExecute: () => !0
1237
1058
  });
1238
1059
  };
1239
- function Fo(n) {
1060
+ function Uo(n) {
1240
1061
  const e = Symbol("CodeEngineToken");
1241
- n.engine = new En(n.editor), Do(n.engine, n.commandHandler), n.loadEditor = (t) => {
1062
+ n.engine = new In(n.editor), zo(n.engine, n.commandHandler), n.loadEditor = (t) => {
1242
1063
  n.engine?.pause(), n.displayedGraph.clear(), n.editor.load(t), n.commandHandler.executeCommand(ue.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(ue.CLEAR_HISTORY_COMMAND), n.engine?.resume(), n.engine?.runOnce(null);
1243
1064
  }, n.newGraph = () => {
1244
1065
  n.engine?.pause(), n.displayedGraph.clear(), n.commandHandler.executeCommand(ue.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(ue.CLEAR_HISTORY_COMMAND), n.displayedGraph.id = re(), n.engine?.resume(), n.engine?.runOnce(null);
@@ -1276,7 +1097,7 @@ class Ie extends Pt {
1276
1097
  super(e, t), this.editor = e, this.template = t, e.code && (this.code = e.code);
1277
1098
  }
1278
1099
  get codeNodes() {
1279
- return Ct(this);
1100
+ return bt(this);
1280
1101
  }
1281
1102
  get connections() {
1282
1103
  return super.connections;
@@ -1305,15 +1126,14 @@ class Ie extends Pt {
1305
1126
  get visibleNodes() {
1306
1127
  return this.nodes.filter((e) => !e.state?.hidden);
1307
1128
  }
1308
- // /**
1309
- // * Add code node to graph.
1310
- // * @param node code node
1311
- // * @param props optional
1312
- // */
1313
- // public override addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined {
1314
- // if (node.state && props) node.state.props = props;
1315
- // return super.addNode(node as AbstractNode) as AbstractCodeNode;
1316
- // }
1129
+ /**
1130
+ * Add code node to graph.
1131
+ * @param node code node
1132
+ * @param props optional
1133
+ */
1134
+ addNode(e, t) {
1135
+ return e.state && t && (e.state.props = t), super.addNode(e);
1136
+ }
1317
1137
  /**
1318
1138
  * Add code node at coordinates.
1319
1139
  * @param node code node
@@ -1399,18 +1219,190 @@ class Ie extends Pt {
1399
1219
  }
1400
1220
  }
1401
1221
  }
1402
- const Ct = (n) => {
1222
+ const bt = (n) => {
1403
1223
  const e = [];
1404
1224
  return n.nodes.length === 0 || n.nodes.forEach((t) => {
1405
- t && (t.hasOwnProperty("subgraph") ? e.push(...Ct(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
1225
+ t && (t.hasOwnProperty("subgraph") ? e.push(...bt(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
1406
1226
  }), e;
1407
- }, yr = (n = 0, e = 100) => ({
1227
+ }, br = (n = 0, e = 100) => ({
1408
1228
  x: n * 420,
1409
1229
  y: e
1410
- }), _r = (n) => {
1230
+ }), yr = (n) => {
1411
1231
  const e = { ...n.position };
1412
1232
  return e.x -= 440, e.y += 50, e;
1413
- };
1233
+ }, We = "__baklava_SubgraphInputNode", Ye = "__baklava_SubgraphOutputNode";
1234
+ class yt extends Re {
1235
+ graphInterfaceId;
1236
+ constructor() {
1237
+ super(), this.graphInterfaceId = re();
1238
+ }
1239
+ onPlaced() {
1240
+ super.onPlaced(), this.initializeIo();
1241
+ }
1242
+ load(e) {
1243
+ super.load(e), this.graphInterfaceId = e.graphInterfaceId;
1244
+ }
1245
+ save() {
1246
+ return {
1247
+ ...super.save(),
1248
+ graphInterfaceId: this.graphInterfaceId
1249
+ };
1250
+ }
1251
+ update() {
1252
+ }
1253
+ }
1254
+ class _t extends yt {
1255
+ static isGraphInputNode(e) {
1256
+ return e.type === We;
1257
+ }
1258
+ type = We;
1259
+ inputs = {
1260
+ name: new J("Name", "Input")
1261
+ };
1262
+ outputs = {
1263
+ placeholder: new J("Value", void 0)
1264
+ };
1265
+ }
1266
+ class Ct extends yt {
1267
+ static isGraphOutputNode(e) {
1268
+ return e.type === Ye;
1269
+ }
1270
+ type = Ye;
1271
+ inputs = {
1272
+ name: new J("Name", "Output"),
1273
+ placeholder: new J("Value", void 0)
1274
+ };
1275
+ outputs = {
1276
+ output: new J("Output", void 0).setHidden(!0)
1277
+ };
1278
+ calculate = ({ placeholder: e }) => ({
1279
+ output: e
1280
+ });
1281
+ }
1282
+ const Do = [
1283
+ "component",
1284
+ "connectionCount",
1285
+ "events",
1286
+ "hidden",
1287
+ "hooks",
1288
+ "id",
1289
+ "isCodeNode",
1290
+ "isInput",
1291
+ "name",
1292
+ "nodeId",
1293
+ "port",
1294
+ "templateId",
1295
+ "value"
1296
+ ];
1297
+ function Fo(n) {
1298
+ return class extends lt {
1299
+ type = st(n);
1300
+ get title() {
1301
+ return this._title;
1302
+ }
1303
+ set title(t) {
1304
+ this.template.name = t;
1305
+ }
1306
+ inputs = {};
1307
+ outputs = {};
1308
+ template = n;
1309
+ subgraph;
1310
+ update() {
1311
+ }
1312
+ onConnected() {
1313
+ }
1314
+ onUnconnected() {
1315
+ }
1316
+ calculate = async (t, s) => {
1317
+ if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
1318
+ if (!s.engine || typeof s.engine != "object")
1319
+ throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
1320
+ const o = s.engine.getInputValues(this.subgraph);
1321
+ for (const a of this.subgraph.inputs)
1322
+ o.set(a.nodeInterfaceId, t[a.id]);
1323
+ const r = await s.engine.runGraph(
1324
+ this.subgraph,
1325
+ o,
1326
+ s.globalValues
1327
+ );
1328
+ s.engine.pause(), rt(r, s.engine.editor), s.engine.resume();
1329
+ const i = {};
1330
+ for (const a of this.subgraph.outputs)
1331
+ i[a.id] = r.get(a.nodeId)?.get("output");
1332
+ return i._calculationResults = r, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
1333
+ };
1334
+ load(t) {
1335
+ if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
1336
+ if (!this.template) throw new Error("Unable to load graph node without graph template");
1337
+ this.subgraph.load(t.graphState), super.load(t);
1338
+ }
1339
+ save() {
1340
+ if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
1341
+ return {
1342
+ ...super.save(),
1343
+ graphState: this.subgraph.save()
1344
+ };
1345
+ }
1346
+ onPlaced() {
1347
+ this.template.events.updated.subscribe(this, () => this.initialize()), this.template.events.nameChanged.subscribe(this, (t) => {
1348
+ this._title = t;
1349
+ }), this.initialize();
1350
+ }
1351
+ onDestroy() {
1352
+ this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
1353
+ }
1354
+ initialize() {
1355
+ this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
1356
+ {{ /nodes }}`, this.events.update.emit(null);
1357
+ }
1358
+ /**
1359
+ * Render code of this node.
1360
+ */
1361
+ renderCode(t) {
1362
+ return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : ce.render(this.state.codeTemplate, t);
1363
+ }
1364
+ updateInterfaces() {
1365
+ if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
1366
+ for (const t of this.subgraph.inputs)
1367
+ t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
1368
+ for (const t of Object.keys(this.inputs))
1369
+ this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
1370
+ for (const t of this.subgraph.outputs)
1371
+ t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
1372
+ for (const t of Object.keys(this.outputs))
1373
+ this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
1374
+ this.addInput(
1375
+ "_code",
1376
+ new D("", []).use(V, X).use(de).setHidden(!0)
1377
+ ), this.addOutput(
1378
+ "_code",
1379
+ new D("", []).use(V, X).use(de).setHidden(!0)
1380
+ ), this.addOutput("_calculationResults", new J("_calculationResults", void 0).setHidden(!0));
1381
+ }
1382
+ /**
1383
+ * When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
1384
+ * For example, the `type` property or the `allowMultipleConnections` property.
1385
+ * These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
1386
+ */
1387
+ createProxyInterface(t, s) {
1388
+ const o = new D(t.name, void 0);
1389
+ return new Proxy(o, {
1390
+ get: (r, i) => {
1391
+ if (Do.includes(i) || i in r || typeof i == "string" && i.startsWith("__v_"))
1392
+ return Reflect.get(r, i);
1393
+ let a;
1394
+ s ? a = this.subgraph?.nodes.find(
1395
+ (C) => _t.isGraphInputNode(C) && C.graphInterfaceId === t.id
1396
+ )?.outputs.placeholder.id : a = this.subgraph?.nodes.find(
1397
+ (C) => Ct.isGraphOutputNode(C) && C.graphInterfaceId === t.id
1398
+ )?.inputs.placeholder.id;
1399
+ const l = this.subgraph?.connections.find((f) => a === (s ? f.from : f.to)?.id), d = s ? l?.to : l?.from;
1400
+ if (d) return Reflect.get(d, i);
1401
+ }
1402
+ });
1403
+ }
1404
+ };
1405
+ }
1414
1406
  function Wo(n, e) {
1415
1407
  return Object.fromEntries(Object.entries(n).filter(e));
1416
1408
  }
@@ -2011,13 +2003,13 @@ const es = /* @__PURE__ */ qo(Zo), ts = (n) => ({
2011
2003
  };
2012
2004
  return (i, a) => (p(), b("div", null, [
2013
2005
  o.value ? (p(), b("button", ns, [
2014
- G(O(Mn))
2006
+ G(O(On))
2015
2007
  ])) : (p(), b("button", {
2016
2008
  key: 1,
2017
2009
  onClick: r,
2018
2010
  class: "baklava-button"
2019
2011
  }, [
2020
- G(O(Vn))
2012
+ G(O(jn))
2021
2013
  ]))
2022
2014
  ]));
2023
2015
  }
@@ -2043,7 +2035,7 @@ const es = /* @__PURE__ */ qo(Zo), ts = (n) => ({
2043
2035
  title: "The code is locked.",
2044
2036
  onClick: i[0] || (i[0] = (l) => o(!1))
2045
2037
  }, [
2046
- G(O(vt))
2038
+ G(O(ht))
2047
2039
  ])) : j("", !0),
2048
2040
  G(os, { text: n.modelValue }, null, 8, ["text"])
2049
2041
  ]),
@@ -2237,35 +2229,35 @@ const es = /* @__PURE__ */ qo(Zo), ts = (n) => ({
2237
2229
  ]),
2238
2230
  m("div", ds, [
2239
2231
  r.value.isCodeNode ? (p(), b(U, { key: 0 }, [
2240
- r.value.state.lockCode ? (p(), B(O(vt), {
2232
+ r.value.state.lockCode ? (p(), B(O(ht), {
2241
2233
  key: 0,
2242
2234
  class: "--clickable mx-1",
2243
2235
  onClick: g[0] || (g[0] = (c) => r.value.lockCode = !1)
2244
2236
  })) : j("", !0),
2245
- r.value.state.integrated ? (p(), B(O(An), {
2237
+ r.value.state.integrated ? (p(), B(O(Pn), {
2246
2238
  key: 1,
2247
2239
  class: "--clickable mx-1",
2248
2240
  onClick: g[1] || (g[1] = (c) => oe(!1))
2249
- })) : (p(), B(O(Po), {
2241
+ })) : (p(), B(O(Mo), {
2250
2242
  key: 2,
2251
2243
  class: "--clickable mx-1",
2252
2244
  onClick: g[2] || (g[2] = (c) => oe(!0))
2253
2245
  })),
2254
- !O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(uo), {
2246
+ !O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(io), {
2255
2247
  key: 3,
2256
2248
  class: "--clickable mx-1",
2257
2249
  onClick: ge
2258
- })) : O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(to), {
2250
+ })) : O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(Zn), {
2259
2251
  key: 4,
2260
2252
  class: "--clickable mx-1",
2261
2253
  onClick: he
2262
- })) : (p(), B(O(ro), {
2254
+ })) : (p(), B(O(oo), {
2263
2255
  key: 5,
2264
2256
  class: "--clickable mx-1",
2265
2257
  onClick: z
2266
2258
  }))
2267
2259
  ], 64)) : j("", !0),
2268
- G(O(Un), {
2260
+ G(O(Hn), {
2269
2261
  class: "--clickable mx-1",
2270
2262
  onClick: R
2271
2263
  }),
@@ -2675,7 +2667,7 @@ const Je = /* @__PURE__ */ A(Rs, [["render", Vs]]), Bs = { class: "navbar" }, Hs
2675
2667
  class: "remove",
2676
2668
  onClick: le((a) => s(i.graph.id), ["prevent"])
2677
2669
  }, [
2678
- G(O(Ho))
2670
+ G(O(Vo))
2679
2671
  ], 8, Hs)
2680
2672
  ]),
2681
2673
  default: ee(() => [
@@ -2689,7 +2681,7 @@ const Je = /* @__PURE__ */ A(Rs, [["render", Vs]]), Bs = { class: "navbar" }, Hs
2689
2681
  class: "navItem"
2690
2682
  }, {
2691
2683
  default: ee(() => [
2692
- G(O(Co), { class: "plus" })
2684
+ G(O(yo), { class: "plus" })
2693
2685
  ]),
2694
2686
  _: 1
2695
2687
  }, 8, ["to"])
@@ -2697,7 +2689,7 @@ const Je = /* @__PURE__ */ A(Rs, [["render", Vs]]), Bs = { class: "navbar" }, Hs
2697
2689
  ]));
2698
2690
  }
2699
2691
  });
2700
- class wt extends ft {
2692
+ class wt extends _t {
2701
2693
  _title = "Subgraph Input";
2702
2694
  inputs = {
2703
2695
  _code: new D("", "").use(V, X).setHidden(!0),
@@ -2708,7 +2700,7 @@ class wt extends ft {
2708
2700
  placeholder: new J("Connection", void 0)
2709
2701
  };
2710
2702
  }
2711
- class kt extends mt {
2703
+ class kt extends Ct {
2712
2704
  _title = "Subgraph Output";
2713
2705
  inputs = {
2714
2706
  _code: new D("", "").use(V, X).setHidden(!0),
@@ -2818,7 +2810,7 @@ class Fs extends Lt {
2818
2810
  addGraphTemplate(e) {
2819
2811
  if (this.events.beforeAddGraphTemplate.emit(e).prevented) return;
2820
2812
  this._graphTemplates.push(e), this.graphTemplateEvents.addTarget(e.events), this.graphTemplateHooks.addTarget(e.hooks);
2821
- const t = Nn(e);
2813
+ const t = Fo(e);
2822
2814
  this.registerNodeType(t, { category: "Subgraphs", title: e.name }), this.events.addGraphTemplate.emit(e);
2823
2815
  }
2824
2816
  /**
@@ -2869,7 +2861,7 @@ function Ir(n) {
2869
2861
  settings: l,
2870
2862
  switchGraph: i
2871
2863
  });
2872
- return e.value.registerViewModel(N), Fo(N), sn(r, d), Us(r, d, i), rn(r, d), an(r, d, i), ln(r, d), un(r, d, l), zo(r, d, l), Uo(l), tt(
2864
+ return e.value.registerViewModel(N), Uo(N), sn(r, d), Us(r, d, i), rn(r, d), an(r, d, i), ln(r, d), un(r, d, l), Bo(r, d, l), Ho(l), tt(
2873
2865
  t,
2874
2866
  (v, w) => {
2875
2867
  w && (w.events.registerGraph.unsubscribe(s), w.graphEvents.beforeAddNode.unsubscribe(s), v.nodeHooks.beforeLoad.unsubscribe(s), v.nodeHooks.afterSave.unsubscribe(s), v.graphTemplateHooks.beforeLoad.unsubscribe(s), v.graphTemplateHooks.afterSave.unsubscribe(s), v.graph.hooks.load.unsubscribe(s), v.graph.hooks.save.unsubscribe(s)), v && (v.nodeHooks.beforeLoad.subscribe(s, (u, y) => (y.position = u.position ?? { x: 0, y: 0 }, y.width = u.width ?? l.nodes.defaultWidth, y.twoColumn = u.twoColumn ?? !1, u)), v.nodeHooks.afterSave.subscribe(s, (u, y) => (u.position = y.position, u.width = y.width, u.twoColumn = y.twoColumn, u)), v.graphTemplateHooks.beforeLoad.subscribe(s, (u, y) => (y.panning = u.panning, y.scaling = u.scaling, u)), v.graphTemplateHooks.afterSave.subscribe(s, (u, y) => (u.panning = y.panning, u.scaling = y.scaling, u)), v.graph.hooks.load.subscribe(s, (u, y) => (y.panning = u.panning, y.scaling = u.scaling, u)), v.graph.hooks.save.subscribe(s, (u, y) => (u.panning = y.panning, u.scaling = y.scaling, u)), v.graphEvents.beforeAddNode.subscribe(
@@ -2882,20 +2874,20 @@ function Ir(n) {
2882
2874
  }
2883
2875
  export {
2884
2876
  lt as AbstractCodeNode,
2885
- gt as CLEAR_ALL_COMMAND,
2877
+ ft as CLEAR_ALL_COMMAND,
2886
2878
  zs as CREATE_SUBGRAPH_COMMAND,
2887
- Mn as Check,
2879
+ On as Check,
2888
2880
  sr as CheckboxInterface,
2889
2881
  ze as Code,
2890
2882
  Cr as CodeEditor,
2891
- En as CodeEngine,
2883
+ In as CodeEngine,
2892
2884
  Ie as CodeGraph,
2893
2885
  wr as CodeGraphEditor,
2894
2886
  kr as CodeGraphInfo,
2895
- ft as CodeGraphInputNode,
2887
+ _t as CodeGraphInputNode,
2896
2888
  gs as CodeGraphNode,
2897
2889
  Ke as CodeGraphNodeInterface,
2898
- mt as CodeGraphOutputNode,
2890
+ Ct as CodeGraphOutputNode,
2899
2891
  $s as CodeGraphSidebar,
2900
2892
  Ne as CodeGraphTemplate,
2901
2893
  Re as CodeNode,
@@ -2904,68 +2896,68 @@ export {
2904
2896
  je as CodeNodeInterfaceComponent,
2905
2897
  gn as CodeNodeOutputInterface,
2906
2898
  As as CodeNodePalette,
2907
- An as CodeVariable,
2908
- Vn as Copy,
2899
+ Pn as CodeVariable,
2900
+ jn as Copy,
2909
2901
  os as CopyToClipboard,
2910
- Un as DotsVertical,
2902
+ Hn as DotsVertical,
2911
2903
  xn as DynamicCodeNode,
2912
2904
  We as GRAPH_INPUT_NODE_TYPE,
2913
2905
  Ye as GRAPH_OUTPUT_NODE_TYPE,
2914
2906
  rr as IntegerInterface,
2915
- gr as JavascriptCode,
2916
- Yn as LayoutSidebarLeftCollapse,
2917
- Jn as LayoutSidebarLeftExpand,
2918
- to as LayoutSidebarRight,
2919
- ro as LayoutSidebarRightCollapse,
2920
- uo as LayoutSidebarRightExpand,
2907
+ vr as JavascriptCode,
2908
+ Fn as LayoutSidebarLeftCollapse,
2909
+ Kn as LayoutSidebarLeftExpand,
2910
+ Zn as LayoutSidebarRight,
2911
+ oo as LayoutSidebarRightCollapse,
2912
+ io as LayoutSidebarRightExpand,
2921
2913
  ar as ListInputInterface,
2922
- vt as LockCode,
2914
+ ht as LockCode,
2923
2915
  xr as NavBar,
2924
2916
  Je as NavItem,
2925
2917
  ir as NumberInterface,
2926
- go as PlayerPlay,
2927
- Co as Plus,
2928
- vr as PythonCode,
2929
- bt as RUN_ENGINE_COMMAND,
2930
- Io as Schema,
2931
- Oo as SchemaOff,
2918
+ mo as PlayerPlay,
2919
+ yo as Plus,
2920
+ mr as PythonCode,
2921
+ mt as RUN_ENGINE_COMMAND,
2922
+ ko as Schema,
2923
+ Eo as SchemaOff,
2932
2924
  lr as SelectInterface,
2933
2925
  qe as SidebarCheckbox,
2934
2926
  ur as SliderInterface,
2935
2927
  wt as SubgraphInputNode,
2936
2928
  kt as SubgraphOutputNode,
2937
- yt as TOGGLE_MINIMAP_COMMAND,
2938
- _t as TOGGLE_PALETTE_COMMAND,
2929
+ vt as TOGGLE_MINIMAP_COMMAND,
2930
+ gt as TOGGLE_PALETTE_COMMAND,
2939
2931
  dr as TextInputInterface,
2940
2932
  kn as TextInputInterfaceComponent,
2941
2933
  cr as TextareaInputInterface,
2942
- Po as TransitionBottom,
2943
- jo as TrashOff,
2934
+ Mo as TransitionBottom,
2935
+ Ao as TrashOff,
2944
2936
  pr as TupleInputInterface,
2945
- Ho as X,
2937
+ Vo as X,
2946
2938
  or as addDefaultInterfaceTypes,
2947
- br as allowMultipleConnections,
2939
+ gr as allowMultipleConnections,
2948
2940
  dt as booleanType,
2949
- Nn as createCodeGraphNodeType,
2941
+ Fo as createCodeGraphNodeType,
2950
2942
  hr as defineCodeNode,
2951
2943
  fr as defineDynamicCodeNode,
2952
2944
  vn as dictType,
2953
2945
  hn as formatInputs,
2954
- Ct as getCodeNodes,
2955
- yr as getPositionAtColumn,
2956
- _r as getPositionBeforeNode,
2946
+ bt as getCodeNodes,
2947
+ br as getPositionAtColumn,
2948
+ yr as getPositionBeforeNode,
2957
2949
  ct as listType,
2958
2950
  ut as loadNodeState,
2959
2951
  X as nodeType,
2960
2952
  Le as numberType,
2961
- Fo as registerCodeEngine,
2953
+ Uo as registerCodeEngine,
2962
2954
  Us as registerCreateSubgraphCommand,
2963
- zo as registerCustomCommands,
2964
- Do as registerRunEngineCommands,
2955
+ Bo as registerCustomCommands,
2956
+ zo as registerRunEngineCommands,
2965
2957
  fn as saveNodeState,
2966
2958
  Ve as stringType,
2967
2959
  pt as tupleType,
2968
- Uo as updateToolbarItems,
2960
+ Ho as updateToolbarItems,
2969
2961
  Ir as useCodeGraph,
2970
2962
  Ko as useSwitchCodeGraph
2971
2963
  };