@nxgt/material-vue 0.16.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +4 -0
  2. package/dist/_baseIsEqual-Cj6hHjs0.js +226 -0
  3. package/dist/abnfDiagram-O67JEVCF-Cl_I9xuI.js +89 -0
  4. package/dist/arc-DNNg1pxp.js +80 -0
  5. package/dist/architecture-7GRP2DOG-DDr0RGVC.js +3 -0
  6. package/dist/architectureDiagram-NJMV4G6O-CVS4UUCi.js +4146 -0
  7. package/dist/array-CApNbSU9.js +6 -0
  8. package/dist/blockDiagram-BEXU5L5S-B5Z0jbc8.js +1946 -0
  9. package/dist/c4Diagram-YGBWAQC7-B6jKsl3h.js +2990 -0
  10. package/dist/{camera-Cbd1TWFd.js → camera-oxz1xItP.js} +4 -4
  11. package/dist/channel-BA1GJyZ7.js +5 -0
  12. package/dist/chunk-2Q5K7J3B-kzxEEeTu.js +15 -0
  13. package/dist/chunk-3FUC2YCW-CX-v_TQz.js +364 -0
  14. package/dist/chunk-5DYCD2WN-B9vjeX2u.js +37 -0
  15. package/dist/chunk-5VM5RSS4-Cr17nBXp.js +5 -0
  16. package/dist/chunk-6AEJRKK7-D9IaQdwq.js +10 -0
  17. package/dist/chunk-742MDFTN-BIhVe9GR.js +275 -0
  18. package/dist/chunk-7INBJB4K-CwPgdc2G.js +4487 -0
  19. package/dist/chunk-7M6MHVWA-Deh_-m6x.js +4256 -0
  20. package/dist/chunk-7PRAP22T-CofnNOEr.js +67 -0
  21. package/dist/chunk-DUW6YSOI-BdOla2G8.js +10 -0
  22. package/dist/chunk-FOHPRMQF-Crq0JMf2.js +21388 -0
  23. package/dist/chunk-GNY47TPC-rS2K544k.js +75 -0
  24. package/dist/chunk-GTNCS2PH-BR0O70z_.js +490 -0
  25. package/dist/chunk-GWA4HPMP-DU9lUCZD.js +61 -0
  26. package/dist/chunk-J5ZVWO5B-CYzz6Pq8.js +12 -0
  27. package/dist/chunk-JWPE2WC7-Ccb0QaC8.js +8 -0
  28. package/dist/chunk-LNGE3PJU-CiGrDO_F.js +1513 -0
  29. package/dist/chunk-MBY4JIJT-HYVRUG_P.js +1847 -0
  30. package/dist/chunk-NETBCI7D-C8amwD_P.js +236 -0
  31. package/dist/chunk-O7XYJQB3-WMQqqzRb.js +3922 -0
  32. package/dist/chunk-UA2S7LBM-DtBatid7.js +363 -0
  33. package/dist/chunk-WEXAMYUT-Cc10h8ed.js +26 -0
  34. package/dist/chunk-XXDRQBXY-B2pGFcse.js +9 -0
  35. package/dist/chunk-Y2CYZVJY-i11wjrBe.js +12 -0
  36. package/dist/chunk-Z7XXMR3K-CJmsOGTV.js +676 -0
  37. package/dist/chunk-ZIGJFQKS-DBdWb0bj.js +1366 -0
  38. package/dist/classDiagram-v2-NBCMYWYE-Caqw5P6A.js +3397 -0
  39. package/dist/{components-DLtnz66n.js → components-IbdMALGv.js} +43465 -18610
  40. package/dist/components.js +5 -5
  41. package/dist/{composables-BJ2GgDD0.js → composables-6zV0t-y7.js} +1 -1
  42. package/dist/composables.js +1 -1
  43. package/dist/cose-bilkent-JH36ORCC-DStMi-eo.js +2251 -0
  44. package/dist/cynefin-OW5HDTMX-B8HVdZhp.js +3 -0
  45. package/dist/cynefinDiagram-VND7K2PF-0Mq0e5NQ.js +349 -0
  46. package/dist/cytoscape.esm-_jXi1N4y.js +18151 -0
  47. package/dist/dagre-6A5THRUB-EHXNn6Wq.js +2192 -0
  48. package/dist/defaultLocale-DnzPsei5.js +201 -0
  49. package/dist/diagram-22UHCM2B-B3RAQlqQ.js +5084 -0
  50. package/dist/diagram-3UASUU5V-BznCZHss.js +525 -0
  51. package/dist/diagram-ATOU4E4O-DtIUxSAn.js +432 -0
  52. package/dist/diagram-CDSNMT55-DOjN3BR2.js +301 -0
  53. package/dist/diagram-MLGK6HIB-Dx2UboD6.js +134 -0
  54. package/dist/diagram-MPIPVDR6-DnPL3RV0.js +214 -0
  55. package/dist/dist-D9zvfe2i.js +59 -0
  56. package/dist/{dnd-Cmcrm28l.js → dnd-CaDeYjQx.js} +1 -1
  57. package/dist/dnd.js +1 -1
  58. package/dist/ebnfDiagram-ZINNZB2B-BNbxCL0b.js +100 -0
  59. package/dist/elk-276RUBZZ-B9WeHolc.js +47597 -0
  60. package/dist/erDiagram-OPXOYQCR-DReZElBu.js +1970 -0
  61. package/dist/eventmodeling-NTZA5JFV-C1CEo-26.js +3 -0
  62. package/dist/flowDiagram-KWPJA3E3-DYss4vEI.js +17 -0
  63. package/dist/ganttDiagram-FUAMR5RP-64EZDDmC.js +3083 -0
  64. package/dist/gitGraph-4MIJSDKK-BTeCS_5q.js +3 -0
  65. package/dist/gitGraphDiagram-X574FWY7-DmMMrp5A.js +729 -0
  66. package/dist/graphlib-CrmIPC4m.js +372 -0
  67. package/dist/{i18n-DmMS3ID3.js → i18n-OBzfa-B7.js} +233 -924
  68. package/dist/i18n.js +2 -2
  69. package/dist/info-A6RAGUB7-BvtuPd9C.js +3 -0
  70. package/dist/infoDiagram-VRGFBTTK-XlBUAu0t.js +20 -0
  71. package/dist/init-MwSGRDIl.js +15 -0
  72. package/dist/isArrayLikeObject-VG1KOJ3m.js +539 -0
  73. package/dist/isEmpty-CMjyBU-a.js +136 -0
  74. package/dist/ishikawaDiagram-OU5B5YK6-C9cMWMPO.js +719 -0
  75. package/dist/journeyDiagram-ZHPQQLJL-DXdfP9BW.js +884 -0
  76. package/dist/kanban-definition-PNTS6WVX-DhOBy3A0.js +976 -0
  77. package/dist/katex-BMQ6LGsM.js +21962 -0
  78. package/dist/lib/components/index.d.ts +4 -0
  79. package/dist/lib/components/ui/chat/chat-composer-mentions.vue.d.ts +13 -0
  80. package/dist/lib/components/ui/chat/chat-composer.vue.d.ts +6 -2
  81. package/dist/lib/components/ui/contacts/consts.d.ts +1 -1
  82. package/dist/lib/components/ui/emoji/emoji-list.vue.d.ts +11 -0
  83. package/dist/lib/components/ui/emoji/emoji-picker.vue.d.ts +12 -0
  84. package/dist/lib/components/ui/emoji/emoji.utils.d.ts +2 -0
  85. package/dist/lib/components/ui/emoji/index.d.ts +4 -0
  86. package/dist/lib/components/ui/emoji/types.d.ts +6 -0
  87. package/dist/lib/components/ui/markdown/index.d.ts +2 -0
  88. package/dist/lib/components/ui/markdown/markdown.utils.d.ts +10 -0
  89. package/dist/lib/components/ui/markdown/markdown.vue.d.ts +10 -0
  90. package/dist/lib/components/ui/markdown/mermaid.lazy.d.ts +12 -0
  91. package/dist/lib/components/ui/markdown/partials/mermaid-diagram.vue.d.ts +7 -0
  92. package/dist/lib/components/ui/mentions/index.d.ts +4 -0
  93. package/dist/lib/components/ui/mentions/mention-list.vue.d.ts +16 -0
  94. package/dist/lib/components/ui/mentions/mentions.utils.d.ts +7 -0
  95. package/dist/lib/components/ui/mentions/types.d.ts +5 -0
  96. package/dist/lib/components/ui/terminal/index.d.ts +3 -0
  97. package/dist/lib/components/ui/terminal/terminal.utils.d.ts +5 -0
  98. package/dist/lib/components/ui/terminal/terminal.vue.d.ts +17 -0
  99. package/dist/lib/i18n/resources/en/index.d.ts +7 -0
  100. package/dist/lib/i18n/resources/en/material.json.d.ts +7 -0
  101. package/dist/lib/i18n/resources/fr/index.d.ts +7 -0
  102. package/dist/lib/i18n/resources/fr/material.json.d.ts +7 -0
  103. package/dist/lib/i18n/resources/index.d.ts +14 -0
  104. package/dist/lib/i18n/translator.d.ts +1 -1
  105. package/dist/lib/nuxt/component-names.d.ts +1 -1
  106. package/dist/lib-B9AHrvmh.js +389 -0
  107. package/dist/lib.js +1 -1
  108. package/dist/line-UP6dkL36.js +34 -0
  109. package/dist/linear-bD_QoED_.js +289 -0
  110. package/dist/main.js +9 -9
  111. package/dist/material-vue.css +1 -1
  112. package/dist/merge-B4IBXGaq.js +170 -0
  113. package/dist/mermaid-parser.core-Cz-MfB4Z.js +638 -0
  114. package/dist/mermaid.core-C_Rtflmc.js +1096 -0
  115. package/dist/mindmap-definition-NLK3R4M7-CO6s2Afv.js +1008 -0
  116. package/dist/ordinal-D_ZgubzR.js +65 -0
  117. package/dist/packet-AYTQ26CC-CshIswP8.js +3 -0
  118. package/dist/path-DGNPZRdx.js +85 -0
  119. package/dist/{pdf-outline-sidebar-BBXJRwdt.js → pdf-outline-sidebar-D5VedBgk.js} +3 -2
  120. package/dist/{pdf-page-DZyTFukn.js → pdf-page-B1Ze518d.js} +1 -1
  121. package/dist/{pdf-page-list-C3GukJ3_.js → pdf-page-list-CBJziavm.js} +3 -2
  122. package/dist/{pdf-reader-Ci4v2Ff9.js → pdf-reader-Cn1uxtJN.js} +13 -13
  123. package/dist/{pdf-sidebar-Dl8fQStG.js → pdf-sidebar-PXfgGlmq.js} +4 -4
  124. package/dist/{pdf-thumbnail-sidebar-GS_V0PGc.js → pdf-thumbnail-sidebar-7agqWsXT.js} +4 -3
  125. package/dist/{pdf-toolbar-D37w-WIK.js → pdf-toolbar-Blm9CFvh.js} +22 -21
  126. package/dist/pegDiagram-GJSIUBJH-gvsGke9W.js +94 -0
  127. package/dist/pie-WAS4IAKB-CYs22y4X.js +3 -0
  128. package/dist/pieDiagram-5QR66LMP-DLBcErnI.js +205 -0
  129. package/dist/quadrantDiagram-O4NWA36T-Bn3CmGxM.js +2001 -0
  130. package/dist/radar-RG4KPBEZ-BOJKjbGv.js +3 -0
  131. package/dist/railroad-74A4TZTK-Dt1BmUkI.js +3 -0
  132. package/dist/railroad-abnf-HS5TGJTU-Cs9GMUMY.js +3 -0
  133. package/dist/railroad-ebnf-LZEXJU2U-D4y0fXoW.js +3 -0
  134. package/dist/railroad-peg-WCYAUIDC-D2f_ZNR5.js +3 -0
  135. package/dist/railroadDiagram-XR7U4H2S-DLeBxWbV.js +76 -0
  136. package/dist/requirementDiagram-PLB6GJNP-JpWB5sEv.js +2228 -0
  137. package/dist/rolldown-runtime-CWhphoD1.js +23 -0
  138. package/dist/rough.esm-rcMoXTJj.js +1352 -0
  139. package/dist/sankeyDiagram-IPEJSGJF-a4rFl5rR.js +970 -0
  140. package/dist/sequenceDiagram-PO4LG4MO-CjUigcL2.js +4200 -0
  141. package/dist/sizeCapture-INFHLROL-CHXIsPO_.js +46 -0
  142. package/dist/src-CNRY2AUH.js +2142 -0
  143. package/dist/stateDiagram-v2-GCMORJYK-DJkVDIb0.js +2143 -0
  144. package/dist/{stx-player-C0FOaRjU.js → stx-player-rs3uH0iI.js} +17 -17
  145. package/dist/swimlanes-2SLR337P-D7Ff0hLr.js +4763 -0
  146. package/dist/swimlanesDiagram-TC7HE7FX-DZZ9d76C.js +28 -0
  147. package/dist/timeline-definition-EJHVYXUP-C0aHlt9K.js +1073 -0
  148. package/dist/treeView-Q6P3EWNA-BrJylG9N.js +3 -0
  149. package/dist/treemap-WGGIJYW6-DpIZuqbj.js +3 -0
  150. package/dist/usecaseDiagram-POWQR4AR-BrRAt7Wu.js +9932 -0
  151. package/dist/vennDiagram-UO4OBE2U-B22Jhju8.js +1880 -0
  152. package/dist/wardley-WFR3VGLG-CbwdAAbH.js +3 -0
  153. package/dist/wardleyDiagram-VNRHLVJA-Dw4YgRiQ.js +645 -0
  154. package/dist/xychartDiagram-PMCCYNJV-DtuDs9I7.js +2214 -0
  155. package/lib/nuxt/component-names.ts +2 -0
  156. package/package.json +5 -1
  157. package/dist/lib-CT0uRn8S.js +0 -611
