sldeditor 0.6.0 → 0.6.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.
package/dist/sldeditor.js CHANGED
@@ -727,9 +727,9 @@ const Yn = "-", hv = (e) => {
727
727
  if (i.includes(k))
728
728
  continue;
729
729
  i.push(k);
730
- const b = r(g, h);
731
- for (let S = 0; S < b.length; ++S) {
732
- const C = b[S];
730
+ const x = r(g, h);
731
+ for (let $ = 0; $ < x.length; ++$) {
732
+ const C = x[$];
733
733
  i.push(E + C);
734
734
  }
735
735
  a = d + (a.length > 0 ? " " + a : a);
@@ -767,10 +767,10 @@ function Nv(e, ...t) {
767
767
  return i(Sv.apply(null, arguments));
768
768
  };
769
769
  }
770
- const le = (e) => {
770
+ const ce = (e) => {
771
771
  const t = (n) => n[e] || [];
772
772
  return t.isThemeGetter = !0, t;
773
- }, Zr = /^\[(?:([a-z-]+):)?(.+)\]$/i, Ev = /^\d+\/\d+$/, Mv = /* @__PURE__ */ new Set(["px", "full", "screen"]), Tv = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, Av = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, Cv = /^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/, Iv = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, Pv = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, Le = (e) => lt(e) || Mv.has(e) || Ev.test(e), We = (e) => mt(e, "length", Fv), lt = (e) => !!e && !Number.isNaN(Number(e)), hn = (e) => mt(e, "number", lt), xt = (e) => !!e && Number.isInteger(Number(e)), Ov = (e) => e.endsWith("%") && lt(e.slice(0, -1)), U = (e) => Zr.test(e), qe = (e) => Tv.test(e), Bv = /* @__PURE__ */ new Set(["length", "size", "percentage"]), jv = (e) => mt(e, Bv, Qr), Lv = (e) => mt(e, "position", Qr), zv = /* @__PURE__ */ new Set(["image", "url"]), Dv = (e) => mt(e, zv, Wv), Rv = (e) => mt(e, "", Hv), wt = () => !0, mt = (e, t, n) => {
773
+ }, Zr = /^\[(?:([a-z-]+):)?(.+)\]$/i, Ev = /^\d+\/\d+$/, Mv = /* @__PURE__ */ new Set(["px", "full", "screen"]), Tv = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, Av = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, Cv = /^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/, Iv = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, Pv = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, ze = (e) => lt(e) || Mv.has(e) || Ev.test(e), qe = (e) => mt(e, "length", Fv), lt = (e) => !!e && !Number.isNaN(Number(e)), hn = (e) => mt(e, "number", lt), xt = (e) => !!e && Number.isInteger(Number(e)), Ov = (e) => e.endsWith("%") && lt(e.slice(0, -1)), U = (e) => Zr.test(e), Ge = (e) => Tv.test(e), Bv = /* @__PURE__ */ new Set(["length", "size", "percentage"]), jv = (e) => mt(e, Bv, Qr), Lv = (e) => mt(e, "position", Qr), zv = /* @__PURE__ */ new Set(["image", "url"]), Dv = (e) => mt(e, zv, Wv), Rv = (e) => mt(e, "", Hv), wt = () => !0, mt = (e, t, n) => {
774
774
  const o = Zr.exec(e);
775
775
  return o ? o[1] ? typeof t == "string" ? o[1] === t : t.has(o[1]) : n(o[2]) : !1;
776
776
  }, Fv = (e) => (
@@ -779,17 +779,17 @@ const le = (e) => {
779
779
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
780
780
  Av.test(e) && !Cv.test(e)
781
781
  ), Qr = () => !1, Hv = (e) => Iv.test(e), Wv = (e) => Pv.test(e), qv = () => {
782
- const e = le("colors"), t = le("spacing"), n = le("blur"), o = le("brightness"), r = le("borderColor"), i = le("borderRadius"), s = le("borderSpacing"), a = le("borderWidth"), l = le("contrast"), d = le("grayscale"), c = le("hueRotate"), u = le("invert"), f = le("gap"), p = le("gradientColorStops"), h = le("gradientColorStopPositions"), g = le("inset"), w = le("margin"), E = le("opacity"), k = le("padding"), b = le("saturate"), S = le("scale"), C = le("sepia"), j = le("skew"), q = le("space"), V = le("translate"), ie = () => ["auto", "contain", "none"], se = () => ["auto", "hidden", "clip", "visible", "scroll"], D = () => ["auto", U, t], F = () => [U, t], Z = () => ["", Le, We], ae = () => ["auto", lt, U], ce = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], Q = () => ["solid", "dashed", "dotted", "double", "none"], ye = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], be = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], xe = () => ["", "0", U], Be = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Ee = () => [lt, U];
782
+ const e = ce("colors"), t = ce("spacing"), n = ce("blur"), o = ce("brightness"), r = ce("borderColor"), i = ce("borderRadius"), s = ce("borderSpacing"), a = ce("borderWidth"), l = ce("contrast"), d = ce("grayscale"), c = ce("hueRotate"), u = ce("invert"), f = ce("gap"), p = ce("gradientColorStops"), h = ce("gradientColorStopPositions"), g = ce("inset"), w = ce("margin"), E = ce("opacity"), k = ce("padding"), x = ce("saturate"), $ = ce("scale"), C = ce("sepia"), j = ce("skew"), W = ce("space"), K = ce("translate"), re = () => ["auto", "contain", "none"], ae = () => ["auto", "hidden", "clip", "visible", "scroll"], D = () => ["auto", U, t], F = () => [U, t], Z = () => ["", ze, qe], le = () => ["auto", lt, U], de = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], Q = () => ["solid", "dashed", "dotted", "double", "none"], ye = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], be = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], xe = () => ["", "0", U], Be = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Ee = () => [lt, U];
783
783
  return {
784
784
  cacheSize: 500,
785
785
  separator: ":",
786
786
  theme: {
787
787
  colors: [wt],
788
- spacing: [Le, We],
789
- blur: ["none", "", qe, U],
788
+ spacing: [ze, qe],
789
+ blur: ["none", "", Ge, U],
790
790
  brightness: Ee(),
791
791
  borderColor: [e],
792
- borderRadius: ["none", "", "full", qe, U],
792
+ borderRadius: ["none", "", "full", Ge, U],
793
793
  borderSpacing: F(),
794
794
  borderWidth: Z(),
795
795
  contrast: Ee(),
@@ -798,7 +798,7 @@ const le = (e) => {
798
798
  invert: xe(),
799
799
  gap: F(),
800
800
  gradientColorStops: [e],
801
- gradientColorStopPositions: [Ov, We],
801
+ gradientColorStopPositions: [Ov, qe],
802
802
  inset: D(),
803
803
  margin: D(),
804
804
  opacity: Ee(),
@@ -829,7 +829,7 @@ const le = (e) => {
829
829
  * @see https://tailwindcss.com/docs/columns
830
830
  */
831
831
  columns: [{
832
- columns: [qe]
832
+ columns: [Ge]
833
833
  }],
834
834
  /**
835
835
  * Break After
@@ -902,49 +902,49 @@ const le = (e) => {
902
902
  * @see https://tailwindcss.com/docs/object-position
903
903
  */
904
904
  "object-position": [{
905
- object: [...ce(), U]
905
+ object: [...de(), U]
906
906
  }],
907
907
  /**
908
908
  * Overflow
909
909
  * @see https://tailwindcss.com/docs/overflow
910
910
  */
911
911
  overflow: [{
912
- overflow: se()
912
+ overflow: ae()
913
913
  }],
914
914
  /**
915
915
  * Overflow X
916
916
  * @see https://tailwindcss.com/docs/overflow
917
917
  */
918
918
  "overflow-x": [{
919
- "overflow-x": se()
919
+ "overflow-x": ae()
920
920
  }],
921
921
  /**
922
922
  * Overflow Y
923
923
  * @see https://tailwindcss.com/docs/overflow
924
924
  */
925
925
  "overflow-y": [{
926
- "overflow-y": se()
926
+ "overflow-y": ae()
927
927
  }],
928
928
  /**
929
929
  * Overscroll Behavior
930
930
  * @see https://tailwindcss.com/docs/overscroll-behavior
931
931
  */
932
932
  overscroll: [{
933
- overscroll: ie()
933
+ overscroll: re()
934
934
  }],
935
935
  /**
936
936
  * Overscroll Behavior X
937
937
  * @see https://tailwindcss.com/docs/overscroll-behavior
938
938
  */
939
939
  "overscroll-x": [{
940
- "overscroll-x": ie()
940
+ "overscroll-x": re()
941
941
  }],
942
942
  /**
943
943
  * Overscroll Behavior Y
944
944
  * @see https://tailwindcss.com/docs/overscroll-behavior
945
945
  */
946
946
  "overscroll-y": [{
947
- "overscroll-y": ie()
947
+ "overscroll-y": re()
948
948
  }],
949
949
  /**
950
950
  * Position
@@ -1097,14 +1097,14 @@ const le = (e) => {
1097
1097
  * @see https://tailwindcss.com/docs/grid-column
1098
1098
  */
1099
1099
  "col-start": [{
1100
- "col-start": ae()
1100
+ "col-start": le()
1101
1101
  }],
1102
1102
  /**
1103
1103
  * Grid Column End
1104
1104
  * @see https://tailwindcss.com/docs/grid-column
1105
1105
  */
1106
1106
  "col-end": [{
1107
- "col-end": ae()
1107
+ "col-end": le()
1108
1108
  }],
1109
1109
  /**
1110
1110
  * Grid Template Rows
@@ -1127,14 +1127,14 @@ const le = (e) => {
1127
1127
  * @see https://tailwindcss.com/docs/grid-row
1128
1128
  */
1129
1129
  "row-start": [{
1130
- "row-start": ae()
1130
+ "row-start": le()
1131
1131
  }],
1132
1132
  /**
1133
1133
  * Grid Row End
1134
1134
  * @see https://tailwindcss.com/docs/grid-row
1135
1135
  */
1136
1136
  "row-end": [{
1137
- "row-end": ae()
1137
+ "row-end": le()
1138
1138
  }],
1139
1139
  /**
1140
1140
  * Grid Auto Flow
@@ -1373,7 +1373,7 @@ const le = (e) => {
1373
1373
  * @see https://tailwindcss.com/docs/space
1374
1374
  */
1375
1375
  "space-x": [{
1376
- "space-x": [q]
1376
+ "space-x": [W]
1377
1377
  }],
1378
1378
  /**
1379
1379
  * Space Between X Reverse
@@ -1385,7 +1385,7 @@ const le = (e) => {
1385
1385
  * @see https://tailwindcss.com/docs/space
1386
1386
  */
1387
1387
  "space-y": [{
1388
- "space-y": [q]
1388
+ "space-y": [W]
1389
1389
  }],
1390
1390
  /**
1391
1391
  * Space Between Y Reverse
@@ -1413,8 +1413,8 @@ const le = (e) => {
1413
1413
  */
1414
1414
  "max-w": [{
1415
1415
  "max-w": [U, t, "none", "full", "min", "max", "fit", "prose", {
1416
- screen: [qe]
1417
- }, qe]
1416
+ screen: [Ge]
1417
+ }, Ge]
1418
1418
  }],
1419
1419
  /**
1420
1420
  * Height
@@ -1450,7 +1450,7 @@ const le = (e) => {
1450
1450
  * @see https://tailwindcss.com/docs/font-size
1451
1451
  */
1452
1452
  "font-size": [{
1453
- text: ["base", qe, We]
1453
+ text: ["base", Ge, qe]
1454
1454
  }],
1455
1455
  /**
1456
1456
  * Font Smoothing
@@ -1525,7 +1525,7 @@ const le = (e) => {
1525
1525
  * @see https://tailwindcss.com/docs/line-height
1526
1526
  */
1527
1527
  leading: [{
1528
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Le, U]
1528
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", ze, U]
1529
1529
  }],
1530
1530
  /**
1531
1531
  * List Style Image
@@ -1601,14 +1601,14 @@ const le = (e) => {
1601
1601
  * @see https://tailwindcss.com/docs/text-decoration-thickness
1602
1602
  */
1603
1603
  "text-decoration-thickness": [{
1604
- decoration: ["auto", "from-font", Le, We]
1604
+ decoration: ["auto", "from-font", ze, qe]
1605
1605
  }],
1606
1606
  /**
1607
1607
  * Text Underline Offset
1608
1608
  * @see https://tailwindcss.com/docs/text-underline-offset
1609
1609
  */
1610
1610
  "underline-offset": [{
1611
- "underline-offset": ["auto", Le, U]
1611
+ "underline-offset": ["auto", ze, U]
1612
1612
  }],
1613
1613
  /**
1614
1614
  * Text Decoration Color
@@ -1711,7 +1711,7 @@ const le = (e) => {
1711
1711
  * @see https://tailwindcss.com/docs/background-position
1712
1712
  */
1713
1713
  "bg-position": [{
1714
- bg: [...ce(), Lv]
1714
+ bg: [...de(), Lv]
1715
1715
  }],
1716
1716
  /**
1717
1717
  * Background Repeat
@@ -2090,14 +2090,14 @@ const le = (e) => {
2090
2090
  * @see https://tailwindcss.com/docs/outline-offset
2091
2091
  */
2092
2092
  "outline-offset": [{
2093
- "outline-offset": [Le, U]
2093
+ "outline-offset": [ze, U]
2094
2094
  }],
2095
2095
  /**
2096
2096
  * Outline Width
2097
2097
  * @see https://tailwindcss.com/docs/outline-width
2098
2098
  */
2099
2099
  "outline-w": [{
2100
- outline: [Le, We]
2100
+ outline: [ze, qe]
2101
2101
  }],
2102
2102
  /**
2103
2103
  * Outline Color
@@ -2137,7 +2137,7 @@ const le = (e) => {
2137
2137
  * @see https://tailwindcss.com/docs/ring-offset-width
2138
2138
  */
2139
2139
  "ring-offset-w": [{
2140
- "ring-offset": [Le, We]
2140
+ "ring-offset": [ze, qe]
2141
2141
  }],
2142
2142
  /**
2143
2143
  * Ring Offset Color
@@ -2152,7 +2152,7 @@ const le = (e) => {
2152
2152
  * @see https://tailwindcss.com/docs/box-shadow
2153
2153
  */
2154
2154
  shadow: [{
2155
- shadow: ["", "inner", "none", qe, Rv]
2155
+ shadow: ["", "inner", "none", Ge, Rv]
2156
2156
  }],
2157
2157
  /**
2158
2158
  * Box Shadow Color
@@ -2217,7 +2217,7 @@ const le = (e) => {
2217
2217
  * @see https://tailwindcss.com/docs/drop-shadow
2218
2218
  */
2219
2219
  "drop-shadow": [{
2220
- "drop-shadow": ["", "none", qe, U]
2220
+ "drop-shadow": ["", "none", Ge, U]
2221
2221
  }],
2222
2222
  /**
2223
2223
  * Grayscale
@@ -2245,7 +2245,7 @@ const le = (e) => {
2245
2245
  * @see https://tailwindcss.com/docs/saturate
2246
2246
  */
2247
2247
  saturate: [{
2248
- saturate: [b]
2248
+ saturate: [x]
2249
2249
  }],
2250
2250
  /**
2251
2251
  * Sepia
@@ -2316,7 +2316,7 @@ const le = (e) => {
2316
2316
  * @see https://tailwindcss.com/docs/backdrop-saturate
2317
2317
  */
2318
2318
  "backdrop-saturate": [{
2319
- "backdrop-saturate": [b]
2319
+ "backdrop-saturate": [x]
2320
2320
  }],
2321
2321
  /**
2322
2322
  * Backdrop Sepia
@@ -2417,21 +2417,21 @@ const le = (e) => {
2417
2417
  * @see https://tailwindcss.com/docs/scale
2418
2418
  */
2419
2419
  scale: [{
2420
- scale: [S]
2420
+ scale: [$]
2421
2421
  }],
2422
2422
  /**
2423
2423
  * Scale X
2424
2424
  * @see https://tailwindcss.com/docs/scale
2425
2425
  */
2426
2426
  "scale-x": [{
2427
- "scale-x": [S]
2427
+ "scale-x": [$]
2428
2428
  }],
2429
2429
  /**
2430
2430
  * Scale Y
2431
2431
  * @see https://tailwindcss.com/docs/scale
2432
2432
  */
2433
2433
  "scale-y": [{
2434
- "scale-y": [S]
2434
+ "scale-y": [$]
2435
2435
  }],
2436
2436
  /**
2437
2437
  * Rotate
@@ -2445,14 +2445,14 @@ const le = (e) => {
2445
2445
  * @see https://tailwindcss.com/docs/translate
2446
2446
  */
2447
2447
  "translate-x": [{
2448
- "translate-x": [V]
2448
+ "translate-x": [K]
2449
2449
  }],
2450
2450
  /**
2451
2451
  * Translate Y
2452
2452
  * @see https://tailwindcss.com/docs/translate
2453
2453
  */
2454
2454
  "translate-y": [{
2455
- "translate-y": [V]
2455
+ "translate-y": [K]
2456
2456
  }],
2457
2457
  /**
2458
2458
  * Skew X
@@ -2732,7 +2732,7 @@ const le = (e) => {
2732
2732
  * @see https://tailwindcss.com/docs/stroke-width
2733
2733
  */
2734
2734
  "stroke-w": [{
2735
- stroke: [Le, We, hn]
2735
+ stroke: [ze, qe, hn]
2736
2736
  }],
2737
2737
  /**
2738
2738
  * Stroke
@@ -3402,18 +3402,18 @@ const In = (e) => (t) => {
3402
3402
  var w, E;
3403
3403
  if (!c) return;
3404
3404
  const k = ++a;
3405
- s = !1, l.forEach((S) => {
3405
+ s = !1, l.forEach(($) => {
3406
3406
  var C;
3407
- return S((C = o()) != null ? C : p);
3407
+ return $((C = o()) != null ? C : p);
3408
3408
  });
3409
- const b = ((E = i.onRehydrateStorage) == null ? void 0 : E.call(i, (w = o()) != null ? w : p)) || void 0;
3410
- return In(c.getItem.bind(c))(i.name).then((S) => {
3411
- if (S)
3412
- if (typeof S.version == "number" && S.version !== i.version) {
3409
+ const x = ((E = i.onRehydrateStorage) == null ? void 0 : E.call(i, (w = o()) != null ? w : p)) || void 0;
3410
+ return In(c.getItem.bind(c))(i.name).then(($) => {
3411
+ if ($)
3412
+ if (typeof $.version == "number" && $.version !== i.version) {
3413
3413
  if (i.migrate) {
3414
3414
  const C = i.migrate(
3415
- S.state,
3416
- S.version
3415
+ $.state,
3416
+ $.version
3417
3417
  );
3418
3418
  return C instanceof Promise ? C.then((j) => [!0, j]) : [!0, C];
3419
3419
  }
@@ -3421,22 +3421,22 @@ const In = (e) => (t) => {
3421
3421
  "State loaded from storage couldn't be migrated since no migrate function was provided"
3422
3422
  );
3423
3423
  } else
3424
- return [!1, S.state];
3424
+ return [!1, $.state];
3425
3425
  return [!1, void 0];
3426
- }).then((S) => {
3426
+ }).then(($) => {
3427
3427
  var C;
3428
3428
  if (k !== a)
3429
3429
  return;
3430
- const [j, q] = S;
3430
+ const [j, W] = $;
3431
3431
  if (h = i.merge(
3432
- q,
3432
+ W,
3433
3433
  (C = o()) != null ? C : p
3434
3434
  ), n(h, !0), j)
3435
3435
  return u();
3436
3436
  }).then(() => {
3437
- k === a && (b == null || b(o(), void 0), h = o(), s = !0, d.forEach((S) => S(h)));
3438
- }).catch((S) => {
3439
- k === a && (b == null || b(void 0, S));
3437
+ k === a && (x == null || x(o(), void 0), h = o(), s = !0, d.forEach(($) => $(h)));
3438
+ }).catch(($) => {
3439
+ k === a && (x == null || x(void 0, $));
3440
3440
  });
3441
3441
  };
3442
3442
  return r.persist = {
@@ -3459,27 +3459,27 @@ const In = (e) => (t) => {
3459
3459
  d.delete(w);
3460
3460
  })
3461
3461
  }, i.skipHydration || g(), h || p;
3462
- }, Qv = Zv, ze = 0.5;
3462
+ }, Qv = Zv, De = 0.5;
3463
3463
  function ii(e) {
3464
3464
  if (e.length < 2) return e.map((r) => [r[0], r[1]]);
3465
3465
  const t = [[e[0][0], e[0][1]]];
3466
3466
  for (let r = 1; r < e.length; r++) {
3467
3467
  const i = t[t.length - 1];
3468
- Math.abs(i[0] - e[r][0]) < ze && Math.abs(i[1] - e[r][1]) < ze || t.push([e[r][0], e[r][1]]);
3468
+ Math.abs(i[0] - e[r][0]) < De && Math.abs(i[1] - e[r][1]) < De || t.push([e[r][0], e[r][1]]);
3469
3469
  }
3470
3470
  if (t.length < 2) return t;
3471
3471
  const n = [t[0]];
3472
3472
  for (let r = 1; r < t.length; r++) {
3473
3473
  const i = n[n.length - 1], s = t[r], a = Math.abs(i[0] - s[0]), l = Math.abs(i[1] - s[1]);
3474
- if (a > ze && l > ze) {
3475
- const c = (n.length >= 2 ? Math.abs(n[n.length - 2][1] - i[1]) < ze ? "h" : "v" : null) === "h" ? [s[0], i[1]] : [i[0], s[1]];
3474
+ if (a > De && l > De) {
3475
+ const c = (n.length >= 2 ? Math.abs(n[n.length - 2][1] - i[1]) < De ? "h" : "v" : null) === "h" ? [s[0], i[1]] : [i[0], s[1]];
3476
3476
  n.push(c);
3477
3477
  }
3478
3478
  n.push(s);
3479
3479
  }
3480
3480
  const o = [n[0]];
3481
3481
  for (let r = 1; r < n.length - 1; r++) {
3482
- const i = o[o.length - 1], s = n[r], a = n[r + 1], l = Math.abs(i[0] - s[0]) < ze && Math.abs(s[0] - a[0]) < ze, d = Math.abs(i[1] - s[1]) < ze && Math.abs(s[1] - a[1]) < ze;
3482
+ const i = o[o.length - 1], s = n[r], a = n[r + 1], l = Math.abs(i[0] - s[0]) < De && Math.abs(s[0] - a[0]) < De, d = Math.abs(i[1] - s[1]) < De && Math.abs(s[1] - a[1]) < De;
3483
3483
  l || d || o.push(s);
3484
3484
  }
3485
3485
  return o.push(n[n.length - 1]), o;
@@ -3508,7 +3508,7 @@ function t2(e) {
3508
3508
  function Pn(e) {
3509
3509
  return e === 90 || e === 270 ? "y" : "x";
3510
3510
  }
3511
- function je(e, t) {
3511
+ function Le(e, t) {
3512
3512
  let [n, o] = e;
3513
3513
  switch (t.mirror && (n = -n), t.rot) {
3514
3514
  case 0:
@@ -3597,7 +3597,7 @@ function To(e, t) {
3597
3597
  const n = Eo.indexOf(e), r = ((Eo.indexOf(t) - n) % 4 + 4) % 4;
3598
3598
  return [0, 90, 180, 270][r];
3599
3599
  }
3600
- const Ao = 320, pn = 220, vt = 260, gn = 720, kt = 30, Co = 30, Ge = 80, Io = 10, r2 = 60, i2 = 520, s2 = 80, a2 = 80, Po = 8, Oo = /* @__PURE__ */ new Set(["source", "renewable"]);
3600
+ const Ao = 320, pn = 220, vt = 260, gn = 720, kt = 30, Co = 30, Xe = 80, Io = 10, r2 = 60, i2 = 520, s2 = 80, a2 = 80, Po = 8, Oo = /* @__PURE__ */ new Set(["source", "renewable"]);
3601
3601
  function l2(e) {
3602
3602
  var mo, fo, ho, po, go, yo;
3603
3603
  const { elements: t, buses: n, wires: o, library: r, userLayout: i, userBusLayout: s } = e, a = new Map(i), l = new Map(s), d = new Set(i.keys()), c = new Set(s.keys()), u = /* @__PURE__ */ new Map();
@@ -3614,7 +3614,7 @@ function l2(e) {
3614
3614
  for (const y of t) {
3615
3615
  const v = r.get(y.kind);
3616
3616
  if (v)
3617
- for (const $ of v.terminals) w.add(`${y.id}.${$.id}`);
3617
+ for (const S of v.terminals) w.add(`${y.id}.${S.id}`);
3618
3618
  }
3619
3619
  for (const y of n) w.add(y.id);
3620
3620
  const E = [];
@@ -3623,68 +3623,68 @@ function l2(e) {
3623
3623
  const k = /* @__PURE__ */ new Map();
3624
3624
  for (const y of E)
3625
3625
  for (const v of y) k.set(v, [y]);
3626
- const b = /* @__PURE__ */ new Map();
3626
+ const x = /* @__PURE__ */ new Map();
3627
3627
  for (const y of E) {
3628
3628
  const v = y.filter(g);
3629
3629
  if (v.length !== 0)
3630
- for (const $ of v) {
3631
- const N = y.filter((_) => _ !== $), M = b.get($) ?? [];
3632
- M.push(...N), b.set($, M);
3630
+ for (const S of v) {
3631
+ const N = y.filter((_) => _ !== S), M = x.get(S) ?? [];
3632
+ M.push(...N), x.set(S, M);
3633
3633
  }
3634
3634
  }
3635
- const S = /* @__PURE__ */ new Map();
3635
+ const $ = /* @__PURE__ */ new Map();
3636
3636
  for (const y of E) {
3637
3637
  const v = y.filter(g);
3638
3638
  if (v.length !== 0)
3639
- for (const $ of y) {
3640
- if (g($)) continue;
3641
- const N = $.indexOf(".");
3639
+ for (const S of y) {
3640
+ if (g(S)) continue;
3641
+ const N = S.indexOf(".");
3642
3642
  if (N < 0) continue;
3643
- const M = $.slice(0, N), _ = $.slice(N + 1), T = S.get(M) ?? [];
3643
+ const M = S.slice(0, N), _ = S.slice(N + 1), T = $.get(M) ?? [];
3644
3644
  for (const L of v)
3645
3645
  T.some((I) => I.busId === L && I.pin === _) || T.push({ busId: L, pin: _ });
3646
- S.set(M, T);
3646
+ $.set(M, T);
3647
3647
  }
3648
3648
  }
3649
3649
  const C = [], j = /* @__PURE__ */ new Set();
3650
- for (const [y, v] of S)
3650
+ for (const [y, v] of $)
3651
3651
  if (new Set(v.map((N) => N.busId)).size >= 2) {
3652
3652
  const N = ((fo = r.get(((mo = u.get(y)) == null ? void 0 : mo.kind) ?? "")) == null ? void 0 : fo.category) === "transformer" ? "vertical" : "horizontal";
3653
3653
  C.push({ elementId: y, attachments: v, orientation: N }), N === "vertical" && j.add(y);
3654
3654
  }
3655
- const q = /* @__PURE__ */ new Map(), V = (y, v) => {
3656
- y !== v && (q.has(y) || q.set(y, /* @__PURE__ */ new Set()), q.has(v) || q.set(v, /* @__PURE__ */ new Set()), q.get(y).add(v), q.get(v).add(y));
3655
+ const W = /* @__PURE__ */ new Map(), K = (y, v) => {
3656
+ y !== v && (W.has(y) || W.set(y, /* @__PURE__ */ new Set()), W.has(v) || W.set(v, /* @__PURE__ */ new Set()), W.get(y).add(v), W.get(v).add(y));
3657
3657
  };
3658
3658
  for (const y of o)
3659
- V(y.ends[0], y.ends[1]);
3659
+ K(y.ends[0], y.ends[1]);
3660
3660
  for (const y of t) {
3661
3661
  const v = r.get(y.kind);
3662
3662
  if (!v || v.terminals.length < 2) continue;
3663
- const $ = v.terminals.map(
3663
+ const S = v.terminals.map(
3664
3664
  (N) => `${y.id}.${N.id}`
3665
3665
  );
3666
- for (let N = 0; N < $.length; N++)
3667
- for (let M = N + 1; M < $.length; M++)
3668
- V($[N], $[M]);
3666
+ for (let N = 0; N < S.length; N++)
3667
+ for (let M = N + 1; M < S.length; M++)
3668
+ K(S[N], S[M]);
3669
3669
  }
3670
3670
  for (const y of t) {
3671
3671
  if (j.has(y.id)) continue;
3672
3672
  const v = r.get(y.kind);
3673
3673
  if (!v || v.category !== "transformer" || v.terminals.length < 2) continue;
3674
- const $ = v.terminals.map(
3674
+ const S = v.terminals.map(
3675
3675
  (_) => `${y.id}.${_.id}`
3676
3676
  ), N = /* @__PURE__ */ new Map();
3677
- for (const _ of $) {
3677
+ for (const _ of S) {
3678
3678
  const T = _.slice(y.id.length + 1);
3679
3679
  N.set(T, /* @__PURE__ */ new Set());
3680
- const L = new Set($.filter((O) => O !== _)), I = /* @__PURE__ */ new Set([_]), P = [_];
3680
+ const L = new Set(S.filter((O) => O !== _)), I = /* @__PURE__ */ new Set([_]), P = [_];
3681
3681
  for (; P.length > 0; ) {
3682
3682
  const O = P.shift();
3683
3683
  if (g(O)) {
3684
3684
  N.get(T).add(O);
3685
3685
  continue;
3686
3686
  }
3687
- const A = q.get(O);
3687
+ const A = W.get(O);
3688
3688
  if (A)
3689
3689
  for (const z of A)
3690
3690
  I.has(z) || L.has(z) || (I.add(z), P.push(z));
@@ -3700,9 +3700,9 @@ function l2(e) {
3700
3700
  C.push({ elementId: y.id, attachments: _, orientation: "vertical" }), j.add(y.id);
3701
3701
  }
3702
3702
  }
3703
- const ie = (y, v) => {
3703
+ const re = (y, v) => {
3704
3704
  var L;
3705
- const $ = p(v), N = $ ? $.terminals.map((I) => `${v}.${I.id}`) : [], M = y, _ = /* @__PURE__ */ new Set([M, ...N]), T = [M];
3705
+ const S = p(v), N = S ? S.terminals.map((I) => `${v}.${I.id}`) : [], M = y, _ = /* @__PURE__ */ new Set([M, ...N]), T = [M];
3706
3706
  for (; T.length > 0; ) {
3707
3707
  const I = T.shift(), P = I.indexOf(".");
3708
3708
  if (P > 0) {
@@ -3712,7 +3712,7 @@ function l2(e) {
3712
3712
  if (R && Oo.has(R)) return !0;
3713
3713
  }
3714
3714
  }
3715
- const O = q.get(I);
3715
+ const O = W.get(I);
3716
3716
  if (O)
3717
3717
  for (const A of O)
3718
3718
  _.has(A) || (_.add(A), T.push(A));
@@ -3722,27 +3722,27 @@ function l2(e) {
3722
3722
  for (const y of C) {
3723
3723
  if (y.orientation !== "horizontal") continue;
3724
3724
  const v = new Set(y.attachments.map((N) => N.busId));
3725
- let $ = 0;
3725
+ let S = 0;
3726
3726
  for (const N of v)
3727
- ie(N, y.elementId) && $++;
3728
- $ === 1 && (y.orientation = "vertical", j.add(y.elementId));
3727
+ re(N, y.elementId) && S++;
3728
+ S === 1 && (y.orientation = "vertical", j.add(y.elementId));
3729
3729
  }
3730
3730
  for (const y of t) {
3731
3731
  if (j.has(y.id) || y.kind !== "breaker") continue;
3732
3732
  const v = r.get(y.kind);
3733
3733
  if (!v || v.terminals.length !== 2) continue;
3734
- const $ = v.terminals.map(
3734
+ const S = v.terminals.map(
3735
3735
  (_) => `${y.id}.${_.id}`
3736
3736
  ), N = /* @__PURE__ */ new Map();
3737
- for (const _ of $) {
3738
- const T = _.slice(y.id.length + 1), L = new Set($.filter((O) => O !== _)), I = /* @__PURE__ */ new Set([_]), P = [_];
3737
+ for (const _ of S) {
3738
+ const T = _.slice(y.id.length + 1), L = new Set(S.filter((O) => O !== _)), I = /* @__PURE__ */ new Set([_]), P = [_];
3739
3739
  for (; P.length > 0; ) {
3740
3740
  const O = P.shift();
3741
3741
  if (g(O)) {
3742
3742
  N.set(T, O);
3743
3743
  break;
3744
3744
  }
3745
- const A = q.get(O);
3745
+ const A = W.get(O);
3746
3746
  if (A)
3747
3747
  for (const z of A) {
3748
3748
  if (I.has(z) || L.has(z)) continue;
@@ -3750,8 +3750,8 @@ function l2(e) {
3750
3750
  if (R > 0) {
3751
3751
  const H = z.slice(0, R);
3752
3752
  if (H !== y.id) {
3753
- const G = u.get(H), K = G ? r.get(G.kind) : void 0;
3754
- if ((K == null ? void 0 : K.category) === "transformer") continue;
3753
+ const G = u.get(H), Y = G ? r.get(G.kind) : void 0;
3754
+ if ((Y == null ? void 0 : Y.category) === "transformer") continue;
3755
3755
  }
3756
3756
  }
3757
3757
  I.add(z), P.push(z);
@@ -3769,27 +3769,27 @@ function l2(e) {
3769
3769
  });
3770
3770
  }
3771
3771
  }
3772
- const se = /* @__PURE__ */ new Map();
3773
- for (const y of n) se.set(y.id, /* @__PURE__ */ new Map());
3772
+ const ae = /* @__PURE__ */ new Map();
3773
+ for (const y of n) ae.set(y.id, /* @__PURE__ */ new Map());
3774
3774
  for (const y of C) {
3775
- const v = Array.from(new Set(y.attachments.map(($) => $.busId)));
3776
- for (const $ of v)
3775
+ const v = Array.from(new Set(y.attachments.map((S) => S.busId)));
3776
+ for (const S of v)
3777
3777
  for (const N of v)
3778
- $ !== N && ((ho = se.get($)) == null || ho.set(N, y));
3778
+ S !== N && ((ho = ae.get(S)) == null || ho.set(N, y));
3779
3779
  }
3780
3780
  const D = (y) => {
3781
- var $;
3782
- const v = ($ = r.get(y)) == null ? void 0 : $.category;
3781
+ var S;
3782
+ const v = (S = r.get(y)) == null ? void 0 : S.category;
3783
3783
  return v ? Oo.has(v) : !1;
3784
3784
  }, F = [];
3785
3785
  for (const y of n) {
3786
- const v = b.get(y.id);
3786
+ const v = x.get(y.id);
3787
3787
  if (v)
3788
- for (const $ of v) {
3789
- if (g($)) continue;
3790
- const N = $.indexOf(".");
3788
+ for (const S of v) {
3789
+ if (g(S)) continue;
3790
+ const N = S.indexOf(".");
3791
3791
  if (N < 0) continue;
3792
- const M = $.slice(0, N), _ = u.get(M);
3792
+ const M = S.slice(0, N), _ = u.get(M);
3793
3793
  if (_ && D(_.kind)) {
3794
3794
  F.push(y.id);
3795
3795
  break;
@@ -3802,11 +3802,11 @@ function l2(e) {
3802
3802
  {
3803
3803
  const y = [...F];
3804
3804
  for (; y.length > 0; ) {
3805
- const v = y.shift(), $ = Z.get(v), N = se.get(v);
3805
+ const v = y.shift(), S = Z.get(v), N = ae.get(v);
3806
3806
  if (N)
3807
3807
  for (const [M, _] of N) {
3808
3808
  if (Z.has(M)) continue;
3809
- const T = _.orientation === "horizontal" ? $ : $ + 1;
3809
+ const T = _.orientation === "horizontal" ? S : S + 1;
3810
3810
  Z.set(M, T), y.push(M);
3811
3811
  }
3812
3812
  }
@@ -3816,16 +3816,16 @@ function l2(e) {
3816
3816
  const v = Z.size === 0 ? -1 : Math.max(...Array.from(Z.values()));
3817
3817
  Z.set(y.id, v + 1);
3818
3818
  }
3819
- const ae = /* @__PURE__ */ new Map();
3819
+ const le = /* @__PURE__ */ new Map();
3820
3820
  for (const y of n) {
3821
- const v = Z.get(y.id), $ = ae.get(v) ?? [];
3822
- $.push(y.id), ae.set(v, $);
3821
+ const v = Z.get(y.id), S = le.get(v) ?? [];
3822
+ S.push(y.id), le.set(v, S);
3823
3823
  }
3824
- const ce = [...ae.keys()].sort((y, v) => y - v), Q = (y, v, $) => {
3825
- const N = `${y.elementId}.${$}`, M = v, _ = p(y.elementId), T = /* @__PURE__ */ new Set();
3824
+ const de = [...le.keys()].sort((y, v) => y - v), Q = (y, v, S) => {
3825
+ const N = `${y.elementId}.${S}`, M = v, _ = p(y.elementId), T = /* @__PURE__ */ new Set();
3826
3826
  if (_)
3827
3827
  for (const A of _.terminals)
3828
- A.id !== $ && T.add(`${y.elementId}.${A.id}`);
3828
+ A.id !== S && T.add(`${y.elementId}.${A.id}`);
3829
3829
  const L = /* @__PURE__ */ new Set([N]), I = [
3830
3830
  { ref: N, dist: 0 }
3831
3831
  ], P = /* @__PURE__ */ new Map(), O = (A, z, R, H) => {
@@ -3834,49 +3834,49 @@ function l2(e) {
3834
3834
  for (; I.length > 0; ) {
3835
3835
  const { ref: A, dist: z } = I.shift();
3836
3836
  if (A === M) {
3837
- const K = P.get(M);
3838
- let de;
3839
- if (K) {
3840
- const J = K.indexOf(".");
3837
+ const Y = P.get(M);
3838
+ let ue;
3839
+ if (Y) {
3840
+ const J = Y.indexOf(".");
3841
3841
  if (J > 0) {
3842
- const W = K.slice(0, J);
3843
- W !== y.elementId && (de = W);
3842
+ const q = Y.slice(0, J);
3843
+ q !== y.elementId && (ue = q);
3844
3844
  }
3845
3845
  }
3846
- return { extent: z, head: de };
3846
+ return { extent: z, head: ue };
3847
3847
  }
3848
3848
  const R = A.indexOf(".");
3849
3849
  if (R < 0)
3850
3850
  continue;
3851
3851
  const H = A.slice(0, R), G = A.slice(R + 1);
3852
3852
  if (!g(H) && !j.has(H)) {
3853
- const K = p(H), de = K == null ? void 0 : K.terminals.find((J) => J.id === G);
3854
- if (K && de)
3855
- for (const J of K.terminals) {
3853
+ const Y = p(H), ue = Y == null ? void 0 : Y.terminals.find((J) => J.id === G);
3854
+ if (Y && ue)
3855
+ for (const J of Y.terminals) {
3856
3856
  if (J.id === G) continue;
3857
- const W = `${H}.${J.id}`;
3858
- L.has(W) || T.has(W) || O(W, A, Math.abs(de.y - J.y), z);
3857
+ const q = `${H}.${J.id}`;
3858
+ L.has(q) || T.has(q) || O(q, A, Math.abs(ue.y - J.y), z);
3859
3859
  }
3860
3860
  }
3861
- for (const K of k.get(A) ?? [])
3862
- for (const de of K) {
3863
- if (de === A || L.has(de) || T.has(de)) continue;
3864
- const J = g(A) || g(de);
3865
- O(de, A, J ? Co : kt, z);
3861
+ for (const Y of k.get(A) ?? [])
3862
+ for (const ue of Y) {
3863
+ if (ue === A || L.has(ue) || T.has(ue)) continue;
3864
+ const J = g(A) || g(ue);
3865
+ O(ue, A, J ? Co : kt, z);
3866
3866
  }
3867
3867
  }
3868
3868
  return { extent: 0 };
3869
3869
  }, ye = (y, v) => {
3870
3870
  var A, z, R;
3871
- const $ = (A = se.get(y)) == null ? void 0 : A.get(v);
3872
- if (!$ || $.orientation === "horizontal") return vt;
3873
- const N = p($.elementId);
3871
+ const S = (A = ae.get(y)) == null ? void 0 : A.get(v);
3872
+ if (!S || S.orientation === "horizontal") return vt;
3873
+ const N = p(S.elementId);
3874
3874
  if (!N) return vt;
3875
- const M = (z = $.attachments.find((H) => H.busId === y)) == null ? void 0 : z.pin, _ = (R = $.attachments.find((H) => H.busId === v)) == null ? void 0 : R.pin;
3875
+ const M = (z = S.attachments.find((H) => H.busId === y)) == null ? void 0 : z.pin, _ = (R = S.attachments.find((H) => H.busId === v)) == null ? void 0 : R.pin;
3876
3876
  if (!M || !_) return vt;
3877
3877
  const T = N.terminals.find((H) => H.id === M), L = N.terminals.find((H) => H.id === _);
3878
3878
  if (!T || !L) return vt;
3879
- const I = Math.abs(L.y - T.y), P = Q($, y, M).extent, O = Q($, v, _).extent;
3879
+ const I = Math.abs(L.y - T.y), P = Q(S, y, M).extent, O = Q(S, v, _).extent;
3880
3880
  return P + I + O;
3881
3881
  }, be = /* @__PURE__ */ new Map();
3882
3882
  for (const y of C) {
@@ -3885,17 +3885,17 @@ function l2(e) {
3885
3885
  (L, I) => (Z.get(L.busId) ?? 0) - (Z.get(I.busId) ?? 0)
3886
3886
  );
3887
3887
  if (v.length < 2) continue;
3888
- const $ = v[0].busId, N = v[1].busId, M = v[0].pin, T = Q(y, $, M).head ?? y.elementId;
3888
+ const S = v[0].busId, N = v[1].busId, M = v[0].pin, T = Q(y, S, M).head ?? y.elementId;
3889
3889
  be.set(T, { lowerBusId: N });
3890
3890
  }
3891
3891
  const xe = 30, Be = (y) => {
3892
3892
  const v = p(y);
3893
- return Math.max((v == null ? void 0 : v.width) ?? Ge, Ge);
3894
- }, Ee = 2, eo = (y, v, $, N = 0) => {
3893
+ return Math.max((v == null ? void 0 : v.width) ?? Xe, Xe);
3894
+ }, Ee = 2, eo = (y, v, S, N = 0) => {
3895
3895
  const M = p(v);
3896
3896
  let _ = Be(v);
3897
- if (M && !$.has(v) && N < Ee) {
3898
- $.add(v);
3897
+ if (M && !S.has(v) && N < Ee) {
3898
+ S.add(v);
3899
3899
  let T = 0;
3900
3900
  for (const L of M.terminals) {
3901
3901
  const I = `${v}.${L.id}`;
@@ -3912,7 +3912,7 @@ function l2(e) {
3912
3912
  const H = R.indexOf(".");
3913
3913
  if (H < 0) continue;
3914
3914
  const G = R.slice(0, H);
3915
- G === v || $.has(G) || j.has(G) || O.add(G);
3915
+ G === v || S.has(G) || j.has(G) || O.add(G);
3916
3916
  }
3917
3917
  if (A || O.size === 0) continue;
3918
3918
  let z = 0;
@@ -3920,36 +3920,36 @@ function l2(e) {
3920
3920
  const H = [...P].find(
3921
3921
  (G) => G.indexOf(".") > 0 && G.slice(0, G.indexOf(".")) === R
3922
3922
  );
3923
- z += (H ? eo(H, R, $, N + 1) : Be(R)) + xe;
3923
+ z += (H ? eo(H, R, S, N + 1) : Be(R)) + xe;
3924
3924
  }
3925
3925
  T = Math.max(T, z - xe);
3926
3926
  }
3927
3927
  }
3928
- $.delete(v), _ = Math.max(_, T);
3928
+ S.delete(v), _ = Math.max(_, T);
3929
3929
  }
3930
3930
  return _;
3931
3931
  }, pt = 320, nt = /* @__PURE__ */ new Map(), to = (y, v) => {
3932
3932
  if (!j.has(y)) return !1;
3933
- const $ = C.find((T) => T.elementId === y), N = $ == null ? void 0 : $.attachments.find((T) => T.busId !== v);
3933
+ const S = C.find((T) => T.elementId === y), N = S == null ? void 0 : S.attachments.find((T) => T.busId !== v);
3934
3934
  if (!N) return !1;
3935
3935
  const M = Z.get(v) ?? 0;
3936
3936
  return (Z.get(N.busId) ?? 0) < M;
3937
- }, gt = (y, v, $) => {
3937
+ }, gt = (y, v, S) => {
3938
3938
  const N = be.get(y);
3939
3939
  if (N) {
3940
3940
  const _ = nt.get(N.lowerBusId);
3941
3941
  if (_ !== void 0)
3942
- return Math.max(v, _ + Ge);
3942
+ return Math.max(v, _ + Xe);
3943
3943
  }
3944
3944
  let M = 0;
3945
- return $ && (M = eo($, y, /* @__PURE__ */ new Set())), Math.max(v, Ge, M);
3945
+ return S && (M = eo(S, y, /* @__PURE__ */ new Set())), Math.max(v, Xe, M);
3946
3946
  }, no = (y, v) => {
3947
3947
  if (nt.has(y)) return nt.get(y);
3948
3948
  if (v.has(y)) return pt;
3949
3949
  v.add(y);
3950
- const $ = b.get(y) ?? [];
3950
+ const S = x.get(y) ?? [];
3951
3951
  let N = 0, M = 0;
3952
- for (const T of $) {
3952
+ for (const T of S) {
3953
3953
  if (g(T)) continue;
3954
3954
  const L = T.indexOf(".");
3955
3955
  if (L < 0) continue;
@@ -3970,15 +3970,15 @@ function l2(e) {
3970
3970
  }
3971
3971
  const _ = Math.max(
3972
3972
  pt,
3973
- Math.max(N, M) + Ge
3973
+ Math.max(N, M) + Xe
3974
3974
  );
3975
3975
  return nt.set(y, _), v.delete(y), _;
3976
3976
  };
3977
3977
  for (const y of n) no(y.id, /* @__PURE__ */ new Set());
3978
- const He = /* @__PURE__ */ new Map(), Bw = (y, v, $) => {
3978
+ const We = /* @__PURE__ */ new Map(), Bw = (y, v, S) => {
3979
3979
  const N = p(v);
3980
3980
  if (!N) return;
3981
- const M = `${v}.${$}`, _ = N.terminals.filter((I) => I.id !== $).map((I) => `${v}.${I.id}`);
3981
+ const M = `${v}.${S}`, _ = N.terminals.filter((I) => I.id !== S).map((I) => `${v}.${I.id}`);
3982
3982
  if (_.length === 0) return;
3983
3983
  const T = /* @__PURE__ */ new Set([M, ..._]), L = _.slice();
3984
3984
  for (; L.length > 0; ) {
@@ -4004,10 +4004,10 @@ function l2(e) {
4004
4004
  }
4005
4005
  }
4006
4006
  }, jw = (y) => {
4007
- const v = b.get(y);
4007
+ const v = x.get(y);
4008
4008
  if (!v || v.length === 0) return;
4009
- const $ = l.get(y);
4010
- if (!$) return;
4009
+ const S = l.get(y);
4010
+ if (!S) return;
4011
4011
  const N = v.flatMap((A) => {
4012
4012
  if (g(A)) return [];
4013
4013
  const z = A.indexOf(".");
@@ -4017,11 +4017,11 @@ function l2(e) {
4017
4017
  if (to(R, y)) return [];
4018
4018
  const G = p(R);
4019
4019
  if (!G) return [];
4020
- const K = G.terminals.find((de) => de.id === H);
4021
- return K ? [{
4020
+ const Y = G.terminals.find((ue) => ue.id === H);
4021
+ return Y ? [{
4022
4022
  elId: R,
4023
4023
  lib: G,
4024
- localTerm: K,
4024
+ localTerm: Y,
4025
4025
  isLinker: j.has(R),
4026
4026
  busFacingRef: `${R}.${H}`
4027
4027
  }] : [];
@@ -4033,33 +4033,33 @@ function l2(e) {
4033
4033
  const T = (A) => A.reduce(
4034
4034
  (z, R) => z + gt(R.elId, R.lib.width, R.busFacingRef),
4035
4035
  0
4036
- ), L = Math.max(T(M), T(_)) + Ge, I = Math.max($.span, L);
4037
- I !== $.span && !c.has(y) && l.set(y, { ...$, span: I });
4036
+ ), L = Math.max(T(M), T(_)) + Xe, I = Math.max(S.span, L);
4037
+ I !== S.span && !c.has(y) && l.set(y, { ...S, span: I });
4038
4038
  const P = l.get(y), O = (A, z) => {
4039
4039
  if (A.length === 0) return;
4040
4040
  const R = /* @__PURE__ */ new Map();
4041
4041
  for (const X of A) {
4042
- const Y = Bw(y, X.elId, X.localTerm.id);
4043
- Y !== void 0 && R.set(X.elId, Y);
4042
+ const V = Bw(y, X.elId, X.localTerm.id);
4043
+ V !== void 0 && R.set(X.elId, V);
4044
4044
  }
4045
- A.sort((X, Y) => {
4046
- const fe = R.get(X.elId) ?? P.at[0], we = R.get(Y.elId) ?? P.at[0];
4045
+ A.sort((X, V) => {
4046
+ const fe = R.get(X.elId) ?? P.at[0], we = R.get(V.elId) ?? P.at[0];
4047
4047
  if (fe !== we) return fe - we;
4048
4048
  const ve = gt(X.elId, X.lib.width, X.busFacingRef);
4049
- return gt(Y.elId, Y.lib.width, Y.busFacingRef) - ve;
4049
+ return gt(V.elId, V.lib.width, V.busFacingRef) - ve;
4050
4050
  });
4051
4051
  const H = A.map(
4052
4052
  (X) => gt(X.elId, X.lib.width, X.busFacingRef)
4053
- ), G = H.reduce((X, Y) => X + Y, 0), K = Math.max(I, G), de = (K - G) / (A.length + 1);
4054
- let J = P.at[0] - K / 2 + de;
4055
- const W = P.at[1] + z * Co;
4053
+ ), G = H.reduce((X, V) => X + V, 0), Y = Math.max(I, G), ue = (Y - G) / (A.length + 1);
4054
+ let J = P.at[0] - Y / 2 + ue;
4055
+ const q = P.at[1] + z * Co;
4056
4056
  for (let X = 0; X < A.length; X++) {
4057
- const Y = A[X], fe = H[X], we = J + fe / 2;
4058
- Y.isLinker ? He.has(Y.elId) || He.set(Y.elId, we) : a.set(Y.elId, {
4059
- at: [ge(we - Y.localTerm.x), ge(W - Y.localTerm.y)],
4057
+ const V = A[X], fe = H[X], we = J + fe / 2;
4058
+ V.isLinker ? We.has(V.elId) || We.set(V.elId, we) : a.set(V.elId, {
4059
+ at: [ge(we - V.localTerm.x), ge(q - V.localTerm.y)],
4060
4060
  rot: 0,
4061
4061
  mirror: !1
4062
- }), J += fe + de;
4062
+ }), J += fe + ue;
4063
4063
  }
4064
4064
  };
4065
4065
  O(M, -1), O(_, 1);
@@ -4067,29 +4067,29 @@ function l2(e) {
4067
4067
  if (a.has(y.elementId) || y.orientation === "horizontal") return;
4068
4068
  const v = p(y.elementId);
4069
4069
  if (!v) return;
4070
- const $ = y.attachments.filter(
4070
+ const S = y.attachments.filter(
4071
4071
  (J) => l.has(J.busId)
4072
4072
  );
4073
- if ($.length < 2) return;
4074
- const N = $.slice().sort(
4075
- (J, W) => (Z.get(J.busId) ?? 0) - (Z.get(W.busId) ?? 0)
4073
+ if (S.length < 2) return;
4074
+ const N = S.slice().sort(
4075
+ (J, q) => (Z.get(J.busId) ?? 0) - (Z.get(q.busId) ?? 0)
4076
4076
  ), M = N[0].busId, _ = l.get(M), T = N[0].pin, L = N[N.length - 1].pin, I = v.terminals.find((J) => J.id === T), P = v.terminals.find((J) => J.id === L);
4077
4077
  if (!I || !P) return;
4078
- const O = I.y <= P.y ? 0 : 180, A = Z.get(M) ?? 0, z = $.filter(
4078
+ const O = I.y <= P.y ? 0 : 180, A = Z.get(M) ?? 0, z = S.filter(
4079
4079
  (J) => (Z.get(J.busId) ?? 0) === A
4080
4080
  ), R = [];
4081
4081
  let H = 0;
4082
4082
  for (const J of z) {
4083
- const W = Q(y, J.busId, J.pin);
4084
- H = Math.max(H, W.extent);
4085
- const X = W.head ? a.get(W.head) : void 0;
4086
- X ? R.push(X.at[0]) : He.has(y.elementId) ? R.push(He.get(y.elementId)) : R.push(l.get(J.busId).at[0]);
4083
+ const q = Q(y, J.busId, J.pin);
4084
+ H = Math.max(H, q.extent);
4085
+ const X = q.head ? a.get(q.head) : void 0;
4086
+ X ? R.push(X.at[0]) : We.has(y.elementId) ? R.push(We.get(y.elementId)) : R.push(l.get(J.busId).at[0]);
4087
4087
  }
4088
4088
  let G;
4089
- R.length > 0 ? G = R.reduce((J, W) => J + W, 0) / R.length : He.has(y.elementId) ? G = He.get(y.elementId) : G = _.at[0];
4090
- const K = _.at[1] + H, de = O === 0 ? [ge(G - I.x), ge(K - I.y)] : [ge(G + I.x), ge(K + I.y)];
4091
- if (a.set(y.elementId, { at: de, rot: O, mirror: !1 }), z.length > 1) {
4092
- const J = a.get(y.elementId), W = je(
4089
+ R.length > 0 ? G = R.reduce((J, q) => J + q, 0) / R.length : We.has(y.elementId) ? G = We.get(y.elementId) : G = _.at[0];
4090
+ const Y = _.at[1] + H, ue = O === 0 ? [ge(G - I.x), ge(Y - I.y)] : [ge(G + I.x), ge(Y + I.y)];
4091
+ if (a.set(y.elementId, { at: ue, rot: O, mirror: !1 }), z.length > 1) {
4092
+ const J = a.get(y.elementId), q = Le(
4093
4093
  [I.x, I.y],
4094
4094
  J
4095
4095
  ), X = Rt(
@@ -4098,14 +4098,14 @@ function l2(e) {
4098
4098
  );
4099
4099
  zw(
4100
4100
  `${y.elementId}.${T}`,
4101
- W,
4101
+ q,
4102
4102
  X,
4103
4103
  G
4104
4104
  );
4105
4105
  }
4106
- }, zw = (y, v, $, N) => {
4106
+ }, zw = (y, v, S, N) => {
4107
4107
  const M = /* @__PURE__ */ new Set([y]);
4108
- let _ = y, T = v, L = $;
4108
+ let _ = y, T = v, L = S;
4109
4109
  for (; ; ) {
4110
4110
  const I = k.get(_) ?? [];
4111
4111
  let P, O = !1;
@@ -4133,32 +4133,32 @@ function l2(e) {
4133
4133
  if (!H) break;
4134
4134
  const G = H.terminals.find((ke) => ke.id === R);
4135
4135
  if (!G) break;
4136
- const K = No(L), de = [
4137
- T[0] + K[0] * kt,
4138
- T[1] + K[1] * kt
4139
- ], J = Mo[L], W = To(G.orientation, J), X = je([G.x, G.y], {
4136
+ const Y = No(L), ue = [
4137
+ T[0] + Y[0] * kt,
4138
+ T[1] + Y[1] * kt
4139
+ ], J = Mo[L], q = To(G.orientation, J), X = Le([G.x, G.y], {
4140
4140
  at: [0, 0],
4141
- rot: W,
4141
+ rot: q,
4142
4142
  mirror: !1
4143
- }), Y = [
4143
+ }), V = [
4144
4144
  ge(N - X[0]),
4145
- ge(de[1] - X[1])
4145
+ ge(ue[1] - X[1])
4146
4146
  ];
4147
- a.set(z, { at: Y, rot: W, mirror: !1 }), M.add(P);
4147
+ a.set(z, { at: V, rot: q, mirror: !1 }), M.add(P);
4148
4148
  const fe = H.terminals.find((ke) => ke.id !== R);
4149
4149
  if (!fe) break;
4150
4150
  const we = `${z}.${fe.id}`;
4151
4151
  M.add(we);
4152
- const ve = { at: Y, rot: W, mirror: !1 };
4153
- T = je([fe.x, fe.y], ve), L = Rt(fe.orientation, ve), _ = we;
4152
+ const ve = { at: V, rot: q, mirror: !1 };
4153
+ T = Le([fe.x, fe.y], ve), L = Rt(fe.orientation, ve), _ = we;
4154
4154
  }
4155
4155
  }, Dw = (y) => {
4156
4156
  if (a.has(y.elementId) || y.orientation !== "horizontal") return;
4157
4157
  const v = p(y.elementId);
4158
4158
  if (!v) return;
4159
- const $ = y.attachments.filter((z) => l.has(z.busId));
4160
- if ($.length < 2) return;
4161
- const N = $.map((z) => {
4159
+ const S = y.attachments.filter((z) => l.has(z.busId));
4160
+ if (S.length < 2) return;
4161
+ const N = S.map((z) => {
4162
4162
  const R = Q(y, z.busId, z.pin), H = R.head ? a.get(R.head) : void 0, G = H ? H.at[0] : l.get(z.busId).at[0];
4163
4163
  return { att: z, x: G, extent: R.extent };
4164
4164
  });
@@ -4173,38 +4173,38 @@ function l2(e) {
4173
4173
  });
4174
4174
  }, oo = 100;
4175
4175
  let Ct = pn;
4176
- for (let y = 0; y < ce.length; y++) {
4177
- const v = ce[y], $ = ae.get(v);
4176
+ for (let y = 0; y < de.length; y++) {
4177
+ const v = de[y], S = le.get(v);
4178
4178
  let N;
4179
4179
  if (y === 0)
4180
4180
  N = pn;
4181
4181
  else {
4182
- const _ = ae.get(ce[y - 1]);
4182
+ const _ = le.get(de[y - 1]);
4183
4183
  let T = 0;
4184
4184
  for (const L of _)
4185
- for (const I of $)
4186
- (po = se.get(L)) != null && po.get(I) && (T = Math.max(T, ye(L, I)));
4185
+ for (const I of S)
4186
+ (po = ae.get(L)) != null && po.get(I) && (T = Math.max(T, ye(L, I)));
4187
4187
  T === 0 && (T = vt), N = Ct + T;
4188
4188
  }
4189
4189
  Ct = N;
4190
4190
  let M = Ao;
4191
- for (const _ of $) {
4191
+ for (const _ of S) {
4192
4192
  if (l.has(_)) {
4193
4193
  Ct = Math.max(Ct, l.get(_).at[1]);
4194
4194
  continue;
4195
4195
  }
4196
4196
  let T;
4197
4197
  if (y > 0) {
4198
- const I = ae.get(ce[y - 1]), P = [];
4198
+ const I = le.get(de[y - 1]), P = [];
4199
4199
  for (const O of I) {
4200
- const A = (go = se.get(O)) == null ? void 0 : go.get(_);
4200
+ const A = (go = ae.get(O)) == null ? void 0 : go.get(_);
4201
4201
  if (!A || A.orientation !== "vertical") continue;
4202
4202
  const z = (yo = A.attachments.find(
4203
4203
  (H) => H.busId === O
4204
4204
  )) == null ? void 0 : yo.pin;
4205
4205
  if (!z) continue;
4206
4206
  const R = Q(A, O, z);
4207
- R.head && a.has(R.head) ? P.push(a.get(R.head).at[0]) : He.has(A.elementId) ? P.push(He.get(A.elementId)) : P.push(l.get(O).at[0]);
4207
+ R.head && a.has(R.head) ? P.push(a.get(R.head).at[0]) : We.has(A.elementId) ? P.push(We.get(A.elementId)) : P.push(l.get(O).at[0]);
4208
4208
  }
4209
4209
  P.length > 0 && (T = P.reduce((O, A) => O + A, 0) / P.length);
4210
4210
  }
@@ -4220,16 +4220,16 @@ function l2(e) {
4220
4220
  axis: Pn(0)
4221
4221
  });
4222
4222
  }
4223
- for (const _ of $)
4223
+ for (const _ of S)
4224
4224
  jw(_);
4225
4225
  if (y > 0)
4226
4226
  for (const _ of C)
4227
4227
  a.has(_.elementId) || !_.attachments.some(
4228
- (L) => $.includes(L.busId)
4228
+ (L) => S.includes(L.busId)
4229
4229
  ) || Lw(_);
4230
4230
  for (const _ of C)
4231
4231
  _.orientation !== "horizontal" || a.has(_.elementId) || !_.attachments.every(
4232
- (L) => $.includes(L.busId)
4232
+ (L) => S.includes(L.busId)
4233
4233
  ) || Dw(_);
4234
4234
  }
4235
4235
  if (n.length === 0 && a.size < t.length) {
@@ -4248,7 +4248,7 @@ function l2(e) {
4248
4248
  }
4249
4249
  }
4250
4250
  return _;
4251
- }, v = /* @__PURE__ */ new Set(), $ = [];
4251
+ }, v = /* @__PURE__ */ new Set(), S = [];
4252
4252
  for (const M of t) {
4253
4253
  if (v.has(M.id) || !p(M.id)) continue;
4254
4254
  const _ = [], T = [M.id];
@@ -4258,21 +4258,21 @@ function l2(e) {
4258
4258
  for (const I of y(L))
4259
4259
  v.has(I) || (v.add(I), T.push(I));
4260
4260
  }
4261
- _.length >= 2 && $.push(_);
4261
+ _.length >= 2 && S.push(_);
4262
4262
  }
4263
4263
  let N = Ao;
4264
- for (const M of $) {
4264
+ for (const M of S) {
4265
4265
  if (M.some((P) => a.has(P))) continue;
4266
4266
  M.sort((P, O) => {
4267
- var G, K;
4268
- const A = D(((G = u.get(P)) == null ? void 0 : G.kind) ?? "") ? 0 : 1, z = D(((K = u.get(O)) == null ? void 0 : K.kind) ?? "") ? 0 : 1;
4267
+ var G, Y;
4268
+ const A = D(((G = u.get(P)) == null ? void 0 : G.kind) ?? "") ? 0 : 1, z = D(((Y = u.get(O)) == null ? void 0 : Y.kind) ?? "") ? 0 : 1;
4269
4269
  if (A !== z) return A - z;
4270
4270
  const R = y(P).size, H = y(O).size;
4271
4271
  return R !== H ? R - H : P.localeCompare(O);
4272
4272
  });
4273
4273
  const _ = M[0], T = p(_);
4274
4274
  if (!T) continue;
4275
- const L = T.terminals.slice().sort((P, O) => O.y - P.y)[0], I = L ? je([L.x, L.y], {
4275
+ const L = T.terminals.slice().sort((P, O) => O.y - P.y)[0], I = L ? Le([L.x, L.y], {
4276
4276
  at: [0, 0],
4277
4277
  rot: 0,
4278
4278
  mirror: !1
@@ -4281,7 +4281,7 @@ function l2(e) {
4281
4281
  at: [ge(N - I[0]), ge(pn - I[1])],
4282
4282
  rot: 0,
4283
4283
  mirror: !1
4284
- }), N += Math.max(gn, M.length * Ge) + oo;
4284
+ }), N += Math.max(gn, M.length * Xe) + oo;
4285
4285
  }
4286
4286
  }
4287
4287
  const Rw = (y) => {
@@ -4294,67 +4294,67 @@ function l2(e) {
4294
4294
  ln = !1;
4295
4295
  for (const y of E) {
4296
4296
  if (y.length < 2) continue;
4297
- const v = [], $ = /* @__PURE__ */ new Map();
4298
- for (const W of y) {
4299
- if (g(W))
4297
+ const v = [], S = /* @__PURE__ */ new Map();
4298
+ for (const q of y) {
4299
+ if (g(q))
4300
4300
  continue;
4301
- const X = W.indexOf(".");
4301
+ const X = q.indexOf(".");
4302
4302
  if (X < 0) continue;
4303
- const Y = W.slice(0, X), fe = W.slice(X + 1);
4304
- if (a.has(Y)) {
4305
- v.push(W);
4303
+ const V = q.slice(0, X), fe = q.slice(X + 1);
4304
+ if (a.has(V)) {
4305
+ v.push(q);
4306
4306
  continue;
4307
4307
  }
4308
- if (j.has(Y) || $.has(Y)) continue;
4309
- const we = p(Y);
4308
+ if (j.has(V) || S.has(V)) continue;
4309
+ const we = p(V);
4310
4310
  if (!we) continue;
4311
4311
  const ve = we.terminals.find((ke) => ke.id === fe);
4312
- ve && $.set(Y, {
4313
- ref: W,
4314
- elId: Y,
4312
+ ve && S.set(V, {
4313
+ ref: q,
4314
+ elId: V,
4315
4315
  lib: we,
4316
4316
  localTerm: ve
4317
4317
  });
4318
4318
  }
4319
- if ($.size === 0 || v.length === 0) continue;
4320
- const N = [...$.values()], M = /* @__PURE__ */ new Map();
4321
- for (const W of N)
4322
- for (const X of k.get(W.ref) ?? [])
4323
- for (const Y of X) {
4324
- if (Y === W.ref || g(Y) || !Rw(Y)) continue;
4325
- const fe = Y;
4319
+ if (S.size === 0 || v.length === 0) continue;
4320
+ const N = [...S.values()], M = /* @__PURE__ */ new Map();
4321
+ for (const q of N)
4322
+ for (const X of k.get(q.ref) ?? [])
4323
+ for (const V of X) {
4324
+ if (V === q.ref || g(V) || !Rw(V)) continue;
4325
+ const fe = V;
4326
4326
  M.set(fe, (M.get(fe) ?? 0) + 1);
4327
4327
  }
4328
4328
  let _;
4329
4329
  if (M.size > 0) {
4330
- let W = -1;
4331
- for (const [X, Y] of M)
4332
- (Y > W || Y === W && (_ === void 0 || X < _)) && (W = Y, _ = X);
4330
+ let q = -1;
4331
+ for (const [X, V] of M)
4332
+ (V > q || V === q && (_ === void 0 || X < _)) && (q = V, _ = X);
4333
4333
  }
4334
4334
  if (_ || (_ = [...v].sort()[0]), !_) continue;
4335
4335
  const T = _.indexOf("."), L = _.slice(0, T), I = _.slice(T + 1), P = p(L), O = a.get(L);
4336
4336
  if (!P || !O) continue;
4337
- const A = P.terminals.find((W) => W.id === I);
4337
+ const A = P.terminals.find((q) => q.id === I);
4338
4338
  if (!A) continue;
4339
- const z = je(
4339
+ const z = Le(
4340
4340
  [A.x, A.y],
4341
4341
  O
4342
4342
  ), R = Rt(
4343
4343
  A.orientation,
4344
4344
  O
4345
4345
  ), H = No(R), G = [-H[1], H[0]];
4346
- N.sort((W, X) => W.elId.localeCompare(X.elId));
4347
- const K = N.map(
4348
- (W) => Math.max(W.lib.width, Ge)
4346
+ N.sort((q, X) => q.elId.localeCompare(X.elId));
4347
+ const Y = N.map(
4348
+ (q) => Math.max(q.lib.width, Xe)
4349
4349
  );
4350
- let J = -K.reduce((W, X) => W + X, 0) / 2;
4351
- for (let W = 0; W < N.length; W++) {
4352
- const X = N[W], Y = K[W], fe = J + Y / 2;
4353
- J += Y;
4350
+ let J = -Y.reduce((q, X) => q + X, 0) / 2;
4351
+ for (let q = 0; q < N.length; q++) {
4352
+ const X = N[q], V = Y[q], fe = J + V / 2;
4353
+ J += V;
4354
4354
  const we = Mo[R], ve = To(
4355
4355
  X.localTerm.orientation,
4356
4356
  we
4357
- ), ke = je(
4357
+ ), ke = Le(
4358
4358
  [X.localTerm.x, X.localTerm.y],
4359
4359
  { at: [0, 0], rot: ve, mirror: !1 }
4360
4360
  ), Ue = [
@@ -4369,11 +4369,11 @@ function l2(e) {
4369
4369
  }
4370
4370
  }
4371
4371
  const yt = (y) => {
4372
- const v = a.get(y), $ = p(y);
4373
- if (!v || !$) return null;
4374
- const N = $.viewBox.split(/\s+/).map(Number);
4372
+ const v = a.get(y), S = p(y);
4373
+ if (!v || !S) return null;
4374
+ const N = S.viewBox.split(/\s+/).map(Number);
4375
4375
  if (N.length < 4 || N.some((A) => Number.isNaN(A))) {
4376
- const A = $.width / 2;
4376
+ const A = S.width / 2;
4377
4377
  return { min: v.at[0] - A, max: v.at[0] + A };
4378
4378
  }
4379
4379
  const [M, _, T, L] = N, I = [
@@ -4384,14 +4384,14 @@ function l2(e) {
4384
4384
  ];
4385
4385
  let P = 1 / 0, O = -1 / 0;
4386
4386
  for (const A of I) {
4387
- const z = je(A, v);
4387
+ const z = Le(A, v);
4388
4388
  P = Math.min(P, z[0]), O = Math.max(O, z[0]);
4389
4389
  }
4390
4390
  return { min: P, max: O };
4391
4391
  }, cn = (y) => {
4392
- const v = /* @__PURE__ */ new Set(), $ = p(y);
4393
- if (!$) return v;
4394
- for (const N of $.terminals) {
4392
+ const v = /* @__PURE__ */ new Set(), S = p(y);
4393
+ if (!S) return v;
4394
+ for (const N of S.terminals) {
4395
4395
  const M = `${y}.${N.id}`;
4396
4396
  for (const _ of k.get(M) ?? [])
4397
4397
  for (const T of _) {
@@ -4404,11 +4404,11 @@ function l2(e) {
4404
4404
  }
4405
4405
  return v;
4406
4406
  }, ro = 40, dn = (y) => {
4407
- const v = a.get(y), $ = p(y);
4408
- if (!v || !$) return null;
4409
- const N = $.viewBox.split(/\s+/).map(Number);
4407
+ const v = a.get(y), S = p(y);
4408
+ if (!v || !S) return null;
4409
+ const N = S.viewBox.split(/\s+/).map(Number);
4410
4410
  if (N.length < 4 || N.some((A) => Number.isNaN(A))) {
4411
- const A = $.height / 2;
4411
+ const A = S.height / 2;
4412
4412
  return { min: v.at[1] - A, max: v.at[1] + A };
4413
4413
  }
4414
4414
  const [M, _, T, L] = N, I = [
@@ -4419,39 +4419,39 @@ function l2(e) {
4419
4419
  ];
4420
4420
  let P = 1 / 0, O = -1 / 0;
4421
4421
  for (const A of I) {
4422
- const z = je(A, v);
4422
+ const z = Le(A, v);
4423
4423
  P = Math.min(P, z[1]), O = Math.max(O, z[1]);
4424
4424
  }
4425
4425
  return { min: P, max: O };
4426
4426
  }, Hw = (y, v) => {
4427
- const $ = /* @__PURE__ */ new Set(), N = [];
4428
- for (const M of b.get(y) ?? []) {
4427
+ const S = /* @__PURE__ */ new Set(), N = [];
4428
+ for (const M of x.get(y) ?? []) {
4429
4429
  if (g(M)) continue;
4430
4430
  const _ = M.indexOf(".");
4431
4431
  if (_ < 0) continue;
4432
4432
  const T = M.slice(0, _), L = a.get(T);
4433
- !L || L.at[1] >= v - 1 || $.has(T) || ($.add(T), N.push(T));
4433
+ !L || L.at[1] >= v - 1 || S.has(T) || (S.add(T), N.push(T));
4434
4434
  }
4435
4435
  for (; N.length > 0; ) {
4436
4436
  const M = N.pop();
4437
4437
  for (const _ of cn(M)) {
4438
- if ($.has(_)) continue;
4438
+ if (S.has(_)) continue;
4439
4439
  const T = a.get(_);
4440
- !T || T.at[1] >= v - 1 || ($.add(_), N.push(_));
4440
+ !T || T.at[1] >= v - 1 || (S.add(_), N.push(_));
4441
4441
  }
4442
4442
  }
4443
- return $;
4444
- }, io = (y, v, $) => {
4443
+ return S;
4444
+ }, io = (y, v, S) => {
4445
4445
  const N = /* @__PURE__ */ new Set([y]), M = [y];
4446
4446
  for (; M.length > 0; ) {
4447
4447
  const _ = M.pop();
4448
4448
  for (const T of cn(_))
4449
- T === v || N.has(T) || !$.has(T) || (N.add(T), M.push(T));
4449
+ T === v || N.has(T) || !S.has(T) || (N.add(T), M.push(T));
4450
4450
  }
4451
4451
  return N;
4452
4452
  }, so = (y, v) => {
4453
- let $ = y.length * y.length + 8, N = !1, M = !0;
4454
- for (; M && $-- > 0; ) {
4453
+ let S = y.length * y.length + 8, N = !1, M = !0;
4454
+ for (; M && S-- > 0; ) {
4455
4455
  M = !1;
4456
4456
  for (let _ = 0; _ < y.length && !M; _++)
4457
4457
  for (let T = _ + 1; T < y.length; T++) {
@@ -4459,16 +4459,16 @@ function l2(e) {
4459
4459
  if (!P || !O || !A || !z) continue;
4460
4460
  const R = Math.min(P.max, O.max) - Math.max(P.min, O.min), H = Math.min(A.max, z.max) - Math.max(A.min, z.min);
4461
4461
  if (R <= 0 || H <= 0) continue;
4462
- const G = io(L, I, v), K = io(I, L, v);
4463
- if (G.has(I) || K.has(L)) continue;
4464
- const de = ![...G].some((ve) => d.has(ve)), J = ![...K].some((ve) => d.has(ve));
4465
- if (!de && !J) continue;
4466
- const W = (P.min + P.max) / 2, X = (O.min + O.max) / 2;
4467
- let Y, fe;
4468
- de && (!J || G.size <= K.size) ? (Y = G, fe = W <= X ? -1 : 1) : (Y = K, fe = X <= W ? -1 : 1);
4462
+ const G = io(L, I, v), Y = io(I, L, v);
4463
+ if (G.has(I) || Y.has(L)) continue;
4464
+ const ue = ![...G].some((ve) => d.has(ve)), J = ![...Y].some((ve) => d.has(ve));
4465
+ if (!ue && !J) continue;
4466
+ const q = (P.min + P.max) / 2, X = (O.min + O.max) / 2;
4467
+ let V, fe;
4468
+ ue && (!J || G.size <= Y.size) ? (V = G, fe = q <= X ? -1 : 1) : (V = Y, fe = X <= q ? -1 : 1);
4469
4469
  const we = ge(fe * (R + ro));
4470
4470
  if (we !== 0) {
4471
- for (const ve of Y) {
4471
+ for (const ve of V) {
4472
4472
  const ke = a.get(ve);
4473
4473
  ke && a.set(ve, {
4474
4474
  ...ke,
@@ -4485,10 +4485,10 @@ function l2(e) {
4485
4485
  for (const y of n) {
4486
4486
  const v = l.get(y.id);
4487
4487
  if (!v) continue;
4488
- const $ = Hw(y.id, v.at[1]);
4489
- if ($.size < 2) continue;
4490
- const N = [...$];
4491
- if (so(N, $)) {
4488
+ const S = Hw(y.id, v.at[1]);
4489
+ if (S.size < 2) continue;
4490
+ const N = [...S];
4491
+ if (so(N, S)) {
4492
4492
  let _ = 1 / 0, T = -1 / 0;
4493
4493
  for (const L of N) {
4494
4494
  const I = yt(L);
@@ -4514,13 +4514,13 @@ function l2(e) {
4514
4514
  }
4515
4515
  const ao = () => {
4516
4516
  const v = t.map((N) => N.id).filter((N) => a.has(N)).map((N) => ({ x: yt(N), y: dn(N) })).filter((N) => N.x && N.y);
4517
- let $ = 0;
4517
+ let S = 0;
4518
4518
  for (let N = 0; N < v.length; N++)
4519
4519
  for (let M = N + 1; M < v.length; M++) {
4520
4520
  const _ = Math.min(v[N].x.max, v[M].x.max) - Math.max(v[N].x.min, v[M].x.min), T = Math.min(v[N].y.max, v[M].y.max) - Math.max(v[N].y.min, v[M].y.min);
4521
- _ > 1 && T > 1 && $++;
4521
+ _ > 1 && T > 1 && S++;
4522
4522
  }
4523
- return $;
4523
+ return S;
4524
4524
  }, Ww = ao(), lo = /* @__PURE__ */ new Map();
4525
4525
  for (const [y, v] of a) lo.set(y, { ...v, at: [...v.at] });
4526
4526
  const co = /* @__PURE__ */ new Map();
@@ -4528,19 +4528,19 @@ function l2(e) {
4528
4528
  co.set(y, { ...v, at: [...v.at] });
4529
4529
  const un = 120, uo = /* @__PURE__ */ new Map();
4530
4530
  {
4531
- const y = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), $ = [];
4531
+ const y = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), S = [];
4532
4532
  for (const M of n)
4533
- for (const _ of b.get(M.id) ?? []) {
4533
+ for (const _ of x.get(M.id) ?? []) {
4534
4534
  if (g(_)) continue;
4535
4535
  const T = _.indexOf(".");
4536
4536
  if (T < 0) continue;
4537
4537
  const L = _.slice(0, T);
4538
- a.has(L) && $.push({ el: L, bus: M.id, d: 1 });
4538
+ a.has(L) && S.push({ el: L, bus: M.id, d: 1 });
4539
4539
  }
4540
- $.sort((M, _) => M.d - _.d);
4540
+ S.sort((M, _) => M.d - _.d);
4541
4541
  let N = 0;
4542
- for (; N < $.length; ) {
4543
- const { el: M, bus: _, d: T } = $[N++], L = y.get(M);
4542
+ for (; N < S.length; ) {
4543
+ const { el: M, bus: _, d: T } = S[N++], L = y.get(M);
4544
4544
  if (L === void 0)
4545
4545
  y.set(M, T), v.set(M, _);
4546
4546
  else if (T === L && v.get(M) !== _) {
@@ -4549,37 +4549,37 @@ function l2(e) {
4549
4549
  } else
4550
4550
  continue;
4551
4551
  for (const I of cn(M))
4552
- a.has(I) && (y.has(I) || $.push({ el: I, bus: _, d: T + 1 }));
4552
+ a.has(I) && (y.has(I) || S.push({ el: I, bus: _, d: T + 1 }));
4553
4553
  }
4554
4554
  for (const [M, _] of v) _ && uo.set(M, _);
4555
4555
  }
4556
- for (const y of ce) {
4557
- const v = (ae.get(y) ?? []).filter(
4556
+ for (const y of de) {
4557
+ const v = (le.get(y) ?? []).filter(
4558
4558
  (P) => l.has(P)
4559
4559
  );
4560
4560
  if (v.length < 2 || v.some((P) => c.has(P))) continue;
4561
- const $ = [];
4561
+ const S = [];
4562
4562
  let N = 0;
4563
4563
  for (const P of v) {
4564
4564
  const O = l.get(P), A = [];
4565
4565
  let z = 1 / 0, R = -1 / 0;
4566
4566
  for (const [H, G] of uo) {
4567
4567
  if (G !== P) continue;
4568
- const K = yt(H);
4569
- K && (A.push(H), z = Math.min(z, K.min), R = Math.max(R, K.max));
4568
+ const Y = yt(H);
4569
+ Y && (A.push(H), z = Math.min(z, Y.min), R = Math.max(R, Y.max));
4570
4570
  }
4571
- Number.isFinite(z) || (z = O.at[0] - pt / 2, R = O.at[0] + pt / 2), $.push({ busId: P, min: z, max: R, members: A }), N += R - z;
4571
+ Number.isFinite(z) || (z = O.at[0] - pt / 2, R = O.at[0] + pt / 2), S.push({ busId: P, min: z, max: R, members: A }), N += R - z;
4572
4572
  }
4573
- if ($.some((P) => P.members.some((O) => d.has(O))))
4573
+ if (S.some((P) => P.members.some((O) => d.has(O))))
4574
4574
  continue;
4575
4575
  let M = 1 / 0, _ = -1 / 0;
4576
- for (const P of $)
4576
+ for (const P of S)
4577
4577
  M = Math.min(M, P.min), _ = Math.max(_, P.max);
4578
- const T = _ - M, L = N + un * ($.length - 1);
4578
+ const T = _ - M, L = N + un * (S.length - 1);
4579
4579
  if (!(T > L + un)) continue;
4580
- $.sort((P, O) => (P.min + P.max) / 2 - (O.min + O.max) / 2);
4580
+ S.sort((P, O) => (P.min + P.max) / 2 - (O.min + O.max) / 2);
4581
4581
  let I = M;
4582
- for (const P of $) {
4582
+ for (const P of S) {
4583
4583
  const O = ge(I - P.min);
4584
4584
  if (O !== 0) {
4585
4585
  const A = l.get(P.busId);
@@ -4592,13 +4592,13 @@ function l2(e) {
4592
4592
  }
4593
4593
  I = P.max + un;
4594
4594
  }
4595
- for (const P of $) {
4595
+ for (const P of S) {
4596
4596
  const O = l.get(P.busId), A = Math.max(pt, P.max - P.min);
4597
4597
  A < O.span && l.set(P.busId, { ...O, span: A });
4598
4598
  }
4599
4599
  }
4600
4600
  {
4601
- const y = t.map(($) => $.id).filter(($) => a.has($)), v = new Set(y);
4601
+ const y = t.map((S) => S.id).filter((S) => a.has(S)), v = new Set(y);
4602
4602
  so(y, v);
4603
4603
  }
4604
4604
  if (ao() > Ww) {
@@ -4610,11 +4610,11 @@ function l2(e) {
4610
4610
  let mn = 0;
4611
4611
  for (const y of t) {
4612
4612
  if (a.has(y.id)) continue;
4613
- const v = mn % Po, $ = Math.floor(mn / Po);
4613
+ const v = mn % Po, S = Math.floor(mn / Po);
4614
4614
  a.set(y.id, {
4615
4615
  at: [
4616
4616
  ge(r2 + v * s2),
4617
- ge(i2 + $ * a2)
4617
+ ge(i2 + S * a2)
4618
4618
  ],
4619
4619
  rot: 0,
4620
4620
  mirror: !1
@@ -6979,106 +6979,106 @@ const M$ = 320;
6979
6979
  function Je(e) {
6980
6980
  var h, g, w, E, k;
6981
6981
  const t = e2(), n = /* @__PURE__ */ new Map();
6982
- e.elements.forEach((b, S) => {
6983
- if (n.has(b.id)) {
6982
+ e.elements.forEach((x, $) => {
6983
+ if (n.has(x.id)) {
6984
6984
  t.diagnostics.push({
6985
6985
  code: "E001",
6986
6986
  severity: "error",
6987
- message: _e("compile.duplicateId", { id: b.id }),
6988
- pointer: `/elements/${S}`
6987
+ message: _e("compile.duplicateId", { id: x.id }),
6988
+ pointer: `/elements/${$}`
6989
6989
  });
6990
6990
  return;
6991
6991
  }
6992
- n.set(b.id, b);
6993
- const C = Do.get(b.kind);
6992
+ n.set(x.id, x);
6993
+ const C = Do.get(x.kind);
6994
6994
  C || t.diagnostics.push({
6995
6995
  code: "E003",
6996
6996
  severity: "error",
6997
- message: `${_e("compile.unknownKind", { kind: b.kind })} (id=${b.id})`,
6998
- pointer: `/elements/${S}`
6999
- }), t.elements.set(b.id, { element: b, libraryDef: C });
6997
+ message: `${_e("compile.unknownKind", { kind: x.kind })} (id=${x.id})`,
6998
+ pointer: `/elements/${$}`
6999
+ }), t.elements.set(x.id, { element: x, libraryDef: C });
7000
7000
  });
7001
7001
  const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
7002
- (e.buses ?? []).forEach((b, S) => {
7003
- if (n.has(b.id) || o.has(b.id)) {
7002
+ (e.buses ?? []).forEach((x, $) => {
7003
+ if (n.has(x.id) || o.has(x.id)) {
7004
7004
  t.diagnostics.push({
7005
7005
  code: "E001",
7006
7006
  severity: "error",
7007
- message: _e("compile.duplicateId", { id: b.id }),
7008
- pointer: `/buses/${S}`
7007
+ message: _e("compile.duplicateId", { id: x.id }),
7008
+ pointer: `/buses/${$}`
7009
7009
  });
7010
7010
  return;
7011
7011
  }
7012
- if (o.set(b.id, b), b.layout) {
7013
- const C = b.layout.rot ?? 0;
7014
- r.set(b.id, {
7015
- at: b.layout.at,
7016
- span: b.layout.span,
7012
+ if (o.set(x.id, x), x.layout) {
7013
+ const C = x.layout.rot ?? 0;
7014
+ r.set(x.id, {
7015
+ at: x.layout.at,
7016
+ span: x.layout.span,
7017
7017
  rot: C,
7018
7018
  axis: Pn(C)
7019
7019
  });
7020
7020
  }
7021
7021
  });
7022
7022
  const i = /* @__PURE__ */ new Map();
7023
- (e.junctions ?? []).forEach((b, S) => {
7024
- if (n.has(b.id) || o.has(b.id) || i.has(b.id)) {
7023
+ (e.junctions ?? []).forEach((x, $) => {
7024
+ if (n.has(x.id) || o.has(x.id) || i.has(x.id)) {
7025
7025
  t.diagnostics.push({
7026
7026
  code: "E001",
7027
7027
  severity: "error",
7028
- message: _e("compile.duplicateId", { id: b.id }),
7029
- pointer: `/junctions/${S}`
7028
+ message: _e("compile.duplicateId", { id: x.id }),
7029
+ pointer: `/junctions/${$}`
7030
7030
  });
7031
7031
  return;
7032
7032
  }
7033
- i.set(b.id, b);
7033
+ i.set(x.id, x);
7034
7034
  });
7035
- const s = (b) => !b.includes(".") && o.has(b), a = (b) => !b.includes(".") && i.has(b), l = (b, S) => {
7036
- if (s(b) || a(b)) return !0;
7037
- const C = b.indexOf(".");
7035
+ const s = (x) => !x.includes(".") && o.has(x), a = (x) => !x.includes(".") && i.has(x), l = (x, $) => {
7036
+ if (s(x) || a(x)) return !0;
7037
+ const C = x.indexOf(".");
7038
7038
  if (C <= 0)
7039
7039
  return t.diagnostics.push({
7040
7040
  code: "E003",
7041
7041
  severity: "error",
7042
- message: _e("compile.invalidTermRef", { ref: b }),
7043
- pointer: S
7042
+ message: _e("compile.invalidTermRef", { ref: x }),
7043
+ pointer: $
7044
7044
  }), !1;
7045
- const j = b.slice(0, C), q = b.slice(C + 1), V = t.elements.get(j);
7046
- if (!V)
7045
+ const j = x.slice(0, C), W = x.slice(C + 1), K = t.elements.get(j);
7046
+ if (!K)
7047
7047
  return t.diagnostics.push({
7048
7048
  code: "E002",
7049
7049
  severity: "error",
7050
7050
  message: _e("compile.elementMissing", { id: j }),
7051
- pointer: S
7051
+ pointer: $
7052
7052
  }), !1;
7053
- if (!V.libraryDef) return !1;
7054
- if (!V.libraryDef.terminals.find((ie) => ie.id === q)) {
7055
- const ie = V.libraryDef.terminals.map((se) => se.id).join(", ");
7053
+ if (!K.libraryDef) return !1;
7054
+ if (!K.libraryDef.terminals.find((re) => re.id === W)) {
7055
+ const re = K.libraryDef.terminals.map((ae) => ae.id).join(", ");
7056
7056
  return t.diagnostics.push({
7057
7057
  code: "E003",
7058
7058
  severity: "error",
7059
7059
  message: _e("compile.missingPin", {
7060
7060
  id: j,
7061
- kind: V.element.kind,
7062
- pin: q,
7063
- available: ie
7061
+ kind: K.element.kind,
7062
+ pin: W,
7063
+ available: re
7064
7064
  }),
7065
- pointer: S
7065
+ pointer: $
7066
7066
  }), !1;
7067
7067
  }
7068
7068
  return !0;
7069
7069
  }, d = [];
7070
- (e.wires ?? []).forEach((b, S) => {
7071
- const C = `/wires/${S}`, j = l(b.ends[0], C), q = l(b.ends[1], C);
7072
- j && q && d.push(b);
7070
+ (e.wires ?? []).forEach((x, $) => {
7071
+ const C = `/wires/${$}`, j = l(x.ends[0], C), W = l(x.ends[1], C);
7072
+ j && W && d.push(x);
7073
7073
  });
7074
7074
  const c = /* @__PURE__ */ new Map();
7075
7075
  if (e.layout)
7076
- for (const [b, S] of Object.entries(e.layout))
7077
- t.elements.has(b) ? c.set(b, t2(S)) : t.diagnostics.push({
7076
+ for (const [x, $] of Object.entries(e.layout))
7077
+ t.elements.has(x) ? c.set(x, t2($)) : t.diagnostics.push({
7078
7078
  code: "E004",
7079
7079
  severity: "error",
7080
- message: _e("compile.layoutMissingElement", { id: b }),
7081
- pointer: `/layout/${b}`
7080
+ message: _e("compile.layoutMissingElement", { id: x }),
7081
+ pointer: `/layout/${x}`
7082
7082
  });
7083
7083
  const u = l2({
7084
7084
  elements: e.elements,
@@ -7089,110 +7089,110 @@ function Je(e) {
7089
7089
  userBusLayout: r
7090
7090
  });
7091
7091
  t.layout = u.devices;
7092
- for (const [b, S] of u.buses) {
7093
- const C = o.get(b);
7094
- C && t.buses.set(b, { bus: C, geometry: S });
7092
+ for (const [x, $] of u.buses) {
7093
+ const C = o.get(x);
7094
+ C && t.buses.set(x, { bus: C, geometry: $ });
7095
7095
  }
7096
- for (const [b, S] of o)
7097
- t.buses.has(b) || t.buses.set(b, {
7098
- bus: S,
7096
+ for (const [x, $] of o)
7097
+ t.buses.has(x) || t.buses.set(x, {
7098
+ bus: $,
7099
7099
  geometry: {
7100
- at: ((h = S.layout) == null ? void 0 : h.at) ?? [0, 0],
7101
- span: ((g = S.layout) == null ? void 0 : g.span) ?? M$,
7102
- rot: ((w = S.layout) == null ? void 0 : w.rot) ?? 0,
7103
- axis: Pn(((E = S.layout) == null ? void 0 : E.rot) ?? 0)
7100
+ at: ((h = $.layout) == null ? void 0 : h.at) ?? [0, 0],
7101
+ span: ((g = $.layout) == null ? void 0 : g.span) ?? M$,
7102
+ rot: ((w = $.layout) == null ? void 0 : w.rot) ?? 0,
7103
+ axis: Pn(((E = $.layout) == null ? void 0 : E.rot) ?? 0)
7104
7104
  }
7105
7105
  });
7106
- for (const b of t.elements.values()) {
7107
- if (!b.libraryDef) continue;
7108
- const S = t.layout.get(b.element.id);
7109
- if (!S) continue;
7106
+ for (const x of t.elements.values()) {
7107
+ if (!x.libraryDef) continue;
7108
+ const $ = t.layout.get(x.element.id);
7109
+ if (!$) continue;
7110
7110
  const C = [];
7111
- for (const j of b.libraryDef.terminals) {
7112
- const q = `${b.element.id}.${j.id}`, V = je([j.x, j.y], S), ie = Rt(j.orientation, S);
7113
- t.terminals.set(q, {
7114
- ref: q,
7115
- elementId: b.element.id,
7111
+ for (const j of x.libraryDef.terminals) {
7112
+ const W = `${x.element.id}.${j.id}`, K = Le([j.x, j.y], $), re = Rt(j.orientation, $);
7113
+ t.terminals.set(W, {
7114
+ ref: W,
7115
+ elementId: x.element.id,
7116
7116
  pin: j.id,
7117
- world: V,
7118
- orientation: ie
7119
- }), C.push(q);
7117
+ world: K,
7118
+ orientation: re
7119
+ }), C.push(W);
7120
7120
  }
7121
- t.elementToTerminals.set(b.element.id, C);
7121
+ t.elementToTerminals.set(x.element.id, C);
7122
7122
  }
7123
- const f = (b) => {
7124
- if (!b.includes(".")) {
7125
- const C = t.buses.get(b);
7123
+ const f = (x) => {
7124
+ if (!x.includes(".")) {
7125
+ const C = t.buses.get(x);
7126
7126
  return C ? C.geometry.at : null;
7127
7127
  }
7128
- const S = t.terminals.get(b);
7129
- return S ? S.world : null;
7128
+ const $ = t.terminals.get(x);
7129
+ return $ ? $.world : null;
7130
7130
  };
7131
- for (const [b, S] of i) {
7131
+ for (const [x, $] of i) {
7132
7132
  let C;
7133
- if ((k = S.layout) != null && k.at)
7134
- C = [S.layout.at[0], S.layout.at[1]];
7133
+ if ((k = $.layout) != null && k.at)
7134
+ C = [$.layout.at[0], $.layout.at[1]];
7135
7135
  else {
7136
7136
  const j = [];
7137
- for (const q of d) {
7138
- const [V, ie] = q.ends, se = V === b ? ie : ie === b ? V : null;
7139
- if (se === null) continue;
7140
- const D = f(se);
7137
+ for (const W of d) {
7138
+ const [K, re] = W.ends, ae = K === x ? re : re === x ? K : null;
7139
+ if (ae === null) continue;
7140
+ const D = f(ae);
7141
7141
  D && j.push(D);
7142
7142
  }
7143
7143
  C = j.length ? [
7144
- j.reduce((q, V) => q + V[0], 0) / j.length,
7145
- j.reduce((q, V) => q + V[1], 0) / j.length
7144
+ j.reduce((W, K) => W + K[0], 0) / j.length,
7145
+ j.reduce((W, K) => W + K[1], 0) / j.length
7146
7146
  ] : [0, 0];
7147
7147
  }
7148
- t.junctions.set(b, { junction: S, world: C });
7148
+ t.junctions.set(x, { junction: $, world: C });
7149
7149
  }
7150
7150
  const p = new si();
7151
- for (const b of d)
7152
- p.add(b.ends[0]), p.add(b.ends[1]), p.union(b.ends[0], b.ends[1]);
7153
- for (const [, b] of p.groups()) {
7154
- const S = E$(b);
7155
- t.nodes.set(S, { id: S, terminals: b });
7156
- for (const C of b) t.terminalToNode.set(C, S);
7157
- }
7158
- for (const b of t.elements.values()) {
7159
- const S = t.elementToTerminals.get(b.element.id) ?? [];
7160
- if (S.length === 0) continue;
7161
- S.some((j) => t.terminalToNode.has(j)) || t.diagnostics.push({
7151
+ for (const x of d)
7152
+ p.add(x.ends[0]), p.add(x.ends[1]), p.union(x.ends[0], x.ends[1]);
7153
+ for (const [, x] of p.groups()) {
7154
+ const $ = E$(x);
7155
+ t.nodes.set($, { id: $, terminals: x });
7156
+ for (const C of x) t.terminalToNode.set(C, $);
7157
+ }
7158
+ for (const x of t.elements.values()) {
7159
+ const $ = t.elementToTerminals.get(x.element.id) ?? [];
7160
+ if ($.length === 0) continue;
7161
+ $.some((j) => t.terminalToNode.has(j)) || t.diagnostics.push({
7162
7162
  code: "W001",
7163
7163
  severity: "warning",
7164
- message: _e("compile.elementUnconnected", { id: b.element.id })
7164
+ message: _e("compile.elementUnconnected", { id: x.element.id })
7165
7165
  });
7166
7166
  }
7167
- for (const b of t.buses.keys())
7168
- t.terminalToNode.has(b) || t.diagnostics.push({
7167
+ for (const x of t.buses.keys())
7168
+ t.terminalToNode.has(x) || t.diagnostics.push({
7169
7169
  code: "W001",
7170
7170
  severity: "warning",
7171
- message: _e("compile.elementUnconnected", { id: b })
7171
+ message: _e("compile.elementUnconnected", { id: x })
7172
7172
  });
7173
- for (const b of t.junctions.keys())
7174
- t.terminalToNode.has(b) || t.diagnostics.push({
7173
+ for (const x of t.junctions.keys())
7174
+ t.terminalToNode.has(x) || t.diagnostics.push({
7175
7175
  code: "W001",
7176
7176
  severity: "warning",
7177
- message: _e("compile.elementUnconnected", { id: b })
7177
+ message: _e("compile.elementUnconnected", { id: x })
7178
7178
  });
7179
- for (const b of d) {
7180
- if (b.path && b.path.length >= 2) {
7181
- const C = b.path, j = C.length >= 2 ? C[1] : null, q = C.length >= 2 ? C[C.length - 2] : null, V = jo(b.ends[0], j, t), ie = jo(b.ends[1], q, t);
7182
- if (V && ie) {
7183
- const se = [
7184
- [V[0], V[1]],
7179
+ for (const x of d) {
7180
+ if (x.path && x.path.length >= 2) {
7181
+ const C = x.path, j = C.length >= 2 ? C[1] : null, W = C.length >= 2 ? C[C.length - 2] : null, K = jo(x.ends[0], j, t), re = jo(x.ends[1], W, t);
7182
+ if (K && re) {
7183
+ const ae = [
7184
+ [K[0], K[1]],
7185
7185
  ...C.slice(1, -1).map((F) => [F[0], F[1]]),
7186
- [ie[0], ie[1]]
7187
- ], D = ii(se);
7186
+ [re[0], re[1]]
7187
+ ], D = ii(ae);
7188
7188
  if (D.length >= 2) {
7189
- t.wireRenders.set(b.id, { wireId: b.id, path: D, userEdited: !0 });
7189
+ t.wireRenders.set(x.id, { wireId: x.id, path: D, userEdited: !0 });
7190
7190
  continue;
7191
7191
  }
7192
7192
  }
7193
7193
  }
7194
- const S = c2(b, t);
7195
- S && t.wireRenders.set(b.id, S);
7194
+ const $ = c2(x, t);
7195
+ $ && t.wireRenders.set(x.id, $);
7196
7196
  }
7197
7197
  return t;
7198
7198
  }
@@ -7274,7 +7274,7 @@ function I$() {
7274
7274
  return "select";
7275
7275
  }
7276
7276
  }
7277
- const x = Zt()(
7277
+ const b = Zt()(
7278
7278
  Qv(
7279
7279
  (e, t) => ({
7280
7280
  diagram: qo,
@@ -7518,35 +7518,35 @@ const x = Zt()(
7518
7518
  };
7519
7519
  t().dispatch((u) => {
7520
7520
  const f = n.elements.map((k) => {
7521
- const b = structuredClone(k);
7522
- return b.id = l.get(k.id), b;
7521
+ const x = structuredClone(k);
7522
+ return x.id = l.get(k.id), x;
7523
7523
  }), p = n.buses.map((k) => {
7524
- const b = structuredClone(k);
7525
- b.id = l.get(k.id);
7526
- const S = n.busLayouts[k.id];
7527
- return S && (b.layout = {
7528
- ...S,
7529
- at: [S.at[0] + s, S.at[1] + a]
7530
- }), b;
7524
+ const x = structuredClone(k);
7525
+ x.id = l.get(k.id);
7526
+ const $ = n.busLayouts[k.id];
7527
+ return $ && (x.layout = {
7528
+ ...$,
7529
+ at: [$.at[0] + s, $.at[1] + a]
7530
+ }), x;
7531
7531
  }), h = n.junctions.map((k) => {
7532
- const b = structuredClone(k);
7533
- return b.id = l.get(k.id), b.layout && (b.layout = {
7534
- at: [b.layout.at[0] + s, b.layout.at[1] + a]
7535
- }), b;
7532
+ const x = structuredClone(k);
7533
+ return x.id = l.get(k.id), x.layout && (x.layout = {
7534
+ at: [x.layout.at[0] + s, x.layout.at[1] + a]
7535
+ }), x;
7536
7536
  }), g = { ...u.layout ?? {} };
7537
- for (const [k, b] of l) {
7538
- const S = n.placements[k];
7539
- S && (g[b] = {
7540
- ...S,
7541
- at: [S.at[0] + s, S.at[1] + a]
7537
+ for (const [k, x] of l) {
7538
+ const $ = n.placements[k];
7539
+ $ && (g[x] = {
7540
+ ...$,
7541
+ at: [$.at[0] + s, $.at[1] + a]
7542
7542
  });
7543
7543
  }
7544
7544
  const w = n.wires.map((k) => {
7545
- const b = [
7545
+ const x = [
7546
7546
  c(k.ends[0]),
7547
7547
  c(k.ends[1])
7548
7548
  ];
7549
- return { id: at(b[0], b[1]), ends: b };
7549
+ return { id: at(x[0], x[1]), ends: x };
7550
7550
  }), E = Xo(u.wires ?? [], w);
7551
7551
  return {
7552
7552
  ...u,
@@ -7783,7 +7783,7 @@ const x = Zt()(
7783
7783
  for (const p of o) {
7784
7784
  if (r.junctions.has(p)) continue;
7785
7785
  if (r.buses.has(p)) {
7786
- const w = r.buses.get(p), k = (((((u = (c = (d = i.buses) == null ? void 0 : d.find((b) => b.id === p)) == null ? void 0 : c.layout) == null ? void 0 : u.rot) ?? w.geometry.rot ?? 0) + n) % 360 + 360) % 360;
7786
+ const w = r.buses.get(p), k = (((((u = (c = (d = i.buses) == null ? void 0 : d.find((x) => x.id === p)) == null ? void 0 : c.layout) == null ? void 0 : u.rot) ?? w.geometry.rot ?? 0) + n) % 360 + 360) % 360;
7787
7787
  a.set(p, k);
7788
7788
  continue;
7789
7789
  }
@@ -7884,11 +7884,11 @@ const x = Zt()(
7884
7884
  }, d = (h) => {
7885
7885
  if ("end" in h) return h.end;
7886
7886
  if ("junctionAt" in h) return l(h.junctionAt);
7887
- const g = (i.wires ?? []).find((b) => b.id === h.onWire), w = l(h.at);
7887
+ const g = (i.wires ?? []).find((x) => x.id === h.onWire), w = l(h.at);
7888
7888
  if (!g) return w;
7889
- const E = (i.wires ?? []).filter((b) => b.id !== h.onWire), k = (b, S) => ({
7890
- id: at(b, S),
7891
- ends: [b, S]
7889
+ const E = (i.wires ?? []).filter((x) => x.id !== h.onWire), k = (x, $) => ({
7890
+ id: at(x, $),
7891
+ ends: [x, $]
7892
7892
  });
7893
7893
  return i = {
7894
7894
  ...i,
@@ -8034,35 +8034,35 @@ function Zx() {
8034
8034
  const e = document.querySelector(".ole-canvas-root");
8035
8035
  return !!e && !e.classList.contains("hide-grid");
8036
8036
  }
8037
- function re(e) {
8037
+ function se(e) {
8038
8038
  return Zx() ? Math.round(e / Xt) * Xt : e;
8039
8039
  }
8040
8040
  const O$ = 30, B$ = 144;
8041
8041
  function Qx(e, t) {
8042
- const n = Ye[e], o = x.getState(), r = o.diagram;
8042
+ const n = Ye[e], o = b.getState(), r = o.diagram;
8043
8043
  if (!n || e === "busbar")
8044
8044
  return { newElementId: o.addElement(e, t), attachedToBus: !1 };
8045
8045
  const i = j$(r, t);
8046
8046
  if (!i) {
8047
- const g = ew(n), w = g ? [re(t[0]) - g.x, re(t[1]) - g.y] : [re(t[0]), re(t[1])];
8047
+ const g = ew(n), w = g ? [se(t[0]) - g.x, se(t[1]) - g.y] : [se(t[0]), se(t[1])];
8048
8048
  return { newElementId: o.addElement(e, w), attachedToBus: !1 };
8049
8049
  }
8050
- const { busId: s, busAt: a, axis: l } = i, d = L$(n, l), c = Gt(r, e), u = n.terminals.find((g) => g.id === d), f = l === "x" ? t[0] : a[0], p = l === "y" ? t[1] : a[1], h = u ? [re(f) - u.x, re(p) - u.y] : [re(t[0]), re(t[1])];
8050
+ const { busId: s, busAt: a, axis: l } = i, d = L$(n, l), c = Gt(r, e), u = n.terminals.find((g) => g.id === d), f = l === "x" ? t[0] : a[0], p = l === "y" ? t[1] : a[1], h = u ? [se(f) - u.x, se(p) - u.y] : [se(t[0]), se(t[1])];
8051
8051
  return o.dispatch((g) => {
8052
- const w = { id: c, kind: e }, E = { at: h }, k = `${c}.${d}`, b = {
8052
+ const w = { id: c, kind: e }, E = { at: h }, k = `${c}.${d}`, x = {
8053
8053
  id: at(s, k),
8054
8054
  ends: [s, k]
8055
8055
  };
8056
8056
  return {
8057
8057
  ...g,
8058
8058
  elements: [...g.elements, w],
8059
- wires: [...g.wires ?? [], b],
8059
+ wires: [...g.wires ?? [], x],
8060
8060
  layout: { ...g.layout ?? {}, [c]: E }
8061
8061
  };
8062
8062
  }), o.setSelection([c]), { newElementId: c, attachedToBus: !0 };
8063
8063
  }
8064
8064
  function j$(e, t) {
8065
- const n = x.getState().internal;
8065
+ const n = b.getState().internal;
8066
8066
  let o = null;
8067
8067
  for (const r of e.buses ?? []) {
8068
8068
  const i = n.buses.get(r.id);
@@ -8089,7 +8089,7 @@ function ew(e) {
8089
8089
  return !e || e.stretchable || e.terminals.length === 0 ? null : [...e.terminals].sort((n, o) => n.y - o.y)[0];
8090
8090
  }
8091
8091
  function tw(e, t) {
8092
- const n = x.getState().internal;
8092
+ const n = b.getState().internal;
8093
8093
  if (!e.includes(".") && n.buses.has(e)) {
8094
8094
  const r = n.buses.get(e), { axis: i, at: s, span: a } = r.geometry;
8095
8095
  if (i === "x") {
@@ -8129,23 +8129,23 @@ function Yo(e, t, n) {
8129
8129
  return o * o + r * r;
8130
8130
  }
8131
8131
  function D$(e, t, n) {
8132
- const o = Ye[e], r = x.getState(), i = r.diagram;
8132
+ const o = Ye[e], r = b.getState(), i = r.diagram;
8133
8133
  if (!o) return null;
8134
8134
  const s = tw(t, n);
8135
8135
  if (!s) return null;
8136
- const a = n[0] - s.world[0], l = n[1] - s.world[1], d = a * a + l * l <= B$, c = [re(n[0]), re(n[1])], u = nw(o, s, c), f = d ? s.world : c, p = [
8137
- re(f[0] - u.x),
8138
- re(f[1] - u.y)
8136
+ const a = n[0] - s.world[0], l = n[1] - s.world[1], d = a * a + l * l <= B$, c = [se(n[0]), se(n[1])], u = nw(o, s, c), f = d ? s.world : c, p = [
8137
+ se(f[0] - u.x),
8138
+ se(f[1] - u.y)
8139
8139
  ], h = Gt(i, e);
8140
8140
  return r.dispatch((g) => {
8141
- const w = { id: h, kind: e }, E = { at: p }, k = `${h}.${u.id}`, b = s.isBus && s.busId ? s.busId : t, S = {
8142
- id: at(b, k),
8143
- ends: [b, k]
8141
+ const w = { id: h, kind: e }, E = { at: p }, k = `${h}.${u.id}`, x = s.isBus && s.busId ? s.busId : t, $ = {
8142
+ id: at(x, k),
8143
+ ends: [x, k]
8144
8144
  };
8145
8145
  return {
8146
8146
  ...g,
8147
8147
  elements: [...g.elements, w],
8148
- wires: [...g.wires ?? [], S],
8148
+ wires: [...g.wires ?? [], $],
8149
8149
  layout: { ...g.layout ?? {}, [h]: E }
8150
8150
  };
8151
8151
  }), r.setSelection([h]), { newElementId: h, attachedToBus: s.isBus };
@@ -8187,12 +8187,12 @@ function R$(e) {
8187
8187
  return t.length !== 4 || t.some((n) => Number.isNaN(n)) ? null : { x: t[0], y: t[1], w: t[2], h: t[3] };
8188
8188
  }
8189
8189
  function F$() {
8190
- const e = x((r) => r.internal.elements), t = x((r) => r.internal.layout), n = x(
8190
+ const e = b((r) => r.internal.elements), t = b((r) => r.internal.layout), n = b(
8191
8191
  (r) => {
8192
8192
  var i;
8193
8193
  return ((i = r.diagram.meta) == null ? void 0 : i.labelMode) ?? "all";
8194
8194
  }
8195
- ), o = x((r) => r.editingElement);
8195
+ ), o = b((r) => r.editingElement);
8196
8196
  return /* @__PURE__ */ m("g", { className: "ole-annotation-layer", pointerEvents: "none", children: Array.from(e.values()).map((r) => {
8197
8197
  var c;
8198
8198
  const i = t.get(r.element.id);
@@ -8251,7 +8251,7 @@ function H$({
8251
8251
  }, [e]);
8252
8252
  function i() {
8253
8253
  var f;
8254
- const l = x.getState(), d = l.diagram.elements.find((p) => p.id === e);
8254
+ const l = b.getState(), d = l.diagram.elements.find((p) => p.id === e);
8255
8255
  if (!d) {
8256
8256
  l.setEditingElement(null);
8257
8257
  return;
@@ -8307,7 +8307,7 @@ function H$({
8307
8307
  }
8308
8308
  const ow = 8, Yt = 1.25;
8309
8309
  function W$() {
8310
- const e = x((o) => o.diagram.annotations), t = x((o) => o.selectedAnnotation), n = x((o) => o.editingAnnotation);
8310
+ const e = b((o) => o.diagram.annotations), t = b((o) => o.selectedAnnotation), n = b((o) => o.editingAnnotation);
8311
8311
  return !e || e.length === 0 ? null : /* @__PURE__ */ m("g", { className: "ole-free-annotation-layer", children: e.map(
8312
8312
  (o) => n === o.id ? /* @__PURE__ */ m(G$, { ann: o }, o.id) : /* @__PURE__ */ m(
8313
8313
  q$,
@@ -8384,7 +8384,7 @@ function G$({ ann: e }) {
8384
8384
  }, [e.id]);
8385
8385
  function o() {
8386
8386
  var d;
8387
- const a = x.getState(), l = (((d = t.current) == null ? void 0 : d.innerText) ?? "").replace(/\u00a0/g, " ").trimEnd();
8387
+ const a = b.getState(), l = (((d = t.current) == null ? void 0 : d.innerText) ?? "").replace(/\u00a0/g, " ").trimEnd();
8388
8388
  l === "" ? a.deleteAnnotation(e.id) : l !== e.text && a.updateAnnotation(e.id, { text: l }), a.setEditingAnnotation(null), l !== "" && a.setSelectedAnnotation(e.id), a.activeTool === "text" && a.setActiveTool("select");
8389
8389
  }
8390
8390
  function r(a) {
@@ -8439,7 +8439,7 @@ function G$({ ann: e }) {
8439
8439
  }
8440
8440
  const X$ = 20;
8441
8441
  function K$() {
8442
- const e = x((c) => c.selection), t = x((c) => c.internal);
8442
+ const e = b((c) => c.selection), t = b((c) => c.internal);
8443
8443
  if (e.length !== 1) return null;
8444
8444
  const n = e[0], o = t.buses.get(n);
8445
8445
  if (!o) return null;
@@ -8476,7 +8476,7 @@ function Vo({
8476
8476
  }) {
8477
8477
  const i = et(), s = me(null), a = (c) => {
8478
8478
  if (c.button !== 0 || (c.stopPropagation(), c.preventDefault(), !i)) return;
8479
- const u = x.getState().internal.buses.get(n);
8479
+ const u = b.getState().internal.buses.get(n);
8480
8480
  u && (s.current = {
8481
8481
  pointerId: c.pointerId,
8482
8482
  startSpan: u.geometry.span,
@@ -8489,7 +8489,7 @@ function Vo({
8489
8489
  const f = i.screenToSvg(c.clientX, c.clientY), p = r === "x" ? f[0] - u.startSvg[0] : f[1] - u.startSvg[1], h = Zx() ? Math.round(p / Xt) * Xt : p, g = u.startSpan + (o === "end" ? h : -h);
8490
8490
  if (g < X$) return;
8491
8491
  const w = r === "x" ? [u.startAt[0] + h / 2, u.startAt[1]] : [u.startAt[0], u.startAt[1] + h / 2];
8492
- x.getState().updateBus(n, { span: g, at: w });
8492
+ b.getState().updateBus(n, { span: g, at: w });
8493
8493
  }, d = (c) => {
8494
8494
  const u = s.current;
8495
8495
  !u || c.pointerId !== u.pointerId || (c.target.hasPointerCapture(c.pointerId) && c.target.releasePointerCapture(c.pointerId), s.current = null);
@@ -8514,7 +8514,7 @@ function Et(e, t) {
8514
8514
  return Math.abs(e[1] - t[1]) < On ? "h" : "v";
8515
8515
  }
8516
8516
  function Y$() {
8517
- const e = x((a) => a.selectedWire), t = x((a) => a.internal.wireRenders);
8517
+ const e = b((a) => a.selectedWire), t = b((a) => a.internal.wireRenders);
8518
8518
  if (!e) return null;
8519
8519
  const n = t.get(e);
8520
8520
  if (!n || n.path.length < 2) return null;
@@ -8560,14 +8560,14 @@ function V$({
8560
8560
  xLocked: n,
8561
8561
  yLocked: o
8562
8562
  }) {
8563
- const r = et(), i = me(null), s = x((h) => {
8563
+ const r = et(), i = me(null), s = b((h) => {
8564
8564
  var g;
8565
8565
  return (g = h.internal.wireRenders.get(e)) == null ? void 0 : g.path;
8566
8566
  });
8567
8567
  if (!s || t <= 0 || t >= s.length - 1) return null;
8568
8568
  const [a, l] = s[t], d = n && !o ? "ns-resize" : !n && o ? "ew-resize" : "move", c = (h) => {
8569
8569
  if (h.button !== 0 || (h.stopPropagation(), h.preventDefault(), !r)) return;
8570
- const g = x.getState().internal.wireRenders.get(e);
8570
+ const g = b.getState().internal.wireRenders.get(e);
8571
8571
  g && (i.current = {
8572
8572
  pointerId: h.pointerId,
8573
8573
  startPath: g.path.map((w) => [w[0], w[1]]),
@@ -8581,17 +8581,17 @@ function V$({
8581
8581
  if (!g || h.pointerId !== g.pointerId || !r) return;
8582
8582
  const w = r.screenToSvg(h.clientX, h.clientY), E = g.startPath, k = g.index;
8583
8583
  if (k <= 0 || k >= E.length - 1) return;
8584
- const b = E[k], S = [
8585
- g.xLocked ? b[0] : re(b[0] + (w[0] - g.startSvg[0])),
8586
- g.yLocked ? b[1] : re(b[1] + (w[1] - g.startSvg[1]))
8584
+ const x = E[k], $ = [
8585
+ g.xLocked ? x[0] : se(x[0] + (w[0] - g.startSvg[0])),
8586
+ g.yLocked ? x[1] : se(x[1] + (w[1] - g.startSvg[1]))
8587
8587
  ];
8588
- if (S[0] === b[0] && S[1] === b[1]) return;
8589
- const C = E.map((V) => [V[0], V[1]]);
8590
- C[k] = S;
8588
+ if ($[0] === x[0] && $[1] === x[1]) return;
8589
+ const C = E.map((K) => [K[0], K[1]]);
8590
+ C[k] = $;
8591
8591
  const j = Et(E[k - 1], E[k]);
8592
- k - 1 > 0 && (j === "h" ? C[k - 1] = [E[k - 1][0], S[1]] : C[k - 1] = [S[0], E[k - 1][1]]);
8593
- const q = Et(E[k], E[k + 1]);
8594
- k + 1 < E.length - 1 && (q === "h" ? C[k + 1] = [E[k + 1][0], S[1]] : C[k + 1] = [S[0], E[k + 1][1]]), x.getState().updateWirePath(e, C);
8592
+ k - 1 > 0 && (j === "h" ? C[k - 1] = [E[k - 1][0], $[1]] : C[k - 1] = [$[0], E[k - 1][1]]);
8593
+ const W = Et(E[k], E[k + 1]);
8594
+ k + 1 < E.length - 1 && (W === "h" ? C[k + 1] = [E[k + 1][0], $[1]] : C[k + 1] = [$[0], E[k + 1][1]]), b.getState().updateWirePath(e, C);
8595
8595
  }, f = (h) => {
8596
8596
  const g = i.current;
8597
8597
  !g || h.pointerId !== g.pointerId || (h.target.hasPointerCapture(h.pointerId) && h.target.releasePointerCapture(h.pointerId), i.current = null, document.body.style.cursor = "");
@@ -8610,10 +8610,10 @@ function V$({
8610
8610
  onPointerCancel: f,
8611
8611
  onDoubleClick: (h) => {
8612
8612
  h.stopPropagation(), h.preventDefault();
8613
- const g = x.getState().internal.wireRenders.get(e);
8613
+ const g = b.getState().internal.wireRenders.get(e);
8614
8614
  if (!g || g.path.length <= 2 || t <= 0 || t >= g.path.length - 1) return;
8615
8615
  const w = g.path.filter((E, k) => k !== t);
8616
- x.getState().updateWirePath(e, w);
8616
+ b.getState().updateWirePath(e, w);
8617
8617
  }
8618
8618
  }
8619
8619
  );
@@ -8623,14 +8623,14 @@ function U$({
8623
8623
  segIndex: t,
8624
8624
  axis: n
8625
8625
  }) {
8626
- const o = et(), r = me(null), i = x((h) => {
8626
+ const o = et(), r = me(null), i = b((h) => {
8627
8627
  var g;
8628
8628
  return (g = h.internal.wireRenders.get(e)) == null ? void 0 : g.path;
8629
8629
  });
8630
8630
  if (!i || t < 0 || t >= i.length - 1) return null;
8631
8631
  const s = i[t], a = i[t + 1], l = (s[0] + a[0]) / 2, d = (s[1] + a[1]) / 2, c = n === "h" ? "ns-resize" : "ew-resize", u = (h) => {
8632
8632
  if (h.button !== 0 || (h.stopPropagation(), h.preventDefault(), !o)) return;
8633
- const g = x.getState().internal.wireRenders.get(e);
8633
+ const g = b.getState().internal.wireRenders.get(e);
8634
8634
  g && (r.current = {
8635
8635
  pointerId: h.pointerId,
8636
8636
  startPath: g.path.map((w) => [w[0], w[1]]),
@@ -8643,17 +8643,17 @@ function U$({
8643
8643
  if (!g || h.pointerId !== g.pointerId || !o) return;
8644
8644
  const w = o.screenToSvg(h.clientX, h.clientY), E = g.startPath, k = g.segIndex;
8645
8645
  if (k >= E.length - 1) return;
8646
- const b = E[k], S = E[k + 1], C = [];
8646
+ const x = E[k], $ = E[k + 1], C = [];
8647
8647
  for (let j = 0; j <= k; j++) C.push(E[j]);
8648
8648
  if (g.axis === "h") {
8649
- const j = re(b[1] + (w[1] - g.startSvg[1]));
8650
- C.push([b[0], j]), C.push([S[0], j]);
8649
+ const j = se(x[1] + (w[1] - g.startSvg[1]));
8650
+ C.push([x[0], j]), C.push([$[0], j]);
8651
8651
  } else {
8652
- const j = re(b[0] + (w[0] - g.startSvg[0]));
8653
- C.push([j, b[1]]), C.push([j, S[1]]);
8652
+ const j = se(x[0] + (w[0] - g.startSvg[0]));
8653
+ C.push([j, x[1]]), C.push([j, $[1]]);
8654
8654
  }
8655
8655
  for (let j = k + 1; j < E.length; j++) C.push(E[j]);
8656
- x.getState().updateWirePath(e, C);
8656
+ b.getState().updateWirePath(e, C);
8657
8657
  }, p = (h) => {
8658
8658
  const g = r.current;
8659
8659
  if (!g || h.pointerId !== g.pointerId) return;
@@ -8694,7 +8694,7 @@ function U$({
8694
8694
  }
8695
8695
  const J$ = 3, vn = 12;
8696
8696
  function Z$() {
8697
- const e = x((a) => a.internal.buses), t = x((a) => a.selection), n = x((a) => a.selectedNode), o = x((a) => a.internal.nodes), r = x((a) => a.internal.terminalToNode), i = new Set(t), s = /* @__PURE__ */ new Set();
8697
+ const e = b((a) => a.internal.buses), t = b((a) => a.selection), n = b((a) => a.selectedNode), o = b((a) => a.internal.nodes), r = b((a) => a.internal.terminalToNode), i = new Set(t), s = /* @__PURE__ */ new Set();
8698
8698
  if (n) {
8699
8699
  const a = o.get(n);
8700
8700
  if (a)
@@ -8702,13 +8702,13 @@ function Z$() {
8702
8702
  !l.includes(".") && e.has(l) && s.add(l);
8703
8703
  }
8704
8704
  return /* @__PURE__ */ m("g", { className: "ole-bus-layer", children: Array.from(e.values()).map(({ bus: a, geometry: l }) => {
8705
- const { axis: d, at: c, span: u } = l, f = u / 2, p = d === "x" ? c[0] - f : c[0], h = d === "x" ? c[1] : c[1] - f, g = d === "x" ? c[0] + f : c[0], w = d === "x" ? c[1] : c[1] + f, E = i.has(a.id), k = s.has(a.id), b = r.get(a.id) ?? void 0, S = vn / 2, C = d === "x" ? c[0] - f : c[0] - S, j = d === "x" ? c[1] - S : c[1] - f, q = d === "x" ? u : vn, V = d === "x" ? vn : u;
8705
+ const { axis: d, at: c, span: u } = l, f = u / 2, p = d === "x" ? c[0] - f : c[0], h = d === "x" ? c[1] : c[1] - f, g = d === "x" ? c[0] + f : c[0], w = d === "x" ? c[1] : c[1] + f, E = i.has(a.id), k = s.has(a.id), x = r.get(a.id) ?? void 0, $ = vn / 2, C = d === "x" ? c[0] - f : c[0] - $, j = d === "x" ? c[1] - $ : c[1] - f, W = d === "x" ? u : vn, K = d === "x" ? vn : u;
8706
8706
  return /* @__PURE__ */ B(
8707
8707
  "g",
8708
8708
  {
8709
8709
  "data-bus-id": a.id,
8710
8710
  "data-element-id": a.id,
8711
- "data-node-id": b,
8711
+ "data-node-id": x,
8712
8712
  "data-selected": E ? "true" : void 0,
8713
8713
  "data-node-related": k ? "true" : void 0,
8714
8714
  className: "ole-bus",
@@ -8718,8 +8718,8 @@ function Z$() {
8718
8718
  {
8719
8719
  x: C,
8720
8720
  y: j,
8721
- width: q,
8722
- height: V,
8721
+ width: W,
8722
+ height: K,
8723
8723
  fill: "transparent",
8724
8724
  className: "ole-bus-hit"
8725
8725
  }
@@ -8744,7 +8744,7 @@ function Z$() {
8744
8744
  }) });
8745
8745
  }
8746
8746
  function Q$() {
8747
- const e = x((a) => a.busbarDrawStart), t = x((a) => a.cursorSvg);
8747
+ const e = b((a) => a.busbarDrawStart), t = b((a) => a.cursorSvg);
8748
8748
  if (!e || !t) return null;
8749
8749
  const n = t[0] - e[0], o = t[1] - e[1], r = Math.abs(n) >= Math.abs(o), i = r ? t[0] : e[0], s = r ? e[1] : t[1];
8750
8750
  return /* @__PURE__ */ B("g", { className: "ole-busbar-preview", pointerEvents: "none", children: [
@@ -8780,7 +8780,7 @@ function Q$() {
8780
8780
  }
8781
8781
  const eS = 4, tS = 9;
8782
8782
  function nS() {
8783
- const e = x((a) => a.internal.junctions), t = x((a) => a.selection), n = x((a) => a.selectedNode), o = x((a) => a.internal.nodes), r = x((a) => a.internal.terminalToNode), i = new Set(t), s = /* @__PURE__ */ new Set();
8783
+ const e = b((a) => a.internal.junctions), t = b((a) => a.selection), n = b((a) => a.selectedNode), o = b((a) => a.internal.nodes), r = b((a) => a.internal.terminalToNode), i = new Set(t), s = /* @__PURE__ */ new Set();
8784
8784
  if (n) {
8785
8785
  const a = o.get(n);
8786
8786
  if (a) for (const l of a.terminals) s.add(l);
@@ -8827,7 +8827,7 @@ function rS({ lib: e }) {
8827
8827
  ) : null;
8828
8828
  }
8829
8829
  function iS() {
8830
- const e = x((a) => a.internal.elements), t = x((a) => a.internal.layout), n = x((a) => a.selection), o = x((a) => a.selectedNode), r = x((a) => a.internal.nodes), i = new Set(n), s = /* @__PURE__ */ new Set();
8830
+ const e = b((a) => a.internal.elements), t = b((a) => a.internal.layout), n = b((a) => a.selection), o = b((a) => a.selectedNode), r = b((a) => a.internal.nodes), i = new Set(n), s = /* @__PURE__ */ new Set();
8831
8831
  if (o) {
8832
8832
  const a = r.get(o);
8833
8833
  if (a)
@@ -8923,7 +8923,7 @@ function lS() {
8923
8923
  );
8924
8924
  }
8925
8925
  function cS() {
8926
- const e = x((d) => d.activeTool), t = x((d) => d.placeKind), n = x((d) => d.cursorSvg), o = x((d) => d.placeFromTerminal);
8926
+ const e = b((d) => d.activeTool), t = b((d) => d.placeKind), n = b((d) => d.cursorSvg), o = b((d) => d.placeFromTerminal);
8927
8927
  if (e !== "place" || !t || !n) return null;
8928
8928
  const r = N$(t);
8929
8929
  if (!r) return null;
@@ -8968,7 +8968,7 @@ function cS() {
8968
8968
  ] });
8969
8969
  }
8970
8970
  function dS() {
8971
- const e = x((r) => r.selection), t = x((r) => r.internal.elements), n = x((r) => r.internal.layout), o = x((r) => r.internal.buses);
8971
+ const e = b((r) => r.selection), t = b((r) => r.internal.elements), n = b((r) => r.internal.layout), o = b((r) => r.internal.buses);
8972
8972
  return e.length === 0 ? null : /* @__PURE__ */ m("g", { className: "ole-selection-overlay", pointerEvents: "none", children: e.map((r) => {
8973
8973
  const i = o.get(r);
8974
8974
  if (i) {
@@ -9009,7 +9009,7 @@ function uS(e) {
9009
9009
  return t.length !== 4 || t.some((n) => Number.isNaN(n)) ? null : { x: t[0], y: t[1], w: t[2], h: t[3] };
9010
9010
  }
9011
9011
  function mS() {
9012
- const e = x((i) => i.internal.terminals), t = x((i) => i.internal.terminalToNode), n = x((i) => i.wireFromTerminal), o = x((i) => i.selection), r = new Set(o);
9012
+ const e = b((i) => i.internal.terminals), t = b((i) => i.internal.terminalToNode), n = b((i) => i.wireFromTerminal), o = b((i) => i.selection), r = new Set(o);
9013
9013
  return /* @__PURE__ */ m("g", { className: "ole-terminal-layer", children: Array.from(e.values()).map((i) => {
9014
9014
  const s = t.get(i.ref), a = s !== void 0, l = n === i.ref, d = r.has(i.elementId);
9015
9015
  return /* @__PURE__ */ m(
@@ -9031,7 +9031,7 @@ function mS() {
9031
9031
  }) });
9032
9032
  }
9033
9033
  function fS() {
9034
- const e = x((s) => s.internal.wireRenders), t = x((s) => s.internal.terminalToNode), n = x((s) => s.diagram.wires), o = x((s) => s.selectedWire), r = x((s) => s.selectedNode), i = /* @__PURE__ */ new Map();
9034
+ const e = b((s) => s.internal.wireRenders), t = b((s) => s.internal.terminalToNode), n = b((s) => s.diagram.wires), o = b((s) => s.selectedWire), r = b((s) => s.selectedNode), i = /* @__PURE__ */ new Map();
9035
9035
  for (const s of n ?? []) {
9036
9036
  const a = t.get(s.ends[0]);
9037
9037
  a && i.set(s.id, a);
@@ -9068,7 +9068,7 @@ function fS() {
9068
9068
  }
9069
9069
  let Ze = null;
9070
9070
  const jn = /* @__PURE__ */ new Set();
9071
- function De(e) {
9071
+ function Re(e) {
9072
9072
  if (!(e === null && Ze === null || e && Ze && e.ref === Ze.ref && e.world[0] === Ze.world[0] && e.world[1] === Ze.world[1])) {
9073
9073
  Ze = e;
9074
9074
  for (const t of jn) t(e);
@@ -9083,7 +9083,7 @@ function pS(e) {
9083
9083
  };
9084
9084
  }
9085
9085
  function gS() {
9086
- const e = x((l) => l.wireDragFrom), t = x((l) => l.cursorSvg), [n, o] = pe(hS());
9086
+ const e = b((l) => l.wireDragFrom), t = b((l) => l.cursorSvg), [n, o] = pe(hS());
9087
9087
  if (ne(() => pS(o), []), !e || !t) return null;
9088
9088
  const r = e.world, i = (n == null ? void 0 : n.world[0]) ?? t[0], s = (n == null ? void 0 : n.world[1]) ?? t[1], a = (n == null ? void 0 : n.create) === "junction";
9089
9089
  return /* @__PURE__ */ B("g", { className: "ole-wire-preview", pointerEvents: "none", children: [
@@ -9184,7 +9184,7 @@ function xS(e) {
9184
9184
  return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || e.isContentEditable;
9185
9185
  }
9186
9186
  function sw() {
9187
- const e = x.getState(), t = e.activeTool;
9187
+ const e = b.getState(), t = e.activeTool;
9188
9188
  if (e.editingAnnotation || e.editingElement) {
9189
9189
  if (typeof document < "u") {
9190
9190
  const n = document.querySelector(
@@ -9209,7 +9209,7 @@ function wS() {
9209
9209
  ne(() => {
9210
9210
  const e = (t) => {
9211
9211
  if (xS(t.target)) return;
9212
- const n = t.metaKey || t.ctrlKey, o = x.getState();
9212
+ const n = t.metaKey || t.ctrlKey, o = b.getState();
9213
9213
  if (n && t.key.toLowerCase() === "z") {
9214
9214
  t.preventDefault(), t.shiftKey ? o.redo() : o.undo();
9215
9215
  return;
@@ -9220,7 +9220,7 @@ function wS() {
9220
9220
  }
9221
9221
  if (n && t.key.toLowerCase() === "a") {
9222
9222
  t.preventDefault();
9223
- const r = x.getState().diagram.elements.map((i) => i.id);
9223
+ const r = b.getState().diagram.elements.map((i) => i.id);
9224
9224
  o.setSelection(r);
9225
9225
  return;
9226
9226
  }
@@ -9341,7 +9341,7 @@ function NS(e) {
9341
9341
  a(ut(u.target));
9342
9342
  const f = ct(u.target);
9343
9343
  let p = null;
9344
- f ? p = x.getState().internal.terminalToNode.get(f) ?? null : p = rn(u.target), l(p);
9344
+ f ? p = b.getState().internal.terminalToNode.get(f) ?? null : p = rn(u.target), l(p);
9345
9345
  }, c = () => {
9346
9346
  a(null), l(null);
9347
9347
  };
@@ -9354,7 +9354,7 @@ function jt(e) {
9354
9354
  return e.replace(/(["\\])/g, "\\$1");
9355
9355
  }
9356
9356
  function aw(e, t) {
9357
- const n = x.getState().internal;
9357
+ const n = b.getState().internal;
9358
9358
  if (!e.includes(".")) {
9359
9359
  const r = n.buses.get(e);
9360
9360
  if (r) {
@@ -9373,61 +9373,61 @@ function aw(e, t) {
9373
9373
  return o ? { ref: e, world: o.world, isBus: !1 } : null;
9374
9374
  }
9375
9375
  const Jo = 3;
9376
- let ue = null, Me = null, Te = null, he = null;
9376
+ let ie = null, Me = null, Te = null, he = null;
9377
9377
  const ES = {
9378
9378
  id: "select",
9379
9379
  cursor: "default",
9380
9380
  onPointerDown(e, t) {
9381
- var f, p, h, g, w, E, k;
9381
+ var p, h, g, w, E, k, x;
9382
9382
  if (e.button !== 0 || e.target instanceof Element && e.target.closest(".ole-bus-handle, .ole-wire-handle"))
9383
9383
  return;
9384
- const n = x.getState(), o = Vt(e.target);
9384
+ const n = b.getState(), o = Vt(e.target);
9385
9385
  if (o) {
9386
9386
  e.preventDefault(), e.stopPropagation();
9387
- const b = (f = n.diagram.annotations) == null ? void 0 : f.find((S) => S.id === o);
9388
- if (!b) return;
9387
+ const $ = (p = n.diagram.annotations) == null ? void 0 : p.find((C) => C.id === o);
9388
+ if (!$) return;
9389
9389
  n.setSelectedAnnotation(o), he = {
9390
9390
  pointerId: e.pointerId,
9391
9391
  id: o,
9392
9392
  startSvg: t.viewport.screenToSvg(e.clientX, e.clientY),
9393
- origin: [b.at[0], b.at[1]],
9393
+ origin: [$.at[0], $.at[1]],
9394
9394
  moved: !1
9395
9395
  };
9396
9396
  return;
9397
9397
  }
9398
- const i = (e.target instanceof Element ? (p = e.target.closest("[data-terminal-id]")) == null ? void 0 : p.getAttribute("data-terminal-id") : null) ? ct(e.target) : null;
9398
+ const i = (e.target instanceof Element ? (h = e.target.closest("[data-terminal-id]")) == null ? void 0 : h.getAttribute("data-terminal-id") : null) ? ct(e.target) : null;
9399
9399
  if (i) {
9400
- const b = i.indexOf("."), S = b > 0 ? i.slice(0, b) : "";
9401
- if (S && n.selection.includes(S)) {
9402
- e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((g = (h = e.target).hasPointerCapture) != null && g.call(h, e.pointerId)) && e.target.releasePointerCapture(e.pointerId), t.hostEl.classList.add("tool-wire"), n.setWireFromTerminal(i), n.setCursorSvg(t.viewport.screenToSvg(e.clientX, e.clientY)), Te = { pointerId: e.pointerId, fromRef: i };
9400
+ const $ = i.indexOf("."), C = $ > 0 ? i.slice(0, $) : "";
9401
+ if (C && n.selection.includes(C)) {
9402
+ e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((w = (g = e.target).hasPointerCapture) != null && w.call(g, e.pointerId)) && e.target.releasePointerCapture(e.pointerId), t.hostEl.classList.add("tool-wire"), n.setWireFromTerminal(i), n.setCursorSvg(t.viewport.screenToSvg(e.clientX, e.clientY)), Te = { pointerId: e.pointerId, fromRef: i };
9403
9403
  return;
9404
9404
  }
9405
9405
  }
9406
9406
  let s = ut(e.target);
9407
9407
  if (!s) {
9408
- const b = Ln(e.target);
9409
- if (b && typeof document < "u") {
9410
- const S = document.elementsFromPoint(e.clientX, e.clientY);
9411
- for (const C of S) {
9412
- const j = (E = (w = C.closest) == null ? void 0 : w.call(C, "[data-bus-id]")) == null ? void 0 : E.getAttribute("data-bus-id");
9413
- if (!j) continue;
9414
- const q = (k = n.diagram.wires) == null ? void 0 : k.find((V) => V.id === b);
9415
- q && (q.ends[0] === j || q.ends[1] === j) && (s = j);
9408
+ const $ = Ln(e.target);
9409
+ if ($ && typeof document < "u") {
9410
+ const C = document.elementsFromPoint(e.clientX, e.clientY);
9411
+ for (const j of C) {
9412
+ const W = (k = (E = j.closest) == null ? void 0 : E.call(j, "[data-bus-id]")) == null ? void 0 : k.getAttribute("data-bus-id");
9413
+ if (!W) continue;
9414
+ const K = (x = n.diagram.wires) == null ? void 0 : x.find((re) => re.id === $);
9415
+ K && (K.ends[0] === W || K.ends[1] === W) && (s = W);
9416
9416
  break;
9417
9417
  }
9418
9418
  }
9419
9419
  }
9420
9420
  if (!s) {
9421
- const b = Ln(e.target);
9422
- if (b) {
9421
+ const $ = Ln(e.target);
9422
+ if ($) {
9423
9423
  if (e.preventDefault(), e.altKey) {
9424
- const S = rn(e.target);
9425
- if (S) {
9426
- n.setSelectedNode(S);
9424
+ const C = rn(e.target);
9425
+ if (C) {
9426
+ n.setSelectedNode(C);
9427
9427
  return;
9428
9428
  }
9429
9429
  }
9430
- n.setSelectedWire(b);
9430
+ n.setSelectedWire($);
9431
9431
  return;
9432
9432
  }
9433
9433
  e.shiftKey || n.clearSelection(), Me = {
@@ -9440,53 +9440,59 @@ const ES = {
9440
9440
  }
9441
9441
  const a = n.selection;
9442
9442
  e.shiftKey ? n.toggleInSelection(s) : a.includes(s) || n.setSelection([s]);
9443
- const l = e.shiftKey ? x.getState().selection : a.includes(s) ? a : [s];
9443
+ const l = e.shiftKey ? b.getState().selection : a.includes(s) ? a : [s];
9444
9444
  if (l.length === 0) return;
9445
- const d = x.getState().internal, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
9446
- for (const b of l) {
9447
- const S = d.buses.get(b);
9448
- if (S) {
9449
- u.set(b, [S.geometry.at[0], S.geometry.at[1]]);
9445
+ const d = b.getState().internal, c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
9446
+ for (const $ of l) {
9447
+ const C = d.buses.get($);
9448
+ if (C) {
9449
+ u.set($, [C.geometry.at[0], C.geometry.at[1]]);
9450
+ continue;
9451
+ }
9452
+ const j = d.junctions.get($);
9453
+ if (j) {
9454
+ f.set($, [j.world[0], j.world[1]]);
9450
9455
  continue;
9451
9456
  }
9452
- const C = d.layout.get(b);
9453
- C && c.set(b, { ...C });
9457
+ const W = d.layout.get($);
9458
+ W && c.set($, { ...W });
9454
9459
  }
9455
- c.size === 0 && u.size === 0 || (ue = {
9460
+ c.size === 0 && u.size === 0 && f.size === 0 || (ie = {
9456
9461
  pointerId: e.pointerId,
9457
9462
  startSvg: t.viewport.screenToSvg(e.clientX, e.clientY),
9458
9463
  originals: c,
9459
9464
  busOriginals: u,
9465
+ junctionOriginals: f,
9460
9466
  moved: !1
9461
9467
  }, e.preventDefault());
9462
9468
  },
9463
9469
  onPointerMove(e, t) {
9464
9470
  if (he && e.pointerId === he.pointerId) {
9465
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = re(n[0] - he.startSvg[0]), r = re(n[1] - he.startSvg[1]);
9471
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = se(n[0] - he.startSvg[0]), r = se(n[1] - he.startSvg[1]);
9466
9472
  !he.moved && (o !== 0 || r !== 0) && (he.moved = !0, t.hostEl.hasPointerCapture(e.pointerId) || t.hostEl.setPointerCapture(e.pointerId));
9467
9473
  const i = t.hostEl.querySelector(
9468
- `[data-annotation-id="${Xe(he.id)}"]`
9474
+ `[data-annotation-id="${je(he.id)}"]`
9469
9475
  );
9470
9476
  i && i.setAttribute("transform", `translate(${o} ${r})`);
9471
9477
  return;
9472
9478
  }
9473
9479
  if (Te && e.pointerId === Te.pointerId) {
9474
9480
  const n = t.viewport.screenToSvg(e.clientX, e.clientY);
9475
- x.getState().setCursorSvg(n);
9481
+ b.getState().setCursorSvg(n);
9476
9482
  const o = typeof document < "u" ? document.elementFromPoint(e.clientX, e.clientY) : null, r = o ? ct(o) : null;
9477
9483
  if (!r || r === Te.fromRef) {
9478
- De(null);
9484
+ Re(null);
9479
9485
  return;
9480
9486
  }
9481
- De(aw(r, n));
9487
+ Re(aw(r, n));
9482
9488
  return;
9483
9489
  }
9484
- if (ue && e.pointerId === ue.pointerId) {
9485
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = re(n[0] - ue.startSvg[0]), r = re(n[1] - ue.startSvg[1]);
9486
- !ue.moved && (o !== 0 || r !== 0) && (ue.moved = !0, t.hostEl.hasPointerCapture(e.pointerId) || t.hostEl.setPointerCapture(e.pointerId));
9487
- for (const [i, s] of ue.originals) {
9490
+ if (ie && e.pointerId === ie.pointerId) {
9491
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = se(n[0] - ie.startSvg[0]), r = se(n[1] - ie.startSvg[1]);
9492
+ !ie.moved && (o !== 0 || r !== 0) && (ie.moved = !0, t.hostEl.hasPointerCapture(e.pointerId) || t.hostEl.setPointerCapture(e.pointerId));
9493
+ for (const [i, s] of ie.originals) {
9488
9494
  const a = t.hostEl.querySelector(
9489
- `[data-element-id="${Xe(i)}"]`
9495
+ `[data-element-id="${je(i)}"]`
9490
9496
  );
9491
9497
  if (!a) continue;
9492
9498
  const l = {
@@ -9495,9 +9501,15 @@ const ES = {
9495
9501
  };
9496
9502
  a.setAttribute("transform", Ke(l));
9497
9503
  }
9498
- for (const i of ue.busOriginals.keys()) {
9504
+ for (const i of ie.busOriginals.keys()) {
9505
+ const s = t.hostEl.querySelector(
9506
+ `[data-element-id="${je(i)}"]`
9507
+ );
9508
+ s && s.setAttribute("transform", `translate(${o} ${r})`);
9509
+ }
9510
+ for (const i of ie.junctionOriginals.keys()) {
9499
9511
  const s = t.hostEl.querySelector(
9500
- `[data-element-id="${Xe(i)}"]`
9512
+ `[data-element-id="${je(i)}"]`
9501
9513
  );
9502
9514
  s && s.setAttribute("transform", `translate(${o} ${r})`);
9503
9515
  }
@@ -9512,38 +9524,45 @@ const ES = {
9512
9524
  onPointerUp(e, t) {
9513
9525
  if (he && e.pointerId === he.pointerId) {
9514
9526
  t.hostEl.hasPointerCapture(e.pointerId) && t.hostEl.releasePointerCapture(e.pointerId);
9515
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = re(n[0] - he.startSvg[0]), r = re(n[1] - he.startSvg[1]), i = t.hostEl.querySelector(
9516
- `[data-annotation-id="${Xe(he.id)}"]`
9527
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = se(n[0] - he.startSvg[0]), r = se(n[1] - he.startSvg[1]), i = t.hostEl.querySelector(
9528
+ `[data-annotation-id="${je(he.id)}"]`
9517
9529
  );
9518
- i && i.removeAttribute("transform"), he.moved && (o !== 0 || r !== 0) && x.getState().updateAnnotation(he.id, {
9530
+ i && i.removeAttribute("transform"), he.moved && (o !== 0 || r !== 0) && b.getState().updateAnnotation(he.id, {
9519
9531
  at: [he.origin[0] + o, he.origin[1] + r]
9520
9532
  }), he = null;
9521
9533
  return;
9522
9534
  }
9523
9535
  if (Te && e.pointerId === Te.pointerId) {
9524
- const n = x.getState(), o = Te.fromRef;
9525
- Te = null, t.hostEl.classList.remove("tool-wire"), n.setWireFromTerminal(null), n.setCursorSvg(null), De(null);
9536
+ const n = b.getState(), o = Te.fromRef;
9537
+ Te = null, t.hostEl.classList.remove("tool-wire"), n.setWireFromTerminal(null), n.setCursorSvg(null), Re(null);
9526
9538
  const r = ct(e.target);
9527
9539
  r && r !== o && n.addWire(o, r);
9528
9540
  return;
9529
9541
  }
9530
- if (ue && e.pointerId === ue.pointerId) {
9531
- if (t.hostEl.hasPointerCapture(e.pointerId) && t.hostEl.releasePointerCapture(e.pointerId), ue.moved) {
9532
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = re(n[0] - ue.startSvg[0]), r = re(n[1] - ue.startSvg[1]);
9542
+ if (ie && e.pointerId === ie.pointerId) {
9543
+ if (t.hostEl.hasPointerCapture(e.pointerId) && t.hostEl.releasePointerCapture(e.pointerId), ie.moved) {
9544
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = se(n[0] - ie.startSvg[0]), r = se(n[1] - ie.startSvg[1]);
9533
9545
  if (o !== 0 || r !== 0) {
9534
9546
  const i = /* @__PURE__ */ new Map();
9535
- for (const s of ue.originals.keys()) i.set(s, [o, r]);
9536
- for (const s of ue.busOriginals.keys()) i.set(s, [o, r]);
9537
- x.getState().moveElements(i);
9547
+ for (const s of ie.originals.keys()) i.set(s, [o, r]);
9548
+ for (const s of ie.busOriginals.keys()) i.set(s, [o, r]);
9549
+ for (const s of ie.junctionOriginals.keys()) i.set(s, [o, r]);
9550
+ b.getState().moveElements(i);
9551
+ }
9552
+ for (const i of ie.busOriginals.keys()) {
9553
+ const s = t.hostEl.querySelector(
9554
+ `[data-element-id="${je(i)}"]`
9555
+ );
9556
+ s && s.removeAttribute("transform");
9538
9557
  }
9539
- for (const i of ue.busOriginals.keys()) {
9558
+ for (const i of ie.junctionOriginals.keys()) {
9540
9559
  const s = t.hostEl.querySelector(
9541
- `[data-element-id="${Xe(i)}"]`
9560
+ `[data-element-id="${je(i)}"]`
9542
9561
  );
9543
9562
  s && s.removeAttribute("transform");
9544
9563
  }
9545
9564
  }
9546
- ue = null;
9565
+ ie = null;
9547
9566
  return;
9548
9567
  }
9549
9568
  if (Me && e.pointerId === Me.pointerId) {
@@ -9555,9 +9574,9 @@ const ES = {
9555
9574
  const i = new Set(Me.baseSelection);
9556
9575
  for (const s of r)
9557
9576
  i.has(s) ? i.delete(s) : i.add(s);
9558
- x.getState().setSelection([...i]);
9577
+ b.getState().setSelection([...i]);
9559
9578
  } else
9560
- x.getState().setSelection(r);
9579
+ b.getState().setSelection(r);
9561
9580
  }
9562
9581
  Bt(null), Me = null;
9563
9582
  }
@@ -9566,7 +9585,7 @@ const ES = {
9566
9585
  var n, o, r, i, s, a;
9567
9586
  if (he && e.pointerId === he.pointerId) {
9568
9587
  const l = t.hostEl.querySelector(
9569
- `[data-annotation-id="${Xe(he.id)}"]`
9588
+ `[data-annotation-id="${je(he.id)}"]`
9570
9589
  );
9571
9590
  if (l && l.removeAttribute("transform"), (o = (n = t.hostEl).hasPointerCapture) != null && o.call(n, e.pointerId))
9572
9591
  try {
@@ -9575,16 +9594,22 @@ const ES = {
9575
9594
  }
9576
9595
  he = null;
9577
9596
  }
9578
- if (ue && e.pointerId === ue.pointerId) {
9579
- for (const [l, d] of ue.originals) {
9597
+ if (ie && e.pointerId === ie.pointerId) {
9598
+ for (const [l, d] of ie.originals) {
9580
9599
  const c = t.hostEl.querySelector(
9581
- `[data-element-id="${Xe(l)}"]`
9600
+ `[data-element-id="${je(l)}"]`
9582
9601
  );
9583
9602
  c && c.setAttribute("transform", Ke(d));
9584
9603
  }
9585
- for (const l of ue.busOriginals.keys()) {
9604
+ for (const l of ie.busOriginals.keys()) {
9605
+ const d = t.hostEl.querySelector(
9606
+ `[data-element-id="${je(l)}"]`
9607
+ );
9608
+ d && d.removeAttribute("transform");
9609
+ }
9610
+ for (const l of ie.junctionOriginals.keys()) {
9586
9611
  const d = t.hostEl.querySelector(
9587
- `[data-element-id="${Xe(l)}"]`
9612
+ `[data-element-id="${je(l)}"]`
9588
9613
  );
9589
9614
  d && d.removeAttribute("transform");
9590
9615
  }
@@ -9593,12 +9618,12 @@ const ES = {
9593
9618
  t.hostEl.releasePointerCapture(e.pointerId);
9594
9619
  } catch {
9595
9620
  }
9596
- ue = null;
9621
+ ie = null;
9597
9622
  }
9598
9623
  if (Te && e.pointerId === Te.pointerId) {
9599
9624
  t.hostEl.classList.remove("tool-wire");
9600
- const l = x.getState();
9601
- l.setWireFromTerminal(null), l.setCursorSvg(null), De(null), Te = null;
9625
+ const l = b.getState();
9626
+ l.setWireFromTerminal(null), l.setCursorSvg(null), Re(null), Te = null;
9602
9627
  }
9603
9628
  if (Me && e.pointerId === Me.pointerId) {
9604
9629
  if ((a = (s = t.hostEl).hasPointerCapture) != null && a.call(s, e.pointerId))
@@ -9610,7 +9635,7 @@ const ES = {
9610
9635
  }
9611
9636
  },
9612
9637
  onDoubleClick(e) {
9613
- const t = x.getState(), n = Vt(e.target);
9638
+ const t = b.getState(), n = Vt(e.target);
9614
9639
  if (n) {
9615
9640
  e.preventDefault(), e.stopPropagation(), t.setEditingAnnotation(n);
9616
9641
  return;
@@ -9619,10 +9644,10 @@ const ES = {
9619
9644
  o && (e.preventDefault(), e.stopPropagation(), t.setEditingElement(o));
9620
9645
  },
9621
9646
  onDeactivate(e) {
9622
- if (ue = null, Me = null, he = null, Te) {
9647
+ if (ie = null, Me = null, he = null, Te) {
9623
9648
  e.hostEl.classList.remove("tool-wire");
9624
- const t = x.getState();
9625
- t.setWireFromTerminal(null), t.setCursorSvg(null), De(null), Te = null;
9649
+ const t = b.getState();
9650
+ t.setWireFromTerminal(null), t.setCursorSvg(null), Re(null), Te = null;
9626
9651
  }
9627
9652
  Bt(null);
9628
9653
  }
@@ -9632,7 +9657,7 @@ function Zo(e, t) {
9632
9657
  return { x: n, y: o, w: r, h: i };
9633
9658
  }
9634
9659
  function MS(e) {
9635
- const { internal: t } = x.getState(), n = [];
9660
+ const { internal: t } = b.getState(), n = [];
9636
9661
  for (const o of t.elements.values()) {
9637
9662
  if (!o.libraryDef) continue;
9638
9663
  const r = t.layout.get(o.element.id);
@@ -9654,6 +9679,8 @@ function MS(e) {
9654
9679
  const { axis: i, at: s, span: a } = r, l = a / 2, d = i === "x" ? s[0] - l : s[0], c = i === "x" ? s[0] + l : s[0], u = i === "x" ? s[1] : s[1] - l, f = i === "x" ? s[1] : s[1] + l;
9655
9680
  c >= e.x && d <= e.x + e.w && f >= e.y && u <= e.y + e.h && n.push(o.id);
9656
9681
  }
9682
+ for (const { junction: o, world: r } of t.junctions.values())
9683
+ r[0] >= e.x && r[0] <= e.x + e.w && r[1] >= e.y && r[1] <= e.y + e.h && n.push(o.id);
9657
9684
  return n;
9658
9685
  }
9659
9686
  function TS(e, t) {
@@ -9677,7 +9704,7 @@ function AS(e) {
9677
9704
  const t = e.trim().split(/\s+/).map(Number);
9678
9705
  return t.length !== 4 || t.some((n) => Number.isNaN(n)) ? null : { x: t[0], y: t[1], w: t[2], h: t[3] };
9679
9706
  }
9680
- function Xe(e) {
9707
+ function je(e) {
9681
9708
  return e.replace(/(["\\])/g, "\\$1");
9682
9709
  }
9683
9710
  const CS = 4;
@@ -9690,9 +9717,9 @@ const IS = {
9690
9717
  const n = t.viewport.getViewport(), o = ut(e.target);
9691
9718
  let r = null;
9692
9719
  if (o) {
9693
- const i = x.getState();
9720
+ const i = b.getState();
9694
9721
  i.selection.includes(o) || i.setSelection([o]);
9695
- const s = x.getState().selection, a = x.getState().internal, l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
9722
+ const s = b.getState().selection, a = b.getState().internal, l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
9696
9723
  for (const c of s) {
9697
9724
  const u = a.buses.get(c);
9698
9725
  if (u) {
@@ -9731,7 +9758,7 @@ const IS = {
9731
9758
  }
9732
9759
  if (te.moved) {
9733
9760
  if (te.elementDrag) {
9734
- const r = t.viewport.screenToSvg(e.clientX, e.clientY), i = re(r[0] - te.elementDrag.startSvg[0]), s = re(r[1] - te.elementDrag.startSvg[1]);
9761
+ const r = t.viewport.screenToSvg(e.clientX, e.clientY), i = se(r[0] - te.elementDrag.startSvg[0]), s = se(r[1] - te.elementDrag.startSvg[1]);
9735
9762
  for (const [a, l] of te.elementDrag.originals) {
9736
9763
  const d = t.hostEl.querySelector(
9737
9764
  `[data-element-id="${_t(a)}"]`
@@ -9757,14 +9784,14 @@ const IS = {
9757
9784
  onPointerUp(e, t) {
9758
9785
  if (!(!te || e.pointerId !== te.pointerId)) {
9759
9786
  if (t.hostEl.hasPointerCapture(e.pointerId) && t.hostEl.releasePointerCapture(e.pointerId), t.hostEl.style.cursor = "grab", te.elementDrag && te.moved) {
9760
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = re(n[0] - te.elementDrag.startSvg[0]), r = re(n[1] - te.elementDrag.startSvg[1]);
9787
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = se(n[0] - te.elementDrag.startSvg[0]), r = se(n[1] - te.elementDrag.startSvg[1]);
9761
9788
  if (o !== 0 || r !== 0) {
9762
9789
  const i = /* @__PURE__ */ new Map();
9763
9790
  for (const s of te.elementDrag.originals.keys())
9764
9791
  i.set(s, [o, r]);
9765
9792
  for (const s of te.elementDrag.busOriginals.keys())
9766
9793
  i.set(s, [o, r]);
9767
- x.getState().moveElements(i);
9794
+ b.getState().moveElements(i);
9768
9795
  }
9769
9796
  for (const i of te.elementDrag.busOriginals.keys()) {
9770
9797
  const s = t.hostEl.querySelector(
@@ -9799,7 +9826,7 @@ const IS = {
9799
9826
  };
9800
9827
  function PS(e) {
9801
9828
  if (!e) return;
9802
- const t = x.getState(), n = Vt(e);
9829
+ const t = b.getState(), n = Vt(e);
9803
9830
  if (n) {
9804
9831
  t.setSelectedAnnotation(n);
9805
9832
  return;
@@ -9865,10 +9892,10 @@ function cw() {
9865
9892
  return window.innerWidth < St.dense;
9866
9893
  }
9867
9894
  function sn() {
9868
- cw() && x.getState().setActiveTool("pan");
9895
+ cw() && b.getState().setActiveTool("pan");
9869
9896
  }
9870
9897
  function jS() {
9871
- cw() && x.getState().setPlaceKind(null);
9898
+ cw() && b.getState().setPlaceKind(null);
9872
9899
  }
9873
9900
  const er = 10, Lt = (e) => Math.round(e / er) * er;
9874
9901
  function LS(e, t) {
@@ -9890,7 +9917,7 @@ function kn(e, t) {
9890
9917
  }
9891
9918
  const o = e ? Ln(e) : null;
9892
9919
  if (o) {
9893
- const i = x.getState().internal.wireRenders.get(o), s = i ? LS(i.path, t) : t, a = [Lt(s[0]), Lt(s[1])];
9920
+ const i = b.getState().internal.wireRenders.get(o), s = i ? LS(i.path, t) : t, a = [Lt(s[0]), Lt(s[1])];
9894
9921
  return { spec: { onWire: o, at: a }, world: a, ref: null, isBus: !1, create: !0 };
9895
9922
  }
9896
9923
  const r = [Lt(t[0]), Lt(t[1])];
@@ -9915,18 +9942,18 @@ const DS = {
9915
9942
  },
9916
9943
  onDeactivate(e) {
9917
9944
  e.hostEl.classList.remove("tool-wire");
9918
- const t = x.getState();
9919
- t.setWireFromTerminal(null), t.setWireDragFrom(null), t.setCursorSvg(null), De(null);
9945
+ const t = b.getState();
9946
+ t.setWireFromTerminal(null), t.setWireDragFrom(null), t.setCursorSvg(null), Re(null);
9920
9947
  },
9921
9948
  onPointerDown(e, t) {
9922
9949
  var i, s;
9923
9950
  if (e.button !== 0) return;
9924
9951
  e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((s = (i = e.target).hasPointerCapture) != null && s.call(i, e.pointerId)) && e.target.releasePointerCapture(e.pointerId);
9925
- const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = kn(e.target instanceof Element ? e.target : null, n), r = x.getState();
9952
+ const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = kn(e.target instanceof Element ? e.target : null, n), r = b.getState();
9926
9953
  r.setWireDragFrom({ spec: o.spec, world: o.world, ref: o.ref }), r.setWireFromTerminal(o.ref), r.setCursorSvg(n);
9927
9954
  },
9928
9955
  onPointerMove(e, t) {
9929
- const n = x.getState(), o = n.wireDragFrom;
9956
+ const n = b.getState(), o = n.wireDragFrom;
9930
9957
  if (!o) return;
9931
9958
  const r = t.viewport.screenToSvg(e.clientX, e.clientY);
9932
9959
  n.setCursorSvg(r);
@@ -9936,11 +9963,11 @@ const DS = {
9936
9963
  ref: o.ref,
9937
9964
  create: !o.ref
9938
9965
  };
9939
- De(nr(a, s) ? null : zS(s));
9966
+ Re(nr(a, s) ? null : zS(s));
9940
9967
  },
9941
9968
  onPointerUp(e, t) {
9942
- const n = x.getState(), o = n.wireDragFrom;
9943
- if (n.setWireFromTerminal(null), n.setWireDragFrom(null), n.setCursorSvg(null), De(null), !o) return;
9969
+ const n = b.getState(), o = n.wireDragFrom;
9970
+ if (n.setWireFromTerminal(null), n.setWireDragFrom(null), n.setCursorSvg(null), Re(null), !o) return;
9944
9971
  const r = t.viewport.screenToSvg(e.clientX, e.clientY), i = tr(e.clientX, e.clientY) ?? (e.target instanceof Element ? e.target : null), s = kn(i, r), a = {
9945
9972
  spec: o.spec,
9946
9973
  world: o.world,
@@ -9950,8 +9977,8 @@ const DS = {
9950
9977
  nr(a, s) || (n.connectWire(o.spec, s.spec), sn());
9951
9978
  },
9952
9979
  onPointerLeave() {
9953
- const e = x.getState();
9954
- e.setWireFromTerminal(null), e.setWireDragFrom(null), e.setCursorSvg(null), De(null);
9980
+ const e = b.getState();
9981
+ e.setWireFromTerminal(null), e.setWireDragFrom(null), e.setCursorSvg(null), Re(null);
9955
9982
  }
9956
9983
  }, or = 10;
9957
9984
  let $t = !1;
@@ -9966,19 +9993,19 @@ const RS = {
9966
9993
  },
9967
9994
  onDeactivate(e) {
9968
9995
  e.hostEl.classList.remove("tool-place");
9969
- const t = x.getState();
9996
+ const t = b.getState();
9970
9997
  t.setPlaceFromTerminal(null), t.setCursorSvg(null), $t = !1;
9971
9998
  },
9972
9999
  onPointerDown(e, t) {
9973
10000
  var i, s;
9974
10001
  if (e.button !== 0) return;
9975
- const { placeKind: n } = x.getState();
10002
+ const { placeKind: n } = b.getState();
9976
10003
  if (!n) return;
9977
10004
  e.preventDefault();
9978
10005
  const o = ct(e.target);
9979
10006
  if (o) {
9980
10007
  e.stopPropagation(), e.target instanceof Element && ((s = (i = e.target).hasPointerCapture) != null && s.call(i, e.pointerId)) && e.target.releasePointerCapture(e.pointerId);
9981
- const a = x.getState();
10008
+ const a = b.getState();
9982
10009
  a.setPlaceFromTerminal(o), a.setCursorSvg(t.viewport.screenToSvg(e.clientX, e.clientY));
9983
10010
  return;
9984
10011
  }
@@ -9987,10 +10014,10 @@ const RS = {
9987
10014
  },
9988
10015
  onPointerMove(e, t) {
9989
10016
  const n = t.viewport.screenToSvg(e.clientX, e.clientY);
9990
- x.getState().setCursorSvg([ir(n[0]), ir(n[1])]);
10017
+ b.getState().setCursorSvg([ir(n[0]), ir(n[1])]);
9991
10018
  },
9992
10019
  onPointerUp(e, t) {
9993
- const n = x.getState(), o = n.placeFromTerminal;
10020
+ const n = b.getState(), o = n.placeFromTerminal;
9994
10021
  if (o) {
9995
10022
  n.setPlaceFromTerminal(null);
9996
10023
  const { placeKind: r } = n;
@@ -10002,11 +10029,11 @@ const RS = {
10002
10029
  $t && ($t = !1, rr());
10003
10030
  },
10004
10031
  onPointerLeave() {
10005
- const e = x.getState();
10032
+ const e = b.getState();
10006
10033
  e.setPlaceFromTerminal(null), e.setCursorSvg(null);
10007
10034
  },
10008
10035
  onPointerCancel() {
10009
- const e = x.getState();
10036
+ const e = b.getState();
10010
10037
  e.setPlaceFromTerminal(null), e.setCursorSvg(null), $t = !1;
10011
10038
  }
10012
10039
  };
@@ -10024,15 +10051,15 @@ const FS = {
10024
10051
  if (e.button !== 0) return;
10025
10052
  e.preventDefault();
10026
10053
  const n = t.viewport.screenToSvg(e.clientX, e.clientY), o = [rt(n[0]), rt(n[1])];
10027
- x.getState().setBusbarDrawStart(o), x.getState().setCursorSvg(o);
10054
+ b.getState().setBusbarDrawStart(o), b.getState().setCursorSvg(o);
10028
10055
  },
10029
10056
  onPointerMove(e, t) {
10030
10057
  const n = t.viewport.screenToSvg(e.clientX, e.clientY);
10031
- x.getState().setCursorSvg([rt(n[0]), rt(n[1])]);
10058
+ b.getState().setCursorSvg([rt(n[0]), rt(n[1])]);
10032
10059
  },
10033
10060
  onPointerUp(e, t) {
10034
- const n = x.getState().busbarDrawStart;
10035
- if (x.getState().setBusbarDrawStart(null), !n) return;
10061
+ const n = b.getState().busbarDrawStart;
10062
+ if (b.getState().setBusbarDrawStart(null), !n) return;
10036
10063
  const o = t.viewport.screenToSvg(e.clientX, e.clientY), r = rt(o[0]), i = rt(o[1]), s = r - n[0], a = i - n[1], l = Math.abs(s) >= Math.abs(a);
10037
10064
  let d, c, u;
10038
10065
  if (l) {
@@ -10042,18 +10069,18 @@ const FS = {
10042
10069
  if (c = Math.abs(a), c < ar) return;
10043
10070
  d = 90, u = [n[0], (n[1] + i) / 2];
10044
10071
  }
10045
- x.getState().addBus(u, c, d), sn();
10072
+ b.getState().addBus(u, c, d), sn();
10046
10073
  },
10047
10074
  onPointerLeave() {
10048
- const e = x.getState();
10075
+ const e = b.getState();
10049
10076
  e.setBusbarDrawStart(null), e.setCursorSvg(null);
10050
10077
  },
10051
10078
  onPointerCancel() {
10052
- const e = x.getState();
10079
+ const e = b.getState();
10053
10080
  e.setBusbarDrawStart(null), e.setCursorSvg(null);
10054
10081
  },
10055
10082
  onDeactivate() {
10056
- const e = x.getState();
10083
+ const e = b.getState();
10057
10084
  e.setBusbarDrawStart(null), e.setCursorSvg(null);
10058
10085
  }
10059
10086
  }, lr = 10, cr = (e) => Math.round(e / lr) * lr, HS = {
@@ -10063,14 +10090,14 @@ const FS = {
10063
10090
  if (e.button !== 0) return;
10064
10091
  e.preventDefault(), e.stopPropagation();
10065
10092
  const n = t.viewport.screenToSvg(e.clientX, e.clientY);
10066
- x.getState().addJunction([cr(n[0]), cr(n[1])]), sn();
10093
+ b.getState().addJunction([cr(n[0]), cr(n[1])]), sn();
10067
10094
  }
10068
10095
  }, WS = {
10069
10096
  id: "text",
10070
10097
  cursor: "text",
10071
10098
  onPointerDown(e, t) {
10072
10099
  if (e.button !== 0) return;
10073
- const n = x.getState(), o = Vt(e.target);
10100
+ const n = b.getState(), o = Vt(e.target);
10074
10101
  if (o) {
10075
10102
  e.preventDefault(), e.stopPropagation(), n.setActiveTool("select"), n.setSelectedAnnotation(o);
10076
10103
  return;
@@ -10089,7 +10116,7 @@ const FS = {
10089
10116
  text: WS
10090
10117
  };
10091
10118
  function GS(e, t) {
10092
- const n = x((o) => o.activeTool);
10119
+ const n = b((o) => o.activeTool);
10093
10120
  ne(() => {
10094
10121
  var f;
10095
10122
  const o = e.current;
@@ -10160,14 +10187,14 @@ function JS(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
10160
10187
  g = null;
10161
10188
  return;
10162
10189
  }
10163
- const D = [...h.values()], F = D[1].x - D[0].x, Z = D[1].y - D[0].y, ae = Math.hypot(F, Z) || 1, ce = s.getBoundingClientRect();
10190
+ const D = [...h.values()], F = D[1].x - D[0].x, Z = D[1].y - D[0].y, le = Math.hypot(F, Z) || 1, de = s.getBoundingClientRect();
10164
10191
  g = {
10165
- startDist: ae,
10192
+ startDist: le,
10166
10193
  startScale: o.current.scale,
10167
10194
  startTx: o.current.tx,
10168
10195
  startTy: o.current.ty,
10169
- startMidX: (D[0].x + D[1].x) / 2 - ce.left,
10170
- startMidY: (D[0].y + D[1].y) / 2 - ce.top
10196
+ startMidX: (D[0].x + D[1].x) / 2 - de.left,
10197
+ startMidY: (D[0].y + D[1].y) / 2 - de.top
10171
10198
  };
10172
10199
  }, k = (D) => {
10173
10200
  if (D.pointerType === "touch") {
@@ -10185,14 +10212,14 @@ function JS(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
10185
10212
  }
10186
10213
  }
10187
10214
  }
10188
- }, b = (D) => {
10215
+ }, x = (D) => {
10189
10216
  if (D.pointerType !== "touch" || !h.has(D.pointerId) || (h.set(D.pointerId, { x: D.clientX, y: D.clientY }), !w || !g)) return;
10190
10217
  D.stopPropagation();
10191
10218
  const F = [...h.values()];
10192
10219
  if (F.length < 2) return;
10193
- const Z = F[1].x - F[0].x, ae = F[1].y - F[0].y, ce = Math.hypot(Z, ae) || 1, Q = s.getBoundingClientRect(), ye = (F[0].x + F[1].x) / 2 - Q.left, be = (F[0].y + F[1].y) / 2 - Q.top, xe = ce / g.startDist, Be = Sn(g.startScale * xe, _n, $n), Ee = Be / g.startScale;
10220
+ const Z = F[1].x - F[0].x, le = F[1].y - F[0].y, de = Math.hypot(Z, le) || 1, Q = s.getBoundingClientRect(), ye = (F[0].x + F[1].x) / 2 - Q.left, be = (F[0].y + F[1].y) / 2 - Q.top, xe = de / g.startDist, Be = Sn(g.startScale * xe, _n, $n), Ee = Be / g.startScale;
10194
10221
  o.current.tx = g.startMidX - (g.startMidX - g.startTx) * Ee + (ye - g.startMidX), o.current.ty = g.startMidY - (g.startMidY - g.startTy) * Ee + (be - g.startMidY), o.current.scale = Be, i();
10195
- }, S = (D) => {
10222
+ }, $ = (D) => {
10196
10223
  var F;
10197
10224
  if (D.pointerType === "touch" && h.has(D.pointerId) && (h.delete(D.pointerId), w)) {
10198
10225
  if (D.stopPropagation(), (F = s.hasPointerCapture) != null && F.call(s, D.pointerId))
@@ -10204,31 +10231,31 @@ function JS(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
10204
10231
  }
10205
10232
  }, C = (D) => {
10206
10233
  D.preventDefault();
10207
- const F = s.getBoundingClientRect(), Z = D.clientX - F.left, ae = D.clientY - F.top, ce = D.ctrlKey || D.metaKey;
10208
- if (D.deltaX === 0 || ce) {
10209
- const be = Math.pow(ce ? US : VS, -D.deltaY), xe = Sn(o.current.scale * be, _n, $n), Be = xe / o.current.scale;
10210
- o.current.tx = Z - (Z - o.current.tx) * Be, o.current.ty = ae - (ae - o.current.ty) * Be, o.current.scale = xe;
10234
+ const F = s.getBoundingClientRect(), Z = D.clientX - F.left, le = D.clientY - F.top, de = D.ctrlKey || D.metaKey;
10235
+ if (D.deltaX === 0 || de) {
10236
+ const be = Math.pow(de ? US : VS, -D.deltaY), xe = Sn(o.current.scale * be, _n, $n), Be = xe / o.current.scale;
10237
+ o.current.tx = Z - (Z - o.current.tx) * Be, o.current.ty = le - (le - o.current.ty) * Be, o.current.scale = xe;
10211
10238
  } else
10212
10239
  o.current.tx -= D.deltaX, o.current.ty -= D.deltaY;
10213
10240
  i();
10214
10241
  }, j = (D) => {
10215
10242
  const F = D.button === 1, Z = p && D.button === 0;
10216
10243
  !F && !Z || (D.preventDefault(), a = !0, l = D.pointerId, d = D.clientX, c = D.clientY, u = o.current.tx, f = o.current.ty, s.setPointerCapture(D.pointerId), s.style.cursor = "grabbing");
10217
- }, q = (D) => {
10244
+ }, W = (D) => {
10218
10245
  !a || D.pointerId !== l || (o.current.tx = u + (D.clientX - d), o.current.ty = f + (D.clientY - c), i());
10219
- }, V = (D) => {
10246
+ }, K = (D) => {
10220
10247
  a && D.pointerId === l && (a = !1, s.releasePointerCapture(D.pointerId), s.style.cursor = p ? "grab" : "");
10221
- }, ie = (D) => {
10248
+ }, re = (D) => {
10222
10249
  if (D.code === "Space" && !p) {
10223
10250
  const F = D.target;
10224
10251
  if (F && (F.tagName === "INPUT" || F.tagName === "TEXTAREA" || F.isContentEditable)) return;
10225
10252
  p = !0, s.style.cursor = "grab", D.preventDefault();
10226
10253
  }
10227
- }, se = (D) => {
10254
+ }, ae = (D) => {
10228
10255
  D.code === "Space" && (p = !1, a || (s.style.cursor = ""));
10229
10256
  };
10230
- return s.addEventListener("wheel", C, { passive: !1 }), s.addEventListener("pointerdown", j), s.addEventListener("pointermove", q), s.addEventListener("pointerup", V), s.addEventListener("pointercancel", V), s.addEventListener("pointerdown", k, { capture: !0 }), s.addEventListener("pointermove", b, { capture: !0 }), s.addEventListener("pointerup", S, { capture: !0 }), s.addEventListener("pointercancel", S, { capture: !0 }), window.addEventListener("keydown", ie), window.addEventListener("keyup", se), i(), () => {
10231
- s.removeEventListener("wheel", C), s.removeEventListener("pointerdown", j), s.removeEventListener("pointermove", q), s.removeEventListener("pointerup", V), s.removeEventListener("pointercancel", V), s.removeEventListener("pointerdown", k, { capture: !0 }), s.removeEventListener("pointermove", b, { capture: !0 }), s.removeEventListener("pointerup", S, { capture: !0 }), s.removeEventListener("pointercancel", S, { capture: !0 }), window.removeEventListener("keydown", ie), window.removeEventListener("keyup", se);
10257
+ return s.addEventListener("wheel", C, { passive: !1 }), s.addEventListener("pointerdown", j), s.addEventListener("pointermove", W), s.addEventListener("pointerup", K), s.addEventListener("pointercancel", K), s.addEventListener("pointerdown", k, { capture: !0 }), s.addEventListener("pointermove", x, { capture: !0 }), s.addEventListener("pointerup", $, { capture: !0 }), s.addEventListener("pointercancel", $, { capture: !0 }), window.addEventListener("keydown", re), window.addEventListener("keyup", ae), i(), () => {
10258
+ s.removeEventListener("wheel", C), s.removeEventListener("pointerdown", j), s.removeEventListener("pointermove", W), s.removeEventListener("pointerup", K), s.removeEventListener("pointercancel", K), s.removeEventListener("pointerdown", k, { capture: !0 }), s.removeEventListener("pointermove", x, { capture: !0 }), s.removeEventListener("pointerup", $, { capture: !0 }), s.removeEventListener("pointercancel", $, { capture: !0 }), window.removeEventListener("keydown", re), window.removeEventListener("keyup", ae);
10232
10259
  };
10233
10260
  }, []), {
10234
10261
  screenToSvg(s, a) {
@@ -10272,7 +10299,7 @@ function t4() {
10272
10299
  }, [r]);
10273
10300
  const i = Xv(), s = Ht(
10274
10301
  (c, u, f) => {
10275
- const p = x.getState(), h = p.activeTool;
10302
+ const p = b.getState(), h = p.activeTool;
10276
10303
  if (h === "wire" || h === "busbar" || h === "junction" || h === "place") {
10277
10304
  sw();
10278
10305
  return;
@@ -10284,19 +10311,19 @@ function t4() {
10284
10311
  const j = rn(f);
10285
10312
  j && p.selectedNode !== j && p.setSelectedNode(j);
10286
10313
  }
10287
- const w = x.getState(), E = w.selection.length > 0, k = w.selectedNode != null, b = !!w.clipboard, S = w.diagram.elements.length > 0, C = [
10314
+ const w = b.getState(), E = w.selection.length > 0, k = w.selectedNode != null, x = !!w.clipboard, $ = w.diagram.elements.length > 0, C = [
10288
10315
  {
10289
10316
  label: e("menu.undo"),
10290
10317
  shortcut: `${it}Z`,
10291
10318
  icon: Xn,
10292
- onSelect: () => x.getState().undo(),
10319
+ onSelect: () => b.getState().undo(),
10293
10320
  disabled: w.past.length === 0
10294
10321
  },
10295
10322
  {
10296
10323
  label: e("menu.redo"),
10297
10324
  shortcut: `${it}${ZS}Z`,
10298
10325
  icon: Gn,
10299
- onSelect: () => x.getState().redo(),
10326
+ onSelect: () => b.getState().redo(),
10300
10327
  disabled: w.future.length === 0
10301
10328
  },
10302
10329
  { type: "separator" },
@@ -10304,36 +10331,36 @@ function t4() {
10304
10331
  label: e("menu.cut"),
10305
10332
  shortcut: `${it}X`,
10306
10333
  icon: Wr,
10307
- onSelect: () => x.getState().cutSelection(),
10334
+ onSelect: () => b.getState().cutSelection(),
10308
10335
  disabled: !E
10309
10336
  },
10310
10337
  {
10311
10338
  label: e("menu.copy"),
10312
10339
  shortcut: `${it}C`,
10313
10340
  icon: Dr,
10314
- onSelect: () => x.getState().copySelection(),
10341
+ onSelect: () => b.getState().copySelection(),
10315
10342
  disabled: !E
10316
10343
  },
10317
10344
  {
10318
10345
  label: e("menu.paste"),
10319
10346
  shortcut: `${it}V`,
10320
10347
  icon: zr,
10321
- onSelect: () => x.getState().pasteClipboard(),
10322
- disabled: !b
10348
+ onSelect: () => b.getState().pasteClipboard(),
10349
+ disabled: !x
10323
10350
  },
10324
10351
  { type: "separator" },
10325
10352
  {
10326
10353
  label: e("menu.rotate"),
10327
10354
  shortcut: "R",
10328
10355
  icon: Hr,
10329
- onSelect: () => x.getState().rotateSelection(90),
10356
+ onSelect: () => b.getState().rotateSelection(90),
10330
10357
  disabled: !E
10331
10358
  },
10332
10359
  {
10333
10360
  label: e("menu.mirror"),
10334
10361
  shortcut: "M",
10335
10362
  icon: Rr,
10336
- onSelect: () => x.getState().mirrorSelection(),
10363
+ onSelect: () => b.getState().mirrorSelection(),
10337
10364
  disabled: !E
10338
10365
  },
10339
10366
  { type: "separator" },
@@ -10342,10 +10369,10 @@ function t4() {
10342
10369
  shortcut: `${it}A`,
10343
10370
  icon: fv,
10344
10371
  onSelect: () => {
10345
- const j = x.getState();
10346
- j.setSelection(j.diagram.elements.map((q) => q.id));
10372
+ const j = b.getState();
10373
+ j.setSelection(j.diagram.elements.map((W) => W.id));
10347
10374
  },
10348
- disabled: !S
10375
+ disabled: !$
10349
10376
  },
10350
10377
  { type: "separator" },
10351
10378
  {
@@ -10353,7 +10380,7 @@ function t4() {
10353
10380
  shortcut: "Del",
10354
10381
  icon: Gr,
10355
10382
  destructive: !0,
10356
- onSelect: () => k && !E ? x.getState().deleteSelectedNode() : x.getState().deleteSelection(),
10383
+ onSelect: () => k && !E ? b.getState().deleteSelectedNode() : b.getState().deleteSelection(),
10357
10384
  disabled: !E && !k
10358
10385
  }
10359
10386
  ];
@@ -10368,22 +10395,22 @@ function t4() {
10368
10395
  let p, h = null;
10369
10396
  const g = () => {
10370
10397
  p !== void 0 && window.clearTimeout(p), p = void 0, h = null;
10371
- }, w = (b) => {
10372
- b.pointerType === "touch" && (g(), h = {
10373
- pointerId: b.pointerId,
10374
- x: b.clientX,
10375
- y: b.clientY,
10376
- target: b.target
10398
+ }, w = (x) => {
10399
+ x.pointerType === "touch" && (g(), h = {
10400
+ pointerId: x.pointerId,
10401
+ x: x.clientX,
10402
+ y: x.clientY,
10403
+ target: x.target
10377
10404
  }, p = window.setTimeout(() => {
10378
- const S = h;
10379
- h = null, p = void 0, S && (iw(c, S.pointerId), s(S.x, S.y, S.target));
10405
+ const $ = h;
10406
+ h = null, p = void 0, $ && (iw(c, $.pointerId), s($.x, $.y, $.target));
10380
10407
  }, u));
10381
- }, E = (b) => {
10382
- if (!h || b.pointerId !== h.pointerId) return;
10383
- const S = b.clientX - h.x, C = b.clientY - h.y;
10384
- Math.hypot(S, C) > f && g();
10385
- }, k = (b) => {
10386
- !h || b.pointerId !== h.pointerId || g();
10408
+ }, E = (x) => {
10409
+ if (!h || x.pointerId !== h.pointerId) return;
10410
+ const $ = x.clientX - h.x, C = x.clientY - h.y;
10411
+ Math.hypot($, C) > f && g();
10412
+ }, k = (x) => {
10413
+ !h || x.pointerId !== h.pointerId || g();
10387
10414
  };
10388
10415
  return c.addEventListener("pointerdown", w), c.addEventListener("pointermove", E), c.addEventListener("pointerup", k), c.addEventListener("pointercancel", k), () => {
10389
10416
  g(), c.removeEventListener("pointerdown", w), c.removeEventListener("pointermove", E), c.removeEventListener("pointerup", k), c.removeEventListener("pointercancel", k);
@@ -10498,20 +10525,20 @@ function c4() {
10498
10525
  if (window.clearTimeout(a.current), o(!1), i(null), !!e)
10499
10526
  return a.current = window.setTimeout(() => o(!0), a4), () => window.clearTimeout(a.current);
10500
10527
  }, [e]);
10501
- const d = x((h) => e ? h.diagram.elements.find((g) => g.id === e) ?? null : null);
10528
+ const d = b((h) => e ? h.diagram.elements.find((g) => g.id === e) ?? null : null);
10502
10529
  if (Jt(() => {
10503
10530
  if (!n || !e) return;
10504
10531
  let h = 0, g = -1, w = -1;
10505
10532
  const E = () => {
10506
10533
  const k = document.querySelector(
10507
10534
  `[data-element-id="${d4(e)}"]`
10508
- ), b = s.current;
10509
- if (k && b) {
10510
- const S = k.getBoundingClientRect();
10511
- let C = S.bottom + ur;
10512
- C + b.offsetHeight > window.innerHeight - 4 && (C = S.top - b.offsetHeight - ur);
10513
- let j = S.left + S.width / 2 - b.offsetWidth / 2;
10514
- j = Math.max(4, Math.min(j, window.innerWidth - b.offsetWidth - 4)), (C !== g || j !== w) && (i({ top: C, left: j }), g = C, w = j);
10535
+ ), x = s.current;
10536
+ if (k && x) {
10537
+ const $ = k.getBoundingClientRect();
10538
+ let C = $.bottom + ur;
10539
+ C + x.offsetHeight > window.innerHeight - 4 && (C = $.top - x.offsetHeight - ur);
10540
+ let j = $.left + $.width / 2 - x.offsetWidth / 2;
10541
+ j = Math.max(4, Math.min(j, window.innerWidth - x.offsetWidth - 4)), (C !== g || j !== w) && (i({ top: C, left: j }), g = C, w = j);
10515
10542
  }
10516
10543
  h = requestAnimationFrame(E);
10517
10544
  };
@@ -10705,15 +10732,15 @@ function Ie({
10705
10732
  };
10706
10733
  Jt(() => {
10707
10734
  if (!s || !r.current || !i.current) return;
10708
- const E = r.current.getBoundingClientRect(), k = i.current.getBoundingClientRect(), b = 8;
10709
- let S = "top", C = E.top - k.height - b;
10710
- C < 4 && (S = "bottom", C = E.bottom + b);
10735
+ const E = r.current.getBoundingClientRect(), k = i.current.getBoundingClientRect(), x = 8;
10736
+ let $ = "top", C = E.top - k.height - x;
10737
+ C < 4 && ($ = "bottom", C = E.bottom + x);
10711
10738
  let j = E.left + E.width / 2 - k.width / 2;
10712
- j = Math.max(4, Math.min(j, window.innerWidth - k.width - 4)), d({ top: C, left: j, side: S });
10739
+ j = Math.max(4, Math.min(j, window.innerWidth - k.width - 4)), d({ top: C, left: j, side: $ });
10713
10740
  }, [s, e]), ne(() => () => window.clearTimeout(u.current), []), ne(() => {
10714
10741
  if (!s) return;
10715
- const E = (b) => {
10716
- b.key === "Escape" && a(!1);
10742
+ const E = (x) => {
10743
+ x.key === "Escape" && a(!1);
10717
10744
  }, k = () => a(!1);
10718
10745
  return window.addEventListener("keydown", E), window.addEventListener("scroll", k, !0), window.addEventListener("resize", k), () => {
10719
10746
  window.removeEventListener("keydown", E), window.removeEventListener("scroll", k, !0), window.removeEventListener("resize", k);
@@ -10770,50 +10797,50 @@ function Ie({
10770
10797
  const pr = 12, S4 = 56;
10771
10798
  function N4() {
10772
10799
  var E;
10773
- const e = oe(), t = x((k) => k.selection), n = x((k) => k.selectedNode), o = x((k) => k.selectedWire), r = x((k) => k.activeTool), i = x((k) => k.rotateSelection), s = x((k) => k.mirrorSelection), a = x((k) => k.deleteSelection), l = x((k) => k.deleteSelectedNode), d = x((k) => k.deleteSelectedWire), c = x((k) => k.resetWirePath), u = x((k) => k.internal.wireRenders), f = o != null && ((E = u.get(o)) == null ? void 0 : E.userEdited) === !0, p = me(null);
10800
+ const e = oe(), t = b((k) => k.selection), n = b((k) => k.selectedNode), o = b((k) => k.selectedWire), r = b((k) => k.activeTool), i = b((k) => k.rotateSelection), s = b((k) => k.mirrorSelection), a = b((k) => k.deleteSelection), l = b((k) => k.deleteSelectedNode), d = b((k) => k.deleteSelectedWire), c = b((k) => k.resetWirePath), u = b((k) => k.internal.wireRenders), f = o != null && ((E = u.get(o)) == null ? void 0 : E.userEdited) === !0, p = me(null);
10774
10801
  ne(() => {
10775
10802
  const k = p.current;
10776
10803
  if (!k) return;
10777
- const b = t.length > 0, S = !b && o != null, C = !b && !S && n != null;
10778
- if (!((b || S || C) && (r === "select" || r === "pan"))) {
10804
+ const x = t.length > 0, $ = !x && o != null, C = !x && !$ && n != null;
10805
+ if (!((x || $ || C) && (r === "select" || r === "pan"))) {
10779
10806
  k.style.display = "none";
10780
10807
  return;
10781
10808
  }
10782
10809
  k.style.display = "flex";
10783
- let q = 0, V = "";
10784
- const ie = () => {
10785
- let se = 1 / 0, D = -1 / 0, F = 1 / 0, Z = -1 / 0, ae = !1;
10786
- const ce = (Q) => {
10787
- Q.width === 0 && Q.height === 0 || (Q.left < se && (se = Q.left), Q.right > D && (D = Q.right), Q.top < F && (F = Q.top), Q.bottom > Z && (Z = Q.bottom), ae = !0);
10810
+ let W = 0, K = "";
10811
+ const re = () => {
10812
+ let ae = 1 / 0, D = -1 / 0, F = 1 / 0, Z = -1 / 0, le = !1;
10813
+ const de = (Q) => {
10814
+ Q.width === 0 && Q.height === 0 || (Q.left < ae && (ae = Q.left), Q.right > D && (D = Q.right), Q.top < F && (F = Q.top), Q.bottom > Z && (Z = Q.bottom), le = !0);
10788
10815
  };
10789
- if (b)
10816
+ if (x)
10790
10817
  for (const Q of t) {
10791
10818
  const ye = document.querySelector(
10792
10819
  `[data-element-id="${CSS.escape(Q)}"]`
10793
10820
  );
10794
- ye && ce(ye.getBoundingClientRect());
10821
+ ye && de(ye.getBoundingClientRect());
10795
10822
  }
10796
- else if (S && o) {
10823
+ else if ($ && o) {
10797
10824
  const Q = document.querySelector(
10798
10825
  `polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`
10799
10826
  );
10800
- Q && ce(Q.getBoundingClientRect());
10827
+ Q && de(Q.getBoundingClientRect());
10801
10828
  } else if (C && n) {
10802
10829
  const Q = document.querySelectorAll(
10803
10830
  `polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`
10804
10831
  );
10805
- for (const ye of Q) ce(ye.getBoundingClientRect());
10832
+ for (const ye of Q) de(ye.getBoundingClientRect());
10806
10833
  }
10807
- if (ae) {
10808
- const Q = (se + D) / 2;
10834
+ if (le) {
10835
+ const Q = (ae + D) / 2;
10809
10836
  let ye = F - pr, be = "-100%";
10810
10837
  ye < S4 && (ye = Z + pr, be = "0%");
10811
10838
  const xe = `translate3d(${Q}px, ${ye}px, 0) translate(-50%, ${be})`;
10812
- xe !== V && (k.style.transform = xe, V = xe);
10839
+ xe !== K && (k.style.transform = xe, K = xe);
10813
10840
  }
10814
- q = requestAnimationFrame(ie);
10841
+ W = requestAnimationFrame(re);
10815
10842
  };
10816
- return q = requestAnimationFrame(ie), () => cancelAnimationFrame(q);
10843
+ return W = requestAnimationFrame(re), () => cancelAnimationFrame(W);
10817
10844
  }, [t, n, o, r]);
10818
10845
  const h = t.length === 0 && o != null, g = t.length === 0 && !h && n != null, w = g || h;
10819
10846
  return /* @__PURE__ */ B(
@@ -11035,7 +11062,7 @@ const P4 = {
11035
11062
  };
11036
11063
  function O4() {
11037
11064
  var o;
11038
- const e = x.getState(), t = ((o = e.diagram.meta) == null ? void 0 : o.labelMode) ?? "all", n = P4[t];
11065
+ const e = b.getState(), t = ((o = e.diagram.meta) == null ? void 0 : o.labelMode) ?? "all", n = P4[t];
11039
11066
  e.dispatch((r) => {
11040
11067
  const i = { ...r.meta ?? {}, labelMode: n };
11041
11068
  return { ...r, meta: i };
@@ -11177,7 +11204,7 @@ function $w({
11177
11204
  );
11178
11205
  }
11179
11206
  function Sw() {
11180
- const e = oe(), t = x(
11207
+ const e = oe(), t = b(
11181
11208
  (n) => {
11182
11209
  var o;
11183
11210
  return ((o = n.diagram.meta) == null ? void 0 : o.labelMode) ?? "all";
@@ -11348,7 +11375,7 @@ const yr = [
11348
11375
  }
11349
11376
  ];
11350
11377
  function z4() {
11351
- const e = oe(), t = x((c) => c.activeTool), n = x((c) => c.placeKind), o = x((c) => c.placeFromTerminal), r = x((c) => c.wireDragFrom), i = x((c) => c.busbarDrawStart), s = x(
11378
+ const e = oe(), t = b((c) => c.activeTool), n = b((c) => c.placeKind), o = b((c) => c.placeFromTerminal), r = b((c) => c.wireDragFrom), i = b((c) => c.busbarDrawStart), s = b(
11352
11379
  (c) => c.selection.length > 0 || c.selectedNode != null
11353
11380
  );
11354
11381
  let a = null, l = !1;
@@ -11386,7 +11413,7 @@ function z4() {
11386
11413
  ] });
11387
11414
  }
11388
11415
  function D4() {
11389
- const e = oe(), t = x((h) => h.activeTool), n = x((h) => h.placeKind), o = x((h) => h.setActiveTool), r = x((h) => h.past.length), i = x((h) => h.future.length), s = x((h) => h.undo), a = x((h) => h.redo), l = Ve(), d = Oe(l, "tight"), c = !Oe(l, "dense"), u = Oe(l, "dense"), f = u ? yr.filter((h) => h.id !== "select" && h.id !== "text") : yr, p = (h) => t === h.switchTo;
11416
+ const e = oe(), t = b((h) => h.activeTool), n = b((h) => h.placeKind), o = b((h) => h.setActiveTool), r = b((h) => h.past.length), i = b((h) => h.future.length), s = b((h) => h.undo), a = b((h) => h.redo), l = Ve(), d = Oe(l, "tight"), c = !Oe(l, "dense"), u = Oe(l, "dense"), f = u ? yr.filter((h) => h.id !== "select" && h.id !== "text") : yr, p = (h) => t === h.switchTo;
11390
11417
  return /* @__PURE__ */ B(
11391
11418
  "div",
11392
11419
  {
@@ -11530,7 +11557,7 @@ function dt({
11530
11557
  ) });
11531
11558
  }
11532
11559
  function Nw() {
11533
- const e = x((r) => r.diagram.elements), t = x((r) => r.diagram.layout), n = x((r) => r.selection), o = t ?? {};
11560
+ const e = b((r) => r.diagram.elements), t = b((r) => r.diagram.layout), n = b((r) => r.selection), o = t ?? {};
11534
11561
  return {
11535
11562
  hasAnyElement: e.length > 0,
11536
11563
  hasArrangedAny: Object.keys(o).length > 0,
@@ -11564,7 +11591,7 @@ function F4({ iconOnly: e }) {
11564
11591
  /* @__PURE__ */ m(
11565
11592
  Ae,
11566
11593
  {
11567
- onClick: i(() => x.getState().autoArrangeAll()),
11594
+ onClick: i(() => b.getState().autoArrangeAll()),
11568
11595
  icon: /* @__PURE__ */ m(Nt, {}),
11569
11596
  disabled: !r.hasAnyElement || !r.hasArrangedAny,
11570
11597
  children: t("layout.allAuto")
@@ -11573,7 +11600,7 @@ function F4({ iconOnly: e }) {
11573
11600
  /* @__PURE__ */ m(
11574
11601
  Ae,
11575
11602
  {
11576
- onClick: i(() => x.getState().autoArrangeSelection()),
11603
+ onClick: i(() => b.getState().autoArrangeSelection()),
11577
11604
  icon: /* @__PURE__ */ m(Nt, {}),
11578
11605
  disabled: !r.hasSelection || !r.selectionHasArranged,
11579
11606
  children: t("layout.selAuto")
@@ -11583,7 +11610,7 @@ function F4({ iconOnly: e }) {
11583
11610
  /* @__PURE__ */ m(
11584
11611
  Ae,
11585
11612
  {
11586
- onClick: i(() => x.getState().fillUnplacedAll()),
11613
+ onClick: i(() => b.getState().fillUnplacedAll()),
11587
11614
  icon: /* @__PURE__ */ m(Wt, {}),
11588
11615
  disabled: !r.hasGapsAll,
11589
11616
  children: t("layout.allFill")
@@ -11592,7 +11619,7 @@ function F4({ iconOnly: e }) {
11592
11619
  /* @__PURE__ */ m(
11593
11620
  Ae,
11594
11621
  {
11595
- onClick: i(() => x.getState().fillUnplacedSelection()),
11622
+ onClick: i(() => b.getState().fillUnplacedSelection()),
11596
11623
  icon: /* @__PURE__ */ m(Wt, {}),
11597
11624
  disabled: !r.hasSelection || !r.selectionHasGaps,
11598
11625
  children: t("layout.selFill")
@@ -11603,7 +11630,7 @@ function F4({ iconOnly: e }) {
11603
11630
  );
11604
11631
  }
11605
11632
  function H4({ stacked: e }) {
11606
- const t = oe(), [n, o] = pe(!1), r = x((f) => f.past.length), i = x((f) => f.future.length), s = x((f) => f.undo), a = x((f) => f.redo), l = x((f) => f.selection.length > 0), d = x((f) => f.clipboard != null), c = Nw(), u = (f) => () => {
11633
+ const t = oe(), [n, o] = pe(!1), r = b((f) => f.past.length), i = b((f) => f.future.length), s = b((f) => f.undo), a = b((f) => f.redo), l = b((f) => f.selection.length > 0), d = b((f) => f.clipboard != null), c = Nw(), u = (f) => () => {
11607
11634
  o(!1), f();
11608
11635
  };
11609
11636
  return /* @__PURE__ */ B(
@@ -11646,7 +11673,7 @@ function H4({ stacked: e }) {
11646
11673
  /* @__PURE__ */ m(
11647
11674
  Ae,
11648
11675
  {
11649
- onClick: u(() => x.getState().cutSelection()),
11676
+ onClick: u(() => b.getState().cutSelection()),
11650
11677
  icon: /* @__PURE__ */ m(Wr, {}),
11651
11678
  disabled: !l,
11652
11679
  children: t("menu.cut")
@@ -11655,7 +11682,7 @@ function H4({ stacked: e }) {
11655
11682
  /* @__PURE__ */ m(
11656
11683
  Ae,
11657
11684
  {
11658
- onClick: u(() => x.getState().copySelection()),
11685
+ onClick: u(() => b.getState().copySelection()),
11659
11686
  icon: /* @__PURE__ */ m(Dr, {}),
11660
11687
  disabled: !l,
11661
11688
  children: t("menu.copy")
@@ -11664,7 +11691,7 @@ function H4({ stacked: e }) {
11664
11691
  /* @__PURE__ */ m(
11665
11692
  Ae,
11666
11693
  {
11667
- onClick: u(() => x.getState().pasteClipboard()),
11694
+ onClick: u(() => b.getState().pasteClipboard()),
11668
11695
  icon: /* @__PURE__ */ m(zr, {}),
11669
11696
  disabled: !d,
11670
11697
  children: t("menu.paste")
@@ -11674,7 +11701,7 @@ function H4({ stacked: e }) {
11674
11701
  /* @__PURE__ */ m(
11675
11702
  Ae,
11676
11703
  {
11677
- onClick: u(() => x.getState().autoArrangeAll()),
11704
+ onClick: u(() => b.getState().autoArrangeAll()),
11678
11705
  icon: /* @__PURE__ */ m(Nt, {}),
11679
11706
  disabled: !c.hasAnyElement || !c.hasArrangedAny,
11680
11707
  children: t("layout.allAuto")
@@ -11683,7 +11710,7 @@ function H4({ stacked: e }) {
11683
11710
  /* @__PURE__ */ m(
11684
11711
  Ae,
11685
11712
  {
11686
- onClick: u(() => x.getState().autoArrangeSelection()),
11713
+ onClick: u(() => b.getState().autoArrangeSelection()),
11687
11714
  icon: /* @__PURE__ */ m(Nt, {}),
11688
11715
  disabled: !c.hasSelection || !c.selectionHasArranged,
11689
11716
  children: t("layout.selAuto")
@@ -11692,7 +11719,7 @@ function H4({ stacked: e }) {
11692
11719
  /* @__PURE__ */ m(
11693
11720
  Ae,
11694
11721
  {
11695
- onClick: u(() => x.getState().fillUnplacedAll()),
11722
+ onClick: u(() => b.getState().fillUnplacedAll()),
11696
11723
  icon: /* @__PURE__ */ m(Wt, {}),
11697
11724
  disabled: !c.hasGapsAll,
11698
11725
  children: t("layout.allFill")
@@ -11701,7 +11728,7 @@ function H4({ stacked: e }) {
11701
11728
  /* @__PURE__ */ m(
11702
11729
  Ae,
11703
11730
  {
11704
- onClick: u(() => x.getState().fillUnplacedSelection()),
11731
+ onClick: u(() => b.getState().fillUnplacedSelection()),
11705
11732
  icon: /* @__PURE__ */ m(Wt, {}),
11706
11733
  disabled: !c.hasSelection || !c.selectionHasGaps,
11707
11734
  children: t("layout.selFill")
@@ -11785,7 +11812,7 @@ function br({
11785
11812
  onClose: e,
11786
11813
  sheet: t
11787
11814
  }) {
11788
- const n = oe(), o = x((d) => d.diagram.elements), r = x((d) => d.activeTool === "place"), i = Ve(), s = Oe(i, "compact"), a = Oe(i, "dense"), l = t ? "min(50vh, calc(100vh - 9rem))" : r ? "min(40vh, calc(100vh - 200px))" : "min(70vh, calc(100vh - 100px))";
11815
+ const n = oe(), o = b((d) => d.diagram.elements), r = b((d) => d.activeTool === "place"), i = Ve(), s = Oe(i, "compact"), a = Oe(i, "dense"), l = t ? "min(50vh, calc(100vh - 9rem))" : r ? "min(40vh, calc(100vh - 200px))" : "min(70vh, calc(100vh - 100px))";
11789
11816
  return /* @__PURE__ */ B(
11790
11817
  "aside",
11791
11818
  {
@@ -11816,7 +11843,7 @@ function br({
11816
11843
  );
11817
11844
  }
11818
11845
  function G4({ element: e }) {
11819
- const t = Ye[e.kind], n = x((l) => l.selection.includes(e.id)), o = x((l) => l.setSelection), r = x((l) => l.toggleInSelection), i = Ve(), s = !Oe(i, "compact"), a = (l) => {
11846
+ const t = Ye[e.kind], n = b((l) => l.selection.includes(e.id)), o = b((l) => l.setSelection), r = b((l) => l.toggleInSelection), i = Ve(), s = !Oe(i, "compact"), a = (l) => {
11820
11847
  l.shiftKey || l.metaKey || l.ctrlKey ? r(e.id) : o([e.id]);
11821
11848
  };
11822
11849
  return /* @__PURE__ */ B(
@@ -12194,7 +12221,7 @@ function Q4(e) {
12194
12221
  }
12195
12222
  }
12196
12223
  function e6() {
12197
- const e = oe(), t = x((u) => u.activeTool === "place"), n = x((u) => u.placeKind), o = x((u) => u.setActiveTool), r = Tt((u) => u.outlineOpen), i = Ve(), s = Oe(i, "dense"), a = 68, d = s ? void 0 : `calc(100vh - ${a}px - ${r ? "calc(40vh + 20px)" : "68px"})`;
12224
+ const e = oe(), t = b((u) => u.activeTool === "place"), n = b((u) => u.placeKind), o = b((u) => u.setActiveTool), r = Tt((u) => u.outlineOpen), i = Ve(), s = Oe(i, "dense"), a = 68, d = s ? void 0 : `calc(100vh - ${a}px - ${r ? "calc(40vh + 20px)" : "68px"})`;
12198
12225
  if (!t || s && n != null) return null;
12199
12226
  const c = s ? {
12200
12227
  top: `calc(${a}px + var(--ole-top-inset, 0px))`,
@@ -12323,9 +12350,9 @@ function o6({
12323
12350
  entry: e,
12324
12351
  sheet: t
12325
12352
  }) {
12326
- const n = oe(), o = At(), r = o(`${e.id}.name`, e.name), i = o(`${e.id}.desc`, e.description ?? ""), s = x((u) => u.setActiveTool), a = x(
12353
+ const n = oe(), o = At(), r = o(`${e.id}.name`, e.name), i = o(`${e.id}.desc`, e.description ?? ""), s = b((u) => u.setActiveTool), a = b(
12327
12354
  (u) => u.activeTool === "place" && u.placeKind === e.id
12328
- ), l = x(
12355
+ ), l = b(
12329
12356
  (u) => t && u.activeTool === "place" && u.placeKind == null && u.lastPlaceKind === e.id
12330
12357
  ), d = me(null);
12331
12358
  return ne(() => {
@@ -12490,7 +12517,7 @@ function En({
12490
12517
  ] });
12491
12518
  }
12492
12519
  function a6() {
12493
- const e = oe(), t = x((f) => f.selection), n = x((f) => f.diagram.elements), o = x((f) => f.diagram.buses), r = x((f) => f.diagram.junctions), i = x((f) => f.selectedNode), s = x((f) => f.selectedWire);
12520
+ const e = oe(), t = b((f) => f.selection), n = b((f) => f.diagram.elements), o = b((f) => f.diagram.buses), r = b((f) => f.diagram.junctions), i = b((f) => f.selectedNode), s = b((f) => f.selectedWire);
12494
12521
  if (s) return /* @__PURE__ */ m(f6, { wireId: s });
12495
12522
  if (i) return /* @__PURE__ */ m(p6, { nodeId: i });
12496
12523
  if (t.length === 0)
@@ -12511,7 +12538,7 @@ function a6() {
12511
12538
  label: e("props.name"),
12512
12539
  value: c.name ?? "",
12513
12540
  placeholder: c.id,
12514
- onCommit: (f) => x.getState().updateElement(a, { name: f.trim() === "" ? void 0 : f.trim() })
12541
+ onCommit: (f) => b.getState().updateElement(a, { name: f.trim() === "" ? void 0 : f.trim() })
12515
12542
  }
12516
12543
  ),
12517
12544
  /* @__PURE__ */ m(
@@ -12519,7 +12546,7 @@ function a6() {
12519
12546
  {
12520
12547
  label: e("props.note"),
12521
12548
  value: c.note ?? "",
12522
- onCommit: (f) => x.getState().updateElement(a, { note: f.trim() === "" ? void 0 : f.trim() })
12549
+ onCommit: (f) => b.getState().updateElement(a, { note: f.trim() === "" ? void 0 : f.trim() })
12523
12550
  }
12524
12551
  ),
12525
12552
  (u == null ? void 0 : u.state) && u.state.length > 0 && /* @__PURE__ */ m("div", { className: "mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5", children: u.state.map((f) => /* @__PURE__ */ m(g6, { id: a, element: c, field: f }, f.name)) }),
@@ -12569,7 +12596,7 @@ function c6({
12569
12596
  var l;
12570
12597
  const o = oe(), r = At(), i = ((l = t.params) == null ? void 0 : l[n.name]) ?? n.default, s = r(`${t.kind}.param.${n.name}`, n.label ?? n.name), a = (d) => {
12571
12598
  const c = { ...t.params ?? {} };
12572
- d === void 0 || d === n.default ? delete c[n.name] : c[n.name] = d, x.getState().updateElement(e, {
12599
+ d === void 0 || d === n.default ? delete c[n.name] : c[n.name] = d, b.getState().updateElement(e, {
12573
12600
  params: Object.keys(c).length > 0 ? c : void 0
12574
12601
  });
12575
12602
  };
@@ -12599,7 +12626,7 @@ function d6({
12599
12626
  }) {
12600
12627
  const r = oe(), i = (s) => {
12601
12628
  const a = { ...t.params ?? {} };
12602
- s === void 0 ? delete a[n] : a[n] = s, x.getState().updateElement(e, {
12629
+ s === void 0 ? delete a[n] : a[n] = s, b.getState().updateElement(e, {
12603
12630
  params: Object.keys(a).length > 0 ? a : void 0
12604
12631
  });
12605
12632
  };
@@ -12656,13 +12683,13 @@ function m6({ bus: e }) {
12656
12683
  ) });
12657
12684
  }
12658
12685
  function Wn(e, t) {
12659
- x.getState().dispatch((n) => {
12686
+ b.getState().dispatch((n) => {
12660
12687
  const o = (n.buses ?? []).map((r) => r.id === e ? { ...r, ...t } : r);
12661
12688
  return { ...n, buses: o };
12662
12689
  });
12663
12690
  }
12664
12691
  function f6({ wireId: e }) {
12665
- const t = oe(), n = x((w) => w.diagram.wires), o = x((w) => w.diagram.elements), r = x((w) => w.diagram.buses), i = x((w) => w.diagram.junctions), s = x((w) => w.internal.terminalToNode), a = x((w) => w.setSelectedNode), l = (n ?? []).find((w) => w.id === e);
12692
+ const t = oe(), n = b((w) => w.diagram.wires), o = b((w) => w.diagram.elements), r = b((w) => w.diagram.buses), i = b((w) => w.diagram.junctions), s = b((w) => w.internal.terminalToNode), a = b((w) => w.setSelectedNode), l = (n ?? []).find((w) => w.id === e);
12666
12693
  if (!l)
12667
12694
  return /* @__PURE__ */ m("div", { className: "px-4 py-5 text-center text-xs text-muted-foreground", children: t("props.wireNotFound", { id: e }) });
12668
12695
  const d = s.get(l.ends[0]), c = new Map(o.map((w) => [w.id, w])), u = new Map((r ?? []).map((w) => [w.id, w])), f = new Map((i ?? []).map((w) => [w.id, w])), p = (w) => {
@@ -12672,8 +12699,8 @@ function f6({ wireId: e }) {
12672
12699
  const j = f.get(w);
12673
12700
  return { id: w, label: (j == null ? void 0 : j.name) ?? w };
12674
12701
  }
12675
- const E = w.indexOf("."), k = w.slice(0, E), b = w.slice(E + 1), S = c.get(k);
12676
- return { id: k, label: (S == null ? void 0 : S.name) ?? k, pin: b };
12702
+ const E = w.indexOf("."), k = w.slice(0, E), x = w.slice(E + 1), $ = c.get(k);
12703
+ return { id: k, label: ($ == null ? void 0 : $.name) ?? k, pin: x };
12677
12704
  }, h = p(l.ends[0]), g = p(l.ends[1]);
12678
12705
  return /* @__PURE__ */ B("div", { className: "flex flex-col gap-3 px-3 py-3 text-xs", children: [
12679
12706
  /* @__PURE__ */ B("div", { className: "space-y-1", children: [
@@ -12684,7 +12711,7 @@ function f6({ wireId: e }) {
12684
12711
  "li",
12685
12712
  {
12686
12713
  className: "flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",
12687
- onClick: () => x.getState().setSelection([w.id]),
12714
+ onClick: () => b.getState().setSelection([w.id]),
12688
12715
  children: [
12689
12716
  /* @__PURE__ */ m("span", { className: "flex-1 truncate font-mono text-[11px]", children: w.id }),
12690
12717
  /* @__PURE__ */ m("span", { className: "truncate text-[10px] text-muted-foreground", children: w.label }),
@@ -12706,7 +12733,7 @@ function f6({ wireId: e }) {
12706
12733
  }
12707
12734
  function h6({ junction: e }) {
12708
12735
  var r;
12709
- const t = oe(), n = x((i) => {
12736
+ const t = oe(), n = b((i) => {
12710
12737
  var s;
12711
12738
  return (s = i.internal.junctions.get(e.id)) == null ? void 0 : s.world;
12712
12739
  }), o = ((r = e.layout) == null ? void 0 : r.at) ?? n;
@@ -12721,7 +12748,7 @@ function h6({ junction: e }) {
12721
12748
  label: t("props.name"),
12722
12749
  value: e.name ?? "",
12723
12750
  placeholder: e.id,
12724
- onCommit: (i) => x.getState().updateJunction(e.id, { name: i.trim() === "" ? void 0 : i.trim() })
12751
+ onCommit: (i) => b.getState().updateJunction(e.id, { name: i.trim() === "" ? void 0 : i.trim() })
12725
12752
  }
12726
12753
  ),
12727
12754
  /* @__PURE__ */ m(
@@ -12729,7 +12756,7 @@ function h6({ junction: e }) {
12729
12756
  {
12730
12757
  label: t("props.note"),
12731
12758
  value: e.note ?? "",
12732
- onCommit: (i) => x.getState().updateJunction(e.id, { note: i.trim() === "" ? void 0 : i.trim() })
12759
+ onCommit: (i) => b.getState().updateJunction(e.id, { note: i.trim() === "" ? void 0 : i.trim() })
12733
12760
  }
12734
12761
  ),
12735
12762
  o && /* @__PURE__ */ B("div", { className: "flex items-center justify-between border-t border-border/40 pt-2", children: [
@@ -12743,7 +12770,7 @@ function h6({ junction: e }) {
12743
12770
  ] });
12744
12771
  }
12745
12772
  function p6({ nodeId: e }) {
12746
- const t = oe(), n = x((a) => a.internal.nodes.get(e)), o = x((a) => a.diagram.elements), r = x((a) => a.setSelection);
12773
+ const t = oe(), n = b((a) => a.internal.nodes.get(e)), o = b((a) => a.diagram.elements), r = b((a) => a.setSelection);
12747
12774
  if (!n)
12748
12775
  return /* @__PURE__ */ m("div", { className: "px-4 py-5 text-center text-xs text-muted-foreground", children: t("props.nodeNotFound", { id: e }) });
12749
12776
  const i = /* @__PURE__ */ new Map();
@@ -12904,7 +12931,7 @@ function g6({
12904
12931
  var l;
12905
12932
  const o = oe(), i = At()(`${t.kind}.state.${n.name}`, n.label ?? n.name), s = ((l = t.state) == null ? void 0 : l[n.name]) ?? n.default, a = (d) => {
12906
12933
  const c = { ...t.state ?? {} };
12907
- d === void 0 || d === n.default ? delete c[n.name] : c[n.name] = d, x.getState().updateElement(e, {
12934
+ d === void 0 || d === n.default ? delete c[n.name] : c[n.name] = d, b.getState().updateElement(e, {
12908
12935
  state: Object.keys(c).length > 0 ? c : void 0
12909
12936
  });
12910
12937
  };
@@ -12925,7 +12952,7 @@ function g6({
12925
12952
  );
12926
12953
  }
12927
12954
  function y6() {
12928
- const e = oe(), t = At(), n = x((u) => u.selection), o = x((u) => u.selectedNode), r = x((u) => u.selectedWire), i = x((u) => u.diagram.elements), s = x((u) => u.diagram.buses), a = Ve(), l = Oe(a, "dense");
12955
+ const e = oe(), t = At(), n = b((u) => u.selection), o = b((u) => u.selectedNode), r = b((u) => u.selectedWire), i = b((u) => u.diagram.elements), s = b((u) => u.diagram.buses), a = Ve(), l = Oe(a, "dense");
12929
12956
  if (n.length === 0 && !o && !r) return null;
12930
12957
  let d = e("props.title"), c = null;
12931
12958
  if (r)
@@ -13029,7 +13056,7 @@ function _6(e) {
13029
13056
  function n5({ className: e, diagram: t, locale: n, theme: o }) {
13030
13057
  return ne(() => {
13031
13058
  if (!t) return;
13032
- x.getState().diagram.elements.length === 0 && x.getState().setDiagram(t);
13059
+ b.getState().diagram.elements.length === 0 && b.getState().setDiagram(t);
13033
13060
  }, [t]), ne(() => {
13034
13061
  n && Qt.getState().setLocale(n);
13035
13062
  }, [n]), ne(() => {
@@ -13118,7 +13145,7 @@ async function _r(e, t, n = {}) {
13118
13145
  return i.href = r, i.download = (t == null ? void 0 : t.name) ?? "diagram.json", i.click(), URL.revokeObjectURL(r), t ?? { name: "diagram.json" };
13119
13146
  }
13120
13147
  function o5() {
13121
- const e = oe(), t = x((u) => u.fileSession), n = (t == null ? void 0 : t.name) ?? e("common.unnamed"), { onNew: o, onOpen: r, onSave: i, onSaveAs: s } = N6(), [a, l] = pe(!1), d = me(null);
13148
+ const e = oe(), t = b((u) => u.fileSession), n = (t == null ? void 0 : t.name) ?? e("common.unnamed"), { onNew: o, onOpen: r, onSave: i, onSaveAs: s } = N6(), [a, l] = pe(!1), d = me(null);
13122
13149
  ne(() => {
13123
13150
  const u = (f) => {
13124
13151
  if (!(f.metaKey || f.ctrlKey)) return;
@@ -13194,9 +13221,9 @@ function zt({
13194
13221
  );
13195
13222
  }
13196
13223
  function N6() {
13197
- const e = oe(), t = x((l) => l.loadDiagramFromFile), n = x((l) => l.setFileSession), o = x((l) => l.setDiagram);
13224
+ const e = oe(), t = b((l) => l.loadDiagramFromFile), n = b((l) => l.setFileSession), o = b((l) => l.setDiagram);
13198
13225
  return { onNew: () => {
13199
- const { diagram: l } = x.getState();
13226
+ const { diagram: l } = b.getState();
13200
13227
  l.elements.length > 0 && !confirm(e("topbar.file.newConfirm")) || (o({ version: "1", elements: [] }), n(null));
13201
13228
  }, onOpen: async () => {
13202
13229
  try {
@@ -13207,26 +13234,26 @@ function N6() {
13207
13234
  }
13208
13235
  }, onSave: async () => {
13209
13236
  try {
13210
- const { diagram: l, fileSession: d } = x.getState(), c = await _r(l, d);
13237
+ const { diagram: l, fileSession: d } = b.getState(), c = await _r(l, d);
13211
13238
  c && n(c);
13212
13239
  } catch (l) {
13213
13240
  alert(e("topbar.file.saveFailed", { err: l.message }));
13214
13241
  }
13215
13242
  }, onSaveAs: async () => {
13216
13243
  try {
13217
- const { diagram: l, fileSession: d } = x.getState(), c = await _r(l, d, { saveAs: !0 });
13244
+ const { diagram: l, fileSession: d } = b.getState(), c = await _r(l, d, { saveAs: !0 });
13218
13245
  c && n(c);
13219
13246
  } catch (l) {
13220
13247
  alert(e("topbar.file.saveFailed", { err: l.message }));
13221
13248
  }
13222
13249
  } };
13223
13250
  }
13224
- const Mn = "WIRES", Fe = "ELEMENTS", $r = "LABELS", Sr = "ANNOTATIONS", Nr = 32, Er = 64, E6 = 8, M6 = 1.25, T6 = 6;
13251
+ const Mn = "WIRES", He = "ELEMENTS", $r = "LABELS", Sr = "ANNOTATIONS", Nr = 32, Er = 64, E6 = 8, M6 = 1.25, T6 = 6;
13225
13252
  function A6(e, t = {}) {
13226
13253
  const n = new q6(t.precision ?? 6);
13227
13254
  n.header(t.title), n.tables([
13228
13255
  { name: Mn, color: 7 },
13229
- { name: Fe, color: 7 },
13256
+ { name: He, color: 7 },
13230
13257
  { name: $r, color: 8 },
13231
13258
  { name: Sr, color: 3 }
13232
13259
  ]), n.beginEntities();
@@ -13305,14 +13332,14 @@ function I6(e, t, n) {
13305
13332
  }
13306
13333
  }
13307
13334
  function P6(e, t, n) {
13308
- const o = $e(t, "x1"), r = $e(t, "y1"), i = $e(t, "x2"), s = $e(t, "y2"), a = Pe(Re([o, r], n)), l = Pe(Re([i, s], n));
13309
- e.line(Fe, a, l);
13335
+ const o = $e(t, "x1"), r = $e(t, "y1"), i = $e(t, "x2"), s = $e(t, "y2"), a = Pe(Fe([o, r], n)), l = Pe(Fe([i, s], n));
13336
+ e.line(He, a, l);
13310
13337
  }
13311
13338
  function Mr(e, t, n, o) {
13312
13339
  const r = W6(t.getAttribute("points") ?? "");
13313
13340
  if (r.length < 2) return;
13314
- const i = r.map((s) => Pe(Re(s, n)));
13315
- e.lwpolyline(Fe, i, o);
13341
+ const i = r.map((s) => Pe(Fe(s, n)));
13342
+ e.lwpolyline(He, i, o);
13316
13343
  }
13317
13344
  function O6(e, t, n) {
13318
13345
  const o = $e(t, "x"), r = $e(t, "y"), i = $e(t, "width"), s = $e(t, "height"), l = [
@@ -13320,12 +13347,12 @@ function O6(e, t, n) {
13320
13347
  [o + i, r],
13321
13348
  [o + i, r + s],
13322
13349
  [o, r + s]
13323
- ].map((d) => Pe(Re(d, n)));
13324
- e.lwpolyline(Fe, l, !0);
13350
+ ].map((d) => Pe(Fe(d, n)));
13351
+ e.lwpolyline(He, l, !0);
13325
13352
  }
13326
13353
  function B6(e, t, n) {
13327
- const o = $e(t, "cx"), r = $e(t, "cy"), i = $e(t, "r"), s = Pe(Re([o, r], n));
13328
- e.circle(Fe, s, i);
13354
+ const o = $e(t, "cx"), r = $e(t, "cy"), i = $e(t, "r"), s = Pe(Fe([o, r], n));
13355
+ e.circle(He, s, i);
13329
13356
  }
13330
13357
  function j6(e, t, n) {
13331
13358
  const o = $e(t, "cx"), r = $e(t, "cy"), i = $e(t, "rx"), s = $e(t, "ry");
@@ -13336,8 +13363,8 @@ function j6(e, t, n) {
13336
13363
  z6(e, o, r, i, s, n);
13337
13364
  }
13338
13365
  function L6(e, t, n, o, r) {
13339
- const i = Pe(Re([t, n], r));
13340
- e.circle(Fe, i, o);
13366
+ const i = Pe(Fe([t, n], r));
13367
+ e.circle(He, i, o);
13341
13368
  }
13342
13369
  function z6(e, t, n, o, r, i) {
13343
13370
  const s = [];
@@ -13345,17 +13372,17 @@ function z6(e, t, n, o, r, i) {
13345
13372
  const l = a / Er * Math.PI * 2;
13346
13373
  s.push(
13347
13374
  Pe(
13348
- Re([t + o * Math.cos(l), n + r * Math.sin(l)], i)
13375
+ Fe([t + o * Math.cos(l), n + r * Math.sin(l)], i)
13349
13376
  )
13350
13377
  );
13351
13378
  }
13352
- e.lwpolyline(Fe, s, !0);
13379
+ e.lwpolyline(He, s, !0);
13353
13380
  }
13354
13381
  function D6(e, t, n) {
13355
13382
  const o = $e(t, "x"), r = $e(t, "y"), i = parseFloat(t.getAttribute("font-size") ?? "") || T6, s = (t.textContent ?? "").trim();
13356
13383
  if (!s) return;
13357
- const a = Pe(Re([o, r], n));
13358
- e.text(Fe, a, s, i, n.rot, n.mirror);
13384
+ const a = Pe(Fe([o, r], n));
13385
+ e.text(He, a, s, i, n.rot, n.mirror);
13359
13386
  }
13360
13387
  function R6(e, t, n) {
13361
13388
  const o = t.getAttribute("d") ?? "", r = F6(o);
@@ -13363,8 +13390,8 @@ function R6(e, t, n) {
13363
13390
  let i = null, s = [];
13364
13391
  const a = () => {
13365
13392
  s.length >= 2 && e.lwpolyline(
13366
- Fe,
13367
- s.map((l) => Pe(Re(l, n))),
13393
+ He,
13394
+ s.map((l) => Pe(Fe(l, n))),
13368
13395
  !1
13369
13396
  ), s = [];
13370
13397
  };
@@ -13414,21 +13441,21 @@ function H6(e, t, n, o, r, i) {
13414
13441
  const F = Math.sqrt(w);
13415
13442
  f *= F, p *= F;
13416
13443
  }
13417
- const E = r === i ? -1 : 1, k = f * f * p * p - f * f * u * u - p * p * c * c, b = f * f * u * u + p * p * c * c, S = E * Math.sqrt(Math.max(0, k / b)), C = S * (f * u) / p, j = S * -(p * c) / f, q = C + (s + l) / 2, V = j + (a + d) / 2, ie = (F, Z, ae, ce) => {
13418
- const Q = F * ae + Z * ce, ye = Math.hypot(F, Z) * Math.hypot(ae, ce);
13444
+ const E = r === i ? -1 : 1, k = f * f * p * p - f * f * u * u - p * p * c * c, x = f * f * u * u + p * p * c * c, $ = E * Math.sqrt(Math.max(0, k / x)), C = $ * (f * u) / p, j = $ * -(p * c) / f, W = C + (s + l) / 2, K = j + (a + d) / 2, re = (F, Z, le, de) => {
13445
+ const Q = F * le + Z * de, ye = Math.hypot(F, Z) * Math.hypot(le, de);
13419
13446
  let be = Math.acos(Math.max(-1, Math.min(1, Q / ye)));
13420
- return F * ce - Z * ae < 0 && (be = -be), be;
13421
- }, se = ie(1, 0, (c - C) / f, (u - j) / p);
13422
- let D = ie(
13447
+ return F * de - Z * le < 0 && (be = -be), be;
13448
+ }, ae = re(1, 0, (c - C) / f, (u - j) / p);
13449
+ let D = re(
13423
13450
  (c - C) / f,
13424
13451
  (u - j) / p,
13425
13452
  (-c - C) / f,
13426
13453
  (-u - j) / p
13427
13454
  );
13428
- return !i && D > 0 ? D -= 2 * Math.PI : i && D < 0 && (D += 2 * Math.PI), { cx: q, cy: V, theta1: se, delta: D };
13455
+ return !i && D > 0 ? D -= 2 * Math.PI : i && D < 0 && (D += 2 * Math.PI), { cx: W, cy: K, theta1: ae, delta: D };
13429
13456
  }
13430
- function Re(e, t) {
13431
- return je(e, t);
13457
+ function Fe(e, t) {
13458
+ return Le(e, t);
13432
13459
  }
13433
13460
  function Pe(e) {
13434
13461
  return [e[0], -e[1]];
@@ -13513,9 +13540,9 @@ function Pw(e, t = {}) {
13513
13540
  }
13514
13541
  l.push(" </g>");
13515
13542
  for (const { bus: u, geometry: f } of e.buses.values()) {
13516
- const { axis: p, at: h, span: g } = f, w = g / 2, E = p === "x" ? h[0] - w : h[0], k = p === "x" ? h[1] : h[1] - w, b = p === "x" ? h[0] + w : h[0], S = p === "x" ? h[1] : h[1] + w;
13543
+ const { axis: p, at: h, span: g } = f, w = g / 2, E = p === "x" ? h[0] - w : h[0], k = p === "x" ? h[1] : h[1] - w, x = p === "x" ? h[0] + w : h[0], $ = p === "x" ? h[1] : h[1] + w;
13517
13544
  l.push(
13518
- ` <line id="${st(u.id)}" x1="${E}" y1="${k}" x2="${b}" y2="${S}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`
13545
+ ` <line id="${st(u.id)}" x1="${E}" y1="${k}" x2="${x}" y2="${$}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`
13519
13546
  );
13520
13547
  }
13521
13548
  for (const { junction: u, world: f } of e.junctions.values())
@@ -13541,9 +13568,9 @@ function Pw(e, t = {}) {
13541
13568
  const h = tn(f, d);
13542
13569
  if (h.length === 0) continue;
13543
13570
  const g = f.libraryDef.label ?? nn(f.libraryDef), [w, E] = on(g, p), k = g.anchor ?? "start";
13544
- for (let b = 0; b < h.length; b++)
13571
+ for (let x = 0; x < h.length; x++)
13545
13572
  l.push(
13546
- ` <text x="${w}" y="${E + b * en}" text-anchor="${k}">${st(h[b])}</text>`
13573
+ ` <text x="${w}" y="${E + x * en}" text-anchor="${k}">${st(h[x])}</text>`
13547
13574
  );
13548
13575
  }
13549
13576
  l.push(" </g>");
@@ -13592,7 +13619,7 @@ function X6(e, t) {
13592
13619
  [u.x + u.w, u.y + u.h]
13593
13620
  ];
13594
13621
  for (const p of f) {
13595
- const [h, g] = je(p, d);
13622
+ const [h, g] = Le(p, d);
13596
13623
  s(h, g);
13597
13624
  }
13598
13625
  }
@@ -13686,7 +13713,7 @@ function r5() {
13686
13713
  const r = (i) => () => {
13687
13714
  var u, f, p, h;
13688
13715
  n(!1);
13689
- const { internal: s, diagram: a, fileSession: l } = x.getState(), d = ((u = l == null ? void 0 : l.name) == null ? void 0 : u.replace(/\.json$/i, "")) ?? ((f = a.meta) == null ? void 0 : f.title) ?? "diagram", c = {
13716
+ const { internal: s, diagram: a, fileSession: l } = b.getState(), d = ((u = l == null ? void 0 : l.name) == null ? void 0 : u.replace(/\.json$/i, "")) ?? ((f = a.meta) == null ? void 0 : f.title) ?? "diagram", c = {
13690
13717
  title: (p = a.meta) == null ? void 0 : p.title,
13691
13718
  labelMode: (h = a.meta) == null ? void 0 : h.labelMode,
13692
13719
  annotations: a.annotations
@@ -13786,8 +13813,8 @@ export {
13786
13813
  No as orientationVec,
13787
13814
  t2 as resolvePlacement,
13788
13815
  Rt as transformOrientation,
13789
- je as transformPoint,
13790
- x as useEditorStore,
13816
+ Le as transformPoint,
13817
+ b as useEditorStore,
13791
13818
  Qt as useLocale,
13792
13819
  at as wireIdFromEnds
13793
13820
  };