@elicdavis/node-flow 0.1.1 → 0.1.2

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.
package/dist/index.mjs CHANGED
@@ -749,6 +749,507 @@ up_fn = function(event) {
749
749
  __privateGet(this, _clickStop).call(this);
750
750
  };
751
751
 
752
+ // src/elements/interfaces.ts
753
+ function InstantiateRenderElementSidesStyling(config) {
754
+ if (typeof config === "number") {
755
+ return {
756
+ Bottom: config,
757
+ Right: config,
758
+ Top: config,
759
+ Left: config
760
+ };
761
+ }
762
+ return {
763
+ Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
764
+ Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
765
+ Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
766
+ Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
767
+ };
768
+ }
769
+
770
+ // src/elements/base.ts
771
+ var _margin, _padding, _border, _backgroundColor, _minWidth, _maxWidth, _minHeight, _maxHeight, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
772
+ var RenderElementBase = class {
773
+ constructor(config) {
774
+ __privateAdd(this, _RenderElementBase_instances);
775
+ __privateAdd(this, _margin);
776
+ __privateAdd(this, _padding);
777
+ __privateAdd(this, _border);
778
+ __privateAdd(this, _backgroundColor);
779
+ __privateAdd(this, _minWidth);
780
+ __privateAdd(this, _maxWidth);
781
+ __privateAdd(this, _minHeight);
782
+ __privateAdd(this, _maxHeight);
783
+ __privateAdd(this, _grow);
784
+ __privateAdd(this, _display);
785
+ var _a, _b, _c, _d, _e, _f, _g;
786
+ __privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
787
+ __privateSet(this, _padding, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
788
+ __privateSet(this, _backgroundColor, config == null ? void 0 : config.BackgroundColor);
789
+ __privateSet(this, _border, {
790
+ Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
791
+ Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
792
+ Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
793
+ });
794
+ __privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
795
+ __privateSet(this, _maxWidth, config == null ? void 0 : config.MaxWidth);
796
+ __privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
797
+ __privateSet(this, _maxHeight, config == null ? void 0 : config.MaxHeight);
798
+ __privateSet(this, _grow, config == null ? void 0 : config.Grow);
799
+ __privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
800
+ }
801
+ setBackgroundColor(newColor) {
802
+ __privateSet(this, _backgroundColor, newColor);
803
+ }
804
+ render(ctx, position, graphScale, scaledFillableSpace) {
805
+ if (__privateGet(this, _display) === "none" /* None */) {
806
+ return;
807
+ }
808
+ const scaledSize = { x: 0, y: 0 };
809
+ this.size(ctx, scaledSize);
810
+ scaledSize.x = scaledSize.x * graphScale;
811
+ scaledSize.y = scaledSize.y * graphScale;
812
+ scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
813
+ scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
814
+ if (__privateGet(this, _backgroundColor)) {
815
+ ctx.fillStyle = __privateGet(this, _backgroundColor);
816
+ ctx.beginPath();
817
+ ctx.roundRect(
818
+ position.x + __privateGet(this, _margin).Left * graphScale,
819
+ position.y + __privateGet(this, _margin).Right * graphScale,
820
+ scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
821
+ scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
822
+ __privateGet(this, _border).Radius * graphScale
823
+ );
824
+ ctx.fill();
825
+ }
826
+ if (__privateGet(this, _border).Thickness > 0) {
827
+ ctx.lineWidth = __privateGet(this, _border).Thickness * graphScale;
828
+ ctx.strokeStyle = __privateGet(this, _border).Color;
829
+ ctx.stroke();
830
+ }
831
+ const offsetPosition = {
832
+ x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
833
+ y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
834
+ };
835
+ const elementSize = {
836
+ x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
837
+ y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
838
+ };
839
+ this.doRender(ctx, offsetPosition, graphScale, elementSize);
840
+ }
841
+ maxLimitations(out) {
842
+ out.x = -1;
843
+ out.y = -1;
844
+ if (__privateGet(this, _maxWidth)) {
845
+ out.x = __privateGet(this, _maxWidth);
846
+ }
847
+ if (__privateGet(this, _maxHeight)) {
848
+ out.y = __privateGet(this, _maxHeight);
849
+ }
850
+ }
851
+ setDisplay(display) {
852
+ __privateSet(this, _display, display);
853
+ }
854
+ getDisplay() {
855
+ return __privateGet(this, _display);
856
+ }
857
+ size(ctx, out) {
858
+ out.x = 0;
859
+ out.y = 0;
860
+ if (__privateGet(this, _display) === "none" /* None */) {
861
+ return;
862
+ }
863
+ const maxLimits = { x: -1, y: -1 };
864
+ this.maxLimitations(maxLimits);
865
+ this.calcSize(ctx, out, maxLimits);
866
+ out.x += __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this);
867
+ out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
868
+ if (__privateGet(this, _minWidth)) {
869
+ out.x = Math.max(out.x, __privateGet(this, _minWidth));
870
+ }
871
+ if (__privateGet(this, _maxWidth)) {
872
+ out.x = Math.min(__privateGet(this, _maxWidth), out.x);
873
+ }
874
+ if (__privateGet(this, _maxHeight)) {
875
+ out.y = Math.min(__privateGet(this, _maxHeight), out.y);
876
+ }
877
+ if (__privateGet(this, _minHeight)) {
878
+ out.y = Math.max(__privateGet(this, _minHeight), out.y);
879
+ }
880
+ }
881
+ };
882
+ _margin = new WeakMap();
883
+ _padding = new WeakMap();
884
+ _border = new WeakMap();
885
+ _backgroundColor = new WeakMap();
886
+ _minWidth = new WeakMap();
887
+ _maxWidth = new WeakMap();
888
+ _minHeight = new WeakMap();
889
+ _maxHeight = new WeakMap();
890
+ _grow = new WeakMap();
891
+ _display = new WeakMap();
892
+ _RenderElementBase_instances = new WeakSet();
893
+ horizontalOffset_fn = function() {
894
+ return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding).Left + __privateGet(this, _padding).Right;
895
+ };
896
+ verticalOffset_fn = function() {
897
+ return __privateGet(this, _border).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding).Top + __privateGet(this, _padding).Bottom;
898
+ };
899
+ totalTopOffset_fn = function() {
900
+ return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding).Top;
901
+ };
902
+ totalLeftOffset_fn = function() {
903
+ return __privateGet(this, _border).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding).Left;
904
+ };
905
+
906
+ // src/elements/container.ts
907
+ var _elements, _layout, _alignment, _ContainerRenderElement_instances, renderColumn_fn;
908
+ var ContainerRenderElement = class extends RenderElementBase {
909
+ constructor(elements, config) {
910
+ super(config);
911
+ __privateAdd(this, _ContainerRenderElement_instances);
912
+ __privateAdd(this, _elements);
913
+ __privateAdd(this, _layout);
914
+ __privateAdd(this, _alignment);
915
+ __privateSet(this, _elements, elements);
916
+ __privateSet(this, _layout, "column" /* Column */);
917
+ __privateSet(this, _alignment, "stretch" /* Stretch */);
918
+ }
919
+ calcSize(ctx, out, limitations) {
920
+ out.x = 0;
921
+ out.y = 0;
922
+ const eleSize = { x: 0, y: 0 };
923
+ switch (__privateGet(this, _layout)) {
924
+ case "column" /* Column */:
925
+ for (let i = 0; i < __privateGet(this, _elements).length; i++) {
926
+ __privateGet(this, _elements)[i].size(ctx, eleSize);
927
+ out.x = Math.max(out.x, eleSize.x);
928
+ out.y += eleSize.y;
929
+ }
930
+ break;
931
+ case "row" /* Row */:
932
+ for (let i = 0; i < __privateGet(this, _elements).length; i++) {
933
+ __privateGet(this, _elements)[i].size(ctx, eleSize);
934
+ out.y = Math.max(out.y, eleSize.y);
935
+ out.x += eleSize.x;
936
+ }
937
+ break;
938
+ default:
939
+ throw new Error("unknown layout: " + __privateGet(this, _layout));
940
+ }
941
+ }
942
+ doRender(ctx, position, graphScale, scaledFillableSpace) {
943
+ switch (__privateGet(this, _layout)) {
944
+ case "column" /* Column */:
945
+ __privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
946
+ break;
947
+ default:
948
+ throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
949
+ }
950
+ }
951
+ };
952
+ _elements = new WeakMap();
953
+ _layout = new WeakMap();
954
+ _alignment = new WeakMap();
955
+ _ContainerRenderElement_instances = new WeakSet();
956
+ renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
957
+ const currnetPos = { x: position.x, y: position.y };
958
+ const scaledEleSize = { x: 0, y: 0 };
959
+ for (let i = 0; i < __privateGet(this, _elements).length; i++) {
960
+ const ele = __privateGet(this, _elements)[i];
961
+ ele.size(ctx, scaledEleSize);
962
+ ScaleVector(scaledEleSize, graphScale);
963
+ switch (__privateGet(this, _alignment)) {
964
+ case "stretch" /* Stretch */:
965
+ currnetPos.x = position.x;
966
+ scaledEleSize.x = scaledFillableSpace.x;
967
+ break;
968
+ // I'm not sure if this is even needed, I feel like this should
969
+ // already be the case.
970
+ case "start" /* Start */:
971
+ currnetPos.x = position.x;
972
+ break;
973
+ case "end" /* End */:
974
+ currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
975
+ break;
976
+ case "center" /* Center */:
977
+ currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
978
+ break;
979
+ default:
980
+ throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
981
+ }
982
+ ele.render(ctx, currnetPos, graphScale, scaledEleSize);
983
+ currnetPos.y += scaledEleSize.y;
984
+ }
985
+ };
986
+
987
+ // src/elements/text.ts
988
+ var _text, _align, _verticalAlign;
989
+ var TextElement = class extends RenderElementBase {
990
+ constructor(text, styling) {
991
+ var _a, _b;
992
+ super(styling);
993
+ __privateAdd(this, _text);
994
+ __privateAdd(this, _align);
995
+ __privateAdd(this, _verticalAlign);
996
+ __privateSet(this, _text, text);
997
+ __privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
998
+ __privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
999
+ }
1000
+ doRender(ctx, position, graphScale, scaledFillableSpace) {
1001
+ const scale = Zero();
1002
+ this.calcSize(ctx, scale, scaledFillableSpace);
1003
+ ScaleVector(scale, graphScale);
1004
+ const justifiedPosition = Zero();
1005
+ CopyVector2(justifiedPosition, position);
1006
+ ctx.textAlign = "left";
1007
+ ctx.textBaseline = "top";
1008
+ switch (__privateGet(this, _align)) {
1009
+ case "left" /* Left */:
1010
+ break;
1011
+ case "right" /* Right */:
1012
+ justifiedPosition.x += scaledFillableSpace.x - scale.x;
1013
+ break;
1014
+ case "center" /* Center */:
1015
+ justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
1016
+ break;
1017
+ default:
1018
+ throw new Error("unimplemented justification: " + __privateGet(this, _align));
1019
+ }
1020
+ switch (__privateGet(this, _verticalAlign)) {
1021
+ case "top" /* Top */:
1022
+ break;
1023
+ case "bottom" /* Bottom */:
1024
+ justifiedPosition.y += scaledFillableSpace.y - scale.y;
1025
+ break;
1026
+ case "center" /* Center */:
1027
+ justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
1028
+ break;
1029
+ default:
1030
+ throw new Error("unimplemented justification: " + __privateGet(this, _align));
1031
+ }
1032
+ if (scaledFillableSpace.x <= 0) {
1033
+ __privateGet(this, _text).render(ctx, graphScale, justifiedPosition);
1034
+ } else {
1035
+ const eles = __privateGet(this, _text).breakIntoLines(ctx, scaledFillableSpace.x);
1036
+ const tempSize = { x: 0, y: 0 };
1037
+ for (let i = 0; i < eles.length; i++) {
1038
+ eles[i].render(ctx, graphScale, justifiedPosition);
1039
+ eles[i].size(ctx, 1, tempSize);
1040
+ justifiedPosition.y += tempSize.y;
1041
+ }
1042
+ }
1043
+ }
1044
+ calcSize(ctx, out, limitations) {
1045
+ if (limitations.x <= 0) {
1046
+ __privateGet(this, _text).size(ctx, 1, out);
1047
+ return;
1048
+ }
1049
+ const eles = __privateGet(this, _text).breakIntoLines(ctx, limitations.x);
1050
+ const tempSize = { x: 0, y: 0 };
1051
+ out.x = 0;
1052
+ out.y = 0;
1053
+ for (let i = 0; i < eles.length; i++) {
1054
+ eles[i].size(ctx, 1, tempSize);
1055
+ out.x = Math.max(tempSize.x, out.x);
1056
+ out.y += tempSize.y;
1057
+ }
1058
+ }
1059
+ };
1060
+ _text = new WeakMap();
1061
+ _align = new WeakMap();
1062
+ _verticalAlign = new WeakMap();
1063
+
1064
+ // src/utils/string.ts
1065
+ var binarySearch = ({ max, getValue, match }) => {
1066
+ let min = 0;
1067
+ while (min <= max) {
1068
+ let guess = Math.floor((min + max) / 2);
1069
+ const compareVal = getValue(guess);
1070
+ if (compareVal === match) return guess;
1071
+ if (compareVal < match) min = guess + 1;
1072
+ else max = guess - 1;
1073
+ }
1074
+ return max;
1075
+ };
1076
+ function fitString(ctx, str, maxWidth) {
1077
+ let width2 = ctx.measureText(str).width;
1078
+ const ellipsis = "\u2026";
1079
+ const ellipsisWidth = ctx.measureText(ellipsis).width;
1080
+ if (width2 <= maxWidth || width2 <= ellipsisWidth) {
1081
+ return str;
1082
+ }
1083
+ const index = binarySearch({
1084
+ max: str.length,
1085
+ getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
1086
+ match: maxWidth - ellipsisWidth
1087
+ });
1088
+ return str.substring(0, index) + ellipsis;
1089
+ }
1090
+ function splitString(ctx, str, maxWidth) {
1091
+ let width2 = ctx.measureText(str).width;
1092
+ if (width2 <= maxWidth) {
1093
+ return [str];
1094
+ }
1095
+ let index = binarySearch({
1096
+ max: str.length,
1097
+ getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
1098
+ match: maxWidth
1099
+ });
1100
+ for (let backward = index - 1; backward >= 1; backward--) {
1101
+ if (str.charAt(backward) === " ") {
1102
+ index = backward + 1;
1103
+ break;
1104
+ }
1105
+ }
1106
+ return [str.substring(0, index), str.substring(index)];
1107
+ }
1108
+ function splitStringIntoLines(ctx, str, maxWidth) {
1109
+ let width2 = ctx.measureText(str).width;
1110
+ if (width2 <= maxWidth) {
1111
+ return [str];
1112
+ }
1113
+ const strings = new Array();
1114
+ let remaining = str;
1115
+ while (remaining !== "") {
1116
+ let index = binarySearch({
1117
+ max: remaining.length,
1118
+ getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
1119
+ match: maxWidth
1120
+ });
1121
+ if (index === remaining.length) {
1122
+ strings.push(remaining.substring(0, index));
1123
+ break;
1124
+ }
1125
+ for (let backward = index - 1; backward >= 1; backward--) {
1126
+ if (remaining.charAt(backward) === " ") {
1127
+ index = backward + 1;
1128
+ break;
1129
+ }
1130
+ }
1131
+ strings.push(remaining.substring(0, index));
1132
+ remaining = remaining.substring(index);
1133
+ }
1134
+ return strings;
1135
+ }
1136
+
1137
+ // src/types/text.ts
1138
+ var _measured, _size2, _style, _value, _Text_instances, measure_fn;
1139
+ var _Text = class _Text {
1140
+ constructor(value, style) {
1141
+ __privateAdd(this, _Text_instances);
1142
+ __privateAdd(this, _measured);
1143
+ __privateAdd(this, _size2);
1144
+ __privateAdd(this, _style);
1145
+ __privateAdd(this, _value);
1146
+ __privateSet(this, _value, value);
1147
+ __privateSet(this, _measured, false);
1148
+ __privateSet(this, _size2, Zero());
1149
+ __privateSet(this, _style, new TextStyle(style));
1150
+ if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
1151
+ document.fonts.addEventListener("loadingdone", (event) => {
1152
+ __privateSet(this, _measured, false);
1153
+ });
1154
+ }
1155
+ }
1156
+ set(newValue) {
1157
+ __privateSet(this, _value, newValue);
1158
+ __privateSet(this, _measured, false);
1159
+ }
1160
+ get() {
1161
+ return __privateGet(this, _value);
1162
+ }
1163
+ breakIntoLines(ctx, maxWidth) {
1164
+ const results = new Array();
1165
+ __privateGet(this, _style).setupStyle(ctx, 1);
1166
+ const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
1167
+ if (entries.length === 1) {
1168
+ return [this];
1169
+ }
1170
+ for (let i = 0; i < entries.length; i++) {
1171
+ const text = new _Text(entries[i]);
1172
+ __privateSet(text, _style, __privateGet(this, _style));
1173
+ results.push(text);
1174
+ }
1175
+ return results;
1176
+ }
1177
+ split(char) {
1178
+ const entries = __privateGet(this, _value).split(char);
1179
+ const results = new Array();
1180
+ for (let i = 0; i < entries.length; i++) {
1181
+ const text = new _Text(entries[i]);
1182
+ __privateSet(text, _style, __privateGet(this, _style));
1183
+ results.push(text);
1184
+ }
1185
+ return results;
1186
+ }
1187
+ splitAtIndex(index) {
1188
+ const results = [
1189
+ new _Text(__privateGet(this, _value).substring(0, index)),
1190
+ new _Text(__privateGet(this, _value).substring(index, 0))
1191
+ ];
1192
+ for (let i = 0; i < results.length; i++) {
1193
+ __privateSet(results[i], _style, __privateGet(this, _style));
1194
+ }
1195
+ return results;
1196
+ }
1197
+ splitAtWidth(ctx, maxWidth) {
1198
+ __privateGet(this, _style).setupStyle(ctx, 1);
1199
+ const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
1200
+ if (entries.length === 1) {
1201
+ return [this];
1202
+ }
1203
+ const results = new Array();
1204
+ for (let i = 0; i < entries.length; i++) {
1205
+ const text = new _Text(entries[i]);
1206
+ __privateSet(text, _style, __privateGet(this, _style));
1207
+ results.push(text);
1208
+ }
1209
+ return results;
1210
+ }
1211
+ size(ctx, scale, out) {
1212
+ __privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
1213
+ CopyVector2(out, __privateGet(this, _size2));
1214
+ ScaleVector(out, scale);
1215
+ }
1216
+ setColor(color) {
1217
+ __privateGet(this, _style).setColor(color);
1218
+ }
1219
+ getColor() {
1220
+ return __privateGet(this, _style).getColor();
1221
+ }
1222
+ setSize(size) {
1223
+ __privateGet(this, _style).setSize(size);
1224
+ }
1225
+ setWeight(weight) {
1226
+ __privateGet(this, _style).setWeight(weight);
1227
+ }
1228
+ render(ctx, scale, position) {
1229
+ __privateGet(this, _style).setupStyle(ctx, scale);
1230
+ ctx.fillText(__privateGet(this, _value), position.x, position.y);
1231
+ }
1232
+ style() {
1233
+ return __privateGet(this, _style);
1234
+ }
1235
+ };
1236
+ _measured = new WeakMap();
1237
+ _size2 = new WeakMap();
1238
+ _style = new WeakMap();
1239
+ _value = new WeakMap();
1240
+ _Text_instances = new WeakSet();
1241
+ measure_fn = function(ctx) {
1242
+ if (__privateGet(this, _measured)) {
1243
+ return;
1244
+ }
1245
+ __privateGet(this, _style).setupStyle(ctx, 1);
1246
+ const measurements = ctx.measureText(__privateGet(this, _value));
1247
+ __privateGet(this, _size2).x = measurements.width;
1248
+ __privateGet(this, _size2).y = measurements.actualBoundingBoxAscent + measurements.actualBoundingBoxDescent;
1249
+ __privateSet(this, _measured, true);
1250
+ };
1251
+ var Text = _Text;
1252
+
752
1253
  // src/utils/math.ts
