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