UNPKG

40.8 kBJavaScriptView Raw
1import { a as F, b as xn, c as zn, d as L, k as Un, e as Hn, g as jn, j as P, l as En, m as kn, n as yn, t as Jn, o as Nn, p as Kn, q as Zn, f as s, G as x, h as w, i as g, r as M, v as y, s as V } from "./graph-0ee63739.js";
2import { a8 as A, a9 as Qn, aa as ne, ab as ee, ac as Ln, ad as B, ae as _n, af as re, ag as Cn, ah as J, ai as te, aj as ie, ak as K, al as ae, am as In, an as oe, ao as ue, ap as H } from "./mermaid-9f2aa176.js";
3var de = /\s/;
4function fe(n) {
5 for (var e = n.length; e-- && de.test(n.charAt(e)); )
6 ;
7 return e;
8}
9var se = /^\s+/;
10function ce(n) {
11 return n && n.slice(0, fe(n) + 1).replace(se, "");
12}
13var un = 0 / 0, he = /^[-+]0x[0-9a-f]+$/i, le = /^0b[01]+$/i, ve = /^0o[0-7]+$/i, pe = parseInt;
14function we(n) {
15 if (typeof n == "number")
16 return n;
17 if (F(n))
18 return un;
19 if (A(n)) {
20 var e = typeof n.valueOf == "function" ? n.valueOf() : n;
21 n = A(e) ? e + "" : e;
22 }
23 if (typeof n != "string")
24 return n === 0 ? n : +n;
25 n = ce(n);
26 var r = le.test(n);
27 return r || ve.test(n) ? pe(n.slice(2), r ? 2 : 8) : he.test(n) ? un : +n;
28}
29var dn = 1 / 0, me = 17976931348623157e292;
30function S(n) {
31 if (!n)
32 return n === 0 ? n : 0;
33 if (n = we(n), n === dn || n === -dn) {
34 var e = n < 0 ? -1 : 1;
35 return e * me;
36 }
37 return n === n ? n : 0;
38}
39function be(n) {
40 var e = S(n), r = e % 1;
41 return e === e ? r ? e - r : e : 0;
42}
43function _(n) {
44 var e = n == null ? 0 : n.length;
45 return e ? xn(n, 1) : [];
46}
47function ge(n) {
48 return Qn(ne(n, void 0, _), n + "");
49}
50var xe = 1, Ee = 4;
51function ke(n) {
52 return zn(n, xe | Ee);
53}
54var ye = function() {
55 return ee.Date.now();
56};
57const fn = ye;
58var Rn = Object.prototype, Ne = Rn.hasOwnProperty, Le = Ln(function(n, e) {
59 n = Object(n);
60 var r = -1, t = e.length, i = t > 2 ? e[2] : void 0;
61 for (i && B(e[0], e[1], i) && (t = 1); ++r < t; )
62 for (var o = e[r], a = _n(o), u = -1, d = a.length; ++u < d; ) {
63 var f = a[u], c = n[f];
64 (c === void 0 || re(c, Rn[f]) && !Ne.call(n, f)) && (n[f] = o[f]);
65 }
66 return n;
67});
68const _e = Le;
69function $(n) {
70 var e = n == null ? 0 : n.length;
71 return e ? n[e - 1] : void 0;
72}
73function Ce(n) {
74 return function(e, r, t) {
75 var i = Object(e);
76 if (!Cn(e)) {
77 var o = L(r);
78 e = Un(e), r = function(u) {
79 return o(i[u], u, i);
80 };
81 }
82 var a = n(e, r, t);
83 return a > -1 ? i[o ? e[a] : a] : void 0;
84 };
85}
86var Ie = Math.max;
87function Re(n, e, r) {
88 var t = n == null ? 0 : n.length;
89 if (!t)
90 return -1;
91 var i = r == null ? 0 : be(r);
92 return i < 0 && (i = Ie(t + i, 0)), Hn(n, L(e), i);
93}
94var Te = Ce(Re);
95const Z = Te;
96function Tn(n, e) {
97 var r = -1, t = Cn(n) ? Array(n.length) : [];
98 return jn(n, function(i, o, a) {
99 t[++r] = e(i, o, a);
100 }), t;
101}
102function m(n, e) {
103 var r = J(n) ? P : Tn;
104 return r(n, L(e));
105}
106function Me(n, e) {
107 return n == null ? n : te(n, En(e), _n);
108}
109function Oe(n, e) {
110 return n && kn(n, En(e));
111}
112function Pe(n, e) {
113 return n > e;
114}
115function Mn(n, e) {
116 return n < e;
117}
118function Y(n, e) {
119 var r = {};
120 return e = L(e), kn(n, function(t, i, o) {
121 ie(r, i, e(t, i, o));
122 }), r;
123}
124function Q(n, e, r) {
125 for (var t = -1, i = n.length; ++t < i; ) {
126 var o = n[t], a = e(o);
127 if (a != null && (u === void 0 ? a === a && !F(a) : r(a, u)))
128 var u = a, d = o;
129 }
130 return d;
131}
132function E(n) {
133 return n && n.length ? Q(n, K, Pe) : void 0;
134}
135function R(n) {
136 return n && n.length ? Q(n, K, Mn) : void 0;
137}
138function nn(n, e) {
139 return n && n.length ? Q(n, L(e), Mn) : void 0;
140}
141function Se(n, e, r, t) {
142 if (!A(n))
143 return n;
144 e = yn(e, n);
145 for (var i = -1, o = e.length, a = o - 1, u = n; u != null && ++i < o; ) {
146 var d = Jn(e[i]), f = r;
147 if (d === "__proto__" || d === "constructor" || d === "prototype")
148 return n;
149 if (i != a) {
150 var c = u[d];
151 f = t ? t(c, d, u) : void 0, f === void 0 && (f = A(c) ? c : ae(e[i + 1]) ? [] : {});
152 }
153 In(u, d, f), u = u[d];
154 }
155 return n;
156}
157function Fe(n, e, r) {
158 for (var t = -1, i = e.length, o = {}; ++t < i; ) {
159 var a = e[t], u = Nn(n, a);
160 r(u, a) && Se(o, yn(a, n), u);
161 }
162 return o;
163}
164function Ae(n, e) {
165 var r = n.length;
166 for (n.sort(e); r--; )
167 n[r] = n[r].value;
168 return n;
169}
170function Be(n, e) {
171 if (n !== e) {
172 var r = n !== void 0, t = n === null, i = n === n, o = F(n), a = e !== void 0, u = e === null, d = e === e, f = F(e);
173 if (!u && !f && !o && n > e || o && a && d && !u && !f || t && a && d || !r && d || !i)
174 return 1;
175 if (!t && !o && !f && n < e || f && r && i && !t && !o || u && r && i || !a && i || !d)
176 return -1;
177 }
178 return 0;
179}
180function $e(n, e, r) {
181 for (var t = -1, i = n.criteria, o = e.criteria, a = i.length, u = r.length; ++t < a; ) {
182 var d = Be(i[t], o[t]);
183 if (d) {
184 if (t >= u)
185 return d;
186 var f = r[t];
187 return d * (f == "desc" ? -1 : 1);
188 }
189 }
190 return n.index - e.index;
191}
192function Ge(n, e, r) {
193 e.length ? e = P(e, function(o) {
194 return J(o) ? function(a) {
195 return Nn(a, o.length === 1 ? o[0] : o);
196 } : o;
197 }) : e = [K];
198 var t = -1;
199 e = P(e, oe(L));
200 var i = Tn(n, function(o, a, u) {
201 var d = P(e, function(f) {
202 return f(o);
203 });
204 return { criteria: d, index: ++t, value: o };
205 });
206 return Ae(i, function(o, a) {
207 return $e(o, a, r);
208 });
209}
210function Ve(n, e) {
211 return Fe(n, e, function(r, t) {
212 return Kn(n, t);
213 });
214}
215var Ye = ge(function(n, e) {
216 return n == null ? {} : Ve(n, e);
217});
218const G = Ye;
219var De = Math.ceil, qe = Math.max;
220function We(n, e, r, t) {
221 for (var i = -1, o = qe(De((e - n) / (r || 1)), 0), a = Array(o); o--; )
222 a[t ? o : ++i] = n, n += r;
223 return a;
224}
225function Xe(n) {
226 return function(e, r, t) {
227 return t && typeof t != "number" && B(e, r, t) && (r = t = void 0), e = S(e), r === void 0 ? (r = e, e = 0) : r = S(r), t = t === void 0 ? e < r ? 1 : -1 : S(t), We(e, r, t, n);
228 };
229}
230var ze = Xe();
231const N = ze;
232var Ue = Ln(function(n, e) {
233 if (n == null)
234 return [];
235 var r = e.length;
236 return r > 1 && B(n, e[0], e[1]) ? e = [] : r > 2 && B(e[0], e[1], e[2]) && (e = [e[0]]), Ge(n, xn(e, 1), []);
237});
238const O = Ue;
239var He = 0;
240function en(n) {
241 var e = ++He;
242 return Zn(n) + e;
243}
244function je(n, e, r) {
245 for (var t = -1, i = n.length, o = e.length, a = {}; ++t < i; ) {
246 var u = t < o ? e[t] : void 0;
247 r(a, n[t], u);
248 }
249 return a;
250}
251function Je(n, e) {
252 return je(n || [], e || [], In);
253}
254class Ke {
255 constructor() {
256 var e = {};
257 e._next = e._prev = e, this._sentinel = e;
258 }
259 dequeue() {
260 var e = this._sentinel, r = e._prev;
261 if (r !== e)
262 return sn(r), r;
263 }
264 enqueue(e) {
265 var r = this._sentinel;
266 e._prev && e._next && sn(e), e._next = r._next, r._next._prev = e, r._next = e, e._prev = r;
267 }
268 toString() {
269 for (var e = [], r = this._sentinel, t = r._prev; t !== r; )
270 e.push(JSON.stringify(t, Ze)), t = t._prev;
271 return "[" + e.join(", ") + "]";
272 }
273}
274function sn(n) {
275 n._prev._next = n._next, n._next._prev = n._prev, delete n._next, delete n._prev;
276}
277function Ze(n, e) {
278 if (n !== "_next" && n !== "_prev")
279 return e;
280}
281var Qe = ue(1);
282function nr(n, e) {
283 if (n.nodeCount() <= 1)
284 return [];
285 var r = rr(n, e || Qe), t = er(r.graph, r.buckets, r.zeroIdx);
286 return _(
287 m(t, function(i) {
288 return n.outEdges(i.v, i.w);
289 })
290 );
291}
292function er(n, e, r) {
293 for (var t = [], i = e[e.length - 1], o = e[0], a; n.nodeCount(); ) {
294 for (; a = o.dequeue(); )
295 q(n, e, r, a);
296 for (; a = i.dequeue(); )
297 q(n, e, r, a);
298 if (n.nodeCount()) {
299 for (var u = e.length - 2; u > 0; --u)
300 if (a = e[u].dequeue(), a) {
301 t = t.concat(q(n, e, r, a, !0));
302 break;
303 }
304 }
305 }
306 return t;
307}
308function q(n, e, r, t, i) {
309 var o = i ? [] : void 0;
310 return s(n.inEdges(t.v), function(a) {
311 var u = n.edge(a), d = n.node(a.v);
312 i && o.push({ v: a.v, w: a.w }), d.out -= u, j(e, r, d);
313 }), s(n.outEdges(t.v), function(a) {
314 var u = n.edge(a), d = a.w, f = n.node(d);
315 f.in -= u, j(e, r, f);
316 }), n.removeNode(t.v), o;
317}
318function rr(n, e) {
319 var r = new x(), t = 0, i = 0;
320 s(n.nodes(), function(u) {
321 r.setNode(u, { v: u, in: 0, out: 0 });
322 }), s(n.edges(), function(u) {
323 var d = r.edge(u.v, u.w) || 0, f = e(u), c = d + f;
324 r.setEdge(u.v, u.w, c), i = Math.max(i, r.node(u.v).out += f), t = Math.max(t, r.node(u.w).in += f);
325 });
326 var o = N(i + t + 3).map(function() {
327 return new Ke();
328 }), a = t + 1;
329 return s(r.nodes(), function(u) {
330 j(o, a, r.node(u));
331 }), { graph: r, buckets: o, zeroIdx: a };
332}
333function j(n, e, r) {
334 r.out ? r.in ? n[r.out - r.in + e].enqueue(r) : n[n.length - 1].enqueue(r) : n[0].enqueue(r);
335}
336function tr(n) {
337 var e = n.graph().acyclicer === "greedy" ? nr(n, r(n)) : ir(n);
338 s(e, function(t) {
339 var i = n.edge(t);
340 n.removeEdge(t), i.forwardName = t.name, i.reversed = !0, n.setEdge(t.w, t.v, i, en("rev"));
341 });
342 function r(t) {
343 return function(i) {
344 return t.edge(i).weight;
345 };
346 }
347}
348function ir(n) {
349 var e = [], r = {}, t = {};
350 function i(o) {
351 w(t, o) || (t[o] = !0, r[o] = !0, s(n.outEdges(o), function(a) {
352 w(r, a.w) ? e.push(a) : i(a.w);
353 }), delete r[o]);
354 }
355 return s(n.nodes(), i), e;
356}
357function ar(n) {
358 s(n.edges(), function(e) {
359 var r = n.edge(e);
360 if (r.reversed) {
361 n.removeEdge(e);
362 var t = r.forwardName;
363 delete r.reversed, delete r.forwardName, n.setEdge(e.w, e.v, r, t);
364 }
365 });
366}
367function C(n, e, r, t) {
368 var i;
369 do
370 i = en(t);
371 while (n.hasNode(i));
372 return r.dummy = e, n.setNode(i, r), i;
373}
374function or(n) {
375 var e = new x().setGraph(n.graph());
376 return s(n.nodes(), function(r) {
377 e.setNode(r, n.node(r));
378 }), s(n.edges(), function(r) {
379 var t = e.edge(r.v, r.w) || { weight: 0, minlen: 1 }, i = n.edge(r);
380 e.setEdge(r.v, r.w, {
381 weight: t.weight + i.weight,
382 minlen: Math.max(t.minlen, i.minlen)
383 });
384 }), e;
385}
386function On(n) {
387 var e = new x({ multigraph: n.isMultigraph() }).setGraph(n.graph());
388 return s(n.nodes(), function(r) {
389 n.children(r).length || e.setNode(r, n.node(r));
390 }), s(n.edges(), function(r) {
391 e.setEdge(r, n.edge(r));
392 }), e;
393}
394function cn(n, e) {
395 var r = n.x, t = n.y, i = e.x - r, o = e.y - t, a = n.width / 2, u = n.height / 2;
396 if (!i && !o)
397 throw new Error("Not possible to find intersection inside of the rectangle");
398 var d, f;
399 return Math.abs(o) * a > Math.abs(i) * u ? (o < 0 && (u = -u), d = u * i / o, f = u) : (i < 0 && (a = -a), d = a, f = a * o / i), { x: r + d, y: t + f };
400}
401function D(n) {
402 var e = m(N(Pn(n) + 1), function() {
403 return [];
404 });
405 return s(n.nodes(), function(r) {
406 var t = n.node(r), i = t.rank;
407 g(i) || (e[i][t.order] = r);
408 }), e;
409}
410function ur(n) {
411 var e = R(
412 m(n.nodes(), function(r) {
413 return n.node(r).rank;
414 })
415 );
416 s(n.nodes(), function(r) {
417 var t = n.node(r);
418 w(t, "rank") && (t.rank -= e);
419 });
420}
421function dr(n) {
422 var e = R(
423 m(n.nodes(), function(o) {
424 return n.node(o).rank;
425 })
426 ), r = [];
427 s(n.nodes(), function(o) {
428 var a = n.node(o).rank - e;
429 r[a] || (r[a] = []), r[a].push(o);
430 });
431 var t = 0, i = n.graph().nodeRankFactor;
432 s(r, function(o, a) {
433 g(o) && a % i !== 0 ? --t : t && s(o, function(u) {
434 n.node(u).rank += t;
435 });
436 });
437}
438function hn(n, e, r, t) {
439 var i = {
440 width: 0,
441 height: 0
442 };
443 return arguments.length >= 4 && (i.rank = r, i.order = t), C(n, "border", i, e);
444}
445function Pn(n) {
446 return E(
447 m(n.nodes(), function(e) {
448 var r = n.node(e).rank;
449 if (!g(r))
450 return r;
451 })
452 );
453}
454function fr(n, e) {
455 var r = { lhs: [], rhs: [] };
456 return s(n, function(t) {
457 e(t) ? r.lhs.push(t) : r.rhs.push(t);
458 }), r;
459}
460function sr(n, e) {
461 var r = fn();
462 try {
463 return e();
464 } finally {
465 console.log(n + " time: " + (fn() - r) + "ms");
466 }
467}
468function cr(n, e) {
469 return e();
470}
471function hr(n) {
472 function e(r) {
473 var t = n.children(r), i = n.node(r);
474 if (t.length && s(t, e), w(i, "minRank")) {
475 i.borderLeft = [], i.borderRight = [];
476 for (var o = i.minRank, a = i.maxRank + 1; o < a; ++o)
477 ln(n, "borderLeft", "_bl", r, i, o), ln(n, "borderRight", "_br", r, i, o);
478 }
479 }
480 s(n.children(), e);
481}
482function ln(n, e, r, t, i, o) {
483 var a = { width: 0, height: 0, rank: o, borderType: e }, u = i[e][o - 1], d = C(n, "border", a, r);
484 i[e][o] = d, n.setParent(d, t), u && n.setEdge(u, d, { weight: 1 });
485}
486function lr(n) {
487 var e = n.graph().rankdir.toLowerCase();
488 (e === "lr" || e === "rl") && Sn(n);
489}
490function vr(n) {
491 var e = n.graph().rankdir.toLowerCase();
492 (e === "bt" || e === "rl") && pr(n), (e === "lr" || e === "rl") && (wr(n), Sn(n));
493}
494function Sn(n) {
495 s(n.nodes(), function(e) {
496 vn(n.node(e));
497 }), s(n.edges(), function(e) {
498 vn(n.edge(e));
499 });
500}
501function vn(n) {
502 var e = n.width;
503 n.width = n.height, n.height = e;
504}
505function pr(n) {
506 s(n.nodes(), function(e) {
507 W(n.node(e));
508 }), s(n.edges(), function(e) {
509 var r = n.edge(e);
510 s(r.points, W), w(r, "y") && W(r);
511 });
512}
513function W(n) {
514 n.y = -n.y;
515}
516function wr(n) {
517 s(n.nodes(), function(e) {
518 X(n.node(e));
519 }), s(n.edges(), function(e) {
520 var r = n.edge(e);
521 s(r.points, X), w(r, "x") && X(r);
522 });
523}
524function X(n) {
525 var e = n.x;
526 n.x = n.y, n.y = e;
527}
528function mr(n) {
529 n.graph().dummyChains = [], s(n.edges(), function(e) {
530 br(n, e);
531 });
532}
533function br(n, e) {
534 var r = e.v, t = n.node(r).rank, i = e.w, o = n.node(i).rank, a = e.name, u = n.edge(e), d = u.labelRank;
535 if (o !== t + 1) {
536 n.removeEdge(e);
537 var f, c, h;
538 for (h = 0, ++t; t < o; ++h, ++t)
539 u.points = [], c = {
540 width: 0,
541 height: 0,
542 edgeLabel: u,
543 edgeObj: e,
544 rank: t
545 }, f = C(n, "edge", c, "_d"), t === d && (c.width = u.width, c.height = u.height, c.dummy = "edge-label", c.labelpos = u.labelpos), n.setEdge(r, f, { weight: u.weight }, a), h === 0 && n.graph().dummyChains.push(f), r = f;
546 n.setEdge(r, i, { weight: u.weight }, a);
547 }
548}
549function gr(n) {
550 s(n.graph().dummyChains, function(e) {
551 var r = n.node(e), t = r.edgeLabel, i;
552 for (n.setEdge(r.edgeObj, t); r.dummy; )
553 i = n.successors(e)[0], n.removeNode(e), t.points.push({ x: r.x, y: r.y }), r.dummy === "edge-label" && (t.x = r.x, t.y = r.y, t.width = r.width, t.height = r.height), e = i, r = n.node(e);
554 });
555}
556function rn(n) {
557 var e = {};
558 function r(t) {
559 var i = n.node(t);
560 if (w(e, t))
561 return i.rank;
562 e[t] = !0;
563 var o = R(
564 m(n.outEdges(t), function(a) {
565 return r(a.w) - n.edge(a).minlen;
566 })
567 );
568 return (o === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
569 o === void 0 || // return value of _.map([]) for Lodash 4
570 o === null) && (o = 0), i.rank = o;
571 }
572 s(n.sources(), r);
573}
574function T(n, e) {
575 return n.node(e.w).rank - n.node(e.v).rank - n.edge(e).minlen;
576}
577function Fn(n) {
578 var e = new x({ directed: !1 }), r = n.nodes()[0], t = n.nodeCount();
579 e.setNode(r, {});
580 for (var i, o; xr(e, n) < t; )
581 i = Er(e, n), o = e.hasNode(i.v) ? T(n, i) : -T(n, i), kr(e, n, o);
582 return e;
583}
584function xr(n, e) {
585 function r(t) {
586 s(e.nodeEdges(t), function(i) {
587 var o = i.v, a = t === o ? i.w : o;
588 !n.hasNode(a) && !T(e, i) && (n.setNode(a, {}), n.setEdge(t, a, {}), r(a));
589 });
590 }
591 return s(n.nodes(), r), n.nodeCount();
592}
593function Er(n, e) {
594 return nn(e.edges(), function(r) {
595 if (n.hasNode(r.v) !== n.hasNode(r.w))
596 return T(e, r);
597 });
598}
599function kr(n, e, r) {
600 s(n.nodes(), function(t) {
601 e.node(t).rank += r;
602 });
603}
604function yr() {
605}
606yr.prototype = new Error();
607function An(n, e, r) {
608 J(e) || (e = [e]);
609 var t = (n.isDirected() ? n.successors : n.neighbors).bind(n), i = [], o = {};
610 return s(e, function(a) {
611 if (!n.hasNode(a))
612 throw new Error("Graph does not have node: " + a);
613 Bn(n, a, r === "post", o, t, i);
614 }), i;
615}
616function Bn(n, e, r, t, i, o) {
617 w(t, e) || (t[e] = !0, r || o.push(e), s(i(e), function(a) {
618 Bn(n, a, r, t, i, o);
619 }), r && o.push(e));
620}
621function Nr(n, e) {
622 return An(n, e, "post");
623}
624function Lr(n, e) {
625 return An(n, e, "pre");
626}
627k.initLowLimValues = an;
628k.initCutValues = tn;
629k.calcCutValue = $n;
630k.leaveEdge = Vn;
631k.enterEdge = Yn;
632k.exchangeEdges = Dn;
633function k(n) {
634 n = or(n), rn(n);
635 var e = Fn(n);
636 an(e), tn(e, n);
637 for (var r, t; r = Vn(e); )
638 t = Yn(e, n, r), Dn(e, n, r, t);
639}
640function tn(n, e) {
641 var r = Nr(n, n.nodes());
642 r = r.slice(0, r.length - 1), s(r, function(t) {
643 _r(n, e, t);
644 });
645}
646function _r(n, e, r) {
647 var t = n.node(r), i = t.parent;
648 n.edge(r, i).cutvalue = $n(n, e, r);
649}
650function $n(n, e, r) {
651 var t = n.node(r), i = t.parent, o = !0, a = e.edge(r, i), u = 0;
652 return a || (o = !1, a = e.edge(i, r)), u = a.weight, s(e.nodeEdges(r), function(d) {
653 var f = d.v === r, c = f ? d.w : d.v;
654 if (c !== i) {
655 var h = f === o, l = e.edge(d).weight;
656 if (u += h ? l : -l, Ir(n, r, c)) {
657 var v = n.edge(r, c).cutvalue;
658 u += h ? -v : v;
659 }
660 }
661 }), u;
662}
663function an(n, e) {
664 arguments.length < 2 && (e = n.nodes()[0]), Gn(n, {}, 1, e);
665}
666function Gn(n, e, r, t, i) {
667 var o = r, a = n.node(t);
668 return e[t] = !0, s(n.neighbors(t), function(u) {
669 w(e, u) || (r = Gn(n, e, r, u, t));
670 }), a.low = o, a.lim = r++, i ? a.parent = i : delete a.parent, r;
671}
672function Vn(n) {
673 return Z(n.edges(), function(e) {
674 return n.edge(e).cutvalue < 0;
675 });
676}
677function Yn(n, e, r) {
678 var t = r.v, i = r.w;
679 e.hasEdge(t, i) || (t = r.w, i = r.v);
680 var o = n.node(t), a = n.node(i), u = o, d = !1;
681 o.lim > a.lim && (u = a, d = !0);
682 var f = M(e.edges(), function(c) {
683 return d === pn(n, n.node(c.v), u) && d !== pn(n, n.node(c.w), u);
684 });
685 return nn(f, function(c) {
686 return T(e, c);
687 });
688}
689function Dn(n, e, r, t) {
690 var i = r.v, o = r.w;
691 n.removeEdge(i, o), n.setEdge(t.v, t.w, {}), an(n), tn(n, e), Cr(n, e);
692}
693function Cr(n, e) {
694 var r = Z(n.nodes(), function(i) {
695 return !e.node(i).parent;
696 }), t = Lr(n, r);
697 t = t.slice(1), s(t, function(i) {
698 var o = n.node(i).parent, a = e.edge(i, o), u = !1;
699 a || (a = e.edge(o, i), u = !0), e.node(i).rank = e.node(o).rank + (u ? a.minlen : -a.minlen);
700 });
701}
702function Ir(n, e, r) {
703 return n.hasEdge(e, r);
704}
705function pn(n, e, r) {
706 return r.low <= e.lim && e.lim <= r.lim;
707}
708function Rr(n) {
709 switch (n.graph().ranker) {
710 case "network-simplex":
711 wn(n);
712 break;
713 case "tight-tree":
714 Mr(n);
715 break;
716 case "longest-path":
717 Tr(n);
718 break;
719 default:
720 wn(n);
721 }
722}
723var Tr = rn;
724function Mr(n) {
725 rn(n), Fn(n);
726}
727function wn(n) {
728 k(n);
729}
730function Or(n) {
731 var e = C(n, "root", {}, "_root"), r = Pr(n), t = E(y(r)) - 1, i = 2 * t + 1;
732 n.graph().nestingRoot = e, s(n.edges(), function(a) {
733 n.edge(a).minlen *= i;
734 });
735 var o = Sr(n) + 1;
736 s(n.children(), function(a) {
737 qn(n, e, i, o, t, r, a);
738 }), n.graph().nodeRankFactor = i;
739}
740function qn(n, e, r, t, i, o, a) {
741 var u = n.children(a);
742 if (!u.length) {
743 a !== e && n.setEdge(e, a, { weight: 0, minlen: r });
744 return;
745 }
746 var d = hn(n, "_bt"), f = hn(n, "_bb"), c = n.node(a);
747 n.setParent(d, a), c.borderTop = d, n.setParent(f, a), c.borderBottom = f, s(u, function(h) {
748 qn(n, e, r, t, i, o, h);
749 var l = n.node(h), v = l.borderTop ? l.borderTop : h, p = l.borderBottom ? l.borderBottom : h, b = l.borderTop ? t : 2 * t, I = v !== p ? 1 : i - o[a] + 1;
750 n.setEdge(d, v, {
751 weight: b,
752 minlen: I,
753 nestingEdge: !0
754 }), n.setEdge(p, f, {
755 weight: b,
756 minlen: I,
757 nestingEdge: !0
758 });
759 }), n.parent(a) || n.setEdge(e, d, { weight: 0, minlen: i + o[a] });
760}
761function Pr(n) {
762 var e = {};
763 function r(t, i) {
764 var o = n.children(t);
765 o && o.length && s(o, function(a) {
766 r(a, i + 1);
767 }), e[t] = i;
768 }
769 return s(n.children(), function(t) {
770 r(t, 1);
771 }), e;
772}
773function Sr(n) {
774 return V(
775 n.edges(),
776 function(e, r) {
777 return e + n.edge(r).weight;
778 },
779 0
780 );
781}
782function Fr(n) {
783 var e = n.graph();
784 n.removeNode(e.nestingRoot), delete e.nestingRoot, s(n.edges(), function(r) {
785 var t = n.edge(r);
786 t.nestingEdge && n.removeEdge(r);
787 });
788}
789function Ar(n, e, r) {
790 var t = {}, i;
791 s(r, function(o) {
792 for (var a = n.parent(o), u, d; a; ) {
793 if (u = n.parent(a), u ? (d = t[u], t[u] = a) : (d = i, i = a), d && d !== a) {
794 e.setEdge(d, a);
795 return;
796 }
797 a = u;
798 }
799 });
800}
801function Br(n, e, r) {
802 var t = $r(n), i = new x({ compound: !0 }).setGraph({ root: t }).setDefaultNodeLabel(function(o) {
803 return n.node(o);
804 });
805 return s(n.nodes(), function(o) {
806 var a = n.node(o), u = n.parent(o);
807 (a.rank === e || a.minRank <= e && e <= a.maxRank) && (i.setNode(o), i.setParent(o, u || t), s(n[r](o), function(d) {
808 var f = d.v === o ? d.w : d.v, c = i.edge(f, o), h = g(c) ? 0 : c.weight;
809 i.setEdge(f, o, { weight: n.edge(d).weight + h });
810 }), w(a, "minRank") && i.setNode(o, {
811 borderLeft: a.borderLeft[e],
812 borderRight: a.borderRight[e]
813 }));
814 }), i;
815}
816function $r(n) {
817 for (var e; n.hasNode(e = en("_root")); )
818 ;
819 return e;
820}
821function Gr(n, e) {
822 for (var r = 0, t = 1; t < e.length; ++t)
823 r += Vr(n, e[t - 1], e[t]);
824 return r;
825}
826function Vr(n, e, r) {
827 for (var t = Je(
828 r,
829 m(r, function(f, c) {
830 return c;
831 })
832 ), i = _(
833 m(e, function(f) {
834 return O(
835 m(n.outEdges(f), function(c) {
836 return { pos: t[c.w], weight: n.edge(c).weight };
837 }),
838 "pos"
839 );
840 })
841 ), o = 1; o < r.length; )
842 o <<= 1;
843 var a = 2 * o - 1;
844 o -= 1;
845 var u = m(new Array(a), function() {
846 return 0;
847 }), d = 0;
848 return s(
849 // @ts-expect-error
850 i.forEach(function(f) {
851 var c = f.pos + o;
852 u[c] += f.weight;
853 for (var h = 0; c > 0; )
854 c % 2 && (h += u[c + 1]), c = c - 1 >> 1, u[c] += f.weight;
855 d += f.weight * h;
856 })
857 ), d;
858}
859function Yr(n) {
860 var e = {}, r = M(n.nodes(), function(u) {
861 return !n.children(u).length;
862 }), t = E(
863 m(r, function(u) {
864 return n.node(u).rank;
865 })
866 ), i = m(N(t + 1), function() {
867 return [];
868 });
869 function o(u) {
870 if (!w(e, u)) {
871 e[u] = !0;
872 var d = n.node(u);
873 i[d.rank].push(u), s(n.successors(u), o);
874 }
875 }
876 var a = O(r, function(u) {
877 return n.node(u).rank;
878 });
879 return s(a, o), i;
880}
881function Dr(n, e) {
882 return m(e, function(r) {
883 var t = n.inEdges(r);
884 if (t.length) {
885 var i = V(
886 t,
887 function(o, a) {
888 var u = n.edge(a), d = n.node(a.v);
889 return {
890 sum: o.sum + u.weight * d.order,
891 weight: o.weight + u.weight
892 };
893 },
894 { sum: 0, weight: 0 }
895 );
896 return {
897 v: r,
898 barycenter: i.sum / i.weight,
899 weight: i.weight
900 };
901 } else
902 return { v: r };
903 });
904}
905function qr(n, e) {
906 var r = {};
907 s(n, function(i, o) {
908 var a = r[i.v] = {
909 indegree: 0,
910 in: [],
911 out: [],
912 vs: [i.v],
913 i: o
914 };
915 g(i.barycenter) || (a.barycenter = i.barycenter, a.weight = i.weight);
916 }), s(e.edges(), function(i) {
917 var o = r[i.v], a = r[i.w];
918 !g(o) && !g(a) && (a.indegree++, o.out.push(r[i.w]));
919 });
920 var t = M(r, function(i) {
921 return !i.indegree;
922 });
923 return Wr(t);
924}
925function Wr(n) {
926 var e = [];
927 function r(o) {
928 return function(a) {
929 a.merged || (g(a.barycenter) || g(o.barycenter) || a.barycenter >= o.barycenter) && Xr(o, a);
930 };
931 }
932 function t(o) {
933 return function(a) {
934 a.in.push(o), --a.indegree === 0 && n.push(a);
935 };
936 }
937 for (; n.length; ) {
938 var i = n.pop();
939 e.push(i), s(i.in.reverse(), r(i)), s(i.out, t(i));
940 }
941 return m(
942 M(e, function(o) {
943 return !o.merged;
944 }),
945 function(o) {
946 return G(o, ["vs", "i", "barycenter", "weight"]);
947 }
948 );
949}
950function Xr(n, e) {
951 var r = 0, t = 0;
952 n.weight && (r += n.barycenter * n.weight, t += n.weight), e.weight && (r += e.barycenter * e.weight, t += e.weight), n.vs = e.vs.concat(n.vs), n.barycenter = r / t, n.weight = t, n.i = Math.min(e.i, n.i), e.merged = !0;
953}
954function zr(n, e) {
955 var r = fr(n, function(c) {
956 return w(c, "barycenter");
957 }), t = r.lhs, i = O(r.rhs, function(c) {
958 return -c.i;
959 }), o = [], a = 0, u = 0, d = 0;
960 t.sort(Ur(!!e)), d = mn(o, i, d), s(t, function(c) {
961 d += c.vs.length, o.push(c.vs), a += c.barycenter * c.weight, u += c.weight, d = mn(o, i, d);
962 });
963 var f = { vs: _(o) };
964 return u && (f.barycenter = a / u, f.weight = u), f;
965}
966function mn(n, e, r) {
967 for (var t; e.length && (t = $(e)).i <= r; )
968 e.pop(), n.push(t.vs), r++;
969 return r;
970}
971function Ur(n) {
972 return function(e, r) {
973 return e.barycenter < r.barycenter ? -1 : e.barycenter > r.barycenter ? 1 : n ? r.i - e.i : e.i - r.i;
974 };
975}
976function Wn(n, e, r, t) {
977 var i = n.children(e), o = n.node(e), a = o ? o.borderLeft : void 0, u = o ? o.borderRight : void 0, d = {};
978 a && (i = M(i, function(p) {
979 return p !== a && p !== u;
980 }));
981 var f = Dr(n, i);
982 s(f, function(p) {
983 if (n.children(p.v).length) {
984 var b = Wn(n, p.v, r, t);
985 d[p.v] = b, w(b, "barycenter") && jr(p, b);
986 }
987 });
988 var c = qr(f, r);
989 Hr(c, d);
990 var h = zr(c, t);
991 if (a && (h.vs = _([a, h.vs, u]), n.predecessors(a).length)) {
992 var l = n.node(n.predecessors(a)[0]), v = n.node(n.predecessors(u)[0]);
993 w(h, "barycenter") || (h.barycenter = 0, h.weight = 0), h.barycenter = (h.barycenter * h.weight + l.order + v.order) / (h.weight + 2), h.weight += 2;
994 }
995 return h;
996}
997function Hr(n, e) {
998 s(n, function(r) {
999 r.vs = _(
1000 r.vs.map(function(t) {
1001 return e[t] ? e[t].vs : t;
1002 })
1003 );
1004 });
1005}
1006function jr(n, e) {
1007 g(n.barycenter) ? (n.barycenter = e.barycenter, n.weight = e.weight) : (n.barycenter = (n.barycenter * n.weight + e.barycenter * e.weight) / (n.weight + e.weight), n.weight += e.weight);
1008}
1009function Jr(n) {
1010 var e = Pn(n), r = bn(n, N(1, e + 1), "inEdges"), t = bn(n, N(e - 1, -1, -1), "outEdges"), i = Yr(n);
1011 gn(n, i);
1012 for (var o = Number.POSITIVE_INFINITY, a, u = 0, d = 0; d < 4; ++u, ++d) {
1013 Kr(u % 2 ? r : t, u % 4 >= 2), i = D(n);
1014 var f = Gr(n, i);
1015 f < o && (d = 0, a = ke(i), o = f);
1016 }
1017 gn(n, a);
1018}
1019function bn(n, e, r) {
1020 return m(e, function(t) {
1021 return Br(n, t, r);
1022 });
1023}
1024function Kr(n, e) {
1025 var r = new x();
1026 s(n, function(t) {
1027 var i = t.graph().root, o = Wn(t, i, r, e);
1028 s(o.vs, function(a, u) {
1029 t.node(a).order = u;
1030 }), Ar(t, r, o.vs);
1031 });
1032}
1033function gn(n, e) {
1034 s(e, function(r) {
1035 s(r, function(t, i) {
1036 n.node(t).order = i;
1037 });
1038 });
1039}
1040function Zr(n) {
1041 var e = nt(n);
1042 s(n.graph().dummyChains, function(r) {
1043 for (var t = n.node(r), i = t.edgeObj, o = Qr(n, e, i.v, i.w), a = o.path, u = o.lca, d = 0, f = a[d], c = !0; r !== i.w; ) {
1044 if (t = n.node(r), c) {
1045 for (; (f = a[d]) !== u && n.node(f).maxRank < t.rank; )
1046 d++;
1047 f === u && (c = !1);
1048 }
1049 if (!c) {
1050 for (; d < a.length - 1 && n.node(f = a[d + 1]).minRank <= t.rank; )
1051 d++;
1052 f = a[d];
1053 }
1054 n.setParent(r, f), r = n.successors(r)[0];
1055 }
1056 });
1057}
1058function Qr(n, e, r, t) {
1059 var i = [], o = [], a = Math.min(e[r].low, e[t].low), u = Math.max(e[r].lim, e[t].lim), d, f;
1060 d = r;
1061 do
1062 d = n.parent(d), i.push(d);
1063 while (d && (e[d].low > a || u > e[d].lim));
1064 for (f = d, d = t; (d = n.parent(d)) !== f; )
1065 o.push(d);
1066 return { path: i.concat(o.reverse()), lca: f };
1067}
1068function nt(n) {
1069 var e = {}, r = 0;
1070 function t(i) {
1071 var o = r;
1072 s(n.children(i), t), e[i] = { low: o, lim: r++ };
1073 }
1074 return s(n.children(), t), e;
1075}
1076function et(n, e) {
1077 var r = {};
1078 function t(i, o) {
1079 var a = 0, u = 0, d = i.length, f = $(o);
1080 return s(o, function(c, h) {
1081 var l = tt(n, c), v = l ? n.node(l).order : d;
1082 (l || c === f) && (s(o.slice(u, h + 1), function(p) {
1083 s(n.predecessors(p), function(b) {
1084 var I = n.node(b), on = I.order;
1085 (on < a || v < on) && !(I.dummy && n.node(p).dummy) && Xn(r, b, p);
1086 });
1087 }), u = h + 1, a = v);
1088 }), o;
1089 }
1090 return V(e, t), r;
1091}
1092function rt(n, e) {
1093 var r = {};
1094 function t(o, a, u, d, f) {
1095 var c;
1096 s(N(a, u), function(h) {
1097 c = o[h], n.node(c).dummy && s(n.predecessors(c), function(l) {
1098 var v = n.node(l);
1099 v.dummy && (v.order < d || v.order > f) && Xn(r, l, c);
1100 });
1101 });
1102 }
1103 function i(o, a) {
1104 var u = -1, d, f = 0;
1105 return s(a, function(c, h) {
1106 if (n.node(c).dummy === "border") {
1107 var l = n.predecessors(c);
1108 l.length && (d = n.node(l[0]).order, t(a, f, h, u, d), f = h, u = d);
1109 }
1110 t(a, f, a.length, d, o.length);
1111 }), a;
1112 }
1113 return V(e, i), r;
1114}
1115function tt(n, e) {
1116 if (n.node(e).dummy)
1117 return Z(n.predecessors(e), function(r) {
1118 return n.node(r).dummy;
1119 });
1120}
1121function Xn(n, e, r) {
1122 if (e > r) {
1123 var t = e;
1124 e = r, r = t;
1125 }
1126 var i = n[e];
1127 i || (n[e] = i = {}), i[r] = !0;
1128}
1129function it(n, e, r) {
1130 if (e > r) {
1131 var t = e;
1132 e = r, r = t;
1133 }
1134 return w(n[e], r);
1135}
1136function at(n, e, r, t) {
1137 var i = {}, o = {}, a = {};
1138 return s(e, function(u) {
1139 s(u, function(d, f) {
1140 i[d] = d, o[d] = d, a[d] = f;
1141 });
1142 }), s(e, function(u) {
1143 var d = -1;
1144 s(u, function(f) {
1145 var c = t(f);
1146 if (c.length) {
1147 c = O(c, function(b) {
1148 return a[b];
1149 });
1150 for (var h = (c.length - 1) / 2, l = Math.floor(h), v = Math.ceil(h); l <= v; ++l) {
1151 var p = c[l];
1152 o[f] === f && d < a[p] && !it(r, f, p) && (o[p] = f, o[f] = i[f] = i[p], d = a[p]);
1153 }
1154 }
1155 });
1156 }), { root: i, align: o };
1157}
1158function ot(n, e, r, t, i) {
1159 var o = {}, a = ut(n, e, r, i), u = i ? "borderLeft" : "borderRight";
1160 function d(h, l) {
1161 for (var v = a.nodes(), p = v.pop(), b = {}; p; )
1162 b[p] ? h(p) : (b[p] = !0, v.push(p), v = v.concat(l(p))), p = v.pop();
1163 }
1164 function f(h) {
1165 o[h] = a.inEdges(h).reduce(function(l, v) {
1166 return Math.max(l, o[v.v] + a.edge(v));
1167 }, 0);
1168 }
1169 function c(h) {
1170 var l = a.outEdges(h).reduce(function(p, b) {
1171 return Math.min(p, o[b.w] - a.edge(b));
1172 }, Number.POSITIVE_INFINITY), v = n.node(h);
1173 l !== Number.POSITIVE_INFINITY && v.borderType !== u && (o[h] = Math.max(o[h], l));
1174 }
1175 return d(f, a.predecessors.bind(a)), d(c, a.successors.bind(a)), s(t, function(h) {
1176 o[h] = o[r[h]];
1177 }), o;
1178}
1179function ut(n, e, r, t) {
1180 var i = new x(), o = n.graph(), a = ht(o.nodesep, o.edgesep, t);
1181 return s(e, function(u) {
1182 var d;
1183 s(u, function(f) {
1184 var c = r[f];
1185 if (i.setNode(c), d) {
1186 var h = r[d], l = i.edge(h, c);
1187 i.setEdge(h, c, Math.max(a(n, f, d), l || 0));
1188 }
1189 d = f;
1190 });
1191 }), i;
1192}
1193function dt(n, e) {
1194 return nn(y(e), function(r) {
1195 var t = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
1196 return Me(r, function(o, a) {
1197 var u = lt(n, a) / 2;
1198 t = Math.max(o + u, t), i = Math.min(o - u, i);
1199 }), t - i;
1200 });
1201}
1202function ft(n, e) {
1203 var r = y(e), t = R(r), i = E(r);
1204 s(["u", "d"], function(o) {
1205 s(["l", "r"], function(a) {
1206 var u = o + a, d = n[u], f;
1207 if (d !== e) {
1208 var c = y(d);
1209 f = a === "l" ? t - R(c) : i - E(c), f && (n[u] = Y(d, function(h) {
1210 return h + f;
1211 }));
1212 }
1213 });
1214 });
1215}
1216function st(n, e) {
1217 return Y(n.ul, function(r, t) {
1218 if (e)
1219 return n[e.toLowerCase()][t];
1220 var i = O(m(n, t));
1221 return (i[1] + i[2]) / 2;
1222 });
1223}
1224function ct(n) {
1225 var e = D(n), r = H(et(n, e), rt(n, e)), t = {}, i;
1226 s(["u", "d"], function(a) {
1227 i = a === "u" ? e : y(e).reverse(), s(["l", "r"], function(u) {
1228 u === "r" && (i = m(i, function(h) {
1229 return y(h).reverse();
1230 }));
1231 var d = (a === "u" ? n.predecessors : n.successors).bind(n), f = at(n, i, r, d), c = ot(n, i, f.root, f.align, u === "r");
1232 u === "r" && (c = Y(c, function(h) {
1233 return -h;
1234 })), t[a + u] = c;
1235 });
1236 });
1237 var o = dt(n, t);
1238 return ft(t, o), st(t, n.graph().align);
1239}
1240function ht(n, e, r) {
1241 return function(t, i, o) {
1242 var a = t.node(i), u = t.node(o), d = 0, f;
1243 if (d += a.width / 2, w(a, "labelpos"))
1244 switch (a.labelpos.toLowerCase()) {
1245 case "l":
1246 f = -a.width / 2;
1247 break;
1248 case "r":
1249 f = a.width / 2;
1250 break;
1251 }
1252 if (f && (d += r ? f : -f), f = 0, d += (a.dummy ? e : n) / 2, d += (u.dummy ? e : n) / 2, d += u.width / 2, w(u, "labelpos"))
1253 switch (u.labelpos.toLowerCase()) {
1254 case "l":
1255 f = u.width / 2;
1256 break;
1257 case "r":
1258 f = -u.width / 2;
1259 break;
1260 }
1261 return f && (d += r ? f : -f), f = 0, d;
1262 };
1263}
1264function lt(n, e) {
1265 return n.node(e).width;
1266}
1267function vt(n) {
1268 n = On(n), pt(n), Oe(ct(n), function(e, r) {
1269 n.node(r).x = e;
1270 });
1271}
1272function pt(n) {
1273 var e = D(n), r = n.graph().ranksep, t = 0;
1274 s(e, function(i) {
1275 var o = E(
1276 m(i, function(a) {
1277 return n.node(a).height;
1278 })
1279 );
1280 s(i, function(a) {
1281 n.node(a).y = t + o / 2;
1282 }), t += o + r;
1283 });
1284}
1285function Yt(n, e) {
1286 var r = e && e.debugTiming ? sr : cr;
1287 r("layout", function() {
1288 var t = r(" buildLayoutGraph", function() {
1289 return _t(n);
1290 });
1291 r(" runLayout", function() {
1292 wt(t, r);
1293 }), r(" updateInputGraph", function() {
1294 mt(n, t);
1295 });
1296 });
1297}
1298function wt(n, e) {
1299 e(" makeSpaceForEdgeLabels", function() {
1300 Ct(n);
1301 }), e(" removeSelfEdges", function() {
1302 At(n);
1303 }), e(" acyclic", function() {
1304 tr(n);
1305 }), e(" nestingGraph.run", function() {
1306 Or(n);
1307 }), e(" rank", function() {
1308 Rr(On(n));
1309 }), e(" injectEdgeLabelProxies", function() {
1310 It(n);
1311 }), e(" removeEmptyRanks", function() {
1312 dr(n);
1313 }), e(" nestingGraph.cleanup", function() {
1314 Fr(n);
1315 }), e(" normalizeRanks", function() {
1316 ur(n);
1317 }), e(" assignRankMinMax", function() {
1318 Rt(n);
1319 }), e(" removeEdgeLabelProxies", function() {
1320 Tt(n);
1321 }), e(" normalize.run", function() {
1322 mr(n);
1323 }), e(" parentDummyChains", function() {
1324 Zr(n);
1325 }), e(" addBorderSegments", function() {
1326 hr(n);
1327 }), e(" order", function() {
1328 Jr(n);
1329 }), e(" insertSelfEdges", function() {
1330 Bt(n);
1331 }), e(" adjustCoordinateSystem", function() {
1332 lr(n);
1333 }), e(" position", function() {
1334 vt(n);
1335 }), e(" positionSelfEdges", function() {
1336 $t(n);
1337 }), e(" removeBorderNodes", function() {
1338 Ft(n);
1339 }), e(" normalize.undo", function() {
1340 gr(n);
1341 }), e(" fixupEdgeLabelCoords", function() {
1342 Pt(n);
1343 }), e(" undoCoordinateSystem", function() {
1344 vr(n);
1345 }), e(" translateGraph", function() {
1346 Mt(n);
1347 }), e(" assignNodeIntersects", function() {
1348 Ot(n);
1349 }), e(" reversePoints", function() {
1350 St(n);
1351 }), e(" acyclic.undo", function() {
1352 ar(n);
1353 });
1354}
1355function mt(n, e) {
1356 s(n.nodes(), function(r) {
1357 var t = n.node(r), i = e.node(r);
1358 t && (t.x = i.x, t.y = i.y, e.children(r).length && (t.width = i.width, t.height = i.height));
1359 }), s(n.edges(), function(r) {
1360 var t = n.edge(r), i = e.edge(r);
1361 t.points = i.points, w(i, "x") && (t.x = i.x, t.y = i.y);
1362 }), n.graph().width = e.graph().width, n.graph().height = e.graph().height;
1363}
1364var bt = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], gt = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" }, xt = ["acyclicer", "ranker", "rankdir", "align"], Et = ["width", "height"], kt = { width: 0, height: 0 }, yt = ["minlen", "weight", "width", "height", "labeloffset"], Nt = {
1365 minlen: 1,
1366 weight: 1,
1367 width: 0,
1368 height: 0,
1369 labeloffset: 10,
1370 labelpos: "r"
1371}, Lt = ["labelpos"];
1372function _t(n) {
1373 var e = new x({ multigraph: !0, compound: !0 }), r = U(n.graph());
1374 return e.setGraph(
1375 H({}, gt, z(r, bt), G(r, xt))
1376 ), s(n.nodes(), function(t) {
1377 var i = U(n.node(t));
1378 e.setNode(t, _e(z(i, Et), kt)), e.setParent(t, n.parent(t));
1379 }), s(n.edges(), function(t) {
1380 var i = U(n.edge(t));
1381 e.setEdge(
1382 t,
1383 H({}, Nt, z(i, yt), G(i, Lt))
1384 );
1385 }), e;
1386}
1387function Ct(n) {
1388 var e = n.graph();
1389 e.ranksep /= 2, s(n.edges(), function(r) {
1390 var t = n.edge(r);
1391 t.minlen *= 2, t.labelpos.toLowerCase() !== "c" && (e.rankdir === "TB" || e.rankdir === "BT" ? t.width += t.labeloffset : t.height += t.labeloffset);
1392 });
1393}
1394function It(n) {
1395 s(n.edges(), function(e) {
1396 var r = n.edge(e);
1397 if (r.width && r.height) {
1398 var t = n.node(e.v), i = n.node(e.w), o = { rank: (i.rank - t.rank) / 2 + t.rank, e };
1399 C(n, "edge-proxy", o, "_ep");
1400 }
1401 });
1402}
1403function Rt(n) {
1404 var e = 0;
1405 s(n.nodes(), function(r) {
1406 var t = n.node(r);
1407 t.borderTop && (t.minRank = n.node(t.borderTop).rank, t.maxRank = n.node(t.borderBottom).rank, e = E(e, t.maxRank));
1408 }), n.graph().maxRank = e;
1409}
1410function Tt(n) {
1411 s(n.nodes(), function(e) {
1412 var r = n.node(e);
1413 r.dummy === "edge-proxy" && (n.edge(r.e).labelRank = r.rank, n.removeNode(e));
1414 });
1415}
1416function Mt(n) {
1417 var e = Number.POSITIVE_INFINITY, r = 0, t = Number.POSITIVE_INFINITY, i = 0, o = n.graph(), a = o.marginx || 0, u = o.marginy || 0;
1418 function d(f) {
1419 var c = f.x, h = f.y, l = f.width, v = f.height;
1420 e = Math.min(e, c - l / 2), r = Math.max(r, c + l / 2), t = Math.min(t, h - v / 2), i = Math.max(i, h + v / 2);
1421 }
1422 s(n.nodes(), function(f) {
1423 d(n.node(f));
1424 }), s(n.edges(), function(f) {
1425 var c = n.edge(f);
1426 w(c, "x") && d(c);
1427 }), e -= a, t -= u, s(n.nodes(), function(f) {
1428 var c = n.node(f);
1429 c.x -= e, c.y -= t;
1430 }), s(n.edges(), function(f) {
1431 var c = n.edge(f);
1432 s(c.points, function(h) {
1433 h.x -= e, h.y -= t;
1434 }), w(c, "x") && (c.x -= e), w(c, "y") && (c.y -= t);
1435 }), o.width = r - e + a, o.height = i - t + u;
1436}
1437function Ot(n) {
1438 s(n.edges(), function(e) {
1439 var r = n.edge(e), t = n.node(e.v), i = n.node(e.w), o, a;
1440 r.points ? (o = r.points[0], a = r.points[r.points.length - 1]) : (r.points = [], o = i, a = t), r.points.unshift(cn(t, o)), r.points.push(cn(i, a));
1441 });
1442}
1443function Pt(n) {
1444 s(n.edges(), function(e) {
1445 var r = n.edge(e);
1446 if (w(r, "x"))
1447 switch ((r.labelpos === "l" || r.labelpos === "r") && (r.width -= r.labeloffset), r.labelpos) {
1448 case "l":
1449 r.x -= r.width / 2 + r.labeloffset;
1450 break;
1451 case "r":
1452 r.x += r.width / 2 + r.labeloffset;
1453 break;
1454 }
1455 });
1456}
1457function St(n) {
1458 s(n.edges(), function(e) {
1459 var r = n.edge(e);
1460 r.reversed && r.points.reverse();
1461 });
1462}
1463function Ft(n) {
1464 s(n.nodes(), function(e) {
1465 if (n.children(e).length) {
1466 var r = n.node(e), t = n.node(r.borderTop), i = n.node(r.borderBottom), o = n.node($(r.borderLeft)), a = n.node($(r.borderRight));
1467 r.width = Math.abs(a.x - o.x), r.height = Math.abs(i.y - t.y), r.x = o.x + r.width / 2, r.y = t.y + r.height / 2;
1468 }
1469 }), s(n.nodes(), function(e) {
1470 n.node(e).dummy === "border" && n.removeNode(e);
1471 });
1472}
1473function At(n) {
1474 s(n.edges(), function(e) {
1475 if (e.v === e.w) {
1476 var r = n.node(e.v);
1477 r.selfEdges || (r.selfEdges = []), r.selfEdges.push({ e, label: n.edge(e) }), n.removeEdge(e);
1478 }
1479 });
1480}
1481function Bt(n) {
1482 var e = D(n);
1483 s(e, function(r) {
1484 var t = 0;
1485 s(r, function(i, o) {
1486 var a = n.node(i);
1487 a.order = o + t, s(a.selfEdges, function(u) {
1488 C(
1489 n,
1490 "selfedge",
1491 {
1492 width: u.label.width,
1493 height: u.label.height,
1494 rank: a.rank,
1495 order: o + ++t,
1496 e: u.e,
1497 label: u.label
1498 },
1499 "_se"
1500 );
1501 }), delete a.selfEdges;
1502 });
1503 });
1504}
1505function $t(n) {
1506 s(n.nodes(), function(e) {
1507 var r = n.node(e);
1508 if (r.dummy === "selfedge") {
1509 var t = n.node(r.e.v), i = t.x + t.width / 2, o = t.y, a = r.x - i, u = t.height / 2;
1510 n.setEdge(r.e, r.label), n.removeNode(e), r.label.points = [
1511 { x: i + 2 * a / 3, y: o - u },
1512 { x: i + 5 * a / 6, y: o - u },
1513 { x: i + a, y: o },
1514 { x: i + 5 * a / 6, y: o + u },
1515 { x: i + 2 * a / 3, y: o + u }
1516 ], r.label.x = r.x, r.label.y = r.y;
1517 }
1518 });
1519}
1520function z(n, e) {
1521 return Y(G(n, e), Number);
1522}
1523function U(n) {
1524 var e = {};
1525 return s(n, function(r, t) {
1526 e[t.toLowerCase()] = r;
1527 }), e;
1528}
1529export {
1530 _e as d,
1531 Yt as l,
1532 m,
1533 G as p,
1534 N as r,
1535 en as u
1536};