@@ -0,0 +1,4763 @@
1
+ import { n as e } from "./chunk-Y2CYZVJY-i11wjrBe.js";
2
+ import { m as t } from "./src-CNRY2AUH.js";
3
+ import "./chunk-O7XYJQB3-WMQqqzRb.js";
4
+ import "./chunk-ZIGJFQKS-DBdWb0bj.js";
5
+ import "./chunk-742MDFTN-BIhVe9GR.js";
6
+ import "./chunk-MBY4JIJT-HYVRUG_P.js";
7
+ import "./chunk-7PRAP22T-CofnNOEr.js";
8
+ import "./chunk-7INBJB4K-CwPgdc2G.js";
9
+ import "./chunk-5DYCD2WN-B9vjeX2u.js";
10
+ import "./chunk-Z7XXMR3K-CJmsOGTV.js";
11
+ import "./chunk-UA2S7LBM-DtBatid7.js";
12
+ import { r as n } from "./chunk-3FUC2YCW-CX-v_TQz.js";
13
+ import { t as r } from "./chunk-NETBCI7D-C8amwD_P.js";
14
+ //#region node_modules/mermaid/dist/chunks/mermaid.core/swimlanes-2SLR337P.mjs
15
+ function i(e, { measure: t }) {
16
+ let n = e.config?.swimlane?.lineHops;
17
+ if (n === !1) return;
18
+ let i = n === "gap" ? "gap" : "arc", a = e.edges.filter((e) => Array.isArray(e.points) && e.points.length >= 2).map((e) => ({
19
+ id: e.id,
20
+ points: e.points,
21
+ curve: e.curve,
22
+ arrowTypeStart: e.arrowTypeStart,
23
+ arrowTypeEnd: e.arrowTypeEnd
24
+ }));
25
+ r(t.groups.edgePaths, a, {
26
+ enabled: !0,
27
+ jumpRadius: 6,
28
+ jumpStyle: i
29
+ });
30
+ }
31
+ e(i, "applySwimlaneLineJumps");
32
+ var a = "__swimlane_default__", o = 21, s = 20;
33
+ function c(e) {
34
+ return Math.max(e.padding ?? s, s);
35
+ }
36
+ e(c, "topLaneHorizontalPadding");
37
+ function l(e) {
38
+ let { x: t, y: n, width: r, height: i } = e, a = e.swimlaneContentTop;
39
+ if (typeof t != "number" || typeof n != "number" || typeof r != "number" || typeof i != "number" || typeof a != "number" || !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(a) || r <= 0 || i <= 0) {
40
+ delete e.groupTitleRect;
41
+ return;
42
+ }
43
+ let s = n - i / 2, c = Math.min(a, n + i / 2), l = s + Math.min(o, Math.max(0, c - s));
44
+ if (l <= s) {
45
+ delete e.groupTitleRect;
46
+ return;
47
+ }
48
+ e.groupTitleRect = {
49
+ left: t - r / 2,
50
+ right: t + r / 2,
51
+ top: s,
52
+ bottom: l
53
+ };
54
+ }
55
+ e(l, "assignTopLaneTitleRect");
56
+ function u(e) {
57
+ let t = e.direction, n = e.nodes ??= [];
58
+ for (let n of e.nodes ?? []) n.isGroup && !n.parentId && (n.shape = "swimlane", t && (n.direction = t));
59
+ let r = n.filter((e) => !e.isGroup && !e.parentId);
60
+ if (r.length === 0) return;
61
+ let i = n.find((e) => e.id === a);
62
+ i ? i.isGroup && (i.shape = "swimlane", t && (i.direction = t)) : (i = {
63
+ id: a,
64
+ label: "",
65
+ isGroup: !0,
66
+ shape: "swimlane",
67
+ padding: 20,
68
+ look: e.config?.look,
69
+ colorIndex: n.reduce((e, t) => Math.max(e, t.colorIndex ?? -1), -1) + 1,
70
+ ...t ? { direction: t } : {}
71
+ }, n.push(i));
72
+ for (let e of r) e.parentId = a;
73
+ }
74
+ e(u, "prepareLayoutForSwimlanes");
75
+ function d(e) {
76
+ let t = /* @__PURE__ */ new Map();
77
+ for (let n of e.nodes ?? []) t.set(n.id, n);
78
+ let n = [];
79
+ for (let t of e.edges ?? []) {
80
+ let e = typeof t.start == "string" ? t.start : void 0, r = typeof t.end == "string" ? t.end : void 0;
81
+ !e || !r || t.labelNodeId || n.push({
82
+ id: t.id,
83
+ src: e,
84
+ dst: r,
85
+ ref: t
86
+ });
87
+ }
88
+ let r = e.nodes ?? [], i = r.filter((e) => e.isGroup), a = r.filter((e) => !e.isGroup);
89
+ return {
90
+ nodes: [...[...i].reverse(), ...a].map((e) => e.id),
91
+ edges: n,
92
+ layout: e,
93
+ nodeById: t
94
+ };
95
+ }
96
+ e(d, "toGraphView");
97
+ function f(e, t, n, r) {
98
+ let { layout: i } = e, a = e.nodeById, o = r?.layerGap ?? 100, s = r?.nodeGap ?? 40, u = 0;
99
+ for (let e of t.layers) {
100
+ let t = 0;
101
+ for (let r of e) {
102
+ let e = a.get(r);
103
+ if (!e) {
104
+ t++;
105
+ continue;
106
+ }
107
+ e.layer = u, e.order = t;
108
+ let i = n.x[r] ?? t * s, c = n.y[r] ?? u * o;
109
+ e.x = i, e.y = c, t++;
110
+ }
111
+ u++;
112
+ }
113
+ let d = i.nodes ?? [], f = /* @__PURE__ */ new Map(), p = [];
114
+ for (let e of d) {
115
+ if (!e?.isGroup) continue;
116
+ e.parentId || p.push(e);
117
+ let t = d.filter((t) => t.parentId === e.id), r = Infinity, i = -Infinity, a = Infinity, o = -Infinity;
118
+ for (let e of t) {
119
+ let t = e.x ?? n.x[e.id], s = e.y ?? n.y[e.id], c = e.width ?? 0, l = e.height ?? 0;
120
+ t != null && s != null && (r = Math.min(r, t - c / 2), i = Math.max(i, t + c / 2), a = Math.min(a, s - l / 2), o = Math.max(o, s + l / 2));
121
+ }
122
+ if (r === Infinity || a === Infinity) e.x = e.x ?? 0, e.y = e.y ?? 0, e.width = e.width ?? 0, e.height = e.height ?? 0;
123
+ else {
124
+ let t = e.padding ?? 20, n = e.parentId ? t : 2 * c(e), s = t, l = Math.max(0, i - r) + n, u = Math.max(0, o - a) + s, d = (r + i) / 2, p = (a + o) / 2;
125
+ e.x = d, e.y = p, e.width = l, e.height = u, f.set(e.id, {
126
+ minX: r,
127
+ maxX: i,
128
+ minY: a,
129
+ maxY: o
130
+ });
131
+ }
132
+ }
133
+ if (p.length > 0 && f.size > 0) {
134
+ let e = Infinity, t = -Infinity, n = 0;
135
+ for (let r of p) {
136
+ let i = r.padding ?? 20;
137
+ i > n && (n = i);
138
+ let a = f.get(r.id);
139
+ a && (e = Math.min(e, a.minY), t = Math.max(t, a.maxY));
140
+ }
141
+ if (e !== Infinity && t !== -Infinity) {
142
+ let r = Math.max(0, t - e) + 2 * Math.max(n, 36), i = (e + t) / 2;
143
+ for (let t of p) t.y = i, t.height = r, t.swimlaneContentTop = e;
144
+ let a = [...p].sort((e, t) => (e.x ?? 0) - (t.x ?? 0)), o = [], s = [], u = [];
145
+ for (let e of a) {
146
+ let t = f.get(e.id);
147
+ if (!t) continue;
148
+ let n = Math.max(0, t.maxX - t.minX) + 2 * c(e), r = (t.minX + t.maxX) / 2;
149
+ o.push(e.id), s.push(r), u.push(n);
150
+ }
151
+ let d = o.length;
152
+ if (d > 0) {
153
+ let e = /* @__PURE__ */ new Map();
154
+ if (d === 1) e.set(o[0], u[0]);
155
+ else {
156
+ let t = [];
157
+ for (let e = 0; e < d - 1; e++) t.push(s[e + 1] - s[e]);
158
+ let n = Array(d);
159
+ n[0] = 0;
160
+ for (let e = 0; e < d - 1; e++) n[e + 1] = 2 * t[e] - n[e];
161
+ let r = 0, i = Infinity;
162
+ for (let e = 0; e < d; e++) {
163
+ let t = u[e];
164
+ e % 2 == 0 ? r = Math.max(r, t - n[e]) : i = Math.min(i, n[e] - t);
165
+ }
166
+ let a = r;
167
+ a = r <= i ? (r + i) / 2 : r;
168
+ for (let t = 0; t < d; t++) {
169
+ let r = n[t] + (t % 2 == 0 ? a : -a), i = Math.max(u[t], r);
170
+ e.set(o[t], i);
171
+ }
172
+ }
173
+ for (let t of p) {
174
+ let n = e.get(t.id);
175
+ n != null && (t.width = n), l(t);
176
+ }
177
+ }
178
+ }
179
+ }
180
+ }
181
+ e(f, "writeBackToLayoutData");
182
+ var p = "[EdgeLabelNodes]";
183
+ function m(e) {
184
+ let n = [], r = [], i = /* @__PURE__ */ new Map();
185
+ for (let t of e.nodes) i.set(t.id, t);
186
+ for (let a of e.edges) {
187
+ if (!a.label || a.label.length === 0 || a.isLayoutOnly || a.labelNodeId) continue;
188
+ let e = a.start ? i.get(a.start) : void 0, o = a.end ? i.get(a.end) : void 0;
189
+ if (!e || !o) {
190
+ t.warn(p, `Edge ${a.id} has missing source or target node`);
191
+ continue;
192
+ }
193
+ let s = `edge-label-${a.start}-${a.end}-${a.id}`, c = e.parentId === o.parentId ? e.parentId : o.parentId, l = {
194
+ id: s,
195
+ label: a.label,
196
+ edgeStart: a.start ?? "",
197
+ edgeEnd: a.end ?? "",
198
+ shape: "labelRect",
199
+ width: 0,
200
+ height: 0,
201
+ isEdgeLabel: !0,
202
+ isDummy: !0,
203
+ parentId: c,
204
+ isGroup: !1,
205
+ labelStyle: Array.isArray(a.labelStyle) ? a.labelStyle[0] : a.labelStyle ?? "",
206
+ ...e.dir ? { dir: e.dir } : {}
207
+ };
208
+ n.push(l), a.labelNodeId = s, a.label = void 0, a.text = void 0;
209
+ let u = {
210
+ id: `${a.id}-to-label`,
211
+ start: a.start,
212
+ end: s,
213
+ type: "normal",
214
+ isLayoutOnly: !0
215
+ }, d = {
216
+ id: `${a.id}-from-label`,
217
+ start: s,
218
+ end: a.end,
219
+ type: "normal",
220
+ isLayoutOnly: !0
221
+ };
222
+ r.push(u, d);
223
+ }
224
+ let a = [...e.nodes, ...n], o = [...e.edges, ...r];
225
+ return {
226
+ ...e,
227
+ nodes: a,
228
+ edges: o
229
+ };
230
+ }
231
+ e(m, "createEdgeLabelNodes");
232
+ var h = .001;
233
+ function g(e) {
234
+ let t = e.x ?? 0, n = e.y ?? 0, r = e.width ?? 0, i = e.height ?? 0;
235
+ return r > 0 && i > 0 ? {
236
+ cx: t,
237
+ cy: n,
238
+ rect: P(t, n, r, i)
239
+ } : void 0;
240
+ }
241
+ e(g, "measuredNodeRect");
242
+ function _(e) {
243
+ if (e.isGroup) return;
244
+ let t = g(e);
245
+ if (t) return {
246
+ id: String(e.id ?? ""),
247
+ cx: t.cx,
248
+ cy: t.cy,
249
+ rect: t.rect
250
+ };
251
+ }
252
+ e(_, "nodeBoundsInfoFor");
253
+ function v(e, t, n = h) {
254
+ return Math.abs(e.x - t.x) < n && Math.abs(e.y - t.y) < n;
255
+ }
256
+ e(v, "samePoint");
257
+ function y(e, t, n = h) {
258
+ return Math.abs(e.x - t.x) < n;
259
+ }
260
+ e(y, "sameX");
261
+ function b(e, t, n = h) {
262
+ return Math.abs(e.y - t.y) < n;
263
+ }
264
+ e(b, "sameY");
265
+ function x(e, t, n = h) {
266
+ return b(e, t, n) && Math.abs(e.x - t.x) > n;
267
+ }
268
+ e(x, "isHorizontalSegment");
269
+ function S(e, t, n = h) {
270
+ return y(e, t, n) && Math.abs(e.y - t.y) > n;
271
+ }
272
+ e(S, "isVerticalSegment");
273
+ function C(e, t, n, r) {
274
+ return Math.max(0, Math.min(Math.max(e, t), Math.max(n, r)) - Math.max(Math.min(e, t), Math.min(n, r)));
275
+ }
276
+ e(C, "overlapLength");
277
+ function w(e, t, n = h) {
278
+ return e.horizontal && t.horizontal && b(e.a, t.a, n) ? C(e.a.x, e.b.x, t.a.x, t.b.x) : e.vertical && t.vertical && y(e.a, t.a, n) ? C(e.a.y, e.b.y, t.a.y, t.b.y) : 0;
279
+ }
280
+ e(w, "sameAxisSegmentOverlapLength");
281
+ function T(e, t = h) {
282
+ let n = [];
283
+ for (let r = 0; r < e.length - 1; r++) {
284
+ let i = e[r], a = e[r + 1], o = x(i, a, t), s = S(i, a, t);
285
+ (o || s) && n.push({
286
+ index: r,
287
+ a: i,
288
+ b: a,
289
+ horizontal: o,
290
+ vertical: s
291
+ });
292
+ }
293
+ return n;
294
+ }
295
+ e(T, "orthogonalSegmentsForPoints");
296
+ function E(e, t = h) {
297
+ let n = T(e, t), r = 0;
298
+ for (let e = 1; e < n.length; e++) n[e - 1].horizontal !== n[e].horizontal && r++;
299
+ return r;
300
+ }
301
+ e(E, "countOrthogonalBends");
302
+ function D(e, t = h) {
303
+ let n = [];
304
+ for (let r of e) {
305
+ let e = n.length > 0 ? n[n.length - 1] : void 0;
306
+ (!e || !v(e, r, t)) && n.push({
307
+ x: r.x,
308
+ y: r.y
309
+ });
310
+ }
311
+ return n;
312
+ }
313
+ e(D, "dedupeConsecutivePoints");
314
+ function O(e, t = h) {
315
+ if (!e || e.length !== 4) return;
316
+ let [n, r, i, a] = e;
317
+ return x(n, r, t) && S(r, i, t) && x(i, a, t) ? {
318
+ kind: "HVH",
319
+ p0: n,
320
+ p1: r,
321
+ p2: i,
322
+ p3: a
323
+ } : S(n, r, t) && x(r, i, t) && S(i, a, t) ? {
324
+ kind: "VHV",
325
+ p0: n,
326
+ p1: r,
327
+ p2: i,
328
+ p3: a
329
+ } : void 0;
330
+ }
331
+ e(O, "classifyThreeSegmentRoute");
332
+ function k(e, t, n, r = 0) {
333
+ let i = Math.min(e.x, t.x), a = Math.max(e.x, t.x), o = Math.min(e.y, t.y), s = Math.max(e.y, t.y);
334
+ return a > n.left - r && i < n.right + r && s > n.top - r && o < n.bottom + r;
335
+ }
336
+ e(k, "segmentBoundsOverlapRect");
337
+ function A(e, t, n = 0) {
338
+ return e.x > t.left + n && e.x < t.right - n && e.y > t.top + n && e.y < t.bottom - n;
339
+ }
340
+ e(A, "pointInsideRect");
341
+ function j(e, t) {
342
+ return e.left <= t.left && e.right >= t.right && e.top <= t.top && e.bottom >= t.bottom;
343
+ }
344
+ e(j, "rectContainsRect");
345
+ function M(e, t) {
346
+ return e.left < t.right && e.right > t.left && e.top < t.bottom && e.bottom > t.top;
347
+ }
348
+ e(M, "rectsOverlap");
349
+ function N(e, t) {
350
+ return {
351
+ left: e.left - t,
352
+ right: e.right + t,
353
+ top: e.top - t,
354
+ bottom: e.bottom + t
355
+ };
356
+ }
357
+ e(N, "inflateRect");
358
+ function P(e, t, n, r) {
359
+ return {
360
+ left: e - n / 2,
361
+ right: e + n / 2,
362
+ top: t - r / 2,
363
+ bottom: t + r / 2
364
+ };
365
+ }
366
+ e(P, "rectFromCenterSize");
367
+ function F(e) {
368
+ return g(e)?.rect;
369
+ }
370
+ e(F, "rectOfNodeBounds");
371
+ function I(e, t) {
372
+ switch (t) {
373
+ case "top": return {
374
+ x: e.cx,
375
+ y: e.rect.top
376
+ };
377
+ case "bottom": return {
378
+ x: e.cx,
379
+ y: e.rect.bottom
380
+ };
381
+ case "left": return {
382
+ x: e.rect.left,
383
+ y: e.cy
384
+ };
385
+ case "right": return {
386
+ x: e.rect.right,
387
+ y: e.cy
388
+ };
389
+ }
390
+ }
391
+ e(I, "portForRectSide");
392
+ function ee(e, t, n, r, i, a = h) {
393
+ let o = t === "left" || t === "right", s = r === "left" || r === "right";
394
+ if (o && s) {
395
+ if (t === "right" && r === "left" && e.x < n.x || t === "left" && r === "right" && e.x > n.x) {
396
+ if (b(e, n, a)) return [e, n];
397
+ let t = (e.x + n.x) / 2;
398
+ return [
399
+ e,
400
+ {
401
+ x: t,
402
+ y: e.y
403
+ },
404
+ {
405
+ x: t,
406
+ y: n.y
407
+ },
408
+ n
409
+ ];
410
+ }
411
+ if (t === r) {
412
+ if (b(e, n, a)) return;
413
+ let r = t === "left" ? Math.min(e.x, n.x) - i : Math.max(e.x, n.x) + i;
414
+ return [
415
+ e,
416
+ {
417
+ x: r,
418
+ y: e.y
419
+ },
420
+ {
421
+ x: r,
422
+ y: n.y
423
+ },
424
+ n
425
+ ];
426
+ }
427
+ return;
428
+ }
429
+ if (!o && !s) {
430
+ if (t === r) {
431
+ if (y(e, n, a)) return;
432
+ let r = t === "top" ? Math.min(e.y, n.y) - i : Math.max(e.y, n.y) + i;
433
+ return [
434
+ e,
435
+ {
436
+ x: e.x,
437
+ y: r
438
+ },
439
+ {
440
+ x: n.x,
441
+ y: r
442
+ },
443
+ n
444
+ ];
445
+ }
446
+ if (!(t === "bottom" && r === "top" && e.y < n.y || t === "top" && r === "bottom" && e.y > n.y)) return;
447
+ if (y(e, n, a)) return [e, n];
448
+ let o = (e.y + n.y) / 2;
449
+ return [
450
+ e,
451
+ {
452
+ x: e.x,
453
+ y: o
454
+ },
455
+ {
456
+ x: n.x,
457
+ y: o
458
+ },
459
+ n
460
+ ];
461
+ }
462
+ if (o && !s) {
463
+ let i = t === "right" && n.x > e.x || t === "left" && n.x < e.x, a = r === "top" && e.y < n.y || r === "bottom" && e.y > n.y;
464
+ return i && a ? [
465
+ e,
466
+ {
467
+ x: n.x,
468
+ y: e.y
469
+ },
470
+ n
471
+ ] : void 0;
472
+ }
473
+ let c = t === "bottom" && n.y > e.y || t === "top" && n.y < e.y, l = r === "left" && e.x < n.x || r === "right" && e.x > n.x;
474
+ return c && l ? [
475
+ e,
476
+ {
477
+ x: e.x,
478
+ y: n.y
479
+ },
480
+ n
481
+ ] : void 0;
482
+ }
483
+ e(ee, "buildOrthogonalPortPath");
484
+ function L(e, t, n, r) {
485
+ return t === "left" || t === "right" ? [
486
+ e,
487
+ {
488
+ x: r,
489
+ y: e.y
490
+ },
491
+ {
492
+ x: r,
493
+ y: n.y
494
+ },
495
+ n
496
+ ] : [
497
+ e,
498
+ {
499
+ x: e.x,
500
+ y: r
501
+ },
502
+ {
503
+ x: n.x,
504
+ y: r
505
+ },
506
+ n
507
+ ];
508
+ }
509
+ e(L, "buildSameSideTrackPath");
510
+ function R(e) {
511
+ let t = /* @__PURE__ */ new Map(), n = [];
512
+ for (let r of e) {
513
+ if (r.isEdgeLabel) continue;
514
+ let e = _(r);
515
+ e && (t.set(e.id, e), n.push({
516
+ id: e.id,
517
+ rect: e.rect
518
+ }));
519
+ }
520
+ return {
521
+ nodeInfoById: t,
522
+ realNodeRects: n
523
+ };
524
+ }
525
+ e(R, "collectRealNodeBounds");
526
+ function z(e) {
527
+ let t = [], n = [];
528
+ for (let r of e) {
529
+ let e = _(r);
530
+ if (!e) continue;
531
+ let i = {
532
+ id: e.id,
533
+ rect: e.rect
534
+ };
535
+ r.isEdgeLabel ? n.push(i) : t.push(i);
536
+ }
537
+ return {
538
+ realNodeRects: t,
539
+ labelNodeRects: n
540
+ };
541
+ }
542
+ e(z, "collectNodeRectEntries");
543
+ function te(e, { includeEdgeLabels: t = !0 } = {}) {
544
+ let n = [];
545
+ for (let r of e) {
546
+ if (r.isGroup || !t && r.isEdgeLabel) continue;
547
+ let e = r.x ?? 0, i = r.y ?? 0, a = r.width ?? 0, o = r.height ?? 0;
548
+ n.push({
549
+ nodeId: r.id,
550
+ ...P(e, i, a, o)
551
+ });
552
+ }
553
+ return n;
554
+ }
555
+ e(te, "collectLayoutNodeRects");
556
+ function ne(e, t, n = h) {
557
+ let r = e.start, i = e.end;
558
+ if (!r || !i) return;
559
+ let a = t.get(r), o = t.get(i);
560
+ if (!(!a || !o)) return {
561
+ srcId: r,
562
+ dstId: i,
563
+ srcInfo: a,
564
+ dstInfo: o,
565
+ collinearX: Math.abs(a.cx - o.cx) < n,
566
+ collinearY: Math.abs(a.cy - o.cy) < n
567
+ };
568
+ }
569
+ e(ne, "getNodePairGeometry");
570
+ function B(e, t, n, r = [], i = 0) {
571
+ for (let a of n) if (!r.includes(a.id) && k(e, t, a.rect, -i)) return !0;
572
+ return !1;
573
+ }
574
+ e(B, "segmentHitsAnyRect");
575
+ function re(e, t, n, r, i = h, a = 1e-6) {
576
+ let o = b(e, t, i), s = y(e, t, i), c = b(n, r, i), l = y(n, r, i);
577
+ if (o && c || s && l || !(o || s) || !(c || l)) return !1;
578
+ let u = o ? {
579
+ a: e,
580
+ b: t
581
+ } : {
582
+ a: n,
583
+ b: r
584
+ }, d = s ? {
585
+ a: e,
586
+ b: t
587
+ } : {
588
+ a: n,
589
+ b: r
590
+ }, f = u.a.y, p = Math.min(u.a.x, u.b.x), m = Math.max(u.a.x, u.b.x), g = d.a.x, _ = Math.min(d.a.y, d.b.y), v = Math.max(d.a.y, d.b.y);
591
+ if (g < p || g > m || f < _ || f > v) return !1;
592
+ let x = Math.abs(g - u.a.x) < a && Math.abs(f - u.a.y) < a || Math.abs(g - u.b.x) < a && Math.abs(f - u.b.y) < a, S = Math.abs(g - d.a.x) < a && Math.abs(f - d.a.y) < a || Math.abs(g - d.b.x) < a && Math.abs(f - d.b.y) < a;
593
+ return !(x && S);
594
+ }
595
+ e(re, "orthogonalSegmentsCross");
596
+ function ie(e, t, n, r, i = h) {
597
+ let a = b(e, t, i), o = y(e, t, i), s = b(n, r, i), c = y(n, r, i);
598
+ return o && c && y(e, n, i) ? C(e.y, t.y, n.y, r.y) > i : a && s && b(e, n, i) ? C(e.x, t.x, n.x, r.x) > i : !1;
599
+ }
600
+ e(ie, "sameAxisSegmentsOverlap");
601
+ function ae(e, t, n, r, { epsilon: i = h, skipDegenerateOther: a = !1 } = {}) {
602
+ for (let o of n) {
603
+ if (o === r || o.isLayoutOnly) continue;
604
+ let n = o.points;
605
+ if (!(!n || n.length < 2)) for (let r = 0; r < n.length - 1; r++) {
606
+ let o = n[r], s = n[r + 1];
607
+ if (!(a && v(o, s, i)) && (re(e, t, o, s, i) || ie(e, t, o, s, i))) return !0;
608
+ }
609
+ }
610
+ return !1;
611
+ }
612
+ e(ae, "segmentConflictsWithAnyEdge");
613
+ function V(e, t, n, r, i = h) {
614
+ let a = b(e, t, i), o = y(e, t, i), s = b(n, r, i), c = y(n, r, i);
615
+ if (!(a && c || o && s)) return !1;
616
+ let l = a ? {
617
+ a: e,
618
+ b: t
619
+ } : {
620
+ a: n,
621
+ b: r
622
+ }, u = a ? {
623
+ a: n,
624
+ b: r
625
+ } : {
626
+ a: e,
627
+ b: t
628
+ }, d = l.a.y, f = Math.min(l.a.x, l.b.x), p = Math.max(l.a.x, l.b.x), m = u.a.x, g = Math.min(u.a.y, u.b.y), _ = Math.max(u.a.y, u.b.y);
629
+ return m > f + i && m < p - i && d > g + i && d < _ - i;
630
+ }
631
+ e(V, "orthogonalSegmentsStrictlyCross");
632
+ function oe(e, t, n) {
633
+ let r = Math.min(t, n), i = Math.max(t, n);
634
+ return e > r + h && e < i - h;
635
+ }
636
+ e(oe, "strictlyBetween");
637
+ function H(e, t, n) {
638
+ return y(e, t) && y(t, n) ? oe(t.y, e.y, n.y) : b(e, t) && b(t, n) ? oe(t.x, e.x, n.x) : !1;
639
+ }
640
+ e(H, "isCollinearIntermediate");
641
+ function U(e) {
642
+ let t = !1, n = [];
643
+ for (let r = 0; r < e.length; r++) {
644
+ let i = n[n.length - 1], a = e[r], o = r + 1 < e.length ? e[r + 1] : void 0;
645
+ if (i && o) {
646
+ if (v(i, o)) {
647
+ r++, t = !0;
648
+ continue;
649
+ }
650
+ if (H(i, a, o)) {
651
+ t = !0;
652
+ continue;
653
+ }
654
+ }
655
+ n.push(a);
656
+ }
657
+ return {
658
+ points: n,
659
+ changed: t
660
+ };
661
+ }
662
+ e(U, "simplifyPolylineOnce");
663
+ function W(e) {
664
+ let t = [e[0]];
665
+ for (let n = 1; n < e.length; n++) {
666
+ let r = t[t.length - 1], i = e[n];
667
+ if (!y(r, i) && !b(r, i)) {
668
+ let e = t.length >= 2 ? t[t.length - 2] : void 0, n = e && y(e, r) ? {
669
+ x: r.x,
670
+ y: i.y
671
+ } : {
672
+ x: i.x,
673
+ y: r.y
674
+ };
675
+ t.push(n);
676
+ }
677
+ t.push(i);
678
+ }
679
+ let n = [];
680
+ for (let e of t) {
681
+ let t = n[n.length - 1];
682
+ (!t || !v(t, e)) && n.push(e);
683
+ }
684
+ return n;
685
+ }
686
+ e(W, "orthogonalizePolyline");
687
+ function G(e) {
688
+ if (e.length < 3) return e;
689
+ let t = [...e];
690
+ for (let e = 0; e < 32; e++) {
691
+ let e = U(t);
692
+ if (t = e.points, !e.changed) break;
693
+ }
694
+ return t;
695
+ }
696
+ e(G, "simplifyPolyline");
697
+ var K = .001, se = .5, ce = 4;
698
+ function le(e, t, n) {
699
+ let r = e;
700
+ if (r.isLayoutOnly || !r.points || r.points.length < n) return;
701
+ let i = r.start ? t.get(r.start) : void 0, a = r.end ? t.get(r.end) : void 0;
702
+ return {
703
+ edge: r,
704
+ points: r.points,
705
+ srcRect: i ? F(i) : void 0,
706
+ dstRect: a ? F(a) : void 0
707
+ };
708
+ }
709
+ e(le, "endpointContextFor");
710
+ function ue(e, t, n) {
711
+ if (b(e, t, K)) return {
712
+ x: e.x < n.left ? n.left : n.right,
713
+ y: e.y
714
+ };
715
+ if (y(e, t, K)) {
716
+ let t = e.y < n.top ? n.top : n.bottom;
717
+ return {
718
+ x: e.x,
719
+ y: t
720
+ };
721
+ }
722
+ return {
723
+ x: Math.min(n.right, Math.max(n.left, e.x)),
724
+ y: Math.min(n.bottom, Math.max(n.top, e.y))
725
+ };
726
+ }
727
+ e(ue, "segmentEnterPoint");
728
+ function de(e, t, n) {
729
+ let r = n ? 1 : -1, i = n ? 0 : e.length - 1;
730
+ for (; i >= 0 && i < e.length && A(e[i], t, se);) i += r;
731
+ if (i < 0 || i >= e.length) return e;
732
+ let a = i - r;
733
+ if (a < 0 || a >= e.length) return e;
734
+ let o = ue(e[i], e[a], t);
735
+ return n ? [o, ...e.slice(i)] : [...e.slice(0, i + 1), o];
736
+ }
737
+ e(de, "clipEndpoint");
738
+ function q(e, t) {
739
+ for (let n of e) {
740
+ let e = le(n, t, 2);
741
+ if (!e) continue;
742
+ let r = [...e.points];
743
+ e.srcRect && (r = de(r, e.srcRect, !0)), e.dstRect && (r = de(r, e.dstRect, !1)), r = G(W(r)), r = xe(r, e.srcRect, e.dstRect), e.edge.points = G(W(r));
744
+ }
745
+ }
746
+ e(q, "clipEdgeEndpointsToNodeBoundaries");
747
+ function J(e, t, n, r = !1) {
748
+ if (b(e, t, K)) {
749
+ if (t.y < n.top - K || t.y > n.bottom + K) return t;
750
+ if (r) {
751
+ if (e.x < n.left - K) return {
752
+ x: n.left,
753
+ y: e.y
754
+ };
755
+ if (e.x > n.right + K) return {
756
+ x: n.right,
757
+ y: e.y
758
+ };
759
+ }
760
+ return {
761
+ x: Math.abs(t.x - n.left) <= Math.abs(t.x - n.right) ? n.left : n.right,
762
+ y: e.y
763
+ };
764
+ }
765
+ if (y(e, t, K)) {
766
+ if (t.x < n.left - K || t.x > n.right + K) return t;
767
+ if (r) {
768
+ if (e.y < n.top - K) return {
769
+ x: e.x,
770
+ y: n.top
771
+ };
772
+ if (e.y > n.bottom + K) return {
773
+ x: e.x,
774
+ y: n.bottom
775
+ };
776
+ }
777
+ let i = Math.abs(t.y - n.top) <= Math.abs(t.y - n.bottom);
778
+ return {
779
+ x: e.x,
780
+ y: i ? n.top : n.bottom
781
+ };
782
+ }
783
+ return t;
784
+ }
785
+ e(J, "snapEndpointToBoundary");
786
+ function fe(e, t, n) {
787
+ let r = e[t];
788
+ for (let i = t + n; i >= 0 && i < e.length; i += n) {
789
+ let t = e[i];
790
+ if (!v(t, r, K)) return t;
791
+ }
792
+ return e[t + n];
793
+ }
794
+ e(fe, "firstDistinctAdjacent");
795
+ function pe(e, t) {
796
+ let n = e + ce, r = t - ce;
797
+ return n <= r ? {
798
+ lo: n,
799
+ hi: r
800
+ } : {
801
+ lo: (e + t) / 2,
802
+ hi: (e + t) / 2
803
+ };
804
+ }
805
+ e(pe, "cornerClearanceRange");
806
+ function me(e, t, n) {
807
+ let { lo: r, hi: i } = pe(t, n);
808
+ return Math.min(i, Math.max(r, e));
809
+ }
810
+ e(me, "clampToCornerClearance");
811
+ function he(e) {
812
+ let t = Math.max(...e.map((e) => e.lo)), n = Math.min(...e.map((e) => e.hi));
813
+ if (!(t > n)) return {
814
+ lo: t,
815
+ hi: n
816
+ };
817
+ }
818
+ e(he, "intersectRanges");
819
+ function ge(e, t) {
820
+ return t === "left" || t === "right" ? pe(e.top, e.bottom) : pe(e.left, e.right);
821
+ }
822
+ e(ge, "clearanceRangeForSide");
823
+ function _e(e, t, n) {
824
+ let r = e.y >= n.top - K && e.y <= n.bottom + K, i = e.x >= n.left - K && e.x <= n.right + K;
825
+ if (b(e, t, K) && r) {
826
+ if (Math.abs(e.x - n.left) < K) return "left";
827
+ if (Math.abs(e.x - n.right) < K) return "right";
828
+ }
829
+ if (y(e, t, K) && i) {
830
+ if (Math.abs(e.y - n.top) < K) return "top";
831
+ if (Math.abs(e.y - n.bottom) < K) return "bottom";
832
+ }
833
+ }
834
+ e(_e, "terminalSideForSegment");
835
+ function ve(e) {
836
+ return e === "left" || e === "right";
837
+ }
838
+ e(ve, "isHorizontalSide");
839
+ function ye(e, t, n, r, i) {
840
+ let a = [], o = n ? _e(e, t, n) : void 0, s = r ? _e(t, e, r) : void 0;
841
+ return n && o && ve(o) === i && a.push(ge(n, o)), r && s && ve(s) === i && a.push(ge(r, s)), a.length > 0 ? he(a) : void 0;
842
+ }
843
+ e(ye, "straightClearanceRange");
844
+ function be(e, t, n, r, i) {
845
+ let a = ye(e, t, n, r, i);
846
+ if (!a) return;
847
+ let o = i ? e.y : e.x, s = Math.min(a.hi, Math.max(a.lo, o));
848
+ if (!(Math.abs(s - o) < K)) return i ? [{
849
+ x: e.x,
850
+ y: s
851
+ }, {
852
+ x: t.x,
853
+ y: s
854
+ }] : [{
855
+ x: s,
856
+ y: e.y
857
+ }, {
858
+ x: s,
859
+ y: t.y
860
+ }];
861
+ }
862
+ e(be, "clearStraightEndpointCornerAxis");
863
+ function xe(e, t, n) {
864
+ if (e.length !== 2) return e;
865
+ let [r, i] = e;
866
+ return b(r, i, K) ? be(r, i, t, n, !0) ?? e : y(r, i, K) ? be(r, i, t, n, !1) ?? e : e;
867
+ }
868
+ e(xe, "clearStraightEndpointCornerConnections");
869
+ function Se(e, t, n) {
870
+ return ve(n) ? {
871
+ x: e.x,
872
+ y: me(e.y, t.top, t.bottom)
873
+ } : {
874
+ x: me(e.x, t.left, t.right),
875
+ y: e.y
876
+ };
877
+ }
878
+ e(Se, "cornerClearedEndpoint");
879
+ function Ce(e, t, n, r, i, a) {
880
+ let o = e.map((e) => ({ ...e }));
881
+ for (let s = t; s >= 0 && s < e.length; s += n) {
882
+ let t = e[s];
883
+ if (a && !b(t, r, K) || !a && !y(t, r, K)) break;
884
+ a ? o[s].y = i.y : o[s].x = i.x;
885
+ }
886
+ return o;
887
+ }
888
+ e(Ce, "moveCollinearEndpointRun");
889
+ function we(e, t, n) {
890
+ if (e.length < 2) return e;
891
+ let r = n ? 0 : e.length - 1, i = n ? 1 : -1, a = e[r], o = fe(e, r, i);
892
+ if (!o) return e;
893
+ let s = _e(a, o, t);
894
+ if (!s) return e;
895
+ let c = ve(s), l = Se(a, t, s);
896
+ return v(a, l, K) ? e : Ce(e, r, i, a, l, c);
897
+ }
898
+ e(we, "clearEndpointCornerConnection");
899
+ function Te(e, t, n) {
900
+ let r = Math.min(e.x, t.x) >= n.left - K && Math.max(e.x, t.x) <= n.right + K, i = Math.min(e.y, t.y) >= n.top - K && Math.max(e.y, t.y) <= n.bottom + K;
901
+ if (Math.abs(e.y - n.top) < K && Math.abs(t.y - n.top) < K && r) return "top";
902
+ if (Math.abs(e.y - n.bottom) < K && Math.abs(t.y - n.bottom) < K && r) return "bottom";
903
+ if (Math.abs(e.x - n.left) < K && Math.abs(t.x - n.left) < K && i) return "left";
904
+ if (Math.abs(e.x - n.right) < K && Math.abs(t.x - n.right) < K && i) return "right";
905
+ }
906
+ e(Te, "borderSideForSegment");
907
+ function Ee(e, t, n, r) {
908
+ switch (e) {
909
+ case "top": return y(t, n, K) && n.y < r.top - K;
910
+ case "bottom": return y(t, n, K) && n.y > r.bottom + K;
911
+ case "left": return b(t, n, K) && n.x < r.left - K;
912
+ case "right": return b(t, n, K) && n.x > r.right + K;
913
+ }
914
+ }
915
+ e(Ee, "leavesOutward");
916
+ function De(e, t, n) {
917
+ if (e.length < 3) return e;
918
+ if (n) {
919
+ let n = Te(e[0], e[1], t);
920
+ return n && Ee(n, e[1], e[2], t) ? e.slice(1) : e;
921
+ }
922
+ let r = e.length - 1, i = Te(e[r - 1], e[r], t);
923
+ return i && Ee(i, e[r - 1], e[r - 2], t) ? e.slice(0, r) : e;
924
+ }
925
+ e(De, "collapseOwnBorderStub");
926
+ function Oe(e, t, n) {
927
+ let r = e;
928
+ if (t) {
929
+ let e = fe(r, 0, 1);
930
+ if (e) {
931
+ let n = J(e, r[0], t);
932
+ n !== r[0] && (r = [n, ...r.slice(1)]);
933
+ }
934
+ r = De(r, t, !0);
935
+ }
936
+ if (n) {
937
+ let e = r.length - 1, t = fe(r, e, -1);
938
+ if (t) {
939
+ let i = J(t, r[e], n, !0);
940
+ i !== r[e] && (r = [...r.slice(0, e), i]);
941
+ }
942
+ r = De(r, n, !1);
943
+ }
944
+ let i = xe(r, t, n);
945
+ return i !== r || r.length === 2 ? i : (t && (r = we(r, t, !0)), n && (r = we(r, n, !1)), r);
946
+ }
947
+ e(Oe, "snapAndCollapseEndpoints");
948
+ function ke(e, t) {
949
+ for (let n of e) {
950
+ let e = le(n, t, 2);
951
+ if (!e) continue;
952
+ let r = Oe(D(e.points, K), e.srcRect, e.dstRect);
953
+ if (r.length < 3) {
954
+ e.edge.points = r;
955
+ continue;
956
+ }
957
+ let i = [
958
+ r[0],
959
+ { ...r[0] },
960
+ ...r.slice(1, -1),
961
+ r[r.length - 1],
962
+ { ...r[r.length - 1] }
963
+ ];
964
+ e.edge.points = i;
965
+ }
966
+ }
967
+ e(ke, "prepareEdgeEndpointsForRenderer");
968
+ function Ae(e) {
969
+ return new Map(e.map((e) => [e.id, e]));
970
+ }
971
+ e(Ae, "buildNodeMap");
972
+ function je(e, t) {
973
+ let n = e.parentId, r = null;
974
+ for (; n;) {
975
+ let e = t.get(n);
976
+ if (!e?.isGroup) break;
977
+ r = e.id, n = e.parentId;
978
+ }
979
+ return r;
980
+ }
981
+ e(je, "resolveTopLevelGroupId");
982
+ function Me(e, t) {
983
+ let n = 0, r = e.parentId;
984
+ for (; r;) {
985
+ let e = t.get(r);
986
+ if (!e?.isGroup) break;
987
+ n++, r = e.parentId;
988
+ }
989
+ return n;
990
+ }
991
+ e(Me, "groupDepth");
992
+ function Ne(e) {
993
+ let t = Infinity, n = -Infinity, r = Infinity, i = -Infinity;
994
+ for (let a of e) {
995
+ let e = a.x, o = a.y;
996
+ if (typeof e != "number" || typeof o != "number") continue;
997
+ let s = a.width ?? 0, c = a.height ?? 0;
998
+ t = Math.min(t, e - s / 2), n = Math.max(n, e + s / 2), r = Math.min(r, o - c / 2), i = Math.max(i, o + c / 2);
999
+ }
1000
+ return t === Infinity || r === Infinity ? null : {
1001
+ minX: t,
1002
+ maxX: n,
1003
+ minY: r,
1004
+ maxY: i
1005
+ };
1006
+ }
1007
+ e(Ne, "boundsForChildren");
1008
+ function Pe(e, t) {
1009
+ let n = e.padding ?? 20;
1010
+ e.x = (t.minX + t.maxX) / 2, e.y = (t.minY + t.maxY) / 2, e.width = Math.max(0, t.maxX - t.minX) + n, e.height = Math.max(0, t.maxY - t.minY) + n;
1011
+ }
1012
+ e(Pe, "applyGroupBounds");
1013
+ function Fe(e) {
1014
+ let t = Ae(e), n = e.filter((e) => e.isGroup && e.parentId).sort((e, n) => Me(n, t) - Me(e, t));
1015
+ for (let t of n) {
1016
+ let n = Ne(e.filter((e) => e.parentId === t.id));
1017
+ n && Pe(t, n);
1018
+ }
1019
+ }
1020
+ e(Fe, "recomputeNestedGroupBounds");
1021
+ function Ie(t, n) {
1022
+ let r = t.nodes ?? [], i = t.edges ?? [], a = r.filter((e) => !e.isGroup), o = Infinity, s = -Infinity;
1023
+ for (let e of a) {
1024
+ let t = e[n];
1025
+ typeof t == "number" && (o = Math.min(o, t), s = Math.max(s, t));
1026
+ }
1027
+ if (!Number.isFinite(o) || !Number.isFinite(s)) return !1;
1028
+ let c = /* @__PURE__ */ e((e) => o + s - e, "mirror");
1029
+ for (let e of r) {
1030
+ let t = e[n];
1031
+ typeof t == "number" && (e[n] = c(t));
1032
+ let r = e.groupTitleRect;
1033
+ r && (e.groupTitleRect = n === "x" ? {
1034
+ ...r,
1035
+ left: c(r.right),
1036
+ right: c(r.left)
1037
+ } : {
1038
+ ...r,
1039
+ top: c(r.bottom),
1040
+ bottom: c(r.top)
1041
+ });
1042
+ }
1043
+ for (let e of i) for (let t of e.points ?? []) t[n] = c(t[n]);
1044
+ return !0;
1045
+ }
1046
+ e(Ie, "mirrorAxis");
1047
+ function Le(e) {
1048
+ return !(e.nodes ?? []).some((e) => !e.isGroup) || Ie(e, "y");
1049
+ }
1050
+ e(Le, "applyBtDirectionTransform");
1051
+ function Re(e, t = "LR") {
1052
+ let n = e.nodes ?? [], r = e.edges ?? [], i = n.filter((e) => !e.isGroup), a = Infinity, o = Infinity;
1053
+ for (let e of i) {
1054
+ let t = e.x ?? 0, n = e.y ?? 0;
1055
+ t < a && (a = t), n < o && (o = n);
1056
+ }
1057
+ if (!Number.isFinite(a) || !Number.isFinite(o)) return !1;
1058
+ let s = 0, c = 0;
1059
+ for (let e of i) s += e.width ?? 0, c += e.height ?? 0;
1060
+ let l = s / i.length, u = c / i.length, d = u > 0 ? Math.max(1, l / u) : 1;
1061
+ for (let e of i) {
1062
+ let t = e.x ?? 0, n = ((e.y ?? 0) - o) * d + 36, r = t - a;
1063
+ e.x = n, e.y = r;
1064
+ }
1065
+ for (let e of r) if (e.points) for (let t of e.points) {
1066
+ let e = t.x, n = (t.y - o) * d + 36, r = e - a;
1067
+ t.x = n, t.y = r;
1068
+ }
1069
+ Fe(n);
1070
+ let f = n.filter((e) => e.isGroup && !e.parentId);
1071
+ if (f.length === 0) return t === "RL" && Ie(e, "x"), !0;
1072
+ let p = Ae(n), m = /* @__PURE__ */ new Map();
1073
+ for (let e of n) {
1074
+ if (e.isGroup) continue;
1075
+ let t = je(e, p);
1076
+ if (!t) continue;
1077
+ let n = m.get(t) ?? [];
1078
+ n.push(e), m.set(t, n);
1079
+ }
1080
+ let h = 0;
1081
+ for (let e of f) {
1082
+ let t = e.padding ?? 0;
1083
+ t > h && (h = t);
1084
+ }
1085
+ let g = [], _ = Infinity, v = -Infinity;
1086
+ for (let e of f) {
1087
+ let t = Ne(m.get(e.id) ?? []);
1088
+ t && (_ = Math.min(_, t.minX), v = Math.max(v, t.maxX), g.push({
1089
+ lane: e,
1090
+ contentTop: t.minY,
1091
+ contentBottom: t.maxY,
1092
+ centerY: (t.minY + t.maxY) / 2
1093
+ }));
1094
+ }
1095
+ if (_ === Infinity || v === -Infinity) return !0;
1096
+ let y = Math.max(0, v - _) + 2 * Math.max(h, 10), b = 36 + y, x = (_ + v) / 2 - y / 2 - 36, S = x + b / 2, C = Math.max(h, 36);
1097
+ g.sort((e, t) => e.centerY - t.centerY);
1098
+ for (let e = 0; e < g.length; e++) {
1099
+ let t = g[e], n, r;
1100
+ if (n = e === 0 ? t.contentTop - C : (g[e - 1].contentBottom + t.contentTop) / 2, e === g.length - 1) r = t.contentBottom + C;
1101
+ else {
1102
+ let n = g[e + 1];
1103
+ r = (t.contentBottom + n.contentTop) / 2;
1104
+ }
1105
+ let i = Math.max(0, r - n), a = (n + r) / 2;
1106
+ t.lane.x = S, t.lane.y = a, t.lane.width = b, t.lane.height = i, t.lane.swimlaneContentTop = t.contentTop, t.lane.groupTitleRect = {
1107
+ left: x,
1108
+ right: x + 36,
1109
+ top: n,
1110
+ bottom: r
1111
+ };
1112
+ }
1113
+ return t === "RL" && Ie(e, "x"), !0;
1114
+ }
1115
+ e(Re, "applyLrDirectionTransform");
1116
+ var ze = 1e-6, Be = 8, Ve = [
1117
+ 0,
1118
+ Be,
1119
+ -Be,
1120
+ 2 * Be,
1121
+ -2 * Be
1122
+ ];
1123
+ function He(e, t) {
1124
+ let { nodeInfoById: n, realNodeRects: r } = R(t);
1125
+ for (let t of e) {
1126
+ if (t.isLayoutOnly) continue;
1127
+ let i = t.points;
1128
+ if (!i || i.length < 4) continue;
1129
+ let a = O(D(i, ze), ze);
1130
+ if (!a) continue;
1131
+ let { p3: o } = a, s = a.kind === "HVH", c = ne(t, n, ze);
1132
+ if (!c) continue;
1133
+ let { srcId: l, dstId: u, srcInfo: d, dstInfo: f, collinearX: p, collinearY: m } = c;
1134
+ if (p || m) continue;
1135
+ let h, g = d.rect;
1136
+ for (let n of Ve) {
1137
+ let i, a, c;
1138
+ if (s) {
1139
+ let e = f.cy > d.cy ? g.bottom : g.top, t = d.cx + n;
1140
+ if (t <= g.left + ze || t >= g.right - ze) continue;
1141
+ i = {
1142
+ x: t,
1143
+ y: e
1144
+ }, a = {
1145
+ x: t,
1146
+ y: o.y
1147
+ }, c = {
1148
+ x: o.x,
1149
+ y: o.y
1150
+ };
1151
+ } else {
1152
+ let e = f.cx > d.cx ? g.right : g.left, t = d.cy + n;
1153
+ if (t <= g.top + ze || t >= g.bottom - ze) continue;
1154
+ i = {
1155
+ x: e,
1156
+ y: t
1157
+ }, a = {
1158
+ x: o.x,
1159
+ y: t
1160
+ }, c = {
1161
+ x: o.x,
1162
+ y: o.y
1163
+ };
1164
+ }
1165
+ let p = v(i, a, ze), m = v(a, c, ze);
1166
+ if (p && m || !p && B(i, a, r, [l], 1) || !m && B(a, c, r, [u], 1)) continue;
1167
+ let _ = !p && ae(i, a, e, t, {
1168
+ epsilon: ze,
1169
+ skipDegenerateOther: !0
1170
+ }), y = !m && ae(a, c, e, t, {
1171
+ epsilon: ze,
1172
+ skipDegenerateOther: !0
1173
+ });
1174
+ if (!(_ || y)) {
1175
+ h = p ? [a, c] : m ? [i, a] : [
1176
+ i,
1177
+ a,
1178
+ c
1179
+ ];
1180
+ break;
1181
+ }
1182
+ }
1183
+ h && (t.points = h);
1184
+ }
1185
+ }
1186
+ e(He, "portSwapToLShape");
1187
+ function Ue(t, n) {
1188
+ let r = .001, { realNodeRects: i, labelNodeRects: a } = z(n.values());
1189
+ for (let o of t) {
1190
+ if (o.isLayoutOnly) continue;
1191
+ let s = o.points;
1192
+ if (!s || s.length < 4) continue;
1193
+ let c = D(s, r);
1194
+ if (c.length < 4) continue;
1195
+ let l = c.length - 1, u = c[l], d = c[l - 1], f = c[l - 2], p = u.x - d.x, m = u.y - d.y, h = Math.hypot(p, m);
1196
+ if (h >= 10 || h < r) continue;
1197
+ let g = d.x - f.x, _ = d.y - f.y;
1198
+ if (Math.hypot(g, _) < r) continue;
1199
+ let v = x(d, u, r), C = S(d, u, r), w = x(f, d, r), T = S(f, d, r);
1200
+ if (!(v && T || C && w)) continue;
1201
+ let E = o.end, O = o.start, k = E ? n.get(E) : void 0;
1202
+ if (!k) continue;
1203
+ let j = k.x ?? 0, M = k.y ?? 0, N = F(k);
1204
+ if (!N) continue;
1205
+ let P, I;
1206
+ if (T) {
1207
+ let e = _ < 0;
1208
+ P = {
1209
+ x: j,
1210
+ y: f.y
1211
+ }, I = {
1212
+ x: j,
1213
+ y: e ? N.bottom : N.top
1214
+ };
1215
+ } else {
1216
+ let e = g > 0;
1217
+ P = {
1218
+ x: f.x,
1219
+ y: M
1220
+ }, I = {
1221
+ x: e ? N.right : N.left,
1222
+ y: M
1223
+ };
1224
+ }
1225
+ if (B(P, I, i, E ? [E] : [], -2) || B(P, I, a, [], -2)) continue;
1226
+ if (O) {
1227
+ let e = n.get(O), t = e ? F(e) : void 0;
1228
+ if (t && A(P, t, 2)) continue;
1229
+ }
1230
+ let ee = /* @__PURE__ */ e((e, t) => `${e.x.toFixed(3)},${e.y.toFixed(3)}|${t.x.toFixed(3)},${t.y.toFixed(3)}`, "ownSegmentKey"), L = /* @__PURE__ */ new Set();
1231
+ for (let e = 0; e < c.length - 1; e++) L.add(ee(c[e], c[e + 1]));
1232
+ let R = /* @__PURE__ */ e((e, n) => {
1233
+ for (let i of t) {
1234
+ if (i === o || i.isLayoutOnly) continue;
1235
+ let t = i.points;
1236
+ if (!(!t || t.length < 2)) for (let i = 0; i < t.length - 1; i++) {
1237
+ let a = t[i], o = t[i + 1];
1238
+ if (!L.has(ee(a, o)) && V(e, n, a, o, r)) return !0;
1239
+ }
1240
+ }
1241
+ return !1;
1242
+ }, "segmentCrossesOtherEdge");
1243
+ if (R(P, I)) continue;
1244
+ if (l - 3 >= 0) {
1245
+ let e = c[l - 3], t = [O, E].filter((e) => !!e);
1246
+ if (B(e, P, i, t, -2) || R(e, P)) continue;
1247
+ }
1248
+ let z = [
1249
+ ...c.slice(0, l - 2),
1250
+ P,
1251
+ I
1252
+ ];
1253
+ o.points = z;
1254
+ let te = o.labelNodeId;
1255
+ if (te) {
1256
+ let e = n.get(te);
1257
+ if (e) {
1258
+ let t = e.width ?? 0, n = e.height ?? 0;
1259
+ if (t > 0 && n > 0) {
1260
+ let i, a, o = -1;
1261
+ for (let e = 0; e < z.length - 1; e++) {
1262
+ let s = z[e], c = z[e + 1], l = Math.hypot(c.x - s.x, c.y - s.y), u = b(s, c, r), d = y(s, c, r);
1263
+ (u && l >= t + 2 || d && l >= n + 2) && l > o && (o = l, i = (s.x + c.x) / 2, a = (s.y + c.y) / 2);
1264
+ }
1265
+ i !== void 0 && a !== void 0 && (e.x = i, e.y = a);
1266
+ }
1267
+ }
1268
+ }
1269
+ }
1270
+ }
1271
+ e(Ue, "collapseShortTerminalStub");
1272
+ var Y = .001, X = 8, Z = T, We = /* @__PURE__ */ e((e, t) => y(e, t, Y) || b(e, t, Y), "orthogonallyAligned");
1273
+ function Ge(t, n) {
1274
+ let r = /* @__PURE__ */ e((e, t) => {
1275
+ let n = e.x ?? 0, r = e.y ?? 0, i = t.x - n, a = t.y - r, o = (e.width ?? 0) / 2, s = (e.height ?? 0) / 2;
1276
+ return Math.abs(a) * o > Math.abs(i) * s ? (a < 0 && (s = -s), {
1277
+ x: n + (a === 0 ? 0 : s * i / a),
1278
+ y: r + s
1279
+ }) : (i < 0 && (o = -o), {
1280
+ x: n + o,
1281
+ y: r + (i === 0 ? 0 : o * a / i)
1282
+ });
1283
+ }, "rectIntersect"), i = /* @__PURE__ */ e((e, t) => {
1284
+ let i = D(e.points ?? []);
1285
+ if (i.length < 2) return;
1286
+ let a = t ? e.start : e.end, o = a ? n.get(a) : void 0, s = o ? F(o) : void 0;
1287
+ if (!o || !a || !s) return;
1288
+ let c = t ? i[0] : i[i.length - 1], l = t ? i[1] : i[i.length - 2], u = r(o, c), d = c;
1289
+ if (We(l, u) && (d = l), y(u, d, Y)) return {
1290
+ edge: e,
1291
+ edgeId: String(e.id ?? ""),
1292
+ nodeId: a,
1293
+ atStart: t,
1294
+ orientation: "V",
1295
+ coord: u.x,
1296
+ min: Math.min(u.y, d.y),
1297
+ max: Math.max(u.y, d.y),
1298
+ boundary: u,
1299
+ railEnd: d,
1300
+ rect: s
1301
+ };
1302
+ if (b(u, d, Y)) return {
1303
+ edge: e,
1304
+ edgeId: String(e.id ?? ""),
1305
+ nodeId: a,
1306
+ atStart: t,
1307
+ orientation: "H",
1308
+ coord: u.y,
1309
+ min: Math.min(u.x, d.x),
1310
+ max: Math.max(u.x, d.x),
1311
+ boundary: u,
1312
+ railEnd: d,
1313
+ rect: s
1314
+ };
1315
+ }, "terminalLaneFor"), a = /* @__PURE__ */ e((e, t) => Math.max(0, Math.min(e.max, t.max) - Math.max(e.min, t.min)), "projectedOverlapLength"), o = /* @__PURE__ */ e((e, t) => e.nodeId !== t.nodeId || e.orientation !== t.orientation ? !1 : e.orientation === "H" ? (Math.abs(e.boundary.x - e.rect.left) < 1 || Math.abs(e.boundary.x - e.rect.right) < 1) && y(e.boundary, t.boundary, 1) : (Math.abs(e.boundary.y - e.rect.top) < 1 || Math.abs(e.boundary.y - e.rect.bottom) < 1) && b(e.boundary, t.boundary, 1), "sameTerminalFace"), s = /* @__PURE__ */ e((e, t) => e.nodeId !== t.nodeId || e.orientation !== t.orientation ? !1 : a(e, t) >= X && Math.abs(e.coord - t.coord) < .5, "exactTerminalLaneConflict"), c = /* @__PURE__ */ e((e, t) => {
1316
+ if (e.nodeId !== t.nodeId || e.orientation !== t.orientation || e.orientation !== "H" || e.atStart === t.atStart) return !1;
1317
+ let n = a(e, t);
1318
+ if (n < X) return !1;
1319
+ let r = e.rect.bottom - e.rect.top;
1320
+ return n < r || n > 2 * r ? !1 : o(e, t) && Math.abs(e.coord - t.coord) < 16;
1321
+ }, "nearTerminalLaneConflict"), l = /* @__PURE__ */ e((t, n) => {
1322
+ let r = D(t.edge.points ?? []);
1323
+ if (r.length < 2) return;
1324
+ let i = t.orientation === "V" ? {
1325
+ x: t.boundary.x + n,
1326
+ y: t.boundary.y
1327
+ } : {
1328
+ x: t.boundary.x,
1329
+ y: t.boundary.y + n
1330
+ }, a = t.orientation === "V" ? {
1331
+ x: t.railEnd.x + n,
1332
+ y: t.railEnd.y
1333
+ } : {
1334
+ x: t.railEnd.x,
1335
+ y: t.railEnd.y + n
1336
+ };
1337
+ if (!(/* @__PURE__ */ e(() => Math.abs(t.boundary.y - t.rect.top) < 1 || Math.abs(t.boundary.y - t.rect.bottom) < 1 ? b(i, t.boundary, Y) && i.x >= t.rect.left + 1 && i.x <= t.rect.right - 1 : Math.abs(t.boundary.x - t.rect.left) < 1 || Math.abs(t.boundary.x - t.rect.right) < 1 ? y(i, t.boundary, Y) && i.y >= t.rect.top + 1 && i.y <= t.rect.bottom - 1 : !1, "boundaryStaysOnSameFace"))()) return;
1338
+ if (t.atStart) {
1339
+ let e = r.length > 1 && v(r[1], t.railEnd, Y), n = r.slice(e ? 2 : 1), o = n[0];
1340
+ return o && !We(o, a) ? void 0 : [
1341
+ i,
1342
+ a,
1343
+ ...n
1344
+ ];
1345
+ }
1346
+ let o = r.length > 1 && v(r[r.length - 2], t.railEnd, Y), s = r.slice(0, o ? -2 : -1), c = s[s.length - 1];
1347
+ if (!(c && !We(c, a))) return [
1348
+ ...s,
1349
+ a,
1350
+ i
1351
+ ];
1352
+ }, "shiftedCandidate"), u = /* @__PURE__ */ e((e) => {
1353
+ let t = e.edge, r = D(t.points ?? []);
1354
+ if (r.length !== 2) return !1;
1355
+ let i = t.start, a = t.end, o = i ? n.get(i) : void 0, s = a ? n.get(a) : void 0;
1356
+ if (!o || !s) return !1;
1357
+ let c = o.x ?? 0, l = o.y ?? 0, u = s.x ?? 0, d = s.y ?? 0, [f, p] = r;
1358
+ return b(f, p, Y) && Math.abs(l - d) < 1 && Math.abs(c - u) > 1 || y(f, p, Y) && Math.abs(c - u) < 1 && Math.abs(l - d) > 1;
1359
+ }, "laneIsStraightCollinearConnector"), d = [
1360
+ -7,
1361
+ 7,
1362
+ -14,
1363
+ 14,
1364
+ -21,
1365
+ 21
1366
+ ];
1367
+ for (let e = 0; e < 8; e++) {
1368
+ let e = t.filter((e) => !e.isLayoutOnly).flatMap((e) => [i(e, !0), i(e, !1)]).filter((e) => !!e), n = !1;
1369
+ for (let t = 0; t < e.length && !n; t++) for (let r = t + 1; r < e.length && !n; r++) {
1370
+ let a = e[t], o = e[r];
1371
+ if (a.edge === o.edge || !(s(a, o) || c(a, o))) continue;
1372
+ let f = !s(a, o), p = [a, o].sort((e, t) => {
1373
+ let n = u(e), r = u(t);
1374
+ return n === r ? Number(!t.atStart) - Number(!e.atStart) : Number(n) - Number(r);
1375
+ });
1376
+ for (let t of p) {
1377
+ for (let r of d) {
1378
+ let a = l(t, r);
1379
+ if (!a) continue;
1380
+ let o = i({
1381
+ ...t.edge,
1382
+ points: a
1383
+ }, t.atStart);
1384
+ if (!(!o || e.some((e) => e.edge !== t.edge && (s(o, e) || f && c(o, e))))) {
1385
+ t.edge.points = a, n = !0;
1386
+ break;
1387
+ }
1388
+ }
1389
+ if (n) break;
1390
+ }
1391
+ }
1392
+ if (!n) return;
1393
+ }
1394
+ }
1395
+ e(Ge, "separateSharedRenderedTerminalLanes");
1396
+ function Ke(t, n) {
1397
+ let { realNodeRects: r, labelNodeRects: i } = z(n.values()), a = /* @__PURE__ */ e((e, n) => {
1398
+ let a = e.start, o = e.end, s = Z(n);
1399
+ if (s.length !== n.length - 1) return !1;
1400
+ let c = [a, o].filter((e) => !!e);
1401
+ for (let e of s) if (B(e.a, e.b, r, c, -2) || B(e.a, e.b, i, [], -2)) return !1;
1402
+ for (let n of t) {
1403
+ if (n === e || n.isLayoutOnly) continue;
1404
+ let t = n.points;
1405
+ if (!(!t || t.length < 2)) {
1406
+ for (let e of s) for (let n of Z(D(t))) if (w(e, n, .5) >= X || V(e.a, e.b, n.a, n.b, Y)) return !1;
1407
+ }
1408
+ }
1409
+ return !0;
1410
+ }, "candidateIsSafe"), o = /* @__PURE__ */ e((e, t) => {
1411
+ if (t + 4 >= e.length) return;
1412
+ let n = e[t], r = e[t + 1], i = e[t + 2], a = e[t + 3], o = e[t + 4], s = x(n, r) && S(r, i) && x(i, a) && S(a, o) && y(n, a, Y) && y(n, o, Y) && y(r, i, Y) && (r.x - n.x) * (a.x - i.x) < 0, c = S(n, r) && x(r, i) && S(i, a) && x(a, o) && b(n, a, Y) && b(n, o, Y) && b(r, i, Y) && (r.y - n.y) * (a.y - i.y) < 0;
1413
+ if (s || c) return D([
1414
+ ...e.slice(0, t + 1),
1415
+ o,
1416
+ ...e.slice(t + 5)
1417
+ ]);
1418
+ if (t + 5 >= e.length) return;
1419
+ let l = e[t + 5], u = S(n, r) && x(r, i) && S(i, a) && x(a, o) && S(o, l) && y(n, o, Y) && y(n, l, Y) && y(i, a, Y) && (i.x - r.x) * (o.x - a.x) < 0, d = x(n, r) && S(r, i) && x(i, a) && S(a, o) && x(o, l) && b(n, o, Y) && b(n, l, Y) && b(i, a, Y) && (i.y - r.y) * (o.y - a.y) < 0;
1420
+ if (!(!u && !d)) return D([
1421
+ ...e.slice(0, t + 1),
1422
+ l,
1423
+ ...e.slice(t + 6)
1424
+ ]);
1425
+ }, "withoutDogleg");
1426
+ for (let e = 0; e < 8; e++) {
1427
+ let e = !1;
1428
+ for (let n of t) {
1429
+ if (n.isLayoutOnly) continue;
1430
+ let t = D(n.points ?? []);
1431
+ for (let r = 0; r <= t.length - 5; r++) {
1432
+ let i = o(t, r);
1433
+ if (!(!i || !a(n, i))) {
1434
+ n.points = i, e = !0;
1435
+ break;
1436
+ }
1437
+ }
1438
+ if (e) break;
1439
+ }
1440
+ if (!e) return;
1441
+ }
1442
+ }
1443
+ e(Ke, "collapseRedundantRectangularDoglegs");
1444
+ function qe(t, n) {
1445
+ let { realNodeRects: r, labelNodeRects: i } = z(n.values()), a = t.filter((e) => !e.isLayoutOnly), o = /* @__PURE__ */ e((e, t, n) => D(e === t ? n ?? [] : e.points ?? []), "pointsFor"), s = /* @__PURE__ */ e((e, t) => {
1446
+ let n = 0;
1447
+ for (let r = 0; r < a.length; r++) {
1448
+ let i = Z(o(a[r], e, t));
1449
+ for (let s = r + 1; s < a.length; s++) {
1450
+ let r = Z(o(a[s], e, t));
1451
+ for (let e of i) for (let t of r) V(e.a, e.b, t.a, t.b, Y) && n++;
1452
+ }
1453
+ }
1454
+ return n;
1455
+ }, "strictCrossingCount"), c = /* @__PURE__ */ e((e) => {
1456
+ let t = Z(e);
1457
+ if (t.length !== 3) return;
1458
+ let n = t[1];
1459
+ if (!(t[0].horizontal === n.horizontal || t[2].horizontal === n.horizontal)) return {
1460
+ index: n.index,
1461
+ horizontal: n.horizontal,
1462
+ vertical: n.vertical,
1463
+ segment: n
1464
+ };
1465
+ }, "middleRail"), l = /* @__PURE__ */ e((e, t) => {
1466
+ let n = [e.start, e.end].filter((e) => !!e);
1467
+ return r.filter((e) => {
1468
+ if (n.includes(e.id)) return !1;
1469
+ let r = e.rect;
1470
+ return t.horizontal ? C(t.a.x, t.b.x, r.left, r.right) >= X && t.a.y >= r.top - 2 && t.a.y <= r.bottom + 2 : C(t.a.y, t.b.y, r.top, r.bottom) >= X && t.a.x >= r.left - 2 && t.a.x <= r.right + 2;
1471
+ });
1472
+ }, "blockingRectsFor"), u = /* @__PURE__ */ e((e, t, n) => {
1473
+ let r = e.map((e) => ({ ...e }));
1474
+ if (t.horizontal) r[t.index].y = n, r[t.index + 1].y = n;
1475
+ else if (t.vertical) r[t.index].x = n, r[t.index + 1].x = n;
1476
+ else return;
1477
+ let i = G(D(r));
1478
+ return Z(i).length === i.length - 1 ? i : void 0;
1479
+ }, "candidateByMovingRail"), d = /* @__PURE__ */ e((e, t, n) => {
1480
+ let c = [e.start, e.end].filter((e) => !!e), l = Z(t);
1481
+ if (l.length !== t.length - 1) return !1;
1482
+ for (let e of l) if (B(e.a, e.b, r, c, -2) || B(e.a, e.b, i, [], -2)) return !1;
1483
+ for (let t of a) if (t !== e) {
1484
+ for (let e of l) for (let n of Z(o(t))) if (w(e, n, .5) >= X) return !1;
1485
+ }
1486
+ return s(e, t) <= n;
1487
+ }, "candidateIsSafe");
1488
+ for (let e = 0; e < 8; e++) {
1489
+ let e = s(), t = !1;
1490
+ for (let n of a) {
1491
+ let r = o(n), i = c(r);
1492
+ if (!i) continue;
1493
+ let a = l(n, i.segment);
1494
+ if (a.length === 0) continue;
1495
+ let s = i.horizontal ? [Math.min(...a.map((e) => e.rect.top)) - 20, Math.max(...a.map((e) => e.rect.bottom)) + 20] : [Math.min(...a.map((e) => e.rect.left)) - 20, Math.max(...a.map((e) => e.rect.right)) + 20];
1496
+ for (let a of s) {
1497
+ let o = u(r, i.segment, a);
1498
+ if (!(!o || !d(n, o, e))) {
1499
+ n.points = o, t = !0;
1500
+ break;
1501
+ }
1502
+ }
1503
+ if (t) break;
1504
+ }
1505
+ if (!t) return;
1506
+ }
1507
+ }
1508
+ e(qe, "liftObstacleHuggingSameSideRails");
1509
+ function Je(t, n) {
1510
+ let r = /* @__PURE__ */ e((e) => {
1511
+ let t = e.groupTitleRect;
1512
+ if (!(!t || typeof t.left != "number" || typeof t.right != "number" || typeof t.top != "number" || typeof t.bottom != "number" || !Number.isFinite(t.left) || !Number.isFinite(t.right) || !Number.isFinite(t.top) || !Number.isFinite(t.bottom) || t.right <= t.left || t.bottom <= t.top)) return {
1513
+ left: t.left,
1514
+ right: t.right,
1515
+ top: t.top,
1516
+ bottom: t.bottom
1517
+ };
1518
+ }, "validTitleRect"), i = /* @__PURE__ */ e((e) => {
1519
+ if (!e.isGroup || e.parentId) return;
1520
+ let t = e.direction, n = typeof t == "string" ? t.toUpperCase() : "";
1521
+ if (n === "LR" || n === "RL" || n === "BT") return;
1522
+ let i = r(e), a = e.y, o = e.height;
1523
+ if (!i || typeof a != "number" || typeof o != "number" || !Number.isFinite(a) || !Number.isFinite(o) || o <= 0) return;
1524
+ let s = i.right - i.left, c = i.bottom - i.top;
1525
+ if (!(c <= 0 || s < c)) return {
1526
+ node: e,
1527
+ rect: i
1528
+ };
1529
+ }, "topLaneTitleFor"), a = /* @__PURE__ */ e((e, t) => {
1530
+ if (!e.horizontal) return !1;
1531
+ let n = e.a.y;
1532
+ return n <= t.top + Y || n >= t.bottom - Y ? !1 : C(e.a.x, e.b.x, t.left, t.right) >= X;
1533
+ }, "horizontalSegmentIntersectsTitle"), o = [...n.values()].map(i).filter((e) => !!e);
1534
+ if (o.length === 0) return;
1535
+ let s = 0;
1536
+ for (let e of t) {
1537
+ if (e.isLayoutOnly) continue;
1538
+ let t = D(e.points ?? []);
1539
+ for (let e of Z(t)) for (let t of o) a(e, t.rect) && (s = Math.max(s, t.rect.bottom - e.a.y + 4));
1540
+ }
1541
+ if (!(s <= Y)) for (let e of o) {
1542
+ let t = e.node.y, n = e.node.height;
1543
+ typeof t != "number" || typeof n != "number" || !Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || (e.node.y = t - s / 2, e.node.height = n + s, e.node.groupTitleRect = {
1544
+ ...e.rect,
1545
+ top: e.rect.top - s,
1546
+ bottom: e.rect.bottom - s
1547
+ });
1548
+ }
1549
+ }
1550
+ e(Je, "liftTopLaneTitleBandsAboveRails");
1551
+ function Ye(t, n) {
1552
+ let r = /* @__PURE__ */ e((e) => {
1553
+ let t = e.groupTitleRect;
1554
+ if (!(!t || typeof t.left != "number" || typeof t.right != "number" || typeof t.top != "number" || typeof t.bottom != "number" || !Number.isFinite(t.left) || !Number.isFinite(t.right) || !Number.isFinite(t.top) || !Number.isFinite(t.bottom) || t.right <= t.left || t.bottom <= t.top)) return {
1555
+ left: t.left,
1556
+ right: t.right,
1557
+ top: t.top,
1558
+ bottom: t.bottom
1559
+ };
1560
+ }, "validTitleRect"), i = /* @__PURE__ */ e((e) => {
1561
+ if (!e.isGroup || e.parentId || e.direction !== "LR") return;
1562
+ let t = r(e), n = e.x, i = e.width;
1563
+ if (!t || typeof n != "number" || typeof i != "number" || !Number.isFinite(n) || !Number.isFinite(i) || i <= 0) return;
1564
+ let a = t.right - t.left, o = t.bottom - t.top;
1565
+ if (!(a <= 0 || o < a)) return {
1566
+ node: e,
1567
+ rect: t
1568
+ };
1569
+ }, "leftLaneTitleFor"), a = /* @__PURE__ */ e((e, t) => {
1570
+ if (!e.vertical) return !1;
1571
+ let n = e.a.x;
1572
+ return n <= t.left + Y || n >= t.right - Y ? !1 : C(e.a.y, e.b.y, t.top, t.bottom) >= X;
1573
+ }, "verticalSegmentIntersectsTitle"), o = /* @__PURE__ */ e((e, t) => {
1574
+ if (!e.horizontal) return !1;
1575
+ let n = e.a.y;
1576
+ return n <= t.top + Y || n >= t.bottom - Y ? !1 : C(e.a.x, e.b.x, t.left, t.right) >= X;
1577
+ }, "horizontalSegmentIntersectsTitle"), s = [...n.values()].map(i).filter((e) => !!e);
1578
+ if (s.length === 0) return;
1579
+ let c = 0;
1580
+ for (let e of t) {
1581
+ if (e.isLayoutOnly) continue;
1582
+ let t = D(e.points ?? []);
1583
+ for (let e of Z(t)) for (let t of s) if (a(e, t.rect)) c = Math.max(c, t.rect.right - e.a.x + 4);
1584
+ else if (o(e, t.rect)) {
1585
+ let n = Math.min(e.a.x, e.b.x);
1586
+ c = Math.max(c, t.rect.right - n + 4);
1587
+ }
1588
+ }
1589
+ if (!(c <= Y)) for (let e of s) {
1590
+ let t = e.node.x, n = e.node.width;
1591
+ typeof t != "number" || typeof n != "number" || !Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || (e.node.x = t - c / 2, e.node.width = n + c, e.node.groupTitleRect = {
1592
+ ...e.rect,
1593
+ left: e.rect.left - c,
1594
+ right: e.rect.right - c
1595
+ });
1596
+ }
1597
+ }
1598
+ e(Ye, "shiftLeftLaneTitleBandsLeftOfRails");
1599
+ function Xe(t, n) {
1600
+ let { realNodeRects: r } = z(n.values()), i = t.filter((e) => !e.isLayoutOnly), a = /* @__PURE__ */ e((e, t = /* @__PURE__ */ new Map()) => D(t.get(e) ?? e.points ?? []), "replacementPointsFor"), o = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => {
1601
+ let t = 0;
1602
+ for (let n = 0; n < i.length; n++) {
1603
+ let r = Z(a(i[n], e));
1604
+ for (let o = n + 1; o < i.length; o++) {
1605
+ let n = Z(a(i[o], e));
1606
+ for (let e of r) for (let r of n) V(e.a, e.b, r.a, r.b, Y) && t++;
1607
+ }
1608
+ }
1609
+ return t;
1610
+ }, "crossingCount"), s = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => i.reduce((t, n) => t + E(a(n, e)), 0), "totalBends"), c = /* @__PURE__ */ e((e) => {
1611
+ let t = a(e);
1612
+ if (t.length < 4) return;
1613
+ let n = t[t.length - 2], r = t[t.length - 1];
1614
+ if (!(!x(n, r, Y) && !S(n, r, Y))) return {
1615
+ tailStart: n,
1616
+ terminal: r
1617
+ };
1618
+ }, "terminalTailFor"), l = /* @__PURE__ */ e((e, t) => {
1619
+ let n = a(e);
1620
+ if (n.length < 3) return;
1621
+ let r = n[0], i = n[1], o;
1622
+ if (x(r, i, Y)) o = {
1623
+ x: i.x,
1624
+ y: t.tailStart.y
1625
+ };
1626
+ else if (S(r, i, Y)) o = {
1627
+ x: t.tailStart.x,
1628
+ y: i.y
1629
+ };
1630
+ else return;
1631
+ let s = G(D([
1632
+ r,
1633
+ i,
1634
+ o,
1635
+ t.tailStart,
1636
+ t.terminal
1637
+ ]));
1638
+ return Z(s).length === s.length - 1 ? s : void 0;
1639
+ }, "candidateWithDestinationTail"), u = /* @__PURE__ */ e((e, t) => {
1640
+ let n = [e.start, e.end].filter((e) => !!e);
1641
+ for (let e of Z(t)) if (B(e.a, e.b, r, n, -2)) return !0;
1642
+ return !1;
1643
+ }, "pathHasNodeHit"), d = /* @__PURE__ */ e((e, t, n) => {
1644
+ for (let r of i) if (r !== e) {
1645
+ for (let e of Z(t)) for (let t of Z(a(r, n))) if (w(e, t, .5) >= X) return !0;
1646
+ }
1647
+ return !1;
1648
+ }, "pathHasSharedTrack"), f = /* @__PURE__ */ e((e, t, n) => !u(e, t) && !d(e, t, n), "candidateIsSafe"), p = /* @__PURE__ */ e(() => {
1649
+ let e = /* @__PURE__ */ new Map();
1650
+ for (let t of i) {
1651
+ let r = t.end;
1652
+ if (!r || !n.has(r) || a(t).length < 4) continue;
1653
+ let i = e.get(r) ?? [];
1654
+ i.push(t), e.set(r, i);
1655
+ }
1656
+ return e;
1657
+ }, "edgesByDestination");
1658
+ for (let e = 0; e < 4; e++) {
1659
+ let e = o();
1660
+ if (e === 0) return;
1661
+ let t = s(), n, r = e, i = t;
1662
+ for (let t of p().values()) for (let a = 0; a < t.length; a++) for (let u = a + 1; u < t.length; u++) {
1663
+ let d = t[a], p = t[u], m = c(d), h = c(p);
1664
+ if (!m || !h) continue;
1665
+ let g = l(d, h), _ = l(p, m);
1666
+ if (!g || !_) continue;
1667
+ let v = /* @__PURE__ */ new Map([[d, g], [p, _]]);
1668
+ if (!f(d, g, v) || !f(p, _, v)) continue;
1669
+ let y = o(v), b = s(v);
1670
+ y >= e || y > r || y === r && b >= i || (n = v, r = y, i = b);
1671
+ }
1672
+ if (!n) return;
1673
+ for (let [e, t] of n) e.points = t;
1674
+ }
1675
+ }
1676
+ e(Xe, "swapDestinationTerminalTailsToReduceCrossings");
1677
+ function Ze(t, n) {
1678
+ let { realNodeRects: r, labelNodeRects: i } = z(n.values()), a = t.filter((e) => !e.isLayoutOnly), o = /* @__PURE__ */ e((e, t = /* @__PURE__ */ new Map()) => D(t.get(e) ?? e.points ?? []), "replacementPointsFor"), s = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => {
1679
+ let t = 0;
1680
+ for (let n = 0; n < a.length; n++) {
1681
+ let r = Z(o(a[n], e));
1682
+ for (let i = n + 1; i < a.length; i++) {
1683
+ let n = Z(o(a[i], e));
1684
+ for (let e of r) for (let r of n) V(e.a, e.b, r.a, r.b, Y) && t++;
1685
+ }
1686
+ }
1687
+ return t;
1688
+ }, "strictCrossingCount"), c = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => a.reduce((t, n) => t + E(o(n, e)), 0), "totalBends"), l = /* @__PURE__ */ e((e) => {
1689
+ let t = e.start, r = e.end, i = t ? n.get(t) : void 0, a = r ? n.get(r) : void 0, o = i ? F(i) : void 0, s = a ? F(a) : void 0;
1690
+ return o && s ? {
1691
+ src: o,
1692
+ dst: s
1693
+ } : void 0;
1694
+ }, "endpointRectsFor"), u = /* @__PURE__ */ e((e, t, n) => {
1695
+ if (n.index <= 0 || n.index + 1 >= t.length - 1) return;
1696
+ let r = l(e);
1697
+ if (r) {
1698
+ if (n.vertical) {
1699
+ let i = n.a.x, a = Math.min(r.src.left, r.dst.left), o = Math.max(r.src.right, r.dst.right), s = i < a - Y ? "left" : i > o + Y ? "right" : void 0;
1700
+ return s ? {
1701
+ edge: e,
1702
+ points: t,
1703
+ segmentIndex: n.index,
1704
+ axis: "vertical",
1705
+ side: s,
1706
+ coord: i,
1707
+ min: Math.min(n.a.y, n.b.y),
1708
+ max: Math.max(n.a.y, n.b.y)
1709
+ } : void 0;
1710
+ }
1711
+ if (n.horizontal) {
1712
+ let i = n.a.y, a = Math.min(r.src.top, r.dst.top), o = Math.max(r.src.bottom, r.dst.bottom), s = i < a - Y ? "top" : i > o + Y ? "bottom" : void 0;
1713
+ return s ? {
1714
+ edge: e,
1715
+ points: t,
1716
+ segmentIndex: n.index,
1717
+ axis: "horizontal",
1718
+ side: s,
1719
+ coord: i,
1720
+ min: Math.min(n.a.x, n.b.x),
1721
+ max: Math.max(n.a.x, n.b.x)
1722
+ } : void 0;
1723
+ }
1724
+ }
1725
+ }, "externalRailForSegment"), d = /* @__PURE__ */ e(() => {
1726
+ let e = [];
1727
+ for (let t of a) {
1728
+ let n = o(t);
1729
+ for (let r of Z(n)) {
1730
+ let i = u(t, n, r);
1731
+ i && e.push(i);
1732
+ }
1733
+ }
1734
+ return e;
1735
+ }, "collectExternalRails"), f = /* @__PURE__ */ e((e, t) => e.edge !== t.edge && e.axis === t.axis && e.side === t.side && C(e.min, e.max, t.min, t.max) >= X, "railsInteract"), p = /* @__PURE__ */ e((e) => {
1736
+ let t = [], n = /* @__PURE__ */ new Set();
1737
+ for (let r of e) {
1738
+ if (n.has(r)) continue;
1739
+ let i = [r], a = [];
1740
+ for (n.add(r); i.length > 0;) {
1741
+ let t = i.pop();
1742
+ a.push(t);
1743
+ for (let r of e) !n.has(r) && f(t, r) && (n.add(r), i.push(r));
1744
+ }
1745
+ a.length > 1 && t.push(a);
1746
+ }
1747
+ return t;
1748
+ }, "connectedComponents"), m = /* @__PURE__ */ e((e) => {
1749
+ let t = [];
1750
+ for (let n of e) t.some((e) => Math.abs(e - n.coord) < Y) || t.push(n.coord);
1751
+ for (; t.length < e.length;) {
1752
+ let n = Math.min(...t), r = Math.max(...t), i = e[0].side;
1753
+ t.push(i === "left" || i === "top" ? n - 12 * (e.length - t.length) : r + 12 * (e.length - t.length));
1754
+ }
1755
+ return t;
1756
+ }, "uniqueCoordsFor"), h = /* @__PURE__ */ e((t) => {
1757
+ let n = t.map((e) => e.coord), r = m(t), i = [];
1758
+ if (t.length <= 6) {
1759
+ let a = Array(r.length).fill(!1), o = [], s = /* @__PURE__ */ e(() => {
1760
+ if (o.length === t.length) {
1761
+ o.some((e, t) => Math.abs(e - n[t]) >= Y) && i.push([...o]);
1762
+ return;
1763
+ }
1764
+ for (let [e, t] of r.entries()) a[e] || (a[e] = !0, o.push(t), s(), o.pop(), a[e] = !1);
1765
+ }, "visit");
1766
+ return s(), i;
1767
+ }
1768
+ for (let e = 0; e < n.length; e++) for (let t = e + 1; t < n.length; t++) {
1769
+ let r = [...n];
1770
+ [r[e], r[t]] = [r[t], r[e]], i.push(r);
1771
+ }
1772
+ return i;
1773
+ }, "coordinateAssignmentsFor"), g = /* @__PURE__ */ e((e, t) => {
1774
+ let n = /* @__PURE__ */ new Map();
1775
+ for (let [r, i] of e.entries()) {
1776
+ let e = t[r], a = n.get(i.edge) ?? i.points.map((e) => ({
1777
+ x: e.x,
1778
+ y: e.y
1779
+ }));
1780
+ i.axis === "vertical" ? (a[i.segmentIndex].x = e, a[i.segmentIndex + 1].x = e) : (a[i.segmentIndex].y = e, a[i.segmentIndex + 1].y = e), n.set(i.edge, a);
1781
+ }
1782
+ let r = /* @__PURE__ */ new Map();
1783
+ for (let [e, t] of n) {
1784
+ let n = G(D(t));
1785
+ if (Z(n).length !== n.length - 1) return;
1786
+ r.set(e, n);
1787
+ }
1788
+ return r;
1789
+ }, "replacementsForAssignment"), _ = /* @__PURE__ */ e((e) => {
1790
+ for (let [t, n] of e) {
1791
+ let e = [t.start, t.end].filter((e) => !!e);
1792
+ for (let t of Z(n)) if (B(t.a, t.b, r, e, -2) || B(t.a, t.b, i, [], -2)) return !1;
1793
+ }
1794
+ for (let t = 0; t < a.length; t++) {
1795
+ let n = a[t], r = e.has(n), i = Z(o(n, e));
1796
+ for (let n = t + 1; n < a.length; n++) {
1797
+ let t = a[n];
1798
+ if (!r && !e.has(t)) continue;
1799
+ let s = Z(o(t, e));
1800
+ for (let e of i) for (let t of s) if (w(e, t, .5) >= X) return !1;
1801
+ }
1802
+ }
1803
+ return !0;
1804
+ }, "candidateIsSafe");
1805
+ for (let e = 0; e < 4; e++) {
1806
+ let e = s();
1807
+ if (e === 0) return;
1808
+ let t, n = e, r = c(), i = Infinity;
1809
+ for (let a of p(d())) for (let o of h(a)) {
1810
+ let l = g(a, o);
1811
+ if (!l || !_(l)) continue;
1812
+ let u = s(l);
1813
+ if (u >= e) continue;
1814
+ let d = c(l), f = a.reduce((e, t, n) => e + Math.abs(o[n] - t.coord), 0);
1815
+ u > n || u === n && (d > r || d === r && f >= i) || (t = l, n = u, r = d, i = f);
1816
+ }
1817
+ if (!t) return;
1818
+ for (let [e, n] of t) e.points = n;
1819
+ }
1820
+ }
1821
+ e(Ze, "reassignCrossingExternalRailChannels");
1822
+ function Qe(t, n) {
1823
+ let { realNodeRects: r, labelNodeRects: i } = z(n.values()), a = t.filter((e) => !e.isLayoutOnly), o = /* @__PURE__ */ e((e, t, n) => D(e === t ? n ?? [] : e.points ?? []), "pointsFor"), s = /* @__PURE__ */ e((e) => Z(e).reduce((e, t) => {
1824
+ let n = t.a.x - t.b.x, r = t.a.y - t.b.y;
1825
+ return e + Math.hypot(n, r);
1826
+ }, 0), "pathLength"), c = /* @__PURE__ */ e((e, t) => {
1827
+ let n = 0;
1828
+ for (let r = 0; r < a.length; r++) {
1829
+ let i = Z(o(a[r], e, t));
1830
+ for (let s = r + 1; s < a.length; s++) {
1831
+ let r = Z(o(a[s], e, t));
1832
+ for (let e of i) for (let t of r) V(e.a, e.b, t.a, t.b, Y) && n++;
1833
+ }
1834
+ }
1835
+ return n;
1836
+ }, "strictCrossingCount"), l = /* @__PURE__ */ e((e, t) => {
1837
+ if (e.horizontal) {
1838
+ let n = e.a.y;
1839
+ return (Math.abs(n - t.top) < 1 || Math.abs(n - t.bottom) < 1) && C(e.a.x, e.b.x, t.left, t.right) >= X;
1840
+ }
1841
+ if (e.vertical) {
1842
+ let n = e.a.x;
1843
+ return (Math.abs(n - t.left) < 1 || Math.abs(n - t.right) < 1) && C(e.a.y, e.b.y, t.top, t.bottom) >= X;
1844
+ }
1845
+ return !1;
1846
+ }, "segmentRunsAlongRectBorder"), u = /* @__PURE__ */ e((e) => {
1847
+ let t = [e.start, e.end].filter((e) => !!e), r = [];
1848
+ for (let e of t) {
1849
+ let t = n.get(e), i = t ? F(t) : void 0;
1850
+ i && r.push(i);
1851
+ }
1852
+ return r;
1853
+ }, "endpointRectsFor"), d = /* @__PURE__ */ e((e, t) => {
1854
+ if (t + 3 >= e.length) return [];
1855
+ let n = e[t], r = e[t + 1], i = e[t + 2], a = e[t + 3], o = x(n, r, Y) && S(r, i, Y) && x(i, a, Y), s = S(n, r, Y) && x(r, i, Y) && S(i, a, Y);
1856
+ if (!o && !s || !(o ? Math.sign(r.x - n.x) !== Math.sign(a.x - i.x) : Math.sign(r.y - n.y) !== Math.sign(a.y - i.y))) return [];
1857
+ let c = y(n, a, Y) || b(n, a, Y) ? [] : [{
1858
+ x: n.x,
1859
+ y: a.y
1860
+ }, {
1861
+ x: a.x,
1862
+ y: n.y
1863
+ }], l = c.length === 0 ? [[...e.slice(0, t + 1), ...e.slice(t + 3)]] : c.map((n) => [
1864
+ ...e.slice(0, t + 1),
1865
+ n,
1866
+ ...e.slice(t + 3)
1867
+ ]), u = /* @__PURE__ */ new Set();
1868
+ return l.map((e) => G(D(e))).filter((e) => {
1869
+ if (Z(e).length !== e.length - 1 || !e.some((e) => v(e, a, Y))) return !1;
1870
+ let t = e.map((e) => `${e.x.toFixed(3)},${e.y.toFixed(3)}`).join("|");
1871
+ return u.has(t) ? !1 : (u.add(t), !0);
1872
+ });
1873
+ }, "shortcutCandidatesAt"), f = /* @__PURE__ */ e((e, t, n) => {
1874
+ let s = [e.start, e.end].filter((e) => !!e), d = u(e);
1875
+ for (let e of Z(t)) if (B(e.a, e.b, r, s, -2) || B(e.a, e.b, i, [], -2) || d.some((t) => l(e, t))) return !1;
1876
+ for (let n of a) if (n !== e) {
1877
+ for (let e of Z(t)) for (let t of Z(o(n))) if (w(e, t, .5) >= X) return !1;
1878
+ }
1879
+ return c(e, t) <= n;
1880
+ }, "candidateIsSafe");
1881
+ for (let e = 0; e < 8; e++) {
1882
+ let e = c(), t, n, r = e, i = Infinity, l = Infinity;
1883
+ for (let u of a) {
1884
+ let a = o(u), p = E(a, Y), m = s(a);
1885
+ for (let o = 0; o <= a.length - 4; o++) for (let h of d(a, o)) {
1886
+ let a = E(h, Y), o = s(h);
1887
+ if (!(a < p || a === p && o < m - Y) || !f(u, h, e)) continue;
1888
+ let d = c(u, h);
1889
+ d > r || d === r && (a > i || a === i && o >= l) || (t = u, n = h, r = d, i = a, l = o);
1890
+ }
1891
+ }
1892
+ if (!t || !n) return;
1893
+ t.points = n;
1894
+ }
1895
+ }
1896
+ e(Qe, "shortcutRedundantOrthogonalJogs");
1897
+ function $e(t, n) {
1898
+ let r = [];
1899
+ for (let e of n.values()) {
1900
+ if (e.isGroup || e.isEdgeLabel) continue;
1901
+ let t = e.x ?? 0, n = e.y ?? 0, i = F(e);
1902
+ i && r.push({
1903
+ id: String(e.id ?? ""),
1904
+ cx: t,
1905
+ cy: n,
1906
+ rect: i
1907
+ });
1908
+ }
1909
+ if (r.length === 0) return;
1910
+ let i = new Map(r.map((e) => [e.id, e])), a = r.map((e) => ({
1911
+ id: e.id,
1912
+ rect: e.rect
1913
+ })), o = [
1914
+ "top",
1915
+ "bottom",
1916
+ "left",
1917
+ "right"
1918
+ ], s = {
1919
+ top: Math.min(...r.map((e) => e.rect.top)) - 20,
1920
+ bottom: Math.max(...r.map((e) => e.rect.bottom)) + 20,
1921
+ left: Math.min(...r.map((e) => e.rect.left)) - 20,
1922
+ right: Math.max(...r.map((e) => e.rect.right)) + 20
1923
+ }, c = t.filter((e) => !e.isLayoutOnly), l = new Map(c.map((e, t) => [e, t])), u = /* @__PURE__ */ e((e) => {
1924
+ let t = e === "left" || e === "top" ? -1 : 1, n = [];
1925
+ for (let r = 0; r <= 2; r++) n.push(s[e] + t * 20 * r);
1926
+ return n;
1927
+ }, "outwardTracksForSide"), d = /* @__PURE__ */ e((e, t = /* @__PURE__ */ new Map()) => D(t.get(e) ?? e.points ?? []), "replacementPointsFor"), f = /* @__PURE__ */ e((e, t) => {
1928
+ let n = 0;
1929
+ for (let r of e) for (let e of t) V(r.a, r.b, e.a, e.b, Y) && n++;
1930
+ return n;
1931
+ }, "crossingCountBetweenSegments"), p = /* @__PURE__ */ e((e, t) => f(Z(e), Z(t)), "crossingCountBetweenPaths"), m = /* @__PURE__ */ e((t = /* @__PURE__ */ new Map()) => {
1932
+ let n = 0, r = [], i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ e((e) => {
1933
+ i.has(e) || (i.add(e), a.push(e));
1934
+ }, "addEdge");
1935
+ for (let e = 0; e < c.length; e++) {
1936
+ let i = c[e], a = d(i, t);
1937
+ for (let s = e + 1; s < c.length; s++) {
1938
+ let e = c[s], l = p(a, d(e, t));
1939
+ l > 0 && (n += l, r.push({
1940
+ first: i,
1941
+ second: e,
1942
+ count: l
1943
+ }), o(i), o(e));
1944
+ }
1945
+ }
1946
+ return a.sort((e, t) => (l.get(e) ?? 0) - (l.get(t) ?? 0)), {
1947
+ count: n,
1948
+ pairs: r,
1949
+ edgeSet: i,
1950
+ edges: a
1951
+ };
1952
+ }, "crossingSnapshot"), h = /* @__PURE__ */ e((e, t) => {
1953
+ let n = new Set(t.keys());
1954
+ if (n.size === 0) return e.count;
1955
+ let r = 0;
1956
+ for (let t of e.pairs) (n.has(t.first) || n.has(t.second)) && (r += t.count);
1957
+ let i = 0;
1958
+ for (let e = 0; e < c.length; e++) {
1959
+ let r = c[e], a = n.has(r), o = d(r, t);
1960
+ for (let r = e + 1; r < c.length; r++) {
1961
+ let e = c[r];
1962
+ !a && !n.has(e) || (i += p(o, d(e, t)));
1963
+ }
1964
+ }
1965
+ return e.count - r + i;
1966
+ }, "crossingCountWithReplacements"), g = /* @__PURE__ */ e((e) => {
1967
+ let t = /* @__PURE__ */ new Map();
1968
+ for (let n of e.pairs) {
1969
+ let e = t.get(n.first) ?? /* @__PURE__ */ new Set();
1970
+ e.add(n.second), t.set(n.first, e);
1971
+ let r = t.get(n.second) ?? /* @__PURE__ */ new Set();
1972
+ r.add(n.first), t.set(n.second, r);
1973
+ }
1974
+ let n = [], r = /* @__PURE__ */ new Set();
1975
+ for (let i of e.edges) {
1976
+ if (r.has(i)) continue;
1977
+ let e = [i], a = [];
1978
+ for (r.add(i); e.length > 0;) {
1979
+ let n = e.pop();
1980
+ a.push(n);
1981
+ for (let i of t.get(n) ?? []) r.has(i) || (r.add(i), e.push(i));
1982
+ }
1983
+ a.sort((e, t) => (l.get(e) ?? 0) - (l.get(t) ?? 0)), a.length > 1 && n.push(a);
1984
+ }
1985
+ return n;
1986
+ }, "crossingComponents"), _ = /* @__PURE__ */ e((e) => [e.start, e.end].filter((e) => !!e), "endpointIdsFor"), v = /* @__PURE__ */ e((e) => {
1987
+ let t = [];
1988
+ for (let n of g(e)) {
1989
+ let e = new Set(n), r = new Set(n.flatMap((e) => _(e))), i = [...n];
1990
+ for (let t of c) e.has(t) || _(t).some((e) => r.has(e)) && i.push(t);
1991
+ i.sort((e, t) => (l.get(e) ?? 0) - (l.get(t) ?? 0)), t.push(i);
1992
+ }
1993
+ return t;
1994
+ }, "pairSearchGroups"), y = /* @__PURE__ */ e((e, t, n) => h(e, /* @__PURE__ */ new Map([[t, n]])), "crossingCountWithSingleReplacement"), b = /* @__PURE__ */ e((e) => {
1995
+ let t = /* @__PURE__ */ new Map();
1996
+ for (let n of e.pairs) t.set(n.first, (t.get(n.first) ?? 0) + n.count), t.set(n.second, (t.get(n.second) ?? 0) + n.count);
1997
+ return t;
1998
+ }, "currentCrossingsByEdge"), C = /* @__PURE__ */ e((e) => e.slice(1).reduce((t, n, r) => {
1999
+ let i = e[r];
2000
+ return t + Math.abs(n.x - i.x) + Math.abs(n.y - i.y);
2001
+ }, 0), "pathLength"), T = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => c.reduce((t, n) => t + E(d(n, e)), 0), "totalBends"), O = /* @__PURE__ */ e((e = /* @__PURE__ */ new Map()) => c.reduce((t, n) => t + C(d(n, e)), 0), "totalLength"), k = /* @__PURE__ */ e((e, t, n = /* @__PURE__ */ new Map()) => {
2002
+ let r = Z(t);
2003
+ for (let t of c) if (t !== e) {
2004
+ for (let e of r) for (let r of Z(d(t, n))) if (w(e, r, .5) >= X) return !0;
2005
+ }
2006
+ return !1;
2007
+ }, "pathHasSegmentConflict"), A = /* @__PURE__ */ e((e, t) => {
2008
+ let n = [e.start, e.end].filter((e) => !!e);
2009
+ for (let e of Z(t)) if (B(e.a, e.b, a, n, -2)) return !0;
2010
+ return !1;
2011
+ }, "pathHitsNode"), j = /* @__PURE__ */ e((e, t) => {
2012
+ let n = G(D(t));
2013
+ Z(n).length === n.length - 1 && e.push(n);
2014
+ }, "pushOrthogonalCandidate"), M = /* @__PURE__ */ e((e) => e === "left" || e === "right", "sideIsHorizontal"), N = /* @__PURE__ */ e((e, t, n) => {
2015
+ switch (t) {
2016
+ case "left": return Math.min(e.x, n.x) - 20;
2017
+ case "right": return Math.max(e.x, n.x) + 20;
2018
+ case "top": return Math.min(e.y, n.y) - 20;
2019
+ case "bottom": return Math.max(e.y, n.y) + 20;
2020
+ }
2021
+ }, "localTrackForSameSide"), P = /* @__PURE__ */ e((e, t, n, r) => {
2022
+ let i = n === "left" || n === "top" ? -1 : 1, a = [N(t, n, r), s[n]];
2023
+ for (let o of a) for (let a = 0; a <= 2; a++) j(e, L(t, n, r, o + i * 20 * a));
2024
+ }, "addSameSideCandidates"), R = /* @__PURE__ */ e((e, t, n, r, i) => {
2025
+ for (let a of u(n)) for (let n of u(i)) j(e, [
2026
+ t,
2027
+ {
2028
+ x: a,
2029
+ y: t.y
2030
+ },
2031
+ {
2032
+ x: a,
2033
+ y: n
2034
+ },
2035
+ {
2036
+ x: r.x,
2037
+ y: n
2038
+ },
2039
+ r
2040
+ ]);
2041
+ }, "addHorizontalToVerticalCandidates"), z = /* @__PURE__ */ e((e, t, n, r, i) => {
2042
+ for (let a of u(n)) for (let n of u(i)) j(e, [
2043
+ t,
2044
+ {
2045
+ x: t.x,
2046
+ y: a
2047
+ },
2048
+ {
2049
+ x: n,
2050
+ y: a
2051
+ },
2052
+ {
2053
+ x: n,
2054
+ y: r.y
2055
+ },
2056
+ r
2057
+ ]);
2058
+ }, "addVerticalToHorizontalCandidates"), te = /* @__PURE__ */ e((e, t, n, r, i) => {
2059
+ let a = [...u("top"), ...u("bottom")];
2060
+ for (let o of u(n)) for (let n of u(i)) for (let i of a) j(e, [
2061
+ t,
2062
+ {
2063
+ x: o,
2064
+ y: t.y
2065
+ },
2066
+ {
2067
+ x: o,
2068
+ y: i
2069
+ },
2070
+ {
2071
+ x: n,
2072
+ y: i
2073
+ },
2074
+ {
2075
+ x: n,
2076
+ y: r.y
2077
+ },
2078
+ r
2079
+ ]);
2080
+ }, "addHorizontalPairCandidates"), ne = /* @__PURE__ */ e((e, t, n, r, i) => {
2081
+ let a = [...u("left"), ...u("right")];
2082
+ for (let o of u(n)) for (let n of u(i)) for (let i of a) j(e, [
2083
+ t,
2084
+ {
2085
+ x: t.x,
2086
+ y: o
2087
+ },
2088
+ {
2089
+ x: i,
2090
+ y: o
2091
+ },
2092
+ {
2093
+ x: i,
2094
+ y: n
2095
+ },
2096
+ {
2097
+ x: r.x,
2098
+ y: n
2099
+ },
2100
+ r
2101
+ ]);
2102
+ }, "addVerticalPairCandidates"), re = /* @__PURE__ */ e((e) => {
2103
+ let t = /* @__PURE__ */ new Set();
2104
+ return e.map((e) => D(e)).filter((e) => {
2105
+ let n = e.map((e) => `${e.x.toFixed(3)},${e.y.toFixed(3)}`).join("|");
2106
+ return t.has(n) || e.length < 2 ? !1 : (t.add(n), !0);
2107
+ });
2108
+ }, "dedupeCandidatePaths"), ie = /* @__PURE__ */ e((e, t, n, r) => {
2109
+ let i = [], a = ee(e, t, n, r, 20, Y);
2110
+ a && j(i, a), t === r && P(i, e, t, n);
2111
+ let o = M(t), s = M(r);
2112
+ return o && !s ? R(i, e, t, n, r) : !o && s ? z(i, e, t, n, r) : o ? te(i, e, t, n, r) : ne(i, e, t, n, r), re(i);
2113
+ }, "buildCandidatesForSides"), ae = /* @__PURE__ */ e((e, t, n, r) => {
2114
+ let i = [...u("left"), ...u("right")], a = [...u("top"), ...u("bottom")];
2115
+ for (let s of o) {
2116
+ let o = I(r, s), c = s === "top" || s === "bottom" ? u(s) : a;
2117
+ for (let r of i) {
2118
+ j(e, [
2119
+ t,
2120
+ n,
2121
+ {
2122
+ x: r,
2123
+ y: n.y
2124
+ },
2125
+ {
2126
+ x: r,
2127
+ y: o.y
2128
+ },
2129
+ o
2130
+ ]);
2131
+ for (let i of c) j(e, [
2132
+ t,
2133
+ n,
2134
+ {
2135
+ x: r,
2136
+ y: n.y
2137
+ },
2138
+ {
2139
+ x: r,
2140
+ y: i
2141
+ },
2142
+ {
2143
+ x: o.x,
2144
+ y: i
2145
+ },
2146
+ o
2147
+ ]);
2148
+ }
2149
+ }
2150
+ }, "addVerticalDepartureOuterTrackCandidates"), oe = /* @__PURE__ */ e((e, t, n, r) => {
2151
+ let i = [...u("left"), ...u("right")], a = [...u("top"), ...u("bottom")];
2152
+ for (let s of o) {
2153
+ let o = I(r, s), c = s === "left" || s === "right" ? u(s) : i;
2154
+ for (let r of a) {
2155
+ j(e, [
2156
+ t,
2157
+ n,
2158
+ {
2159
+ x: n.x,
2160
+ y: r
2161
+ },
2162
+ {
2163
+ x: o.x,
2164
+ y: r
2165
+ },
2166
+ o
2167
+ ]);
2168
+ for (let i of c) j(e, [
2169
+ t,
2170
+ n,
2171
+ {
2172
+ x: n.x,
2173
+ y: r
2174
+ },
2175
+ {
2176
+ x: i,
2177
+ y: r
2178
+ },
2179
+ {
2180
+ x: i,
2181
+ y: o.y
2182
+ },
2183
+ o
2184
+ ]);
2185
+ }
2186
+ }
2187
+ }, "addHorizontalDepartureOuterTrackCandidates"), H = /* @__PURE__ */ e((e) => {
2188
+ let t = e.start, n = e.end, r = n ? i.get(n) : void 0;
2189
+ if (!t || !r) return [];
2190
+ let a = D(e.points ?? []);
2191
+ if (a.length < 4) return [];
2192
+ let o = a[0], s = a[1], c = [];
2193
+ return S(o, s, Y) ? ae(c, o, s, r) : x(o, s, Y) && oe(c, o, s, r), c;
2194
+ }, "terminalPreservingOuterTrackCandidates"), U = /* @__PURE__ */ e((e) => {
2195
+ let t = e.start, n = e.end, r = t ? i.get(t) : void 0, a = n ? i.get(n) : void 0;
2196
+ if (!r || !a) return [];
2197
+ let s = [];
2198
+ for (let e of o) {
2199
+ let t = I(r, e);
2200
+ for (let n of o) s.push(...ie(t, e, I(a, n), n));
2201
+ }
2202
+ return s.push(...H(e)), s;
2203
+ }, "candidatePathsFor"), W = /* @__PURE__ */ e(() => new Map(c.map((e) => [e, Z(d(e))])), "currentSegmentsByEdge"), K = /* @__PURE__ */ e((e, t, n) => {
2204
+ let r = /* @__PURE__ */ new Set();
2205
+ for (let i of c) {
2206
+ if (i === e) continue;
2207
+ let a = n.get(i) ?? Z(d(i));
2208
+ t.some((e) => a.some((t) => w(e, t, .5) >= X)) && r.add(i);
2209
+ }
2210
+ return r;
2211
+ }, "sharedTrackConflictsFor"), se = /* @__PURE__ */ e((e, t, n, r) => {
2212
+ let i = /* @__PURE__ */ new Set();
2213
+ return U(e).map((e) => G(D(e))).filter((t) => {
2214
+ if (A(e, t)) return !1;
2215
+ let n = t.map((e) => `${e.x.toFixed(3)},${e.y.toFixed(3)}`).join("|");
2216
+ return i.has(n) || t.length < 2 ? !1 : (i.add(n), !0);
2217
+ }).map((i) => {
2218
+ let a = Z(i), o = 0;
2219
+ for (let t of c) t !== e && (o += f(a, n.get(t) ?? Z(d(t))));
2220
+ return {
2221
+ candidate: i,
2222
+ candidateSegments: a,
2223
+ crossings: t.count - (r.get(e) ?? 0) + o,
2224
+ bends: E(i, Y),
2225
+ totalBends: E(i),
2226
+ length: C(i)
2227
+ };
2228
+ }).filter(({ crossings: e }) => e <= t.count).sort((e, t) => e.crossings - t.crossings || e.bends - t.bends || e.length - t.length).slice(0, 48).map((t) => ({
2229
+ path: t.candidate,
2230
+ segments: t.candidateSegments,
2231
+ sharedTrackConflicts: K(e, t.candidateSegments, n),
2232
+ totalBends: t.totalBends,
2233
+ length: t.length
2234
+ }));
2235
+ }, "pairCandidatesFor"), ce = /* @__PURE__ */ e((e, t, n, r, i, a) => {
2236
+ let o = 0;
2237
+ for (let n of e.pairs) (n.first === t || n.second === t || n.first === r || n.second === r) && (o += n.count);
2238
+ let s = f(n.segments, i.segments);
2239
+ for (let e of c) {
2240
+ if (e === t || e === r) continue;
2241
+ let o = a.get(e) ?? Z(d(e));
2242
+ s += f(n.segments, o) + f(i.segments, o);
2243
+ }
2244
+ return e.count - o + s;
2245
+ }, "pairCrossingCount"), le = /* @__PURE__ */ e((e, t) => {
2246
+ for (let n of e.sharedTrackConflicts) if (n !== t) return !1;
2247
+ return !0;
2248
+ }, "conflictsOnlyWith"), ue = /* @__PURE__ */ e((e, t) => e.segments.some((e) => t.segments.some((t) => w(e, t, .5) >= X)), "candidatesShareTrack"), de = /* @__PURE__ */ e((e, t, n, r) => le(t, n.edge) && le(r, e.edge) && !ue(t, r), "pairCandidatesAreCompatible"), q = /* @__PURE__ */ e((e, t, n, r, i) => {
2249
+ let a = ce(e.current, t.edge, n, r.edge, i, e.baseSegments);
2250
+ if (!(a >= e.current.count)) return {
2251
+ replacements: /* @__PURE__ */ new Map([[t.edge, n.path], [r.edge, i.path]]),
2252
+ crossings: a,
2253
+ bends: e.currentBends - (e.baseBendsByEdge.get(t.edge) ?? 0) - (e.baseBendsByEdge.get(r.edge) ?? 0) + n.totalBends + i.totalBends,
2254
+ length: e.currentLength - (e.baseLengthByEdge.get(t.edge) ?? 0) - (e.baseLengthByEdge.get(r.edge) ?? 0) + n.length + i.length
2255
+ };
2256
+ }, "scorePairReplacement"), J = /* @__PURE__ */ e((e, t) => e.crossings < t.crossings || e.crossings === t.crossings && (e.bends < t.bends || e.bends === t.bends && e.length < t.length), "pairScoreIsBetter"), fe = /* @__PURE__ */ e((e, t, n, r) => {
2257
+ let i = r;
2258
+ for (let r of t.candidates) for (let a of n.candidates) {
2259
+ if (!de(t, r, n, a)) continue;
2260
+ let o = q(e, t, r, n, a);
2261
+ o && J(o, i) && (i = o);
2262
+ }
2263
+ return i;
2264
+ }, "bestScoreForOptionPair"), pe = /* @__PURE__ */ e((e) => {
2265
+ let t = T(), n = O(), r = W(), i = b(e), a = new Map(c.map((e) => [e, E(d(e))])), o = new Map(c.map((e) => [e, C(d(e))])), s = /* @__PURE__ */ new Map(), l = v(e);
2266
+ for (let t of l) for (let n of t) {
2267
+ if (s.has(n)) continue;
2268
+ let t = se(n, e, r, i);
2269
+ t.length > 0 && s.set(n, {
2270
+ edge: n,
2271
+ candidates: t
2272
+ });
2273
+ }
2274
+ let u = {
2275
+ replacements: /* @__PURE__ */ new Map(),
2276
+ crossings: e.count,
2277
+ bends: t,
2278
+ length: n
2279
+ }, f = {
2280
+ current: e,
2281
+ currentBends: t,
2282
+ currentLength: n,
2283
+ baseBendsByEdge: a,
2284
+ baseLengthByEdge: o,
2285
+ baseSegments: r
2286
+ };
2287
+ for (let t of l) {
2288
+ let n = new Set(t.filter((t) => e.edgeSet.has(t))), r = t.map((e) => s.get(e)).filter((e) => !!e);
2289
+ for (let e = 0; e < r.length; e++) {
2290
+ let t = r[e];
2291
+ for (let i = e + 1; i < r.length; i++) {
2292
+ let e = r[i];
2293
+ !n.has(t.edge) && !n.has(e.edge) || (u = fe(f, t, e, u));
2294
+ }
2295
+ }
2296
+ }
2297
+ return u.replacements.size > 0 ? u.replacements : void 0;
2298
+ }, "bestPairedReplacement");
2299
+ for (let e = 0; e < 4; e++) {
2300
+ let e = m(), t = e.count;
2301
+ if (t === 0) return;
2302
+ let n, r, i = t, a = Infinity;
2303
+ for (let o of e.edges) {
2304
+ let s = E(d(o), Y);
2305
+ for (let c of U(o)) {
2306
+ let l = A(o, c), u = !l && k(o, c), d = y(e, o, c), f = E(c, Y);
2307
+ l || u || (d < t || d === t && f < s) && (d > i || d === i && f >= a || (n = o, r = c, i = d, a = f));
2308
+ }
2309
+ }
2310
+ if (n && r) {
2311
+ n.points = r;
2312
+ continue;
2313
+ }
2314
+ let o = pe(e);
2315
+ if (!o) return;
2316
+ for (let [e, t] of o) e.points = t;
2317
+ }
2318
+ }
2319
+ e($e, "resolveRenderedOrthogonalCrossings");
2320
+ var et = .001, tt = 8;
2321
+ function nt(t, n) {
2322
+ let { nodeInfoById: r, realNodeRects: i } = R(n), a = [
2323
+ "top",
2324
+ "bottom",
2325
+ "left",
2326
+ "right"
2327
+ ], o = {
2328
+ top: Math.min(...i.map((e) => e.rect.top)) - 20,
2329
+ bottom: Math.max(...i.map((e) => e.rect.bottom)) + 20,
2330
+ left: Math.min(...i.map((e) => e.rect.left)) - 20,
2331
+ right: Math.max(...i.map((e) => e.rect.right)) + 20
2332
+ }, s = /* @__PURE__ */ e((e, t, n, r) => {
2333
+ let i = [], a = ee(e, t, n, r, 20, et);
2334
+ return a && i.push(a), t === r && i.push(L(e, t, n, o[t])), i;
2335
+ }, "buildOrthogonalPathCandidates"), c = /* @__PURE__ */ e((e, t) => {
2336
+ for (let n = 0; n < e.length - 1; n++) {
2337
+ let r = e[n], a = e[n + 1];
2338
+ if (B(r, a, i, t, 1)) return !0;
2339
+ }
2340
+ return !1;
2341
+ }, "pathHitsNode"), l = /* @__PURE__ */ e((e, n, r = !1) => {
2342
+ let i = 0, a = T(e, et), o = n.start, s = n.end;
2343
+ for (let e of t) {
2344
+ if (e === n || e.isLayoutOnly) continue;
2345
+ let t = e.start, c = e.end;
2346
+ if (!r && o && s && (t === o || t === s || c === o || c === s)) continue;
2347
+ let l = e.points;
2348
+ if (!(!l || l.length < 2)) for (let e of a) for (let t of T(l, et)) {
2349
+ if (re(e.a, e.b, t.a, t.b, et, et)) {
2350
+ i++;
2351
+ continue;
2352
+ }
2353
+ w(e, t, et) >= tt && i++;
2354
+ }
2355
+ }
2356
+ return i;
2357
+ }, "pathConflictCount"), u = /* @__PURE__ */ e((e, t) => {
2358
+ let n = Math.abs(e.y - t.rect.top), r = Math.abs(e.y - t.rect.bottom), i = Math.abs(e.x - t.rect.left), a = Math.abs(e.x - t.rect.right), o = "top", s = n;
2359
+ return r < s && (o = "bottom", s = r), i < s && (o = "left", s = i), a < s && (o = "right", s = a), o;
2360
+ }, "nearestSideOfRect"), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ e((e, t, n) => {
2361
+ let r = d.get(e) ?? [];
2362
+ r.push({
2363
+ side: t,
2364
+ edgeId: n
2365
+ }), d.set(e, r);
2366
+ }, "addFaceClaim");
2367
+ for (let e of t) {
2368
+ if (e.isLayoutOnly) continue;
2369
+ let t = e.points ?? [];
2370
+ if (t.length < 1) continue;
2371
+ let n = e.id ?? "", i = e.start, a = e.end;
2372
+ if (i) {
2373
+ let e = r.get(i);
2374
+ e && f(i, u(t[0], e), n);
2375
+ }
2376
+ if (a) {
2377
+ let e = r.get(a);
2378
+ e && f(a, u(t[t.length - 1], e), n);
2379
+ }
2380
+ }
2381
+ let p = /* @__PURE__ */ e((e, t, n) => d.get(e)?.some((e) => e.edgeId !== n && e.side === t) ?? !1, "faceIsClaimed");
2382
+ for (let e of t) {
2383
+ if (e.isLayoutOnly) continue;
2384
+ let t = e.points;
2385
+ if (!t || t.length < 2) continue;
2386
+ let n = E(t, et);
2387
+ if (n < 4) continue;
2388
+ let i = e.start, o = e.end;
2389
+ if (!i || !o) continue;
2390
+ let m = r.get(i), h = r.get(o);
2391
+ if (!m || !h) continue;
2392
+ let g = e.id ?? "", _ = l(t, e, !0), v = l(t, e), y, b = _, x = n;
2393
+ for (let t of a) {
2394
+ if (p(i, t, g)) continue;
2395
+ let n = I(m, t);
2396
+ for (let r of a) {
2397
+ if (p(o, r, g)) continue;
2398
+ let a = I(h, r);
2399
+ for (let u of s(n, t, a, r)) {
2400
+ if (c(u, [i, o])) continue;
2401
+ let t = E(u, et);
2402
+ if (_ > 0) {
2403
+ let n = l(u, e, !0);
2404
+ if (n > b || n === b && t >= x) continue;
2405
+ b = n, x = t, y = u;
2406
+ continue;
2407
+ }
2408
+ l(u, e) > v || t < x && (x = t, y = u);
2409
+ }
2410
+ }
2411
+ }
2412
+ if (y) {
2413
+ e.points = y;
2414
+ let t = d.get(i);
2415
+ t && d.set(i, t.filter((e) => e.edgeId !== g));
2416
+ let n = d.get(o);
2417
+ n && d.set(o, n.filter((e) => e.edgeId !== g)), f(i, u(y[0], m), g), f(o, u(y[y.length - 1], h), g);
2418
+ }
2419
+ }
2420
+ }
2421
+ e(nt, "simplifyDetouredEdges");
2422
+ var Q = .001, rt = 10, it = 7;
2423
+ function at(e, t) {
2424
+ let n = t ? 0 : e.length - 1, r = t ? 1 : -1, i = e[n], a = e[n + r];
2425
+ if (!i || !a) return;
2426
+ let o = a.x - i.x, s = a.y - i.y;
2427
+ if (!(Math.abs(o) + Math.abs(s) < Q)) {
2428
+ if (Math.abs(s) <= Q) {
2429
+ let e = i.x + Math.sign(o) * rt;
2430
+ return {
2431
+ left: Math.min(i.x, e),
2432
+ right: Math.max(i.x, e),
2433
+ top: i.y - it,
2434
+ bottom: i.y + it
2435
+ };
2436
+ }
2437
+ if (Math.abs(o) <= Q) {
2438
+ let e = i.y + Math.sign(s) * rt;
2439
+ return {
2440
+ left: i.x - it,
2441
+ right: i.x + it,
2442
+ top: Math.min(i.y, e),
2443
+ bottom: Math.max(i.y, e)
2444
+ };
2445
+ }
2446
+ return {
2447
+ left: Math.min(i.x, a.x),
2448
+ right: Math.max(i.x, a.x),
2449
+ top: Math.min(i.y, a.y),
2450
+ bottom: Math.max(i.y, a.y)
2451
+ };
2452
+ }
2453
+ }
2454
+ e(at, "markerClearanceRectFor");
2455
+ function ot(e) {
2456
+ return {
2457
+ left: Math.min(e.left, e.right),
2458
+ right: Math.max(e.left, e.right),
2459
+ top: Math.min(e.top, e.bottom),
2460
+ bottom: Math.max(e.top, e.bottom)
2461
+ };
2462
+ }
2463
+ e(ot, "normalizeRect");
2464
+ function st(e, t) {
2465
+ let n = D(t);
2466
+ return [at(n, !0), at(n, !1)].some((t) => t && M(e, ot(t)));
2467
+ }
2468
+ e(st, "labelOverlapsOwnMarker");
2469
+ function ct(t, n) {
2470
+ let r = [];
2471
+ for (let e of t) {
2472
+ if (e.isLayoutOnly) continue;
2473
+ let t = e.points;
2474
+ if (!(!t || t.length < 2)) for (let n = 0; n < t.length - 1; n++) r.push({
2475
+ edgeId: e.id,
2476
+ p1: t[n],
2477
+ p2: t[n + 1]
2478
+ });
2479
+ }
2480
+ let i = [], a = [];
2481
+ for (let e of n.values()) {
2482
+ let t = e.isGroup, n = e.parentId;
2483
+ if (t && !n) {
2484
+ let t = F(e);
2485
+ t && a.push({
2486
+ id: e.id,
2487
+ rect: t
2488
+ });
2489
+ continue;
2490
+ }
2491
+ if (t || e.isEdgeLabel) continue;
2492
+ let r = F(e);
2493
+ r && i.push({
2494
+ nodeId: e.id,
2495
+ rect: r
2496
+ });
2497
+ }
2498
+ let o = /* @__PURE__ */ e((e, t) => {
2499
+ let n = N(t, 3);
2500
+ for (let { nodeId: t, rect: r } of i) if (t !== e && M(n, r)) return !0;
2501
+ return !1;
2502
+ }, "labelOverlapsForeignNode"), s = /* @__PURE__ */ e((e, t) => {
2503
+ let n = N(t, 3);
2504
+ for (let t of r) if (t.edgeId !== e && k(t.p1, t.p2, n)) return !0;
2505
+ return !1;
2506
+ }, "labelOverlapsForeignEdge"), c = /* @__PURE__ */ e((e, t, n) => o(e, n) || s(t, n), "labelOverlapsAnything"), l = [], u = /* @__PURE__ */ e((e) => {
2507
+ for (let { id: t, rect: n } of a) if (j(n, e)) return t;
2508
+ }, "findContainingLane"), d = /* @__PURE__ */ e((e, t) => l.some((n) => n.labelId !== e && M(t, n.rect)), "overlapsPlacedLabel");
2509
+ for (let r of t) {
2510
+ if (r.isLayoutOnly) continue;
2511
+ let t = r.labelNodeId;
2512
+ if (!t) continue;
2513
+ let i = n.get(t);
2514
+ if (!i) continue;
2515
+ let f = r.points;
2516
+ if (!f || f.length < 2) continue;
2517
+ let p = i.width ?? 0, m = i.height ?? 0;
2518
+ if (p <= 0 || m <= 0) continue;
2519
+ let h = [];
2520
+ for (let e = 0; e < f.length - 1; e++) {
2521
+ let t = f[e], n = f[e + 1], r = Math.abs(t.x - n.x), i = Math.abs(t.y - n.y);
2522
+ r < Q && i < Q || r >= Q && i >= Q || h.push({
2523
+ idx: e,
2524
+ length: r + i,
2525
+ orientation: r >= Q ? "horizontal" : "vertical",
2526
+ midX: (t.x + n.x) / 2,
2527
+ midY: (t.y + n.y) / 2
2528
+ });
2529
+ }
2530
+ if (h.length === 0) continue;
2531
+ let g = h.length >= 3 ? h.filter((e) => e.idx > 0 && e.idx < h.length - 1) : h, _ = g.length > 0 ? g : h, v = p >= m ? "horizontal" : "vertical", y = /* @__PURE__ */ e((e) => [...e].sort((e, t) => {
2532
+ let n = e.orientation === v;
2533
+ if (n !== (t.orientation === v)) return n ? -1 : 1;
2534
+ let r = e.length >= (e.orientation === "horizontal" ? p : m) + 2;
2535
+ return r === t.length >= (t.orientation === "horizontal" ? p : m) + 2 ? t.length - e.length : r ? -1 : 1;
2536
+ }), "rankSegments"), b = h[0], x = h[h.length - 1], S = [
2537
+ .5,
2538
+ .25,
2539
+ .75,
2540
+ .05,
2541
+ .95,
2542
+ .15,
2543
+ .85,
2544
+ .1,
2545
+ .9
2546
+ ], C = /* @__PURE__ */ e((e, t) => {
2547
+ let n = f[e.idx], r = f[e.idx + 1];
2548
+ return {
2549
+ midX: n.x + (r.x - n.x) * t,
2550
+ midY: n.y + (r.y - n.y) * t
2551
+ };
2552
+ }, "anchorAtT"), w = /* @__PURE__ */ e((e, t, n) => Math.min(n, Math.max(t, e)), "clamp"), T = /* @__PURE__ */ e((e, t) => e.midX >= t.left - Q && e.midX <= t.right + Q && e.midY >= t.top - Q && e.midY <= t.bottom + Q, "pointInsideRectInclusive"), E = /* @__PURE__ */ e((e) => {
2553
+ let t = P(e.midX, e.midY, p, m), n = u(t);
2554
+ if (n) return {
2555
+ laneId: n,
2556
+ anchor: e,
2557
+ rect: t
2558
+ };
2559
+ let r = a.find(({ rect: t }) => T(e, t));
2560
+ if (!r) return;
2561
+ let i = r.rect.left + p / 2 + 1, o = r.rect.right - p / 2 - 1, s = r.rect.top + m / 2 + 1, c = r.rect.bottom - m / 2 - 1;
2562
+ if (i > o || s > c) return;
2563
+ let l = {
2564
+ midX: w(e.midX, i, o),
2565
+ midY: w(e.midY, s, c)
2566
+ }, d = P(l.midX, l.midY, p, m);
2567
+ return T(e, d) ? {
2568
+ laneId: r.id,
2569
+ anchor: l,
2570
+ rect: d
2571
+ } : void 0;
2572
+ }, "placementForAnchor"), D = /* @__PURE__ */ e((e, t, n) => e.orientation === "horizontal" ? Math.abs(t.midX - n.x) : Math.abs(t.midY - n.y), "distanceAlongSegment"), O = /* @__PURE__ */ e((e, t) => {
2573
+ let n = (e.orientation === "horizontal" ? p / 2 : m / 2) + 12;
2574
+ if (e === b) {
2575
+ let r = f[e.idx];
2576
+ if (D(e, t, r) + Q < n) return !1;
2577
+ }
2578
+ if (e === x) {
2579
+ let r = f[e.idx + 1];
2580
+ if (D(e, t, r) + Q < n) return !1;
2581
+ }
2582
+ return !0;
2583
+ }, "labelClearsTerminalEndpoints"), k = /* @__PURE__ */ e((e) => {
2584
+ let n = y(e);
2585
+ for (let e of n) for (let n of S) {
2586
+ let i = C(e, n);
2587
+ if (!O(e, i)) continue;
2588
+ let a = E(i);
2589
+ if (a && !st(a.rect, f) && !d(t, a.rect) && !c(t, r.id, a.rect)) return {
2590
+ laneId: a.laneId,
2591
+ anchor: a.anchor
2592
+ };
2593
+ }
2594
+ }, "tryPool"), A = /* @__PURE__ */ e((e, n, i = !1) => {
2595
+ let a = y(e);
2596
+ for (let e of a) {
2597
+ let a = {
2598
+ midX: e.midX,
2599
+ midY: e.midY
2600
+ };
2601
+ if (n && !O(e, a)) continue;
2602
+ let c = E(a);
2603
+ if (c && !st(c.rect, f) && !d(t, c.rect) && !o(t, c.rect) && (i || !s(r.id, c.rect))) return {
2604
+ laneId: c.laneId,
2605
+ anchor: c.anchor
2606
+ };
2607
+ }
2608
+ }, "findLaneContainingFallback"), j = k(_) ?? (_.length < h.length ? k(h) : void 0) ?? A(h, !0) ?? A(h, !1) ?? A(h, !1, !0);
2609
+ if (j) {
2610
+ i.x = j.anchor.midX, i.y = j.anchor.midY, i.parentId = j.laneId;
2611
+ let e = P(j.anchor.midX, j.anchor.midY, p, m), n = l.findIndex((e) => e.labelId === t);
2612
+ n >= 0 ? l[n] = {
2613
+ labelId: t,
2614
+ rect: e
2615
+ } : l.push({
2616
+ labelId: t,
2617
+ rect: e
2618
+ });
2619
+ }
2620
+ }
2621
+ }
2622
+ e(ct, "anchorLabelsToPolyline");
2623
+ var lt = 1e-6, ut = 8 / 2, dt = 3;
2624
+ function ft(e, t) {
2625
+ return e < t ? `${e}::${t}` : `${t}::${e}`;
2626
+ }
2627
+ e(ft, "pairKey");
2628
+ function pt(t, n) {
2629
+ let { nodeInfoById: r, realNodeRects: i } = R(n), a = /* @__PURE__ */ new Map();
2630
+ for (let e of n) {
2631
+ let t = e.id;
2632
+ if (!e.isGroup && e.isEdgeLabel) {
2633
+ a.set(t, {
2634
+ w: e.width ?? 0,
2635
+ h: e.height ?? 0
2636
+ });
2637
+ continue;
2638
+ }
2639
+ }
2640
+ let o = /* @__PURE__ */ e((n, r, i, o) => {
2641
+ let s = ft(r, i), c = 0, l = /* @__PURE__ */ e((e) => {
2642
+ if (!e) return;
2643
+ let t = a.get(e);
2644
+ if (!t) return;
2645
+ let n = o === "x" ? t.w / 2 : t.h / 2;
2646
+ n > c && (c = n);
2647
+ }, "consider");
2648
+ l(n.labelNodeId);
2649
+ for (let e of t) {
2650
+ if (e === n || e.isLayoutOnly) continue;
2651
+ let t = e.start, r = e.end;
2652
+ !t || !r || ft(t, r) === s && l(e.labelNodeId);
2653
+ }
2654
+ return c > 0 ? c + dt : 0;
2655
+ }, "labelClearanceFor");
2656
+ for (let e of t) {
2657
+ if (e.isLayoutOnly) continue;
2658
+ let n = e.points;
2659
+ if (!O(n, lt)) continue;
2660
+ let a = ne(e, r, lt);
2661
+ if (!a) continue;
2662
+ let { srcId: s, dstId: c, srcInfo: l, dstInfo: u, collinearX: d, collinearY: f } = a;
2663
+ if (d === f) continue;
2664
+ let p, m;
2665
+ if (d) {
2666
+ let e = u.cy > l.cy;
2667
+ p = {
2668
+ x: l.cx,
2669
+ y: e ? l.rect.bottom : l.rect.top
2670
+ }, m = {
2671
+ x: u.cx,
2672
+ y: e ? u.rect.top : u.rect.bottom
2673
+ };
2674
+ } else {
2675
+ let e = u.cx > l.cx;
2676
+ p = {
2677
+ x: e ? l.rect.right : l.rect.left,
2678
+ y: l.cy
2679
+ }, m = {
2680
+ x: e ? u.rect.left : u.rect.right,
2681
+ y: u.cy
2682
+ };
2683
+ }
2684
+ if (B(p, m, i, [s, c], 1)) continue;
2685
+ let h = o(e, s, c, d ? "x" : "y"), g = h > ut ? h : ut, _ = [
2686
+ 0,
2687
+ g,
2688
+ -g
2689
+ ];
2690
+ for (let n of _) {
2691
+ let r = { ...p }, a = { ...m };
2692
+ if (d) {
2693
+ if (r.x += n, a.x += n, r.x <= l.rect.left || r.x >= l.rect.right || a.x <= u.rect.left || a.x >= u.rect.right) continue;
2694
+ } else if (r.y += n, a.y += n, r.y <= l.rect.top || r.y >= l.rect.bottom || a.y <= u.rect.top || a.y >= u.rect.bottom) continue;
2695
+ if (!B(r, a, i, [s, c], 1) && !ae(r, a, t, e, { epsilon: lt })) {
2696
+ e.points = [r, a];
2697
+ break;
2698
+ }
2699
+ }
2700
+ }
2701
+ }
2702
+ e(pt, "straightenCollinearSiblingDetours");
2703
+ function mt(t, n) {
2704
+ let r = .001, { realNodeRects: i, labelNodeRects: a } = z(n.values()), o = /* @__PURE__ */ e((e, t) => T(t, r).map((n) => ({
2705
+ ...n,
2706
+ edge: e,
2707
+ interior: n.index >= 1 && n.index <= t.length - 3
2708
+ })), "segmentsFor"), s = /* @__PURE__ */ e(() => {
2709
+ let e = [];
2710
+ for (let n of t) {
2711
+ if (n.isLayoutOnly) continue;
2712
+ let t = n.points;
2713
+ !t || t.length < 2 || e.push(...o(n, D(t)));
2714
+ }
2715
+ return e;
2716
+ }, "allSegments"), c = /* @__PURE__ */ e((e, t) => e.horizontal && t.horizontal ? C(e.a.x, e.b.x, t.a.x, t.b.x) >= 8 && Math.abs(e.a.y - t.a.y) < 7 : e.vertical && t.vertical ? C(e.a.y, e.b.y, t.a.y, t.b.y) >= 8 && Math.abs(e.a.x - t.a.x) < 7 : !1, "hasCrowdedParallelTrack"), l = /* @__PURE__ */ e((e, n) => {
2717
+ let s = e.start, l = e.end, u = o(e, n);
2718
+ if (u.length !== n.length - 1) return !1;
2719
+ let d = [s, l].filter((e) => !!e), f = e.labelNodeId ? [e.labelNodeId] : [];
2720
+ for (let e of u) if (B(e.a, e.b, i, d, -2) || B(e.a, e.b, a, f, -2)) return !1;
2721
+ for (let n of t) {
2722
+ if (n === e || n.isLayoutOnly) continue;
2723
+ let t = n.points;
2724
+ if (!(!t || t.length < 2)) {
2725
+ for (let e of u) for (let i of o(n, D(t))) if (c(e, i) || V(e.a, e.b, i.a, i.b, r)) return !1;
2726
+ }
2727
+ }
2728
+ return !0;
2729
+ }, "candidateIsSafe"), u = /* @__PURE__ */ e((e, t) => {
2730
+ let n = D(e.edge.points ?? []);
2731
+ if (n.length < 4 || e.index >= n.length - 1) return;
2732
+ let r = n.map((e) => ({ ...e }));
2733
+ if (e.horizontal) r[e.index].y += t, r[e.index + 1].y += t;
2734
+ else if (e.vertical) r[e.index].x += t, r[e.index + 1].x += t;
2735
+ else return;
2736
+ return o(e.edge, r).length === r.length - 1 ? r : void 0;
2737
+ }, "shiftedCandidate"), d = /* @__PURE__ */ e((e, t) => ({
2738
+ x: e.x ?? (t.left + t.right) / 2,
2739
+ y: e.y ?? (t.top + t.bottom) / 2
2740
+ }), "nodeCenter"), f = /* @__PURE__ */ e((e) => {
2741
+ let t = e.edge, r = D(t.points ?? []);
2742
+ if (r.length !== 4 || e.index !== 1) return;
2743
+ let i = t.start ? n.get(t.start) : void 0, a = t.end ? n.get(t.end) : void 0, o = i ? F(i) : void 0, s = a ? F(a) : void 0, c = r.slice(e.index + 2);
2744
+ if (!(!i || !a || !o || !s || c.length === 0)) return {
2745
+ sourceCenter: d(i, o),
2746
+ targetCenter: d(a, s),
2747
+ sourceRect: o,
2748
+ tail: c
2749
+ };
2750
+ }, "sourceDetourContextFor"), p = /* @__PURE__ */ e((e, t, n, i, a, o) => {
2751
+ let s = i.y >= n.y, c = s ? a.bottom : a.top, l = c + (s ? 20 : -20);
2752
+ if (s && e.b.y <= l + r || !s && e.b.y >= l - r) return;
2753
+ let u = e.a.x + t;
2754
+ return D([
2755
+ {
2756
+ x: n.x,
2757
+ y: c
2758
+ },
2759
+ {
2760
+ x: n.x,
2761
+ y: l
2762
+ },
2763
+ {
2764
+ x: u,
2765
+ y: l
2766
+ },
2767
+ {
2768
+ x: u,
2769
+ y: e.b.y
2770
+ },
2771
+ ...o
2772
+ ], r);
2773
+ }, "verticalSourceDetour"), m = /* @__PURE__ */ e((e, t, n, i, a, o) => {
2774
+ let s = i.x >= n.x, c = s ? a.right : a.left, l = c + (s ? 20 : -20);
2775
+ if (s && e.b.x <= l + r || !s && e.b.x >= l - r) return;
2776
+ let u = e.a.y + t;
2777
+ return D([
2778
+ {
2779
+ x: c,
2780
+ y: n.y
2781
+ },
2782
+ {
2783
+ x: l,
2784
+ y: n.y
2785
+ },
2786
+ {
2787
+ x: l,
2788
+ y: u
2789
+ },
2790
+ {
2791
+ x: e.b.x,
2792
+ y: u
2793
+ },
2794
+ ...o
2795
+ ], r);
2796
+ }, "horizontalSourceDetour"), h = /* @__PURE__ */ e((e, t) => {
2797
+ let n = f(e);
2798
+ if (n) {
2799
+ if (e.vertical) return p(e, t, n.sourceCenter, n.targetCenter, n.sourceRect, n.tail);
2800
+ if (e.horizontal) return m(e, t, n.sourceCenter, n.targetCenter, n.sourceRect, n.tail);
2801
+ }
2802
+ }, "sourceDetourCandidate"), g = [
2803
+ -7,
2804
+ 7,
2805
+ -14,
2806
+ 14,
2807
+ -21,
2808
+ 21
2809
+ ];
2810
+ for (let e = 0; e < 12; e++) {
2811
+ let e = s(), t = !1;
2812
+ for (let n = 0; n < e.length && !t; n++) for (let r = n + 1; r < e.length && !t; r++) {
2813
+ let i = e[n], a = e[r];
2814
+ if (i.edge === a.edge || !c(i, a)) continue;
2815
+ let o = [i, a].filter((e) => e.interior);
2816
+ for (let e of o) {
2817
+ for (let n of g) {
2818
+ let r = u(e, n);
2819
+ if (r && l(e.edge, r)) {
2820
+ e.edge.points = r, t = !0;
2821
+ break;
2822
+ }
2823
+ let i = h(e, n);
2824
+ if (i && l(e.edge, i)) {
2825
+ e.edge.points = i, t = !0;
2826
+ break;
2827
+ }
2828
+ }
2829
+ if (t) break;
2830
+ }
2831
+ }
2832
+ if (!t) return;
2833
+ }
2834
+ }
2835
+ e(mt, "nudgeSharedInteriorSubpaths");
2836
+ function ht(e, t, n, r) {
2837
+ let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
2838
+ if (Math.abs(c) < 1e-10) return !1;
2839
+ let l = n.x - e.x, u = n.y - e.y, d = (l * s - u * o) / c, f = (l * a - u * i) / c, p = .01;
2840
+ return d > p && d < 1 - p && f > p && f < 1 - p;
2841
+ }
2842
+ e(ht, "segmentsIntersect");
2843
+ function gt(e) {
2844
+ let n = e.nodes ?? [], r = e.edges ?? [], i = [];
2845
+ if (!r.length || !n.length) return i;
2846
+ let a = te(n), o = [];
2847
+ for (let e of r) {
2848
+ if (e.isLayoutOnly) continue;
2849
+ let t = e.points;
2850
+ if (!t || t.length < 2) continue;
2851
+ let n = e.start, r = e.end, s = e.labelNodeId, c = e.id ?? `${n}->${r}`;
2852
+ for (let e of a) if (!(e.nodeId === n || e.nodeId === r) && !(s && e.nodeId === s)) {
2853
+ for (let n = 0; n < t.length - 1; n++) if (k(t[n], t[n + 1], e, -1)) {
2854
+ i.push({
2855
+ type: "edge-node-overlap",
2856
+ edgeId: c,
2857
+ targetId: e.nodeId,
2858
+ detail: `segment ${n} passes through node "${e.nodeId}"`
2859
+ });
2860
+ break;
2861
+ }
2862
+ }
2863
+ for (let e = 0; e < t.length - 1; e++) o.push({
2864
+ edgeId: c,
2865
+ start: n,
2866
+ end: r,
2867
+ p1: t[e],
2868
+ p2: t[e + 1]
2869
+ });
2870
+ }
2871
+ let s = /* @__PURE__ */ new Set();
2872
+ for (let e = 0; e < o.length; e++) for (let t = e + 1; t < o.length; t++) {
2873
+ let n = o[e], r = o[t];
2874
+ if (n.edgeId !== r.edgeId && !(n.start === r.start || n.start === r.end || n.end === r.start || n.end === r.end) && ht(n.p1, n.p2, r.p1, r.p2)) {
2875
+ let e = n.edgeId < r.edgeId ? `${n.edgeId}|${r.edgeId}` : `${r.edgeId}|${n.edgeId}`;
2876
+ s.has(e) || (s.add(e), i.push({
2877
+ type: "edge-edge-crossing",
2878
+ edgeId: n.edgeId,
2879
+ targetId: r.edgeId,
2880
+ detail: `edges "${n.edgeId}" and "${r.edgeId}" cross`
2881
+ }));
2882
+ }
2883
+ }
2884
+ if (i.length > 0) {
2885
+ let e = i.filter((e) => e.type === "edge-node-overlap").length, n = i.filter((e) => e.type === "edge-edge-crossing").length;
2886
+ t.warn(`[SWIMLANE_VALIDATE] ${i.length} issue(s) detected: ${e} edge-node overlap(s), ${n} edge crossing(s)`);
2887
+ for (let e of i) t.warn(`[SWIMLANE_VALIDATE] ${e.type}: ${e.detail}`);
2888
+ }
2889
+ return i;
2890
+ }
2891
+ e(gt, "validateSwimlanesLayout");
2892
+ function _t(t, n) {
2893
+ let r = t.nodes ?? [], i = t.edges ?? [], a = r.filter((e) => !e.isGroup);
2894
+ if ((n === "LR" || n === "RL") && a.length > 0 && !Re(t, n) || n === "BT" && a.length > 0 && !Le(t)) return;
2895
+ for (let e of i) {
2896
+ if (e.isLayoutOnly) continue;
2897
+ let t = e.points;
2898
+ !t || t.length < 2 || (e.points = G(W(t)));
2899
+ }
2900
+ nt(i, r), pt(i, r), He(i, r);
2901
+ let o = /* @__PURE__ */ new Map();
2902
+ for (let e of r) o.set(String(e.id), e);
2903
+ ct(i, o), q(i, o), Ue(i, o), mt(i, o), Ge(i, o), Ke(i, o), qe(i, o), Xe(i, o);
2904
+ let s = /* @__PURE__ */ e(() => {
2905
+ $e(i, o), Ze(i, o), Qe(i, o), ct(i, o), ke(i, o), qe(i, o), ct(i, o), ke(i, o);
2906
+ }, "finalizeRenderedEdges");
2907
+ s(), mt(i, o), s(), Je(i, o), Ye(i, o), Je(i, o), Ye(i, o);
2908
+ }
2909
+ e(_t, "postProcessSwimlaneLayout");
2910
+ function vt(e) {
2911
+ let t = new Map(e.nodeById), n = /* @__PURE__ */ new Set(), r = [];
2912
+ for (let i of e.edges) {
2913
+ if (!t.has(i.src) || !t.has(i.dst)) continue;
2914
+ let e = `${i.id}:${i.src}->${i.dst}`;
2915
+ n.has(e) || (n.add(e), r.push(i));
2916
+ }
2917
+ return {
2918
+ nodes: [...t.keys()],
2919
+ edges: r,
2920
+ layout: e.layout,
2921
+ nodeById: t
2922
+ };
2923
+ }
2924
+ e(vt, "normalizeGraph");
2925
+ function yt(e, t) {
2926
+ return e.edges.filter((e) => e.dst === t);
2927
+ }
2928
+ e(yt, "incoming");
2929
+ function bt(e) {
2930
+ let t = /* @__PURE__ */ new Map();
2931
+ for (let n of e.nodes) t.set(n, []);
2932
+ for (let n of e.edges) t.get(n.src).push(n.dst);
2933
+ return t;
2934
+ }
2935
+ e(bt, "buildSuccessorMap");
2936
+ function xt(e) {
2937
+ let t = bt(e);
2938
+ for (let e of t.values()) e.sort((e, t) => e.localeCompare(t));
2939
+ return t;
2940
+ }
2941
+ e(xt, "buildSortedSuccessorMap");
2942
+ function St(e) {
2943
+ let t = /* @__PURE__ */ new Map();
2944
+ for (let n of e.nodes) t.set(n, 0);
2945
+ for (let n of e.edges) t.set(n.dst, (t.get(n.dst) ?? 0) + 1);
2946
+ return t;
2947
+ }
2948
+ e(St, "buildInDegreeMap");
2949
+ function Ct(e) {
2950
+ return [...e.entries()].filter(([, e]) => e === 0).map(([e]) => e).sort((e, t) => e.localeCompare(t));
2951
+ }
2952
+ e(Ct, "sortedZeroInDegreeNodes");
2953
+ function wt(e, t = () => !0) {
2954
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
2955
+ for (let t of e.nodes) n.set(t, []), r.set(t, []);
2956
+ for (let i of e.edges) t(i) && (r.get(i.src).push(i.dst), n.get(i.dst).push(i.src));
2957
+ return {
2958
+ preds: n,
2959
+ succs: r
2960
+ };
2961
+ }
2962
+ e(wt, "buildPredecessorSuccessorMaps");
2963
+ function Tt(e, t, n, r) {
2964
+ let i = 0;
2965
+ for (let t of e.nodes) r?.skipGroups && e.nodeById.get(t)?.isGroup || (i = Math.max(i, n[t] ?? 0));
2966
+ let a = Array.from({ length: i + 1 }, () => []);
2967
+ for (let i of t) r?.skipGroups && e.nodeById.get(i)?.isGroup || a[Math.max(0, n[i] ?? 0)].push(i);
2968
+ return a;
2969
+ }
2970
+ e(Tt, "buildLayersFromRanks");
2971
+ function Et(e) {
2972
+ let t = St(e), n = Ct(t), r = [], i = xt(e);
2973
+ for (; n.length;) {
2974
+ let e = n.shift();
2975
+ r.push(e);
2976
+ for (let r of i.get(e) ?? []) if (t.set(r, (t.get(r) ?? 0) - 1), (t.get(r) ?? 0) === 0) {
2977
+ let e = 0;
2978
+ for (; e < n.length && n[e] < r;) e++;
2979
+ n.splice(e, 0, r);
2980
+ }
2981
+ }
2982
+ return r.length === e.nodes.length ? r : null;
2983
+ }
2984
+ e(Et, "topoSortIfAcyclic");
2985
+ function Dt(e) {
2986
+ let t = /* @__PURE__ */ new Map(), n = 0;
2987
+ for (let r of e) t.set(r, n), n++;
2988
+ return t;
2989
+ }
2990
+ e(Dt, "buildLayerIndex");
2991
+ function Ot(t) {
2992
+ let n = Array(t.length), r = /* @__PURE__ */ e((e, i) => {
2993
+ if (i - e <= 1) return 0;
2994
+ let a = e + i >> 1, o = r(e, a) + r(a, i), s = e, c = a, l = e;
2995
+ for (; s < a || c < i;) c >= i || s < a && t[s] <= t[c] ? n[l++] = t[s++] : (n[l++] = t[c++], o += a - s);
2996
+ for (let r = e; r < i; r++) t[r] = n[r];
2997
+ return o;
2998
+ }, "count");
2999
+ return r(0, t.length);
3000
+ }
3001
+ e(Ot, "countInversions");
3002
+ function kt(t) {
3003
+ let n = vt(t), r = /* @__PURE__ */ new Map();
3004
+ for (let e of n.nodes) r.set(e, []);
3005
+ for (let e of n.edges) r.get(e.src).push(e);
3006
+ for (let e of r.values()) e.sort((e, t) => e.dst === t.dst ? e.id.localeCompare(t.id) : e.dst.localeCompare(t.dst));
3007
+ let i = /* @__PURE__ */ Object.create(null);
3008
+ for (let e of n.nodes) i[e] = 0;
3009
+ let a = [], o = /* @__PURE__ */ e((e) => {
3010
+ i[e] = 1;
3011
+ for (let t of r.get(e) ?? []) {
3012
+ let e = t.dst;
3013
+ i[e] === 0 ? o(e) : i[e] === 1 && a.push(t);
3014
+ }
3015
+ i[e] = 2;
3016
+ }, "dfs"), s = St(n), c = [...n.nodes.filter((e) => (s.get(e) ?? 0) === 0), ...n.nodes.filter((e) => (s.get(e) ?? 0) !== 0)];
3017
+ for (let e of c) i[e] === 0 && o(e);
3018
+ let l = new Set(a.map((e) => `${e.id}:${e.src}->${e.dst}`)), u = n.edges.map((e) => l.has(`${e.id}:${e.src}->${e.dst}`) ? {
3019
+ id: e.id,
3020
+ src: e.dst,
3021
+ dst: e.src,
3022
+ weight: e.weight,
3023
+ ref: e.ref
3024
+ } : e);
3025
+ return {
3026
+ acyclic: {
3027
+ nodes: [...n.nodes],
3028
+ edges: u,
3029
+ layout: n.layout,
3030
+ nodeById: new Map(n.nodeById)
3031
+ },
3032
+ reversed: a
3033
+ };
3034
+ }
3035
+ e(kt, "removeCycles_DFS");
3036
+ function At(t) {
3037
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ e((e) => {
3038
+ if (n.has(e)) return n.get(e);
3039
+ let i = t.nodeById.get(e);
3040
+ if (!i) return n.set(e, null), null;
3041
+ let a = i.parentId;
3042
+ if (!a) return n.set(e, null), null;
3043
+ let o = r(a) ?? a;
3044
+ return n.set(e, o), o;
3045
+ }, "resolve");
3046
+ for (let e of t.nodes) r(e);
3047
+ return n;
3048
+ }
3049
+ e(At, "buildTopLaneMap");
3050
+ function jt(e) {
3051
+ let t = At(e);
3052
+ return (e) => t.get(e) ?? null;
3053
+ }
3054
+ e(jt, "createTopLaneResolver");
3055
+ function Mt(e) {
3056
+ let t = [];
3057
+ for (let n of e.layout.nodes ?? []) n.isGroup && !n.parentId && t.push(n.id);
3058
+ return [...new Set(t)].reverse();
3059
+ }
3060
+ e(Mt, "buildTopLaneOrder");
3061
+ function Nt(e, t) {
3062
+ let n = Mt(e);
3063
+ if (!t || t.length === 0) return n;
3064
+ let r = new Set(n), i = /* @__PURE__ */ new Set(), a = [];
3065
+ for (let e of t) !r.has(e) || i.has(e) || (i.add(e), a.push(e));
3066
+ for (let e of n) i.has(e) || a.push(e);
3067
+ return a;
3068
+ }
3069
+ e(Nt, "resolveTopLaneOrder");
3070
+ var Pt = { EPSILON: 1e-6 }, Ft = {
3071
+ GRAVITY_ITERATIONS: 8,
3072
+ MAX_CROSSING_OPTIMIZATION_PASSES: 4,
3073
+ DEFAULT_COMPACT_SINGLE_INPUT: !0
3074
+ }, It = {
3075
+ DEFAULT_LAYER_GAP: 100,
3076
+ DEFAULT_NODE_GAP: 40
3077
+ };
3078
+ function Lt(t, n) {
3079
+ let r = vt(t), i = n?.laneOf ?? (() => null), a = n?.rankHint, { preds: o } = wt(r);
3080
+ for (let e of o.values()) e.sort((e, t) => e.localeCompare(t));
3081
+ let s = Et(r) ?? [...r.nodes].sort((e, t) => e.localeCompare(t)), c = /* @__PURE__ */ new Map();
3082
+ for (let [e, t] of s.entries()) c.set(t, e);
3083
+ let l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
3084
+ for (let e of r.nodes) u.set(e, []);
3085
+ for (let e of s) {
3086
+ let t = (o.get(e) ?? []).filter((e) => l.has(e));
3087
+ if (t.length > 0) {
3088
+ let n = Rt(e, t, {
3089
+ laneOf: i,
3090
+ rankHint: a,
3091
+ topoIndex: c
3092
+ });
3093
+ l.set(e, n), u.get(n).push(e);
3094
+ } else l.has(e) || l.set(e, null);
3095
+ }
3096
+ for (let e of r.nodes) l.has(e) || l.set(e, null);
3097
+ let d = /* @__PURE__ */ new Set();
3098
+ for (let e of r.nodes) (l.get(e) ?? null) === null && d.add(e);
3099
+ let f = [...d].sort((e, t) => {
3100
+ let n = c.get(e) ?? 0, r = c.get(t) ?? 0;
3101
+ return n === r ? e.localeCompare(t) : n - r;
3102
+ }), p = zt(r), m = /* @__PURE__ */ new Map();
3103
+ for (let [e, t] of p.entries()) m.set(e, [...t].sort((e, t) => e.localeCompare(t)));
3104
+ let h = Bt(m), g = Vt(m), _ = /* @__PURE__ */ new Map();
3105
+ for (let e of r.nodes) _.set(e, []);
3106
+ for (let e of g) for (let t of e.nodes) {
3107
+ let n = _.get(t);
3108
+ n ? n.push(e.id) : _.set(t, [e.id]);
3109
+ }
3110
+ let v = [], y = [], b = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ e((e) => {
3111
+ if (!b.has(e)) {
3112
+ b.add(e), v.push(e);
3113
+ for (let t of u.get(e) ?? []) x(t);
3114
+ y.push(e);
3115
+ }
3116
+ }, "walk");
3117
+ for (let e of f) x(e);
3118
+ for (let e of s) x(e);
3119
+ return {
3120
+ parent: l,
3121
+ children: u,
3122
+ roots: f,
3123
+ componentOf: h,
3124
+ blocks: g,
3125
+ nodeBlocks: _,
3126
+ adjacency: m,
3127
+ preorder: v,
3128
+ postorder: y,
3129
+ topologicalOrder: s
3130
+ };
3131
+ }
3132
+ e(Lt, "buildDrivingTree");
3133
+ function Rt(e, t, n) {
3134
+ let r = n.laneOf(e);
3135
+ return [...t].sort((e, t) => {
3136
+ let i = n.laneOf(e), a = n.laneOf(t), o = i != null && i === r;
3137
+ if (o !== (a != null && a === r)) return o ? -1 : 1;
3138
+ let s = n.rankHint?.[e], c = n.rankHint?.[t];
3139
+ if (s != null && c != null && s !== c) return c - s;
3140
+ let l = n.topoIndex.get(e) ?? 0, u = n.topoIndex.get(t) ?? 0;
3141
+ return l === u ? e.localeCompare(t) : l - u;
3142
+ })[0];
3143
+ }
3144
+ e(Rt, "chooseParent");
3145
+ function zt(e) {
3146
+ let t = /* @__PURE__ */ new Map();
3147
+ for (let n of e.nodes) t.set(n, /* @__PURE__ */ new Set());
3148
+ for (let n of e.edges) t.get(n.src).add(n.dst), t.get(n.dst).add(n.src);
3149
+ return t;
3150
+ }
3151
+ e(zt, "buildAdjacency");
3152
+ function Bt(e) {
3153
+ let t = /* @__PURE__ */ new Map(), n = 0;
3154
+ for (let r of e.keys()) {
3155
+ if (t.has(r)) continue;
3156
+ let i = [r];
3157
+ for (; i.length > 0;) {
3158
+ let r = i.pop();
3159
+ if (!t.has(r)) {
3160
+ t.set(r, n);
3161
+ for (let n of e.get(r) ?? []) t.has(n) || i.push(n);
3162
+ }
3163
+ }
3164
+ n++;
3165
+ }
3166
+ return t;
3167
+ }
3168
+ e(Bt, "assignComponents");
3169
+ function Vt(t) {
3170
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [], a = [], o = 0, s = /* @__PURE__ */ e((e, c) => {
3171
+ n.set(e, ++o), r.set(e, o);
3172
+ for (let l of t.get(e) ?? []) l !== c && (n.has(l) ? (n.get(l) ?? 0) < (n.get(e) ?? 0) && (i.push([e, l]), r.set(e, Math.min(r.get(e) ?? o, n.get(l) ?? o))) : (i.push([e, l]), s(l, e), r.set(e, Math.min(r.get(e) ?? o, r.get(l) ?? o)), (r.get(l) ?? 0) >= (n.get(e) ?? 0) && a.push(Ht(e, l, i, a.length))));
3173
+ }, "visit");
3174
+ for (let e of t.keys()) n.has(e) || s(e, null);
3175
+ return a;
3176
+ }
3177
+ e(Vt, "computeBlocks");
3178
+ function Ht(e, t, n, r) {
3179
+ let i = [], a = /* @__PURE__ */ new Set();
3180
+ for (; n.length > 0;) {
3181
+ let r = n.pop();
3182
+ if (i.push(r), a.add(r[0]), a.add(r[1]), r[0] === e && r[1] === t || r[0] === t && r[1] === e) break;
3183
+ }
3184
+ return {
3185
+ id: r,
3186
+ edges: i,
3187
+ nodes: [...a]
3188
+ };
3189
+ }
3190
+ e(Ht, "popBlock");
3191
+ function Ut(t, n, r) {
3192
+ let i = [...t.nodes], a = /* @__PURE__ */ new Map();
3193
+ for (let [e, t] of i.entries()) a.set(t, e);
3194
+ let o = i.length, s = Array(o).fill(-1), c = Array(o).fill(0), l = [], u = /* @__PURE__ */ new Set();
3195
+ for (let e of i) {
3196
+ let t = r.parent.get(e) ?? null, n = a.get(e);
3197
+ n != null && (t ?? (s[n] = -1, c[n] = 0, u.has(e) || (u.add(e), l.push(e))));
3198
+ }
3199
+ for (; l.length > 0;) {
3200
+ let e = l.shift(), t = a.get(e);
3201
+ if (t == null) continue;
3202
+ let n = r.children.get(e) ?? [];
3203
+ for (let e of n) {
3204
+ if (u.has(e)) continue;
3205
+ let n = a.get(e);
3206
+ n != null && (s[n] = t, c[n] = c[t] + 1, u.add(e), l.push(e));
3207
+ }
3208
+ }
3209
+ for (let e of i) {
3210
+ if (u.has(e)) continue;
3211
+ let t = a.get(e);
3212
+ t != null && (s[t] = -1, c[t] = 0, u.add(e));
3213
+ }
3214
+ let d = Math.max(1, Math.ceil(Math.log2(Math.max(1, o))) + 1), f = Array.from({ length: d }, () => Array(o).fill(-1));
3215
+ for (let e = 0; e < o; e++) f[0][e] = s[e];
3216
+ for (let e = 1; e < d; e++) for (let t = 0; t < o; t++) {
3217
+ let n = f[e - 1][t];
3218
+ f[e][t] = n === -1 ? -1 : f[e - 1][n];
3219
+ }
3220
+ let p = /* @__PURE__ */ e((e, t) => {
3221
+ if (e === -1 || t === -1) return -1;
3222
+ c[e] < c[t] && ([e, t] = [t, e]);
3223
+ let n = c[e] - c[t];
3224
+ for (let t = 0; t < d; t++) if (n >> t & 1 && (e = f[t][e], e === -1)) return -1;
3225
+ if (e === t) return e;
3226
+ for (let n = d - 1; n >= 0; n--) {
3227
+ let r = f[n][e], i = f[n][t];
3228
+ r === -1 || i === -1 || r !== i && (e = r, t = i);
3229
+ }
3230
+ return f[0][e];
3231
+ }, "lcaIndex"), m = Array.from({ length: o }, () => /* @__PURE__ */ new Map());
3232
+ for (let e of t.edges) {
3233
+ let t = e.src, r = e.dst, i = n[t], o = n[r];
3234
+ if (i == null || o == null || (i > o && ([t, r] = [r, t], [i, o] = [o, i]), i == null || o == null || i === o)) continue;
3235
+ let s = a.get(t), c = a.get(r);
3236
+ if (s == null || c == null) continue;
3237
+ let l = p(s, c);
3238
+ if (l === -1) continue;
3239
+ let u = m[l];
3240
+ for (let e = i; e < o; e++) u.set(e, (u.get(e) ?? 0) + 1);
3241
+ }
3242
+ let h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ e((e, t) => {
3243
+ if (t.size !== 0) for (let [n, r] of t) e.set(n, (e.get(n) ?? 0) + r);
3244
+ }, "mergeInto"), _ = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ e((e) => {
3245
+ let t = a.get(e);
3246
+ _.add(e);
3247
+ let i = t == null ? void 0 : m[t], o = i ? new Map(i) : /* @__PURE__ */ new Map(), s = r.children.get(e) ?? [];
3248
+ for (let t of s) {
3249
+ let r = v(t), i = n[e];
3250
+ if (i != null) {
3251
+ let a = h.get(e);
3252
+ a || (a = /* @__PURE__ */ new Map(), h.set(e, a));
3253
+ let o = r.get(i) ?? 0, s = n[t];
3254
+ s != null && s > i && (o += 1), a.set(t, o);
3255
+ }
3256
+ g(o, r);
3257
+ }
3258
+ return o;
3259
+ }, "dfs");
3260
+ for (let e of r.roots) _.has(e) || v(e);
3261
+ for (let e of i) _.has(e) || v(e);
3262
+ return h;
3263
+ }
3264
+ e(Ut, "computeSubtreeCrossCounts");
3265
+ function Wt(t, n, r) {
3266
+ let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ e((e) => {
3267
+ let t = r[e] ?? 0, o = [...n.get(e) ?? []];
3268
+ o.sort(Gt(r));
3269
+ for (let e of o) {
3270
+ a(e);
3271
+ let n = i.get(e);
3272
+ n != null && (t = Math.min(t, n));
3273
+ }
3274
+ i.set(e, t);
3275
+ }, "annotate");
3276
+ for (let e of t) a(e);
3277
+ return i;
3278
+ }
3279
+ e(Wt, "annotateMinimumLayers");
3280
+ function Gt(e) {
3281
+ return (t, n) => {
3282
+ let r = e[t] ?? 0, i = e[n] ?? 0;
3283
+ return r === i ? t.localeCompare(n) : r - i;
3284
+ };
3285
+ }
3286
+ e(Gt, "compareByRankThenId");
3287
+ function Kt(t, n, r, i) {
3288
+ let a = 0;
3289
+ for (let e of n) {
3290
+ let t = r[e] ?? 0;
3291
+ t > a && (a = t);
3292
+ }
3293
+ let o = Array.from({ length: a + 1 }, () => []), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ e((e) => {
3294
+ if (s.has(e)) return;
3295
+ s.add(e);
3296
+ let t = r[e] ?? 0;
3297
+ o[t] || (o[t] = []), o[t].push(e);
3298
+ for (let t of i(e)) c(t);
3299
+ }, "emit");
3300
+ for (let e of t) c(e);
3301
+ for (let e of n) if (!s.has(e)) {
3302
+ let t = r[e] ?? 0;
3303
+ o[t] || (o[t] = []), o[t].push(e), s.add(e);
3304
+ }
3305
+ return o;
3306
+ }
3307
+ e(Kt, "emitNodesInTreeOrder");
3308
+ function qt(e) {
3309
+ let t = [];
3310
+ for (let n of e) {
3311
+ let e = /* @__PURE__ */ new Set(), r = [];
3312
+ for (let t of n) e.has(t) || (e.add(t), r.push(t));
3313
+ t.push(r);
3314
+ }
3315
+ return t;
3316
+ }
3317
+ e(qt, "deduplicateLayers");
3318
+ function Jt(e, t, n, r) {
3319
+ return (i) => {
3320
+ let a = e.get(i) ?? [];
3321
+ if (a.length === 0) return [];
3322
+ let o = t[i] ?? 0, s = [], c = [], l = n.get(i);
3323
+ for (let e of a) {
3324
+ let t = r.get(e) ?? o;
3325
+ t > o ? s.push({
3326
+ child: e,
3327
+ min: t
3328
+ }) : c.push(e);
3329
+ }
3330
+ return s.sort((e, t) => e.min === t.min ? e.child.localeCompare(t.child) : e.min - t.min), c.sort((e, t) => {
3331
+ let n = l?.get(e) ?? 0, i = l?.get(t) ?? 0;
3332
+ if (n !== i) return n - i;
3333
+ let a = r.get(e) ?? o, s = r.get(t) ?? o;
3334
+ return a === s ? e.localeCompare(t) : a - s;
3335
+ }), [...s.map((e) => e.child), ...c];
3336
+ };
3337
+ }
3338
+ e(Jt, "createChildOrderer");
3339
+ function Yt(e, t, n) {
3340
+ let r = Lt(e, {
3341
+ rankHint: t,
3342
+ laneOf: n
3343
+ }), { children: i, roots: a } = r;
3344
+ for (let t of e.nodes) i.has(t) || i.set(t, []);
3345
+ let o = Ut(e, t, r), s = [...a].sort(Gt(t)), c = Jt(i, t, o, Wt(s, i, t)), l = Kt(s, e.nodes, t, c);
3346
+ return l = qt(l), l;
3347
+ }
3348
+ e(Yt, "buildMultitreeLayerOrder");
3349
+ function Xt(e, t, n) {
3350
+ let r = new Set(e), i = new Set(t), a = Dt(t), o = [];
3351
+ for (let e of n) r.has(e.src) && i.has(e.dst) && o.push(a.get(e.dst));
3352
+ return Ot(o);
3353
+ }
3354
+ e(Xt, "countCrossingsBetweenAdjacent");
3355
+ function Zt(e, t, n) {
3356
+ let r = [];
3357
+ for (let e of t) {
3358
+ let t = n[e.src], i = n[e.dst];
3359
+ if (t == null || i == null || t === i) continue;
3360
+ let a = e.src, o = e.dst, s = t, c = i;
3361
+ t > i && (a = e.dst, o = e.src, s = i, c = t);
3362
+ for (let t = s; t < c; t++) r.push({
3363
+ id: `${e.id}@${t}`,
3364
+ src: a,
3365
+ dst: o,
3366
+ ref: e.ref
3367
+ });
3368
+ }
3369
+ let i = 0;
3370
+ for (let t = 0; t + 1 < e.length; t++) i += Xt(e[t], e[t + 1], r);
3371
+ return i;
3372
+ }
3373
+ e(Zt, "totalCrossings");
3374
+ function Qt(e, t) {
3375
+ let n = { ...t }, { preds: r } = wt(e), i = jt(e), a = Zt(Yt(e, n, i), e.edges, n), o = Ft.MAX_CROSSING_OPTIMIZATION_PASSES;
3376
+ for (let t = 0; t < o; t++) {
3377
+ let t = !1, o = [...e.nodes].sort((e, t) => (n[t] ?? 0) - (n[e] ?? 0));
3378
+ for (let s of o) {
3379
+ let o = n[s] ?? 0;
3380
+ if (o === 0) continue;
3381
+ let c = 0;
3382
+ for (let e of r.get(s) ?? []) c = Math.max(c, (n[e] ?? 0) + 1);
3383
+ if (c >= o) continue;
3384
+ let l = o;
3385
+ n[s] = c;
3386
+ let u = Zt(Yt(e, n, i), e.edges, n);
3387
+ u < a ? (a = u, t = !0) : n[s] = l;
3388
+ }
3389
+ if (!t) break;
3390
+ }
3391
+ return n;
3392
+ }
3393
+ e(Qt, "optimizeRanksByCrossings");
3394
+ function $t(e, t) {
3395
+ let n = jt(e), r = [...e.nodes].sort((e, n) => (t[e] ?? 0) - (t[n] ?? 0) || e.localeCompare(n));
3396
+ for (let i of r) {
3397
+ let r = n(i);
3398
+ if (!r) continue;
3399
+ let a = e.edges.filter((e) => e.src === i);
3400
+ if (a.length === 0) continue;
3401
+ let o = !1, s = 0;
3402
+ for (let e of a) {
3403
+ let t = n(e.dst);
3404
+ t == null || t === r ? o = !0 : s++;
3405
+ }
3406
+ if (s === 0 || o) continue;
3407
+ let c = 0, l = !1;
3408
+ for (let t of e.edges) {
3409
+ if (t.dst !== i) continue;
3410
+ let e = n(t.src);
3411
+ e && (e === r ? l = !0 : c++);
3412
+ }
3413
+ if (c > 0 || !l) continue;
3414
+ let u = t[i] ?? 0, d = u + s, f = 0;
3415
+ for (let n of e.edges) n.dst === i && (f = Math.max(f, (t[n.src] ?? 0) + 1));
3416
+ let p = Math.max(u, f, d);
3417
+ p !== u && (t[i] = p);
3418
+ }
3419
+ }
3420
+ e($t, "adjustCrossLaneSources");
3421
+ function en(e, t) {
3422
+ let n = vt(e), r = Et(n) ?? [...n.nodes].sort(), i = t?.compactSingleInput ?? !1, a = jt(n), o = /* @__PURE__ */ Object.create(null);
3423
+ for (let e of r) {
3424
+ let r = yt(n, e), s = t?.ignoreCrossLaneEdges ? r.filter((t) => {
3425
+ let n = a(t.src), r = a(e);
3426
+ return !n || !r || n === r;
3427
+ }) : r;
3428
+ if (s.length === 0) o[e] = 0;
3429
+ else if (i && s.length === 1) {
3430
+ let t = s[0].src;
3431
+ a(t) === a(e) ? o[e] = (o[t] ?? 0) + 1 : o[e] = o[t] ?? 0;
3432
+ } else {
3433
+ let t = -Infinity;
3434
+ for (let e of s) t = Math.max(t, (o[e.src] ?? 0) + 1);
3435
+ o[e] = t === -Infinity ? 0 : t;
3436
+ }
3437
+ }
3438
+ return (t?.optimizeRanksByCrossings ?? !1) && (o = Qt(n, o)), t?.ignoreCrossLaneEdges && $t(n, o), {
3439
+ layers: Yt(n, o, a),
3440
+ rankOf: o,
3441
+ dummy: /* @__PURE__ */ new Set()
3442
+ };
3443
+ }
3444
+ e(en, "assignLayers_LongestPath");
3445
+ function tn(t, n) {
3446
+ let r = vt(t), i = { ...en(r, {
3447
+ compactSingleInput: n?.compactSingleInput,
3448
+ ignoreCrossLaneEdges: n?.ignoreCrossLaneEdges,
3449
+ optimizeRanksByCrossings: n?.optimizeRanksByCrossings
3450
+ }).rankOf }, a = jt(r), { preds: o, succs: s } = wt(r, (e) => {
3451
+ if (n?.ignoreCrossLaneEdges) {
3452
+ let t = a(e.src), n = a(e.dst);
3453
+ if (t && n && t !== n) return !1;
3454
+ }
3455
+ return !0;
3456
+ }), c = Et(r) ?? [...r.nodes], l = [...c].reverse(), u = /* @__PURE__ */ e((e, t) => {
3457
+ let n = 0;
3458
+ for (let t of o.get(e) ?? []) n = Math.max(n, (i[t] ?? 0) + 1);
3459
+ let r = Infinity, a = s.get(e) ?? [];
3460
+ return a.length > 0 && (r = Math.min(...a.map((e) => (i[e] ?? 0) - 1))), Number.isFinite(r) || (r = Math.max(n, t)), Math.min(Math.max(t, n), r);
3461
+ }, "clampFeasible"), d = Ft.GRAVITY_ITERATIONS, f = /* @__PURE__ */ e((e) => {
3462
+ let t = !1;
3463
+ for (let n of e) {
3464
+ let e = o.get(n) ?? [], r = s.get(n) ?? [];
3465
+ if (e.length === 0 && r.length === 0) continue;
3466
+ let a = e.length > 0 ? e.reduce((e, t) => e + (i[t] ?? 0) + 1, 0) / e.length : i[n] ?? 0, c = r.length > 0 ? r.reduce((e, t) => e + (i[t] ?? 0) - 1, 0) / r.length : i[n] ?? 0, l = Math.round((a + c) / 2), d = u(n, l);
3467
+ d !== i[n] && (i[n] = d, t = !0);
3468
+ }
3469
+ return t;
3470
+ }, "relaxOrder");
3471
+ for (let e = 0; e < d; e++) {
3472
+ let e = f(c), t = f(l);
3473
+ if (!e && !t) break;
3474
+ }
3475
+ for (let e of c) {
3476
+ let t = 0;
3477
+ for (let n of o.get(e) ?? []) t = Math.max(t, (i[n] ?? 0) + 1);
3478
+ (i[e] ?? 0) < t && (i[e] = t);
3479
+ }
3480
+ for (let e of l) {
3481
+ let t = s.get(e) ?? [];
3482
+ if (t.length > 0) {
3483
+ let n = Math.min(...t.map((e) => (i[e] ?? 0) - 1));
3484
+ (i[e] ?? 0) > n && (i[e] = n);
3485
+ }
3486
+ }
3487
+ return {
3488
+ layers: Tt(r, c, i),
3489
+ rankOf: i,
3490
+ dummy: /* @__PURE__ */ new Set()
3491
+ };
3492
+ }
3493
+ e(tn, "assignLayers_Gravity");
3494
+ function nn(e) {
3495
+ let t = St(e), n = xt(e), r = Ct(t), i = [];
3496
+ for (; r.length > 0;) {
3497
+ let e = [];
3498
+ for (let a of r) {
3499
+ i.push(a);
3500
+ for (let r of n.get(a) ?? []) t.set(r, (t.get(r) ?? 0) - 1), (t.get(r) ?? 0) === 0 && e.push(r);
3501
+ }
3502
+ r = e.sort((e, t) => e.localeCompare(t));
3503
+ }
3504
+ return i.length === e.nodes.length ? i : null;
3505
+ }
3506
+ e(nn, "topoSortByGenerationIfAcyclic");
3507
+ function rn(t, n) {
3508
+ let r = vt(t), i = n?.direction === "LR" ? nn(r) ?? [...r.nodes].sort() : Et(r) ?? [...r.nodes].sort(), a = jt(r), o = /* @__PURE__ */ e((e) => a(e) ?? e, "laneOf"), s = /* @__PURE__ */ Object.create(null), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ e((e, t) => n?.ignoreCrossLaneEdges ?? !0 ? +(o(e) === o(t)) : 1, "edgeWeight");
3509
+ for (let e of i) {
3510
+ if (r.nodeById.get(e)?.isGroup) continue;
3511
+ let t = yt(r, e), n = 0;
3512
+ if (t.length > 0) for (let r of t) {
3513
+ let t = r.src, i = s[t] ?? 0;
3514
+ n = Math.max(n, i + l(t, e));
3515
+ }
3516
+ let i = o(e), a = c.get(i) ?? 0, u = Math.max(n, a);
3517
+ s[e] = u, c.set(i, u + 1);
3518
+ }
3519
+ return {
3520
+ layers: Tt(r, i, s, { skipGroups: !0 }),
3521
+ rankOf: s,
3522
+ dummy: /* @__PURE__ */ new Set()
3523
+ };
3524
+ }
3525
+ e(rn, "assignLayers_LaneAwareCompact");
3526
+ function an(t, n) {
3527
+ let r = vt(n), { rankOf: i } = t, a = t.layers.map((e) => [...e]), o = new Set(t.dummy ? [...t.dummy] : []), s = 0, c = new Map(r.nodeById), l = /* @__PURE__ */ e((e) => {
3528
+ let t = `placeholder-${s++}`, n = {
3529
+ id: t,
3530
+ isGroup: !1,
3531
+ isDummy: !0,
3532
+ width: 0,
3533
+ height: 0
3534
+ };
3535
+ for (c.set(t, n), o.add(t); a.length <= e;) a.push([]);
3536
+ return a[e].push(t), i[t] = e, t;
3537
+ }, "addDummyAt"), u = [...r.edges].sort((e, t) => e.id === t.id ? e.src === t.src ? e.dst.localeCompare(t.dst) : e.src.localeCompare(t.src) : e.id.localeCompare(t.id)), d = [];
3538
+ for (let e of u) {
3539
+ let t = i[e.src] ?? 0, n = i[e.dst] ?? 0;
3540
+ if (n - t <= 1) {
3541
+ d.push(e);
3542
+ continue;
3543
+ }
3544
+ let r = e.src;
3545
+ for (let i = t + 1, a = 0; i < n; i++, a++) {
3546
+ let t = l(i);
3547
+ d.push({
3548
+ id: `${e.id}#${a}`,
3549
+ src: r,
3550
+ dst: t,
3551
+ weight: e.weight,
3552
+ ref: e.ref
3553
+ }), r = t;
3554
+ }
3555
+ let a = n - t - 2;
3556
+ d.push({
3557
+ id: `${e.id}#${Math.max(a + 1, 0)}`,
3558
+ src: r,
3559
+ dst: e.dst,
3560
+ weight: e.weight,
3561
+ ref: e.ref
3562
+ });
3563
+ }
3564
+ let f = {
3565
+ nodes: [...r.nodes, ...[...o].filter((e) => !r.nodes.includes(e))],
3566
+ edges: d,
3567
+ layout: r.layout,
3568
+ nodeById: c
3569
+ };
3570
+ return {
3571
+ layering: {
3572
+ layers: a,
3573
+ rankOf: i,
3574
+ dummy: o
3575
+ },
3576
+ graphWithDummies: f
3577
+ };
3578
+ }
3579
+ e(an, "makeProperLayering");
3580
+ function on(e) {
3581
+ let t = e.length;
3582
+ if (t === 0) return Infinity;
3583
+ let n = [...e].sort((e, t) => e - t);
3584
+ return t % 2 == 1 ? n[(t - 1) / 2] : .5 * (n[t / 2 - 1] + n[t / 2]);
3585
+ }
3586
+ e(on, "median");
3587
+ function sn(e) {
3588
+ return e.length === 0 ? Infinity : e.reduce((e, t) => e + t, 0) / e.length;
3589
+ }
3590
+ e(sn, "barycenter");
3591
+ function cn(e, t, n, r) {
3592
+ let i = /* @__PURE__ */ new Map();
3593
+ for (let t of e) i.set(t, []);
3594
+ for (let e of n) r === "down" ? t.has(e.src) && i.has(e.dst) && i.get(e.dst).push(t.get(e.src)) : t.has(e.dst) && i.has(e.src) && i.get(e.src).push(t.get(e.dst));
3595
+ return i;
3596
+ }
3597
+ e(cn, "neighborPositionsFor");
3598
+ function ln(e, t, n) {
3599
+ let r = n.get(e) ?? 0, i = n.get(t) ?? 0;
3600
+ return r === i ? e.localeCompare(t) : r - i;
3601
+ }
3602
+ e(ln, "currentOrderTieBreak");
3603
+ function un(e, t, n) {
3604
+ let r = new Set(e), i = new Set(t), a = Dt(e), o = Dt(t), s = [];
3605
+ for (let e of n) r.has(e.src) && i.has(e.dst) && s.push({
3606
+ u: a.get(e.src),
3607
+ v: o.get(e.dst)
3608
+ });
3609
+ return s.sort((e, t) => e.u === t.u ? e.v - t.v : e.u - t.u), Ot(s.map((e) => e.v));
3610
+ }
3611
+ e(un, "countCrossingsBetweenAdjacent");
3612
+ function dn(e, t, n) {
3613
+ return [...e].sort((e, r) => {
3614
+ let i = on(t.get(e) ?? []), a = on(t.get(r) ?? []);
3615
+ return i === a ? ln(e, r, n) : isFinite(i) ? isFinite(a) ? i - a : -1 : 1;
3616
+ });
3617
+ }
3618
+ e(dn, "sortByHeuristic");
3619
+ function fn(e, t, n, r, i, a) {
3620
+ let o = Dt(e), s = Dt(t), c = cn(t, o, n, r);
3621
+ if (!i || !a || a.length === 0) return dn(t, c, s);
3622
+ let l = /* @__PURE__ */ new Map();
3623
+ for (let e of t) {
3624
+ let t = i(e), n = l.get(t) ?? [];
3625
+ n.push(e), l.set(t, n);
3626
+ }
3627
+ let u = [];
3628
+ for (let e of a) {
3629
+ let t = l.get(e);
3630
+ if (!t || t.length === 0) continue;
3631
+ let n = dn(t, c, s);
3632
+ u.push(...n);
3633
+ }
3634
+ let d = l.get(null);
3635
+ if (d && d.length > 0) {
3636
+ let e = dn(d, c, s);
3637
+ for (let t of e) {
3638
+ let e = sn(c.get(t) ?? []), n = u.length;
3639
+ if (isFinite(e)) {
3640
+ for (let [t, r] of u.entries()) if (e < sn(c.get(r) ?? [])) {
3641
+ n = t;
3642
+ break;
3643
+ }
3644
+ }
3645
+ u.splice(n, 0, t);
3646
+ }
3647
+ }
3648
+ return u;
3649
+ }
3650
+ e(fn, "reorderLayer");
3651
+ function pn(t, n, r, i, a) {
3652
+ let o = [...n], s = new Set(t), c = new Set(n), l = i ? new Set(i) : null, u = r.filter((e) => s.has(e.src) && c.has(e.dst)), d = l ? r.filter((e) => c.has(e.src) && l.has(e.dst)) : void 0, f = /* @__PURE__ */ e((e) => {
3653
+ let n = un(t, e, u);
3654
+ return d && i && (n += un(e, i, d)), n;
3655
+ }, "crossingScore"), p = a ? /* @__PURE__ */ new Map() : null;
3656
+ if (a && p) for (let e of n) p.set(e, a(e));
3657
+ let m = !0, h = f(o);
3658
+ for (; m;) {
3659
+ m = !1;
3660
+ for (let e = 0; e + 1 < o.length; e++) {
3661
+ if (p && p.get(o[e]) !== p.get(o[e + 1])) continue;
3662
+ let t = h;
3663
+ [o[e], o[e + 1]] = [o[e + 1], o[e]];
3664
+ let n = f(o);
3665
+ n < t ? (h = n, m = !0) : [o[e], o[e + 1]] = [o[e + 1], o[e]];
3666
+ }
3667
+ }
3668
+ return o;
3669
+ }
3670
+ e(pn, "transposeImprove");
3671
+ function mn(e, t, n) {
3672
+ let r = e.layers.map((e) => [...e]), i = t.edges, a = jt(t), o = Nt(t, n?.laneOrder);
3673
+ for (let e = 0; e < 3; e++) {
3674
+ for (let e = 1; e < r.length; e++) r[e] = fn(r[e - 1], r[e], i, "down", a, o), r[e] = pn(r[e - 1], r[e], i, r[e + 1], a);
3675
+ for (let e = r.length - 2; e >= 0; e--) r[e] = fn(r[e + 1], r[e], i, "up", a, o), r[e] = pn(r[e + 1], r[e], i, r[e - 1], a);
3676
+ }
3677
+ return { layers: r };
3678
+ }
3679
+ e(mn, "orderLayers");
3680
+ function hn(t, n, r) {
3681
+ let i = r?.layerGap ?? It.DEFAULT_LAYER_GAP, a = r?.nodeGap ?? It.DEFAULT_NODE_GAP, o = r?.laneGap ?? a * 2, s = r?.direction ?? "TB", c = s === "LR" || s === "RL", l = t.layers, u = /* @__PURE__ */ Object.create(null), d = /* @__PURE__ */ Object.create(null), f = /* @__PURE__ */ e((e) => n.nodeById.get(e), "getNode"), p = /* @__PURE__ */ e((e) => f(e)?.width ?? 0, "getWidth"), m = /* @__PURE__ */ e((e) => f(e)?.height ?? 0, "getHeight"), h = jt(n), g = Nt(n, r?.laneOrder), _ = l.map((e) => e.reduce((e, t) => Math.max(e, m(t)), 0)), v = [];
3682
+ if (c) for (let e = 0; e + 1 < l.length; e++) {
3683
+ let t = l[e].reduce((e, t) => Math.max(e, p(t)), 0), n = l[e + 1].reduce((e, t) => Math.max(e, p(t)), 0), r = _[e], a = _[e + 1], o = r / 2 + a / 2, s = (t + n) / 2, c = Math.max(0, s - o - i);
3684
+ v.push(c);
3685
+ }
3686
+ let y = /* @__PURE__ */ new Set();
3687
+ for (let e of l) for (let t of e) y.add(h(t));
3688
+ let b = y.has(null), x = g.filter((e) => y.has(e)), S = [...b ? [null] : [], ...x], C = /* @__PURE__ */ Object.create(null);
3689
+ for (let e of x) C[e] = 0;
3690
+ b && (C.null = 0);
3691
+ for (let e of l) {
3692
+ let t = /* @__PURE__ */ Object.create(null), n = [];
3693
+ for (let r of e) {
3694
+ let e = h(r);
3695
+ e === null ? n.push(r) : (t[e] ||= []).push(r);
3696
+ }
3697
+ for (let [e, n] of Object.entries(t)) {
3698
+ let t = n.reduce((e, t) => e + p(t), 0) + a * Math.max(0, n.length - 1);
3699
+ C[e] = Math.max(C[e] ?? 0, t);
3700
+ }
3701
+ if (b && n.length) {
3702
+ let e = n.reduce((e, t) => e + p(t), 0) + a * Math.max(0, n.length - 1);
3703
+ C.null = Math.max(C.null ?? 0, e);
3704
+ }
3705
+ }
3706
+ let w = /* @__PURE__ */ new Map();
3707
+ {
3708
+ let e = S.map((e) => (e === null ? C.null : C[e]) ?? 0), t = -(e.reduce((e, t) => e + t, 0) + o * Math.max(0, S.length - 1)) / 2;
3709
+ for (let n = 0; n < S.length; n++) {
3710
+ let r = S[n], i = e[n] ?? 0, a = t + i / 2;
3711
+ w.set(r, a), t += i, n < S.length - 1 && (t += o);
3712
+ }
3713
+ }
3714
+ let T = 0;
3715
+ for (let [e, t] of l.entries()) {
3716
+ let n = _[e] ?? 0, r = /* @__PURE__ */ new Map();
3717
+ for (let e of t) {
3718
+ let t = h(e), n = r.get(t) ?? [];
3719
+ n.push(e), r.set(t, n);
3720
+ }
3721
+ for (let e of S) {
3722
+ let t = r.get(e) ?? [];
3723
+ if (t.length === 0) continue;
3724
+ let i = w.get(e);
3725
+ if (t.length === 1) {
3726
+ let e = t[0];
3727
+ u[e] = i, d[e] = T + n / 2;
3728
+ } else {
3729
+ let e = t.map((e) => p(e)), r = i - (e.reduce((e, t) => e + t, 0) + a * (t.length - 1)) / 2;
3730
+ for (let [i, o] of t.entries()) {
3731
+ let t = e[i];
3732
+ u[o] = r + t / 2, d[o] = T + n / 2, r += t + a;
3733
+ }
3734
+ }
3735
+ }
3736
+ let o = v[e] ?? 0;
3737
+ T += n + i + o;
3738
+ }
3739
+ let E = /* @__PURE__ */ new Map();
3740
+ for (let e of n.edges) {
3741
+ let t = e.ref.id;
3742
+ E.has(t) || E.set(t, []), E.get(t).push(e);
3743
+ }
3744
+ for (let [, e] of E) {
3745
+ if (e.length === 0) continue;
3746
+ let t = e[0].ref, r = t.start, i = t.end;
3747
+ if (r == null || i == null) continue;
3748
+ let a = Math.round(((u[r] ?? 0) + (u[i] ?? 0)) / 2), o = /* @__PURE__ */ new Set();
3749
+ for (let t of e) o.add(t.src), o.add(t.dst);
3750
+ for (let e of o) e === r || e === i || n.nodeById.get(e)?.isDummy && (u[e] = a);
3751
+ }
3752
+ return {
3753
+ x: u,
3754
+ y: d
3755
+ };
3756
+ }
3757
+ e(hn, "assignCoordinates");
3758
+ var gn = 8;
3759
+ function _n(e) {
3760
+ let t = 2166136261;
3761
+ for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
3762
+ return t >>> 0;
3763
+ }
3764
+ e(_n, "hashString");
3765
+ function vn(e) {
3766
+ let t = e >>> 0;
3767
+ return () => {
3768
+ t += 1831565813;
3769
+ let e = t;
3770
+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
3771
+ };
3772
+ }
3773
+ e(vn, "mulberry32");
3774
+ function yn(e, t) {
3775
+ let n = [...e], r = vn(t);
3776
+ for (let e = n.length - 1; e > 0; e--) {
3777
+ let t = Math.floor(r() * (e + 1));
3778
+ [n[e], n[t]] = [n[t], n[e]];
3779
+ }
3780
+ return n;
3781
+ }
3782
+ e(yn, "deterministicShuffle");
3783
+ function bn(e, t) {
3784
+ let n = 0;
3785
+ for (let [r, i] of e.entries()) n += Math.abs(r - (t.get(i) ?? r));
3786
+ return n;
3787
+ }
3788
+ e(bn, "sourceDistance");
3789
+ function xn(e, t) {
3790
+ let n = /* @__PURE__ */ new Map();
3791
+ for (let [t, r] of e.entries()) n.set(r, t);
3792
+ let r = 0;
3793
+ for (let { a: e, b: i, weight: a } of t) {
3794
+ let t = n.get(e), o = n.get(i);
3795
+ t == null || o == null || (r += a * Math.abs(t - o));
3796
+ }
3797
+ return r;
3798
+ }
3799
+ e(xn, "laneArrangementCost");
3800
+ function Sn(e) {
3801
+ let t = Mt(e);
3802
+ if (t.length < 2) return [];
3803
+ let n = new Map(t.map((e, t) => [e, t])), r = jt(e), i = /* @__PURE__ */ new Map();
3804
+ for (let t of e.layout.edges ?? []) {
3805
+ if (t.isLayoutOnly) continue;
3806
+ let a = typeof t.start == "string" ? t.start : void 0, o = typeof t.end == "string" ? t.end : void 0;
3807
+ if (!a || !o || !e.nodeById.has(a) || !e.nodeById.has(o)) continue;
3808
+ let s = r(a), c = r(o);
3809
+ if (!s || !c || s === c) continue;
3810
+ let l = n.get(s), u = n.get(c);
3811
+ if (l == null || u == null) continue;
3812
+ let [d, f] = l <= u ? [s, c] : [c, s], p = `${d}\0${f}`, m = i.get(p);
3813
+ m ? m.weight++ : i.set(p, {
3814
+ a: d,
3815
+ b: f,
3816
+ weight: 1
3817
+ });
3818
+ }
3819
+ return [...i.values()];
3820
+ }
3821
+ e(Sn, "buildWeightedLaneEdges");
3822
+ function Cn(e, t, n) {
3823
+ let r = [...e], i = xn(r, t), a = !0, o = 0, s = Math.max(1, r.length);
3824
+ for (; a && o < s;) {
3825
+ a = !1, o++;
3826
+ for (let e = 0; e + 1 < r.length; e++) {
3827
+ [r[e], r[e + 1]] = [r[e + 1], r[e]];
3828
+ let n = xn(r, t);
3829
+ n < i ? (i = n, a = !0) : [r[e], r[e + 1]] = [r[e + 1], r[e]];
3830
+ }
3831
+ }
3832
+ return {
3833
+ order: r,
3834
+ cost: i,
3835
+ sourceDistance: bn(r, n)
3836
+ };
3837
+ }
3838
+ e(Cn, "greedySwitch");
3839
+ function wn(e, t) {
3840
+ return e.cost === t.cost ? e.sourceDistance < t.sourceDistance : e.cost < t.cost;
3841
+ }
3842
+ e(wn, "isBetterCandidate");
3843
+ function Tn(e, t, n) {
3844
+ let r = [...t].sort((e, t) => e.a === t.a ? e.b.localeCompare(t.b) : e.a.localeCompare(t.a)).map(({ a: e, b: t, weight: n }) => `${e}:${t}:${n}`).join("|");
3845
+ return _n(`${e.join("|")}#${r}#${n}`);
3846
+ }
3847
+ e(Tn, "seedForRestart");
3848
+ function En(e, t = {}) {
3849
+ let n = Mt(e);
3850
+ if (n.length < 2) return n;
3851
+ let r = Sn(e);
3852
+ if (r.length === 0) return n;
3853
+ let i = new Map(n.map((e, t) => [e, t])), a = Cn(n, r, i), o = Math.max(0, t.restarts ?? gn);
3854
+ for (let e = 0; e < o; e++) {
3855
+ let t = Cn(yn(n, Tn(n, r, e)), r, i);
3856
+ wn(t, a) && (a = t);
3857
+ }
3858
+ return a.order;
3859
+ }
3860
+ e(En, "optimizeTopLaneOrder");
3861
+ function Dn(e, t) {
3862
+ let n = t?.ignoreCrossLaneEdges ?? !0, r = t?.optimizeRanksByCrossings ?? !0, i = vt(e), a = t?.automaticLaneOrdering ? En(i, { restarts: gn }) : void 0, o = kt(i), s = o.acyclic, { layering: c, graphWithDummies: l } = an(n ? rn(s, {
3863
+ compactSingleInput: t?.compactSingleInput ?? Ft.DEFAULT_COMPACT_SINGLE_INPUT,
3864
+ ignoreCrossLaneEdges: !0,
3865
+ direction: t?.direction
3866
+ }) : tn(s, {
3867
+ compactSingleInput: t?.compactSingleInput ?? Ft.DEFAULT_COMPACT_SINGLE_INPUT,
3868
+ ignoreCrossLaneEdges: !1,
3869
+ optimizeRanksByCrossings: r
3870
+ }), s), u = mn(c, l, { laneOrder: a }), d = hn(u, l, {
3871
+ layerGap: t?.layerGap,
3872
+ nodeGap: t?.nodeGap,
3873
+ direction: t?.direction,
3874
+ laneOrder: a
3875
+ });
3876
+ return {
3877
+ acyclic: s,
3878
+ reversed: o.reversed,
3879
+ layering: c,
3880
+ ordered: u,
3881
+ coordinates: d
3882
+ };
3883
+ }
3884
+ e(Dn, "sugiyamaLayout");
3885
+ var $ = Pt.EPSILON, On = 8, kn = 15, An = 15, jn = 25, Mn = 20, Nn = 10;
3886
+ function Pn(e, t, n) {
3887
+ let r = e.x ?? 0, i = e.y ?? 0, a = t.x - r, o = t.y - i, s = Math.abs(a), c = Math.abs(o);
3888
+ return s < $ && c < $ ? n : c > $ && c * 3 >= s ? o > 0 ? "bottom" : "top" : s > $ ? a > 0 ? "right" : "left" : n;
3889
+ }
3890
+ e(Pn, "chooseOrthogonalSide");
3891
+ function Fn(e, t) {
3892
+ return Math.abs(e.to - t.from) < $ || Math.abs(e.to - t.to) < $ ? e.to : e.from;
3893
+ }
3894
+ e(Fn, "sharedLineEndpointCoord");
3895
+ function In(e, t) {
3896
+ return e.orient === "vertical" ? {
3897
+ x: e.coord,
3898
+ y: t
3899
+ } : {
3900
+ x: t,
3901
+ y: e.coord
3902
+ };
3903
+ }
3904
+ e(In, "pointOnLine");
3905
+ function Ln(t, n) {
3906
+ let r = t.nodes ?? [], i = t.edges ?? [], a = [];
3907
+ for (let e of i) e.isLayoutOnly || a.push({
3908
+ ...e,
3909
+ __originalEdge: e
3910
+ });
3911
+ let o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = [], l = n === "LR";
3912
+ for (let e of r) o.set(e.id, e);
3913
+ let u = r.filter((e) => e.isGroup && !e.parentId);
3914
+ for (let t of u) {
3915
+ let n = { id: t.id }, i = /* @__PURE__ */ e((e) => {
3916
+ s.set(e.id, n), r.filter((t) => t.parentId === e.id).forEach(i);
3917
+ }, "assignLane");
3918
+ i(t);
3919
+ }
3920
+ let d = r.filter((e) => !e.isGroup && !e.isEdgeLabel).map((e) => {
3921
+ let t = e.width ?? 10, n = e.height ?? 10, r = e.x ?? 0, i = e.y ?? 0, a = On;
3922
+ return {
3923
+ nodeId: e.id,
3924
+ minX: r - t / 2 - a,
3925
+ maxX: r + t / 2 + a,
3926
+ minY: i - n / 2 - a,
3927
+ maxY: i + n / 2 + a,
3928
+ visualXHalfExtent: l ? n / 2 + a : t / 2 + a
3929
+ };
3930
+ }), f = /* @__PURE__ */ e((e, t, n, r) => {
3931
+ let i = c.find((n) => n.orientation === e && Math.abs(n.coord - t) < 1);
3932
+ return i || (i = {
3933
+ id: `pipe-${e}-${t.toFixed(0)}`,
3934
+ orientation: e,
3935
+ coord: t,
3936
+ spanMin: n,
3937
+ spanMax: r,
3938
+ tracks: []
3939
+ }, c.push(i)), i.spanMin = Math.min(i.spanMin, n), i.spanMax = Math.max(i.spanMax, r), i;
3940
+ }, "getOrAddPipe"), p = /* @__PURE__ */ e((e, t) => {
3941
+ let n = e.width ?? 10, r = e.height ?? 10, i = e.x ?? 0, a = e.y ?? 0;
3942
+ switch (t) {
3943
+ case "top": return {
3944
+ x: i,
3945
+ y: a - r / 2
3946
+ };
3947
+ case "bottom": return {
3948
+ x: i,
3949
+ y: a + r / 2
3950
+ };
3951
+ case "left": return {
3952
+ x: i - n / 2,
3953
+ y: a
3954
+ };
3955
+ case "right": return {
3956
+ x: i + n / 2,
3957
+ y: a
3958
+ };
3959
+ }
3960
+ }, "portForSide"), m = /* @__PURE__ */ e((e, t, n) => p(e, Pn(e, t, n ? "bottom" : "top")), "getOrthogonalPort"), h = [], g = [], _ = /* @__PURE__ */ new Set(), v = 1e3, y = /* @__PURE__ */ e((e, t, n) => {
3961
+ if (h.length === 0) return 0;
3962
+ let r = Math.abs(t.y - n.y) < $, i = Math.abs(t.x - n.x) < $;
3963
+ if (!r && !i) return 0;
3964
+ let a = 0;
3965
+ if (r) {
3966
+ let r = t.y, i = Math.min(t.x, n.x) - $, o = Math.max(t.x, n.x) + $;
3967
+ if (o <= i) return 0;
3968
+ for (let t of h) t.edgeIndex === e || t.orientation !== "vertical" || t.pipe.coord < i || t.pipe.coord > o || t.from - $ <= r && t.to + $ >= r && (a += v);
3969
+ } else if (i) {
3970
+ let r = t.x, i = Math.min(t.y, n.y) - $, o = Math.max(t.y, n.y) + $;
3971
+ if (o <= i) return 0;
3972
+ for (let t of h) t.edgeIndex === e || t.orientation !== "horizontal" || t.pipe.coord < i || t.pipe.coord > o || t.from - $ <= r && t.to + $ >= r && (a += v);
3973
+ }
3974
+ return a;
3975
+ }, "crossingPenalty"), b = a.map((e, t) => {
3976
+ if (!e.start || !e.end) return {
3977
+ idx: t,
3978
+ crossLane: 0,
3979
+ dx: 0,
3980
+ dy: 0
3981
+ };
3982
+ let n = o.get(e.start), r = o.get(e.end), i = s.get(e.start), a = s.get(e.end);
3983
+ return {
3984
+ idx: t,
3985
+ crossLane: i && a && i.id !== a.id ? 1 : 0,
3986
+ dx: n && r ? Math.abs((r.x ?? 0) - (n.x ?? 0)) : 0,
3987
+ dy: n && r ? Math.abs((r.y ?? 0) - (n.y ?? 0)) : 0
3988
+ };
3989
+ }).sort((e, t) => {
3990
+ if (e.crossLane !== t.crossLane) return t.crossLane - e.crossLane;
3991
+ let n = e.dx + e.dy, r = t.dx + t.dy;
3992
+ return Math.abs(n - r) > 1 ? n - r : e.idx - t.idx;
3993
+ }).map((e) => e.idx), x = /* @__PURE__ */ e((e, t, n, r) => {
3994
+ let i = Math.min(e.x, t.x), a = Math.max(e.x, t.x), o = Math.min(e.y, t.y), s = Math.max(e.y, t.y);
3995
+ return !!d.find((c) => n && c.nodeId === n || r && c.nodeId === r ? !1 : Math.abs(e.x - t.x) > $ ? c.minY < e.y && c.maxY > e.y && c.maxX > i && c.minX < a : c.minX < e.x && c.maxX > e.x && c.maxY > o && c.minY < s);
3996
+ }, "isSegmentBlocked"), S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
3997
+ for (let e of a) !e.start || !e.end || e.start === e.end || (C.set(e.start, (C.get(e.start) ?? 0) + 1), C.set(e.end, (C.get(e.end) ?? 0) + 1));
3998
+ let w = /* @__PURE__ */ e((e, t) => Pn(e, t, "bottom"), "determineSide"), T = /* @__PURE__ */ new Map();
3999
+ for (let [e, t] of a.entries()) {
4000
+ if (!t.start || !t.end || t.start === t.end || t.points && t.points.length > 0) continue;
4001
+ let n = o.get(t.start), r = o.get(t.end);
4002
+ if (!n || !r) continue;
4003
+ let i = (r.x ?? 0) - (n.x ?? 0), a = (r.y ?? 0) - (n.y ?? 0);
4004
+ T.set(e, {
4005
+ edgeIdx: e,
4006
+ srcId: t.start,
4007
+ dstId: t.end,
4008
+ srcSide: w(n, {
4009
+ x: r.x ?? 0,
4010
+ y: r.y ?? 0
4011
+ }),
4012
+ dstSide: w(r, {
4013
+ x: n.x ?? 0,
4014
+ y: n.y ?? 0
4015
+ }),
4016
+ absDx: Math.abs(i),
4017
+ absDy: Math.abs(a),
4018
+ dxSign: Math.sign(i),
4019
+ dySign: Math.sign(a)
4020
+ });
4021
+ }
4022
+ let E = /* @__PURE__ */ e((e) => e.srcSide === "top" || e.srcSide === "bottom" ? e.absDx === 0 ? Infinity : e.absDy / e.absDx : e.absDy === 0 ? Infinity : e.absDx / e.absDy, "preferenceStrength"), D = /* @__PURE__ */ e((e) => e.srcSide === "top" || e.srcSide === "bottom" ? e.dxSign >= 0 ? "right" : "left" : e.dySign >= 0 ? "bottom" : "top", "secondarySide"), O = /* @__PURE__ */ new Map();
4023
+ for (let e of T.values()) {
4024
+ let t = `${e.srcId}:${e.srcSide}`;
4025
+ O.has(t) || O.set(t, []), O.get(t).push(e);
4026
+ }
4027
+ let k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ e((e, t) => `${e}:${t}`, "loadKey");
4028
+ for (let e of T.values()) k.set(A(e.srcId, e.srcSide), (k.get(A(e.srcId, e.srcSide)) ?? 0) + 1), k.set(A(e.dstId, e.dstSide), (k.get(A(e.dstId, e.dstSide)) ?? 0) + 1);
4029
+ for (let e of O.values()) if (!(e.length < 2)) {
4030
+ e.sort((e, t) => {
4031
+ let n = E(e), r = E(t);
4032
+ return Math.abs(n - r) > 1e-9 ? r - n : e.edgeIdx - t.edgeIdx;
4033
+ });
4034
+ for (let t = 1; t < e.length; t++) {
4035
+ let n = e[t], r = D(n), i = k.get(A(n.srcId, n.srcSide)) ?? 0, a = k.get(A(n.srcId, r)) ?? 0;
4036
+ a >= i || (k.set(A(n.srcId, n.srcSide), i - 1), k.set(A(n.srcId, r), a + 1), n.srcSide = r);
4037
+ }
4038
+ }
4039
+ let j = /* @__PURE__ */ e((e) => {
4040
+ let t = e?.shape;
4041
+ return t === "question" || t === "diamond";
4042
+ }, "isDiamondNode"), M = /* @__PURE__ */ new Map();
4043
+ for (let e of T.values()) M.has(e.dstId) || M.set(e.dstId, /* @__PURE__ */ new Set()), M.get(e.dstId).add(e.dstSide);
4044
+ for (let e of T.values()) {
4045
+ if (!j(o.get(e.srcId))) continue;
4046
+ let t = M.get(e.srcId);
4047
+ if (!t?.has(e.srcSide)) continue;
4048
+ let n = D(e);
4049
+ if (t.has(n) || (k.get(A(e.srcId, n)) ?? 0) > 0) continue;
4050
+ let r = k.get(A(e.srcId, e.srcSide)) ?? 0;
4051
+ k.set(A(e.srcId, e.srcSide), Math.max(0, r - 1)), k.set(A(e.srcId, n), 1), e.srcSide = n;
4052
+ }
4053
+ for (let e of T.values()) {
4054
+ let { edgeIdx: t, srcId: n, dstId: r, srcSide: i, dstSide: a } = e, s = o.get(n), c = o.get(r), l = `${n}:${i}:src`, u = i === "top" || i === "bottom" ? c.x ?? 0 : c.y ?? 0;
4055
+ S.has(l) || S.set(l, []), S.get(l).push({
4056
+ edgeIdx: t,
4057
+ oppositeCoord: u
4058
+ });
4059
+ let d = `${r}:${a}:dst`, f = a === "top" || a === "bottom" ? s.x ?? 0 : s.y ?? 0;
4060
+ S.has(d) || S.set(d, []), S.get(d).push({
4061
+ edgeIdx: t,
4062
+ oppositeCoord: f
4063
+ });
4064
+ }
4065
+ let N = /* @__PURE__ */ new Map();
4066
+ for (let [e, t] of S) {
4067
+ if (t.length < 2) continue;
4068
+ t.sort((e, t) => e.oppositeCoord - t.oppositeCoord);
4069
+ let n = e.split(":"), r = n.slice(0, -2).join(":"), i = n[n.length - 2], a = n[n.length - 1], s = o.get(r);
4070
+ if (!s) continue;
4071
+ let c = i === "left" || i === "right" ? s.height ?? 10 : s.width ?? 10, l = s.shape, u = l === "question" || l === "diamond" ? c * .3 : c, d = Math.min(20, Math.max(8, u / (t.length + 1))), f = -(d * (t.length - 1)) / 2;
4072
+ for (let [e, n] of t.entries()) {
4073
+ let t = f + e * d, r = `${n.edgeIdx}:${a}`;
4074
+ N.set(r, t);
4075
+ }
4076
+ }
4077
+ let P = /* @__PURE__ */ e((e) => !!a[e]?.labelNodeId, "edgeHasLabelNode"), F = /* @__PURE__ */ e((e, t) => e ? (S.get(`${e}:${t}:src`) ?? []).some(({ edgeIdx: e }) => P(e)) || (S.get(`${e}:${t}:dst`) ?? []).some(({ edgeIdx: e }) => P(e)) : !1, "faceHasLabelNode"), I = /* @__PURE__ */ e((e, t, n) => t === "top" || t === "bottom" ? {
4078
+ x: e.x + n,
4079
+ y: e.y
4080
+ } : {
4081
+ x: e.x,
4082
+ y: e.y + n
4083
+ }, "applyPortOffset"), ee = /* @__PURE__ */ e((e, t, n) => {
4084
+ let r = T.get(e), i = {
4085
+ x: n.x ?? 0,
4086
+ y: n.y ?? 0
4087
+ }, a = {
4088
+ x: t.x ?? 0,
4089
+ y: t.y ?? 0
4090
+ }, o = r?.srcSide ?? w(t, i), s = r?.dstSide ?? w(n, a), c = r ? p(t, r.srcSide) : m(t, i, !0), l = r ? p(n, r.dstSide) : m(n, a, !1), u = N.get(`${e}:src`), d = N.get(`${e}:dst`);
4091
+ return u !== void 0 && (c = I(c, o, u)), d !== void 0 && (l = I(l, s, d)), {
4092
+ pSrcPort: c,
4093
+ pDstPort: l,
4094
+ srcSide: o,
4095
+ dstSide: s
4096
+ };
4097
+ }, "portsForEdge");
4098
+ for (let t of b) {
4099
+ let n = a[t];
4100
+ if (g[t] = [], !n.start || !n.end || n.points && n.points.length > 0 || n.start === n.end) continue;
4101
+ let r = o.get(n.start), i = o.get(n.end);
4102
+ if (!r || !i) continue;
4103
+ let { pSrcPort: s, pDstPort: u, srcSide: p, dstSide: m } = ee(t, r, i), v = { ...s }, b = { ...u }, w = p === "top" || p === "bottom", T = m === "top" || m === "bottom";
4104
+ w ? v.y = s.y > (r.y ?? 0) ? s.y + Mn : s.y - Mn : v.x = s.x > (r.x ?? 0) ? s.x + Mn : s.x - Mn, T ? b.y = u.y > (i.y ?? 0) ? u.y + Mn : u.y - Mn : b.x = u.x > (i.x ?? 0) ? u.x + Mn : u.x - Mn;
4105
+ let E = /* @__PURE__ */ e((e, t) => {
4106
+ for (let n of d) if (!t.includes(n.nodeId) && e.x > n.minX && e.x < n.maxX && e.y > n.minY && e.y < n.maxY) return {
4107
+ inside: !0,
4108
+ obstacle: n
4109
+ };
4110
+ return { inside: !1 };
4111
+ }, "isPointInObstacle"), D = /* @__PURE__ */ e((e, t, n, r, i) => {
4112
+ if (i) {
4113
+ let i = e.y > (t.y ?? 0);
4114
+ return {
4115
+ x: (n.x ?? 0) >= e.x ? r.maxX + kn : r.minX - kn,
4116
+ y: i ? r.maxY + An : r.minY - An,
4117
+ leavesPositiveSide: i
4118
+ };
4119
+ }
4120
+ let a = e.x > (t.x ?? 0), o = (n.y ?? 0) >= e.y;
4121
+ return {
4122
+ x: a ? r.maxX + kn : r.minX - kn,
4123
+ y: o ? r.maxY + An : r.minY - An,
4124
+ leavesPositiveSide: a
4125
+ };
4126
+ }, "obstacleDetour"), O = [], k = [n.start, n.end], A = E(v, k);
4127
+ if (A.inside && A.obstacle) {
4128
+ let e = A.obstacle;
4129
+ if (w) {
4130
+ let t = D(s, r, i, e, !0);
4131
+ v.x = t.x, v.y = t.y;
4132
+ let n = t.leavesPositiveSide ? Math.min(e.minY - 2, s.y + Mn) : Math.max(e.maxY + 2, s.y - Mn);
4133
+ O = [
4134
+ {
4135
+ x: s.x,
4136
+ y: n
4137
+ },
4138
+ {
4139
+ x: t.x,
4140
+ y: n
4141
+ },
4142
+ {
4143
+ x: t.x,
4144
+ y: t.y
4145
+ }
4146
+ ];
4147
+ } else {
4148
+ let t = D(s, r, i, e, !1), n = t.leavesPositiveSide ? Math.min(e.minX - 2, s.x + Mn) : Math.max(e.maxX + 2, s.x - Mn);
4149
+ v.x = t.x, v.y = t.y, O = [
4150
+ {
4151
+ x: n,
4152
+ y: s.y
4153
+ },
4154
+ {
4155
+ x: n,
4156
+ y: t.y
4157
+ },
4158
+ {
4159
+ x: t.x,
4160
+ y: t.y
4161
+ }
4162
+ ];
4163
+ }
4164
+ }
4165
+ let j = [], M = E(b, k);
4166
+ if (M.inside && M.obstacle) {
4167
+ let e = M.obstacle;
4168
+ if (T) {
4169
+ let t = D(u, i, r, e, !0);
4170
+ b.x = t.x, b.y = t.y, j = [{
4171
+ x: t.x,
4172
+ y: t.y
4173
+ }, {
4174
+ x: u.x,
4175
+ y: t.y
4176
+ }];
4177
+ } else {
4178
+ let t = D(u, i, r, e, !1);
4179
+ b.x = t.x, b.y = t.y, j = [{
4180
+ x: t.x,
4181
+ y: t.y
4182
+ }, {
4183
+ x: t.x,
4184
+ y: u.y
4185
+ }];
4186
+ }
4187
+ }
4188
+ if (O.length === 0 && j.length === 0) {
4189
+ let e = kn, r = Math.abs(v.x - b.x) < e, i = Math.abs(v.y - b.y) < e, a = N.get(`${t}:src`) !== void 0 || N.get(`${t}:dst`) !== void 0, o = (S.get(`${n.start ?? ""}:${p}:src`)?.length ?? 0) + (S.get(`${n.start ?? ""}:${p}:dst`)?.length ?? 0), c = (S.get(`${n.end ?? ""}:${m}:src`)?.length ?? 0) + (S.get(`${n.end ?? ""}:${m}:dst`)?.length ?? 0), l = o > 1 || c > 1, d = C.get(n.start ?? "") ?? 0, f = C.get(n.end ?? "") ?? 0, g = o > 1 && F(n.start, p) || c > 1 && F(n.end, m);
4190
+ if ((r || i) && !a && (!l || l && !g && (o <= 1 || d <= 2) && (c <= 1 || f <= 2)) && !x(s, u, n.start, n.end)) {
4191
+ n.points = [
4192
+ { ...s },
4193
+ { ...v },
4194
+ { ...b },
4195
+ { ...u }
4196
+ ], _.add(t);
4197
+ let e = i ? "horizontal" : "vertical", r = i ? s.y : s.x, a = i ? Math.min(s.x, u.x) : Math.min(s.y, u.y), o = i ? Math.max(s.x, u.x) : Math.max(s.y, u.y), c = {
4198
+ id: `fast-path-${e}-${r.toFixed(0)}-${t}`,
4199
+ orientation: e,
4200
+ coord: r,
4201
+ spanMin: a,
4202
+ spanMax: o,
4203
+ tracks: []
4204
+ };
4205
+ h.push({
4206
+ edgeIndex: t,
4207
+ segmentIndex: 0,
4208
+ orientation: e,
4209
+ pipe: c,
4210
+ trackIndex: 0,
4211
+ from: a,
4212
+ to: o
4213
+ });
4214
+ continue;
4215
+ }
4216
+ }
4217
+ v.x = f("vertical", v.x, v.y, v.y).coord, b.x = f("vertical", b.x, b.y, b.y).coord;
4218
+ let P = Math.min(v.x, b.x) - 50, I = Math.max(v.x, b.x) + 50, L = Math.min(v.y, b.y) - 50, R = Math.max(v.y, b.y) + 50;
4219
+ for (let e of d) {
4220
+ let t = Math.min(v.x, b.x), n = Math.max(v.x, b.x), r = Math.min(v.y, b.y), i = Math.max(v.y, b.y);
4221
+ e.minX < n && e.maxX > t && e.minY < i && e.maxY > r && (P = Math.min(P, e.minX - jn), I = Math.max(I, e.maxX + jn), L = Math.min(L, e.minY - jn), R = Math.max(R, e.maxY + jn));
4222
+ }
4223
+ for (let e of d) {
4224
+ if (e.maxX < P || e.minX > I || e.maxY < L || e.minY > R) continue;
4225
+ let t = kn;
4226
+ f("horizontal", e.minY - t, P, I), f("horizontal", e.maxY + t, P, I);
4227
+ let n = An;
4228
+ f("vertical", e.minX - n, L, R), f("vertical", e.maxX + n, L, R);
4229
+ }
4230
+ f("horizontal", v.y, P, I), f("horizontal", b.y, P, I);
4231
+ let z = c.filter((e) => e.orientation === "horizontal" && e.coord >= L && e.coord <= R), te = c.filter((e) => e.orientation === "vertical" && e.coord >= P && e.coord <= I), ne = /* @__PURE__ */ e((e, t) => `${e.toFixed(1)},${t.toFixed(1)}`, "getKey"), B = ne(v.x, v.y), re = ne(b.x, b.y), ie = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Set(), H = [];
4232
+ ie.set(B, 0), V.set(B, "n"), H.push({
4233
+ key: B,
4234
+ f: Math.hypot(b.x - v.x, b.y - v.y),
4235
+ pt: v
4236
+ }), oe.add(B);
4237
+ let U = [], W = /* @__PURE__ */ e((e, t) => x(e, t, n.start, n.end), "checkSegmentBlocked"), G = {
4238
+ x: b.x,
4239
+ y: v.y
4240
+ }, K = W(v, G), se = W(G, b), ce = K || se, le = {
4241
+ x: v.x,
4242
+ y: b.y
4243
+ }, ue = W(v, le), de = W(le, b);
4244
+ if (ce ? ue || de || (U = Math.abs(v.x - b.x) < $ ? [v, b] : [
4245
+ v,
4246
+ le,
4247
+ b
4248
+ ]) : U = Math.abs(v.y - b.y) < $ || Math.abs(v.x - b.x) < $ ? [v, b] : [
4249
+ v,
4250
+ G,
4251
+ b
4252
+ ], U.length === 0) for (; H.length > 0;) {
4253
+ H.sort((e, t) => e.f - t.f);
4254
+ let e = H.shift();
4255
+ if (oe.delete(e.key), e.key === re) {
4256
+ let e = re, t = b;
4257
+ for (U = [t]; ae.has(e);) {
4258
+ let n = ae.get(e);
4259
+ U.unshift(n), t = n, e = ne(n.x, n.y);
4260
+ }
4261
+ break;
4262
+ }
4263
+ let r = e.pt.x, i = e.pt.y, a = te.sort((e, t) => e.coord - t.coord), o = a.findIndex((e) => Math.abs(e.coord - r) < 1), s = z.sort((e, t) => e.coord - t.coord), c = s.findIndex((e) => Math.abs(e.coord - i) < 1), l = [];
4264
+ o > 0 && l.push({
4265
+ x: a[o - 1].coord,
4266
+ y: i
4267
+ }), o >= 0 && o < a.length - 1 && l.push({
4268
+ x: a[o + 1].coord,
4269
+ y: i
4270
+ }), c > 0 && l.push({
4271
+ x: r,
4272
+ y: s[c - 1].coord
4273
+ }), c >= 0 && c < s.length - 1 && l.push({
4274
+ x: r,
4275
+ y: s[c + 1].coord
4276
+ });
4277
+ for (let a of l) {
4278
+ let o = Math.min(r, a.x), s = Math.max(r, a.x), c = Math.min(i, a.y), l = Math.max(i, a.y);
4279
+ if (d.some((e) => e.nodeId === n.start || e.nodeId === n.end ? !1 : o === s ? e.minX < r && e.maxX > r && e.maxY > c && e.minY < l : e.minY < i && e.maxY > i && e.maxX > o && e.minX < s)) continue;
4280
+ let u = ne(a.x, a.y), f = Math.abs(a.x - r) + Math.abs(a.y - i), p = y(t, e.pt, a), m = 0, h = b.x - v.x, g = b.y - v.y, _ = a.x - r, x = a.y - i;
4281
+ (g > 10 && x < -5 || g < -10 && x > 5) && (m = Math.abs(x) * 100), (h > 10 && _ < -5 || h < -10 && _ > 5) && (m += Math.abs(_) * 50);
4282
+ let S = 0, C = V.get(e.key) ?? "n", w = Math.abs(_) > $ ? "h" : "v";
4283
+ C !== "n" && C !== w && (S = 50);
4284
+ let T = f + p + m + S, E = (ie.get(e.key) ?? Infinity) + T, D = Math.abs(b.x - a.x) + Math.abs(b.y - a.y);
4285
+ if (E < (ie.get(u) ?? Infinity)) if (ae.set(u, e.pt), ie.set(u, E), V.set(u, w), !oe.has(u)) H.push({
4286
+ key: u,
4287
+ f: E + D,
4288
+ pt: a
4289
+ }), oe.add(u);
4290
+ else {
4291
+ let e = H.findIndex((e) => e.key === u);
4292
+ e !== -1 && (H[e].f = E + D);
4293
+ }
4294
+ }
4295
+ }
4296
+ if (U.length === 0 && (U = [
4297
+ v,
4298
+ {
4299
+ x: v.x,
4300
+ y: b.y
4301
+ },
4302
+ b
4303
+ ]), U.length > 4) {
4304
+ let t = U[0], n = U[U.length - 1], r = Math.min(t.x, n.x), i = Math.max(t.x, n.x), a = Math.min(t.y, n.y), o = Math.max(t.y, n.y);
4305
+ for (let e of U) r = Math.min(r, e.x), i = Math.max(i, e.x), a = Math.min(a, e.y), o = Math.max(o, e.y);
4306
+ let s = i > Math.max(t.x, n.x), c = r < Math.min(t.x, n.x);
4307
+ if (l) {
4308
+ let e = An;
4309
+ if (s) {
4310
+ let r = Math.max(t.x, n.x), a = Math.min(t.y, n.y), o = Math.max(t.y, n.y), s = d.filter((e) => e.minX < r && e.maxX > r && e.minY < o && e.maxY > a);
4311
+ if (s.length > 0) {
4312
+ let r = Math.max(t.x, n.x);
4313
+ for (let t of s) {
4314
+ let n = (t.minX + t.maxX) / 2;
4315
+ if (t.visualXHalfExtent === void 0 || isNaN(t.visualXHalfExtent)) continue;
4316
+ let i = n + t.visualXHalfExtent + e;
4317
+ r = Math.max(r, i);
4318
+ }
4319
+ isNaN(r) || (i = r);
4320
+ }
4321
+ }
4322
+ if (c) {
4323
+ let i = d.filter((r) => r.minX < Math.min(t.x, n.x) + e && r.minY < Math.max(t.y, n.y) && r.maxY > Math.min(t.y, n.y));
4324
+ if (i.length > 0) {
4325
+ let a = Math.min(t.x, n.x);
4326
+ for (let t of i) {
4327
+ let n = (t.minX + t.maxX) / 2 - t.visualXHalfExtent - e;
4328
+ a = Math.min(a, n);
4329
+ }
4330
+ r = a;
4331
+ }
4332
+ }
4333
+ }
4334
+ let u = /* @__PURE__ */ e((e) => {
4335
+ let r = n.y > t.y, i = d.filter((e) => {
4336
+ let r = Math.min(t.x, n.x) < e.maxX && Math.max(t.x, n.x) > e.minX, i = Math.min(t.y, n.y) < e.maxY && Math.max(t.y, n.y) > e.minY;
4337
+ return r && i;
4338
+ }), a = i;
4339
+ if (l && i.length > 0) {
4340
+ let t = i.filter((t) => t.minX < e && t.maxX > e);
4341
+ t.length > 0 && (a = t);
4342
+ }
4343
+ if (a.length === 0) return n.y;
4344
+ let o = kn;
4345
+ if (r) {
4346
+ let e = Math.max(...a.map((e) => e.maxY)) + o;
4347
+ if (e < n.y - $) return e;
4348
+ } else {
4349
+ let e = Math.min(...a.map((e) => e.minY)) - o;
4350
+ if (e > n.y + $) return e;
4351
+ }
4352
+ return n.y;
4353
+ }, "findBestReturnY"), f = /* @__PURE__ */ e((e) => {
4354
+ let r = u(e), i = {
4355
+ x: e,
4356
+ y: t.y
4357
+ }, a = {
4358
+ x: e,
4359
+ y: r
4360
+ }, o = {
4361
+ x: n.x,
4362
+ y: r
4363
+ }, s = W(t, i), c = W(i, a), l = W(a, o), d = r !== n.y && W(o, n);
4364
+ return !s && !c && !l && !d ? Math.abs(r - n.y) < $ ? [
4365
+ t,
4366
+ i,
4367
+ a,
4368
+ n
4369
+ ] : [
4370
+ t,
4371
+ i,
4372
+ a,
4373
+ o,
4374
+ n
4375
+ ] : null;
4376
+ }, "trySimplifyWithDetourX"), p = s && !c ? f(i) : c && !s ? f(r) : null;
4377
+ p && (U = p);
4378
+ }
4379
+ let q = [
4380
+ s,
4381
+ ...O,
4382
+ ...U,
4383
+ ...j.reverse(),
4384
+ u
4385
+ ];
4386
+ if (q.length >= 3) {
4387
+ let e = q[q.length - 1], t = q[q.length - 2], n = q[q.length - 3], r = Math.abs(n.y - t.y) < $ && Math.abs(t.y - e.y) < $, i = Math.abs(n.x - t.x) < $ && Math.abs(t.x - e.x) < $;
4388
+ if (r) {
4389
+ let r = Math.sign(t.x - n.x), i = Math.sign(e.x - n.x);
4390
+ r !== 0 && r === i && Math.abs(t.x - n.x) > Math.abs(e.x - n.x) && q.splice(-2, 1);
4391
+ } else if (i) {
4392
+ let r = Math.sign(t.y - n.y), i = Math.sign(e.y - n.y);
4393
+ r !== 0 && r === i && Math.abs(t.y - n.y) > Math.abs(e.y - n.y) && q.splice(-2, 1);
4394
+ }
4395
+ }
4396
+ let J = [q[0]];
4397
+ for (let e = 1; e < q.length - 1; e++) {
4398
+ if (e === 1) {
4399
+ J.push(q[e]);
4400
+ continue;
4401
+ }
4402
+ let t = J[J.length - 1], n = q[e], r = q[e + 1];
4403
+ if (Math.abs(t.y - n.y) < $ && Math.abs(n.y - r.y) < $) {
4404
+ if (n.x > t.x != r.x > n.x) {
4405
+ J.push(n);
4406
+ continue;
4407
+ }
4408
+ continue;
4409
+ }
4410
+ if (Math.abs(t.x - n.x) < $ && Math.abs(n.x - r.x) < $) {
4411
+ if (n.y > t.y != r.y > n.y) {
4412
+ J.push(n);
4413
+ continue;
4414
+ }
4415
+ continue;
4416
+ }
4417
+ J.push(n);
4418
+ }
4419
+ J.push(q[q.length - 1]);
4420
+ for (let e = 0; e < J.length - 1; e++) {
4421
+ let n = J[e], r = J[e + 1], i = Math.abs(n.x - r.x) < $ ? "vertical" : "horizontal", a = i === "vertical" ? n.x : n.y, o = i === "vertical" ? Math.min(n.y, r.y) : Math.min(n.x, r.x), s = i === "vertical" ? Math.max(n.y, r.y) : Math.max(n.x, r.x), c = f(i, a, o, s), l = {
4422
+ edgeIndex: t,
4423
+ segmentIndex: e,
4424
+ orientation: i,
4425
+ pipe: c,
4426
+ trackIndex: 0,
4427
+ from: o,
4428
+ to: s
4429
+ };
4430
+ h.push(l), g[t].push(h.length - 1), c.tracks[0] || (c.tracks[0] = {
4431
+ index: 0,
4432
+ coord: c.coord,
4433
+ segments: []
4434
+ }), c.tracks[0].segments.push({
4435
+ edgeIndex: t,
4436
+ segmentIndex: e,
4437
+ from: o,
4438
+ to: s
4439
+ });
4440
+ }
4441
+ }
4442
+ let L = /* @__PURE__ */ e((e, t) => e.from < t.to && t.from < e.to, "segmentsOverlap"), R = /* @__PURE__ */ e((e, t, n, r) => {
4443
+ let i = !r.segments.some((n) => (n.edgeIndex !== t.edgeIndex || n.segmentIndex !== t.segmentIndex) && L(n, e)), a = !n.segments.some((n) => (n.edgeIndex !== e.edgeIndex || n.segmentIndex !== e.segmentIndex) && L(n, t));
4444
+ return i && a ? (e.trackIndex = r.index, t.trackIndex = n.index, n.segments = [...n.segments.filter((t) => t.edgeIndex !== e.edgeIndex || t.segmentIndex !== e.segmentIndex), {
4445
+ edgeIndex: t.edgeIndex,
4446
+ segmentIndex: t.segmentIndex,
4447
+ from: t.from,
4448
+ to: t.to
4449
+ }], r.segments = [...r.segments.filter((e) => e.edgeIndex !== t.edgeIndex || e.segmentIndex !== t.segmentIndex), {
4450
+ edgeIndex: e.edgeIndex,
4451
+ segmentIndex: e.segmentIndex,
4452
+ from: e.from,
4453
+ to: e.to
4454
+ }], !0) : !1;
4455
+ }, "trySwapSegmentsAcrossTracks"), z = /* @__PURE__ */ e((e) => {
4456
+ let t = e.tracks.length;
4457
+ return e.tracks[t] = {
4458
+ index: t,
4459
+ coord: e.coord,
4460
+ segments: []
4461
+ }, t;
4462
+ }, "createNewTrack"), te = /* @__PURE__ */ e((e, t) => {
4463
+ let n = e.pipe.tracks[e.trackIndex];
4464
+ n.segments = n.segments.filter((t) => t.edgeIndex !== e.edgeIndex || t.segmentIndex !== e.segmentIndex), e.trackIndex = t, e.pipe.tracks[t].segments.push({
4465
+ edgeIndex: e.edgeIndex,
4466
+ segmentIndex: e.segmentIndex,
4467
+ from: e.from,
4468
+ to: e.to
4469
+ });
4470
+ }, "moveSegmentToTrack"), ne = /* @__PURE__ */ e((e, t) => {
4471
+ let n = g[e.edgeIndex];
4472
+ for (let r of n) {
4473
+ let n = h[r];
4474
+ n.pipe === e.pipe && te(n, t);
4475
+ }
4476
+ }, "moveSegmentChainToTrack"), B = /* @__PURE__ */ e((e) => {
4477
+ let t = g[e.edgeIndex], n = t.indexOf(h.indexOf(e)), r = [];
4478
+ return n > 0 && r.push(h[t[n - 1]]), n < t.length - 1 && r.push(h[t[n + 1]]), r;
4479
+ }, "getAdjacentSegmentsAlongEdge"), re = /* @__PURE__ */ e((e, t) => {
4480
+ if (e.orientation === t.orientation) return !1;
4481
+ let n = e.orientation === "horizontal" ? e : t, r = e.orientation === "horizontal" ? t : e;
4482
+ return r.pipe.coord > n.from && r.pipe.coord < n.to && n.pipe.coord > r.from && n.pipe.coord < r.to;
4483
+ }, "haveAnyCrossing"), ie = /* @__PURE__ */ e((e, t) => {
4484
+ for (let n of e.tracks) if (!n.segments.some((e) => (e.edgeIndex !== t.edgeIndex || e.segmentIndex !== t.segmentIndex) && L(e, t))) return n.index;
4485
+ return -1;
4486
+ }, "findAvailableTrack"), ae = /* @__PURE__ */ e((e, t) => {
4487
+ if (e.trackIndex === t.trackIndex) return L(e, t);
4488
+ let n = B(e), r = B(t);
4489
+ return n.some((e) => r.some((t) => re(e, t)));
4490
+ }, "segmentsConflict"), V = /* @__PURE__ */ e((e, t, n) => {
4491
+ if (R(e, t, e.pipe.tracks[e.trackIndex], t.pipe.tracks[t.trackIndex])) return;
4492
+ let r = ie(e.pipe, t);
4493
+ n(t, r === -1 ? z(e.pipe) : r);
4494
+ }, "resolveTrackConflict"), oe = /* @__PURE__ */ e((e) => {
4495
+ let t = 0;
4496
+ for (let n = 0; n < e.length; n++) for (let r = n + 1; r < e.length; r++) {
4497
+ let i = e[n], a = e[r];
4498
+ i.pipe === a.pipe && ae(i, a) && (t++, V(i, a, ne));
4499
+ }
4500
+ return t;
4501
+ }, "resolveHandleConflicts"), H = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ e((e) => {
4502
+ if (H.has(e)) return H.get(e);
4503
+ let t = g[e];
4504
+ if (t.length === 0) {
4505
+ let t = {
4506
+ dest: 0,
4507
+ deviation: 0,
4508
+ base: 0,
4509
+ delta: 0
4510
+ };
4511
+ return H.set(e, t), t;
4512
+ }
4513
+ let n = h[t[0]].pipe.coord, r = n;
4514
+ for (let e = 1; e < t.length; e++) {
4515
+ let i = h[t[e]];
4516
+ if (i.orientation === "horizontal") {
4517
+ let e = i.from, t = i.to;
4518
+ r = Math.abs(e - n) > Math.abs(t - n) ? e : t;
4519
+ break;
4520
+ }
4521
+ }
4522
+ let i = Math.abs(r - n), a = {
4523
+ dest: r,
4524
+ deviation: i,
4525
+ base: n,
4526
+ delta: r - n
4527
+ };
4528
+ return H.set(e, a), a;
4529
+ }, "getDestInfo"), W = /* @__PURE__ */ e(() => {
4530
+ let t = 0, n = /* @__PURE__ */ new Map();
4531
+ for (let [e, t] of a.entries()) g[e].length !== 0 && t.start && (n.has(t.start) || n.set(t.start, []), n.get(t.start).push(e));
4532
+ let r = /* @__PURE__ */ e((e) => {
4533
+ let t = a[e];
4534
+ if (!t.start || !t.end) return 0;
4535
+ let n = o.get(t.start), r = o.get(t.end);
4536
+ if (!n || !r) return 0;
4537
+ let i = (r.x ?? 0) - (n.x ?? 0), s = (r.y ?? 0) - (n.y ?? 0);
4538
+ return Math.abs(i) + Math.abs(s);
4539
+ }, "getEdgeDistance");
4540
+ for (let e of n.values()) {
4541
+ e.sort((e, t) => {
4542
+ let n = U(e), i = U(t);
4543
+ if (Math.abs(n.deviation - i.deviation) > 1) return n.deviation - i.deviation;
4544
+ if (Math.abs(n.dest - i.dest) > 1) return n.dest - i.dest;
4545
+ let a = r(e), o = r(t);
4546
+ if (Math.abs(a - o) > 1) return o - a;
4547
+ let s = g[e].length, c = g[t].length;
4548
+ if (s !== c) return s - c;
4549
+ if (s === 1) {
4550
+ let n = g[e][0], r = g[t][0];
4551
+ if (h[n] && h[r]) {
4552
+ let e = h[n], t = h[r], i = Math.abs(e.to - e.from), a = Math.abs(t.to - t.from);
4553
+ if (Math.abs(i - a) > 1) return i - a;
4554
+ }
4555
+ }
4556
+ return 0;
4557
+ });
4558
+ let n = e.map((e) => h[g[e][0]]);
4559
+ t += oe(n);
4560
+ }
4561
+ return t;
4562
+ }, "fixSourceHandleCrossings"), G = /* @__PURE__ */ e(() => {
4563
+ let t = 0, n = /* @__PURE__ */ new Map();
4564
+ for (let [e, t] of a.entries()) g[e].length !== 0 && t.end && (n.has(t.end) || n.set(t.end, []), n.get(t.end).push(e));
4565
+ for (let r of n.values()) {
4566
+ r.sort((t, n) => {
4567
+ let r = /* @__PURE__ */ e((e) => {
4568
+ let t = g[e];
4569
+ if (t.length < 2) return 0;
4570
+ let n = h[t[t.length - 2]];
4571
+ return Math.abs(n.to - n.from);
4572
+ }, "getDist"), i = r(t), a = r(n);
4573
+ return Math.abs(i - a) > .1 ? i - a : t - n;
4574
+ });
4575
+ let n = r.map((e) => h[g[e][g[e].length - 1]]);
4576
+ t += oe(n);
4577
+ }
4578
+ return t;
4579
+ }, "fixTargetHandleCrossings"), K = /* @__PURE__ */ e(() => {
4580
+ let e = 0;
4581
+ for (let t of c) {
4582
+ let n = [];
4583
+ for (let e of t.tracks) for (let t of e.segments) {
4584
+ let e = g[t.edgeIndex].find((e) => h[e].segmentIndex === t.segmentIndex);
4585
+ e !== void 0 && n.push(h[e]);
4586
+ }
4587
+ n.sort((e, t) => e.edgeIndex - t.edgeIndex || e.segmentIndex - t.segmentIndex);
4588
+ for (let t = 0; t < n.length; t++) for (let r = t + 1; r < n.length; r++) {
4589
+ let i = n[t], a = n[r];
4590
+ ae(i, a) && (e++, V(i, a, te));
4591
+ }
4592
+ }
4593
+ return e;
4594
+ }, "fixPipeCrossings"), se = 0;
4595
+ for (; se < 10;) {
4596
+ let e = 0;
4597
+ if (e += W(), e += G(), e += K(), e === 0) break;
4598
+ se++;
4599
+ }
4600
+ let ce = /* @__PURE__ */ new Map();
4601
+ for (let t of c) {
4602
+ let n = [];
4603
+ t.tracks.forEach((e) => {
4604
+ e.segments.forEach((t) => {
4605
+ n.push({
4606
+ edgeIndex: t.edgeIndex,
4607
+ segmentIndex: t.segmentIndex,
4608
+ trackIndex: e.index,
4609
+ from: t.from,
4610
+ to: t.to
4611
+ });
4612
+ });
4613
+ }), n.sort((e, t) => e.from - t.from);
4614
+ let r = [];
4615
+ if (n.length > 0) {
4616
+ let e = [n[0]], t = n[0].to;
4617
+ for (let i = 1; i < n.length; i++) {
4618
+ let a = n[i];
4619
+ a.from < t ? (e.push(a), t = Math.max(t, a.to)) : (r.push(e), e = [a], t = a.to);
4620
+ }
4621
+ r.push(e);
4622
+ }
4623
+ for (let n of r) {
4624
+ let r = /* @__PURE__ */ new Set();
4625
+ n.forEach((e) => r.add(e.trackIndex));
4626
+ let i = /* @__PURE__ */ new Map();
4627
+ n.forEach((e) => {
4628
+ let t = U(e.edgeIndex);
4629
+ i.set(e.trackIndex, (i.get(e.trackIndex) ?? 0) + t.delta);
4630
+ });
4631
+ let a = [...r].filter((e) => (i.get(e) ?? 0) < -1), o = [...r].filter((e) => (i.get(e) ?? 0) > 1), s = [...r].filter((e) => Math.abs(i.get(e) ?? 0) <= 1);
4632
+ a.sort((e, t) => (i.get(t) ?? 0) - (i.get(e) ?? 0)), o.sort((e, t) => (i.get(e) ?? 0) - (i.get(t) ?? 0));
4633
+ let c = /* @__PURE__ */ e((e, r) => {
4634
+ n.filter((t) => t.trackIndex === e).forEach((e) => {
4635
+ let n = _.has(e.edgeIndex) ? t.coord : r;
4636
+ ce.set(`${e.edgeIndex}-${e.segmentIndex}`, n);
4637
+ });
4638
+ }, "assignCoord"), l = 0;
4639
+ for (let e of a) l++, c(e, t.coord - l * Nn);
4640
+ if (s.length === 0 && r.size > 0) {
4641
+ let e = [...r].sort((e, t) => Math.abs(i.get(e) ?? 0) - Math.abs(i.get(t) ?? 0))[0], t = a.indexOf(e);
4642
+ t !== -1 && a.splice(t, 1);
4643
+ let n = o.indexOf(e);
4644
+ n !== -1 && o.splice(n, 1), s.push(e);
4645
+ }
4646
+ let u = 0;
4647
+ for (let e of s) {
4648
+ if (u === 0) c(e, t.coord);
4649
+ else {
4650
+ let n = u % 2 == 1 ? 1 : -1, r = Math.ceil(u / 2);
4651
+ c(e, t.coord + n * r * Nn * .5);
4652
+ }
4653
+ u++;
4654
+ }
4655
+ let d = 0;
4656
+ for (let e of o) d++, c(e, t.coord + d * Nn);
4657
+ }
4658
+ }
4659
+ for (let [e, t] of a.entries()) {
4660
+ let n = g[e] ?? [];
4661
+ if (n.length === 0) continue;
4662
+ let r = [], { pSrcPort: i, pDstPort: a } = ee(e, o.get(t.start), o.get(t.end)), s = n.map((e) => {
4663
+ let t = h[e], n = ce.get(`${t.edgeIndex}-${t.segmentIndex}`) ?? t.pipe.coord;
4664
+ return {
4665
+ orient: t.orientation,
4666
+ coord: n,
4667
+ from: t.from,
4668
+ to: t.to
4669
+ };
4670
+ });
4671
+ r.push(i);
4672
+ for (let e = 0; e < s.length; e++) {
4673
+ let t = s[e], n = r[r.length - 1], i = t.orient === "vertical" ? n.y : n.x, a = t.orient === "vertical" ? n.x : n.y, o = s[e + 1], c = e < s.length - 1;
4674
+ if (Math.abs(a - t.coord) > $ && r.push(In(t, i)), c && o.orient === t.orient) if (Math.abs(t.coord - o.coord) > $) {
4675
+ let e = t.orient === "vertical" ? (i + o.from) / 2 : Fn(t, o);
4676
+ r.push(In(t, e), In(o, e));
4677
+ } else (e === 0 || e === s.length - 2) && r.push(In(t, Fn(t, o)));
4678
+ else if (c) r.push(In(t, o.coord));
4679
+ else {
4680
+ let e = Math.abs(t.from - i) < Math.abs(t.to - i) ? t.to : t.from;
4681
+ r.push(In(t, e));
4682
+ }
4683
+ }
4684
+ let c = r[r.length - 1];
4685
+ (Math.abs(c.x - a.x) > $ || Math.abs(c.y - a.y) > $) && r.push(a);
4686
+ let l = [];
4687
+ r.length > 0 && l.push(r[0]);
4688
+ for (let e = 1; e < r.length; e++) {
4689
+ let t = r[e], n = l[l.length - 1];
4690
+ (Math.abs(t.x - n.x) > $ || Math.abs(t.y - n.y) > $) && l.push(t);
4691
+ }
4692
+ t.points = l;
4693
+ }
4694
+ for (let e of a) {
4695
+ let t = e.__originalEdge;
4696
+ t && e.points && (t.points = e.points);
4697
+ }
4698
+ t.edges = (t.edges ?? []).filter((e) => !e.isLayoutOnly);
4699
+ let le = /* @__PURE__ */ e((e, t) => {
4700
+ let n = t.x ?? 0, r = t.y ?? 0, i = t.width ?? 0, a = t.height ?? 0;
4701
+ if (i <= 0 || a <= 0) return e;
4702
+ let o = n - i / 2, s = n + i / 2, c = r - a / 2, l = r + a / 2;
4703
+ if (e.x < o || e.x > s || e.y < c || e.y > l) return e;
4704
+ let u = e.x - o, d = s - e.x, f = e.y - c, p = l - e.y, m = Math.min(u, d, f, p);
4705
+ return m === u ? {
4706
+ x: o,
4707
+ y: e.y
4708
+ } : m === d ? {
4709
+ x: s,
4710
+ y: e.y
4711
+ } : m === f ? {
4712
+ x: e.x,
4713
+ y: c
4714
+ } : {
4715
+ x: e.x,
4716
+ y: l
4717
+ };
4718
+ }, "nodeBoundaryClamp");
4719
+ for (let e of t.edges) {
4720
+ let t = e.points;
4721
+ if (!t || t.length < 2) continue;
4722
+ let n = e.start, r = e.end, i = n ? o.get(n) : void 0, a = r ? o.get(r) : void 0;
4723
+ i && (t[0] = le(t[0], i)), a && (t[t.length - 1] = le(t[t.length - 1], a));
4724
+ }
4725
+ return t;
4726
+ }
4727
+ e(Ln, "routeEdgesOrthogonal");
4728
+ function Rn(e) {
4729
+ return e.direction ?? "TB";
4730
+ }
4731
+ e(Rn, "getSwimlaneDirection");
4732
+ function zn(e) {
4733
+ let t = d(e), n = e.config.flowchart?.nodeSpacing ?? 40, r = e.config.flowchart?.rankSpacing ?? 100, i = e.config.swimlane?.ignoreCrossLaneEdges ?? !0, a = e.config.swimlane?.optimizeRanksByCrossings ?? !0, o = e.config.swimlane?.automaticLaneOrdering ?? !1, s = Rn(e), { ordered: c, coordinates: l } = Dn(t, {
4734
+ nodeGap: n,
4735
+ layerGap: r,
4736
+ ignoreCrossLaneEdges: i,
4737
+ optimizeRanksByCrossings: a,
4738
+ automaticLaneOrdering: o,
4739
+ direction: s
4740
+ });
4741
+ f(t, c, l, {
4742
+ nodeGap: n,
4743
+ layerGap: r
4744
+ });
4745
+ for (let t of e.edges ?? []) delete t.points;
4746
+ Ln(e, s);
4747
+ for (let t of e.edges ?? []) (!t.curve || t.curve === "basis") && (t.curve = "rounded");
4748
+ return _t(e, s), gt(e), s;
4749
+ }
4750
+ e(zn, "runSwimlaneLayoutCore");
4751
+ function Bn(e) {
4752
+ u(e);
4753
+ let t = m(e);
4754
+ e.nodes = t.nodes, e.edges = t.edges;
4755
+ }
4756
+ e(Bn, "prepareSwimlaneLayout");
4757
+ var Vn = n({
4758
+ prepareLayout: Bn,
4759
+ runLayoutCore: zn,
4760
+ afterPaint: i
4761
+ });
4762
+ //#endregion
4763
+ export { Vn as render };