753
1254
  function Clamp(v, min, max) {
754
1255
  return Math.min(Math.max(v, min), max);
@@ -841,7 +1342,7 @@ function fallbackColor(type, s) {
841
1342
  HSV2RGB(hsv, color);
842
1343
  return RgbToHex(color);
843
1344
  }
844
- var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _onConnectionAdded, _onConnectionRemoved, _box;
1345
+ var _node, _displayName, _emptyStyle, _filledStyle, _connections, _portType, _dataType, _dataTypePopupElement, _onConnectionAdded, _onConnectionRemoved, _box;
845
1346
  var Port = class {
846
1347
  constructor(node, portType, config) {
847
1348
  __privateAdd(this, _node);
@@ -851,6 +1352,7 @@ var Port = class {
851
1352
  __privateAdd(this, _connections);
852
1353
  __privateAdd(this, _portType);
853
1354
  __privateAdd(this, _dataType);
1355
+ __privateAdd(this, _dataTypePopupElement);
854
1356
  __privateAdd(this, _onConnectionAdded);
855
1357
  __privateAdd(this, _onConnectionRemoved);
856
1358
  __privateAdd(this, _box, { Position: { x: 0, y: 0 }, Size: { x: 0, y: 0 } });
@@ -880,6 +1382,40 @@ var Port = class {
880
1382
  if (config == null ? void 0 : config.onConnectionRemoved) {
881
1383
  __privateGet(this, _onConnectionRemoved).push(config == null ? void 0 : config.onConnectionRemoved);
882
1384
  }
1385
+ const containerElements = new Array();
1386
+ let dataTypeDisplay = __privateGet(this, _dataType);
1387
+ if ((config == null ? void 0 : config.array) === true) {
1388
+ dataTypeDisplay = "Array<" + dataTypeDisplay + ">";
1389
+ }
1390
+ containerElements.push(new TextElement(
1391
+ new Text(dataTypeDisplay, {
1392
+ color: "white"
1393
+ }),
1394
+ {
1395
+ Align: "center" /* Center */
1396
+ }
1397
+ ));
1398
+ const description = config == null ? void 0 : config.description;
1399
+ if (description && description !== "") {
1400
+ containerElements.push(new TextElement(
1401
+ new Text(description, { color: "white", style: "italic" /* Italic */ }),
1402
+ {
1403
+ Align: "center" /* Center */,
1404
+ Padding: { Top: 8 },
1405
+ MaxWidth: 300
1406
+ }
1407
+ ));
1408
+ }
1409
+ __privateSet(this, _dataTypePopupElement, new ContainerRenderElement(
1410
+ containerElements,
1411
+ {
1412
+ BackgroundColor: "rgba(0, 0, 0, 0.75)",
1413
+ Border: {
1414
+ Radius: 6
1415
+ },
1416
+ Padding: 13
1417
+ }
1418
+ ));
883
1419
  }
884
1420
  addConnection(connection) {
885
1421
  const c = __privateGet(this, _connections).length;
@@ -948,16 +1484,9 @@ var Port = class {
948
1484
  const xPos = position.x;
949
1485
  const yPos = position.y;
950
1486
  postProcess.queue(() => {
951
- ctx.textAlign = "center" /* Center */;
952
- const padding = 13;
953
- const measurement = ctx.measureText(__privateGet(this, _dataType));
954
- const w = measurement.width + padding * camera.zoom;
955
- ctx.beginPath();
956
- ctx.fillStyle = "rgba(0, 0, 0, 0.75)";
957
- ctx.roundRect(xPos - w / 2, yPos + scaledRadius * 3 - padding * camera.zoom, w, padding * 2 * camera.zoom, 4 * camera.zoom);
958
- ctx.fill();
959
- ctx.fillStyle = "#FFFFFF";
960
- ctx.fillText(__privateGet(this, _dataType), xPos, yPos + scaledRadius * 3);
1487
+ const size = { x: 0, y: 0 };
1488
+ __privateGet(this, _dataTypePopupElement).calcSize(ctx, size, { x: -1, y: -1 });
1489
+ __privateGet(this, _dataTypePopupElement).render(ctx, { x: xPos - size.x / 2, y: yPos }, 1, size);
961
1490
  });
962
1491
  }
963
1492
  __privateGet(this, _box).Position.x = position.x - scaledRadius;
@@ -984,6 +1513,7 @@ _filledStyle = new WeakMap();
984
1513
  _connections = new WeakMap();
985
1514
  _portType = new WeakMap();
986
1515
  _dataType = new WeakMap();
1516
+ _dataTypePopupElement = new WeakMap();
987
1517
  _onConnectionAdded = new WeakMap();
988
1518
  _onConnectionRemoved = new WeakMap();
989
1519
  _box = new WeakMap();
@@ -995,29 +1525,29 @@ function StrokeStyleWithFallback(input, fallback) {
995
1525
  size: (input == null ? void 0 : input.size) === void 0 ? fallback == null ? void 0 : fallback.size : input == null ? void 0 : input.size
996
1526
  };
997
1527
  }
998
- var _size2, _color2;
1528
+ var _size3, _color2;
999
1529
  var StrokeStyle = class {
1000
1530
  constructor(config) {
1001
- __privateAdd(this, _size2);
1531
+ __privateAdd(this, _size3);
1002
1532
  __privateAdd(this, _color2);
1003
- __privateSet(this, _size2, (config == null ? void 0 : config.size) === void 0 ? 0.5 : config.size);
1533
+ __privateSet(this, _size3, (config == null ? void 0 : config.size) === void 0 ? 0.5 : config.size);
1004
1534
  __privateSet(this, _color2, (config == null ? void 0 : config.color) === void 0 ? "black" : config.color);
1005
1535
  }
1006
1536
  setupStyle(ctx, scale) {
1007
1537
  ctx.strokeStyle = __privateGet(this, _color2);
1008
- ctx.lineWidth = scale * __privateGet(this, _size2);
1538
+ ctx.lineWidth = scale * __privateGet(this, _size3);
1009
1539
  }
1010
1540
  setColor(newColor) {
1011
1541
  __privateSet(this, _color2, newColor);
1012
1542
  }
1013
1543
  setSize(newSize) {
1014
- __privateSet(this, _size2, newSize);
1544
+ __privateSet(this, _size3, newSize);
1015
1545
  }
1016
1546
  size() {
1017
- return __privateGet(this, _size2);
1547
+ return __privateGet(this, _size3);
1018
1548
  }
1019
1549
  };
1020
- _size2 = new WeakMap();
1550
+ _size3 = new WeakMap();
1021
1551
  _color2 = new WeakMap();
1022
1552
 
1023
1553
  // src/styles/box.ts
@@ -1028,20 +1558,20 @@ function BoxStyleWithFallback(input, fallback) {
1028
1558
  border: StrokeStyleWithFallback(input == null ? void 0 : input.border, fallback == null ? void 0 : fallback.border)
1029
1559
  };
1030
1560
  }
1031
- var _border, _color3, _radius, _BoxStyle_instances, box_fn, draw_fn;
1561
+ var _border2, _color3, _radius, _BoxStyle_instances, box_fn, draw_fn;
1032
1562
  var BoxStyle = class {
1033
1563
  constructor(config) {
1034
1564
  __privateAdd(this, _BoxStyle_instances);
1035
- __privateAdd(this, _border);
1565
+ __privateAdd(this, _border2);
1036
1566
  __privateAdd(this, _color3);
1037
1567
  __privateAdd(this, _radius);
1038
1568
  __privateSet(this, _color3, (config == null ? void 0 : config.color) === void 0 ? "#CCCCCC" : config.color);
1039
- __privateSet(this, _border, (config == null ? void 0 : config.border) === void 0 ? null : new StrokeStyle(config.border));
1569
+ __privateSet(this, _border2, (config == null ? void 0 : config.border) === void 0 ? null : new StrokeStyle(config.border));
1040
1570
  __privateSet(this, _radius, (config == null ? void 0 : config.radius) === void 0 ? 2 : config.radius);
1041
1571
  }
1042
1572
  Outline(ctx, box, scale, radius) {
1043
1573
  var _a;
1044
- (_a = __privateGet(this, _border)) == null ? void 0 : _a.setupStyle(ctx, scale);
1574
+ (_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
1045
1575
  ctx.beginPath();
1046
1576
  ctx.roundRect(
1047
1577
  box.Position.x,
@@ -1066,238 +1596,49 @@ var BoxStyle = class {
1066
1596
  ctx.stroke();
1067
1597
  }
1068
1598
  borderSize() {
1069
- if (__privateGet(this, _border) === null) {
1599
+ if (__privateGet(this, _border2) === null) {
1070
1600
  return 0;
1071
1601
  }
1072
- return __privateGet(this, _border).size();
1602
+ return __privateGet(this, _border2).size();
1073
1603
  }
1074
1604
  radius() {
1075
1605
  return __privateGet(this, _radius);
1076
1606
  }
1077
1607
  setColor(color) {
1078
- __privateSet(this, _color3, color);
1079
- }
1080
- setBorderColor(color) {
1081
- if (__privateGet(this, _border) === null) {
1082
- __privateSet(this, _border, new StrokeStyle({
1083
- color
1084
- }));
1085
- } else {
1086
- __privateGet(this, _border).setColor(color);
1087
- }
1088
- }
1089
- };
1090
- _border = new WeakMap();
1091
- _color3 = new WeakMap();
1092
- _radius = new WeakMap();
1093
- _BoxStyle_instances = new WeakSet();
1094
- box_fn = function(ctx, box, scale, radius) {
1095
- var _a;
1096
- ctx.fillStyle = __privateGet(this, _color3);
1097
- (_a = __privateGet(this, _border)) == null ? void 0 : _a.setupStyle(ctx, scale);
1098
- ctx.beginPath();
1099
- ctx.roundRect(
1100
- box.Position.x,
1101
- box.Position.y,
1102
- box.Size.x,
1103
- box.Size.y,
1104
- radius
1105
- );
1106
- ctx.fill();
1107
- };
1108
- draw_fn = function(ctx, box, scale, radius) {
1109
- __privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
1110
- ctx.stroke();
1111
- };
1112
-
1113
- // src/utils/string.ts
1114
- var binarySearch = ({ max, getValue, match }) => {
1115
- let min = 0;
1116
- while (min <= max) {
1117
- let guess = Math.floor((min + max) / 2);
1118
- const compareVal = getValue(guess);
1119
- if (compareVal === match) return guess;
1120
- if (compareVal < match) min = guess + 1;
1121
- else max = guess - 1;
1122
- }
1123
- return max;
1124
- };
1125
- function fitString(ctx, str, maxWidth) {
1126
- let width2 = ctx.measureText(str).width;
1127
- const ellipsis = "\u2026";
1128
- const ellipsisWidth = ctx.measureText(ellipsis).width;
1129
- if (width2 <= maxWidth || width2 <= ellipsisWidth) {
1130
- return str;
1131
- }
1132
- const index = binarySearch({
1133
- max: str.length,
1134
- getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
1135
- match: maxWidth - ellipsisWidth
1136
- });
1137
- return str.substring(0, index) + ellipsis;
1138
- }
1139
- function splitString(ctx, str, maxWidth) {
1140
- let width2 = ctx.measureText(str).width;
1141
- if (width2 <= maxWidth) {
1142
- return [str];
1143
- }
1144
- let index = binarySearch({
1145
- max: str.length,
1146
- getValue: (guess) => ctx.measureText(str.substring(0, guess)).width,
1147
- match: maxWidth
1148
- });
1149
- for (let backward = index - 1; backward >= 1; backward--) {
1150
- if (str.charAt(backward) === " ") {
1151
- index = backward + 1;
1152
- break;
1153
- }
1154
- }
1155
- return [str.substring(0, index), str.substring(index)];
1156
- }
1157
- function splitStringIntoLines(ctx, str, maxWidth) {
1158
- let width2 = ctx.measureText(str).width;
1159
- if (width2 <= maxWidth) {
1160
- return [str];
1161
- }
1162
- const strings = new Array();
1163
- let remaining = str;
1164
- while (remaining !== "") {
1165
- let index = binarySearch({
1166
- max: remaining.length,
1167
- getValue: (guess) => ctx.measureText(remaining.substring(0, guess)).width,
1168
- match: maxWidth
1169
- });
1170
- if (index === remaining.length) {
1171
- strings.push(remaining.substring(0, index));
1172
- break;
1173
- }
1174
- for (let backward = index - 1; backward >= 1; backward--) {
1175
- if (remaining.charAt(backward) === " ") {
1176
- index = backward + 1;
1177
- break;
1178
- }
1179
- }
1180
- strings.push(remaining.substring(0, index));
1181
- remaining = remaining.substring(index);
1182
- }
1183
- return strings;
1184
- }
1185
-
1186
- // src/types/text.ts
1187
- var _measured, _size3, _style, _value, _Text_instances, measure_fn;
1188
- var _Text = class _Text {
1189
- constructor(value, style) {
1190
- __privateAdd(this, _Text_instances);
1191
- __privateAdd(this, _measured);
1192
- __privateAdd(this, _size3);
1193
- __privateAdd(this, _style);
1194
- __privateAdd(this, _value);
1195
- __privateSet(this, _value, value);
1196
- __privateSet(this, _measured, false);
1197
- __privateSet(this, _size3, Zero());
1198
- __privateSet(this, _style, new TextStyle(style));
1199
- if (!document.fonts.check(`16px "${__privateGet(this, _style).getFont()}"`)) {
1200
- document.fonts.addEventListener("loadingdone", (event) => {
1201
- __privateSet(this, _measured, false);
1202
- });
1203
- }
1204
- }
1205
- set(newValue) {
1206
- __privateSet(this, _value, newValue);
1207
- __privateSet(this, _measured, false);
1208
- }
1209
- get() {
1210
- return __privateGet(this, _value);
1211
- }
1212
- breakIntoLines(ctx, maxWidth) {
1213
- const results = new Array();
1214
- __privateGet(this, _style).setupStyle(ctx, 1);
1215
- const entries = splitStringIntoLines(ctx, __privateGet(this, _value), maxWidth);
1216
- if (entries.length === 1) {
1217
- return [this];
1218
- }
1219
- for (let i = 0; i < entries.length; i++) {
1220
- const text = new _Text(entries[i]);
1221
- __privateSet(text, _style, __privateGet(this, _style));
1222
- results.push(text);
1223
- }
1224
- return results;
1225
- }
1226
- split(char) {
1227
- const entries = __privateGet(this, _value).split(char);
1228
- const results = new Array();
1229
- for (let i = 0; i < entries.length; i++) {
1230
- const text = new _Text(entries[i]);
1231
- __privateSet(text, _style, __privateGet(this, _style));
1232
- results.push(text);
1233
- }
1234
- return results;
1235
- }
1236
- splitAtIndex(index) {
1237
- const results = [
1238
- new _Text(__privateGet(this, _value).substring(0, index)),
1239
- new _Text(__privateGet(this, _value).substring(index, 0))
1240
- ];
1241
- for (let i = 0; i < results.length; i++) {
1242
- __privateSet(results[i], _style, __privateGet(this, _style));
1243
- }
1244
- return results;
1245
- }
1246
- splitAtWidth(ctx, maxWidth) {
1247
- __privateGet(this, _style).setupStyle(ctx, 1);
1248
- const entries = splitString(ctx, __privateGet(this, _value), maxWidth);
1249
- if (entries.length === 1) {
1250
- return [this];
1251
- }
1252
- const results = new Array();
1253
- for (let i = 0; i < entries.length; i++) {
1254
- const text = new _Text(entries[i]);
1255
- __privateSet(text, _style, __privateGet(this, _style));
1256
- results.push(text);
1257
- }
1258
- return results;
1259
- }
1260
- size(ctx, scale, out) {
1261
- __privateMethod(this, _Text_instances, measure_fn).call(this, ctx);
1262
- CopyVector2(out, __privateGet(this, _size3));
1263
- ScaleVector(out, scale);
1264
- }
1265
- setColor(color) {
1266
- __privateGet(this, _style).setColor(color);
1267
- }
1268
- getColor() {
1269
- return __privateGet(this, _style).getColor();
1270
- }
1271
- setSize(size) {
1272
- __privateGet(this, _style).setSize(size);
1273
- }
1274
- setWeight(weight) {
1275
- __privateGet(this, _style).setWeight(weight);
1276
- }
1277
- render(ctx, scale, position) {
1278
- __privateGet(this, _style).setupStyle(ctx, scale);
1279
- ctx.fillText(__privateGet(this, _value), position.x, position.y);
1608
+ __privateSet(this, _color3, color);
1280
1609
  }
1281
- style() {
1282
- return __privateGet(this, _style);
1610
+ setBorderColor(color) {
1611
+ if (__privateGet(this, _border2) === null) {
1612
+ __privateSet(this, _border2, new StrokeStyle({
1613
+ color
1614
+ }));
1615
+ } else {
1616
+ __privateGet(this, _border2).setColor(color);
1617
+ }
1283
1618
  }
1284
1619
  };
1285
- _measured = new WeakMap();
1286
- _size3 = new WeakMap();
1287
- _style = new WeakMap();
1288
- _value = new WeakMap();
1289
- _Text_instances = new WeakSet();
1290
- measure_fn = function(ctx) {
1291
- if (__privateGet(this, _measured)) {
1292
- return;
1293
- }
1294
- __privateGet(this, _style).setupStyle(ctx, 1);
1295
- const measurements = ctx.measureText(__privateGet(this, _value));
1296
- __privateGet(this, _size3).x = measurements.width;
1297
- __privateGet(this, _size3).y = measurements.actualBoundingBoxAscent + measurements.actualBoundingBoxDescent;
1298
- __privateSet(this, _measured, true);
1620
+ _border2 = new WeakMap();
1621
+ _color3 = new WeakMap();
1622
+ _radius = new WeakMap();
1623
+ _BoxStyle_instances = new WeakSet();
1624
+ box_fn = function(ctx, box, scale, radius) {
1625
+ var _a;
1626
+ ctx.fillStyle = __privateGet(this, _color3);
1627
+ (_a = __privateGet(this, _border2)) == null ? void 0 : _a.setupStyle(ctx, scale);
1628
+ ctx.beginPath();
1629
+ ctx.roundRect(
1630
+ box.Position.x,
1631
+ box.Position.y,
1632
+ box.Size.x,
1633
+ box.Size.y,
1634
+ radius
1635
+ );
1636
+ ctx.fill();
1637
+ };
1638
+ draw_fn = function(ctx, box, scale, radius) {
1639
+ __privateMethod(this, _BoxStyle_instances, box_fn).call(this, ctx, box, scale, radius);
1640
+ ctx.stroke();
1299
1641
  };
1300
- var Text = _Text;
1301
1642
 
1302
1643
  // src/popup.ts
1303
1644
  var _title, _options, _content, _onClose, _buttonCSS, _popup;
@@ -1372,15 +1713,15 @@ function TextBoxStyleWithFallback(input, fallback) {
1372
1713
  textBaseline: (input == null ? void 0 : input.textBaseline) === void 0 ? fallback == null ? void 0 : fallback.textBaseline : input == null ? void 0 : input.textBaseline
1373
1714
  };
1374
1715
  }
1375
- var _box2, _text, _textAlign, _textBaseline;
1716
+ var _box2, _text2, _textAlign, _textBaseline;
1376
1717
  var TextBoxStyle = class {
1377
1718
  constructor(config) {
1378
1719
  __privateAdd(this, _box2);
1379
- __privateAdd(this, _text);
1720
+ __privateAdd(this, _text2);
1380
1721
  __privateAdd(this, _textAlign);
1381
1722
  __privateAdd(this, _textBaseline);
1382
1723
  __privateSet(this, _box2, new BoxStyle(config == null ? void 0 : config.box));
1383
- __privateSet(this, _text, new TextStyle(config == null ? void 0 : config.text));
1724
+ __privateSet(this, _text2, new TextStyle(config == null ? void 0 : config.text));
1384
1725
  __privateSet(this, _textAlign, (config == null ? void 0 : config.textAlign) === void 0 ? "center" /* Center */ : config.textAlign);
1385
1726
  __privateSet(this, _textBaseline, (config == null ? void 0 : config.textBaseline) === void 0 ? "middle" /* Middle */ : config.textBaseline);
1386
1727
  }
@@ -1388,7 +1729,7 @@ var TextBoxStyle = class {
1388
1729
  __privateGet(this, _box2).Draw(ctx, box, scale);
1389
1730
  ctx.textAlign = __privateGet(this, _textAlign);
1390
1731
  ctx.textBaseline = __privateGet(this, _textBaseline);
1391
- __privateGet(this, _text).setupStyle(ctx, scale);
1732
+ __privateGet(this, _text2).setupStyle(ctx, scale);
1392
1733
  ctx.fillText(
1393
1734
  text,
1394
1735
  box.Position.x + box.Size.x / 2,
@@ -1399,7 +1740,7 @@ var TextBoxStyle = class {
1399
1740
  __privateGet(this, _box2).DrawUnderline(ctx, box, scale);
1400
1741
  ctx.textAlign = __privateGet(this, _textAlign);
1401
1742
  ctx.textBaseline = __privateGet(this, _textBaseline);
1402
- __privateGet(this, _text).setupStyle(ctx, scale);
1743
+ __privateGet(this, _text2).setupStyle(ctx, scale);
1403
1744
  ctx.fillText(
1404
1745
  text,
1405
1746
  box.Position.x + box.Size.x / 2,
@@ -1407,7 +1748,7 @@ var TextBoxStyle = class {
1407
1748
  );
1408
1749
  }
1409
1750
  setTextColor(color) {
1410
- __privateGet(this, _text).setColor(color);
1751
+ __privateGet(this, _text2).setColor(color);
1411
1752
  }
1412
1753
  setBoxColor(color) {
1413
1754
  __privateGet(this, _box2).setColor(color);
@@ -1417,7 +1758,7 @@ var TextBoxStyle = class {
1417
1758
  }
1418
1759
  };
1419
1760
  _box2 = new WeakMap();
1420
- _text = new WeakMap();
1761
+ _text2 = new WeakMap();
1421
1762
  _textAlign = new WeakMap();
1422
1763
  _textBaseline = new WeakMap();
1423
1764
 
@@ -1426,7 +1767,7 @@ var width = 150;
1426
1767
  var height = 25;
1427
1768
 
1428
1769
  // src/widgets/number.ts
1429
- var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle, _text2, _callback2;
1770
+ var _node2, _nodeProperty, _value2, _idleBoxStyle, _highlightBoxStyle, _text3, _callback2;
1430
1771
  var NumberWidget = class {
1431
1772
  constructor(node, config) {
1432
1773
  __privateAdd(this, _node2);
@@ -1434,10 +1775,10 @@ var NumberWidget = class {
1434
1775
  __privateAdd(this, _value2);
1435
1776
  __privateAdd(this, _idleBoxStyle);
1436
1777
  __privateAdd(this, _highlightBoxStyle);
1437
- __privateAdd(this, _text2);
1778
+ __privateAdd(this, _text3);
1438
1779
  __privateAdd(this, _callback2);
1439
1780
  __privateSet(this, _value2, 0);
1440
- __privateSet(this, _text2, "0");
1781
+ __privateSet(this, _text3, "0");
1441
1782
  __privateSet(this, _node2, node);
1442
1783
  __privateSet(this, _nodeProperty, config == null ? void 0 : config.property);
1443
1784
  __privateSet(this, _idleBoxStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleBoxStyle, {
@@ -1484,7 +1825,7 @@ var NumberWidget = class {
1484
1825
  if (__privateGet(this, _callback2) !== void 0) {
1485
1826
  __privateGet(this, _callback2).call(this, __privateGet(this, _value2));
1486
1827
  }
1487
- __privateSet(this, _text2, "" + parseFloat(__privateGet(this, _value2).toPrecision(6)));
1828
+ __privateSet(this, _text3, "" + parseFloat(__privateGet(this, _value2).toPrecision(6)));
1488
1829
  }
1489
1830
  ClickStart() {
1490
1831
  }
@@ -1527,7 +1868,7 @@ var NumberWidget = class {
1527
1868
  style = __privateGet(this, _highlightBoxStyle);
1528
1869
  }
1529
1870
  }
1530
- style.DrawUnderline(ctx, box, scale, __privateGet(this, _text2));
1871
+ style.DrawUnderline(ctx, box, scale, __privateGet(this, _text3));
1531
1872
  return box;
1532
1873
  }
1533
1874
  };
@@ -1536,20 +1877,20 @@ _nodeProperty = new WeakMap();
1536
1877
  _value2 = new WeakMap();
1537
1878
  _idleBoxStyle = new WeakMap();
1538
1879
  _highlightBoxStyle = new WeakMap();
1539
- _text2 = new WeakMap();
1880
+ _text3 = new WeakMap();
1540
1881
  _callback2 = new WeakMap();
1541
1882
 
1542
1883
  // src/widgets/button.ts
1543
- var _text3, _idleStyle, _hoverStyle, _clickStyle, _callback3, _gettingClicked;
1884
+ var _text4, _idleStyle, _hoverStyle, _clickStyle, _callback3, _gettingClicked;
1544
1885
  var ButtonWidget = class {
1545
1886
  constructor(config) {
1546
- __privateAdd(this, _text3);
1887
+ __privateAdd(this, _text4);
1547
1888
  __privateAdd(this, _idleStyle);
1548
1889
  __privateAdd(this, _hoverStyle);
1549
1890
  __privateAdd(this, _clickStyle);
1550
1891
  __privateAdd(this, _callback3);
1551
1892
  __privateAdd(this, _gettingClicked);
1552
- __privateSet(this, _text3, (config == null ? void 0 : config.text) === void 0 ? "Button" : config == null ? void 0 : config.text);
1893
+ __privateSet(this, _text4, (config == null ? void 0 : config.text) === void 0 ? "Button" : config == null ? void 0 : config.text);
1553
1894
  __privateSet(this, _callback3, config == null ? void 0 : config.callback);
1554
1895
  __privateSet(this, _gettingClicked, false);
1555
1896
  __privateSet(this, _idleStyle, new TextBoxStyle(TextBoxStyleWithFallback(config == null ? void 0 : config.idleStyle, {
@@ -1604,7 +1945,7 @@ var ButtonWidget = class {
1604
1945
  if (__privateGet(this, _gettingClicked)) {
1605
1946
  style = __privateGet(this, _clickStyle);
1606
1947
  }
1607
- style.Draw(ctx, box, scale, __privateGet(this, _text3));
1948
+ style.Draw(ctx, box, scale, __privateGet(this, _text4));
1608
1949
  return box;
1609
1950
  }
1610
1951
  ClickStart() {
@@ -1617,7 +1958,7 @@ var ButtonWidget = class {
1617
1958
  }
1618
1959
  }
1619
1960
  };
1620
- _text3 = new WeakMap();
1961
+ _text4 = new WeakMap();
1621
1962
  _idleStyle = new WeakMap();
1622
1963
  _hoverStyle = new WeakMap();
1623
1964
  _clickStyle = new WeakMap();
@@ -1735,14 +2076,14 @@ _textBoxStyle = new WeakMap();
1735
2076
  _callback4 = new WeakMap();
1736
2077
 
1737
2078
  // src/widgets/slider.ts
1738
- var _min, _max, _value4, _text4, _snapIncrement, _node4, _nodeProperty3, _change, _release, _textStyle3, _backgroundColor, _borderColor, _fillColor, _lastMousePosition2, _clickStartMousePosition, _clicking;
2079
+ var _min, _max, _value4, _text5, _snapIncrement, _node4, _nodeProperty3, _change, _release, _textStyle3, _backgroundColor2, _borderColor, _fillColor, _lastMousePosition2, _clickStartMousePosition, _clicking;
1739
2080
  var SliderWidget = class {
1740
2081
  constructor(node, config) {
1741
2082
  // Data Variables =========================================================
1742
2083
  __privateAdd(this, _min);
1743
2084
  __privateAdd(this, _max);
1744
2085
  __privateAdd(this, _value4);
1745
- __privateAdd(this, _text4);
2086
+ __privateAdd(this, _text5);
1746
2087
  __privateAdd(this, _snapIncrement);
1747
2088
  __privateAdd(this, _node4);
1748
2089
  __privateAdd(this, _nodeProperty3);
@@ -1751,7 +2092,7 @@ var SliderWidget = class {
1751
2092
  __privateAdd(this, _release);
1752
2093
  // Styling Variables ======================================================
1753
2094
  __privateAdd(this, _textStyle3);
1754
- __privateAdd(this, _backgroundColor);
2095
+ __privateAdd(this, _backgroundColor2);
1755
2096
  __privateAdd(this, _borderColor);
1756
2097
  __privateAdd(this, _fillColor);
1757
2098
  // Runtime Variables ======================================================
@@ -1764,9 +2105,9 @@ var SliderWidget = class {
1764
2105
  __privateSet(this, _max, (config == null ? void 0 : config.max) === void 0 ? 1 : config == null ? void 0 : config.max);
1765
2106
  __privateSet(this, _snapIncrement, config == null ? void 0 : config.snapIncrement);
1766
2107
  __privateSet(this, _nodeProperty3, config == null ? void 0 : config.property);
1767
- __privateSet(this, _text4, "");
2108
+ __privateSet(this, _text5, "");
1768
2109
  __privateSet(this, _release, config == null ? void 0 : config.release);
1769
- __privateSet(this, _backgroundColor, (config == null ? void 0 : config.backgroundColor) === void 0 ? Theme.Widget.BackgroundColor : config == null ? void 0 : config.backgroundColor);
2110
+ __privateSet(this, _backgroundColor2, (config == null ? void 0 : config.backgroundColor) === void 0 ? Theme.Widget.BackgroundColor : config == null ? void 0 : config.backgroundColor);
1770
2111
  __privateSet(this, _fillColor, (config == null ? void 0 : config.fillColor) === void 0 ? Theme.Widget.Slider.FillColor : config == null ? void 0 : config.fillColor);
1771
2112
  __privateSet(this, _borderColor, (config == null ? void 0 : config.borderColor) === void 0 ? Theme.Widget.Border.Color : config == null ? void 0 : config.borderColor);
1772
2113
  __privateSet(this, _textStyle3, new TextStyle(TextStyleFallback(config == null ? void 0 : config.textStyle, {
@@ -1792,7 +2133,7 @@ var SliderWidget = class {
1792
2133
  if (__privateGet(this, _nodeProperty3)) {
1793
2134
  __privateGet(this, _node4).setProperty(__privateGet(this, _nodeProperty3), __privateGet(this, _value4));
1794
2135
  }
1795
- __privateSet(this, _text4, __privateGet(this, _value4).toFixed(3));
2136
+ __privateSet(this, _text5, __privateGet(this, _value4).toFixed(3));
1796
2137
  if (__privateGet(this, _change) !== void 0) {
1797
2138
  __privateGet(this, _change).call(this, __privateGet(this, _value4));
1798
2139
  }
@@ -1814,7 +2155,7 @@ var SliderWidget = class {
1814
2155
  const scaledWidth = width * scale;
1815
2156
  const scaledHeight = height * scale;
1816
2157
  const scaledBorderThickness = Theme.Widget.Border.Size * scale;
1817
- ctx.fillStyle = __privateGet(this, _backgroundColor);
2158
+ ctx.fillStyle = __privateGet(this, _backgroundColor2);
1818
2159
  ctx.strokeStyle = __privateGet(this, _borderColor);
1819
2160
  ctx.lineWidth = scaledBorderThickness;
1820
2161
  ctx.beginPath();
@@ -1842,7 +2183,7 @@ var SliderWidget = class {
1842
2183
  ctx.textBaseline = "middle" /* Middle */;
1843
2184
  __privateGet(this, _textStyle3).setupStyle(ctx, scale);
1844
2185
  ctx.fillText(
1845
- __privateGet(this, _text4),
2186
+ __privateGet(this, _text5),
1846
2187
  position.x + scaledWidth / 2,
1847
2188
  position.y + scaledHeight / 2
1848
2189
  );
@@ -1871,14 +2212,14 @@ var SliderWidget = class {
1871
2212
  _min = new WeakMap();
1872
2213
  _max = new WeakMap();
1873
2214
  _value4 = new WeakMap();
1874
- _text4 = new WeakMap();
2215
+ _text5 = new WeakMap();
1875
2216
  _snapIncrement = new WeakMap();
1876
2217
  _node4 = new WeakMap();
1877
2218
  _nodeProperty3 = new WeakMap();
1878
2219
  _change = new WeakMap();
1879
2220
  _release = new WeakMap();
1880
2221
  _textStyle3 = new WeakMap();
1881
- _backgroundColor = new WeakMap();
2222
+ _backgroundColor2 = new WeakMap();
1882
2223
  _borderColor = new WeakMap();
1883
2224
  _fillColor = new WeakMap();
1884
2225
  _lastMousePosition2 = new WeakMap();
@@ -2082,13 +2423,13 @@ _lightColor = new WeakMap();
2082
2423
  _lightBorderColor = new WeakMap();
2083
2424
  _lightBlur = new WeakMap();
2084
2425
  _box3 = new WeakMap();
2085
- var _node6, _nodeProperty5, _value6, _text5, _enabledStyle, _disabledStyle, _callback6;
2426
+ var _node6, _nodeProperty5, _value6, _text6, _enabledStyle, _disabledStyle, _callback6;
2086
2427
  var ToggleWidget = class {
2087
2428
  constructor(node, config) {
2088
2429
  __privateAdd(this, _node6);
2089
2430
  __privateAdd(this, _nodeProperty5);
2090
2431
  __privateAdd(this, _value6);
2091
- __privateAdd(this, _text5);
2432
+ __privateAdd(this, _text6);
2092
2433
  __privateAdd(this, _enabledStyle);
2093
2434
  __privateAdd(this, _disabledStyle);
2094
2435
  __privateAdd(this, _callback6);
@@ -2096,7 +2437,7 @@ var ToggleWidget = class {
2096
2437
  __privateSet(this, _value6, false);
2097
2438
  __privateSet(this, _node6, node);
2098
2439
  __privateSet(this, _nodeProperty5, config == null ? void 0 : config.property);
2099
- __privateSet(this, _text5, (config == null ? void 0 : config.text) === void 0 ? "Toggle" : config == null ? void 0 : config.text);
2440
+ __privateSet(this, _text6, (config == null ? void 0 : config.text) === void 0 ? "Toggle" : config == null ? void 0 : config.text);
2100
2441
  __privateSet(this, _enabledStyle, new ToggleStyle({
2101
2442
  idle: TextBoxStyleWithFallback((_a = config == null ? void 0 : config.enabledStyle) == null ? void 0 : _a.idle, {
2102
2443
  box: {
@@ -2139,7 +2480,7 @@ var ToggleWidget = class {
2139
2480
  }
2140
2481
  Draw(ctx, position, scale, mousePosition) {
2141
2482
  let style = __privateGet(this, _value6) ? __privateGet(this, _enabledStyle) : __privateGet(this, _disabledStyle);
2142
- return style.Draw(ctx, position, scale, __privateGet(this, _text5), mousePosition);
2483
+ return style.Draw(ctx, position, scale, __privateGet(this, _text6), mousePosition);
2143
2484
  }
2144
2485
  Toggle() {
2145
2486
  this.Set(!__privateGet(this, _value6));
@@ -2165,21 +2506,21 @@ var ToggleWidget = class {
2165
2506
  _node6 = new WeakMap();
2166
2507
  _nodeProperty5 = new WeakMap();
2167
2508
  _value6 = new WeakMap();
2168
- _text5 = new WeakMap();
2509
+ _text6 = new WeakMap();
2169
2510
  _enabledStyle = new WeakMap();
2170
2511
  _disabledStyle = new WeakMap();
2171
2512
  _callback6 = new WeakMap();
2172
2513
 
2173
2514
  // src/widgets/image.ts
2174
- var _url, _image, _maxWidth, _maxHeight;
2515
+ var _url, _image, _maxWidth2, _maxHeight2;
2175
2516
  var ImageWidget = class {
2176
2517
  constructor(config) {
2177
2518
  __privateAdd(this, _url);
2178
2519
  __privateAdd(this, _image);
2179
- __privateAdd(this, _maxWidth);
2180
- __privateAdd(this, _maxHeight);
2181
- __privateSet(this, _maxWidth, (config == null ? void 0 : config.maxWidth) === void 0 ? 150 : config == null ? void 0 : config.maxWidth);
2182
- __privateSet(this, _maxHeight, (config == null ? void 0 : config.maxHeight) === void 0 ? 150 : config == null ? void 0 : config.maxHeight);
2520
+ __privateAdd(this, _maxWidth2);
2521
+ __privateAdd(this, _maxHeight2);
2522
+ __privateSet(this, _maxWidth2, (config == null ? void 0 : config.maxWidth) === void 0 ? 150 : config == null ? void 0 : config.maxWidth);
2523
+ __privateSet(this, _maxHeight2, (config == null ? void 0 : config.maxHeight) === void 0 ? 150 : config == null ? void 0 : config.maxHeight);
2183
2524
  if (config == null ? void 0 : config.image) {
2184
2525
  this.SetUrl(config == null ? void 0 : config.image);
2185
2526
  } else if (config == null ? void 0 : config.blob) {
@@ -2208,11 +2549,11 @@ var ImageWidget = class {
2208
2549
  return { "x": 0, "y": 0 };
2209
2550
  }
2210
2551
  let adjust = 1;
2211
- if (__privateGet(this, _image).width > __privateGet(this, _maxWidth)) {
2212
- adjust = __privateGet(this, _maxWidth) / __privateGet(this, _image).width;
2552
+ if (__privateGet(this, _image).width > __privateGet(this, _maxWidth2)) {
2553
+ adjust = __privateGet(this, _maxWidth2) / __privateGet(this, _image).width;
2213
2554
  }
2214
- if (__privateGet(this, _image).height > __privateGet(this, _maxHeight)) {
2215
- let heightAdjust = __privateGet(this, _maxHeight) / __privateGet(this, _image).height;
2555
+ if (__privateGet(this, _image).height > __privateGet(this, _maxHeight2)) {
2556
+ let heightAdjust = __privateGet(this, _maxHeight2) / __privateGet(this, _image).height;
2216
2557
  if (heightAdjust < adjust) {
2217
2558
  adjust = heightAdjust;
2218
2559
  }
@@ -2251,8 +2592,8 @@ var ImageWidget = class {
2251
2592
  };
2252
2593
  _url = new WeakMap();
2253
2594
  _image = new WeakMap();
2254
- _maxWidth = new WeakMap();
2255
- _maxHeight = new WeakMap();
2595
+ _maxWidth2 = new WeakMap();
2596
+ _maxHeight2 = new WeakMap();
2256
2597
 
2257
2598
  // src/widgets/text.ts
2258
2599
  var _value7, _callback7, _node7, _nodeProperty6, _size4;
@@ -3483,7 +3824,7 @@ function FormPopup(config) {
3483
3824
 
3484
3825
  // src/node.ts
3485
3826
  var MINIMUM_NODE_WIDTH = 150;
3486
- var _position, _title2, _subTitle, _infoSymbol, _infoText, _input, _output, _widgets, _locked, _canEditTitle, _canEditInfo, _canEditPorts, _contextMenu2, _metadata, _onSelect, _onUnselect, _onFiledrop, _onDragStop, _titleChangeCallback, _infoChangeCallback, _titleColor, _selectedStyle, _stateStyles, _padding, _portTextStyle, _elementSpacing, _selected, _inputPortPositions, _outputPortPositions, _widgetPositions, _data, _registeredAnyPropertyChangeCallbacks, _registeredPropertyChangeCallbacks, _FlowNode_instances, popupNodeTitleSelection_fn, popupNodeInfoSelection_fn, popupNewButtonWidget_fn, widgetSubmenu_fn, calculateStyle_fn;
3827
+ var _position, _title2, _subTitle, _infoSymbol, _infoText, _input, _output, _widgets, _locked, _canEditTitle, _canEditInfo, _canEditPorts, _contextMenu2, _metadata, _onSelect, _onUnselect, _onFiledrop, _onDragStop, _titleChangeCallback, _infoChangeCallback, _titleColor, _selectedStyle, _stateStyles, _padding2, _portTextStyle, _elementSpacing, _selected, _inputPortPositions, _outputPortPositions, _widgetPositions, _data, _registeredAnyPropertyChangeCallbacks, _registeredPropertyChangeCallbacks, _FlowNode_instances, popupNodeTitleSelection_fn, popupNodeInfoSelection_fn, popupNewButtonWidget_fn, widgetSubmenu_fn, calculateStyle_fn;
3487
3828
  var FlowNode = class {
3488
3829
  constructor(config) {
3489
3830
  __privateAdd(this, _FlowNode_instances);
@@ -3512,7 +3853,7 @@ var FlowNode = class {
3512
3853
  __privateAdd(this, _titleColor);
3513
3854
  __privateAdd(this, _selectedStyle);
3514
3855
  __privateAdd(this, _stateStyles);
3515
- __privateAdd(this, _padding);
3856
+ __privateAdd(this, _padding2);
3516
3857
  __privateAdd(this, _portTextStyle);
3517
3858
  __privateAdd(this, _elementSpacing);
3518
3859
  // Runtime ================================================================
@@ -3592,7 +3933,7 @@ var FlowNode = class {
3592
3933
  ));
3593
3934
  __privateSet(this, _infoText, (config == null ? void 0 : config.info) ? config == null ? void 0 : config.info : "");
3594
3935
  __privateSet(this, _titleColor, ((_f = (_e = config == null ? void 0 : config.style) == null ? void 0 : _e.title) == null ? void 0 : _f.color) === void 0 ? "#154050" : (_h = (_g = config == null ? void 0 : config.style) == null ? void 0 : _g.title) == null ? void 0 : _h.color);
3595
- __privateSet(this, _padding, ((_j = (_i = config == null ? void 0 : config.style) == null ? void 0 : _i.title) == null ? void 0 : _j.padding) === void 0 ? 15 : (_l = (_k = config == null ? void 0 : config.style) == null ? void 0 : _k.title) == null ? void 0 : _l.padding);
3936
+ __privateSet(this, _padding2, ((_j = (_i = config == null ? void 0 : config.style) == null ? void 0 : _i.title) == null ? void 0 : _j.padding) === void 0 ? 15 : (_l = (_k = config == null ? void 0 : config.style) == null ? void 0 : _k.title) == null ? void 0 : _l.padding);
3596
3937
  __privateSet(this, _stateStyles, /* @__PURE__ */ new Map());
3597
3938
  __privateGet(this, _stateStyles).set(0 /* Idle */, new BoxStyle(BoxStyleWithFallback((_m = config == null ? void 0 : config.style) == null ? void 0 : _m.idle, {
3598
3939
  border: { color: Theme.Node.Border.Idle, size: 1 },
@@ -3873,7 +4214,7 @@ var FlowNode = class {
3873
4214
  // }
3874
4215
  calculateBounds(ctx, camera) {
3875
4216
  const tempMeasurement = Zero();
3876
- const doublePadding = __privateGet(this, _padding) * 2;
4217
+ const doublePadding = __privateGet(this, _padding2) * 2;
3877
4218
  const screenSpacePosition = Zero();
3878
4219
  camera.graphSpaceToScreenSpace(__privateGet(this, _position), screenSpacePosition);
3879
4220
  const size = Zero();
@@ -4038,7 +4379,7 @@ var FlowNode = class {
4038
4379
  __privateGet(this, _inputPortPositions).Clear();
4039
4380
  __privateGet(this, _outputPortPositions).Clear();
4040
4381
  __privateGet(this, _widgetPositions).Clear();
4041
- const scaledPadding = __privateGet(this, _padding) * camera.zoom;
4382
+ const scaledPadding = __privateGet(this, _padding2) * camera.zoom;
4042
4383
  const scaledElementSpacing = __privateGet(this, _elementSpacing) * camera.zoom;
4043
4384
  const nodeBounds = this.calculateBounds(ctx, camera);
4044
4385
  const nodeStyle = __privateMethod(this, _FlowNode_instances, calculateStyle_fn).call(this, state);
@@ -4185,7 +4526,7 @@ _infoChangeCallback = new WeakMap();
4185
4526
  _titleColor = new WeakMap();
4186
4527
  _selectedStyle = new WeakMap();
4187
4528
  _stateStyles = new WeakMap();
4188
- _padding = new WeakMap();
4529
+ _padding2 = new WeakMap();
4189
4530
  _portTextStyle = new WeakMap();
4190
4531
  _elementSpacing = new WeakMap();
4191
4532
  _selected = new WeakMap();
@@ -4485,15 +4826,15 @@ text_fn = function() {
4485
4826
  };
4486
4827
 
4487
4828
  // src/markdown/entry.ts
4488
- var _text6, _calculatedPositions, _calculatedEntries, _calculatedForWidth, _CodeBlockEntry_instances, calculateLayout_fn;
4829
+ var _text7, _calculatedPositions, _calculatedEntries, _calculatedForWidth, _CodeBlockEntry_instances, calculateLayout_fn;
4489
4830
  var CodeBlockEntry = class {
4490
4831
  constructor(text) {
4491
4832
  __privateAdd(this, _CodeBlockEntry_instances);
4492
- __privateAdd(this, _text6);
4833
+ __privateAdd(this, _text7);
4493
4834
  __privateAdd(this, _calculatedPositions);
4494
4835
  __privateAdd(this, _calculatedEntries);
4495
4836
  __privateAdd(this, _calculatedForWidth);
4496
- __privateSet(this, _text6, text);
4837
+ __privateSet(this, _text7, text);
4497
4838
  __privateSet(this, _calculatedForWidth, -1);
4498
4839
  __privateSet(this, _calculatedEntries, new List());
4499
4840
  __privateSet(this, _calculatedPositions, new List());
@@ -4532,7 +4873,7 @@ var CodeBlockEntry = class {
4532
4873
  return max + padding * 2;
4533
4874
  }
4534
4875
  };
4535
- _text6 = new WeakMap();
4876
+ _text7 = new WeakMap();
4536
4877
  _calculatedPositions = new WeakMap();
4537
4878
  _calculatedEntries = new WeakMap();
4538
4879
  _calculatedForWidth = new WeakMap();
@@ -4546,8 +4887,8 @@ calculateLayout_fn = function(ctx, maxWidth) {
4546
4887
  __privateGet(this, _calculatedEntries).Clear();
4547
4888
  __privateGet(this, _calculatedPositions).Clear();
4548
4889
  let curHeight = 0;
4549
- const lineInc = __privateGet(this, _text6).style().getSize() + Theme.Note.LineSpacing;
4550
- let entries = __privateGet(this, _text6).split("\n");
4890
+ const lineInc = __privateGet(this, _text7).style().getSize() + Theme.Note.LineSpacing;
4891
+ let entries = __privateGet(this, _text7).split("\n");
4551
4892
  for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
4552
4893
  const entry = entries[entryIndex];
4553
4894
  let lines = entry.breakIntoLines(ctx, adjustedWith);
@@ -5334,404 +5675,114 @@ var NoteSubsystem = class {
5334
5675
  return false;
5335
5676
  }
5336
5677
  clickEnd() {
5337
- if (__privateGet(this, _noteSelected) !== null) {
5338
- __privateGet(this, _noteSelected).selectHandle(0 /* None */);
5339
- for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
5340
- __privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
5341
- }
5342
- }
5343
- __privateSet(this, _noteSelected, null);
5344
- }
5345
- mouseDragEvent(delta, scale) {
5346
- if (__privateGet(this, _noteSelected) === null) {
5347
- return false;
5348
- }
5349
- if (__privateGet(this, _noteSelected).handleSelected()) {
5350
- return true;
5351
- }
5352
- __privateGet(this, _noteSelected).translate({
5353
- x: delta.x * (1 / scale),
5354
- y: delta.y * (1 / scale)
5355
- });
5356
- return true;
5357
- }
5358
- fileDrop(file) {
5359
- return false;
5360
- }
5361
- removeNote(note) {
5362
- const index = __privateGet(this, _notes).indexOf(note);
5363
- if (index > -1) {
5364
- const noteRemoved = __privateGet(this, _notes)[index];
5365
- __privateGet(this, _notes).splice(index, 1);
5366
- for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
5367
- __privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
5368
- }
5369
- } else {
5370
- console.error("no note found to remove");
5371
- }
5372
- }
5373
- render(ctx, camera, mousePosition) {
5374
- __privateSet(this, _noteHovering, null);
5375
- __privateSet(this, _hoveringHandle, 0 /* None */);
5376
- if (mousePosition) {
5377
- for (let i = 0; i < __privateGet(this, _notes).length; i++) {
5378
- __privateGet(this, _notes)[i].setHovering(false);
5379
- if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
5380
- __privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
5381
- }
5382
- }
5383
- }
5384
- if (__privateGet(this, _noteHovering) != null) {
5385
- __privateGet(this, _noteHovering).setHovering(true);
5386
- if (mousePosition) {
5387
- if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
5388
- __privateSet(this, _hoveringHandle, 1 /* Left */);
5389
- } else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
5390
- __privateSet(this, _hoveringHandle, 2 /* Right */);
5391
- }
5392
- }
5393
- }
5394
- for (let i = 0; i < __privateGet(this, _notes).length; i++) {
5395
- __privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
5396
- }
5397
- return;
5398
- }
5399
- };
5400
- _notes = new WeakMap();
5401
- _noteHovering = new WeakMap();
5402
- _noteSelected = new WeakMap();
5403
- _hoveringHandle = new WeakMap();
5404
- _onNoteAddedCallbacks = new WeakMap();
5405
- _onNoteRemovedCallbacks = new WeakMap();
5406
- _onNoteDragStartCallbacks = new WeakMap();
5407
- _onNoteDragStopCallbacks = new WeakMap();
5408
-
5409
- // src/pass/subsystem.ts
5410
- var _queue;
5411
- var PassSubsystem = class {
5412
- constructor() {
5413
- __privateAdd(this, _queue);
5414
- __privateSet(this, _queue, new List());
5415
- }
5416
- queue(lambda) {
5417
- if (!lambda) {
5418
- return;
5419
- }
5420
- __privateGet(this, _queue).Push(lambda);
5421
- }
5422
- render(ctx, camera, mousePosition) {
5423
- for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
5424
- __privateGet(this, _queue).At(i)();
5425
- }
5426
- __privateGet(this, _queue).Clear();
5427
- return;
5428
- }
5429
- openContextMenu(ctx, position) {
5430
- return null;
5431
- }
5432
- clickStart(mousePosition, camera, ctrlKey) {
5433
- return false;
5434
- }
5435
- mouseDragEvent(delta, scale) {
5436
- return false;
5437
- }
5438
- fileDrop(file) {
5439
- return false;
5440
- }
5441
- clickEnd() {
5442
- }
5443
- };
5444
- _queue = new WeakMap();
5445
-
5446
- // src/elements/interfaces.ts
5447
- function InstantiateRenderElementSidesStyling(config) {
5448
- if (typeof config === "number") {
5449
- return {
5450
- Bottom: config,
5451
- Right: config,
5452
- Top: config,
5453
- Left: config
5454
- };
5455
- }
5456
- return {
5457
- Bottom: (config == null ? void 0 : config.Bottom) === void 0 ? 0 : config == null ? void 0 : config.Bottom,
5458
- Right: (config == null ? void 0 : config.Right) === void 0 ? 0 : config == null ? void 0 : config.Right,
5459
- Left: (config == null ? void 0 : config.Left) === void 0 ? 0 : config == null ? void 0 : config.Left,
5460
- Top: (config == null ? void 0 : config.Top) === void 0 ? 0 : config == null ? void 0 : config.Top
5461
- };
5462
- }
5463
-
5464
- // src/elements/base.ts
5465
- var _margin, _padding2, _border2, _backgroundColor2, _minWidth, _maxWidth2, _minHeight, _maxHeight2, _grow, _display, _RenderElementBase_instances, horizontalOffset_fn, verticalOffset_fn, totalTopOffset_fn, totalLeftOffset_fn;
5466
- var RenderElementBase = class {
5467
- constructor(config) {
5468
- __privateAdd(this, _RenderElementBase_instances);
5469
- __privateAdd(this, _margin);
5470
- __privateAdd(this, _padding2);
5471
- __privateAdd(this, _border2);
5472
- __privateAdd(this, _backgroundColor2);
5473
- __privateAdd(this, _minWidth);
5474
- __privateAdd(this, _maxWidth2);
5475
- __privateAdd(this, _minHeight);
5476
- __privateAdd(this, _maxHeight2);
5477
- __privateAdd(this, _grow);
5478
- __privateAdd(this, _display);
5479
- var _a, _b, _c, _d, _e, _f, _g;
5480
- __privateSet(this, _margin, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Margin));
5481
- __privateSet(this, _padding2, InstantiateRenderElementSidesStyling(config == null ? void 0 : config.Padding));
5482
- __privateSet(this, _backgroundColor2, config == null ? void 0 : config.BackgroundColor);
5483
- __privateSet(this, _border2, {
5484
- Color: (_b = (_a = config == null ? void 0 : config.Border) == null ? void 0 : _a.Color) != null ? _b : "black",
5485
- Thickness: (_d = (_c = config == null ? void 0 : config.Border) == null ? void 0 : _c.Thickness) != null ? _d : 0,
5486
- Radius: (_f = (_e = config == null ? void 0 : config.Border) == null ? void 0 : _e.Radius) != null ? _f : 0
5487
- });
5488
- __privateSet(this, _minWidth, config == null ? void 0 : config.MinWidth);
5489
- __privateSet(this, _maxWidth2, config == null ? void 0 : config.MaxWidth);
5490
- __privateSet(this, _minHeight, config == null ? void 0 : config.MinHeight);
5491
- __privateSet(this, _maxHeight2, config == null ? void 0 : config.MaxHeight);
5492
- __privateSet(this, _grow, config == null ? void 0 : config.Grow);
5493
- __privateSet(this, _display, (_g = config == null ? void 0 : config.Display) != null ? _g : "flex" /* Flex */);
5494
- }
5495
- setBackgroundColor(newColor) {
5496
- __privateSet(this, _backgroundColor2, newColor);
5497
- }
5498
- render(ctx, position, graphScale, scaledFillableSpace) {
5499
- if (__privateGet(this, _display) === "none" /* None */) {
5500
- return;
5501
- }
5502
- const scaledSize = { x: 0, y: 0 };
5503
- this.size(ctx, scaledSize);
5504
- scaledSize.x = scaledSize.x * graphScale;
5505
- scaledSize.y = scaledSize.y * graphScale;
5506
- scaledSize.x = Math.max(scaledSize.x, scaledFillableSpace.x);
5507
- scaledSize.y = Math.max(scaledSize.y, scaledFillableSpace.y);
5508
- if (__privateGet(this, _backgroundColor2)) {
5509
- ctx.fillStyle = __privateGet(this, _backgroundColor2);
5510
- ctx.beginPath();
5511
- ctx.roundRect(
5512
- position.x + __privateGet(this, _margin).Left * graphScale,
5513
- position.y + __privateGet(this, _margin).Right * graphScale,
5514
- scaledSize.x - (__privateGet(this, _margin).Left + __privateGet(this, _margin).Right) * graphScale,
5515
- scaledSize.y - (__privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom) * graphScale,
5516
- __privateGet(this, _border2).Radius * graphScale
5517
- );
5518
- ctx.fill();
5519
- }
5520
- if (__privateGet(this, _border2).Thickness > 0) {
5521
- ctx.lineWidth = __privateGet(this, _border2).Thickness * graphScale;
5522
- ctx.strokeStyle = __privateGet(this, _border2).Color;
5523
- ctx.stroke();
5678
+ if (__privateGet(this, _noteSelected) !== null) {
5679
+ __privateGet(this, _noteSelected).selectHandle(0 /* None */);
5680
+ for (let i = 0; i < __privateGet(this, _onNoteDragStopCallbacks).length; i++) {
5681
+ __privateGet(this, _onNoteDragStopCallbacks)[i](__privateGet(this, _noteSelected));
5682
+ }
5524
5683
  }
5525
- const offsetPosition = {
5526
- x: position.x + __privateMethod(this, _RenderElementBase_instances, totalLeftOffset_fn).call(this) * graphScale,
5527
- y: position.y + __privateMethod(this, _RenderElementBase_instances, totalTopOffset_fn).call(this) * graphScale
5528
- };
5529
- const elementSize = {
5530
- x: scaledSize.x - __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this) * graphScale,
5531
- y: scaledSize.y - __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this) * graphScale
5532
- };
5533
- this.doRender(ctx, offsetPosition, graphScale, elementSize);
5684
+ __privateSet(this, _noteSelected, null);
5534
5685
  }
5535
- maxLimitations(out) {
5536
- out.x = -1;
5537
- out.y = -1;
5538
- if (__privateGet(this, _maxWidth2)) {
5539
- out.x = __privateGet(this, _maxWidth2);
5686
+ mouseDragEvent(delta, scale) {
5687
+ if (__privateGet(this, _noteSelected) === null) {
5688
+ return false;
5540
5689
  }
5541
- if (__privateGet(this, _maxHeight2)) {
5542
- out.y = __privateGet(this, _maxHeight2);
5690
+ if (__privateGet(this, _noteSelected).handleSelected()) {
5691
+ return true;
5543
5692
  }
5693
+ __privateGet(this, _noteSelected).translate({
5694
+ x: delta.x * (1 / scale),
5695
+ y: delta.y * (1 / scale)
5696
+ });
5697
+ return true;
5544
5698
  }
5545
- setDisplay(display) {
5546
- __privateSet(this, _display, display);
5547
- }
5548
- getDisplay() {
5549
- return __privateGet(this, _display);
5699
+ fileDrop(file) {
5700
+ return false;
5550
5701
  }
5551
- size(ctx, out) {
5552
- out.x = 0;
5553
- out.y = 0;
5554
- if (__privateGet(this, _display) === "none" /* None */) {
5555
- return;
5556
- }
5557
- const maxLimits = { x: -1, y: -1 };
5558
- this.maxLimitations(maxLimits);
5559
- this.calcSize(ctx, out, maxLimits);
5560
- out.x += __privateMethod(this, _RenderElementBase_instances, horizontalOffset_fn).call(this);
5561
- out.y += __privateMethod(this, _RenderElementBase_instances, verticalOffset_fn).call(this);
5562
- if (__privateGet(this, _minWidth)) {
5563
- out.x = Math.max(out.x, __privateGet(this, _minWidth));
5702
+ removeNote(note) {
5703
+ const index = __privateGet(this, _notes).indexOf(note);
5704
+ if (index > -1) {
5705
+ const noteRemoved = __privateGet(this, _notes)[index];
5706
+ __privateGet(this, _notes).splice(index, 1);
5707
+ for (let i = 0; i < __privateGet(this, _onNoteRemovedCallbacks).length; i++) {
5708
+ __privateGet(this, _onNoteRemovedCallbacks)[i](noteRemoved);
5709
+ }
5710
+ } else {
5711
+ console.error("no note found to remove");
5564
5712
  }
5565
- if (__privateGet(this, _maxWidth2)) {
5566
- out.x = Math.min(__privateGet(this, _maxWidth2), out.x);
5713
+ }
5714
+ render(ctx, camera, mousePosition) {
5715
+ __privateSet(this, _noteHovering, null);
5716
+ __privateSet(this, _hoveringHandle, 0 /* None */);
5717
+ if (mousePosition) {
5718
+ for (let i = 0; i < __privateGet(this, _notes).length; i++) {
5719
+ __privateGet(this, _notes)[i].setHovering(false);
5720
+ if (InBox(__privateGet(this, _notes)[i].bounds(), mousePosition)) {
5721
+ __privateSet(this, _noteHovering, __privateGet(this, _notes)[i]);
5722
+ }
5723
+ }
5567
5724
  }
5568
- if (__privateGet(this, _maxHeight2)) {
5569
- out.y = Math.min(__privateGet(this, _maxHeight2), out.y);
5725
+ if (__privateGet(this, _noteHovering) != null) {
5726
+ __privateGet(this, _noteHovering).setHovering(true);
5727
+ if (mousePosition) {
5728
+ if (InBox(__privateGet(this, _noteHovering).leftResizeHandleBox(), mousePosition)) {
5729
+ __privateSet(this, _hoveringHandle, 1 /* Left */);
5730
+ } else if (InBox(__privateGet(this, _noteHovering).rightResizeHandleBox(), mousePosition)) {
5731
+ __privateSet(this, _hoveringHandle, 2 /* Right */);
5732
+ }
5733
+ }
5570
5734
  }
5571
- if (__privateGet(this, _minHeight)) {
5572
- out.y = Math.max(__privateGet(this, _minHeight), out.y);
5735
+ for (let i = 0; i < __privateGet(this, _notes).length; i++) {
5736
+ __privateGet(this, _notes)[i].render(ctx, camera, mousePosition);
5573
5737
  }
5738
+ return;
5574
5739
  }
5575
5740
  };
5576
- _margin = new WeakMap();
5577
- _padding2 = new WeakMap();
5578
- _border2 = new WeakMap();
5579
- _backgroundColor2 = new WeakMap();
5580
- _minWidth = new WeakMap();
5581
- _maxWidth2 = new WeakMap();
5582
- _minHeight = new WeakMap();
5583
- _maxHeight2 = new WeakMap();
5584
- _grow = new WeakMap();
5585
- _display = new WeakMap();
5586
- _RenderElementBase_instances = new WeakSet();
5587
- horizontalOffset_fn = function() {
5588
- return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Left + __privateGet(this, _margin).Right + __privateGet(this, _padding2).Left + __privateGet(this, _padding2).Right;
5589
- };
5590
- verticalOffset_fn = function() {
5591
- return __privateGet(this, _border2).Thickness + __privateGet(this, _margin).Top + __privateGet(this, _margin).Bottom + __privateGet(this, _padding2).Top + __privateGet(this, _padding2).Bottom;
5592
- };
5593
- totalTopOffset_fn = function() {
5594
- return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Top + __privateGet(this, _padding2).Top;
5595
- };
5596
- totalLeftOffset_fn = function() {
5597
- return __privateGet(this, _border2).Thickness / 2 + __privateGet(this, _margin).Left + __privateGet(this, _padding2).Left;
5598
- };
5741
+ _notes = new WeakMap();
5742
+ _noteHovering = new WeakMap();
5743
+ _noteSelected = new WeakMap();
5744
+ _hoveringHandle = new WeakMap();
5745
+ _onNoteAddedCallbacks = new WeakMap();
5746
+ _onNoteRemovedCallbacks = new WeakMap();
5747
+ _onNoteDragStartCallbacks = new WeakMap();
5748
+ _onNoteDragStopCallbacks = new WeakMap();
5599
5749
 
5600
- // src/elements/container.ts
5601
- var _elements, _layout, _alignment, _ContainerRenderElement_instances, renderColumn_fn;
5602
- var ContainerRenderElement = class extends RenderElementBase {
5603
- constructor(elements, config) {
5604
- super(config);
5605
- __privateAdd(this, _ContainerRenderElement_instances);
5606
- __privateAdd(this, _elements);
5607
- __privateAdd(this, _layout);
5608
- __privateAdd(this, _alignment);
5609
- __privateSet(this, _elements, elements);
5610
- __privateSet(this, _layout, "column" /* Column */);
5611
- __privateSet(this, _alignment, "stretch" /* Stretch */);
5750
+ // src/pass/subsystem.ts
5751
+ var _queue;
5752
+ var PassSubsystem = class {
5753
+ constructor() {
5754
+ __privateAdd(this, _queue);
5755
+ __privateSet(this, _queue, new List());
5612
5756
  }
5613
- calcSize(ctx, out, limitations) {
5614
- out.x = 0;
5615
- out.y = 0;
5616
- const eleSize = { x: 0, y: 0 };
5617
- switch (__privateGet(this, _layout)) {
5618
- case "column" /* Column */:
5619
- for (let i = 0; i < __privateGet(this, _elements).length; i++) {
5620
- __privateGet(this, _elements)[i].size(ctx, eleSize);
5621
- out.x = Math.max(out.x, eleSize.x);
5622
- out.y += eleSize.y;
5623
- }
5624
- break;
5625
- case "row" /* Row */:
5626
- for (let i = 0; i < __privateGet(this, _elements).length; i++) {
5627
- __privateGet(this, _elements)[i].size(ctx, eleSize);
5628
- out.y = Math.max(out.y, eleSize.y);
5629
- out.x += eleSize.x;
5630
- }
5631
- break;
5632
- default:
5633
- throw new Error("unknown layout: " + __privateGet(this, _layout));
5757
+ queue(lambda) {
5758
+ if (!lambda) {
5759
+ return;
5634
5760
  }
5761
+ __privateGet(this, _queue).Push(lambda);
5635
5762
  }
5636
- doRender(ctx, position, graphScale, scaledFillableSpace) {
5637
- switch (__privateGet(this, _layout)) {
5638
- case "column" /* Column */:
5639
- __privateMethod(this, _ContainerRenderElement_instances, renderColumn_fn).call(this, ctx, position, graphScale, scaledFillableSpace);
5640
- break;
5641
- default:
5642
- throw new Error("unimplemented layout direction: " + __privateGet(this, _layout));
5763
+ render(ctx, camera, mousePosition) {
5764
+ for (let i = 0; i < __privateGet(this, _queue).Count(); i++) {
5765
+ __privateGet(this, _queue).At(i)();
5643
5766
  }
5767
+ __privateGet(this, _queue).Clear();
5768
+ return;
5644
5769
  }
5645
- };
5646
- _elements = new WeakMap();
5647
- _layout = new WeakMap();
5648
- _alignment = new WeakMap();
5649
- _ContainerRenderElement_instances = new WeakSet();
5650
- renderColumn_fn = function(ctx, position, graphScale, scaledFillableSpace) {
5651
- const currnetPos = { x: position.x, y: position.y };
5652
- const scaledEleSize = { x: 0, y: 0 };
5653
- for (let i = 0; i < __privateGet(this, _elements).length; i++) {
5654
- const ele = __privateGet(this, _elements)[i];
5655
- ele.size(ctx, scaledEleSize);
5656
- ScaleVector(scaledEleSize, graphScale);
5657
- switch (__privateGet(this, _alignment)) {
5658
- case "stretch" /* Stretch */:
5659
- currnetPos.x = position.x;
5660
- scaledEleSize.x = scaledFillableSpace.x;
5661
- break;
5662
- // I'm not sure if this is even needed, I feel like this should
5663
- // already be the case.
5664
- case "start" /* Start */:
5665
- currnetPos.x = position.x;
5666
- break;
5667
- case "end" /* End */:
5668
- currnetPos.x = scaledFillableSpace.x - scaledEleSize.x;
5669
- break;
5670
- case "center" /* Center */:
5671
- currnetPos.x = scaledFillableSpace.x - scaledEleSize.x / 2;
5672
- break;
5673
- default:
5674
- throw new Error("unimplmeneted alignment: " + __privateGet(this, _alignment));
5675
- }
5676
- ele.render(ctx, currnetPos, graphScale, scaledEleSize);
5677
- currnetPos.y += scaledEleSize.y;
5770
+ openContextMenu(ctx, position) {
5771
+ return null;
5678
5772
  }
5679
- };
5680
-
5681
- // src/elements/text.ts
5682
- var _text7, _align, _verticalAlign;
5683
- var TextElement = class extends RenderElementBase {
5684
- constructor(text, styling) {
5685
- var _a, _b;
5686
- super(styling);
5687
- __privateAdd(this, _text7);
5688
- __privateAdd(this, _align);
5689
- __privateAdd(this, _verticalAlign);
5690
- __privateSet(this, _text7, text);
5691
- __privateSet(this, _align, (_a = styling == null ? void 0 : styling.Align) != null ? _a : "left" /* Left */);
5692
- __privateSet(this, _verticalAlign, (_b = styling == null ? void 0 : styling.VerticalAlign) != null ? _b : "top" /* Top */);
5773
+ clickStart(mousePosition, camera, ctrlKey) {
5774
+ return false;
5693
5775
  }
5694
- doRender(ctx, position, graphScale, scaledFillableSpace) {
5695
- const scale = Zero();
5696
- this.calcSize(ctx, scale);
5697
- ScaleVector(scale, graphScale);
5698
- const justifiedPosition = Zero();
5699
- CopyVector2(justifiedPosition, position);
5700
- ctx.textAlign = "left";
5701
- ctx.textBaseline = "top";
5702
- switch (__privateGet(this, _align)) {
5703
- case "left" /* Left */:
5704
- break;
5705
- case "right" /* Right */:
5706
- justifiedPosition.x += scaledFillableSpace.x - scale.x;
5707
- break;
5708
- case "center" /* Center */:
5709
- justifiedPosition.x += (scaledFillableSpace.x - scale.x) / 2;
5710
- break;
5711
- default:
5712
- throw new Error("unimplemented justification: " + __privateGet(this, _align));
5713
- }
5714
- switch (__privateGet(this, _verticalAlign)) {
5715
- case "top" /* Top */:
5716
- break;
5717
- case "bottom" /* Bottom */:
5718
- justifiedPosition.y += scaledFillableSpace.y - scale.y;
5719
- break;
5720
- case "center" /* Center */:
5721
- justifiedPosition.y += (scaledFillableSpace.y - scale.y) / 2;
5722
- break;
5723
- default:
5724
- throw new Error("unimplemented justification: " + __privateGet(this, _align));
5725
- }
5726
- __privateGet(this, _text7).render(ctx, graphScale, justifiedPosition);
5776
+ mouseDragEvent(delta, scale) {
5777
+ return false;
5727
5778
  }
5728
- calcSize(ctx, out) {
5729
- __privateGet(this, _text7).size(ctx, 1, out);
5779
+ fileDrop(file) {
5780
+ return false;
5781
+ }
5782
+ clickEnd() {
5730
5783
  }
5731
5784
  };
5732
- _text7 = new WeakMap();
5733
- _align = new WeakMap();
5734
- _verticalAlign = new WeakMap();
5785
+ _queue = new WeakMap();
5735
5786
 
5736
5787
  // src/quickMenu.ts
5737
5788
  var _text8;