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