@rse/gradia 1.2.1 → 1.2.3
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 +16 -8
- package/dst/gradia-api-config.d.ts +1 -0
- package/dst/gradia-api-config.js +2 -1
- package/dst/gradia-api-type-graph.js +39 -18
- package/dst/gradia-api-type-grid.js +24 -8
- package/dst/gradia-api.umd.js +2 -2
- package/dst/gradia-mcp.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -247,8 +247,10 @@ separated by `|`.
|
|
|
247
247
|
except a container with one of its own members. An edge crossing the
|
|
248
248
|
boundary of a container laid out as `graph` is routed through the box
|
|
249
249
|
border to the inner node (entering on the west and leaving on the east
|
|
250
|
-
side
|
|
251
|
-
|
|
250
|
+
side, and where other nodes lie between the inner node and the border,
|
|
251
|
+
around them through the gutter below, passing the border at the
|
|
252
|
+
height of that gutter), while an edge crossing the boundary of a
|
|
253
|
+
container laid out as `hub` or `grid` ends at the box border instead.
|
|
252
254
|
|
|
253
255
|
- All remaining attributes are displayed as `<key>: <val>` lines inside
|
|
254
256
|
the node box.
|
|
@@ -326,14 +328,14 @@ color-edge-halo #ffffff grid-columns-min 3
|
|
|
326
328
|
size-canvas-margin 40 grid-gap-horizontal 40
|
|
327
329
|
size-node-width-min 220 grid-gap-vertical 20
|
|
328
330
|
size-node-width-max 0 grid-node-width-equal true
|
|
329
|
-
size-node-height-scale 2.25
|
|
331
|
+
size-node-height-scale 2.25 grid-node-height-equal true
|
|
330
332
|
```
|
|
331
333
|
|
|
332
334
|
The `size-*`, `group-*`, `container-*`, `graph-*`, `hub-*`, and
|
|
333
335
|
`grid-*` options control the rendering geometry (canvas margin, node
|
|
334
336
|
box sizing, edge routing, group and container box spacing, and the
|
|
335
337
|
per-diagram-type layout) and take non-negative numbers, except the
|
|
336
|
-
|
|
338
|
+
booleans `grid-node-width-equal` and `grid-node-height-equal`.
|
|
337
339
|
|
|
338
340
|
The `size-node-width-max` option additionally enables the word-wrapping
|
|
339
341
|
of the node box texts: given a positive value, the node name, its type,
|
|
@@ -377,10 +379,16 @@ stacked, while `grid-columns-max` caps it, so that larger diagrams grow
|
|
|
377
379
|
in height only. The column count never exceeds the node count and the
|
|
378
380
|
maximum always wins over the minimum.
|
|
379
381
|
|
|
380
|
-
The `grid-node-width-equal`
|
|
381
|
-
diagram: the value `true` forces all node
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
The `grid-node-width-equal` and `grid-node-height-equal` options control
|
|
383
|
+
the tile sizes of a `grid` diagram: the value `true` forces all node
|
|
384
|
+
boxes to the width of the widest one (or the height of the tallest one)
|
|
385
|
+
and hence yields a strictly regular grid, while `false` lets each column
|
|
386
|
+
become only as wide as its own widest node box (or each row only as tall
|
|
387
|
+
as its own tallest node box), with the tiles left-aligned within their
|
|
388
|
+
column (or top-aligned within their row). A nested container box takes
|
|
389
|
+
part in the width unification only, as its height is the one of its
|
|
390
|
+
content: it never grows to the height of the tallest tile of its row,
|
|
391
|
+
but keeps its row as tall as itself.
|
|
384
392
|
|
|
385
393
|
The `font-family` and `color-*` options are embedded directly into the
|
|
386
394
|
generated SVG. When such an option is *not* explicitly configured, the
|
|
@@ -48,6 +48,7 @@ export declare const configDefaults: {
|
|
|
48
48
|
"grid-gap-horizontal": number;
|
|
49
49
|
"grid-gap-vertical": number;
|
|
50
50
|
"grid-node-width-equal": boolean;
|
|
51
|
+
"grid-node-height-equal": boolean;
|
|
51
52
|
};
|
|
52
53
|
export type Config = typeof configDefaults;
|
|
53
54
|
export type ConfigEmbedded = {
|
package/dst/gradia-api-config.js
CHANGED
|
@@ -57,7 +57,8 @@ export const configDefaults = {
|
|
|
57
57
|
"grid-columns-min": 3, /* grid: min side-by-side tiles */
|
|
58
58
|
"grid-gap-horizontal": 40, /* grid: horizontal gap between tiles */
|
|
59
59
|
"grid-gap-vertical": 20, /* grid: vertical gap between tiles */
|
|
60
|
-
"grid-node-width-equal": true /* grid: force equal width of node boxes */
|
|
60
|
+
"grid-node-width-equal": true, /* grid: force equal width of node boxes */
|
|
61
|
+
"grid-node-height-equal": true /* grid: force equal height of node boxes */
|
|
61
62
|
};
|
|
62
63
|
/* resolve a directly embedded configuration option into a CSS value:
|
|
63
64
|
an explicitly configured value is hard-coded (stripped of the
|
|
@@ -243,13 +243,17 @@ const placeGates = (gates, edges, col, row, ncols, nrows) => {
|
|
|
243
243
|
place(outs, ncols - 1);
|
|
244
244
|
return { ncols, nrows };
|
|
245
245
|
};
|
|
246
|
+
/* the channels an edge runs a vertical track in (the gate-side
|
|
247
|
+
channel of a gutter-ending edge is merely crossed horizontally) */
|
|
248
|
+
const trackChans = (plan) => plan.gate === "t" ? [plan.chans[0]] : plan.gate === "s" ? [plan.chans[1]] : plan.chans;
|
|
246
249
|
/* plan the coarse route of every edge: which inter-column channels
|
|
247
250
|
and inter-row gutters it occupies (based on the grid indices and
|
|
248
251
|
the attachment sides only): the source stub reaches the channel
|
|
249
252
|
beside its attachment side, the target stub the channel beside
|
|
250
253
|
its one, and, if those differ, the gutter next to the target row
|
|
251
|
-
connects them
|
|
252
|
-
|
|
254
|
+
connects them (an edge whose gate end lies beyond that gutter ends
|
|
255
|
+
in the gutter itself, as the gate merely marks the border passage) */
|
|
256
|
+
const planRoutes = (edges, col, row, sides, gates) => {
|
|
253
257
|
const flag = (from, to) => ({ mirror: from === "r", hairpin: from === to });
|
|
254
258
|
const plans = edges.map((edge, i) => {
|
|
255
259
|
/* a self-loop detours as a hairpin through the channel beside
|
|
@@ -267,10 +271,12 @@ const planRoutes = (edges, col, row, sides) => {
|
|
|
267
271
|
if (sChan === tChan)
|
|
268
272
|
return { chans: [sChan], guts: [], flags: [flag(sFrom, tTo)] };
|
|
269
273
|
const dir = tChan > sChan ? "r" : "l";
|
|
274
|
+
const gate = gates.has(edge.target) ? "t" : gates.has(edge.source) ? "s" : undefined;
|
|
270
275
|
return {
|
|
271
276
|
chans: [sChan, tChan],
|
|
272
277
|
guts: [tr > sr ? tr - 1 : tr],
|
|
273
|
-
flags: [flag(sFrom, dir), flag(dir === "r" ? "l" : "r", tTo)]
|
|
278
|
+
flags: [flag(sFrom, dir), flag(dir === "r" ? "l" : "r", tTo)],
|
|
279
|
+
gate
|
|
274
280
|
};
|
|
275
281
|
});
|
|
276
282
|
/* count the edges occupying each channel and gutter and determine
|
|
@@ -286,7 +292,8 @@ const planRoutes = (edges, col, row, sides) => {
|
|
|
286
292
|
const gutLbl = new Map();
|
|
287
293
|
const chanNeed = (c, width) => chanLbl.set(c, Math.max(chanLbl.get(c) ?? 0, width));
|
|
288
294
|
plans.forEach((plan, i) => {
|
|
289
|
-
|
|
295
|
+
const chans = trackChans(plan);
|
|
296
|
+
for (const c of chans)
|
|
290
297
|
chanCnt.set(c, (chanCnt.get(c) ?? 0) + 1);
|
|
291
298
|
for (const g of plan.guts)
|
|
292
299
|
gutCnt.set(g, (gutCnt.get(g) ?? 0) + 1);
|
|
@@ -297,8 +304,8 @@ const planRoutes = (edges, col, row, sides) => {
|
|
|
297
304
|
chanNeed(plan.chans[0], textWidth(name, FS_EDGE) + 2 * CHAN_LBL);
|
|
298
305
|
else if (name !== undefined && plan.guts.length > 0)
|
|
299
306
|
gutLbl.set(plan.guts[0], (gutLbl.get(plan.guts[0]) ?? 0) + 1);
|
|
300
|
-
if (arity !== undefined &&
|
|
301
|
-
chanNeed(
|
|
307
|
+
if (arity !== undefined && chans.length > 0)
|
|
308
|
+
chanNeed(chans[chans.length - 1], ARITY_OFF + textWidth(arity, FS_ARITY) + CHAN_LBL);
|
|
302
309
|
});
|
|
303
310
|
/* count the self-loops of every node, as their detours stack up
|
|
304
311
|
above its box and have to fit into the gutter above its row
|
|
@@ -363,10 +370,11 @@ const assignTrackCoords = (edges, plans, portPos, grid, config) => {
|
|
|
363
370
|
const { colWidth, rowHeight, chanW, gutH, colCX, rowCY } = grid;
|
|
364
371
|
const gutBase = (g) => rowCY[g] + rowHeight[g] / 2 + gutH[g] / 2;
|
|
365
372
|
/* assign the vertical tracks within the inter-column channels (the
|
|
366
|
-
leg of a self-loop spans up to its detour above the box
|
|
373
|
+
leg of a self-loop spans up to its detour above the box, and a
|
|
374
|
+
gutter-ending edge takes no track in its gate-side channel) */
|
|
367
375
|
const chanUsers = new Map();
|
|
368
376
|
edges.forEach((edge, i) => {
|
|
369
|
-
const { chans, guts, flags } = plans[i];
|
|
377
|
+
const { chans, guts, flags, gate } = plans[i];
|
|
370
378
|
if (chans.length === 0)
|
|
371
379
|
return;
|
|
372
380
|
const sp = portPos.get(`${i}:s`);
|
|
@@ -377,8 +385,10 @@ const assignTrackCoords = (edges, plans, portPos, grid, config) => {
|
|
|
377
385
|
pushTo(chanUsers, chans[0], { edge: i, posIn: sp.y, posOut: tp.y, ...flags[0] });
|
|
378
386
|
else {
|
|
379
387
|
const gy = gutBase(guts[0]);
|
|
380
|
-
|
|
381
|
-
|
|
388
|
+
if (gate !== "s")
|
|
389
|
+
pushTo(chanUsers, chans[0], { edge: i, posIn: sp.y, posOut: gy, ...flags[0] });
|
|
390
|
+
if (gate !== "t")
|
|
391
|
+
pushTo(chanUsers, chans[1], { edge: i, posIn: gy, posOut: tp.y, ...flags[1] });
|
|
382
392
|
}
|
|
383
393
|
});
|
|
384
394
|
const chanOff = new Map();
|
|
@@ -387,17 +397,20 @@ const assignTrackCoords = (edges, plans, portPos, grid, config) => {
|
|
|
387
397
|
chanOff.set(`${c}:${edge}`, off);
|
|
388
398
|
const chanX = (c, edge) => colCX[c] + colWidth[c] / 2 + chanW[c] / 2 +
|
|
389
399
|
chanOff.get(`${c}:${edge}`);
|
|
390
|
-
/* assign the horizontal tracks within the inter-row gutters
|
|
400
|
+
/* assign the horizontal tracks within the inter-row gutters (the
|
|
401
|
+
run of a gutter-ending edge extends up to its gate, where its
|
|
402
|
+
stub continues straight and hence crosses no other track) */
|
|
391
403
|
const gutUsers = new Map();
|
|
392
404
|
edges.forEach((_, i) => {
|
|
393
|
-
const { chans, guts } = plans[i];
|
|
405
|
+
const { chans, guts, gate } = plans[i];
|
|
394
406
|
if (guts.length === 0)
|
|
395
407
|
return;
|
|
396
408
|
const sp = portPos.get(`${i}:s`);
|
|
409
|
+
const tp = portPos.get(`${i}:t`);
|
|
397
410
|
pushTo(gutUsers, guts[0], {
|
|
398
411
|
edge: i,
|
|
399
|
-
posIn: chanX(chans[0], i),
|
|
400
|
-
posOut: chanX(chans[1], i),
|
|
412
|
+
posIn: gate === "s" ? sp.x : chanX(chans[0], i),
|
|
413
|
+
posOut: gate === "t" ? tp.x : chanX(chans[1], i),
|
|
401
414
|
mirror: sp.y > gutBase(guts[0])
|
|
402
415
|
});
|
|
403
416
|
});
|
|
@@ -442,10 +455,17 @@ const routePolys = (edges, plans, portPos, boxH, cy, chanX, gutY) => {
|
|
|
442
455
|
pts = [[sp.x, sp.y], [ch, sp.y], [ch, tp.y], [tp.x, tp.y]];
|
|
443
456
|
}
|
|
444
457
|
else {
|
|
458
|
+
/* a gutter-ending edge leaves the gutter straight into its
|
|
459
|
+
gate instead of turning into the gate-side channel */
|
|
445
460
|
const ch1 = chanX(chans[0], i);
|
|
446
461
|
const ch2 = chanX(chans[1], i);
|
|
447
462
|
const gy = gutY(guts[0], i);
|
|
448
|
-
|
|
463
|
+
if (plans[i].gate === "t")
|
|
464
|
+
pts = [[sp.x, sp.y], [ch1, sp.y], [ch1, gy], [tp.x, gy]];
|
|
465
|
+
else if (plans[i].gate === "s")
|
|
466
|
+
pts = [[sp.x, gy], [ch2, gy], [ch2, tp.y], [tp.x, tp.y]];
|
|
467
|
+
else
|
|
468
|
+
pts = [[sp.x, sp.y], [ch1, sp.y], [ch1, gy], [ch2, gy], [ch2, tp.y], [tp.x, tp.y]];
|
|
449
469
|
}
|
|
450
470
|
return simplifyPoly(pts);
|
|
451
471
|
});
|
|
@@ -480,7 +500,8 @@ const routeEdges = (edges, plans, sides, boxW, boxH, cx, cy, grid, config, level
|
|
|
480
500
|
gutter-routed edges keep approaching it from their gutter side */
|
|
481
501
|
const nudgeNodes = (nodes, edges, plans, col, row, boxH, grid, nrows, dy, route) => {
|
|
482
502
|
const gutterFree = (g, c) => !plans.some((plan) => plan.guts[0] === g
|
|
483
|
-
&& Math.min(...plan.chans) < c
|
|
503
|
+
&& Math.min(...plan.chans) < c
|
|
504
|
+
&& c <= Math.max(...plan.chans) + (plan.gate === "t" ? 1 : 0))
|
|
484
505
|
&& !edges.some((edge) => edge.source === edge.target
|
|
485
506
|
&& row.get(edge.source) === g + 1 && col.get(edge.source) === c);
|
|
486
507
|
const shiftRange = (id) => {
|
|
@@ -674,12 +695,12 @@ export const render = async (graph, config, level = {}) => {
|
|
|
674
695
|
/* plan the coarse channel/gutter route of every edge (a west side
|
|
675
696
|
attachment in the first column needs a channel left of it, so
|
|
676
697
|
the whole grid is shifted one column to the right then) */
|
|
677
|
-
let routes = planRoutes(edges, col, row, sides);
|
|
698
|
+
let routes = planRoutes(edges, col, row, sides, gates);
|
|
678
699
|
if (routes.plans.some((plan) => plan.chans.some((c) => c < 0))) {
|
|
679
700
|
for (const node of nodes)
|
|
680
701
|
col.set(node.id, col.get(node.id) + 1);
|
|
681
702
|
ncols++;
|
|
682
|
-
routes = planRoutes(edges, col, row, sides);
|
|
703
|
+
routes = planRoutes(edges, col, row, sides, gates);
|
|
683
704
|
}
|
|
684
705
|
const { plans, chanCnt, gutCnt, chanLbl, gutLbl, gutLoop } = routes;
|
|
685
706
|
/* grow the boxes by their edge attachment needs */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { measureNodes, orderOf } from "./gradia-api-render-node.js";
|
|
7
7
|
/* lay out an edge-less graph model as a compact grid of tiles (for a
|
|
8
8
|
containment level: with the container placeholders at their fixed
|
|
9
|
-
sizes, which take part in the tile
|
|
9
|
+
sizes, which take part in the tile width unification only), the tiles in
|
|
10
10
|
declaration order, or in the order of their "order" attributes
|
|
11
11
|
(the tiles without one trailing) */
|
|
12
12
|
export const render = async (graph, config, level = {}) => {
|
|
@@ -24,13 +24,18 @@ export const render = async (graph, config, level = {}) => {
|
|
|
24
24
|
throw new Error("diagram type \"grid\" does not support edges " +
|
|
25
25
|
`(found ${graph.edges.length}, first is "${edge.source}" --> "${edge.target}")`);
|
|
26
26
|
}
|
|
27
|
-
/* determine node box sizes and unify their
|
|
28
|
-
|
|
27
|
+
/* determine node box sizes and, if configured, unify their widths
|
|
28
|
+
into a single tile width (the container placeholders included, so
|
|
29
|
+
the container boxes line up) and their heights into a single tile
|
|
30
|
+
height (the container placeholders excluded, as the height of a
|
|
31
|
+
container box is the one of its content) */
|
|
29
32
|
const { boxW, boxH, contentH } = measureNodes(nodes, config, () => config["size-node-height-scale"] / 2, level.fixedSize);
|
|
30
|
-
const
|
|
33
|
+
const isFixed = (node) => level.fixedSize?.has(node.id) ?? false;
|
|
34
|
+
const tileH = nodes.reduce((a, node) => isFixed(node) ? a : Math.max(a, boxH.get(node.id)), 0);
|
|
31
35
|
const tileW = nodes.reduce((a, node) => Math.max(a, boxW.get(node.id)), 0);
|
|
32
36
|
for (const node of nodes) {
|
|
33
|
-
|
|
37
|
+
if (config["grid-node-height-equal"] && !isFixed(node))
|
|
38
|
+
boxH.set(node.id, tileH);
|
|
34
39
|
if (config["grid-node-width-equal"])
|
|
35
40
|
boxW.set(node.id, tileW);
|
|
36
41
|
}
|
|
@@ -39,11 +44,16 @@ export const render = async (graph, config, level = {}) => {
|
|
|
39
44
|
few nodes still share a row, and capped at the configured maximum
|
|
40
45
|
of columns and the node count, so larger graphs grow only in
|
|
41
46
|
height), with each column as wide as its widest tile and each
|
|
42
|
-
tile left-aligned
|
|
47
|
+
row as tall as its tallest tile, and each tile left-aligned
|
|
48
|
+
within its column and top-aligned within its row */
|
|
43
49
|
const cols = Math.max(Math.min(Math.max(Math.ceil(Math.sqrt(nodes.length)), minCols), maxCols, nodes.length), 1);
|
|
50
|
+
const rows = Math.ceil(nodes.length / cols);
|
|
44
51
|
const colWidth = Array.from({ length: cols }, () => 0);
|
|
52
|
+
const rowHeight = Array.from({ length: rows }, () => 0);
|
|
45
53
|
nodes.forEach((node, i) => {
|
|
46
|
-
|
|
54
|
+
const [c, r] = [i % cols, Math.floor(i / cols)];
|
|
55
|
+
colWidth[c] = Math.max(colWidth[c], boxW.get(node.id));
|
|
56
|
+
rowHeight[r] = Math.max(rowHeight[r], boxH.get(node.id));
|
|
47
57
|
});
|
|
48
58
|
const colLX = [];
|
|
49
59
|
let x = margin;
|
|
@@ -51,11 +61,17 @@ export const render = async (graph, config, level = {}) => {
|
|
|
51
61
|
colLX.push(x);
|
|
52
62
|
x += colWidth[c] + gapH;
|
|
53
63
|
}
|
|
64
|
+
const rowTY = [];
|
|
65
|
+
let y = margin;
|
|
66
|
+
for (let r = 0; r < rows; r++) {
|
|
67
|
+
rowTY.push(y);
|
|
68
|
+
y += rowHeight[r] + gapV;
|
|
69
|
+
}
|
|
54
70
|
const nodeCX = new Map();
|
|
55
71
|
const nodeCY = new Map();
|
|
56
72
|
nodes.forEach((node, i) => {
|
|
57
73
|
nodeCX.set(node.id, colLX[i % cols] + boxW.get(node.id) / 2);
|
|
58
|
-
nodeCY.set(node.id,
|
|
74
|
+
nodeCY.set(node.id, rowTY[Math.floor(i / cols)] + boxH.get(node.id) / 2);
|
|
59
75
|
});
|
|
60
76
|
const cx = (id) => nodeCX.get(id);
|
|
61
77
|
const cy = (id) => nodeCY.get(id);
|
package/dst/gradia-api.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Gradia={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)),u=e=>{let t=[],n=1,r=1,i=0,a=/--(?:\((?:"((?:[^"\\\n]|\\.)*)"|([^()"\s]+))\)--)?>(?:\[(?:"((?:[^"\\\n]|\\.)*)"|([^[\]"\s]+))\])?/y,o=/"((?:[^"\\\n]|\\.)*)"/y,s=/(?:(?!--)[^\s[\](),:">#])+/y,c=t=>(t.lastIndex=i,t.exec(e)),l=e=>e.replace(/\\(.)/g,`$1`);for(;i<e.length;){let u=e[i],d;if(u===`
|
|
2
2
|
`)t.push({type:`newline`,text:`
|
|
3
3
|
`,line:n,col:r}),n++,r=1,i++;else if(u===` `||u===` `||u===`\r`)r++,i++;else if(u===`#`)for(;i<e.length&&e[i]!==`
|
|
4
|
-
`;)r++,i++;else if((d=c(a))!==null){let e=d[1]===void 0?d[2]:l(d[1]),a=d[3]===void 0?d[4]:l(d[3]);t.push({type:`edge`,text:d[0],name:e,arity:a,line:n,col:r}),r+=d[0].length,i+=d[0].length}else if((d=c(o))!==null)t.push({type:`string`,text:l(d[1]),line:n,col:r}),r+=d[0].length,i+=d[0].length;else if(u===`"`)throw Error(`unterminated string at line ${n}, column ${r}`);else if(`[](),:`.includes(u))t.push({type:`punct`,text:u,line:n,col:r}),r++,i++;else if((d=c(s))!==null)t.push({type:`word`,text:d[0],line:n,col:r}),r+=d[0].length,i+=d[0].length;else throw Error(`invalid character ${JSON.stringify(u)} at line ${n}, column ${r}`)}return t},d=e=>{let t=u(e),n={nodes:new Map,edges:[]},r=0,i=()=>r<t.length?t[r]:null,a=e=>{let t=i();return t===null||t.type!==`punct`||t.text!==e?!1:(r++,!0)},o=e=>{let t=i(),n=t===null?`end of input`:`line ${t.line}, column ${t.col}`;throw Error(`expected ${e} at ${n}`)},s=()=>{let e=i();return e===null||e.type!==`word`&&e.type!==`string`?o(`bareword or quoted string`):(r++,e.text)},c=()=>{let e=t[r],i=s(),c=null;a(`:`)&&(c=s());let l=[];if(a(`[`)){for(;;){let e=s();a(`:`)||o(`":" in key/value attribute`);let t=s();if(l.push({key:e,val:t}),!a(`,`))break}a(`]`)||o(`"]" after key/value attributes`)}let u=n.nodes.get(i)??{id:i,name:i,attrs:[]};c!==null&&(u.name=c);for(let t of l){let n=u.attrs.findIndex(e=>e.key===t.key);if(n===-1)u.attrs.push(t);else{if((t.key===`group`||t.key===`parent`)&&u.attrs[n].val!==t.val)throw Error(`node "${i}" cannot be a member of more than one ${t.key===`group`?`group`:`container`} ("${u.attrs[n].val}" vs "${t.val}") at line ${e.line}, column ${e.col}`);u.attrs[n]=t}}let d=u.attrs.find(e=>e.key===`parent`)?.val;return d!==void 0&&!n.nodes.has(d)&&n.nodes.set(d,{id:d,name:d,attrs:[]}),n.nodes.set(i,u),i};for(;r<t.length;){if(t[r].type===`newline`){r++;continue}let e=c(),a=i();for(;a!==null&&a.type===`edge`;){r++;let t=c();n.edges.push({source:e,target:t,name:a.name,arity:a.arity}),e=t,a=i()}a!==null&&a.type!==`newline`&&o(`edge operator or end of line`)}return n},f=l(s(((e,t)=>{t.exports={}}))(),1),p={"font-family":`Helvetica`,"font-embed":!1,"color-node-regular-name":`#336699`,"color-node-regular-box":`#e0f0ff`,"color-node-regular-border":`#c0d0e0`,"color-node-primary-name":`#ffffff`,"color-node-primary-box":`#336699`,"color-node-primary-border":`#003366`,"color-node-ghost-name":`#666666`,"color-node-ghost-box":`#f0f0f0`,"color-node-ghost-border":`#a0a0a0`,"color-group-name":`#6699cc`,"color-group-box":`#f4f8fc`,"color-group-border":`#c0d0e0`,"color-container-name":`#666666`,"color-container-box":`#f6f6f6`,"color-container-border":`#a0a0a0`,"color-edge-line":`#999999`,"color-edge-name":`#333333`,"color-edge-arity":`#333333`,"color-edge-halo":`#ffffff`,"size-canvas-margin":40,"size-node-width-min":220,"size-node-width-max":0,"size-node-height-scale":2.25,"size-edge-corner-radius":20,"size-edge-hop-radius":8,"size-edge-track-gap":12,"size-edge-port-gap":24,"group-box-padding":30,"group-box-gap":40,"container-box-padding":30,"graph-columns-max":4,"graph-channel-width-max":140,"graph-channel-width-min":24,"graph-gutter-height-max":90,"graph-gutter-height-min":20,"graph-node-separation":30,"graph-rank-separation":60,"graph-node-degree-max":3,"hub-channel-width-max":340,"hub-channel-width-min":240,"hub-node-gap":20,"hub-node-degree-max":3,"grid-columns-max":4,"grid-columns-min":3,"grid-gap-horizontal":40,"grid-gap-vertical":20,"grid-node-width-equal":!0},m=(e,t)=>Object.hasOwn(e,t)?e[t].replace(/[;{}]/g,``):`var(--gradia-${t}, ${p[t]})`,h=(e,t)=>{let n={};for(let[r,i]of Object.entries(e)){if(!Object.hasOwn(p,r))throw Error(`unknown configuration option "${r}"`);let e=r;if(i!==void 0){if(e===`font-embed`&&!t.trusted)throw Error(`configuration option "${r}" is not available in this context`);if(typeof p[e]==`boolean`){if(typeof i!=`boolean`&&i!==`true`&&i!==`false`)throw Error(`invalid value "${String(i)}" for boolean configuration option "${r}" (expected "true" or "false")`);n[e]=typeof i==`boolean`?i:i===`true`}else if(typeof p[e]==`number`){let t=Number(i);if(typeof i!=`number`&&typeof i!=`string`||String(i).trim()===``||!Number.isFinite(t)||t<0)throw Error(`invalid value "${String(i)}" for numeric configuration option "${r}" (expected a non-negative number)`);n[e]=t}else{if(typeof i!=`string`)throw Error(`invalid value "${String(i)}" for string configuration option "${r}" (expected a string)`);if(i===``)throw Error(`invalid empty value for string configuration option "${r}"`);if(e===`font-family`&&i.endsWith(`.woff2`)&&!t.trusted)throw Error(`configuration option "font-family" must not be the path to a WOFF2 file in this context`);n[e]=i}}}return n},g=e=>{let t={};for(let n of e.split(/\r?\n/)){let e=/^[ \t]*#config[ \t]+([a-z][a-z0-9-]*)[ \t]+(?:"((?:[^"\\]|\\.)*)"|(\S+))[ \t]*$/.exec(n);if(e===null)continue;let r=e[2]===void 0?e[3]:e[2].replace(/\\(.)/g,`$1`);try{Object.assign(t,h({[e[1]]:r},{trusted:!1}))}catch{}}return t},_={"Source Sans 3":{file:`source-sans/WOFF2/VF/SourceSans3VF-Upright.ttf.woff2`,weight:`200 900`}},v=e=>{let t=e[`font-family`];if(Object.hasOwn(_,t)){let n=_[t];if(e[`font-embed`]){let e=f.default.fileURLToPath((e=>e)(n.file));return{family:t,embed:f.default.readFileSync(e).toString(`base64`),weight:n.weight}}return{family:t}}if(t.endsWith(`.woff2`)){let n=f.default.basename(t,`.woff2`);return e[`font-embed`]?{family:n,embed:f.default.readFileSync(t).toString(`base64`)}:{family:n}}if(e[`font-embed`])throw Error(`option "font-embed" requires option "font-family" to be a built-in font family (${Object.keys(_).map(e=>`"${e}"`).join(`, `)}) or the path to a WOFF2 file`);return{family:t}},y=(e,t)=>e.length*t*.52,b=(e,t,n)=>{let r=e.split(/\s+/).filter(e=>e!==``),i=r.join(` `);if(n<=0||r.length<=1||y(i,t)<=n)return[i];let a=[],o=r[0];for(let e of r.slice(1))y(`${o} ${e}`,t)>n?(a.push(o),o=e):o=`${o} ${e}`;return a.push(o),a},x=e=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`),S=e=>e.attrs.findLast(e=>e.key===`primary`)?.val===`true`,C=e=>S(e)?{fill:`color-node-primary-box`,stroke:`color-node-primary-border`,text:`color-node-primary-name`}:{fill:`color-node-regular-box`,stroke:`color-node-regular-border`,text:`color-node-regular-name`},w=e=>e.attrs.findLast(e=>e.key===`type`)?.val,T=e=>e.attrs.findLast(e=>e.key===`parent`)?.val,E=e=>e.attrs.findLast(e=>e.key===`container`)?.val,D=e=>34+(w(e)===void 0?0:20),O=e=>{let t=e.attrs.findLast(e=>e.key===`order`)?.val,n=t!==void 0&&t.trim()!==``?Number(t):NaN;return Number.isFinite(n)?n:void 0},k=new Set([`url`,`type`,`primary`,`group`,`parent`,`container`,`order`]),A=e=>e.attrs.filter(e=>!k.has(e.key)),ee=/^\s*([A-Za-z][A-Za-z0-9+.-]*):/,j=new Set([`http`,`https`,`mailto`]),M=e=>{let t=e.attrs.findLast(e=>e.key===`url`)?.val;if(t===void 0)return;let n=t.replace(/[\u0000-\u001F\u007F]/g,``),r=ee.exec(n);if(!(r!==null&&!j.has(r[1].toLowerCase())))return n},te=(e,t)=>{let n=t[`size-node-width-max`]>0?t[`size-node-width-max`]-36:0,r=w(e);return{name:b(e.name,30,n),type:r===void 0?[]:b(r,16,n),attrs:A(e).flatMap(e=>b(`${e.key}: ${e.val}`,22,n))}},N=(e,t,n,r)=>{let i=new Map,a=new Map,o=new Map;for(let s of e){let e=r?.get(s.id);if(e!==void 0){i.set(s.id,e.w),a.set(s.id,e.h),o.set(s.id,e.h);continue}let c=te(s,t),l=Math.max(0,...c.name.map(e=>y(e,30)),...c.type.map(e=>y(e,16)),...c.attrs.map(e=>y(e,22))),u=56+(c.name.length-1)*34+c.type.length*26+(c.attrs.length>0?12+(c.attrs.length-1)*30+20:0);i.set(s.id,Math.max(t[`size-node-width-min`],Math.ceil(l)+36)),a.set(s.id,Math.max(u,Math.ceil(u*n(s)))),o.set(s.id,u)}return{boxW:i,boxH:a,contentH:o}},P=10,F=e=>{let t=[...e];for(let e=t.length-2;e>0;e--){let[n,r,i]=[t[e-1],t[e],t[e+1]];(n[0]===r[0]&&r[0]===i[0]||n[1]===r[1]&&r[1]===i[1])&&t.splice(e,1)}let n=[];for(let e of t)n.length>0&&n[n.length-1][0]===e[0]&&n[n.length-1][1]===e[1]||n.push(e);return n},I=(e,t,n,r,i,a,o,s,c)=>{let l=new Map,u=(e,t,n)=>{let r=l.get(e);r===void 0?l.set(e,[{edge:t,role:n}]):r.push({edge:t,role:n})};e.forEach((e,n)=>{u(`${e.source}:${t[n].s}`,n,`s`),u(`${e.target}:${t[n].t}`,n,`t`)});let d=new Map;for(let[t,u]of l){let l=t.lastIndexOf(`:`),f=t.slice(0,l),p=t.slice(l+1);if(p===`n`){u.sort((e,t)=>t.edge-e.edge);let e=Math.min(o,(i.get(f)-P)/u.length);u.forEach((t,i)=>{d.set(`${t.edge}:${t.role}`,{x:n(f)+(i-(u.length-1)/2)*e,y:r(f)-a.get(f)/2})});continue}let m=n(f)+(p===`e`?1:-1)*i.get(f)/2,h=e=>c?.(e.edge,e.role),g=[];for(let e of u.filter(e=>h(e)!==void 0)){let t=r(f)+h(e);d.set(`${e.edge}:${e.role}`,{x:m,y:t}),g.push(t)}g.sort((e,t)=>e-t);let _=u.filter(e=>h(e)===void 0),v=t=>t.role===`s`?e[t.edge].target:e[t.edge].source,y=e=>s?.(e.edge)??r(v(e));_.sort((e,t)=>y(e)-y(t)||e.edge-t.edge);let b=_.length+g.length,x=Math.min(o,(a.get(f)-P)/b),S=(e,t)=>d.set(`${e.edge}:${e.role}`,{x:m,y:t});if(g.length===0){_.forEach((e,t)=>S(e,r(f)+(t-(b-1)/2)*x));continue}let C=r(f)-(a.get(f)-P)/2+x/2,w=r(f)+(a.get(f)-P)/2-x/2,T=[C-x,...g,w+x],E=e=>g.filter(t=>t<y(e)).length,D=T.slice(1).map((e,t)=>({lo:Math.max(C,T[t]+x),hi:Math.min(w,e-x),ports:_.filter(e=>E(e)===t)})),O=e=>e.hi<e.lo?0:Math.floor((e.hi-e.lo)/x)+1;for(let e=0;e<D.length-1;e++)for(;D[e].ports.length>O(D[e]);)D[e+1].ports.unshift(D[e].ports.pop());for(let e=D.length-1;e>0;e--)for(;D[e].ports.length>O(D[e]);)D[e-1].ports.push(D[e].ports.shift());let k=0;D.forEach((e,t)=>{let n=e.ports.length,i=n>1?Math.min(x,Math.max(e.hi-e.lo,0)/(n-1)):x,a=Math.min(Math.max(r(f)+(k+t-(b-1)/2)*x,e.lo),e.hi-(n-1)*i);e.ports.forEach((e,t)=>S(e,a+t*i)),k+=n})}return d},ne=24,L=e=>e.hairpin?e.mirror?[]:[e.posIn,e.posOut]:[e.mirror?e.posOut:e.posIn],re=e=>e.hairpin?e.mirror?[e.posIn,e.posOut]:[]:[e.mirror?e.posIn:e.posOut],ie=(e,t)=>{let n=(e,t)=>t>=Math.min(e.posIn,e.posOut)&&t<=Math.max(e.posIn,e.posOut);return re(e).filter(e=>n(t,e)).length+L(t).filter(t=>n(e,t)).length},ae=(e,t)=>re(e).filter(e=>L(t).includes(e)).length,oe=14,se=e=>{let t=e.length;if(t<2)return e;let n=e.map((n,r)=>e.map((e,i)=>(ae(n,e)*2*t*t+ie(n,e))*t*t+ +(r>i))),r;if(t<=oe){let e=new Float64Array(1<<t).fill(1/0),i=new Int8Array(1<<t);e[0]=0;for(let r=1;r<1<<t;r++)for(let a=0;a<t;a++){if(!(r&1<<a))continue;let o=r&~(1<<a),s=e[o];for(let e=0;e<t;e++)o&1<<e&&(s+=n[e][a]);s<e[r]&&(e[r]=s,i[r]=a)}r=[];for(let e=(1<<t)-1;e!==0;e&=~(1<<i[e]))r.unshift(i[e])}else{r=e.map((e,t)=>t);for(let e=!0;e;){e=!1;for(let i=1;i<t&&!e;i++)for(let a=0;a+i<=t&&!e;a++){let o=0;for(let s=a+i;s<t&&!e;s++){for(let e=a;e<a+i;e++)o+=n[r[s]][r[e]]-n[r[e]][r[s]];o<0&&(r.splice(s-i+1,0,...r.splice(a,i)),e=!0)}o=0;for(let t=a-1;t>=0&&!e;t--){for(let e=a;e<a+i;e++)o+=n[r[e]][r[t]]-n[r[t]][r[e]];o<0&&(r.splice(t,0,...r.splice(a,i)),e=!0)}}}}return r.map(t=>e[t])},ce=(e,t,n,r)=>{let i=(e,t)=>{let n=t?-1:1,r=e.filter(e=>e.posOut<e.posIn).sort((e,t)=>n*(e.posIn-t.posIn||e.posOut-t.posOut)),i=e.filter(e=>e.posOut>=e.posIn).sort((e,t)=>n*(t.posIn-e.posIn||t.posOut-e.posOut));return[...r,...i]},a=se([...i(e.filter(e=>!e.mirror),!1),...i(e.filter(e=>e.mirror),!0)]),o=(e,t)=>Math.min(e.posIn,e.posOut)<Math.max(t.posIn,t.posOut)+ne&&Math.min(t.posIn,t.posOut)<Math.max(e.posIn,e.posOut)+ne,s=new Map,c=0;a.forEach((e,t)=>{let n=0;for(let r=0;r<t;r++)o(a[r],e)&&(n=Math.max(n,s.get(a[r].edge)+1));s.set(e.edge,n),c=Math.max(c,n+1)});let l=Math.min(r,(t-n)/Math.max(c-1,1)),u=new Map;for(let[e,t]of s)u.set(e,(t-(c-1)/2)*l);return u},le=e=>{let t=[];return e.forEach((e,n)=>{for(let r=0;r<e.length-1;r++){let[i,a]=[e[r],e[r+1]];i[0]===a[0]&&t.push({owner:n,x:i[0],y1:Math.min(i[1],a[1]),y2:Math.max(i[1],a[1])})}}),e.map((e,n)=>{let r=new Map;for(let i=0;i<e.length-1;i++){let[a,o]=[e[i],e[i+1]];if(a[1]!==o[1])continue;let s=a[1],c=Math.min(a[0],o[0]),l=Math.max(a[0],o[0]),u=[];for(let e of t)e.owner!==n&&e.x>c+1&&e.x<l-1&&s>e.y1+1&&s<e.y2-1&&u.push(e.x);u.length>0&&r.set(i,u)}return r})},ue=(e,t)=>Math.abs(t[0]-e[0])+Math.abs(t[1]-e[1]),de=(e,t,n,r)=>{let i=i=>{if(i<=0||i>=e.length-1)return 0;let a=Math.min(n,ue(e[i-1],e[i])/2,ue(e[i],e[i+1])/2);for(let n of[i-1,i])for(let o of t.get(n)??[])a=Math.min(a,Math.max(Math.abs(o-e[i][0])-r-2,4));return a},a=[];for(let n=0;n<e.length-1;n++){let[o,s]=[e[n],e[n+1]],c=ue(o,s),l=(s[0]-o[0])/c,u=(s[1]-o[1])/c,d=i(n),f=i(n+1),p=[o[0]+l*d,o[1]+u*d],m=[s[0]-l*f,s[1]-u*f];if(n===0&&a.push(`M ${p[0]} ${p[1]}`),o[1]===s[1]&&t.has(n)){let e=Math.sign(s[0]-o[0]),i=t.get(n).filter(t=>(t-p[0])*e>2&&(m[0]-t)*e>2).sort((t,n)=>(t-n)*e),c=[];for(let e of i){let t=c[c.length-1];t!==void 0&&Math.abs(e-t[t.length-1])<=r*2+14?t.push(e):c.push([e])}for(let t of c){let n=t[0]-e*r,i=t[t.length-1]+e*r;(n-p[0])*e<0&&(n=p[0]),(m[0]-i)*e<0&&(i=m[0]),a.push(`L ${n} ${o[1]}`),a.push(`A ${Math.abs(i-n)/2} ${r} 0 0 ${+(e>0)} ${i} ${o[1]}`)}}if(a.push(`L ${m[0]} ${m[1]}`),n<e.length-2){let t=e[n+1],r=e[n+2],i=ue(t,r),o=[t[0]+(r[0]-t[0])/i*f,t[1]+(r[1]-t[1])/i*f];a.push(`Q ${s[0]} ${s[1]} ${o[0]} ${o[1]}`)}}return a.join(` `)},fe=(e,t)=>{let n=e.slice(0,-1).map((t,n)=>ue(t,e[n+1])),r=n.reduce((e,t)=>e+t,0)*t;for(let t=0;t<n.length;t++){if(r<=n[t]||t===n.length-1){let i=n[t]>0?r/n[t]:0;return{x:e[t][0]+(e[t+1][0]-e[t][0])*Math.min(i,1),y:e[t][1]+(e[t+1][1]-e[t][1])*Math.min(i,1),horizontal:e[t][1]===e[t+1][1]}}r-=n[t]}return{x:e[0][0],y:e[0][1],horizontal:!0}},R=(e,t)=>{let n=new Map,r=new Map;for(let i of e.nodes.values()){let a=E(i);if(a!==void 0&&!t.includes(a))throw Error(`invalid container layout type "${a}" of node "${i.id}"`);let o=T(i);if(o===void 0)continue;if(!e.nodes.has(o))throw Error(`container "${o}" of node "${i.id}" is not a declared node`);n.set(i.id,o);let s=r.get(o);s===void 0?r.set(o,[i]):s.push(i)}for(let e of n.keys()){let t=new Set([e]);for(let r=n.get(e);r!==void 0;r=n.get(r)){if(t.has(r))throw Error(`node "${e}" cannot be nested into itself (containment cycle)`);t.add(r)}}let i=(e,t)=>{for(let r=n.get(t);r!==void 0;r=n.get(r))if(r===e)return!0;return!1};for(let t of e.edges)if(i(t.source,t.target)||i(t.target,t.source))throw Error(`edge "${t.source}" --> "${t.target}" connects a container with one of its own members`);return{parentOf:n,childrenOf:r}},pe=(e,t)=>{let n=t;for(let t=e.parentOf.get(n);t!==void 0;t=e.parentOf.get(n))n=t;return n},me=(e,t=[])=>{let{nodes:n,cx:r,cy:i,boxW:a,boxH:o,polys:s}=e,[c,l,u,d]=[1/0,1/0,-1/0,-1/0];for(let e of n)c=Math.min(c,r(e.id)-a.get(e.id)/2),l=Math.min(l,i(e.id)-o.get(e.id)/2),u=Math.max(u,r(e.id)+a.get(e.id)/2),d=Math.max(d,i(e.id)+o.get(e.id)/2);for(let e of[...s,...t])for(let[t,n]of e)c=Math.min(c,t),l=Math.min(l,n),u=Math.max(u,t),d=Math.max(d,n);for(let t of e.containers??[])c=Math.min(c,t.x),l=Math.min(l,t.y),u=Math.max(u,t.x+t.w),d=Math.max(d,t.y+t.h);return Number.isFinite(c)||([c,l,u,d]=[0,0,0,0]),{minX:c,minY:l,maxX:u,maxY:d}},he=(e,t)=>`\u0000gate:${e}:${t}`,ge=async(e,t,n,r,i)=>{let a=Array.from(e.nodes.values()),o=e=>t.childrenOf.has(e.id)||E(e)!==void 0;if(!a.some(o))return r[n].render(e,i);let s=i[`container-box-padding`];for(let e of a)if(e.id.includes(`\0`))throw Error(`node id ${JSON.stringify(e.id)} contains a reserved control character`);let c=(e,t)=>{let n=Math.max(y(e.name,24),y(w(e)??``,16));return{w:Math.max(t.maxX-t.minX,n)+s*2,h:t.maxY-t.minY+s*2+D(e)}},l=(t,n,r,i,a,o)=>{let l=[{layout:t,dx:0,dy:0}],u=new Map;for(let e of t.nodes)u.set(e.id,0);let d=[],f=[];for(let[r,i]of n){let n=e.nodes.get(r);if(!t.nodes.some(e=>e.id===r))throw Error(`container "${r}" cannot be placed twice by diagram type "${o}"`);let{w:a,h:p}=c(n,i.bounds),m=t.cx(r),h=t.cy(r),g=l.push({layout:i.layout,dx:m-a/2+s-i.bounds.minX,dy:h-p/2+D(n)+s-i.bounds.minY})-1;for(let e of i.layout.nodes)u.set(e.id,g);u.set(r,g),d.push({node:n,x:m-t.boxW.get(r)/2,y:h-t.boxH.get(r)/2,w:t.boxW.get(r),h:t.boxH.get(r)}),f.push(...(i.layout.containers??[]).map(e=>({...e,x:e.x+l[g].dx,y:e.y+l[g].dy})))}let p=(e,t)=>e.map(([e,n])=>[e+l[t].dx,n+l[t].dy]),m=[],h=[],g=new Map;l.forEach((e,t)=>{t!==0&&e.layout.edges.forEach((n,r)=>{m.push(n),h.push(p(e.layout.polys[r],t))})}),r.forEach((r,o)=>{let s=i[o],c=n.get(r.source)?.partial.get(s),l=n.get(r.target)?.partial.get(s),d=F([...c===void 0?[]:p(c,u.get(r.source)),...t.polys[o],...l===void 0?[]:p(l,u.get(r.target))]);a.has(r.source)||a.has(r.target)?g.set(s,d):(m.push(e.edges[s]),h.push(d))});let _=e=>new Map(l.flatMap(t=>Array.from(e(t.layout).entries()))),v={nodes:[...t.nodes.filter(e=>!n.has(e.id)&&!a.has(e.id)),...l.slice(1).flatMap(e=>e.layout.nodes)],edges:m,cx:e=>l[u.get(e)].layout.cx(e)+l[u.get(e)].dx,cy:e=>l[u.get(e)].layout.cy(e)+l[u.get(e)].dy,boxW:_(e=>e.boxW),boxH:_(e=>e.boxH),contentH:_(e=>e.contentH),polys:h,styleOf:e=>(l[u.get(e.id)].layout.styleOf??C)(e),containers:[...d,...f]};return{layout:v,bounds:me(v,Array.from(g.values())),partial:g}},u=async(n,d)=>{let f=n===null?a.filter(e=>T(e)===void 0):t.childrenOf.get(n.id)??[],p=new Set(f.map(e=>e.id)),m=e=>{for(let n=e;n!==void 0;n=t.parentOf.get(n))if(p.has(n))return n},h=new Map;for(let e of f)o(e)&&h.set(e.id,await u(e,E(e)??d));let g=(e,t)=>{let{bounds:n}=h.get(e.id);return t-n.minY+D(e)+s-c(e,n).h/2},_=new Map,v=new Map(f.map(e=>[e.id,e])),y=[],b=[],x=new Map,S=(e,t)=>h.get(e)?.partial.has(t)??!1;e.edges.forEach((e,t)=>{let n=m(e.source),i=m(e.target);if(n===void 0&&i===void 0||n!==void 0&&i!==void 0&&n===i&&h.has(n)&&e.source!==n)return;let a,o;if(n===void 0||i===void 0){if(!r[d].gated)return;let e=he(t,n===void 0?`in`:`out`);_.set(e,n===void 0?`in`:`out`),v.set(e,{id:e,name:``,attrs:[]}),a=n??e,o=i??e}else a=n,o=i;let s=y.length;y.push({source:a,target:o,name:n!==void 0&&i!==void 0?e.name:void 0,arity:i!==void 0&&!S(i,t)?e.arity:void 0}),b.push(t),S(a,t)&&x.set(`${s}:s`,g(v.get(a),h.get(a).partial.get(t).at(-1)[1])),S(o,t)&&x.set(`${s}:t`,g(v.get(o),h.get(o).partial.get(t)[0][1]))});let C=new Map;for(let[e,t]of h)C.set(e,c(v.get(e),t.bounds));for(let e of _.keys())C.set(e,{w:0,h:0});let w=await r[d].render({nodes:v,edges:y},i,{fixedSize:C,fixedPort:(e,t)=>x.get(`${e}:${t}`),gates:_});return l(w,h,y,b,_,d)};return(await u(null,n)).layout},_e=34,ve=e=>e.attrs.findLast(e=>e.key===`group`)?.val,ye=(e,t)=>{let n=Array.from(e.nodes.values());if(!n.some(e=>ve(e)!==void 0))return null;let r=new Map,i=new Map;for(let a of n){let n=pe(t,a.id),o=ve(e.nodes.get(n))??`default`,s=ve(a);if(s!==void 0&&s!==o)throw Error(`node "${a.id}" cannot be a member of group "${s}", as its container "${n}" is a member of group "${o}"`);i.set(a.id,o);let c=r.get(o);c===void 0&&(c={nodes:new Map,edges:[]},r.set(o,c)),c.nodes.set(a.id,a)}for(let t of e.edges){let e=i.get(t.source),n=i.get(t.target);if(e!==n)throw Error(`edge "${t.source}" --> "${t.target}" crosses groups "${e}" and "${n}"`);r.get(e).edges.push(t)}return Array.from(r.entries()).map(([e,t])=>({name:e,graph:t}))},be=(e,t,n)=>{let r=n[`size-canvas-margin`],i=n[`group-box-padding`],a=n[`group-box-gap`],o=[],s=[],c=[],l=new Map,u=r;t.forEach((t,n)=>{let d=me(t),f=Math.max(d.maxX-d.minX+i*2,y(e[n].name,24)+i*2),p=d.maxY-d.minY+i*2+_e;s.push(r+i-d.minX),c.push(u+_e+i-d.minY);for(let e of t.nodes)l.set(e.id,n);o.push({name:e[n].name,x:r,y:u,w:f,h:p}),u+=p+a});let d=e=>new Map(t.flatMap(t=>Array.from(e(t).entries()))),f=e=>l.get(e);return{nodes:t.flatMap(e=>e.nodes),edges:t.flatMap(e=>e.edges),cx:e=>t[f(e)].cx(e)+s[f(e)],cy:e=>t[f(e)].cy(e)+c[f(e)],boxW:d(e=>e.boxW),boxH:d(e=>e.boxH),contentH:d(e=>e.contentH),polys:t.flatMap((e,t)=>e.polys.map(e=>e.map(([e,n])=>[e+s[t],n+c[t]]))),styleOf:e=>(t[f(e.id)].styleOf??C)(e),groups:o,containers:t.flatMap((e,t)=>(e.containers??[]).map(e=>({...e,x:e.x+s[t],y:e.y+c[t]})))}},xe=l(s(((e,t)=>{(function(e,n,r){typeof define==`function`&&define.amd!==void 0?define(function(){return r(e)}):typeof t==`object`&&typeof t.exports==`object`?(t.exports=r(e),t.exports.default=t.exports):e[n]=r(e)})(e,`UUID`,function(){let e=function(e,t,n,r,i,a){let o=function(e,t){let n=e.toString(16);return n.length<2&&(n=`0`+n),t&&(n=n.toUpperCase()),n};for(let s=t;s<=n;s++)i[a++]=o(e[s],r);return i},t=function(e,t,n,r,i){for(let a=t;a<=n;a+=2)r[i++]=parseInt(e.substr(a,2),16)},n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#`.split(``),r=[0,68,0,84,83,82,72,0,75,76,70,65,0,63,62,69,0,1,2,3,4,5,6,7,8,9,64,0,73,66,74,71,81,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,0,78,67,0,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,79,0,80,0,0],i=function(e,t){if(t%4!=0)throw Error(`z85_encode: invalid input length (multiple of 4 expected)`);let r=``,i=0,a=0;for(;i<t;)if(a=a*256+e[i++],i%4==0){let e=52200625;for(;e>=1;){let t=Math.floor(a/e)%85;r+=n[t],e/=85}a=0}return r},a=function(e,t){let n=e.length;if(n%5!=0)throw Error(`z85_decode: invalid input length (multiple of 5 expected)`);t===void 0&&(t=Array(n*4/5));let i=0,a=0,o=0;for(;i<n;){let n=e.charCodeAt(i++)-32;if(n<0||n>=r.length)break;if(o=o*85+r[n],i%5==0){let e=16777216;for(;e>=1;)t[a++]=Math.trunc(o/e%256),e/=256;o=0}}return t},o=function(e,t){let n={ibits:8,obits:8,obigendian:!0};for(let e in t)n[e]!==void 0&&(n[e]=t[e]);let r=[],i=0,a,o,s=0,c,l=0,u=e.length;for(;s===0&&(o=e.charCodeAt(i++)),a=o>>n.ibits-(s+8)&255,s=(s+8)%n.ibits,n.obigendian?l===0?c=a<<n.obits-8:c|=a<<n.obits-8-l:l===0?c=a:c|=a<<l,l=(l+8)%n.obits,!(l===0&&(r.push(c),i>=u)););return r},s=function(e,t){let n={ibits:32,ibigendian:!0};for(let e in t)n[e]!==void 0&&(n[e]=t[e]);let r=``,i=4294967295;n.ibits<32&&(i=(1<<n.ibits)-1);let a=e.length;for(let t=0;t<a;t++){let a=e[t]&i;for(let e=0;e<n.ibits;e+=8)n.ibigendian?r+=String.fromCharCode(a>>n.ibits-8-e&255):r+=String.fromCharCode(a>>e&255)}return r},c=function(e,t,n,r,i,a,o,s){return[s,o,a,i,r,n,t,e]},l=function(){return c(0,0,0,0,0,0,0,0)},u=function(e){return e.slice(0)},d=function(e){let t=l();for(let n=0;n<8;n++)t[n]=Math.floor(e%256),e/=256;return t},f=function(e){let t=0;for(let n=7;n>=0;n--)t*=256,t+=e[n];return Math.floor(t)},p=function(e,t){let n=0;for(let r=0;r<8;r++)n+=e[r]+t[r],e[r]=Math.floor(n%256),n=Math.floor(n/256);return n},m=function(e,t){let n=0;for(let r=0;r<8;r++)n+=e[r]*t,e[r]=Math.floor(n%256),n=Math.floor(n/256);return n},h=function(e,t){let n,r,i=Array(16);for(n=0;n<16;n++)i[n]=0;let a;for(n=0;n<8;n++){for(a=0,r=0;r<8;r++)a+=e[n]*t[r]+i[n+r],i[n+r]=a%256,a/=256;for(;r<16-n;r++)a+=i[n+r],i[n+r]=a%256,a/=256}for(n=0;n<8;n++)e[n]=i[n];return i.slice(8,16)},g=function(e,t){for(let n=0;n<8;n++)e[n]&=t[n];return e},_=function(e,t){for(let n=0;n<8;n++)e[n]|=t[n];return e},v=function(e,t){let n=l();if(t%8!=0)throw Error(`ui64_rorn: only bit rotations supported with a multiple of digit bits`);let r=Math.floor(t/8);for(let t=0;t<r;t++){let t;for(t=6;t>=0;t--)n[t+1]=n[t];for(n[0]=e[0],t=0;t<7;t++)e[t]=e[t+1];e[t]=0}return f(n)},y=function(e,t){if(t>64)throw Error(`ui64_ror: invalid number of bits to shift`);let n=Array(16),r;for(r=0;r<8;r++)n[r+8]=e[r],n[r]=0;let i=Math.floor(t/8),a=t%8;for(r=i;r<15;r++)n[r-i]=(n[r]>>>a|n[r+1]<<8-a)&255;for(n[15-i]=n[15]>>>a&255,r=15-i+1;r<16;r++)n[r]=0;for(r=0;r<8;r++)e[r]=n[r+8];return n.slice(0,8)},b=function(e,t){if(t>64)throw Error(`ui64_rol: invalid number of bits to shift`);let n=Array(16),r;for(r=0;r<8;r++)n[r+8]=0,n[r]=e[r];let i=Math.floor(t/8),a=t%8;for(r=7-i;r>0;r--)n[r+i]=(n[r]<<a|n[r-1]>>>8-a)&255;for(n[0+i]=n[0]<<a&255,r=0+i-1;r>=0;r--)n[r]=0;for(r=0;r<8;r++)e[r]=n[r];return n.slice(8,16)},x=function(e,t){for(let n=0;n<8;n++)e[n]^=t[n]},S=function(e,t){let n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535},C=function(e,t){return e<<t&4294967295|e>>>32-t&4294967295},w=function(e,t){function n(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function r(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}e[t>>5]|=128<<24-t%32,e[(t+64>>9<<4)+15]=t;let i=Array(80),a=1732584193,o=-271733879,s=-1732584194,c=271733878,l=-1009589776;for(let t=0;t<e.length;t+=16){let u=a,d=o,f=s,p=c,m=l;for(let u=0;u<80;u++){u<16?i[u]=e[t+u]:i[u]=C(i[u-3]^i[u-8]^i[u-14]^i[u-16],1);let d=S(S(C(a,5),n(u,o,s,c)),S(S(l,i[u]),r(u)));l=c,c=s,s=C(o,30),o=a,a=d}a=S(a,u),o=S(o,d),s=S(s,f),c=S(c,p),l=S(l,m)}return[a,o,s,c,l]},T=function(e){return s(w(o(e,{ibits:8,obits:32,obigendian:!0}),e.length*8),{ibits:32,ibigendian:!0})},E=function(e,t){function n(e,t,n,r,i,a){return S(C(S(S(t,e),S(r,a)),i),n)}function r(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function i(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}e[t>>5]|=128<<t%32,e[(t+64>>>9<<4)+14]=t;let s=1732584193,c=-271733879,l=-1732584194,u=271733878;for(let t=0;t<e.length;t+=16){let n=s,d=c,f=l,p=u;s=r(s,c,l,u,e[t+0],7,-680876936),u=r(u,s,c,l,e[t+1],12,-389564586),l=r(l,u,s,c,e[t+2],17,606105819),c=r(c,l,u,s,e[t+3],22,-1044525330),s=r(s,c,l,u,e[t+4],7,-176418897),u=r(u,s,c,l,e[t+5],12,1200080426),l=r(l,u,s,c,e[t+6],17,-1473231341),c=r(c,l,u,s,e[t+7],22,-45705983),s=r(s,c,l,u,e[t+8],7,1770035416),u=r(u,s,c,l,e[t+9],12,-1958414417),l=r(l,u,s,c,e[t+10],17,-42063),c=r(c,l,u,s,e[t+11],22,-1990404162),s=r(s,c,l,u,e[t+12],7,1804603682),u=r(u,s,c,l,e[t+13],12,-40341101),l=r(l,u,s,c,e[t+14],17,-1502002290),c=r(c,l,u,s,e[t+15],22,1236535329),s=i(s,c,l,u,e[t+1],5,-165796510),u=i(u,s,c,l,e[t+6],9,-1069501632),l=i(l,u,s,c,e[t+11],14,643717713),c=i(c,l,u,s,e[t+0],20,-373897302),s=i(s,c,l,u,e[t+5],5,-701558691),u=i(u,s,c,l,e[t+10],9,38016083),l=i(l,u,s,c,e[t+15],14,-660478335),c=i(c,l,u,s,e[t+4],20,-405537848),s=i(s,c,l,u,e[t+9],5,568446438),u=i(u,s,c,l,e[t+14],9,-1019803690),l=i(l,u,s,c,e[t+3],14,-187363961),c=i(c,l,u,s,e[t+8],20,1163531501),s=i(s,c,l,u,e[t+13],5,-1444681467),u=i(u,s,c,l,e[t+2],9,-51403784),l=i(l,u,s,c,e[t+7],14,1735328473),c=i(c,l,u,s,e[t+12],20,-1926607734),s=a(s,c,l,u,e[t+5],4,-378558),u=a(u,s,c,l,e[t+8],11,-2022574463),l=a(l,u,s,c,e[t+11],16,1839030562),c=a(c,l,u,s,e[t+14],23,-35309556),s=a(s,c,l,u,e[t+1],4,-1530992060),u=a(u,s,c,l,e[t+4],11,1272893353),l=a(l,u,s,c,e[t+7],16,-155497632),c=a(c,l,u,s,e[t+10],23,-1094730640),s=a(s,c,l,u,e[t+13],4,681279174),u=a(u,s,c,l,e[t+0],11,-358537222),l=a(l,u,s,c,e[t+3],16,-722521979),c=a(c,l,u,s,e[t+6],23,76029189),s=a(s,c,l,u,e[t+9],4,-640364487),u=a(u,s,c,l,e[t+12],11,-421815835),l=a(l,u,s,c,e[t+15],16,530742520),c=a(c,l,u,s,e[t+2],23,-995338651),s=o(s,c,l,u,e[t+0],6,-198630844),u=o(u,s,c,l,e[t+7],10,1126891415),l=o(l,u,s,c,e[t+14],15,-1416354905),c=o(c,l,u,s,e[t+5],21,-57434055),s=o(s,c,l,u,e[t+12],6,1700485571),u=o(u,s,c,l,e[t+3],10,-1894986606),l=o(l,u,s,c,e[t+10],15,-1051523),c=o(c,l,u,s,e[t+1],21,-2054922799),s=o(s,c,l,u,e[t+8],6,1873313359),u=o(u,s,c,l,e[t+15],10,-30611744),l=o(l,u,s,c,e[t+6],15,-1560198380),c=o(c,l,u,s,e[t+13],21,1309151649),s=o(s,c,l,u,e[t+4],6,-145523070),u=o(u,s,c,l,e[t+11],10,-1120210379),l=o(l,u,s,c,e[t+2],15,718787259),c=o(c,l,u,s,e[t+9],21,-343485551),s=S(s,n),c=S(c,d),l=S(l,f),u=S(u,p)}return[s,c,l,u]},D=function(e){return s(E(o(e,{ibits:8,obits:32,obigendian:!1}),e.length*8),{ibits:32,ibigendian:!1})},O=function(e){this.mul=c(88,81,244,45,76,149,127,45),this.inc=c(20,5,123,126,247,103,129,79),this.mask=c(0,0,0,0,255,255,255,255),this.state=u(this.inc),this.next(),g(this.state,this.mask);let t;e===void 0?typeof window==`object`&&typeof window.crypto==`object`&&typeof window.crypto.getRandomValues==`function`?(t=new Uint32Array(2),window.crypto.getRandomValues(t),e=_(d(t[0]>>>0),y(d(t[1]>>>0),32))):typeof globalThis==`object`&&typeof globalThis.crypto==`object`&&typeof globalThis.crypto.getRandomValues==`function`?(t=new Uint32Array(2),globalThis.crypto.getRandomValues(t),e=_(d(t[0]>>>0),y(d(t[1]>>>0),32))):(e=d(Math.random()*4294967295>>>0),_(e,y(d(new Date().getTime()),32))):e=d(e>>>0),_(this.state,e),this.next()};O.prototype.next=function(){let e=u(this.state);h(this.state,this.mul),p(this.state,this.inc);let t=u(e);y(t,18),x(t,e),y(t,27);let n=u(e);y(n,59),g(t,this.mask);let r=f(n),i=u(t);return b(i,32-r),y(t,r),x(t,i),f(t)},O.prototype.reseed=function(e){if(typeof e!=`string`)throw Error(`UUID: PCG: seed: invalid argument (string expected)`);let t=w(o(e,{ibits:8,obits:32,obigendian:!0}),e.length*8);for(let e=0;e<t.length;e++)x(k.state,d(t[e]>>>0))};let k=new O;O.reseed=function(e){k.reseed(e)};let A=function(e,t){let n=[];for(let r=0;r<e;r++)n[r]=k.next()%t;return n},ee=0,j=0,M=function(){if(arguments.length===1&&typeof arguments[0]==`string`)this.parse.apply(this,arguments);else if(arguments.length>=1&&typeof arguments[0]==`number`)this.make.apply(this,arguments);else if(arguments.length>=1)throw Error(`UUID: constructor: invalid arguments`);else for(let e=0;e<16;e++)this[e]=0};return M.prototype=typeof Uint8Array<`u`?new Uint8Array(16):typeof Buffer<`u`?Buffer.alloc(16):Array(16),M.prototype.constructor=M,M.prototype.make=function(e){let t,n=this;if(e===1){let e=new Date().getTime();e===ee?j++:j=0,ee=e;let r=d(e);m(r,1e4),p(r,c(1,178,29,210,19,129,64,0)),j>0&&p(r,d(j));let i;i=v(r,8),n[3]=i&255,i=v(r,8),n[2]=i&255,i=v(r,8),n[1]=i&255,i=v(r,8),n[0]=i&255,i=v(r,8),n[5]=i&255,i=v(r,8),n[4]=i&255,i=v(r,8),n[7]=i&255,i=v(r,8),n[6]=i&15;let a=A(2,255);n[8]=a[0],n[9]=a[1];let o=A(6,255);for(o[0]|=3,t=0;t<6;t++)n[10+t]=o[t]}else if(e===4){let e=A(16,255);for(t=0;t<16;t++)this[t]=e[t]}else if(e===3||e===5){let r=``,i=typeof arguments[1]==`object`&&arguments[1]instanceof M?arguments[1]:new M().parse(arguments[1]);for(t=0;t<16;t++)r+=String.fromCharCode(i[t]);r+=arguments[2];let a=e===3?D(r):T(r);for(t=0;t<16;t++)n[t]=a.charCodeAt(t)}else throw Error(`UUID: make: invalid version`);return n[6]&=15,n[6]|=e<<4,n[8]&=63,n[8]|=128,n},M.prototype.format=function(t){let n,r;if(t===`z85`)n=i(this,16);else if(t===`b16`)r=Array(32),e(this,0,15,!0,r,0),n=r.join(``);else if(t===void 0||t===`std`)r=Array(36),e(this,0,3,!1,r,0),r[8]=`-`,e(this,4,5,!1,r,9),r[13]=`-`,e(this,6,7,!1,r,14),r[18]=`-`,e(this,8,9,!1,r,19),r[23]=`-`,e(this,10,15,!1,r,24),n=r.join(``);else throw Error(`UUID: format: invalid type argument`);return n},M.prototype.toString=function(e){return this.format(e)},M.prototype.toJSON=function(){return this.format(`std`)},M.prototype.parse=function(e,n){if(typeof e!=`string`)throw Error(`UUID: parse: invalid argument (type string expected)`);if(n===`z85`)a(e,this);else if(n===`b16`)t(e,0,35,this,0);else if(n===void 0||n===`std`){let n={nil:`00000000-0000-0000-0000-000000000000`,"ns:DNS":`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,"ns:URL":`6ba7b811-9dad-11d1-80b4-00c04fd430c8`,"ns:OID":`6ba7b812-9dad-11d1-80b4-00c04fd430c8`,"ns:X500":`6ba7b814-9dad-11d1-80b4-00c04fd430c8`};if(n[e]!==void 0)e=n[e];else if(!e.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))throw Error(`UUID: parse: invalid string representation (expected "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")`);t(e,0,7,this,0),t(e,9,12,this,4),t(e,14,17,this,6),t(e,19,22,this,8),t(e,24,35,this,10)}return this},M.prototype.export=function(){let e=Array(16);for(let t=0;t<16;t++)e[t]=this[t];return e},M.prototype.import=function(e){if(!(typeof e==`object`&&e instanceof Array))throw Error(`UUID: import: invalid argument (type Array expected)`);if(e.length!==16)throw Error(`UUID: import: invalid argument (Array of length 16 expected)`);for(let t=0;t<16;t++){if(typeof e[t]!=`number`)throw Error(`UUID: import: invalid array element #`+t+` (type Number expected)`);if(!(isFinite(e[t])&&Math.floor(e[t])===e[t]))throw Error(`UUID: import: invalid array element #`+t+` (Number with integer value expected)`);if(!(e[t]>=0&&e[t]<=255))throw Error(`UUID: import: invalid array element #`+t+` (Number with integer value in range 0...255 expected)`);this[t]=e[t]}return this},M.prototype.compare=function(e){if(typeof e!=`object`||!(e instanceof M))throw Error(`UUID: compare: invalid argument (type UUID expected)`);for(let t=0;t<16;t++)if(this[t]<e[t])return-1;else if(this[t]>e[t])return 1;return 0},M.prototype.equal=function(e){return this.compare(e)===0},M.prototype.fold=function(e){if(e===void 0)throw Error(`UUID: fold: invalid argument (number of fold operations expected)`);if(e<1||e>4)throw Error(`UUID: fold: invalid argument (1-4 fold operations expected)`);let t=16/2**e,n=Array(t);for(let e=0;e<t;e++){let r=0;for(let n=0;e+n<16;n+=t)r^=this[e+n];n[e]=r}return n},M.PCG=O,M})}))(),1),Se=e=>e.replace(/[\\"']/g,`\\$&`).replace(/[\r\n\f]/g,` `),Ce=new xe.default(5,`ns:URL`,`https://github.com/rse/gradia`).format(),we=e=>`gradia-${new xe.default(5,Ce,e).format(`b16`).toLowerCase()}`,Te=18,Ee=12,De=2,Oe=(e,t,n)=>{let{nodes:r,cx:i,cy:a,boxW:o,boxH:s}=e,c=r.map(e=>[i(e.id)-o.get(e.id)/2,a(e.id)-s.get(e.id)/2,i(e.id)+o.get(e.id)/2,a(e.id)+s.get(e.id)/2]);for(let t of e.groups??[])c.push([t.x+Te,t.y+Ee,t.x+Te+y(t.name,24),t.y+Ee+24*1.2]);for(let t of e.containers??[])c.push([t.x+Te,t.y+Ee,t.x+Te+y(t.node.name,24),t.y+D(t.node)]);let l=[];e.polys.forEach((e,r)=>{for(let i=0;i<e.length-1;i++){let[a,o]=[e[i],e[i+1]];l.push([Math.min(a[0],o[0])-De,Math.min(a[1],o[1])-De,Math.max(a[0],o[0])+De,Math.max(a[1],o[1])+De]);for(let e of t[r].get(i)??[])l.push([e-n,a[1]-n,e+n,a[1]])}});let u=(e,t)=>e.filter(e=>t[0]<e[2]&&t[2]>e[0]&&t[1]<e[3]&&t[3]>e[1]).length;return{claim:e=>{let t=e[0],n=1/0;for(let r of e){let e=u(c,r)*(l.length+1)+u(l,r);if(e<n&&(t=r,n=e),e===0)break}return c.push(t),t},occupied:c}},ke=(e,t,n,r,i,a)=>{let{cx:o,cy:s,boxW:c,boxH:l,contentH:u}=t,d=c.get(e.id),f=l.get(e.id),p=o(e.id)-d/2,m=s(e.id)-f/2,h=te(e,a),g=M(e),_=[];_.push(`<rect x="${p}" y="${m}" width="${d}" height="${f}" rx="6" style="fill: ${i(n.fill)}; stroke: ${i(n.stroke)}" stroke-width="4.0"${n.dash===void 0?``:` stroke-dasharray="${x(n.dash)}"`}/>`);let v=s(e.id)-u.get(e.id)/2,y=h.type.length*26,b=(h.name.length-1)*34,S=h.attrs.length>0?v+y+28+30*.36:s(e.id)+y/2+30*.36-b/2;return h.type.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${S-36-(h.type.length-1-a)*26}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),h.name.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${S+a*34}" text-anchor="middle" font-size="30" font-weight="600" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),h.attrs.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${v+y+b+56+12+a*30}" text-anchor="middle" font-size="22" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),g===void 0?_:[`<a href="${x(g)}" xlink:href="${x(g)}">`,..._,`</a>`]},Ae=(e,t,n)=>{let{polys:r}=e,[i,a,o,s]=[1/0,1/0,-1/0,-1/0];for(let[e,n,r,c]of t)i=Math.min(i,e),a=Math.min(a,n),o=Math.max(o,r),s=Math.max(s,c);for(let e of r)for(let[t,n]of e)i=Math.min(i,t),a=Math.min(a,n),o=Math.max(o,t),s=Math.max(s,n);return Number.isFinite(i)||([i,a,o,s]=[0,0,0,0]),{x:Math.floor(i-n/2),y:Math.floor(a-n/2),w:Math.ceil(o-i+n),h:Math.ceil(s-a+n)}},je=(e,t,n,r,i)=>{let a=`stroke-width="4.5" paint-order="stroke" stroke-linejoin="round"`,o=[];if(e.name!==void 0){let s=y(e.name,16),c=[];for(let e of[.5,.4,.6,.3,.7,.2,.8]){let n=fe(t,e);n.horizontal?(c.push([n.x-s/2,n.y-23,n.x+s/2,n.y-3]),c.push([n.x-s/2,n.y+3,n.x+s/2,n.y+23])):(c.push([n.x+5,n.y-10,n.x+5+s,n.y+10]),c.push([n.x-5-s,n.y-10,n.x-5,n.y+10]))}let l=n(c);o.push(`<text x="${(l[0]+l[2])/2}" y="${l[3]-3}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(`color-edge-name`)}; stroke: ${i(`color-edge-halo`)}" ${a}>${x(e.name)}</text>`)}if(e.arity!==void 0){let s=y(e.arity,16),c=fe(t,1),l=fe(t,.999),u;if(c.horizontal){let e=Math.sign(c.x-l.x)||1,t=c.x-e*(24+s/2);u=[[t-s/2,c.y-17,t+s/2,c.y-4],[t-s/2,c.y+4,t+s/2,c.y+17],[t-s/2-e*14,c.y-17,t+s/2-e*14,c.y-4]]}else{let e=Math.sign(c.y-l.y)||1,t=c.y-e*24;u=[[c.x+6,t-7,c.x+6+s,t+6],[c.x-6-s,t-7,c.x-6,t+6],[c.x+6,t-7-e*14,c.x+6+s,t+6-e*14]]}let d=n(u);o.push(`<text x="${(d[0]+d[2])/2}" y="${d[3]-3}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(`color-edge-arity`)}; stroke: ${i(`color-edge-halo`)}" ${a}>${x(e.arity)}</text>`)}return o},Me=(e,t,n)=>[`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="12" style="fill: ${n(`color-group-box`)}; stroke: ${n(`color-group-border`)}" stroke-width="3.0"/>`,`<text x="${e.x+Te}" y="${e.y+Ee+24}" font-size="24" font-weight="600" style="font-family: ${t}; fill: ${n(`color-group-name`)}">${x(e.name)}</text>`],Ne=(e,t,n)=>{let r=w(e.node),i=M(e.node),a=[`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="12" style="fill: ${n(`color-container-box`)}; stroke: ${n(`color-container-border`)}" stroke-width="3.0" stroke-dasharray="10 6"/>`,...r===void 0?[]:[`<text x="${e.x+Te}" y="${e.y+Ee+16}" font-size="16" style="font-family: ${t}; fill: ${n(`color-container-name`)}">${x(r)}</text>`],`<text x="${e.x+Te}" y="${e.y+D(e.node)-34+Ee+24}" font-size="24" font-weight="600" style="font-family: ${t}; fill: ${n(`color-container-name`)}">${x(e.node.name)}</text>`];return i===void 0?a:[`<a href="${x(i)}" xlink:href="${x(i)}">`,...a,`</a>`]},Pe=(e,t,n,r)=>{let{nodes:i,edges:a,polys:o}=e,s=e.groups??[],c=e.containers??[],l=e.styleOf??C,u=e=>x(m(n,e)),d=`${we(r)}-arrow`,{family:f,embed:p,weight:h}=v(t),g=x(`${Object.hasOwn(n,`font-family`)?`'${Se(f)}'`:`var(--gradia-font-family, '${Se(f)}')`}, ui-sans-serif, -apple-system, Helvetica, Arial, sans-serif`),_=le(o),{claim:y,occupied:b}=Oe(e,_,t[`size-edge-hop-radius`]),S=[],w=[];a.forEach((e,n)=>{S.push(`<path d="${de(o[n],_[n],t[`size-edge-corner-radius`],t[`size-edge-hop-radius`])}" fill="none" style="stroke: ${u(`color-edge-line`)}" stroke-width="3.0" marker-end="url(#${d})"/>`),w.push(...je(e,o[n],y,g,u))});let T=i.flatMap(n=>ke(n,e,l(n),g,u,t)),E=s.flatMap(e=>Me(e,g,u)),D=c.flatMap(e=>Ne(e,g,u)),O=s.map(e=>[e.x,e.y,e.x+e.w,e.y+e.h]),k=c.map(e=>[e.x,e.y,e.x+e.w,e.y+e.h]),A=Ae(e,[...b,...O,...k],t[`size-canvas-margin`]);return[`<?xml version="1.0" encoding="UTF-8"?>`,`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="${A.x} ${A.y} ${A.w} ${A.h}" width="${A.w}" height="${A.h}">`,`<defs>`,...p===void 0?[]:[`<style>`,`@font-face { font-family: "${x(Se(f))}"; `+(h===void 0?``:`font-weight: ${x(Se(h))}; `)+`src: url(data:font/woff2;base64,${p}) format("woff2"); }`,`</style>`],`<marker id="${d}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="21" markerHeight="21" markerUnits="userSpaceOnUse" orient="auto-start-reverse">`,`<path d="M 0 1 L 9 5 L 0 9 z" style="fill: ${u(`color-edge-line`)}"/>`,`</marker>`,`</defs>`,...E,...D,...S,...T,...w,`</svg>`,``].join(`
|
|
5
|
-
`)};function Fe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var Ie={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow},z=class extends Error{constructor(e,t,n){super(e),this.position=t,this.token=n,this.name=`ExpressionError`}},B;(function(e){e[e.STRING=0]=`STRING`,e[e.NUMBER=1]=`NUMBER`,e[e.BOOLEAN=2]=`BOOLEAN`,e[e.NULL=3]=`NULL`,e[e.IDENTIFIER=4]=`IDENTIFIER`,e[e.OPERATOR=5]=`OPERATOR`,e[e.FUNCTION=6]=`FUNCTION`,e[e.DOT=7]=`DOT`,e[e.BRACKET_LEFT=8]=`BRACKET_LEFT`,e[e.BRACKET_RIGHT=9]=`BRACKET_RIGHT`,e[e.PAREN_LEFT=10]=`PAREN_LEFT`,e[e.PAREN_RIGHT=11]=`PAREN_RIGHT`,e[e.COMMA=12]=`COMMA`,e[e.QUESTION=13]=`QUESTION`,e[e.COLON=14]=`COLON`,e[e.DOLLAR=15]=`DOLLAR`})(B||={});var Le=new Set([32,9,10,13]),Re=new Set([43,45,42,47,37,33,38,124,61,60,62]),ze=new Map([[`true`,B.BOOLEAN],[`false`,B.BOOLEAN],[`null`,B.NULL]]),Be=new Map([[`===`,!0],[`!==`,!0],[`<=`,!0],[`>=`,!0],[`&&`,!0],[`||`,!0],[`+`,!0],[`-`,!0],[`*`,!0],[`/`,!0],[`%`,!0],[`!`,!0],[`<`,!0],[`>`,!0]]),Ve=new Map([[46,B.DOT],[91,B.BRACKET_LEFT],[93,B.BRACKET_RIGHT],[40,B.PAREN_LEFT],[41,B.PAREN_RIGHT],[44,B.COMMA],[63,B.QUESTION],[58,B.COLON],[36,B.DOLLAR]]),He=new Map;for(let[e,t]of Ve.entries())He.set(e,{type:t,value:String.fromCharCode(e)});function Ue(e){return e>=48&&e<=57}function We(e){return e>=97&&e<=122||e>=65&&e<=90||e===95}function Ge(e){return We(e)||Ue(e)}function Ke(e){return Re.has(e)}var V;(function(e){e[e.Program=0]=`Program`,e[e.Literal=1]=`Literal`,e[e.Identifier=2]=`Identifier`,e[e.MemberExpression=3]=`MemberExpression`,e[e.CallExpression=4]=`CallExpression`,e[e.BinaryExpression=5]=`BinaryExpression`,e[e.UnaryExpression=6]=`UnaryExpression`,e[e.ConditionalExpression=7]=`ConditionalExpression`})(V||={});var qe=new Map([[`||`,2],[`&&`,3],[`===`,4],[`!==`,4],[`>`,5],[`>=`,5],[`<`,5],[`<=`,5],[`+`,6],[`-`,6],[`*`,7],[`/`,7],[`%`,7],[`!`,8]]),Je={type:V.Literal,value:null},Ye={type:V.Literal,value:!0},Xe={type:V.Literal,value:!1},Ze=e=>{let t=0,n=e.length,r=()=>t>=n?null:e[t],i=()=>e[t++],a=e=>{let t=r();return t!==null&&t.type===e},o=e=>e.type===B.OPERATOR?qe.get(e.value)||-1:e.type===B.DOT||e.type===B.BRACKET_LEFT?9:e.type===B.QUESTION?1:-1,s=e=>{let n,o;if(i().type===B.DOT){if(!a(B.IDENTIFIER)){let e=r();throw new z(`Expected property name`,t,e?e.value:`<end of input>`)}let e=i();n={type:V.Identifier,name:e.value},o=!1}else{if(n=l(0),!a(B.BRACKET_RIGHT)){let e=r();throw new z(`Expected closing bracket`,t,e?e.value:`<end of input>`)}i(),o=!0}return{type:V.MemberExpression,object:e,property:n,computed:o}},c=()=>{let e=r();if(!e)throw new z(`Unexpected end of input`,t,`<end of input>`);if(e.type===B.OPERATOR&&(e.value===`!`||e.value===`-`)){i();let t=c();return{type:V.UnaryExpression,operator:e.value,argument:t,prefix:!0}}switch(e.type){case B.NUMBER:return i(),{type:V.Literal,value:Number(e.value)};case B.STRING:return i(),{type:V.Literal,value:e.value};case B.BOOLEAN:return i(),e.value===`true`?Ye:Xe;case B.NULL:return i(),Je;case B.IDENTIFIER:return i(),{type:V.Identifier,name:e.value};case B.FUNCTION:return(()=>{let e=i(),n=[];if(!a(B.PAREN_LEFT)){let e=r();throw new z(`Expected opening parenthesis after function name`,t,e?e.value:`<end of input>`)}for(i();;){if(a(B.PAREN_RIGHT)){i();break}if(!r()){let e=r();throw new z(`Expected closing parenthesis`,t,e?e.value:`<end of input>`)}if(n.length>0){if(!a(B.COMMA)){let e=r();throw new z(`Expected comma between function arguments`,t,e?e.value:`<end of input>`)}i()}let e=l(0);n.push(e)}return{type:V.CallExpression,callee:{type:V.Identifier,name:e.value},arguments:n}})();case B.PAREN_LEFT:{i();let e=l(0);if(!a(B.PAREN_RIGHT)){let e=r();throw new z(`Expected closing parenthesis`,t,e?e.value:`<end of input>`)}return i(),e}default:throw new z(`Unexpected token: ${e.type}`,t,e.value)}},l=(u=0)=>{let d=c();for(;t<n;){let n=e[t],c=o(n);if(c<=u)break;if(n.type!==B.QUESTION){if(n.type!==B.OPERATOR){if(n.type!==B.DOT&&n.type!==B.BRACKET_LEFT)break;d=s(d)}else{i();let e=l(c);d={type:V.BinaryExpression,operator:n.value,left:d,right:e}}}else{i();let e=l(0);if(!a(B.COLON)){let e=r();throw new z(`Expected : in conditional expression`,t,e?e.value:`<end of input>`)}i();let n=l(0);d={type:V.ConditionalExpression,test:d,consequent:e,alternate:n}}}return d},u=l();return{type:V.Program,body:u}},Qe=(e,t,n)=>{let r=t;n&&(r={...t,context:{...t.context,...n}});let i=e=>{switch(e.type){case V.Literal:return(e=>e.value)(e);case V.Identifier:return(e=>{if(!(e.name in r.context))throw new z(`Undefined variable: ${e.name}`);return r.context[e.name]})(e);case V.MemberExpression:return(e=>{let t=i(e.object);if(t==null)throw new z(`Cannot access property of null or undefined`);return t[e.computed?i(e.property):e.property.name]})(e);case V.CallExpression:return(e=>{let t=r.functions[e.callee.name];if(!t)throw new z(`Undefined function: ${e.callee.name}`);return t(...e.arguments.map((e=>i(e))))})(e);case V.BinaryExpression:return(e=>{if(e.operator===`&&`)return i(e.left)&&i(e.right);if(e.operator===`||`)return i(e.left)||i(e.right);let t=i(e.left),n=i(e.right);switch(e.operator){case`+`:return t+n;case`-`:return t-n;case`*`:return t*n;case`/`:return t/n;case`%`:return t%n;case`===`:return t===n;case`!==`:return t!==n;case`>`:return t>n;case`>=`:return t>=n;case`<`:return t<n;case`<=`:return t<=n;default:throw new z(`Unknown operator: ${e.operator}`)}})(e);case V.UnaryExpression:return(e=>{let t=i(e.argument);if(e.prefix)switch(e.operator){case`!`:return!t;case`-`:if(typeof t!=`number`)throw new z(`Cannot apply unary - to non-number: ${t}`);return-t;default:throw new z(`Unknown operator: ${e.operator}`)}throw new z(`Postfix operators are not supported: ${e.operator}`)})(e);case V.ConditionalExpression:return(e=>{let t=i(e.test);return i(t?e.consequent:e.alternate)})(e);default:throw new z(`Evaluation error: Unsupported node type: ${e.type}`)}};return i(e.body)};function $e(e){let t=Ze((e=>{let t=e,n=t.length,r=Array(Math.ceil(n/3)),i=0,a=0;function o(e){let r=a+1;a++;let i=``,o=!1;for(;a<n;){let n=t.charCodeAt(a);if(n===e)return o||(i=t.substring(r,a)),a++,{type:B.STRING,value:i};n===92?(o||=(i=t.substring(r,a),!0),a++,i+=t[a]):o&&(i+=t[a]),a++}throw new z(`Unterminated string starting with ${String.fromCharCode(e)}`,a,t.substring(Math.max(0,a-10),a))}function s(){let e=a;for(t.charCodeAt(a)===45&&a++;a<n&&Ue(t.charCodeAt(a));)a++;if(a<n&&t.charCodeAt(a)===46)for(a++;a<n&&Ue(t.charCodeAt(a));)a++;let r=t.slice(e,a);return{type:B.NUMBER,value:r}}function c(){a++;let e=a;if(a<n&&We(t.charCodeAt(a)))for(a++;a<n&&Ge(t.charCodeAt(a));)a++;let r=t.slice(e,a);return{type:B.FUNCTION,value:r}}function l(){let e=a++;for(;a<n&&Ge(t.charCodeAt(a));)a++;let r=t.slice(e,a),i=ze.get(r);return i?{type:i,value:r}:{type:B.IDENTIFIER,value:r}}function u(){if(a+2<n){let e=t.substring(a,a+3);if(Be.has(e))return a+=3,{type:B.OPERATOR,value:e}}if(a+1<n){let e=t.substring(a,a+2);if(Be.has(e))return a+=2,{type:B.OPERATOR,value:e}}let e=t[a];if(Be.has(e))return a++,{type:B.OPERATOR,value:e};throw new z(`Unknown operator at position ${a}: ${t.substring(a,a+1)}`,a,t.substring(Math.max(0,a-10),a))}for(;a<n;){let e=t.charCodeAt(a);if(d=e,Le.has(d)){a++;continue}let f=He.get(e);if(f)r[i++]=f,a++;else if(e!==34&&e!==39){if(Ue(e)||e===45&&a+1<n&&Ue(t.charCodeAt(a+1)))r[i++]=s();else if(e!==64){if(We(e))r[i++]=l();else{if(!Ke(e))throw new z(`Unexpected character: ${t[a]}`,a,t.substring(Math.max(0,a-10),a));r[i++]=u()}}else r[i++]=c()}else r[i++]=o(e)}var d;return i===r.length?r:r.slice(0,i)})(e)),n=((e={},t={})=>({context:e,functions:t}))({},Ie);return(e={})=>Qe(t,n,e)}function et(e,t={}){return $e(e)(t)}function tt(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)try{return $e(n),et(n,t)}catch{return}}function nt(e){return typeof e==`number`}function rt(e){if(!e)return[0,0,0];if(nt(e))return[e,e,e];if(Array.isArray(e)&&e.length===0)return[0,0,0];let[t,n=t,r=t]=e;return[t,n,r]}function it(e){return nt(e)?!0:Array.isArray(e)?e.every(e=>nt(e)):!1}function H(e){return e==null}function at(e){return typeof e==`string`}function ot(e){return typeof e==`function`}function st(e,t){if(typeof e==`function`)return e;if(typeof e==`string`){let n=e;return(...e)=>{let r={};for(let n=0;n<t.length;n++)r[t[n]]=e[n];return tt(n,r)}}return()=>e}function ct(e,t,n=`node`){if(H(e))return()=>t;if(at(e)){let r=st(e,[n]);return e=>{let n=r(e);return nt(n)?n:t}}return ot(e)?e:nt(e)?()=>e:()=>t}function lt(e,t=10,n=`node`){if(H(e))return()=>t;if(at(e)){let r=st(e,[n]);return e=>{let n=r(e);return it(n)?n:t}}return ot(e)?e:nt(e)||Array.isArray(e)?()=>e:()=>t}function ut(e){return[e.x,e.y,e.z??0]}var dt=class{constructor(e,t={}){this.edgeIdCounter=new Map,this.nodeMap=mt(e.nodes,t.node),this.edgeMap=ht(e.edges||[],t.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(e){this.nodeMap=e.nodes,this.edgeMap=e.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(e){return this.nodeMap.get(e)}nodeAt(e){this.indexNodeCache||this.buildNodeIndexCache();let t=this.indexNodeCache.get(e);return t?this.nodeMap.get(t):void 0}nodeIndexOf(e){return this.nodeIndexCache||this.buildNodeIndexCache(),this.nodeIndexCache.get(e)??-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(e){let t=0;this.nodeMap.forEach(n=>e(n,t++))}originalNode(e){return this.nodeMap.get(e)?._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(e){return this.edgeMap.get(e)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(e){let t=0;this.edgeMap.forEach(n=>e(n,t++))}originalEdge(e){return this.edgeMap.get(e)?._original}edgeCount(){return this.edgeMap.size}getEdgeId(e){if(e.id)return e.id;let t=`${e.source}-${e.target}`,n=this.edgeIdCounter.get(t)||0,r=n===0?t:`${t}-${n}`;return this.edgeIdCounter.set(t,n+1),r}degree(e,t=`both`){this.degreeCache||this.buildDegreeCache();let n=this.degreeCache.get(e);return n?n[t]:0}neighbors(e,t=`both`){if((!this.outAdjacencyCache||!this.inAdjacencyCache)&&this.buildAdjacencyCache(),t===`out`)return Array.from(this.outAdjacencyCache.get(e)||[]);if(t===`in`)return Array.from(this.inAdjacencyCache.get(e)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(e)||[]);let n=this.inAdjacencyCache.get(e),r=this.outAdjacencyCache.get(e);if(!n&&!r)return[];if(!n)return Array.from(r);if(!r)return Array.from(n);let i=new Set;return n.forEach(e=>i.add(e)),r.forEach(e=>i.add(e)),Array.from(i)}successors(e){return this.neighbors(e,`out`)}predecessors(e){return this.neighbors(e,`in`)}setNodeOrder(e){let t=new Map;for(let n of e)t.set(n.id,n);this.nodeMap=t,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(let e of this.edges()){let{source:t,target:n}=e;if(e.source===e.target)continue;this.degreeCache.has(t)||this.degreeCache.set(t,{in:0,out:0,both:0});let r=this.degreeCache.get(e.source);r&&(r.out++,r.both++),this.degreeCache.has(n)||this.degreeCache.set(n,{in:0,out:0,both:0});let i=this.degreeCache.get(e.target);i&&(i.in++,i.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(let e of this.edges())!this.nodeMap.has(e.source)||!this.nodeMap.has(e.target)||(this.outAdjacencyCache.has(e.source)||this.outAdjacencyCache.set(e.source,new Set),this.outAdjacencyCache.get(e.source).add(e.target),this.inAdjacencyCache.has(e.target)||this.inAdjacencyCache.set(e.target,new Set),this.inAdjacencyCache.get(e.target).add(e.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let e=0;this.nodeMap.forEach((t,n)=>{this.nodeIndexCache.set(n,e),this.indexNodeCache.set(e,n),e++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}},ft=[`id`,`x`,`y`,`z`,`vx`,`vy`,`vz`,`fx`,`fy`,`fz`,`parentId`],pt=[`id`,`source`,`target`,`points`];function mt(e,t){if(!e)throw Error(`Data.nodes is required`);let n=new Map;for(let r of e){let e={_original:r};for(let t of ft){let n=r[t];H(n)||(e[t]=n)}if(t){let n=t(r);for(let t in n){let r=n[t];H(r)||(e[t]=r)}}if(H(e.id))throw Error(`Node is missing id field`);n.set(e.id,e)}return n}function ht(e,t,n){let r=new Map;for(let i of e){let e={_original:i};for(let t of pt){let n=i[t];H(n)||(e[t]=n)}if(t){let n=t(i);for(let t in n){let r=n[t];H(r)||(e[t]=r)}}if(H(e.source)||H(e.target))throw Error(`Edge is missing source or target field`);H(e.id)&&(e.id=n?.(i)),r.set(e.id,e)}return r}var gt=class{constructor(e,t={}){this.graph=new dt(e,t)}export(){return this.graph.data()}replace(e){this.graph.replace(e)}forEachNode(e){this.graph.forEachNode(e)}forEachEdge(e){this.graph.forEachEdge((t,n)=>{t.sourceNode=this.graph.node(t.source),t.targetNode=this.graph.node(t.target),e(t,n)})}destroy(){this.graph.destroy()}},_t=Symbol(`Comlink.proxy`),vt=Symbol(`Comlink.endpoint`),yt=Symbol(`Comlink.releaseProxy`),bt=Symbol(`Comlink.finalizer`),xt=Symbol(`Comlink.thrown`),St=e=>typeof e==`object`&&!!e||typeof e==`function`,Ct=new Map([[`proxy`,{canHandle:e=>St(e)&&e[_t],serialize(e){let{port1:t,port2:n}=new MessageChannel;return Tt(e,t),[n,[n]]},deserialize(e){return e.start(),Ot(e)}}],[`throw`,{canHandle:e=>St(e)&&xt in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function wt(e,t){for(let n of e)if(t===n||n===`*`||n instanceof RegExp&&n.test(t))return!0;return!1}function Tt(e,t=globalThis,n=[`*`]){t.addEventListener(`message`,function r(i){if(!i||!i.data)return;if(!wt(n,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(Ht),l;try{let t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(o){case`GET`:l=n;break;case`SET`:t[s.slice(-1)[0]]=Ht(i.data.value),l=!0;break;case`APPLY`:l=n.apply(t,c);break;case`CONSTRUCT`:l=Bt(new n(...c));break;case`ENDPOINT`:{let{port1:t,port2:n}=new MessageChannel;Tt(e,n),l=zt(t,[t])}break;case`RELEASE`:l=void 0;break;default:return}}catch(e){l={value:e,[xt]:0}}Promise.resolve(l).catch(e=>({value:e,[xt]:0})).then(n=>{let[i,s]=Vt(n);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),o===`RELEASE`&&(t.removeEventListener(`message`,r),Dt(t),bt in e&&typeof e[bt]==`function`&&e[bt]())}).catch(e=>{let[n,r]=Vt({value:TypeError(`Unserializable return value`),[xt]:0});t.postMessage(Object.assign(Object.assign({},n),{id:a}),r)})}),t.start&&t.start()}function Et(e){return e.constructor.name===`MessagePort`}function Dt(e){Et(e)&&e.close()}function Ot(e,t){let n=new Map;return e.addEventListener(`message`,function(e){let{data:t}=e;if(!t||!t.id)return;let r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),Ft(e,n,[],t)}function kt(e){if(e)throw Error(`Proxy has been released and is not useable`)}function At(e){return Ut(e,new Map,{type:`RELEASE`}).then(()=>{Dt(e)})}var jt=new WeakMap,Mt=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(jt.get(e)||0)-1;jt.set(e,t),t===0&&At(e)});function Nt(e,t){let n=(jt.get(t)||0)+1;jt.set(t,n),Mt&&Mt.register(e,t,e)}function Pt(e){Mt&&Mt.unregister(e)}function Ft(e,t,n=[],r=function(){}){let i=!1,a=new Proxy(r,{get(r,o){if(kt(i),o===yt)return()=>{Pt(a),At(e),t.clear(),i=!0};if(o===`then`){if(n.length===0)return{then:()=>a};let r=Ut(e,t,{type:`GET`,path:n.map(e=>e.toString())}).then(Ht);return r.then.bind(r)}return Ft(e,t,[...n,o])},set(r,a,o){kt(i);let[s,c]=Vt(o);return Ut(e,t,{type:`SET`,path:[...n,a].map(e=>e.toString()),value:s},c).then(Ht)},apply(r,a,o){kt(i);let s=n[n.length-1];if(s===vt)return Ut(e,t,{type:`ENDPOINT`}).then(Ht);if(s===`bind`)return Ft(e,t,n.slice(0,-1));let[c,l]=Lt(o);return Ut(e,t,{type:`APPLY`,path:n.map(e=>e.toString()),argumentList:c},l).then(Ht)},construct(r,a){kt(i);let[o,s]=Lt(a);return Ut(e,t,{type:`CONSTRUCT`,path:n.map(e=>e.toString()),argumentList:o},s).then(Ht)}});return Nt(a,e),a}function It(e){return Array.prototype.concat.apply([],e)}function Lt(e){let t=e.map(Vt);return[t.map(e=>e[0]),It(t.map(e=>e[1]))]}var Rt=new WeakMap;function zt(e,t){return Rt.set(e,t),e}function Bt(e){return Object.assign(e,{[_t]:!0})}function Vt(e){for(let[t,n]of Ct)if(n.canHandle(e)){let[r,i]=n.serialize(e);return[{type:`HANDLER`,name:t,value:r},i]}return[{type:`RAW`,value:e},Rt.get(e)||[]]}function Ht(e){switch(e.type){case`HANDLER`:return Ct.get(e.name).deserialize(e.value);case`RAW`:return e.value}}function Ut(e,t,n,r){return new Promise(i=>{let a=Wt();t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},n),r)})}function Wt(){return[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)}var Gt=class{constructor(){this.worker=null,this.workerApi=null}execute(e,t,n){return Fe(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw Error(`Worker API not initialized`);return yield this.workerApi.execute(e,t,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return Fe(this,void 0,void 0,function*(){let e=this.resolveWorkerPath(),t=e.includes(`/lib/`)||e.endsWith(`.mjs`)?`module`:`classic`;this.worker=new Worker(e,{type:t}),this.workerApi=Ot(this.worker)})}resolveWorkerPath(){let e=(()=>{if(typeof document>`u`)return null;let e=document.currentScript;if(e?.src)return e.src;let t=document.getElementsByTagName(`script`);for(let e=t.length-1;e>=0;e--){let n=t[e].src;if(n&&(n.includes(`index.js`)||n.includes(`index.min.js`)))return n}return null})();if(e){if(e.includes(`index.js`)||e.includes(`index.min.js`)){let t=e.replace(/index(\.min)?\.(m?js)(\?.*)?$/,`worker.js`);if(t!==e)return t}let t=e.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,`/worker.js`);if(t!==e)return t;let n=e.replace(/\/[^/]+\.(m?js)(\?.*)?$/,`/worker.js`);if(n!==e)return n}return`./worker.js`}},Kt=class{constructor(e){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),e)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(e,t){return Object.assign({},e,t||{})}execute(e,t){return Fe(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,t);let{node:n,edge:r,enableWorker:i}=this.runtimeOptions;this.context=new gt(e,{node:n,edge:r}),this.model=this.context.graph,i&&typeof Worker<`u`?yield this.layoutInWorker(e,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(e,t){var n;return Fe(this,void 0,void 0,function*(){try{this.supervisor||=new Gt;let r=yield this.supervisor.execute(this.id,e,t);(n=this.context)==null||n.replace(r)}catch(e){console.error(`Layout in worker failed, fallback to main thread layout.`,e),yield this.layout(t)}})}forEachNode(e){this.context.forEachNode(e)}forEachEdge(e){this.context.forEachEdge(e)}destroy(){var e;(e=this.context)==null||e.destroy(),this.model=null,this.context=null,this.supervisor&&=(this.supervisor.destroy(),null)}};function qt(e){return Array.isArray(e)}var Jt=(function(e){var t=typeof e;return e!==null&&t===`object`||t===`function`}),Yt=function(e){return typeof e==`object`&&!!e},Xt={}.toString,Zt=function(e,t){return Xt.call(e)===`[object `+t+`]`},Qt=function(e){if(!Yt(e)||!Zt(e,`Object`))return!1;if(Object.getPrototypeOf(e)===null)return!0;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},$t=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function en(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function tn(e){throw Error(`Could not dynamically require "`+e+`". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.`)}var nn,rn;function an(){if(rn)return nn;rn=1;function e(){this.__data__=[],this.size=0}return nn=e,nn}var on,sn;function cn(){if(sn)return on;sn=1;function e(e,t){return e===t||e!==e&&t!==t}return on=e,on}var ln,un;function dn(){if(un)return ln;un=1;var e=cn();function t(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}return ln=t,ln}var fn,pn;function mn(){if(pn)return fn;pn=1;var e=dn(),t=Array.prototype.splice;function n(n){var r=this.__data__,i=e(r,n);return i<0?!1:(i==r.length-1?r.pop():t.call(r,i,1),--this.size,!0)}return fn=n,fn}var hn,gn;function _n(){if(gn)return hn;gn=1;var e=dn();function t(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}return hn=t,hn}var vn,yn;function bn(){if(yn)return vn;yn=1;var e=dn();function t(t){return e(this.__data__,t)>-1}return vn=t,vn}var xn,Sn;function Cn(){if(Sn)return xn;Sn=1;var e=dn();function t(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this}return xn=t,xn}var wn,Tn;function En(){if(Tn)return wn;Tn=1;var e=an(),t=mn(),n=_n(),r=bn(),i=Cn();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,wn=a,wn}var Dn,On;function kn(){if(On)return Dn;On=1;var e=En();function t(){this.__data__=new e,this.size=0}return Dn=t,Dn}var An,jn;function Mn(){if(jn)return An;jn=1;function e(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}return An=e,An}var Nn,Pn;function Fn(){if(Pn)return Nn;Pn=1;function e(e){return this.__data__.get(e)}return Nn=e,Nn}var In,Ln;function Rn(){if(Ln)return In;Ln=1;function e(e){return this.__data__.has(e)}return In=e,In}var zn,Bn;function Vn(){return Bn?zn:(Bn=1,zn=typeof $t==`object`&&$t&&$t.Object===Object&&$t,zn)}var Hn,Un;function U(){if(Un)return Hn;Un=1;var e=Vn(),t=typeof self==`object`&&self&&self.Object===Object&&self;return Hn=e||t||Function(`return this`)(),Hn}var Wn,Gn;function Kn(){return Gn?Wn:(Gn=1,Wn=U().Symbol,Wn)}var qn,Jn;function Yn(){if(Jn)return qn;Jn=1;var e=Kn(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(e){var t=n.call(e,i),a=e[i];try{e[i]=void 0;var o=!0}catch{}var s=r.call(e);return o&&(t?e[i]=a:delete e[i]),s}return qn=a,qn}var Xn,Zn;function Qn(){if(Zn)return Xn;Zn=1;var e=Object.prototype.toString;function t(t){return e.call(t)}return Xn=t,Xn}var $n,er;function tr(){if(er)return $n;er=1;var e=Kn(),t=Yn(),n=Qn(),r=`[object Null]`,i=`[object Undefined]`,a=e?e.toStringTag:void 0;function o(e){return e==null?e===void 0?i:r:a&&a in Object(e)?t(e):n(e)}return $n=o,$n}var nr,rr;function W(){if(rr)return nr;rr=1;function e(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}return nr=e,nr}var ir,ar;function or(){if(ar)return ir;ar=1;var e=tr(),t=W(),n=`[object AsyncFunction]`,r=`[object Function]`,i=`[object GeneratorFunction]`,a=`[object Proxy]`;function o(o){if(!t(o))return!1;var s=e(o);return s==r||s==i||s==n||s==a}return ir=o,ir}var sr,cr;function lr(){return cr?sr:(cr=1,sr=U()[`__core-js_shared__`],sr)}var ur,dr;function fr(){if(dr)return ur;dr=1;var e=lr(),t=function(){var t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||``);return t?`Symbol(src)_1.`+t:``}();function n(e){return!!t&&t in e}return ur=n,ur}var pr,mr;function hr(){if(mr)return pr;mr=1;var e=Function.prototype.toString;function t(t){if(t!=null){try{return e.call(t)}catch{}try{return t+``}catch{}}return``}return pr=t,pr}var gr,_r;function vr(){if(_r)return gr;_r=1;var e=or(),t=fr(),n=W(),r=hr(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=RegExp(`^`+c.call(l).replace(i,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function d(i){return!n(i)||t(i)?!1:(e(i)?u:a).test(r(i))}return gr=d,gr}var yr,br;function xr(){if(br)return yr;br=1;function e(e,t){return e?.[t]}return yr=e,yr}var Sr,Cr;function wr(){if(Cr)return Sr;Cr=1;var e=vr(),t=xr();function n(n,r){var i=t(n,r);return e(i)?i:void 0}return Sr=n,Sr}var Tr,Er;function Dr(){return Er?Tr:(Er=1,Tr=wr()(U(),`Map`),Tr)}var Or,kr;function Ar(){return kr?Or:(kr=1,Or=wr()(Object,`create`),Or)}var jr,Mr;function Nr(){if(Mr)return jr;Mr=1;var e=Ar();function t(){this.__data__=e?e(null):{},this.size=0}return jr=t,jr}var Pr,Fr;function Ir(){if(Fr)return Pr;Fr=1;function e(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}return Pr=e,Pr}var Lr,Rr;function zr(){if(Rr)return Lr;Rr=1;var e=Ar(),t=`__lodash_hash_undefined__`,n=Object.prototype.hasOwnProperty;function r(r){var i=this.__data__;if(e){var a=i[r];return a===t?void 0:a}return n.call(i,r)?i[r]:void 0}return Lr=r,Lr}var Br,Vr;function Hr(){if(Vr)return Br;Vr=1;var e=Ar(),t=Object.prototype.hasOwnProperty;function n(n){var r=this.__data__;return e?r[n]!==void 0:t.call(r,n)}return Br=n,Br}var Ur,Wr;function Gr(){if(Wr)return Ur;Wr=1;var e=Ar(),t=`__lodash_hash_undefined__`;function n(n,r){var i=this.__data__;return this.size+=+!this.has(n),i[n]=e&&r===void 0?t:r,this}return Ur=n,Ur}var Kr,qr;function Jr(){if(qr)return Kr;qr=1;var e=Nr(),t=Ir(),n=zr(),r=Hr(),i=Gr();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,Kr=a,Kr}var Yr,Xr;function Zr(){if(Xr)return Yr;Xr=1;var e=Jr(),t=En(),n=Dr();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Yr=r,Yr}var Qr,$r;function ei(){if($r)return Qr;$r=1;function e(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}return Qr=e,Qr}var ti,ni;function ri(){if(ni)return ti;ni=1;var e=ei();function t(t,n){var r=t.__data__;return e(n)?r[typeof n==`string`?`string`:`hash`]:r.map}return ti=t,ti}var ii,ai;function oi(){if(ai)return ii;ai=1;var e=ri();function t(t){var n=e(this,t).delete(t);return this.size-=+!!n,n}return ii=t,ii}var si,ci;function li(){if(ci)return si;ci=1;var e=ri();function t(t){return e(this,t).get(t)}return si=t,si}var ui,di;function fi(){if(di)return ui;di=1;var e=ri();function t(t){return e(this,t).has(t)}return ui=t,ui}var pi,mi;function hi(){if(mi)return pi;mi=1;var e=ri();function t(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this}return pi=t,pi}var gi,_i;function vi(){if(_i)return gi;_i=1;var e=Zr(),t=oi(),n=li(),r=fi(),i=hi();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,gi=a,gi}var yi,bi;function xi(){if(bi)return yi;bi=1;var e=En(),t=Dr(),n=vi(),r=200;function i(i,a){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<r-1)return s.push([i,a]),this.size=++o.size,this;o=this.__data__=new n(s)}return o.set(i,a),this.size=o.size,this}return yi=i,yi}var Si,Ci;function wi(){if(Ci)return Si;Ci=1;var e=En(),t=kn(),n=Mn(),r=Fn(),i=Rn(),a=xi();function o(t){var n=this.__data__=new e(t);this.size=n.size}return o.prototype.clear=t,o.prototype.delete=n,o.prototype.get=r,o.prototype.has=i,o.prototype.set=a,Si=o,Si}var Ti,Ei;function Di(){if(Ei)return Ti;Ei=1;function e(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}return Ti=e,Ti}var Oi,ki;function Ai(){if(ki)return Oi;ki=1;var e=wr();return Oi=function(){try{var t=e(Object,`defineProperty`);return t({},``,{}),t}catch{}}(),Oi}var ji,Mi;function Ni(){if(Mi)return ji;Mi=1;var e=Ai();function t(t,n,r){n==`__proto__`&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}return ji=t,ji}var Pi,Fi;function Ii(){if(Fi)return Pi;Fi=1;var e=Ni(),t=cn(),n=Object.prototype.hasOwnProperty;function r(r,i,a){var o=r[i];(!(n.call(r,i)&&t(o,a))||a===void 0&&!(i in r))&&e(r,i,a)}return Pi=r,Pi}var Li,Ri;function zi(){if(Ri)return Li;Ri=1;var e=Ii(),t=Ni();function n(n,r,i,a){var o=!i;i||={};for(var s=-1,c=r.length;++s<c;){var l=r[s],u=a?a(i[l],n[l],l,i,n):void 0;u===void 0&&(u=n[l]),o?t(i,l,u):e(i,l,u)}return i}return Li=n,Li}var Bi,Vi;function Hi(){if(Vi)return Bi;Vi=1;function e(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}return Bi=e,Bi}var Ui,Wi;function G(){if(Wi)return Ui;Wi=1;function e(e){return typeof e==`object`&&!!e}return Ui=e,Ui}var Gi,Ki;function qi(){if(Ki)return Gi;Ki=1;var e=tr(),t=G(),n=`[object Arguments]`;function r(r){return t(r)&&e(r)==n}return Gi=r,Gi}var Ji,Yi;function Xi(){if(Yi)return Ji;Yi=1;var e=qi(),t=G(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable;return Ji=e(function(){return arguments}())?e:function(e){return t(e)&&r.call(e,`callee`)&&!i.call(e,`callee`)},Ji}var Zi,Qi;function K(){return Qi?Zi:(Qi=1,Zi=Array.isArray,Zi)}var $i={exports:{}},ea,ta;function na(){if(ta)return ea;ta=1;function e(){return!1}return ea=e,ea}$i.exports;var ra;function ia(){return ra?$i.exports:(ra=1,(function(e,t){var n=U(),r=na(),i=t&&!t.nodeType&&t,a=i&&e&&!e.nodeType&&e,o=a&&a.exports===i?n.Buffer:void 0;e.exports=(o?o.isBuffer:void 0)||r})($i,$i.exports),$i.exports)}var aa,oa;function sa(){if(oa)return aa;oa=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(n,r){var i=typeof n;return r??=e,!!r&&(i==`number`||i!=`symbol`&&t.test(n))&&n>-1&&n%1==0&&n<r}return aa=n,aa}var ca,la;function ua(){if(la)return ca;la=1;var e=9007199254740991;function t(t){return typeof t==`number`&&t>-1&&t%1==0&&t<=e}return ca=t,ca}var da,fa;function pa(){if(fa)return da;fa=1;var e=tr(),t=ua(),n=G(),r=`[object Arguments]`,i=`[object Array]`,a=`[object Boolean]`,o=`[object Date]`,s=`[object Error]`,c=`[object Function]`,l=`[object Map]`,u=`[object Number]`,d=`[object Object]`,f=`[object RegExp]`,p=`[object Set]`,m=`[object String]`,h=`[object WeakMap]`,g=`[object ArrayBuffer]`,_=`[object DataView]`,v=`[object Float32Array]`,y=`[object Float64Array]`,b=`[object Int8Array]`,x=`[object Int16Array]`,S=`[object Int32Array]`,C=`[object Uint8Array]`,w=`[object Uint8ClampedArray]`,T=`[object Uint16Array]`,E=`[object Uint32Array]`,D={};D[v]=D[y]=D[b]=D[x]=D[S]=D[C]=D[w]=D[T]=D[E]=!0,D[r]=D[i]=D[g]=D[a]=D[_]=D[o]=D[s]=D[c]=D[l]=D[u]=D[d]=D[f]=D[p]=D[m]=D[h]=!1;function O(r){return n(r)&&t(r.length)&&!!D[e(r)]}return da=O,da}var ma,ha;function ga(){if(ha)return ma;ha=1;function e(e){return function(t){return e(t)}}return ma=e,ma}var _a={exports:{}};_a.exports;var va;function ya(){return va?_a.exports:(va=1,(function(e,t){var n=Vn(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,a=i&&i.exports===r&&n.process;e.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})(_a,_a.exports),_a.exports)}var ba,xa;function Sa(){if(xa)return ba;xa=1;var e=pa(),t=ga(),n=ya(),r=n&&n.isTypedArray;return ba=r?t(r):e,ba}var Ca,wa;function Ta(){if(wa)return Ca;wa=1;var e=Hi(),t=Xi(),n=K(),r=ia(),i=sa(),a=Sa(),o=Object.prototype.hasOwnProperty;function s(s,c){var l=n(s),u=!l&&t(s),d=!l&&!u&&r(s),f=!l&&!u&&!d&&a(s),p=l||u||d||f,m=p?e(s.length,String):[],h=m.length;for(var g in s)(c||o.call(s,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||i(g,h)))&&m.push(g);return m}return Ca=s,Ca}var Ea,Da;function Oa(){if(Da)return Ea;Da=1;var e=Object.prototype;function t(t){var n=t&&t.constructor;return t===(typeof n==`function`&&n.prototype||e)}return Ea=t,Ea}var ka,Aa;function ja(){if(Aa)return ka;Aa=1;function e(e,t){return function(n){return e(t(n))}}return ka=e,ka}var Ma,Na;function Pa(){return Na?Ma:(Na=1,Ma=ja()(Object.keys,Object),Ma)}var Fa,Ia;function La(){if(Ia)return Fa;Ia=1;var e=Oa(),t=Pa(),n=Object.prototype.hasOwnProperty;function r(r){if(!e(r))return t(r);var i=[];for(var a in Object(r))n.call(r,a)&&a!=`constructor`&&i.push(a);return i}return Fa=r,Fa}var Ra,za;function q(){if(za)return Ra;za=1;var e=or(),t=ua();function n(n){return n!=null&&t(n.length)&&!e(n)}return Ra=n,Ra}var Ba,Va;function J(){if(Va)return Ba;Va=1;var e=Ta(),t=La(),n=q();function r(r){return n(r)?e(r):t(r)}return Ba=r,Ba}var Ha,Ua;function Wa(){if(Ua)return Ha;Ua=1;var e=zi(),t=J();function n(n,r){return n&&e(r,t(r),n)}return Ha=n,Ha}var Ga,Ka;function qa(){if(Ka)return Ga;Ka=1;function e(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return Ga=e,Ga}var Ja,Ya;function Xa(){if(Ya)return Ja;Ya=1;var e=W(),t=Oa(),n=qa(),r=Object.prototype.hasOwnProperty;function i(i){if(!e(i))return n(i);var a=t(i),o=[];for(var s in i)s==`constructor`&&(a||!r.call(i,s))||o.push(s);return o}return Ja=i,Ja}var Za,Qa;function $a(){if(Qa)return Za;Qa=1;var e=Ta(),t=Xa(),n=q();function r(r){return n(r)?e(r,!0):t(r)}return Za=r,Za}var eo,to;function no(){if(to)return eo;to=1;var e=zi(),t=$a();function n(n,r){return n&&e(r,t(r),n)}return eo=n,eo}var ro={exports:{}};ro.exports;var io;function ao(){return io?ro.exports:(io=1,(function(e,t){var n=U(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,a=i&&i.exports===r?n.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}e.exports=s})(ro,ro.exports),ro.exports)}var oo,so;function co(){if(so)return oo;so=1;function e(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}return oo=e,oo}var lo,uo;function fo(){if(uo)return lo;uo=1;function e(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}return lo=e,lo}var po,mo;function ho(){if(mo)return po;mo=1;function e(){return[]}return po=e,po}var go,_o;function vo(){if(_o)return go;_o=1;var e=fo(),t=ho(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return go=r?function(t){return t==null?[]:(t=Object(t),e(r(t),function(e){return n.call(t,e)}))}:t,go}var yo,bo;function xo(){if(bo)return yo;bo=1;var e=zi(),t=vo();function n(n,r){return e(n,t(n),r)}return yo=n,yo}var So,Co;function wo(){if(Co)return So;Co=1;function e(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}return So=e,So}var To,Eo;function Do(){return Eo?To:(Eo=1,To=ja()(Object.getPrototypeOf,Object),To)}var Oo,ko;function Ao(){if(ko)return Oo;ko=1;var e=wo(),t=Do(),n=vo(),r=ho();return Oo=Object.getOwnPropertySymbols?function(r){for(var i=[];r;)e(i,n(r)),r=t(r);return i}:r,Oo}var jo,Mo;function No(){if(Mo)return jo;Mo=1;var e=zi(),t=Ao();function n(n,r){return e(n,t(n),r)}return jo=n,jo}var Po,Fo;function Io(){if(Fo)return Po;Fo=1;var e=wo(),t=K();function n(n,r,i){var a=r(n);return t(n)?a:e(a,i(n))}return Po=n,Po}var Lo,Ro;function zo(){if(Ro)return Lo;Ro=1;var e=Io(),t=vo(),n=J();function r(r){return e(r,n,t)}return Lo=r,Lo}var Bo,Vo;function Ho(){if(Vo)return Bo;Vo=1;var e=Io(),t=Ao(),n=$a();function r(r){return e(r,n,t)}return Bo=r,Bo}var Uo,Wo;function Go(){return Wo?Uo:(Wo=1,Uo=wr()(U(),`DataView`),Uo)}var Ko,qo;function Jo(){return qo?Ko:(qo=1,Ko=wr()(U(),`Promise`),Ko)}var Yo,Xo;function Zo(){return Xo?Yo:(Xo=1,Yo=wr()(U(),`Set`),Yo)}var Qo,$o;function es(){return $o?Qo:($o=1,Qo=wr()(U(),`WeakMap`),Qo)}var ts,ns;function rs(){if(ns)return ts;ns=1;var e=Go(),t=Dr(),n=Jo(),r=Zo(),i=es(),a=tr(),o=hr(),s=`[object Map]`,c=`[object Object]`,l=`[object Promise]`,u=`[object Set]`,d=`[object WeakMap]`,f=`[object DataView]`,p=o(e),m=o(t),h=o(n),g=o(r),_=o(i),v=a;return(e&&v(new e(new ArrayBuffer(1)))!=f||t&&v(new t)!=s||n&&v(n.resolve())!=l||r&&v(new r)!=u||i&&v(new i)!=d)&&(v=function(e){var t=a(e),n=t==c?e.constructor:void 0,r=n?o(n):``;if(r)switch(r){case p:return f;case m:return s;case h:return l;case g:return u;case _:return d}return t}),ts=v,ts}var is,as;function os(){if(as)return is;as=1;var e=Object.prototype.hasOwnProperty;function t(t){var n=t.length,r=new t.constructor(n);return n&&typeof t[0]==`string`&&e.call(t,`index`)&&(r.index=t.index,r.input=t.input),r}return is=t,is}var ss,cs;function ls(){return cs?ss:(cs=1,ss=U().Uint8Array,ss)}var us,ds;function fs(){if(ds)return us;ds=1;var e=ls();function t(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return us=t,us}var ps,ms;function hs(){if(ms)return ps;ms=1;var e=fs();function t(t,n){var r=n?e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}return ps=t,ps}var gs,_s;function vs(){if(_s)return gs;_s=1;var e=/\w*$/;function t(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return gs=t,gs}var ys,bs;function xs(){if(bs)return ys;bs=1;var e=Kn(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(e){return n?Object(n.call(e)):{}}return ys=r,ys}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=fs();function t(t,n){var r=n?e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}return Ss=t,Ss}var Ts,Es;function Ds(){if(Es)return Ts;Es=1;var e=fs(),t=hs(),n=vs(),r=xs(),i=ws(),a=`[object Boolean]`,o=`[object Date]`,s=`[object Map]`,c=`[object Number]`,l=`[object RegExp]`,u=`[object Set]`,d=`[object String]`,f=`[object Symbol]`,p=`[object ArrayBuffer]`,m=`[object DataView]`,h=`[object Float32Array]`,g=`[object Float64Array]`,_=`[object Int8Array]`,v=`[object Int16Array]`,y=`[object Int32Array]`,b=`[object Uint8Array]`,x=`[object Uint8ClampedArray]`,S=`[object Uint16Array]`,C=`[object Uint32Array]`;function w(w,T,E){var D=w.constructor;switch(T){case p:return e(w);case a:case o:return new D(+w);case m:return t(w,E);case h:case g:case _:case v:case y:case b:case x:case S:case C:return i(w,E);case s:return new D;case c:case d:return new D(w);case l:return n(w);case u:return new D;case f:return r(w)}}return Ts=w,Ts}var Os,ks;function As(){if(ks)return Os;ks=1;var e=W(),t=Object.create;return Os=function(){function n(){}return function(r){if(!e(r))return{};if(t)return t(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}(),Os}var js,Ms;function Ns(){if(Ms)return js;Ms=1;var e=As(),t=Do(),n=Oa();function r(r){return typeof r.constructor==`function`&&!n(r)?e(t(r)):{}}return js=r,js}var Ps,Fs;function Is(){if(Fs)return Ps;Fs=1;var e=rs(),t=G(),n=`[object Map]`;function r(r){return t(r)&&e(r)==n}return Ps=r,Ps}var Ls,Rs;function zs(){if(Rs)return Ls;Rs=1;var e=Is(),t=ga(),n=ya(),r=n&&n.isMap;return Ls=r?t(r):e,Ls}var Bs,Vs;function Hs(){if(Vs)return Bs;Vs=1;var e=rs(),t=G(),n=`[object Set]`;function r(r){return t(r)&&e(r)==n}return Bs=r,Bs}var Us,Ws;function Gs(){if(Ws)return Us;Ws=1;var e=Hs(),t=ga(),n=ya(),r=n&&n.isSet;return Us=r?t(r):e,Us}var Ks,qs;function Js(){if(qs)return Ks;qs=1;var e=wi(),t=Di(),n=Ii(),r=Wa(),i=no(),a=ao(),o=co(),s=xo(),c=No(),l=zo(),u=Ho(),d=rs(),f=os(),p=Ds(),m=Ns(),h=K(),g=ia(),_=zs(),v=W(),y=Gs(),b=J(),x=$a(),S=1,C=2,w=4,T=`[object Arguments]`,E=`[object Array]`,D=`[object Boolean]`,O=`[object Date]`,k=`[object Error]`,A=`[object Function]`,ee=`[object GeneratorFunction]`,j=`[object Map]`,M=`[object Number]`,te=`[object Object]`,N=`[object RegExp]`,P=`[object Set]`,F=`[object String]`,I=`[object Symbol]`,ne=`[object WeakMap]`,L=`[object ArrayBuffer]`,re=`[object DataView]`,ie=`[object Float32Array]`,ae=`[object Float64Array]`,oe=`[object Int8Array]`,se=`[object Int16Array]`,ce=`[object Int32Array]`,le=`[object Uint8Array]`,ue=`[object Uint8ClampedArray]`,de=`[object Uint16Array]`,fe=`[object Uint32Array]`,R={};R[T]=R[E]=R[L]=R[re]=R[D]=R[O]=R[ie]=R[ae]=R[oe]=R[se]=R[ce]=R[j]=R[M]=R[te]=R[N]=R[P]=R[F]=R[I]=R[le]=R[ue]=R[de]=R[fe]=!0,R[k]=R[A]=R[ne]=!1;function pe(E,D,O,k,j,M){var N,P=D&S,F=D&C,I=D&w;if(O&&(N=j?O(E,k,j,M):O(E)),N!==void 0)return N;if(!v(E))return E;var ne=h(E);if(ne){if(N=f(E),!P)return o(E,N)}else{var L=d(E),re=L==A||L==ee;if(g(E))return a(E,P);if(L==te||L==T||re&&!j){if(N=F||re?{}:m(E),!P)return F?c(E,i(N,E)):s(E,r(N,E))}else{if(!R[L])return j?E:{};N=p(E,L,P)}}M||=new e;var ie=M.get(E);if(ie)return ie;M.set(E,N),y(E)?E.forEach(function(e){N.add(pe(e,D,O,e,E,M))}):_(E)&&E.forEach(function(e,t){N.set(t,pe(e,D,O,t,E,M))});var ae=ne?void 0:(I?F?u:l:F?x:b)(E);return t(ae||E,function(e,t){ae&&(t=e,e=E[t]),n(N,t,pe(e,D,O,t,E,M))}),N}return Ks=pe,Ks}var Ys,Xs;function Zs(){if(Xs)return Ys;Xs=1;var e=Js(),t=4;function n(n){return e(n,t)}return Ys=n,Ys}var Qs,$s;function ec(){if($s)return Qs;$s=1;function e(e){return function(){return e}}return Qs=e,Qs}var tc,nc;function rc(){if(nc)return tc;nc=1;function e(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}return tc=e,tc}var ic,ac;function oc(){return ac?ic:(ac=1,ic=rc()(),ic)}var sc,cc;function lc(){if(cc)return sc;cc=1;var e=oc(),t=J();function n(n,r){return n&&e(n,r,t)}return sc=n,sc}var uc,dc;function fc(){if(dc)return uc;dc=1;var e=q();function t(t,n){return function(r,i){if(r==null)return r;if(!e(r))return t(r,i);for(var a=r.length,o=n?a:-1,s=Object(r);(n?o--:++o<a)&&i(s[o],o,s)!==!1;);return r}}return uc=t,uc}var pc,mc;function hc(){if(mc)return pc;mc=1;var e=lc();return pc=fc()(e),pc}var gc,_c;function vc(){if(_c)return gc;_c=1;function e(e){return e}return gc=e,gc}var yc,bc;function xc(){if(bc)return yc;bc=1;var e=vc();function t(t){return typeof t==`function`?t:e}return yc=t,yc}var Sc,Cc;function wc(){if(Cc)return Sc;Cc=1;var e=Di(),t=hc(),n=xc(),r=K();function i(i,a){return(r(i)?e:t)(i,n(a))}return Sc=i,Sc}var Tc,Ec;function Dc(){return Ec?Tc:(Ec=1,Tc=wc(),Tc)}var Oc,kc;function Ac(){if(kc)return Oc;kc=1;var e=hc();function t(t,n){var r=[];return e(t,function(e,t,i){n(e,t,i)&&r.push(e)}),r}return Oc=t,Oc}var jc,Mc;function Nc(){if(Mc)return jc;Mc=1;var e=`__lodash_hash_undefined__`;function t(t){return this.__data__.set(t,e),this}return jc=t,jc}var Pc,Fc;function Ic(){if(Fc)return Pc;Fc=1;function e(e){return this.__data__.has(e)}return Pc=e,Pc}var Lc,Rc;function zc(){if(Rc)return Lc;Rc=1;var e=vi(),t=Nc(),n=Ic();function r(t){var n=-1,r=t==null?0:t.length;for(this.__data__=new e;++n<r;)this.add(t[n])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,Lc=r,Lc}var Bc,Vc;function Hc(){if(Vc)return Bc;Vc=1;function e(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}return Bc=e,Bc}var Uc,Wc;function Gc(){if(Wc)return Uc;Wc=1;function e(e,t){return e.has(t)}return Uc=e,Uc}var Kc,qc;function Jc(){if(qc)return Kc;qc=1;var e=zc(),t=Hc(),n=Gc(),r=1,i=2;function a(a,o,s,c,l,u){var d=s&r,f=a.length,p=o.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(a),h=u.get(o);if(m&&h)return m==o&&h==a;var g=-1,_=!0,v=s&i?new e:void 0;for(u.set(a,o),u.set(o,a);++g<f;){var y=a[g],b=o[g];if(c)var x=d?c(b,y,g,o,a,u):c(y,b,g,a,o,u);if(x!==void 0){if(x)continue;_=!1;break}if(v){if(!t(o,function(e,t){if(!n(v,t)&&(y===e||l(y,e,s,c,u)))return v.push(t)})){_=!1;break}}else if(!(y===b||l(y,b,s,c,u))){_=!1;break}}return u.delete(a),u.delete(o),_}return Kc=a,Kc}var Yc,Xc;function Zc(){if(Xc)return Yc;Xc=1;function e(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}return Yc=e,Yc}var Qc,$c;function el(){if($c)return Qc;$c=1;function e(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}return Qc=e,Qc}var tl,nl;function rl(){if(nl)return tl;nl=1;var e=Kn(),t=ls(),n=cn(),r=Jc(),i=Zc(),a=el(),o=1,s=2,c=`[object Boolean]`,l=`[object Date]`,u=`[object Error]`,d=`[object Map]`,f=`[object Number]`,p=`[object RegExp]`,m=`[object Set]`,h=`[object String]`,g=`[object Symbol]`,_=`[object ArrayBuffer]`,v=`[object DataView]`,y=e?e.prototype:void 0,b=y?y.valueOf:void 0;function x(e,y,x,S,C,w,T){switch(x){case v:if(e.byteLength!=y.byteLength||e.byteOffset!=y.byteOffset)return!1;e=e.buffer,y=y.buffer;case _:return!(e.byteLength!=y.byteLength||!w(new t(e),new t(y)));case c:case l:case f:return n(+e,+y);case u:return e.name==y.name&&e.message==y.message;case p:case h:return e==y+``;case d:var E=i;case m:var D=S&o;if(E||=a,e.size!=y.size&&!D)return!1;var O=T.get(e);if(O)return O==y;S|=s,T.set(e,y);var k=r(E(e),E(y),S,C,w,T);return T.delete(e),k;case g:if(b)return b.call(e)==b.call(y)}return!1}return tl=x,tl}var il,al;function ol(){if(al)return il;al=1;var e=zo(),t=1,n=Object.prototype.hasOwnProperty;function r(r,i,a,o,s,c){var l=a&t,u=e(r),d=u.length;if(d!=e(i).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in i:n.call(i,p)))return!1}var m=c.get(r),h=c.get(i);if(m&&h)return m==i&&h==r;var g=!0;c.set(r,i),c.set(i,r);for(var _=l;++f<d;){p=u[f];var v=r[p],y=i[p];if(o)var b=l?o(y,v,p,i,r,c):o(v,y,p,r,i,c);if(!(b===void 0?v===y||s(v,y,a,o,c):b)){g=!1;break}_||=p==`constructor`}if(g&&!_){var x=r.constructor,S=i.constructor;x!=S&&`constructor`in r&&`constructor`in i&&!(typeof x==`function`&&x instanceof x&&typeof S==`function`&&S instanceof S)&&(g=!1)}return c.delete(r),c.delete(i),g}return il=r,il}var sl,cl;function ll(){if(cl)return sl;cl=1;var e=wi(),t=Jc(),n=rl(),r=ol(),i=rs(),a=K(),o=ia(),s=Sa(),c=1,l=`[object Arguments]`,u=`[object Array]`,d=`[object Object]`,f=Object.prototype.hasOwnProperty;function p(p,m,h,g,_,v){var y=a(p),b=a(m),x=y?u:i(p),S=b?u:i(m);x=x==l?d:x,S=S==l?d:S;var C=x==d,w=S==d,T=x==S;if(T&&o(p)){if(!o(m))return!1;y=!0,C=!1}if(T&&!C)return v||=new e,y||s(p)?t(p,m,h,g,_,v):n(p,m,x,h,g,_,v);if(!(h&c)){var E=C&&f.call(p,`__wrapped__`),D=w&&f.call(m,`__wrapped__`);if(E||D){var O=E?p.value():p,k=D?m.value():m;return v||=new e,_(O,k,h,g,v)}}return T?(v||=new e,r(p,m,h,g,_,v)):!1}return sl=p,sl}var ul,dl;function fl(){if(dl)return ul;dl=1;var e=ll(),t=G();function n(r,i,a,o,s){return r===i?!0:r==null||i==null||!t(r)&&!t(i)?r!==r&&i!==i:e(r,i,a,o,n,s)}return ul=n,ul}var pl,ml;function hl(){if(ml)return pl;ml=1;var e=wi(),t=fl(),n=1,r=2;function i(i,a,o,s){var c=o.length,l=c,u=!s;if(i==null)return!l;for(i=Object(i);c--;){var d=o[c];if(u&&d[2]?d[1]!==i[d[0]]:!(d[0]in i))return!1}for(;++c<l;){d=o[c];var f=d[0],p=i[f],m=d[1];if(u&&d[2]){if(p===void 0&&!(f in i))return!1}else{var h=new e;if(s)var g=s(p,m,f,i,a,h);if(!(g===void 0?t(m,p,n|r,s,h):g))return!1}}return!0}return pl=i,pl}var gl,_l;function vl(){if(_l)return gl;_l=1;var e=W();function t(t){return t===t&&!e(t)}return gl=t,gl}var yl,bl;function xl(){if(bl)return yl;bl=1;var e=vl(),t=J();function n(n){for(var r=t(n),i=r.length;i--;){var a=r[i],o=n[a];r[i]=[a,o,e(o)]}return r}return yl=n,yl}var Sl,Cl;function wl(){if(Cl)return Sl;Cl=1;function e(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}return Sl=e,Sl}var Tl,El;function Dl(){if(El)return Tl;El=1;var e=hl(),t=xl(),n=wl();function r(r){var i=t(r);return i.length==1&&i[0][2]?n(i[0][0],i[0][1]):function(t){return t===r||e(t,r,i)}}return Tl=r,Tl}var Ol,kl;function Al(){if(kl)return Ol;kl=1;var e=tr(),t=G(),n=`[object Symbol]`;function r(r){return typeof r==`symbol`||t(r)&&e(r)==n}return Ol=r,Ol}var jl,Ml;function Nl(){if(Ml)return jl;Ml=1;var e=K(),t=Al(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(i,a){if(e(i))return!1;var o=typeof i;return o==`number`||o==`symbol`||o==`boolean`||i==null||t(i)?!0:r.test(i)||!n.test(i)||a!=null&&i in Object(a)}return jl=i,jl}var Pl,Fl;function Il(){if(Fl)return Pl;Fl=1;var e=vi(),t=`Expected a function`;function n(r,i){if(typeof r!=`function`||i!=null&&typeof i!=`function`)throw TypeError(t);var a=function(){var e=arguments,t=i?i.apply(this,e):e[0],n=a.cache;if(n.has(t))return n.get(t);var o=r.apply(this,e);return a.cache=n.set(t,o)||n,o};return a.cache=new(n.Cache||e),a}return n.Cache=e,Pl=n,Pl}var Ll,Rl;function zl(){if(Rl)return Ll;Rl=1;var e=Il(),t=500;function n(n){var r=e(n,function(e){return i.size===t&&i.clear(),e}),i=r.cache;return r}return Ll=n,Ll}var Bl,Vl;function Hl(){if(Vl)return Bl;Vl=1;var e=zl(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g;return Bl=e(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(``),e.replace(t,function(e,t,i,a){r.push(i?a.replace(n,`$1`):t||e)}),r}),Bl}var Ul,Wl;function Gl(){if(Wl)return Ul;Wl=1;function e(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}return Ul=e,Ul}var Kl,ql;function Jl(){if(ql)return Kl;ql=1;var e=Kn(),t=Gl(),n=K(),r=Al(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(e){if(typeof e==`string`)return e;if(n(e))return t(e,o)+``;if(r(e))return a?a.call(e):``;var i=e+``;return i==`0`&&1/e==-1/0?`-0`:i}return Kl=o,Kl}var Yl,Xl;function Zl(){if(Xl)return Yl;Xl=1;var e=Jl();function t(t){return t==null?``:e(t)}return Yl=t,Yl}var Ql,$l;function eu(){if($l)return Ql;$l=1;var e=K(),t=Nl(),n=Hl(),r=Zl();function i(i,a){return e(i)?i:t(i,a)?[i]:n(r(i))}return Ql=i,Ql}var tu,nu;function ru(){if(nu)return tu;nu=1;var e=Al();function t(t){if(typeof t==`string`||e(t))return t;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n}return tu=t,tu}var iu,au;function ou(){if(au)return iu;au=1;var e=eu(),t=ru();function n(n,r){r=e(r,n);for(var i=0,a=r.length;n!=null&&i<a;)n=n[t(r[i++])];return i&&i==a?n:void 0}return iu=n,iu}var su,cu;function lu(){if(cu)return su;cu=1;var e=ou();function t(t,n,r){var i=t==null?void 0:e(t,n);return i===void 0?r:i}return su=t,su}var uu,du;function fu(){if(du)return uu;du=1;function e(e,t){return e!=null&&t in Object(e)}return uu=e,uu}var pu,mu;function hu(){if(mu)return pu;mu=1;var e=eu(),t=Xi(),n=K(),r=sa(),i=ua(),a=ru();function o(o,s,c){s=e(s,o);for(var l=-1,u=s.length,d=!1;++l<u;){var f=a(s[l]);if(!(d=o!=null&&c(o,f)))break;o=o[f]}return d||++l!=u?d:(u=o==null?0:o.length,!!u&&i(u)&&r(f,u)&&(n(o)||t(o)))}return pu=o,pu}var gu,_u;function vu(){if(_u)return gu;_u=1;var e=fu(),t=hu();function n(n,r){return n!=null&&t(n,r,e)}return gu=n,gu}var yu,bu;function xu(){if(bu)return yu;bu=1;var e=fl(),t=lu(),n=vu(),r=Nl(),i=vl(),a=wl(),o=ru(),s=1,c=2;function l(l,u){return r(l)&&i(u)?a(o(l),u):function(r){var i=t(r,l);return i===void 0&&i===u?n(r,l):e(u,i,s|c)}}return yu=l,yu}var Su,Cu;function wu(){if(Cu)return Su;Cu=1;function e(e){return function(t){return t?.[e]}}return Su=e,Su}var Tu,Eu;function Du(){if(Eu)return Tu;Eu=1;var e=ou();function t(t){return function(n){return e(n,t)}}return Tu=t,Tu}var Ou,ku;function Au(){if(ku)return Ou;ku=1;var e=wu(),t=Du(),n=Nl(),r=ru();function i(i){return n(i)?e(r(i)):t(i)}return Ou=i,Ou}var ju,Mu;function Y(){if(Mu)return ju;Mu=1;var e=Dl(),t=xu(),n=vc(),r=K(),i=Au();function a(a){return typeof a==`function`?a:a==null?n:typeof a==`object`?r(a)?t(a[0],a[1]):e(a):i(a)}return ju=a,ju}var Nu,Pu;function Fu(){if(Pu)return Nu;Pu=1;var e=fo(),t=Ac(),n=Y(),r=K();function i(i,a){return(r(i)?e:t)(i,n(a,3))}return Nu=i,Nu}var Iu,Lu;function Ru(){if(Lu)return Iu;Lu=1;var e=Object.prototype.hasOwnProperty;function t(t,n){return t!=null&&e.call(t,n)}return Iu=t,Iu}var zu,Bu;function Vu(){if(Bu)return zu;Bu=1;var e=Ru(),t=hu();function n(n,r){return n!=null&&t(n,r,e)}return zu=n,zu}var Hu,Uu;function Wu(){if(Uu)return Hu;Uu=1;var e=La(),t=rs(),n=Xi(),r=K(),i=q(),a=ia(),o=Oa(),s=Sa(),c=`[object Map]`,l=`[object Set]`,u=Object.prototype.hasOwnProperty;function d(d){if(d==null)return!0;if(i(d)&&(r(d)||typeof d==`string`||typeof d.splice==`function`||a(d)||s(d)||n(d)))return!d.length;var f=t(d);if(f==c||f==l)return!d.size;if(o(d))return!e(d).length;for(var p in d)if(u.call(d,p))return!1;return!0}return Hu=d,Hu}var Gu,Ku;function qu(){if(Ku)return Gu;Ku=1;function e(e){return e===void 0}return Gu=e,Gu}var Ju,Yu;function Xu(){if(Yu)return Ju;Yu=1;var e=hc(),t=q();function n(n,r){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(e,t,n){a[++i]=r(e,t,n)}),a}return Ju=n,Ju}var Zu,Qu;function $u(){if(Qu)return Zu;Qu=1;var e=Gl(),t=Y(),n=Xu(),r=K();function i(i,a){return(r(i)?e:n)(i,t(a,3))}return Zu=i,Zu}var ed,td;function nd(){if(td)return ed;td=1;function e(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}return ed=e,ed}var rd,id;function ad(){if(id)return rd;id=1;function e(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}return rd=e,rd}var od,sd;function cd(){if(sd)return od;sd=1;var e=nd(),t=hc(),n=Y(),r=ad(),i=K();function a(a,o,s){var c=i(a)?e:r,l=arguments.length<3;return c(a,n(o,4),s,l,t)}return od=a,od}var ld,ud;function dd(){if(ud)return ld;ud=1;var e=tr(),t=K(),n=G(),r=`[object String]`;function i(i){return typeof i==`string`||!t(i)&&n(i)&&e(i)==r}return ld=i,ld}var fd,pd;function md(){return pd?fd:(pd=1,fd=wu()(`length`),fd)}var hd,gd;function _d(){if(gd)return hd;gd=1;var e=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`);function t(t){return e.test(t)}return hd=t,hd}var vd,yd;function bd(){if(yd)return vd;yd=1;var e=`\\ud800-\\udfff`,t=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,n=`\\ufe0e\\ufe0f`,r=`[`+e+`]`,i=`[`+t+`]`,a=`\\ud83c[\\udffb-\\udfff]`,o=`(?:`+i+`|`+a+`)`,s=`[^`+e+`]`,c=`(?:\\ud83c[\\udde6-\\uddff]){2}`,l=`[\\ud800-\\udbff][\\udc00-\\udfff]`,u=`\\u200d`,d=o+`?`,f=`[`+n+`]?`,p=`(?:`+u+`(?:`+[s,c,l].join(`|`)+`)`+f+d+`)*`,m=f+d+p,h=`(?:`+[s+i+`?`,i,c,l,r].join(`|`)+`)`,g=RegExp(a+`(?=`+a+`)|`+h+m,`g`);function _(e){for(var t=g.lastIndex=0;g.test(e);)++t;return t}return vd=_,vd}var xd,Sd;function Cd(){if(Sd)return xd;Sd=1;var e=md(),t=_d(),n=bd();function r(r){return t(r)?n(r):e(r)}return xd=r,xd}var wd,Td;function Ed(){if(Td)return wd;Td=1;var e=La(),t=rs(),n=q(),r=dd(),i=Cd(),a=`[object Map]`,o=`[object Set]`;function s(s){if(s==null)return 0;if(n(s))return r(s)?i(s):s.length;var c=t(s);return c==a||c==o?s.size:e(s).length}return wd=s,wd}var Dd,Od;function kd(){if(Od)return Dd;Od=1;var e=Di(),t=As(),n=lc(),r=Y(),i=Do(),a=K(),o=ia(),s=or(),c=W(),l=Sa();function u(u,d,f){var p=a(u),m=p||o(u)||l(u);if(d=r(d,4),f==null){var h=u&&u.constructor;f=m?p?new h:[]:c(u)&&s(h)?t(i(u)):{}}return(m?e:n)(u,function(e,t,n){return d(f,e,t,n)}),f}return Dd=u,Dd}var Ad,jd;function Md(){if(jd)return Ad;jd=1;var e=Kn(),t=Xi(),n=K(),r=e?e.isConcatSpreadable:void 0;function i(e){return n(e)||t(e)||!!(r&&e&&e[r])}return Ad=i,Ad}var Nd,Pd;function Fd(){if(Pd)return Nd;Pd=1;var e=wo(),t=Md();function n(r,i,a,o,s){var c=-1,l=r.length;for(a||=t,s||=[];++c<l;){var u=r[c];i>0&&a(u)?i>1?n(u,i-1,a,o,s):e(s,u):o||(s[s.length]=u)}return s}return Nd=n,Nd}var Id,Ld;function Rd(){if(Ld)return Id;Ld=1;function e(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return Id=e,Id}var zd,Bd;function Vd(){if(Bd)return zd;Bd=1;var e=Rd(),t=Math.max;function n(n,r,i){return r=t(r===void 0?n.length-1:r,0),function(){for(var a=arguments,o=-1,s=t(a.length-r,0),c=Array(s);++o<s;)c[o]=a[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=a[o];return l[r]=i(c),e(n,this,l)}}return zd=n,zd}var Hd,Ud;function Wd(){if(Ud)return Hd;Ud=1;var e=ec(),t=Ai(),n=vc();return Hd=t?function(n,r){return t(n,`toString`,{configurable:!0,enumerable:!1,value:e(r),writable:!0})}:n,Hd}var Gd,Kd;function qd(){if(Kd)return Gd;Kd=1;var e=800,t=16,n=Date.now;function r(r){var i=0,a=0;return function(){var o=n(),s=t-(o-a);if(a=o,s>0){if(++i>=e)return arguments[0]}else i=0;return r.apply(void 0,arguments)}}return Gd=r,Gd}var Jd,Yd;function Xd(){if(Yd)return Jd;Yd=1;var e=Wd();return Jd=qd()(e),Jd}var Zd,Qd;function $d(){if(Qd)return Zd;Qd=1;var e=vc(),t=Vd(),n=Xd();function r(r,i){return n(t(r,i,e),r+``)}return Zd=r,Zd}var ef,tf;function nf(){if(tf)return ef;tf=1;function e(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}return ef=e,ef}var rf,af;function of(){if(af)return rf;af=1;function e(e){return e!==e}return rf=e,rf}var sf,cf;function lf(){if(cf)return sf;cf=1;function e(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}return sf=e,sf}var uf,df;function ff(){if(df)return uf;df=1;var e=nf(),t=of(),n=lf();function r(r,i,a){return i===i?n(r,i,a):e(r,t,a)}return uf=r,uf}var pf,mf;function hf(){if(mf)return pf;mf=1;var e=ff();function t(t,n){return!!(t!=null&&t.length)&&e(t,n,0)>-1}return pf=t,pf}var gf,_f;function vf(){if(_f)return gf;_f=1;function e(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}return gf=e,gf}var yf,bf;function xf(){if(bf)return yf;bf=1;function e(){}return yf=e,yf}var Sf,Cf;function wf(){if(Cf)return Sf;Cf=1;var e=Zo(),t=xf(),n=el();return Sf=e&&1/n(new e([,-0]))[1]==1/0?function(t){return new e(t)}:t,Sf}var Tf,Ef;function Df(){if(Ef)return Tf;Ef=1;var e=zc(),t=hf(),n=vf(),r=Gc(),i=wf(),a=el(),o=200;function s(s,c,l){var u=-1,d=t,f=s.length,p=!0,m=[],h=m;if(l)p=!1,d=n;else if(f>=o){var g=c?null:i(s);if(g)return a(g);p=!1,d=r,h=new e}else h=c?[]:m;outer:for(;++u<f;){var _=s[u],v=c?c(_):_;if(_=l||_!==0?_:0,p&&v===v){for(var y=h.length;y--;)if(h[y]===v)continue outer;c&&h.push(v),m.push(_)}else d(h,v,l)||(h!==m&&h.push(v),m.push(_))}return m}return Tf=s,Tf}var Of,kf;function Af(){if(kf)return Of;kf=1;var e=q(),t=G();function n(n){return t(n)&&e(n)}return Of=n,Of}var jf,Mf;function Nf(){if(Mf)return jf;Mf=1;var e=Fd(),t=$d(),n=Df(),r=Af();return jf=t(function(t){return n(e(t,1,r,!0))}),jf}var Pf,Ff;function If(){if(Ff)return Pf;Ff=1;var e=Gl();function t(t,n){return e(n,function(e){return t[e]})}return Pf=t,Pf}var Lf,Rf;function zf(){if(Rf)return Lf;Rf=1;var e=If(),t=J();function n(n){return n==null?[]:e(n,t(n))}return Lf=n,Lf}var Bf,Vf;function X(){if(Vf)return Bf;Vf=1;var e;if(typeof tn==`function`)try{e={clone:Zs(),constant:ec(),each:Dc(),filter:Fu(),has:Vu(),isArray:K(),isEmpty:Wu(),isFunction:or(),isUndefined:qu(),keys:J(),map:$u(),reduce:cd(),size:Ed(),transform:kd(),union:Nf(),values:zf()}}catch{}return e||=window._,Bf=e,Bf}var Hf,Uf;function Wf(){if(Uf)return Hf;Uf=1;var e=X();Hf=i;var t=`\0`,n=`\0`,r=``;function i(t){this._isDirected=!e.has(t,`directed`)||t.directed,this._isMultigraph=e.has(t,`multigraph`)?t.multigraph:!1,this._isCompound=e.has(t,`compound`)?t.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(e){return this._label=e,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultNodeLabelFn=t,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var t=this;return e.filter(this.nodes(),function(n){return e.isEmpty(t._in[n])})},i.prototype.sinks=function(){var t=this;return e.filter(this.nodes(),function(n){return e.isEmpty(t._out[n])})},i.prototype.setNodes=function(t,n){var r=arguments,i=this;return e.each(t,function(e){r.length>1?i.setNode(e,n):i.setNode(e)}),this},i.prototype.setNode=function(t,r){return e.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=r),this):(this._nodes[t]=arguments.length>1?r:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=n,this._children[t]={},this._children[n][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},i.prototype.node=function(e){return this._nodes[e]},i.prototype.hasNode=function(t){return e.has(this._nodes,t)},i.prototype.removeNode=function(t){var n=this;if(e.has(this._nodes,t)){var r=function(e){n.removeEdge(n._edgeObjs[e])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],e.each(this.children(t),function(e){n.setParent(e)}),delete this._children[t]),e.each(e.keys(this._in[t]),r),delete this._in[t],delete this._preds[t],e.each(e.keys(this._out[t]),r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},i.prototype.setParent=function(t,r){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(e.isUndefined(r))r=n;else{r+=``;for(var i=r;!e.isUndefined(i);i=this.parent(i))if(i===t)throw Error(`Setting `+r+` as parent of `+t+` would create a cycle`);this.setNode(r)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=r,this._children[r][t]=!0,this},i.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},i.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==n)return t}},i.prototype.children=function(t){if(e.isUndefined(t)&&(t=n),this._isCompound){var r=this._children[t];if(r)return e.keys(r)}else if(t===n)return this.nodes();else if(this.hasNode(t))return[]},i.prototype.predecessors=function(t){var n=this._preds[t];if(n)return e.keys(n)},i.prototype.successors=function(t){var n=this._sucs[t];if(n)return e.keys(n)},i.prototype.neighbors=function(t){var n=this.predecessors(t);if(n)return e.union(n,this.successors(t))},i.prototype.isLeaf=function(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0},i.prototype.filterNodes=function(t){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;e.each(this._nodes,function(e,r){t(r)&&n.setNode(r,e)}),e.each(this._edgeObjs,function(e){n.hasNode(e.v)&&n.hasNode(e.w)&&n.setEdge(e,r.edge(e))});var i={};function a(e){var t=r.parent(e);return t===void 0||n.hasNode(t)?(i[e]=t,t):t in i?i[t]:a(t)}return this._isCompound&&e.each(n.nodes(),function(e){n.setParent(e,a(e))}),n},i.prototype.setDefaultEdgeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultEdgeLabelFn=t,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(t,n){var r=this,i=arguments;return e.reduce(t,function(e,t){return i.length>1?r.setEdge(e,t,n):r.setEdge(e,t),t}),this},i.prototype.setEdge=function(){var t,n,r,i,o=!1,l=arguments[0];typeof l==`object`&&l&&`v`in l?(t=l.v,n=l.w,r=l.name,arguments.length===2&&(i=arguments[1],o=!0)):(t=l,n=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],o=!0)),t=``+t,n=``+n,e.isUndefined(r)||(r=``+r);var u=s(this._isDirected,t,n,r);if(e.has(this._edgeLabels,u))return o&&(this._edgeLabels[u]=i),this;if(!e.isUndefined(r)&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(t),this.setNode(n),this._edgeLabels[u]=o?i:this._defaultEdgeLabelFn(t,n,r);var d=c(this._isDirected,t,n,r);return t=d.v,n=d.w,Object.freeze(d),this._edgeObjs[u]=d,a(this._preds[n],t),a(this._sucs[t],n),this._in[n][u]=d,this._out[t][u]=d,this._edgeCount++,this},i.prototype.edge=function(e,t,n){var r=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,e,t,n);return this._edgeLabels[r]},i.prototype.hasEdge=function(t,n,r){var i=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,t,n,r);return e.has(this._edgeLabels,i)},i.prototype.removeEdge=function(e,t,n){var r=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],o(this._preds[t],e),o(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this},i.prototype.inEdges=function(t,n){var r=this._in[t];if(r){var i=e.values(r);return n?e.filter(i,function(e){return e.v===n}):i}},i.prototype.outEdges=function(t,n){var r=this._out[t];if(r){var i=e.values(r);return n?e.filter(i,function(e){return e.w===n}):i}},i.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))};function a(e,t){e[t]?e[t]++:e[t]=1}function o(e,t){--e[t]||delete e[t]}function s(n,i,a,o){var s=``+i,c=``+a;if(!n&&s>c){var l=s;s=c,c=l}return s+r+c+r+(e.isUndefined(o)?t:o)}function c(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function l(e,t){return s(e,t.v,t.w,t.name)}return Hf}var Gf,Kf;function qf(){return Kf?Gf:(Kf=1,Gf=`2.1.8`,Gf)}var Jf,Yf;function Xf(){return Yf?Jf:(Yf=1,Jf={Graph:Wf(),version:qf()},Jf)}var Zf,Qf;function $f(){if(Qf)return Zf;Qf=1;var e=X(),t=Wf();Zf={write:n,read:a};function n(t){var n={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:r(t),edges:i(t)};return e.isUndefined(t.graph())||(n.value=e.clone(t.graph())),n}function r(t){return e.map(t.nodes(),function(n){var r=t.node(n),i=t.parent(n),a={v:n};return e.isUndefined(r)||(a.value=r),e.isUndefined(i)||(a.parent=i),a})}function i(t){return e.map(t.edges(),function(n){var r=t.edge(n),i={v:n.v,w:n.w};return e.isUndefined(n.name)||(i.name=n.name),e.isUndefined(r)||(i.value=r),i})}function a(n){var r=new t(n.options).setGraph(n.value);return e.each(n.nodes,function(e){r.setNode(e.v,e.value),e.parent&&r.setParent(e.v,e.parent)}),e.each(n.edges,function(e){r.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),r}return Zf}var ep,tp;function np(){if(tp)return ep;tp=1;var e=X();ep=t;function t(t){var n={},r=[],i;function a(r){e.has(n,r)||(n[r]=!0,i.push(r),e.each(t.successors(r),a),e.each(t.predecessors(r),a))}return e.each(t.nodes(),function(e){i=[],a(e),i.length&&r.push(i)}),r}return ep}var rp,ip;function ap(){if(ip)return rp;ip=1;var e=X();rp=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(e){return e.key})},t.prototype.has=function(t){return e.has(this._keyIndices,t)},t.prototype.priority=function(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority},t.prototype.min=function(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key},t.prototype.add=function(t,n){var r=this._keyIndices;if(t=String(t),!e.has(r,t)){var i=this._arr,a=i.length;return r[t]=a,i.push({key:t,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},t.prototype.decrease=function(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)},t.prototype._heapify=function(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))},t.prototype._decrease=function(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r},t.prototype._swap=function(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t},rp}var op,sp;function cp(){if(sp)return op;sp=1;var e=X(),t=ap();op=r;var n=e.constant(1);function r(e,t,r,a){return i(e,String(t),r||n,a||function(t){return e.outEdges(t)})}function i(e,n,r,i){var a={},o=new t,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<n.distance&&(n.distance=l,n.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var t=e===n?0:1/0;a[e]={distance:t},o.add(e,t)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}return op}var lp,up;function dp(){if(up)return lp;up=1;var e=cp(),t=X();lp=n;function n(n,r,i){return t.transform(n.nodes(),function(t,a){t[a]=e(n,a,r,i)},{})}return lp}var fp,pp;function mp(){if(pp)return fp;pp=1;var e=X();fp=t;function t(t){var n=0,r=[],i={},a=[];function o(s){var c=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),t.successors(s).forEach(function(t){e.has(i,t)?i[t].onStack&&(c.lowlink=Math.min(c.lowlink,i[t].index)):(o(t),c.lowlink=Math.min(c.lowlink,i[t].lowlink))}),c.lowlink===c.index){var l=[],u;do u=r.pop(),i[u].onStack=!1,l.push(u);while(s!==u);a.push(l)}}return t.nodes().forEach(function(t){e.has(i,t)||o(t)}),a}return fp}var hp,gp;function _p(){if(gp)return hp;gp=1;var e=X(),t=mp();hp=n;function n(n){return e.filter(t(n),function(e){return e.length>1||e.length===1&&n.hasEdge(e[0],e[0])})}return hp}var vp,yp;function bp(){if(yp)return vp;yp=1;var e=X();vp=n;var t=e.constant(1);function n(e,n,i){return r(e,n||t,i||function(t){return e.outEdges(t)})}function r(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}return vp}var xp,Sp;function Cp(){if(Sp)return xp;Sp=1;var e=X();xp=t,t.CycleException=n;function t(t){var r={},i={},a=[];function o(s){if(e.has(i,s))throw new n;e.has(r,s)||(i[s]=!0,r[s]=!0,e.each(t.predecessors(s),o),delete i[s],a.push(s))}if(e.each(t.sinks(),o),e.size(r)!==t.nodeCount())throw new n;return a}function n(){}return n.prototype=Error(),xp}var wp,Tp;function Ep(){if(Tp)return wp;Tp=1;var e=Cp();wp=t;function t(t){try{e(t)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}return wp}var Dp,Op;function kp(){if(Op)return Dp;Op=1;var e=X();Dp=t;function t(t,r,i){e.isArray(r)||(r=[r]);var a=(t.isDirected()?t.successors:t.neighbors).bind(t),o=[],s={};return e.each(r,function(e){if(!t.hasNode(e))throw Error(`Graph does not have node: `+e);n(t,e,i===`post`,s,a,o)}),o}function n(t,r,i,a,o,s){e.has(a,r)||(a[r]=!0,i||s.push(r),e.each(o(r),function(e){n(t,e,i,a,o,s)}),i&&s.push(r))}return Dp}var Ap,jp;function Mp(){if(jp)return Ap;jp=1;var e=kp();Ap=t;function t(t,n){return e(t,n,`post`)}return Ap}var Np,Pp;function Fp(){if(Pp)return Np;Pp=1;var e=kp();Np=t;function t(t,n){return e(t,n,`pre`)}return Np}var Ip,Lp;function Rp(){if(Lp)return Ip;Lp=1;var e=X(),t=Wf(),n=ap();Ip=r;function r(r,i){var a=new t,o={},s=new n,c;function l(e){var t=e.v===c?e.w:e.v,n=s.priority(t);if(n!==void 0){var r=i(e);r<n&&(o[t]=c,s.decrease(t,r))}}if(r.nodeCount()===0)return a;e.each(r.nodes(),function(e){s.add(e,1/0),a.setNode(e)}),s.decrease(r.nodes()[0],0);for(var u=!1;s.size()>0;){if(c=s.removeMin(),e.has(o,c))a.setEdge(c,o[c]);else if(u)throw Error(`Input graph is not connected: `+r);else u=!0;r.nodeEdges(c).forEach(l)}return a}return Ip}var zp,Bp;function Vp(){return Bp?zp:(Bp=1,zp={components:np(),dijkstra:cp(),dijkstraAll:dp(),findCycles:_p(),floydWarshall:bp(),isAcyclic:Ep(),postorder:Mp(),preorder:Fp(),prim:Rp(),tarjan:mp(),topsort:Cp()},zp)}var Hp,Up;function Wp(){if(Up)return Hp;Up=1;var e=Xf();return Hp={Graph:e.Graph,json:$f(),alg:Vp(),version:e.version},Hp}var Gp,Kp;function Z(){if(Kp)return Gp;Kp=1;var e;if(typeof tn==`function`)try{e=Wp()}catch{}return e||=window.graphlib,Gp=e,Gp}var qp,Jp;function Yp(){if(Jp)return qp;Jp=1;var e=Js(),t=1,n=4;function r(r){return e(r,t|n)}return qp=r,qp}var Xp,Zp;function Qp(){if(Zp)return Xp;Zp=1;var e=cn(),t=q(),n=sa(),r=W();function i(i,a,o){if(!r(o))return!1;var s=typeof a;return(s==`number`?t(o)&&n(a,o.length):s==`string`&&a in o)?e(o[a],i):!1}return Xp=i,Xp}var $p,em;function tm(){if(em)return $p;em=1;var e=$d(),t=cn(),n=Qp(),r=$a(),i=Object.prototype,a=i.hasOwnProperty;return $p=e(function(e,o){e=Object(e);var s=-1,c=o.length,l=c>2?o[2]:void 0;for(l&&n(o[0],o[1],l)&&(c=1);++s<c;)for(var u=o[s],d=r(u),f=-1,p=d.length;++f<p;){var m=d[f],h=e[m];(h===void 0||t(h,i[m])&&!a.call(e,m))&&(e[m]=u[m])}return e}),$p}var nm,rm;function im(){if(rm)return nm;rm=1;var e=Y(),t=q(),n=J();function r(r){return function(i,a,o){var s=Object(i);if(!t(i)){var c=e(a,3);i=n(i),a=function(e){return c(s[e],e,s)}}var l=r(i,a,o);return l>-1?s[c?i[l]:l]:void 0}}return nm=r,nm}var am,om;function sm(){if(om)return am;om=1;var e=/\s/;function t(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return am=t,am}var cm,lm;function um(){if(lm)return cm;lm=1;var e=sm(),t=/^\s+/;function n(n){return n&&n.slice(0,e(n)+1).replace(t,``)}return cm=n,cm}var dm,fm;function pm(){if(fm)return dm;fm=1;var e=um(),t=W(),n=Al(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function c(c){if(typeof c==`number`)return c;if(n(c))return r;if(t(c)){var l=typeof c.valueOf==`function`?c.valueOf():c;c=t(l)?l+``:l}if(typeof c!=`string`)return c===0?c:+c;c=e(c);var u=a.test(c);return u||o.test(c)?s(c.slice(2),u?2:8):i.test(c)?r:+c}return dm=c,dm}var mm,hm;function gm(){if(hm)return mm;hm=1;var e=pm(),t=1/0,n=17976931348623157e292;function r(r){return r?(r=e(r),r===t||r===-t?(r<0?-1:1)*n:r===r?r:0):r===0?r:0}return mm=r,mm}var _m,vm;function ym(){if(vm)return _m;vm=1;var e=gm();function t(t){var n=e(t),r=n%1;return n===n?r?n-r:n:0}return _m=t,_m}var bm,xm;function Sm(){if(xm)return bm;xm=1;var e=nf(),t=Y(),n=ym(),r=Math.max;function i(i,a,o){var s=i==null?0:i.length;if(!s)return-1;var c=o==null?0:n(o);return c<0&&(c=r(s+c,0)),e(i,t(a,3),c)}return bm=i,bm}var Cm,wm;function Tm(){return wm?Cm:(wm=1,Cm=im()(Sm()),Cm)}var Em,Dm;function Om(){if(Dm)return Em;Dm=1;var e=Fd();function t(t){return t!=null&&t.length?e(t,1):[]}return Em=t,Em}var km,Am;function jm(){if(Am)return km;Am=1;var e=oc(),t=xc(),n=$a();function r(r,i){return r==null?r:e(r,t(i),n)}return km=r,km}var Mm,Nm;function Pm(){if(Nm)return Mm;Nm=1;function e(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return Mm=e,Mm}var Fm,Im;function Lm(){if(Im)return Fm;Im=1;var e=Ni(),t=lc(),n=Y();function r(r,i){var a={};return i=n(i,3),t(r,function(t,n,r){e(a,n,i(t,n,r))}),a}return Fm=r,Fm}var Rm,zm;function Bm(){if(zm)return Rm;zm=1;var e=Al();function t(t,n,r){for(var i=-1,a=t.length;++i<a;){var o=t[i],s=n(o);if(s!=null&&(c===void 0?s===s&&!e(s):r(s,c)))var c=s,l=o}return l}return Rm=t,Rm}var Vm,Hm;function Um(){if(Hm)return Vm;Hm=1;function e(e,t){return e>t}return Vm=e,Vm}var Wm,Gm;function Km(){if(Gm)return Wm;Gm=1;var e=Bm(),t=Um(),n=vc();function r(r){return r&&r.length?e(r,n,t):void 0}return Wm=r,Wm}var qm,Jm;function Ym(){if(Jm)return qm;Jm=1;var e=Ni(),t=cn();function n(n,r,i){(i!==void 0&&!t(n[r],i)||i===void 0&&!(r in n))&&e(n,r,i)}return qm=n,qm}var Xm,Zm;function Qm(){if(Zm)return Xm;Zm=1;var e=tr(),t=Do(),n=G(),r=`[object Object]`,i=Function.prototype,a=Object.prototype,o=i.toString,s=a.hasOwnProperty,c=o.call(Object);function l(i){if(!n(i)||e(i)!=r)return!1;var a=t(i);if(a===null)return!0;var l=s.call(a,`constructor`)&&a.constructor;return typeof l==`function`&&l instanceof l&&o.call(l)==c}return Xm=l,Xm}var $m,eh;function th(){if(eh)return $m;eh=1;function e(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}return $m=e,$m}var nh,rh;function ih(){if(rh)return nh;rh=1;var e=zi(),t=$a();function n(n){return e(n,t(n))}return nh=n,nh}var ah,oh;function sh(){if(oh)return ah;oh=1;var e=Ym(),t=ao(),n=ws(),r=co(),i=Ns(),a=Xi(),o=K(),s=Af(),c=ia(),l=or(),u=W(),d=Qm(),f=Sa(),p=th(),m=ih();function h(h,g,_,v,y,b,x){var S=p(h,_),C=p(g,_),w=x.get(C);if(w){e(h,_,w);return}var T=b?b(S,C,_+``,h,g,x):void 0,E=T===void 0;if(E){var D=o(C),O=!D&&c(C),k=!D&&!O&&f(C);T=C,D||O||k?o(S)?T=S:s(S)?T=r(S):O?(E=!1,T=t(C,!0)):k?(E=!1,T=n(C,!0)):T=[]:d(C)||a(C)?(T=S,a(S)?T=m(S):(!u(S)||l(S))&&(T=i(C))):E=!1}E&&(x.set(C,T),y(T,C,v,b,x),x.delete(C)),e(h,_,T)}return ah=h,ah}var ch,lh;function uh(){if(lh)return ch;lh=1;var e=wi(),t=Ym(),n=oc(),r=sh(),i=W(),a=$a(),o=th();function s(c,l,u,d,f){c!==l&&n(l,function(n,a){if(f||=new e,i(n))r(c,l,a,u,s,d,f);else{var p=d?d(o(c,a),n,a+``,c,l,f):void 0;p===void 0&&(p=n),t(c,a,p)}},a)}return ch=s,ch}var dh,fh;function ph(){if(fh)return dh;fh=1;var e=$d(),t=Qp();function n(n){return e(function(e,r){var i=-1,a=r.length,o=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(o=n.length>3&&typeof o==`function`?(a--,o):void 0,s&&t(r[0],r[1],s)&&(o=a<3?void 0:o,a=1),e=Object(e);++i<a;){var c=r[i];c&&n(e,c,i,o)}return e})}return dh=n,dh}var mh,hh;function gh(){if(hh)return mh;hh=1;var e=uh();return mh=ph()(function(t,n,r){e(t,n,r)}),mh}var _h,vh;function yh(){if(vh)return _h;vh=1;function e(e,t){return e<t}return _h=e,_h}var bh,xh;function Sh(){if(xh)return bh;xh=1;var e=Bm(),t=yh(),n=vc();function r(r){return r&&r.length?e(r,n,t):void 0}return bh=r,bh}var Ch,wh;function Th(){if(wh)return Ch;wh=1;var e=Bm(),t=Y(),n=yh();function r(r,i){return r&&r.length?e(r,t(i,2),n):void 0}return Ch=r,Ch}var Eh,Dh;function Oh(){if(Dh)return Eh;Dh=1;var e=U();return Eh=function(){return e.Date.now()},Eh}var kh,Ah;function jh(){if(Ah)return kh;Ah=1;var e=Ii(),t=eu(),n=sa(),r=W(),i=ru();function a(a,o,s,c){if(!r(a))return a;o=t(o,a);for(var l=-1,u=o.length,d=u-1,f=a;f!=null&&++l<u;){var p=i(o[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return a;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=r(h)?h:n(o[l+1])?[]:{})}e(f,p,m),f=f[p]}return a}return kh=a,kh}var Mh,Nh;function Ph(){if(Nh)return Mh;Nh=1;var e=ou(),t=jh(),n=eu();function r(r,i,a){for(var o=-1,s=i.length,c={};++o<s;){var l=i[o],u=e(r,l);a(u,l)&&t(c,n(l,r),u)}return c}return Mh=r,Mh}var Fh,Ih;function Lh(){if(Ih)return Fh;Ih=1;var e=Ph(),t=vu();function n(n,r){return e(n,r,function(e,r){return t(n,r)})}return Fh=n,Fh}var Rh,zh;function Bh(){if(zh)return Rh;zh=1;var e=Om(),t=Vd(),n=Xd();function r(r){return n(t(r,void 0,e),r+``)}return Rh=r,Rh}var Vh,Hh;function Uh(){if(Hh)return Vh;Hh=1;var e=Lh();return Vh=Bh()(function(t,n){return t==null?{}:e(t,n)}),Vh}var Wh,Gh;function Kh(){if(Gh)return Wh;Gh=1;var e=Math.ceil,t=Math.max;function n(n,r,i,a){for(var o=-1,s=t(e((r-n)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=n,n+=i;return c}return Wh=n,Wh}var qh,Jh;function Yh(){if(Jh)return qh;Jh=1;var e=Kh(),t=Qp(),n=gm();function r(r){return function(i,a,o){return o&&typeof o!=`number`&&t(i,a,o)&&(a=o=void 0),i=n(i),a===void 0?(a=i,i=0):a=n(a),o=o===void 0?i<a?1:-1:n(o),e(i,a,o,r)}}return qh=r,qh}var Xh,Zh;function Qh(){return Zh?Xh:(Zh=1,Xh=Yh()(),Xh)}var $h,eg;function tg(){if(eg)return $h;eg=1;function e(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}return $h=e,$h}var ng,rg;function ig(){if(rg)return ng;rg=1;var e=Al();function t(t,n){if(t!==n){var r=t!==void 0,i=t===null,a=t===t,o=e(t),s=n!==void 0,c=n===null,l=n===n,u=e(n);if(!c&&!u&&!o&&t>n||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&t<n||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}return ng=t,ng}var ag,og;function sg(){if(og)return ag;og=1;var e=ig();function t(t,n,r){for(var i=-1,a=t.criteria,o=n.criteria,s=a.length,c=r.length;++i<s;){var l=e(a[i],o[i]);if(l)return i>=c?l:l*(r[i]==`desc`?-1:1)}return t.index-n.index}return ag=t,ag}var cg,lg;function ug(){if(lg)return cg;lg=1;var e=Gl(),t=ou(),n=Y(),r=Xu(),i=tg(),a=ga(),o=sg(),s=vc(),c=K();function l(l,u,d){u=u.length?e(u,function(e){return c(e)?function(n){return t(n,e.length===1?e[0]:e)}:e}):[s];var f=-1;return u=e(u,a(n)),i(r(l,function(t,n,r){return{criteria:e(u,function(e){return e(t)}),index:++f,value:t}}),function(e,t){return o(e,t,d)})}return cg=l,cg}var dg,fg;function pg(){if(fg)return dg;fg=1;var e=Fd(),t=ug(),n=$d(),r=Qp();return dg=n(function(n,i){if(n==null)return[];var a=i.length;return a>1&&r(n,i[0],i[1])?i=[]:a>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),t(n,e(i,1),[])}),dg}var mg,hg;function gg(){if(hg)return mg;hg=1;var e=Zl(),t=0;function n(n){var r=++t;return e(n)+r}return mg=n,mg}var _g,vg;function yg(){if(vg)return _g;vg=1;function e(e,t,n){for(var r=-1,i=e.length,a=t.length,o={};++r<i;){var s=r<a?t[r]:void 0;n(o,e[r],s)}return o}return _g=e,_g}var bg,xg;function Sg(){if(xg)return bg;xg=1;var e=Ii(),t=yg();function n(n,r){return t(n||[],r||[],e)}return bg=n,bg}var Cg,wg;function Q(){if(wg)return Cg;wg=1;var e;if(typeof tn==`function`)try{e={cloneDeep:Yp(),constant:ec(),defaults:tm(),each:Dc(),filter:Fu(),find:Tm(),flatten:Om(),forEach:wc(),forIn:jm(),has:Vu(),isUndefined:qu(),last:Pm(),map:$u(),mapValues:Lm(),max:Km(),merge:gh(),min:Sh(),minBy:Th(),now:Oh(),pick:Uh(),range:Qh(),reduce:cd(),sortBy:pg(),uniqueId:gg(),values:zf(),zipObject:Sg()}}catch{}return e||=window._,Cg=e,Cg}var Tg,Eg;function Dg(){if(Eg)return Tg;Eg=1,Tg=e;function e(){var e={};e._next=e._prev=e,this._sentinel=e}e.prototype.dequeue=function(){var e=this._sentinel,n=e._prev;if(n!==e)return t(n),n},e.prototype.enqueue=function(e){var n=this._sentinel;e._prev&&e._next&&t(e),e._next=n._next,n._next._prev=e,n._next=e,e._prev=n},e.prototype.toString=function(){for(var e=[],t=this._sentinel,r=t._prev;r!==t;)e.push(JSON.stringify(r,n)),r=r._prev;return`[`+e.join(`, `)+`]`};function t(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n(e,t){if(e!==`_next`&&e!==`_prev`)return t}return Tg}var Og,kg;function Ag(){if(kg)return Og;kg=1;var e=Q(),t=Z().Graph,n=Dg();Og=i;var r=e.constant(1);function i(t,n){if(t.nodeCount()<=1)return[];var i=s(t,n||r),o=a(i.graph,i.buckets,i.zeroIdx);return e.flatten(e.map(o,function(e){return t.outEdges(e.v,e.w)}),!0)}function a(e,t,n){for(var r=[],i=t[t.length-1],a=t[0],s;e.nodeCount();){for(;s=a.dequeue();)o(e,t,n,s);for(;s=i.dequeue();)o(e,t,n,s);if(e.nodeCount()){for(var c=t.length-2;c>0;--c)if(s=t[c].dequeue(),s){r=r.concat(o(e,t,n,s,!0));break}}}return r}function o(t,n,r,i,a){var o=a?[]:void 0;return e.forEach(t.inEdges(i.v),function(e){var i=t.edge(e),s=t.node(e.v);a&&o.push({v:e.v,w:e.w}),s.out-=i,c(n,r,s)}),e.forEach(t.outEdges(i.v),function(e){var i=t.edge(e),a=e.w,o=t.node(a);o.in-=i,c(n,r,o)}),t.removeNode(i.v),o}function s(r,i){var a=new t,o=0,s=0;e.forEach(r.nodes(),function(e){a.setNode(e,{v:e,in:0,out:0})}),e.forEach(r.edges(),function(e){var t=a.edge(e.v,e.w)||0,n=i(e),r=t+n;a.setEdge(e.v,e.w,r),s=Math.max(s,a.node(e.v).out+=n),o=Math.max(o,a.node(e.w).in+=n)});var l=e.range(s+o+3).map(function(){return new n}),u=o+1;return e.forEach(a.nodes(),function(e){c(l,u,a.node(e))}),{graph:a,buckets:l,zeroIdx:u}}function c(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}return Og}var jg,Mg;function Ng(){if(Mg)return jg;Mg=1;var e=Q(),t=Ag();jg={run:n,undo:i};function n(n){var i=n.graph().acyclicer===`greedy`?t(n,a(n)):r(n);e.forEach(i,function(t){var r=n.edge(t);n.removeEdge(t),r.forwardName=t.name,r.reversed=!0,n.setEdge(t.w,t.v,r,e.uniqueId(`rev`))});function a(e){return function(t){return e.edge(t).weight}}}function r(t){var n=[],r={},i={};function a(o){e.has(i,o)||(i[o]=!0,r[o]=!0,e.forEach(t.outEdges(o),function(t){e.has(r,t.w)?n.push(t):a(t.w)}),delete r[o])}return e.forEach(t.nodes(),a),n}function i(t){e.forEach(t.edges(),function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}})}return jg}var Pg,Fg;function $(){if(Fg)return Pg;Fg=1;var e=Q(),t=Z().Graph;Pg={addDummyNode:n,simplify:r,asNonCompoundGraph:i,successorWeights:a,predecessorWeights:o,intersectRect:s,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:u,addBorderNode:d,maxRank:f,partition:p,time:m,notime:h};function n(t,n,r,i){var a;do a=e.uniqueId(i);while(t.hasNode(a));return r.dummy=n,t.setNode(a,r),a}function r(n){var r=new t().setGraph(n.graph());return e.forEach(n.nodes(),function(e){r.setNode(e,n.node(e))}),e.forEach(n.edges(),function(e){var t=r.edge(e.v,e.w)||{weight:0,minlen:1},i=n.edge(e);r.setEdge(e.v,e.w,{weight:t.weight+i.weight,minlen:Math.max(t.minlen,i.minlen)})}),r}function i(n){var r=new t({multigraph:n.isMultigraph()}).setGraph(n.graph());return e.forEach(n.nodes(),function(e){n.children(e).length||r.setNode(e,n.node(e))}),e.forEach(n.edges(),function(e){r.setEdge(e,n.edge(e))}),r}function a(t){var n=e.map(t.nodes(),function(n){var r={};return e.forEach(t.outEdges(n),function(e){r[e.w]=(r[e.w]||0)+t.edge(e).weight}),r});return e.zipObject(t.nodes(),n)}function o(t){var n=e.map(t.nodes(),function(n){var r={};return e.forEach(t.inEdges(n),function(e){r[e.v]=(r[e.v]||0)+t.edge(e).weight}),r});return e.zipObject(t.nodes(),n)}function s(e,t){var n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);var c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function c(t){var n=e.map(e.range(f(t)+1),function(){return[]});return e.forEach(t.nodes(),function(r){var i=t.node(r),a=i.rank;e.isUndefined(a)||(n[a][i.order]=r)}),n}function l(t){var n=e.min(e.map(t.nodes(),function(e){return t.node(e).rank}));e.forEach(t.nodes(),function(r){var i=t.node(r);e.has(i,`rank`)&&(i.rank-=n)})}function u(t){var n=e.min(e.map(t.nodes(),function(e){return t.node(e).rank})),r=[];e.forEach(t.nodes(),function(e){var i=t.node(e).rank-n;r[i]||(r[i]=[]),r[i].push(e)});var i=0,a=t.graph().nodeRankFactor;e.forEach(r,function(n,r){e.isUndefined(n)&&r%a!==0?--i:i&&e.forEach(n,function(e){t.node(e).rank+=i})})}function d(e,t,r,i){var a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=i),n(e,`border`,a,t)}function f(t){return e.max(e.map(t.nodes(),function(n){var r=t.node(n).rank;if(!e.isUndefined(r))return r}))}function p(t,n){var r={lhs:[],rhs:[]};return e.forEach(t,function(e){n(e)?r.lhs.push(e):r.rhs.push(e)}),r}function m(t,n){var r=e.now();try{return n()}finally{console.log(t+` time: `+(e.now()-r)+`ms`)}}function h(e,t){return t()}return Pg}var Ig,Lg;function Rg(){if(Lg)return Ig;Lg=1;var e=Q(),t=$();Ig={run:n,undo:i};function n(t){t.graph().dummyChains=[],e.forEach(t.edges(),function(e){r(t,e)})}function r(e,n){var r=n.v,i=e.node(r).rank,a=n.w,o=e.node(a).rank,s=n.name,c=e.edge(n),l=c.labelRank;if(o!==i+1){e.removeEdge(n);var u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:n,rank:i},u=t.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(r,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),r=u;e.setEdge(r,a,{weight:c.weight},s)}}function i(t){e.forEach(t.graph().dummyChains,function(e){var n=t.node(e),r=n.edgeLabel,i;for(t.setEdge(n.edgeObj,r);n.dummy;)i=t.successors(e)[0],t.removeNode(e),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),e=i,n=t.node(e)})}return Ig}var zg,Bg;function Vg(){if(Bg)return zg;Bg=1;var e=Q();zg={longestPath:t,slack:n};function t(t){var n={};function r(i){var a=t.node(i);if(e.has(n,i))return a.rank;n[i]=!0;var o=e.min(e.map(t.outEdges(i),function(e){return r(e.w)-t.edge(e).minlen}));return(o===1/0||o==null)&&(o=0),a.rank=o}e.forEach(t.sources(),r)}function n(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}return zg}var Hg,Ug;function Wg(){if(Ug)return Hg;Ug=1;var e=Q(),t=Z().Graph,n=Vg().slack;Hg=r;function r(e){var r=new t({directed:!1}),s=e.nodes()[0],c=e.nodeCount();r.setNode(s,{});for(var l,u;i(r,e)<c;)l=a(r,e),u=r.hasNode(l.v)?n(e,l):-n(e,l),o(r,e,u);return r}function i(t,r){function i(a){e.forEach(r.nodeEdges(a),function(e){var o=e.v,s=a===o?e.w:o;!t.hasNode(s)&&!n(r,e)&&(t.setNode(s,{}),t.setEdge(a,s,{}),i(s))})}return e.forEach(t.nodes(),i),t.nodeCount()}function a(t,r){return e.minBy(r.edges(),function(e){if(t.hasNode(e.v)!==t.hasNode(e.w))return n(r,e)})}function o(t,n,r){e.forEach(t.nodes(),function(e){n.node(e).rank+=r})}return Hg}var Gg,Kg;function qg(){if(Kg)return Gg;Kg=1;var e=Q(),t=Wg(),n=Vg().slack,r=Vg().longestPath,i=Z().alg.preorder,a=Z().alg.postorder,o=$().simplify;Gg=s,s.initLowLimValues=d,s.initCutValues=c,s.calcCutValue=u,s.leaveEdge=p,s.enterEdge=m,s.exchangeEdges=h;function s(e){e=o(e),r(e);var n=t(e);d(n),c(n,e);for(var i,a;i=p(n);)a=m(n,e,i),h(n,e,i,a)}function c(t,n){var r=a(t,t.nodes());r=r.slice(0,r.length-1),e.forEach(r,function(e){l(t,n,e)})}function l(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=u(e,t,n)}function u(t,n,r){var i=t.node(r).parent,a=!0,o=n.edge(r,i),s=0;return o||=(a=!1,n.edge(i,r)),s=o.weight,e.forEach(n.nodeEdges(r),function(e){var o=e.v===r,c=o?e.w:e.v;if(c!==i){var l=o===a,u=n.edge(e).weight;if(s+=l?u:-u,_(t,r,c)){var d=t.edge(r,c).cutvalue;s+=l?-d:d}}}),s}function d(e,t){arguments.length<2&&(t=e.nodes()[0]),f(e,{},1,t)}function f(t,n,r,i,a){var o=r,s=t.node(i);return n[i]=!0,e.forEach(t.neighbors(i),function(a){e.has(n,a)||(r=f(t,n,r,a,i))}),s.low=o,s.lim=r++,a?s.parent=a:delete s.parent,r}function p(t){return e.find(t.edges(),function(e){return t.edge(e).cutvalue<0})}function m(t,r,i){var a=i.v,o=i.w;r.hasEdge(a,o)||(a=i.w,o=i.v);var s=t.node(a),c=t.node(o),l=s,u=!1;s.lim>c.lim&&(l=c,u=!0);var d=e.filter(r.edges(),function(e){return u===v(t,t.node(e.v),l)&&u!==v(t,t.node(e.w),l)});return e.minBy(d,function(e){return n(r,e)})}function h(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),d(e),c(e,t),g(e,t)}function g(t,n){var r=i(t,e.find(t.nodes(),function(e){return!n.node(e).parent}));r=r.slice(1),e.forEach(r,function(e){var r=t.node(e).parent,i=n.edge(e,r),a=!1;i||(i=n.edge(r,e),a=!0),n.node(e).rank=n.node(r).rank+(a?i.minlen:-i.minlen)})}function _(e,t,n){return e.hasEdge(t,n)}function v(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}return Gg}var Jg,Yg;function Xg(){if(Yg)return Jg;Yg=1;var e=Vg().longestPath,t=Wg(),n=qg();Jg=r;function r(e){switch(e.graph().ranker){case`network-simplex`:o(e);break;case`tight-tree`:a(e);break;case`longest-path`:i(e);break;default:o(e)}}var i=e;function a(n){e(n),t(n)}function o(e){n(e)}return Jg}var Zg,Qg;function $g(){if(Qg)return Zg;Qg=1;var e=Q();Zg=t;function t(t){var i=r(t);e.forEach(t.graph().dummyChains,function(e){for(var r=t.node(e),a=r.edgeObj,o=n(t,i,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;e!==a.w;){if(r=t.node(e),d){for(;(u=s[l])!==c&&t.node(u).maxRank<r.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&t.node(u=s[l+1]).minRank<=r.rank;)l++;u=s[l]}t.setParent(e,u),e=t.successors(e)[0]}})}function n(e,t,n,r){var i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c=n,l;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function r(t){var n={},r=0;function i(a){var o=r;e.forEach(t.children(a),i),n[a]={low:o,lim:r++}}return e.forEach(t.children(),i),n}return Zg}var e_,t_;function n_(){if(t_)return e_;t_=1;var e=Q(),t=$();e_={run:n,cleanup:o};function n(n){var o=t.addDummyNode(n,`root`,{},`_root`),s=i(n),c=e.max(e.values(s))-1,l=2*c+1;n.graph().nestingRoot=o,e.forEach(n.edges(),function(e){n.edge(e).minlen*=l});var u=a(n)+1;e.forEach(n.children(),function(e){r(n,o,l,u,c,s,e)}),n.graph().nodeRankFactor=l}function r(n,i,a,o,s,c,l){var u=n.children(l);if(!u.length){l!==i&&n.setEdge(i,l,{weight:0,minlen:a});return}var d=t.addBorderNode(n,`_bt`),f=t.addBorderNode(n,`_bb`),p=n.node(l);n.setParent(d,l),p.borderTop=d,n.setParent(f,l),p.borderBottom=f,e.forEach(u,function(e){r(n,i,a,o,s,c,e);var t=n.node(e),u=t.borderTop?t.borderTop:e,p=t.borderBottom?t.borderBottom:e,m=t.borderTop?o:2*o,h=u===p?s-c[l]+1:1;n.setEdge(d,u,{weight:m,minlen:h,nestingEdge:!0}),n.setEdge(p,f,{weight:m,minlen:h,nestingEdge:!0})}),n.parent(l)||n.setEdge(i,d,{weight:0,minlen:s+c[l]})}function i(t){var n={};function r(i,a){var o=t.children(i);o&&o.length&&e.forEach(o,function(e){r(e,a+1)}),n[i]=a}return e.forEach(t.children(),function(e){r(e,1)}),n}function a(t){return e.reduce(t.edges(),function(e,n){return e+t.edge(n).weight},0)}function o(t){var n=t.graph();t.removeNode(n.nestingRoot),delete n.nestingRoot,e.forEach(t.edges(),function(e){t.edge(e).nestingEdge&&t.removeEdge(e)})}return e_}var r_,i_;function a_(){if(i_)return r_;i_=1;var e=Q(),t=$();r_=n;function n(t){function n(i){var a=t.children(i),o=t.node(i);if(a.length&&e.forEach(a,n),e.has(o,`minRank`)){o.borderLeft=[],o.borderRight=[];for(var s=o.minRank,c=o.maxRank+1;s<c;++s)r(t,`borderLeft`,`_bl`,i,o,s),r(t,`borderRight`,`_br`,i,o,s)}}e.forEach(t.children(),n)}function r(e,n,r,i,a,o){var s={width:0,height:0,rank:o,borderType:n},c=a[n][o-1],l=t.addDummyNode(e,`border`,s,r);a[n][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}return r_}var o_,s_;function c_(){if(s_)return o_;s_=1;var e=Q();o_={adjust:t,undo:n};function t(e){var t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&r(e)}function n(e){var t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&a(e),(t===`lr`||t===`rl`)&&(s(e),r(e))}function r(t){e.forEach(t.nodes(),function(e){i(t.node(e))}),e.forEach(t.edges(),function(e){i(t.edge(e))})}function i(e){var t=e.width;e.width=e.height,e.height=t}function a(t){e.forEach(t.nodes(),function(e){o(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.forEach(r.points,o),e.has(r,`y`)&&o(r)})}function o(e){e.y=-e.y}function s(t){e.forEach(t.nodes(),function(e){c(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.forEach(r.points,c),e.has(r,`x`)&&c(r)})}function c(e){var t=e.x;e.x=e.y,e.y=t}return o_}var l_,u_;function d_(){if(u_)return l_;u_=1;var e=Q();l_=t;function t(t){var n={},r=e.filter(t.nodes(),function(e){return!t.children(e).length}),i=e.max(e.map(r,function(e){return t.node(e).rank})),a=e.map(e.range(i+1),function(){return[]});function o(r){e.has(n,r)||(n[r]=!0,a[t.node(r).rank].push(r),e.forEach(t.successors(r),o))}var s=e.sortBy(r,function(e){return t.node(e).rank});return e.forEach(s,o),a}return l_}var f_,p_;function m_(){if(p_)return f_;p_=1;var e=Q();f_=t;function t(e,t){for(var r=0,i=1;i<t.length;++i)r+=n(e,t[i-1],t[i]);return r}function n(t,n,r){for(var i=e.zipObject(r,e.map(r,function(e,t){return t})),a=e.flatten(e.map(n,function(n){return e.sortBy(e.map(t.outEdges(n),function(e){return{pos:i[e.w],weight:t.edge(e).weight}}),`pos`)}),!0),o=1;o<r.length;)o<<=1;var s=2*o-1;--o;var c=e.map(Array(s),function(){return 0}),l=0;return e.forEach(a.forEach(function(e){var t=e.pos+o;c[t]+=e.weight;for(var n=0;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n})),l}return f_}var h_,g_;function __(){if(g_)return h_;g_=1;var e=Q();h_=t;function t(t,n){return e.map(n,function(n){var r=t.inEdges(n);if(r.length){var i=e.reduce(r,function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}return{v:n}})}return h_}var v_,y_;function b_(){if(y_)return v_;y_=1;var e=Q();v_=t;function t(t,r){var i={};return e.forEach(t,function(t,n){var r=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:n};e.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)}),e.forEach(r.edges(),function(t){var n=i[t.v],r=i[t.w];!e.isUndefined(n)&&!e.isUndefined(r)&&(r.indegree++,n.out.push(i[t.w]))}),n(e.filter(i,function(e){return!e.indegree}))}function n(t){var n=[];function i(t){return function(n){n.merged||(e.isUndefined(n.barycenter)||e.isUndefined(t.barycenter)||n.barycenter>=t.barycenter)&&r(t,n)}}function a(e){return function(n){n.in.push(e),--n.indegree===0&&t.push(n)}}for(;t.length;){var o=t.pop();n.push(o),e.forEach(o.in.reverse(),i(o)),e.forEach(o.out,a(o))}return e.map(e.filter(n,function(e){return!e.merged}),function(t){return e.pick(t,[`vs`,`i`,`barycenter`,`weight`])})}function r(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}return v_}var x_,S_;function C_(){if(S_)return x_;S_=1;var e=Q(),t=$();x_=n;function n(n,a){var o=t.partition(n,function(t){return e.has(t,`barycenter`)}),s=o.lhs,c=e.sortBy(o.rhs,function(e){return-e.i}),l=[],u=0,d=0,f=0;s.sort(i(!!a)),f=r(l,c,f),e.forEach(s,function(e){f+=e.vs.length,l.push(e.vs),u+=e.barycenter*e.weight,d+=e.weight,f=r(l,c,f)});var p={vs:e.flatten(l,!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function r(t,n,r){for(var i;n.length&&(i=e.last(n)).i<=r;)n.pop(),t.push(i.vs),r++;return r}function i(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}return x_}var w_,T_;function E_(){if(T_)return w_;T_=1;var e=Q(),t=__(),n=b_(),r=C_();w_=i;function i(s,c,l,u){var d=s.children(c),f=s.node(c),p=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,h={};p&&(d=e.filter(d,function(e){return e!==p&&e!==m}));var g=t(s,d);e.forEach(g,function(t){if(s.children(t.v).length){var n=i(s,t.v,l,u);h[t.v]=n,e.has(n,`barycenter`)&&o(t,n)}});var _=n(g,l);a(_,h);var v=r(_,u);if(p&&(v.vs=e.flatten([p,v.vs,m],!0),s.predecessors(p).length)){var y=s.node(s.predecessors(p)[0]),b=s.node(s.predecessors(m)[0]);e.has(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.order+b.order)/(v.weight+2),v.weight+=2}return v}function a(t,n){e.forEach(t,function(t){t.vs=e.flatten(t.vs.map(function(e){return n[e]?n[e].vs:e}),!0)})}function o(t,n){e.isUndefined(t.barycenter)?(t.barycenter=n.barycenter,t.weight=n.weight):(t.barycenter=(t.barycenter*t.weight+n.barycenter*n.weight)/(t.weight+n.weight),t.weight+=n.weight)}return w_}var D_,O_;function k_(){if(O_)return D_;O_=1;var e=Q(),t=Z().Graph;D_=n;function n(n,i,a){var o=r(n),s=new t({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(e){return n.node(e)});return e.forEach(n.nodes(),function(t){var r=n.node(t),c=n.parent(t);(r.rank===i||r.minRank<=i&&i<=r.maxRank)&&(s.setNode(t),s.setParent(t,c||o),e.forEach(n[a](t),function(r){var i=r.v===t?r.w:r.v,a=s.edge(i,t),o=e.isUndefined(a)?0:a.weight;s.setEdge(i,t,{weight:n.edge(r).weight+o})}),e.has(r,`minRank`)&&s.setNode(t,{borderLeft:r.borderLeft[i],borderRight:r.borderRight[i]}))}),s}function r(t){for(var n;t.hasNode(n=e.uniqueId(`_root`)););return n}return D_}var A_,j_;function M_(){if(j_)return A_;j_=1;var e=Q();A_=t;function t(t,n,r){var i={},a;e.forEach(r,function(e){for(var r=t.parent(e),o,s;r;){if(o=t.parent(r),o?(s=i[o],i[o]=r):(s=a,a=r),s&&s!==r){n.setEdge(s,r);return}r=o}})}return A_}var N_,P_;function F_(){if(P_)return N_;P_=1;var e=Q(),t=d_(),n=m_(),r=E_(),i=k_(),a=M_(),o=Z().Graph,s=$();N_=c;function c(r){var i=s.maxRank(r),a=l(r,e.range(1,i+1),`inEdges`),o=l(r,e.range(i-1,-1,-1),`outEdges`),c=t(r);d(r,c);for(var f=1/0,p,m=0,h=0;h<4;++m,++h){u(m%2?a:o,m%4>=2),c=s.buildLayerMatrix(r);var g=n(r,c);g<f&&(h=0,p=e.cloneDeep(c),f=g)}d(r,p)}function l(t,n,r){return e.map(n,function(e){return i(t,e,r)})}function u(t,n){var i=new o;e.forEach(t,function(t){var o=t.graph().root,s=r(t,o,i,n);e.forEach(s.vs,function(e,n){t.node(e).order=n}),a(t,i,s.vs)})}function d(t,n){e.forEach(n,function(n){e.forEach(n,function(e,n){t.node(e).order=n})})}return N_}var I_,L_;function R_(){if(L_)return I_;L_=1;var e=Q(),t=Z().Graph,n=$();I_={positionX:m,findType1Conflicts:r,findType2Conflicts:i,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function r(t,n){var r={};function i(n,i){var s=0,c=0,l=n.length,u=e.last(i);return e.forEach(i,function(n,d){var f=a(t,n),p=f?t.node(f).order:l;(f||n===u)&&(e.forEach(i.slice(c,d+1),function(n){e.forEach(t.predecessors(n),function(e){var i=t.node(e),a=i.order;(a<s||p<a)&&!(i.dummy&&t.node(n).dummy)&&o(r,e,n)})}),c=d+1,s=p)}),i}return e.reduce(n,i),r}function i(t,n){var r={};function i(n,i,a,s,c){var l;e.forEach(e.range(i,a),function(i){l=n[i],t.node(l).dummy&&e.forEach(t.predecessors(l),function(e){var n=t.node(e);n.dummy&&(n.order<s||n.order>c)&&o(r,e,l)})})}function a(n,r){var a=-1,o,s=0;return e.forEach(r,function(e,c){if(t.node(e).dummy===`border`){var l=t.predecessors(e);l.length&&(o=t.node(l[0]).order,i(r,s,c,a,o),s=c,a=o)}i(r,s,r.length,o,n.length)}),r}return e.reduce(n,a),r}function a(t,n){if(t.node(n).dummy)return e.find(t.predecessors(n),function(e){return t.node(e).dummy})}function o(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function s(t,n,r){if(n>r){var i=n;n=r,r=i}return e.has(t[n],r)}function c(t,n,r,i){var a={},o={},c={};return e.forEach(n,function(t){e.forEach(t,function(e,t){a[e]=e,o[e]=e,c[e]=t})}),e.forEach(n,function(t){var n=-1;e.forEach(t,function(t){var l=i(t);if(l.length){l=e.sortBy(l,function(e){return c[e]});for(var u=(l.length-1)/2,d=Math.floor(u),f=Math.ceil(u);d<=f;++d){var p=l[d];o[t]===t&&n<c[p]&&!s(r,t,p)&&(o[p]=t,o[t]=a[t]=a[p],n=c[p])}}})}),{root:a,align:o}}function l(t,n,r,i,a){var o={},s=u(t,n,r,a),c=a?`borderLeft`:`borderRight`;function l(e,t){for(var n=s.nodes(),r=n.pop(),i={};r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function d(e){o[e]=s.inEdges(e).reduce(function(e,t){return Math.max(e,o[t.v]+s.edge(t))},0)}function f(e){var n=s.outEdges(e).reduce(function(e,t){return Math.min(e,o[t.w]-s.edge(t))},1/0),r=t.node(e);n!==1/0&&r.borderType!==c&&(o[e]=Math.max(o[e],n))}return l(d,s.predecessors.bind(s)),l(f,s.successors.bind(s)),e.forEach(i,function(e){o[e]=o[r[e]]}),o}function u(n,r,i,a){var o=new t,s=n.graph(),c=h(s.nodesep,s.edgesep,a);return e.forEach(r,function(t){var r;e.forEach(t,function(e){var t=i[e];if(o.setNode(t),r){var a=i[r],s=o.edge(a,t);o.setEdge(a,t,Math.max(c(n,e,r),s||0))}r=e})}),o}function d(t,n){return e.minBy(e.values(n),function(n){var r=-1/0,i=1/0;return e.forIn(n,function(e,n){var a=g(t,n)/2;r=Math.max(e+a,r),i=Math.min(e-a,i)}),r-i})}function f(t,n){var r=e.values(n),i=e.min(r),a=e.max(r);e.forEach([`u`,`d`],function(r){e.forEach([`l`,`r`],function(o){var s=r+o,c=t[s],l;if(c!==n){var u=e.values(c);l=o===`l`?i-e.min(u):a-e.max(u),l&&(t[s]=e.mapValues(c,function(e){return e+l}))}})})}function p(t,n){return e.mapValues(t.ul,function(r,i){if(n)return t[n.toLowerCase()][i];var a=e.sortBy(e.map(t,i));return(a[1]+a[2])/2})}function m(t){var a=n.buildLayerMatrix(t),o=e.merge(r(t,a),i(t,a)),s={},u;return e.forEach([`u`,`d`],function(n){u=n===`u`?a:e.values(a).reverse(),e.forEach([`l`,`r`],function(r){r===`r`&&(u=e.map(u,function(t){return e.values(t).reverse()}));var i=(n===`u`?t.predecessors:t.successors).bind(t),a=c(t,u,o,i),d=l(t,u,a.root,a.align,r===`r`);r===`r`&&(d=e.mapValues(d,function(e){return-e})),s[n+r]=d})}),f(s,d(t,s)),p(s,t.graph().align)}function h(t,n,r){return function(i,a,o){var s=i.node(a),c=i.node(o),l=0,u;if(l+=s.width/2,e.has(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:u=-s.width/2;break;case`r`:u=s.width/2}if(u&&(l+=r?u:-u),u=0,l+=(s.dummy?n:t)/2,l+=(c.dummy?n:t)/2,l+=c.width/2,e.has(c,`labelpos`))switch(c.labelpos.toLowerCase()){case`l`:u=c.width/2;break;case`r`:u=-c.width/2}return u&&(l+=r?u:-u),u=0,l}}function g(e,t){return e.node(t).width}return I_}var z_,B_;function V_(){if(B_)return z_;B_=1;var e=Q(),t=$(),n=R_().positionX;z_=r;function r(r){r=t.asNonCompoundGraph(r),i(r),e.forEach(n(r),function(e,t){r.node(t).x=e})}function i(n){var r=t.buildLayerMatrix(n),i=n.graph().ranksep,a=0;e.forEach(r,function(t){var r=e.max(e.map(t,function(e){return n.node(e).height}));e.forEach(t,function(e){n.node(e).y=a+r/2}),a+=r+i})}return z_}var H_,U_;function W_(){if(U_)return H_;U_=1;var e=Q(),t=Ng(),n=Rg(),r=Xg(),i=$().normalizeRanks,a=$g(),o=$().removeEmptyRanks,s=n_(),c=a_(),l=c_(),u=F_(),d=V_(),f=$(),p=Z().Graph;H_=m;function m(e,t){var n=t&&t.debugTiming?f.time:f.notime;n(`layout`,function(){var t=n(` buildLayoutGraph`,function(){return T(e)});n(` runLayout`,function(){h(t,n)}),n(` updateInputGraph`,function(){g(e,t)})})}function h(e,p){p(` makeSpaceForEdgeLabels`,function(){E(e)}),p(` removeSelfEdges`,function(){N(e)}),p(` acyclic`,function(){t.run(e)}),p(` nestingGraph.run`,function(){s.run(e)}),p(` rank`,function(){r(f.asNonCompoundGraph(e))}),p(` injectEdgeLabelProxies`,function(){D(e)}),p(` removeEmptyRanks`,function(){o(e)}),p(` nestingGraph.cleanup`,function(){s.cleanup(e)}),p(` normalizeRanks`,function(){i(e)}),p(` assignRankMinMax`,function(){O(e)}),p(` removeEdgeLabelProxies`,function(){k(e)}),p(` normalize.run`,function(){n.run(e)}),p(` parentDummyChains`,function(){a(e)}),p(` addBorderSegments`,function(){c(e)}),p(` order`,function(){u(e)}),p(` insertSelfEdges`,function(){P(e)}),p(` adjustCoordinateSystem`,function(){l.adjust(e)}),p(` position`,function(){d(e)}),p(` positionSelfEdges`,function(){F(e)}),p(` removeBorderNodes`,function(){te(e)}),p(` normalize.undo`,function(){n.undo(e)}),p(` fixupEdgeLabelCoords`,function(){j(e)}),p(` undoCoordinateSystem`,function(){l.undo(e)}),p(` translateGraph`,function(){A(e)}),p(` assignNodeIntersects`,function(){ee(e)}),p(` reversePoints`,function(){M(e)}),p(` acyclic.undo`,function(){t.undo(e)})}function g(t,n){e.forEach(t.nodes(),function(e){var r=t.node(e),i=n.node(e);r&&(r.x=i.x,r.y=i.y,n.children(e).length&&(r.width=i.width,r.height=i.height))}),e.forEach(t.edges(),function(r){var i=t.edge(r),a=n.edge(r);i.points=a.points,e.has(a,`x`)&&(i.x=a.x,i.y=a.y)}),t.graph().width=n.graph().width,t.graph().height=n.graph().height}var _=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],v={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},y=[`acyclicer`,`ranker`,`rankdir`,`align`],b=[`width`,`height`],x={width:0,height:0},S=[`minlen`,`weight`,`width`,`height`,`labeloffset`],C={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},w=[`labelpos`];function T(t){var n=new p({multigraph:!0,compound:!0}),r=ne(t.graph());return n.setGraph(e.merge({},v,I(r,_),e.pick(r,y))),e.forEach(t.nodes(),function(r){var i=ne(t.node(r));n.setNode(r,e.defaults(I(i,b),x)),n.setParent(r,t.parent(r))}),e.forEach(t.edges(),function(r){var i=ne(t.edge(r));n.setEdge(r,e.merge({},C,I(i,S),e.pick(i,w)))}),n}function E(t){var n=t.graph();n.ranksep/=2,e.forEach(t.edges(),function(e){var r=t.edge(e);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(n.rankdir===`TB`||n.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function D(t){e.forEach(t.edges(),function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e};f.addDummyNode(t,`edge-proxy`,i,`_ep`)}})}function O(t){var n=0;e.forEach(t.nodes(),function(r){var i=t.node(r);i.borderTop&&(i.minRank=t.node(i.borderTop).rank,i.maxRank=t.node(i.borderBottom).rank,n=e.max(n,i.maxRank))}),t.graph().maxRank=n}function k(t){e.forEach(t.nodes(),function(e){var n=t.node(e);n.dummy===`edge-proxy`&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))})}function A(t){var n=1/0,r=0,i=1/0,a=0,o=t.graph(),s=o.marginx||0,c=o.marginy||0;function l(e){var t=e.x,o=e.y,s=e.width,c=e.height;n=Math.min(n,t-s/2),r=Math.max(r,t+s/2),i=Math.min(i,o-c/2),a=Math.max(a,o+c/2)}e.forEach(t.nodes(),function(e){l(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.has(r,`x`)&&l(r)}),n-=s,i-=c,e.forEach(t.nodes(),function(e){var r=t.node(e);r.x-=n,r.y-=i}),e.forEach(t.edges(),function(r){var a=t.edge(r);e.forEach(a.points,function(e){e.x-=n,e.y-=i}),e.has(a,`x`)&&(a.x-=n),e.has(a,`y`)&&(a.y-=i)}),o.width=r-n+s,o.height=a-i+c}function ee(t){e.forEach(t.edges(),function(e){var n=t.edge(e),r=t.node(e.v),i=t.node(e.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(f.intersectRect(r,a)),n.points.push(f.intersectRect(i,o))})}function j(t){e.forEach(t.edges(),function(n){var r=t.edge(n);if(e.has(r,`x`))switch((r.labelpos===`l`||r.labelpos===`r`)&&(r.width-=r.labeloffset),r.labelpos){case`l`:r.x-=r.width/2+r.labeloffset;break;case`r`:r.x+=r.width/2+r.labeloffset}})}function M(t){e.forEach(t.edges(),function(e){var n=t.edge(e);n.reversed&&n.points.reverse()})}function te(t){e.forEach(t.nodes(),function(n){if(t.children(n).length){var r=t.node(n),i=t.node(r.borderTop),a=t.node(r.borderBottom),o=t.node(e.last(r.borderLeft)),s=t.node(e.last(r.borderRight));r.width=Math.abs(s.x-o.x),r.height=Math.abs(a.y-i.y),r.x=o.x+r.width/2,r.y=i.y+r.height/2}}),e.forEach(t.nodes(),function(e){t.node(e).dummy===`border`&&t.removeNode(e)})}function N(t){e.forEach(t.edges(),function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||=[],n.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e)}})}function P(t){var n=f.buildLayerMatrix(t);e.forEach(n,function(n){var r=0;e.forEach(n,function(n,i){var a=t.node(n);a.order=i+r,e.forEach(a.selfEdges,function(e){f.addDummyNode(t,`selfedge`,{width:e.label.width,height:e.label.height,rank:a.rank,order:i+ ++r,e:e.e,label:e.label},`_se`)}),delete a.selfEdges})})}function F(t){e.forEach(t.nodes(),function(e){var n=t.node(e);if(n.dummy===`selfedge`){var r=t.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function I(t,n){return e.mapValues(e.pick(t,n),Number)}function ne(t){var n={};return e.forEach(t,function(e,t){n[t.toLowerCase()]=e}),n}return H_}var G_,K_;function q_(){if(K_)return G_;K_=1;var e=Q(),t=$(),n=Z().Graph;G_={debugOrdering:r};function r(r){var i=t.buildLayerMatrix(r),a=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(r.nodes(),function(e){a.setNode(e,{label:e}),a.setParent(e,`layer`+r.node(e).rank)}),e.forEach(r.edges(),function(e){a.setEdge(e.v,e.w,{},e.name)}),e.forEach(i,function(t,n){var r=`layer`+n;a.setNode(r,{rank:`same`}),e.reduce(t,function(e,t){return a.setEdge(e,t,{style:`invis`}),t})}),a}return G_}var J_,Y_;function X_(){return Y_?J_:(Y_=1,J_=`0.8.5`,J_)}var Z_,Q_;function $_(){return Q_?Z_:(Q_=1,Z_={graphlib:Z(),layout:W_(),debug:q_(),util:{time:$().time,notime:$().notime},version:X_()},Z_)}var ev=$_(),tv=en(ev),nv=function(e){return Zt(e,`Boolean`)};function rv(e,t){if(e){var n;if(qt(e))for(var r=0,i=e.length;r<i&&(n=t(e[r],r),n!==!1);r++);else if(Jt(e)){for(var a in e)if(e.hasOwnProperty(a)&&(n=t(e[a],a),n===!1))break}}}var iv=Object.prototype.hasOwnProperty,av=(function(e,t){if(e===null||!Qt(e))return{};var n={};return rv(t,function(t){iv.call(e,t)&&(n[t]=e[t])}),n}),ov=class extends Kt{constructor(){super(...arguments),this.id=`dagre`,this.isCompoundGraph=null,this.config={graphAttributes:[`rankdir`,`align`,`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`,`acyclicer`,`ranker`],nodeAttributes:[`width`,`height`],edgeAttributes:[`minlen`,`weight`,`width`,`height`,`labelpos`,`labeloffset`]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:`TB`,align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:`network-simplex`,nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:`r`,edgeLabelOffset:10}}layout(){return Fe(this,void 0,void 0,function*(){let e=new ev.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});e.setGraph(av(this.options,this.config.graphAttributes)),e.setDefaultEdgeLabel(()=>({}));let t=lt(this.options.nodeSize,0);this.model.forEachNode(n=>{let r=n._original,[i,a]=rt(t(r)),o={width:i,height:a};if(e.setNode(String(n.id),o),this.isCompound()){if(H(n.parentId))return;e.setParent(String(n.id),String(n.parentId))}});let{edgeLabelSize:n,edgeLabelOffset:r,edgeLabelPos:i,edgeMinLen:a,edgeWeight:o}=this.options,s=lt(n,0,`edge`),c=ct(r,10,`edge`),l=typeof i==`string`?()=>i:st(i,[`edge`]),u=ct(a,1,`edge`),d=ct(o,1,`edge`);this.model.forEachEdge(t=>{let n=t._original,[r,i]=rt(s(n)),a={width:r,height:i,labelpos:l(n),labeloffset:c(n),minlen:u(n),weight:d(n)};e.setEdge(String(t.source),String(t.target),a,String(t.id))}),tv.layout(e),this.model.forEachNode(t=>{let n=e.node(String(t.id));n&&(t.x=n.x,t.y=n.y,t.size=[n.width,n.height])}),this.model.forEachEdge(t=>{let n=e.edge(String(t.source),String(t.target),String(t.id));if(!n)return;let{width:r,height:i,weight:a,minlen:o,labelpos:s,labeloffset:c,points:l}=n;t.labelSize=[r,i],t.weight=a,t.minLen=o,t.labelPos=s,t.labelOffset=c,t.points=l.map(ut)})})}isCompound(){return this.isCompoundGraph===null?nv(this.options.compound)?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(e=>!H(e.parentId)),this.isCompoundGraph):this.isCompoundGraph}},sv=26,cv=72,lv=24,uv=28,dv=16,fv=8,pv=20,mv=24,hv=12,gv=22,_v=52,vv=24,yv=3,bv=(e,t,n)=>{let r=(e,t)=>{let n=Array.from(new Set(e)).sort((e,t)=>e-t),r=[];for(let e of n)(r.length===0||e-r[r.length-1]>t)&&r.push(e);return r},i=r(e.map(e=>t.get(e.id)),sv),a=r(e.map(e=>n.get(e.id)),cv),o=(e,t)=>{let n=0;for(let r=1;r<e.length;r++)Math.abs(e[r]-t)<Math.abs(e[n]-t)&&(n=r);return n},s=new Map,c=new Map;for(let n of e)s.set(n.id,o(i,t.get(n.id)));for(;;){for(let t of e)c.set(t.id,o(a,n.get(t.id)));let t=new Map,r;for(let i of e){let e=`${s.get(i.id)}:${c.get(i.id)}`,o=t.get(e);if(o===void 0){t.set(e,i);continue}let l=a[c.get(i.id)];r=Math.abs(n.get(i.id)-l)>Math.abs(n.get(o.id)-l)?n.get(i.id):n.get(o.id);break}if(r===void 0)break;a.push(r),a.sort((e,t)=>e-t)}return{col:s,row:c,ncols:i.length,nrows:a.length}},xv=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)},Sv=(e,t,n,r)=>{let i=new Set;for(let t of e)i.add(`${n.get(t.id)}:${r.get(t.id)}`);let a=new Map;for(let e of t)e.source!==e.target&&(xv(a,e.source,e.target),xv(a,e.target,e.source));for(let t of e){let e=a.get(t.id);if(e===void 0)continue;let o=e.map(e=>r.get(e)).sort((e,t)=>e-t),s=o[Math.floor((o.length-1)/2)],c=r.get(t.id),l=Math.abs(s-c);if(l===0)continue;let u=Math.sign(s-c),d;if(l===1){if(!e.some(e=>r.get(e)===s&&Math.abs(n.get(e)-n.get(t.id))===1))continue;d=s}else d=c+u*Math.ceil(l/2);for(let e=d;e!==c;e-=u)if(!i.has(`${n.get(t.id)}:${e}`)){i.delete(`${n.get(t.id)}:${c}`),i.add(`${n.get(t.id)}:${e}`),r.set(t.id,e);break}}},Cv=(e,t,n,r)=>{let i=new Set;for(let t of e)i.add(`${n.get(t.id)}:${r.get(t.id)}`);let a=new Set;for(let e of t)a.add(e.source),a.add(e.target);let o=e.filter(e=>!a.has(e.id)).sort((e,t)=>r.get(e.id)-r.get(t.id));for(let e of o){let t=n.get(e.id);for(let n=0;n<r.get(e.id);n++)if(!i.has(`${t}:${n}`)){i.delete(`${t}:${r.get(e.id)}`),i.add(`${t}:${n}`),r.set(e.id,n);break}}let s=new Map;for(let t of e)xv(s,r.get(t.id),t);let c=Math.max(...s.keys()),l=new Map,u=-1,d=new Set;for(let e=0;e<=c;e++){let t=s.get(e)??[];(u<0||t.some(e=>d.has(n.get(e.id))))&&(u++,d=new Set);for(let e of t)d.add(n.get(e.id));l.set(e,u)}for(let t of e)r.set(t.id,l.get(r.get(t.id)));return u+1},wv=(e,t,n,r,i,a)=>{let o=Array.from(e).filter(([,e])=>e===`in`).map(([e])=>e),s=Array.from(e).filter(([,e])=>e===`out`).map(([e])=>e);if(o.length>0){for(let e of n.keys())n.set(e,n.get(e)+1);i++}s.length>0&&i++;let c=(e,i)=>{let o=new Map;for(let n of e){let e=t.find(e=>e.source===n||e.target===n);o.set(n,e.source===n?e.target:e.source)}let s=e=>r.get(o.get(e));e.sort((e,t)=>s(e)-s(t));let c=[];for(let t of e){let e=s(t),o=e=>c.some(t=>r.get(t)===e),l;for(let t=0;l===void 0&&t<a;t++)e+t<a&&!o(e+t)?l=e+t:e-t>=0&&!o(e-t)&&(l=e-t);if(l===void 0){for(let[t,n]of r)n>e&&r.set(t,n+1);a++,l=e+1}n.set(t,i),r.set(t,l),c.push(t)}};return c(o,0),c(s,i-1),{ncols:i,nrows:a}},Tv=(e,t,n,r)=>{let i=(e,t)=>({mirror:e===`r`,hairpin:e===t}),a=e.map((e,a)=>{let o=t.get(e.source);if(e.source===e.target)return{chans:[o],guts:[],flags:[i(`l`,`l`)]};let s=t.get(e.target),c=n.get(e.source),l=n.get(e.target),u=r[a].s===`e`?o:o-1,d=r[a].t===`w`?s-1:s,f=r[a].s===`e`?`l`:`r`,p=r[a].t===`w`?`r`:`l`;if(u===d)return{chans:[u],guts:[],flags:[i(f,p)]};let m=d>u?`r`:`l`;return{chans:[u,d],guts:[l>c?l-1:l],flags:[i(f,m),i(m===`r`?`l`:`r`,p)]}}),o=new Map,s=new Map,c=new Map,l=new Map,u=(e,t)=>c.set(e,Math.max(c.get(e)??0,t));a.forEach((t,n)=>{for(let e of t.chans)o.set(e,(o.get(e)??0)+1);for(let e of t.guts)s.set(e,(s.get(e)??0)+1);let{name:r,arity:i,source:a,target:c}=e[n];a!==c&&(r!==void 0&&t.chans.length===1?u(t.chans[0],y(r,16)+16):r!==void 0&&t.guts.length>0&&l.set(t.guts[0],(l.get(t.guts[0])??0)+1),i!==void 0&&t.chans.length>0&&u(t.chans[t.chans.length-1],24+y(i,16)+fv))});let d=new Map,f=new Map;for(let t of e.filter(e=>e.source===e.target)){let e=(d.get(t.source)??0)+1;d.set(t.source,e);let r=n.get(t.source)-1;f.set(r,Math.max(f.get(r)??0,e))}return{plans:a,chanCnt:o,gutCnt:s,chanLbl:c,gutLbl:l,gutLoop:f}},Ev=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=Array.from({length:a},()=>0),m=Array.from({length:o},()=>0);for(let a of e)p[t.get(a.id)]=Math.max(p[t.get(a.id)],r.get(a.id)),m[n.get(a.id)]=Math.max(m[n.get(a.id)],i.get(a.id));let h=Array.from({length:a},(e,t)=>{let n=s.get(t)??0;return Math.min(f[`graph-channel-width-max`],Math.max(f[`graph-channel-width-min`],n===0?lv:uv+(n-1)*f[`size-edge-track-gap`],l.get(t)??0))}),g=Array.from({length:o},(e,t)=>{let n=c.get(t)??0,r=u.get(t)??0,i=d.get(t)??0;return Math.min(f[`graph-gutter-height-max`],Math.max(f[`graph-gutter-height-min`],n===0?pv:mv+(n-1)*f[`size-edge-track-gap`],r>0?mv+r*gv:0,i>0?_v+(i-1)*f[`size-edge-track-gap`]+hv:0))}),_=[],v=[],y=f[`size-canvas-margin`];for(let e=0;e<p.length;e++)_.push(y+p[e]/2),y+=p[e]+h[e];let b=f[`size-canvas-margin`];for(let e=0;e<m.length;e++)v.push(b+m[e]/2),b+=m[e]+g[e];return{colWidth:p,rowHeight:m,chanW:h,gutH:g,colCX:_,rowCY:v}},Dv=(e,t,n,r,i)=>{let{colWidth:a,rowHeight:o,chanW:s,gutH:c,colCX:l,rowCY:u}=r,d=e=>u[e]+o[e]/2+c[e]/2,f=new Map;e.forEach((e,r)=>{let{chans:i,guts:a,flags:o}=t[r];if(i.length===0)return;let s=n.get(`${r}:s`),c=n.get(`${r}:t`);if(e.source===e.target)xv(f,i[0],{edge:r,posIn:s.y,posOut:c.y-_v,...o[0]});else if(i.length===1)xv(f,i[0],{edge:r,posIn:s.y,posOut:c.y,...o[0]});else{let e=d(a[0]);xv(f,i[0],{edge:r,posIn:s.y,posOut:e,...o[0]}),xv(f,i[1],{edge:r,posIn:e,posOut:c.y,...o[1]})}});let p=new Map;for(let[e,t]of f)for(let[n,r]of ce(t,s[e],dv,i[`size-edge-track-gap`]))p.set(`${e}:${n}`,r);let m=(e,t)=>l[e]+a[e]/2+s[e]/2+p.get(`${e}:${t}`),h=new Map;e.forEach((e,r)=>{let{chans:i,guts:a}=t[r];if(a.length===0)return;let o=n.get(`${r}:s`);xv(h,a[0],{edge:r,posIn:m(i[0],r),posOut:m(i[1],r),mirror:o.y>d(a[0])})});let g=new Map;for(let[e,t]of h)for(let[n,r]of ce(t,c[e],hv,i[`size-edge-track-gap`]))g.set(`${e}:${n}`,r);return{chanX:m,gutY:(e,t)=>d(e)+g.get(`${e}:${t}`)}},Ov=(e,t,n,r,i,a,o)=>{let s=new Map;return e.forEach((e,n)=>{e.source===e.target&&s.set(e.source,Math.min(s.get(e.source)??1/0,a(t[n].chans[0],n)))}),e.map((e,c)=>{let l=n.get(`${c}:s`),u=n.get(`${c}:t`),{chans:d,guts:f,flags:p}=t[c],m;if(e.source===e.target){let t=a(d[0],c),n=i(e.source)-r.get(e.source)/2-_v-(t-s.get(e.source));m=[[l.x,l.y],[t,l.y],[t,n],[u.x,n],[u.x,u.y]]}else if(d.length===1){let e=a(d[0],c);m=!p[0].hairpin&&l.y===u.y?[[l.x,l.y],[u.x,u.y]]:[[l.x,l.y],[e,l.y],[e,u.y],[u.x,u.y]]}else{let e=a(d[0],c),t=a(d[1],c),n=o(f[0],c);m=[[l.x,l.y],[e,l.y],[e,n],[t,n],[t,u.y],[u.x,u.y]]}return F(m)})},kv=(e,t,n,r,i,a,o,s,c,l)=>{let u=Dv(e,t,I(e,n,a,o,r,i,c[`size-edge-port-gap`],void 0,l.fixedPort),s,c),d=I(e,n,a,o,r,i,c[`size-edge-port-gap`],e=>t[e].guts.length>0?u.gutY(t[e].guts[0],e):void 0,l.fixedPort),{chanX:f,gutY:p}=Dv(e,t,d,s,c),m=Ov(e,t,d,i,o,f,p);return{portPos:d,gutY:p,polys:m,hops:le(m).reduce((e,t)=>e+Array.from(t.values()).reduce((e,t)=>e+t.length,0),0)}},Av=(e,t,n,r,i,a,o,s,c,l)=>{let u=(e,a)=>!n.some(t=>t.guts[0]===e&&Math.min(...t.chans)<a&&a<=Math.max(...t.chans))&&!t.some(t=>t.source===t.target&&i.get(t.source)===e+1&&r.get(t.source)===a),d=e=>{let t=i.get(e),n=r.get(e),c=(o.rowHeight[t]-a.get(e))/2,l=t>0&&u(t-1,n)?o.gutH[t-1]-pv:0,d=t<s-1&&u(t,n)?o.gutH[t]-pv:0;return[-(c+l),c+d]},f=(e,r)=>t.every((t,a)=>{let o=t.source===e?`s`:t.target===e?`t`:null;if(o===null||n[a].guts.length===0)return!0;let s=n[a].guts[0],c=r.portPos.get(`${a}:${o}`).y-r.gutY(s,a);return i.get(e)>s?c>=vv:c<=-24}),p=t.map((e,t)=>n[t].chans.length===1&&!n[t].flags[0].hairpin&&i.get(e.source)===i.get(e.target)),m=e=>t.filter((t,n)=>p[n]&&e.portPos.get(`${n}:s`).y!==e.portPos.get(`${n}:t`).y).length,h=(e,t)=>e.hops<t.hops||e.hops===t.hops&&m(e)<m(t),g=l();for(let n=0;n<yv;n++){let n=!1;for(let r of e){let[e,i]=d(r.id),a=new Set;t.forEach((e,t)=>{if(!p[t])return;let n=g.portPos.get(`${t}:s`),i=g.portPos.get(`${t}:t`);e.source===r.id?a.add(i.y-n.y):e.target===r.id&&a.add(n.y-i.y)});let o=c.get(r.id)??0,s;for(let t of a){if(t===0||o+t<e||o+t>i)continue;c.set(r.id,o+t);let n=l();f(r.id,n)&&h(n,s?.routing??g)&&(s={shift:o+t,routing:n})}c.set(r.id,s?.shift??o),s!==void 0&&(g=s.routing,n=!0)}if(!n)break}return g},jv=(e,t,n)=>e.map((e,r)=>{let i=t.get(e.source),a=t.get(e.target);return e.source===e.target?{s:`e`,t:`n`}:{s:n.fixedPort?.(r,`s`)===void 0?i<=a?`e`:`w`:`e`,t:n.fixedPort?.(r,`t`)===void 0?i<a?`w`:`e`:`w`}}),Mv=(e,t,n,r,i,a)=>{let o=new Map;t.forEach((e,t)=>{o.set(`${n[t].s}:${e.source}`,(o.get(`${n[t].s}:${e.source}`)??0)+1),o.set(`${n[t].t}:${e.target}`,(o.get(`${n[t].t}:${e.target}`)??0)+1)});for(let t of e){if(a.fixedSize?.has(t.id))continue;let e=Math.max(o.get(`w:${t.id}`)??0,o.get(`e:${t.id}`)??0);e>i[`graph-node-degree-max`]&&r.set(t.id,r.get(t.id)+(e-i[`graph-node-degree-max`])*i[`size-edge-port-gap`])}},Nv=async(e,t,n={})=>{let r=Array.from(e.nodes.values()),i=e.edges,a=n.gates??new Map,o=r.filter(e=>!a.has(e.id)),s=i.filter(e=>!a.has(e.source)&&!a.has(e.target)),{boxW:c,boxH:l,contentH:u}=N(r,t,()=>t[`size-node-height-scale`]/2,n.fixedSize),d=Math.max(Math.floor(t[`graph-columns-max`]),1),f=new Map,p=new Map,m,h;if(o.some(e=>O(e)!==void 0)){let e=e=>O(e)??1/0,t=Array.from(new Set(o.map(e))).sort((e,t)=>e-t);m=1,h=0;for(let n of t){let t=o.filter(t=>e(t)===n);t.forEach((e,t)=>{f.set(e.id,t%d),p.set(e.id,h+Math.floor(t/d))}),m=Math.max(m,Math.min(t.length,d)),h+=Math.ceil(t.length/d)}}else{let e=new Map,n=new Map;if(o.length>0){let r=new ov({rankdir:`LR`,nodesep:t[`graph-node-separation`],ranksep:t[`graph-rank-separation`],nodeSize:e=>e.size});await r.execute({nodes:o.map(e=>({id:e.id,size:[c.get(e.id),l.get(e.id)]})),edges:s.map((e,t)=>({id:`e${t}`,source:e.source,target:e.target}))}),r.forEachNode(t=>{e.set(String(t.id),t.x),n.set(String(t.id),t.y)})}let r=bv(o,e,n);for(let[e,t]of r.col)f.set(e,t);for(let[e,t]of r.row)p.set(e,t);if(Sv(o,s,f,p),r.ncols>d)for(let e of o){let t=f.get(e.id);f.set(e.id,t%d),p.set(e.id,p.get(e.id)+Math.floor(t/d)*r.nrows)}m=Math.min(r.ncols,d),h=Cv(o,s,f,p)}({ncols:m,nrows:h}=wv(a,i,f,p,m,h));let g=jv(i,f,n),_=Tv(i,f,p,g);if(_.plans.some(e=>e.chans.some(e=>e<0))){for(let e of r)f.set(e.id,f.get(e.id)+1);m++,_=Tv(i,f,p,g)}let{plans:v,chanCnt:y,gutCnt:b,chanLbl:x,gutLbl:S,gutLoop:C}=_;Mv(r,i,g,l,t,n);let w=Ev(r,f,p,c,l,m,h,y,b,x,S,C,t),T=new Map,E=e=>w.colCX[f.get(e)],D=e=>w.rowCY[p.get(e)]+(T.get(e)??0);return{nodes:r,edges:i,cx:E,cy:D,boxW:c,boxH:l,contentH:u,polys:Av(r,i,v,f,p,l,w,h,T,()=>kv(i,v,g,c,l,E,D,w,t,n)).polys}},Pv=`\0`,Fv=28,Iv=16,Lv=e=>{let t=Array.from(e.nodes.values());for(let e of t)if(e.id.includes(Pv))throw Error(`node id ${JSON.stringify(e.id)} contains a reserved control character`);let n=t.filter(S);if(n.length!==1)throw Error(`expected exactly one node annotated with "primary: true" (found ${n.length})`);let r=n[0],i=new Set,a=new Set;for(let t of e.edges)if(t.source===r.id&&t.target===r.id)throw Error(`self-loop on primary node "${r.id}" not supported`);else if(t.target===r.id)i.add(t.source);else if(t.source===r.id)a.add(t.target);else throw Error(`edge "${t.source}" --> "${t.target}" does not connect to primary node "${r.id}"`);let o=new Set,s=[],c=[];for(let e of t){if(e.id===r.id)continue;let t=i.has(e.id),n=a.has(e.id);if(!t&&!n)throw Error(`node "${e.id}" is neither input nor output of primary node "${r.id}"`);t&&n?(o.add(e.id),s.push({...e,id:e.id+`\0in`}),c.push({...e,id:e.id+`\0out`})):t?s.push(e):c.push(e)}let l=e.edges.map(e=>e.target===r.id&&o.has(e.source)?{...e,source:e.source+`\0in`}:e.source===r.id&&o.has(e.target)?{...e,target:e.target+`\0out`}:e);return{center:r,inputs:s,outputs:c,nodes:[r,...s,...c],edges:l}},Rv={graph:{render:Nv,gated:!0},hub:{render:async(e,t,n={})=>{let{center:r,inputs:i,outputs:a,nodes:o,edges:s}=Lv(e),c=new Set(i.map(e=>e.id)),l=t[`size-canvas-margin`],u=t[`hub-node-gap`],d=t[`size-node-height-scale`],f=e=>e===r.id?1:c.has(e)?0:2,p=s.map(()=>({s:`e`,t:`w`})),{boxW:m,boxH:h,contentH:g}=N(o,t,()=>d/2,n.fixedSize),_=new Map;s.forEach((e,t)=>{_.set(`${p[t].s}:${e.source}`,(_.get(`${p[t].s}:${e.source}`)??0)+1),_.set(`${p[t].t}:${e.target}`,(_.get(`${p[t].t}:${e.target}`)??0)+1)});for(let e of o){if(n.fixedSize?.has(e.id))continue;let r=Math.max(_.get(`w:${e.id}`)??0,_.get(`e:${e.id}`)??0);r>t[`hub-node-degree-max`]&&h.set(e.id,h.get(e.id)+(r-t[`hub-node-degree-max`])*t[`size-edge-port-gap`])}let v=e=>e.reduce((e,t)=>e+h.get(t.id),0)+Math.max(e.length-1,0)*u,y=Math.max(v(i),h.get(r.id),v(a)),b=new Map,x=e=>{let t=l+(y-v(e))/2;for(let n of e)b.set(n.id,t+h.get(n.id)/2),t+=h.get(n.id)+u};x(i),x(a),b.set(r.id,l+y/2);let S=[i.reduce((e,t)=>Math.max(e,m.get(t.id)),0),m.get(r.id),a.reduce((e,t)=>Math.max(e,m.get(t.id)),0)],w=e=>Math.min(f(e.source),f(e.target)),T=[s.filter(e=>w(e)===0).length,s.filter(e=>w(e)===1).length].map(e=>Math.min(t[`hub-channel-width-max`],Math.max(t[`hub-channel-width-min`],Fv+(e-1)*t[`size-edge-track-gap`]))),E=[],D=l;for(let e=0;e<3;e++)E.push(D),D+=S[e]+(e<2?T[e]:0);let O=e=>{let t=f(e);return t===0?E[0]+S[0]-m.get(e)/2:t===2?E[2]+m.get(e)/2:E[1]+S[1]/2},k=e=>b.get(e),A=I(s,p,O,k,m,h,t[`size-edge-port-gap`],void 0,n.fixedPort),ee=[[],[]];s.forEach((e,t)=>{ee[w(e)].push({edge:t,posIn:A.get(`${t}:s`).y,posOut:A.get(`${t}:t`).y,mirror:!1})});let j=new Map;ee.forEach((e,n)=>{for(let[r,i]of ce(e,T[n],Iv,t[`size-edge-track-gap`]))j.set(`${n}:${r}`,i)});let M=(e,t)=>E[e]+S[e]+T[e]/2+j.get(`${e}:${t}`);return{nodes:o,edges:s,cx:O,cy:k,boxW:m,boxH:h,contentH:g,polys:s.map((e,t)=>{let n=A.get(`${t}:s`),r=A.get(`${t}:t`),i=M(w(e),t),a;return a=n.y===r.y?[[n.x,n.y],[r.x,r.y]]:[[n.x,n.y],[i,n.y],[i,r.y],[r.x,r.y]],F(a)}),styleOf:e=>e.id.endsWith(`\0out`)?{fill:`color-node-ghost-box`,stroke:`color-node-ghost-border`,text:`color-node-ghost-name`,dash:`10 6`}:C(e)}},gated:!1},grid:{render:async(e,t,n={})=>{let r=Array.from(e.nodes.values()).sort((e,t)=>(O(e)??1/0)-(O(t)??1/0)||0),i=t[`size-canvas-margin`],a=t[`grid-gap-horizontal`],o=t[`grid-gap-vertical`],s=Math.max(Math.floor(t[`grid-columns-max`]),1),c=Math.max(Math.floor(t[`grid-columns-min`]),1);if(e.edges.length>0){let t=e.edges[0];throw Error(`diagram type "grid" does not support edges (found ${e.edges.length}, first is "${t.source}" --> "${t.target}")`)}let{boxW:l,boxH:u,contentH:d}=N(r,t,()=>t[`size-node-height-scale`]/2,n.fixedSize),f=r.reduce((e,t)=>Math.max(e,u.get(t.id)),0),p=r.reduce((e,t)=>Math.max(e,l.get(t.id)),0);for(let e of r)u.set(e.id,f),t[`grid-node-width-equal`]&&l.set(e.id,p);let m=Math.max(Math.min(Math.max(Math.ceil(Math.sqrt(r.length)),c),s,r.length),1),h=Array.from({length:m},()=>0);r.forEach((e,t)=>{h[t%m]=Math.max(h[t%m],l.get(e.id))});let g=[],_=i;for(let e=0;e<m;e++)g.push(_),_+=h[e]+a;let v=new Map,y=new Map;return r.forEach((e,t)=>{v.set(e.id,g[t%m]+l.get(e.id)/2),y.set(e.id,i+Math.floor(t/m)*(f+o)+f/2)}),{nodes:r,edges:[],cx:e=>v.get(e),cy:e=>y.get(e),boxW:l,boxH:u,contentH:d,polys:[]}},gated:!1}},zv=Object.keys(Rv),Bv=`graph`,Vv=e=>{let t;for(let n of e.split(/\r?\n/)){let e=/^[ \t]*#type[ \t]+([a-z][a-z0-9-]*)[ \t]*$/.exec(n);e===null||!Object.hasOwn(Rv,e[1])||(t=e[1])}return t},Hv=[`svg:standalone`,`svg:embedded`,`url:xml`,`url:base64`];e.Gradia=class e{static config=Object.freeze({...p});static parse(e){return d(e)}static async generate(e,t={}){let n=t.type??`graph`;if(!Object.hasOwn(Rv,n))throw Error(`invalid diagram type "${n}"`);let r=t.format??`svg:standalone`;if(!Hv.includes(r))throw Error(`invalid output format "${r}"`);let i=h(t.config??{},{trusted:!0}),a={...p,...i};for(let[t,n]of e.nodes)if(n.id!==t)throw Error(`node id "${n.id}" does not match its map key "${t}"`);for(let t of e.edges)for(let n of[t.source,t.target])if(!e.nodes.has(n))throw Error(`endpoint "${n}" of edge "${t.source}" --> "${t.target}" is not a declared node`);let o=R(e,zv),s=e=>ge(e,o,n,Rv,a),c=ye(e,o),l=Pe(c===null?await s(e):be(c,await Promise.all(c.map(e=>s(e.graph))),a),a,i,JSON.stringify({type:n,config:a,explicit:Object.keys(i).sort(),nodes:Array.from(e.nodes.values()),edges:e.edges}));return r===`svg:embedded`?l.replace(/^<\?xml[^?]*\?>\n/,``):r===`url:xml`?`data:image/svg+xml,${encodeURIComponent(l)}`:r===`url:base64`?`data:image/svg+xml;base64,${btoa(Array.from(new TextEncoder().encode(l),e=>String.fromCharCode(e)).join(``))}`:l}static async render(t,n={}){let r=e.parse(t),i=n.type??Vv(t),a={...g(t),...n.config??{}};return e.generate(r,{...n,type:i,config:a})}},e.diagramFormatDefault=`svg:standalone`,e.diagramFormats=Hv,e.diagramTypeDefault=Bv,e.diagramTypes=zv});
|
|
4
|
+
`;)r++,i++;else if((d=c(a))!==null){let e=d[1]===void 0?d[2]:l(d[1]),a=d[3]===void 0?d[4]:l(d[3]);t.push({type:`edge`,text:d[0],name:e,arity:a,line:n,col:r}),r+=d[0].length,i+=d[0].length}else if((d=c(o))!==null)t.push({type:`string`,text:l(d[1]),line:n,col:r}),r+=d[0].length,i+=d[0].length;else if(u===`"`)throw Error(`unterminated string at line ${n}, column ${r}`);else if(`[](),:`.includes(u))t.push({type:`punct`,text:u,line:n,col:r}),r++,i++;else if((d=c(s))!==null)t.push({type:`word`,text:d[0],line:n,col:r}),r+=d[0].length,i+=d[0].length;else throw Error(`invalid character ${JSON.stringify(u)} at line ${n}, column ${r}`)}return t},d=e=>{let t=u(e),n={nodes:new Map,edges:[]},r=0,i=()=>r<t.length?t[r]:null,a=e=>{let t=i();return t===null||t.type!==`punct`||t.text!==e?!1:(r++,!0)},o=e=>{let t=i(),n=t===null?`end of input`:`line ${t.line}, column ${t.col}`;throw Error(`expected ${e} at ${n}`)},s=()=>{let e=i();return e===null||e.type!==`word`&&e.type!==`string`?o(`bareword or quoted string`):(r++,e.text)},c=()=>{let e=t[r],i=s(),c=null;a(`:`)&&(c=s());let l=[];if(a(`[`)){for(;;){let e=s();a(`:`)||o(`":" in key/value attribute`);let t=s();if(l.push({key:e,val:t}),!a(`,`))break}a(`]`)||o(`"]" after key/value attributes`)}let u=n.nodes.get(i)??{id:i,name:i,attrs:[]};c!==null&&(u.name=c);for(let t of l){let n=u.attrs.findIndex(e=>e.key===t.key);if(n===-1)u.attrs.push(t);else{if((t.key===`group`||t.key===`parent`)&&u.attrs[n].val!==t.val)throw Error(`node "${i}" cannot be a member of more than one ${t.key===`group`?`group`:`container`} ("${u.attrs[n].val}" vs "${t.val}") at line ${e.line}, column ${e.col}`);u.attrs[n]=t}}let d=u.attrs.find(e=>e.key===`parent`)?.val;return d!==void 0&&!n.nodes.has(d)&&n.nodes.set(d,{id:d,name:d,attrs:[]}),n.nodes.set(i,u),i};for(;r<t.length;){if(t[r].type===`newline`){r++;continue}let e=c(),a=i();for(;a!==null&&a.type===`edge`;){r++;let t=c();n.edges.push({source:e,target:t,name:a.name,arity:a.arity}),e=t,a=i()}a!==null&&a.type!==`newline`&&o(`edge operator or end of line`)}return n},f=l(s(((e,t)=>{t.exports={}}))(),1),p={"font-family":`Helvetica`,"font-embed":!1,"color-node-regular-name":`#336699`,"color-node-regular-box":`#e0f0ff`,"color-node-regular-border":`#c0d0e0`,"color-node-primary-name":`#ffffff`,"color-node-primary-box":`#336699`,"color-node-primary-border":`#003366`,"color-node-ghost-name":`#666666`,"color-node-ghost-box":`#f0f0f0`,"color-node-ghost-border":`#a0a0a0`,"color-group-name":`#6699cc`,"color-group-box":`#f4f8fc`,"color-group-border":`#c0d0e0`,"color-container-name":`#666666`,"color-container-box":`#f6f6f6`,"color-container-border":`#a0a0a0`,"color-edge-line":`#999999`,"color-edge-name":`#333333`,"color-edge-arity":`#333333`,"color-edge-halo":`#ffffff`,"size-canvas-margin":40,"size-node-width-min":220,"size-node-width-max":0,"size-node-height-scale":2.25,"size-edge-corner-radius":20,"size-edge-hop-radius":8,"size-edge-track-gap":12,"size-edge-port-gap":24,"group-box-padding":30,"group-box-gap":40,"container-box-padding":30,"graph-columns-max":4,"graph-channel-width-max":140,"graph-channel-width-min":24,"graph-gutter-height-max":90,"graph-gutter-height-min":20,"graph-node-separation":30,"graph-rank-separation":60,"graph-node-degree-max":3,"hub-channel-width-max":340,"hub-channel-width-min":240,"hub-node-gap":20,"hub-node-degree-max":3,"grid-columns-max":4,"grid-columns-min":3,"grid-gap-horizontal":40,"grid-gap-vertical":20,"grid-node-width-equal":!0,"grid-node-height-equal":!0},m=(e,t)=>Object.hasOwn(e,t)?e[t].replace(/[;{}]/g,``):`var(--gradia-${t}, ${p[t]})`,h=(e,t)=>{let n={};for(let[r,i]of Object.entries(e)){if(!Object.hasOwn(p,r))throw Error(`unknown configuration option "${r}"`);let e=r;if(i!==void 0){if(e===`font-embed`&&!t.trusted)throw Error(`configuration option "${r}" is not available in this context`);if(typeof p[e]==`boolean`){if(typeof i!=`boolean`&&i!==`true`&&i!==`false`)throw Error(`invalid value "${String(i)}" for boolean configuration option "${r}" (expected "true" or "false")`);n[e]=typeof i==`boolean`?i:i===`true`}else if(typeof p[e]==`number`){let t=Number(i);if(typeof i!=`number`&&typeof i!=`string`||String(i).trim()===``||!Number.isFinite(t)||t<0)throw Error(`invalid value "${String(i)}" for numeric configuration option "${r}" (expected a non-negative number)`);n[e]=t}else{if(typeof i!=`string`)throw Error(`invalid value "${String(i)}" for string configuration option "${r}" (expected a string)`);if(i===``)throw Error(`invalid empty value for string configuration option "${r}"`);if(e===`font-family`&&i.endsWith(`.woff2`)&&!t.trusted)throw Error(`configuration option "font-family" must not be the path to a WOFF2 file in this context`);n[e]=i}}}return n},g=e=>{let t={};for(let n of e.split(/\r?\n/)){let e=/^[ \t]*#config[ \t]+([a-z][a-z0-9-]*)[ \t]+(?:"((?:[^"\\]|\\.)*)"|(\S+))[ \t]*$/.exec(n);if(e===null)continue;let r=e[2]===void 0?e[3]:e[2].replace(/\\(.)/g,`$1`);try{Object.assign(t,h({[e[1]]:r},{trusted:!1}))}catch{}}return t},_={"Source Sans 3":{file:`source-sans/WOFF2/VF/SourceSans3VF-Upright.ttf.woff2`,weight:`200 900`}},v=e=>{let t=e[`font-family`];if(Object.hasOwn(_,t)){let n=_[t];if(e[`font-embed`]){let e=f.default.fileURLToPath((e=>e)(n.file));return{family:t,embed:f.default.readFileSync(e).toString(`base64`),weight:n.weight}}return{family:t}}if(t.endsWith(`.woff2`)){let n=f.default.basename(t,`.woff2`);return e[`font-embed`]?{family:n,embed:f.default.readFileSync(t).toString(`base64`)}:{family:n}}if(e[`font-embed`])throw Error(`option "font-embed" requires option "font-family" to be a built-in font family (${Object.keys(_).map(e=>`"${e}"`).join(`, `)}) or the path to a WOFF2 file`);return{family:t}},y=(e,t)=>e.length*t*.52,b=(e,t,n)=>{let r=e.split(/\s+/).filter(e=>e!==``),i=r.join(` `);if(n<=0||r.length<=1||y(i,t)<=n)return[i];let a=[],o=r[0];for(let e of r.slice(1))y(`${o} ${e}`,t)>n?(a.push(o),o=e):o=`${o} ${e}`;return a.push(o),a},x=e=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`),S=e=>e.attrs.findLast(e=>e.key===`primary`)?.val===`true`,C=e=>S(e)?{fill:`color-node-primary-box`,stroke:`color-node-primary-border`,text:`color-node-primary-name`}:{fill:`color-node-regular-box`,stroke:`color-node-regular-border`,text:`color-node-regular-name`},w=e=>e.attrs.findLast(e=>e.key===`type`)?.val,T=e=>e.attrs.findLast(e=>e.key===`parent`)?.val,E=e=>e.attrs.findLast(e=>e.key===`container`)?.val,D=e=>34+(w(e)===void 0?0:20),O=e=>{let t=e.attrs.findLast(e=>e.key===`order`)?.val,n=t!==void 0&&t.trim()!==``?Number(t):NaN;return Number.isFinite(n)?n:void 0},k=new Set([`url`,`type`,`primary`,`group`,`parent`,`container`,`order`]),A=e=>e.attrs.filter(e=>!k.has(e.key)),ee=/^\s*([A-Za-z][A-Za-z0-9+.-]*):/,j=new Set([`http`,`https`,`mailto`]),M=e=>{let t=e.attrs.findLast(e=>e.key===`url`)?.val;if(t===void 0)return;let n=t.replace(/[\u0000-\u001F\u007F]/g,``),r=ee.exec(n);if(!(r!==null&&!j.has(r[1].toLowerCase())))return n},te=(e,t)=>{let n=t[`size-node-width-max`]>0?t[`size-node-width-max`]-36:0,r=w(e);return{name:b(e.name,30,n),type:r===void 0?[]:b(r,16,n),attrs:A(e).flatMap(e=>b(`${e.key}: ${e.val}`,22,n))}},N=(e,t,n,r)=>{let i=new Map,a=new Map,o=new Map;for(let s of e){let e=r?.get(s.id);if(e!==void 0){i.set(s.id,e.w),a.set(s.id,e.h),o.set(s.id,e.h);continue}let c=te(s,t),l=Math.max(0,...c.name.map(e=>y(e,30)),...c.type.map(e=>y(e,16)),...c.attrs.map(e=>y(e,22))),u=56+(c.name.length-1)*34+c.type.length*26+(c.attrs.length>0?12+(c.attrs.length-1)*30+20:0);i.set(s.id,Math.max(t[`size-node-width-min`],Math.ceil(l)+36)),a.set(s.id,Math.max(u,Math.ceil(u*n(s)))),o.set(s.id,u)}return{boxW:i,boxH:a,contentH:o}},P=10,F=e=>{let t=[...e];for(let e=t.length-2;e>0;e--){let[n,r,i]=[t[e-1],t[e],t[e+1]];(n[0]===r[0]&&r[0]===i[0]||n[1]===r[1]&&r[1]===i[1])&&t.splice(e,1)}let n=[];for(let e of t)n.length>0&&n[n.length-1][0]===e[0]&&n[n.length-1][1]===e[1]||n.push(e);return n},I=(e,t,n,r,i,a,o,s,c)=>{let l=new Map,u=(e,t,n)=>{let r=l.get(e);r===void 0?l.set(e,[{edge:t,role:n}]):r.push({edge:t,role:n})};e.forEach((e,n)=>{u(`${e.source}:${t[n].s}`,n,`s`),u(`${e.target}:${t[n].t}`,n,`t`)});let d=new Map;for(let[t,u]of l){let l=t.lastIndexOf(`:`),f=t.slice(0,l),p=t.slice(l+1);if(p===`n`){u.sort((e,t)=>t.edge-e.edge);let e=Math.min(o,(i.get(f)-P)/u.length);u.forEach((t,i)=>{d.set(`${t.edge}:${t.role}`,{x:n(f)+(i-(u.length-1)/2)*e,y:r(f)-a.get(f)/2})});continue}let m=n(f)+(p===`e`?1:-1)*i.get(f)/2,h=e=>c?.(e.edge,e.role),g=[];for(let e of u.filter(e=>h(e)!==void 0)){let t=r(f)+h(e);d.set(`${e.edge}:${e.role}`,{x:m,y:t}),g.push(t)}g.sort((e,t)=>e-t);let _=u.filter(e=>h(e)===void 0),v=t=>t.role===`s`?e[t.edge].target:e[t.edge].source,y=e=>s?.(e.edge)??r(v(e));_.sort((e,t)=>y(e)-y(t)||e.edge-t.edge);let b=_.length+g.length,x=Math.min(o,(a.get(f)-P)/b),S=(e,t)=>d.set(`${e.edge}:${e.role}`,{x:m,y:t});if(g.length===0){_.forEach((e,t)=>S(e,r(f)+(t-(b-1)/2)*x));continue}let C=r(f)-(a.get(f)-P)/2+x/2,w=r(f)+(a.get(f)-P)/2-x/2,T=[C-x,...g,w+x],E=e=>g.filter(t=>t<y(e)).length,D=T.slice(1).map((e,t)=>({lo:Math.max(C,T[t]+x),hi:Math.min(w,e-x),ports:_.filter(e=>E(e)===t)})),O=e=>e.hi<e.lo?0:Math.floor((e.hi-e.lo)/x)+1;for(let e=0;e<D.length-1;e++)for(;D[e].ports.length>O(D[e]);)D[e+1].ports.unshift(D[e].ports.pop());for(let e=D.length-1;e>0;e--)for(;D[e].ports.length>O(D[e]);)D[e-1].ports.push(D[e].ports.shift());let k=0;D.forEach((e,t)=>{let n=e.ports.length,i=n>1?Math.min(x,Math.max(e.hi-e.lo,0)/(n-1)):x,a=Math.min(Math.max(r(f)+(k+t-(b-1)/2)*x,e.lo),e.hi-(n-1)*i);e.ports.forEach((e,t)=>S(e,a+t*i)),k+=n})}return d},ne=24,L=e=>e.hairpin?e.mirror?[]:[e.posIn,e.posOut]:[e.mirror?e.posOut:e.posIn],re=e=>e.hairpin?e.mirror?[e.posIn,e.posOut]:[]:[e.mirror?e.posIn:e.posOut],ie=(e,t)=>{let n=(e,t)=>t>=Math.min(e.posIn,e.posOut)&&t<=Math.max(e.posIn,e.posOut);return re(e).filter(e=>n(t,e)).length+L(t).filter(t=>n(e,t)).length},ae=(e,t)=>re(e).filter(e=>L(t).includes(e)).length,oe=14,se=e=>{let t=e.length;if(t<2)return e;let n=e.map((n,r)=>e.map((e,i)=>(ae(n,e)*2*t*t+ie(n,e))*t*t+ +(r>i))),r;if(t<=oe){let e=new Float64Array(1<<t).fill(1/0),i=new Int8Array(1<<t);e[0]=0;for(let r=1;r<1<<t;r++)for(let a=0;a<t;a++){if(!(r&1<<a))continue;let o=r&~(1<<a),s=e[o];for(let e=0;e<t;e++)o&1<<e&&(s+=n[e][a]);s<e[r]&&(e[r]=s,i[r]=a)}r=[];for(let e=(1<<t)-1;e!==0;e&=~(1<<i[e]))r.unshift(i[e])}else{r=e.map((e,t)=>t);for(let e=!0;e;){e=!1;for(let i=1;i<t&&!e;i++)for(let a=0;a+i<=t&&!e;a++){let o=0;for(let s=a+i;s<t&&!e;s++){for(let e=a;e<a+i;e++)o+=n[r[s]][r[e]]-n[r[e]][r[s]];o<0&&(r.splice(s-i+1,0,...r.splice(a,i)),e=!0)}o=0;for(let t=a-1;t>=0&&!e;t--){for(let e=a;e<a+i;e++)o+=n[r[e]][r[t]]-n[r[t]][r[e]];o<0&&(r.splice(t,0,...r.splice(a,i)),e=!0)}}}}return r.map(t=>e[t])},ce=(e,t,n,r)=>{let i=(e,t)=>{let n=t?-1:1,r=e.filter(e=>e.posOut<e.posIn).sort((e,t)=>n*(e.posIn-t.posIn||e.posOut-t.posOut)),i=e.filter(e=>e.posOut>=e.posIn).sort((e,t)=>n*(t.posIn-e.posIn||t.posOut-e.posOut));return[...r,...i]},a=se([...i(e.filter(e=>!e.mirror),!1),...i(e.filter(e=>e.mirror),!0)]),o=(e,t)=>Math.min(e.posIn,e.posOut)<Math.max(t.posIn,t.posOut)+ne&&Math.min(t.posIn,t.posOut)<Math.max(e.posIn,e.posOut)+ne,s=new Map,c=0;a.forEach((e,t)=>{let n=0;for(let r=0;r<t;r++)o(a[r],e)&&(n=Math.max(n,s.get(a[r].edge)+1));s.set(e.edge,n),c=Math.max(c,n+1)});let l=Math.min(r,(t-n)/Math.max(c-1,1)),u=new Map;for(let[e,t]of s)u.set(e,(t-(c-1)/2)*l);return u},le=e=>{let t=[];return e.forEach((e,n)=>{for(let r=0;r<e.length-1;r++){let[i,a]=[e[r],e[r+1]];i[0]===a[0]&&t.push({owner:n,x:i[0],y1:Math.min(i[1],a[1]),y2:Math.max(i[1],a[1])})}}),e.map((e,n)=>{let r=new Map;for(let i=0;i<e.length-1;i++){let[a,o]=[e[i],e[i+1]];if(a[1]!==o[1])continue;let s=a[1],c=Math.min(a[0],o[0]),l=Math.max(a[0],o[0]),u=[];for(let e of t)e.owner!==n&&e.x>c+1&&e.x<l-1&&s>e.y1+1&&s<e.y2-1&&u.push(e.x);u.length>0&&r.set(i,u)}return r})},ue=(e,t)=>Math.abs(t[0]-e[0])+Math.abs(t[1]-e[1]),de=(e,t,n,r)=>{let i=i=>{if(i<=0||i>=e.length-1)return 0;let a=Math.min(n,ue(e[i-1],e[i])/2,ue(e[i],e[i+1])/2);for(let n of[i-1,i])for(let o of t.get(n)??[])a=Math.min(a,Math.max(Math.abs(o-e[i][0])-r-2,4));return a},a=[];for(let n=0;n<e.length-1;n++){let[o,s]=[e[n],e[n+1]],c=ue(o,s),l=(s[0]-o[0])/c,u=(s[1]-o[1])/c,d=i(n),f=i(n+1),p=[o[0]+l*d,o[1]+u*d],m=[s[0]-l*f,s[1]-u*f];if(n===0&&a.push(`M ${p[0]} ${p[1]}`),o[1]===s[1]&&t.has(n)){let e=Math.sign(s[0]-o[0]),i=t.get(n).filter(t=>(t-p[0])*e>2&&(m[0]-t)*e>2).sort((t,n)=>(t-n)*e),c=[];for(let e of i){let t=c[c.length-1];t!==void 0&&Math.abs(e-t[t.length-1])<=r*2+14?t.push(e):c.push([e])}for(let t of c){let n=t[0]-e*r,i=t[t.length-1]+e*r;(n-p[0])*e<0&&(n=p[0]),(m[0]-i)*e<0&&(i=m[0]),a.push(`L ${n} ${o[1]}`),a.push(`A ${Math.abs(i-n)/2} ${r} 0 0 ${+(e>0)} ${i} ${o[1]}`)}}if(a.push(`L ${m[0]} ${m[1]}`),n<e.length-2){let t=e[n+1],r=e[n+2],i=ue(t,r),o=[t[0]+(r[0]-t[0])/i*f,t[1]+(r[1]-t[1])/i*f];a.push(`Q ${s[0]} ${s[1]} ${o[0]} ${o[1]}`)}}return a.join(` `)},fe=(e,t)=>{let n=e.slice(0,-1).map((t,n)=>ue(t,e[n+1])),r=n.reduce((e,t)=>e+t,0)*t;for(let t=0;t<n.length;t++){if(r<=n[t]||t===n.length-1){let i=n[t]>0?r/n[t]:0;return{x:e[t][0]+(e[t+1][0]-e[t][0])*Math.min(i,1),y:e[t][1]+(e[t+1][1]-e[t][1])*Math.min(i,1),horizontal:e[t][1]===e[t+1][1]}}r-=n[t]}return{x:e[0][0],y:e[0][1],horizontal:!0}},R=(e,t)=>{let n=new Map,r=new Map;for(let i of e.nodes.values()){let a=E(i);if(a!==void 0&&!t.includes(a))throw Error(`invalid container layout type "${a}" of node "${i.id}"`);let o=T(i);if(o===void 0)continue;if(!e.nodes.has(o))throw Error(`container "${o}" of node "${i.id}" is not a declared node`);n.set(i.id,o);let s=r.get(o);s===void 0?r.set(o,[i]):s.push(i)}for(let e of n.keys()){let t=new Set([e]);for(let r=n.get(e);r!==void 0;r=n.get(r)){if(t.has(r))throw Error(`node "${e}" cannot be nested into itself (containment cycle)`);t.add(r)}}let i=(e,t)=>{for(let r=n.get(t);r!==void 0;r=n.get(r))if(r===e)return!0;return!1};for(let t of e.edges)if(i(t.source,t.target)||i(t.target,t.source))throw Error(`edge "${t.source}" --> "${t.target}" connects a container with one of its own members`);return{parentOf:n,childrenOf:r}},pe=(e,t)=>{let n=t;for(let t=e.parentOf.get(n);t!==void 0;t=e.parentOf.get(n))n=t;return n},me=(e,t=[])=>{let{nodes:n,cx:r,cy:i,boxW:a,boxH:o,polys:s}=e,[c,l,u,d]=[1/0,1/0,-1/0,-1/0];for(let e of n)c=Math.min(c,r(e.id)-a.get(e.id)/2),l=Math.min(l,i(e.id)-o.get(e.id)/2),u=Math.max(u,r(e.id)+a.get(e.id)/2),d=Math.max(d,i(e.id)+o.get(e.id)/2);for(let e of[...s,...t])for(let[t,n]of e)c=Math.min(c,t),l=Math.min(l,n),u=Math.max(u,t),d=Math.max(d,n);for(let t of e.containers??[])c=Math.min(c,t.x),l=Math.min(l,t.y),u=Math.max(u,t.x+t.w),d=Math.max(d,t.y+t.h);return Number.isFinite(c)||([c,l,u,d]=[0,0,0,0]),{minX:c,minY:l,maxX:u,maxY:d}},he=(e,t)=>`\u0000gate:${e}:${t}`,ge=async(e,t,n,r,i)=>{let a=Array.from(e.nodes.values()),o=e=>t.childrenOf.has(e.id)||E(e)!==void 0;if(!a.some(o))return r[n].render(e,i);let s=i[`container-box-padding`];for(let e of a)if(e.id.includes(`\0`))throw Error(`node id ${JSON.stringify(e.id)} contains a reserved control character`);let c=(e,t)=>{let n=Math.max(y(e.name,24),y(w(e)??``,16));return{w:Math.max(t.maxX-t.minX,n)+s*2,h:t.maxY-t.minY+s*2+D(e)}},l=(t,n,r,i,a,o)=>{let l=[{layout:t,dx:0,dy:0}],u=new Map;for(let e of t.nodes)u.set(e.id,0);let d=[],f=[];for(let[r,i]of n){let n=e.nodes.get(r);if(!t.nodes.some(e=>e.id===r))throw Error(`container "${r}" cannot be placed twice by diagram type "${o}"`);let{w:a,h:p}=c(n,i.bounds),m=t.cx(r),h=t.cy(r),g=l.push({layout:i.layout,dx:m-a/2+s-i.bounds.minX,dy:h-p/2+D(n)+s-i.bounds.minY})-1;for(let e of i.layout.nodes)u.set(e.id,g);u.set(r,g),d.push({node:n,x:m-t.boxW.get(r)/2,y:h-t.boxH.get(r)/2,w:t.boxW.get(r),h:t.boxH.get(r)}),f.push(...(i.layout.containers??[]).map(e=>({...e,x:e.x+l[g].dx,y:e.y+l[g].dy})))}let p=(e,t)=>e.map(([e,n])=>[e+l[t].dx,n+l[t].dy]),m=[],h=[],g=new Map;l.forEach((e,t)=>{t!==0&&e.layout.edges.forEach((n,r)=>{m.push(n),h.push(p(e.layout.polys[r],t))})}),r.forEach((r,o)=>{let s=i[o],c=n.get(r.source)?.partial.get(s),l=n.get(r.target)?.partial.get(s),d=F([...c===void 0?[]:p(c,u.get(r.source)),...t.polys[o],...l===void 0?[]:p(l,u.get(r.target))]);a.has(r.source)||a.has(r.target)?g.set(s,d):(m.push(e.edges[s]),h.push(d))});let _=e=>new Map(l.flatMap(t=>Array.from(e(t.layout).entries()))),v={nodes:[...t.nodes.filter(e=>!n.has(e.id)&&!a.has(e.id)),...l.slice(1).flatMap(e=>e.layout.nodes)],edges:m,cx:e=>l[u.get(e)].layout.cx(e)+l[u.get(e)].dx,cy:e=>l[u.get(e)].layout.cy(e)+l[u.get(e)].dy,boxW:_(e=>e.boxW),boxH:_(e=>e.boxH),contentH:_(e=>e.contentH),polys:h,styleOf:e=>(l[u.get(e.id)].layout.styleOf??C)(e),containers:[...d,...f]};return{layout:v,bounds:me(v,Array.from(g.values())),partial:g}},u=async(n,d)=>{let f=n===null?a.filter(e=>T(e)===void 0):t.childrenOf.get(n.id)??[],p=new Set(f.map(e=>e.id)),m=e=>{for(let n=e;n!==void 0;n=t.parentOf.get(n))if(p.has(n))return n},h=new Map;for(let e of f)o(e)&&h.set(e.id,await u(e,E(e)??d));let g=(e,t)=>{let{bounds:n}=h.get(e.id);return t-n.minY+D(e)+s-c(e,n).h/2},_=new Map,v=new Map(f.map(e=>[e.id,e])),y=[],b=[],x=new Map,S=(e,t)=>h.get(e)?.partial.has(t)??!1;e.edges.forEach((e,t)=>{let n=m(e.source),i=m(e.target);if(n===void 0&&i===void 0||n!==void 0&&i!==void 0&&n===i&&h.has(n)&&e.source!==n)return;let a,o;if(n===void 0||i===void 0){if(!r[d].gated)return;let e=he(t,n===void 0?`in`:`out`);_.set(e,n===void 0?`in`:`out`),v.set(e,{id:e,name:``,attrs:[]}),a=n??e,o=i??e}else a=n,o=i;let s=y.length;y.push({source:a,target:o,name:n!==void 0&&i!==void 0?e.name:void 0,arity:i!==void 0&&!S(i,t)?e.arity:void 0}),b.push(t),S(a,t)&&x.set(`${s}:s`,g(v.get(a),h.get(a).partial.get(t).at(-1)[1])),S(o,t)&&x.set(`${s}:t`,g(v.get(o),h.get(o).partial.get(t)[0][1]))});let C=new Map;for(let[e,t]of h)C.set(e,c(v.get(e),t.bounds));for(let e of _.keys())C.set(e,{w:0,h:0});let w=await r[d].render({nodes:v,edges:y},i,{fixedSize:C,fixedPort:(e,t)=>x.get(`${e}:${t}`),gates:_});return l(w,h,y,b,_,d)};return(await u(null,n)).layout},_e=34,ve=e=>e.attrs.findLast(e=>e.key===`group`)?.val,ye=(e,t)=>{let n=Array.from(e.nodes.values());if(!n.some(e=>ve(e)!==void 0))return null;let r=new Map,i=new Map;for(let a of n){let n=pe(t,a.id),o=ve(e.nodes.get(n))??`default`,s=ve(a);if(s!==void 0&&s!==o)throw Error(`node "${a.id}" cannot be a member of group "${s}", as its container "${n}" is a member of group "${o}"`);i.set(a.id,o);let c=r.get(o);c===void 0&&(c={nodes:new Map,edges:[]},r.set(o,c)),c.nodes.set(a.id,a)}for(let t of e.edges){let e=i.get(t.source),n=i.get(t.target);if(e!==n)throw Error(`edge "${t.source}" --> "${t.target}" crosses groups "${e}" and "${n}"`);r.get(e).edges.push(t)}return Array.from(r.entries()).map(([e,t])=>({name:e,graph:t}))},be=(e,t,n)=>{let r=n[`size-canvas-margin`],i=n[`group-box-padding`],a=n[`group-box-gap`],o=[],s=[],c=[],l=new Map,u=r;t.forEach((t,n)=>{let d=me(t),f=Math.max(d.maxX-d.minX+i*2,y(e[n].name,24)+i*2),p=d.maxY-d.minY+i*2+_e;s.push(r+i-d.minX),c.push(u+_e+i-d.minY);for(let e of t.nodes)l.set(e.id,n);o.push({name:e[n].name,x:r,y:u,w:f,h:p}),u+=p+a});let d=e=>new Map(t.flatMap(t=>Array.from(e(t).entries()))),f=e=>l.get(e);return{nodes:t.flatMap(e=>e.nodes),edges:t.flatMap(e=>e.edges),cx:e=>t[f(e)].cx(e)+s[f(e)],cy:e=>t[f(e)].cy(e)+c[f(e)],boxW:d(e=>e.boxW),boxH:d(e=>e.boxH),contentH:d(e=>e.contentH),polys:t.flatMap((e,t)=>e.polys.map(e=>e.map(([e,n])=>[e+s[t],n+c[t]]))),styleOf:e=>(t[f(e.id)].styleOf??C)(e),groups:o,containers:t.flatMap((e,t)=>(e.containers??[]).map(e=>({...e,x:e.x+s[t],y:e.y+c[t]})))}},xe=l(s(((e,t)=>{(function(e,n,r){typeof define==`function`&&define.amd!==void 0?define(function(){return r(e)}):typeof t==`object`&&typeof t.exports==`object`?(t.exports=r(e),t.exports.default=t.exports):e[n]=r(e)})(e,`UUID`,function(){let e=function(e,t,n,r,i,a){let o=function(e,t){let n=e.toString(16);return n.length<2&&(n=`0`+n),t&&(n=n.toUpperCase()),n};for(let s=t;s<=n;s++)i[a++]=o(e[s],r);return i},t=function(e,t,n,r,i){for(let a=t;a<=n;a+=2)r[i++]=parseInt(e.substr(a,2),16)},n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#`.split(``),r=[0,68,0,84,83,82,72,0,75,76,70,65,0,63,62,69,0,1,2,3,4,5,6,7,8,9,64,0,73,66,74,71,81,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,0,78,67,0,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,79,0,80,0,0],i=function(e,t){if(t%4!=0)throw Error(`z85_encode: invalid input length (multiple of 4 expected)`);let r=``,i=0,a=0;for(;i<t;)if(a=a*256+e[i++],i%4==0){let e=52200625;for(;e>=1;){let t=Math.floor(a/e)%85;r+=n[t],e/=85}a=0}return r},a=function(e,t){let n=e.length;if(n%5!=0)throw Error(`z85_decode: invalid input length (multiple of 5 expected)`);t===void 0&&(t=Array(n*4/5));let i=0,a=0,o=0;for(;i<n;){let n=e.charCodeAt(i++)-32;if(n<0||n>=r.length)break;if(o=o*85+r[n],i%5==0){let e=16777216;for(;e>=1;)t[a++]=Math.trunc(o/e%256),e/=256;o=0}}return t},o=function(e,t){let n={ibits:8,obits:8,obigendian:!0};for(let e in t)n[e]!==void 0&&(n[e]=t[e]);let r=[],i=0,a,o,s=0,c,l=0,u=e.length;for(;s===0&&(o=e.charCodeAt(i++)),a=o>>n.ibits-(s+8)&255,s=(s+8)%n.ibits,n.obigendian?l===0?c=a<<n.obits-8:c|=a<<n.obits-8-l:l===0?c=a:c|=a<<l,l=(l+8)%n.obits,!(l===0&&(r.push(c),i>=u)););return r},s=function(e,t){let n={ibits:32,ibigendian:!0};for(let e in t)n[e]!==void 0&&(n[e]=t[e]);let r=``,i=4294967295;n.ibits<32&&(i=(1<<n.ibits)-1);let a=e.length;for(let t=0;t<a;t++){let a=e[t]&i;for(let e=0;e<n.ibits;e+=8)n.ibigendian?r+=String.fromCharCode(a>>n.ibits-8-e&255):r+=String.fromCharCode(a>>e&255)}return r},c=function(e,t,n,r,i,a,o,s){return[s,o,a,i,r,n,t,e]},l=function(){return c(0,0,0,0,0,0,0,0)},u=function(e){return e.slice(0)},d=function(e){let t=l();for(let n=0;n<8;n++)t[n]=Math.floor(e%256),e/=256;return t},f=function(e){let t=0;for(let n=7;n>=0;n--)t*=256,t+=e[n];return Math.floor(t)},p=function(e,t){let n=0;for(let r=0;r<8;r++)n+=e[r]+t[r],e[r]=Math.floor(n%256),n=Math.floor(n/256);return n},m=function(e,t){let n=0;for(let r=0;r<8;r++)n+=e[r]*t,e[r]=Math.floor(n%256),n=Math.floor(n/256);return n},h=function(e,t){let n,r,i=Array(16);for(n=0;n<16;n++)i[n]=0;let a;for(n=0;n<8;n++){for(a=0,r=0;r<8;r++)a+=e[n]*t[r]+i[n+r],i[n+r]=a%256,a/=256;for(;r<16-n;r++)a+=i[n+r],i[n+r]=a%256,a/=256}for(n=0;n<8;n++)e[n]=i[n];return i.slice(8,16)},g=function(e,t){for(let n=0;n<8;n++)e[n]&=t[n];return e},_=function(e,t){for(let n=0;n<8;n++)e[n]|=t[n];return e},v=function(e,t){let n=l();if(t%8!=0)throw Error(`ui64_rorn: only bit rotations supported with a multiple of digit bits`);let r=Math.floor(t/8);for(let t=0;t<r;t++){let t;for(t=6;t>=0;t--)n[t+1]=n[t];for(n[0]=e[0],t=0;t<7;t++)e[t]=e[t+1];e[t]=0}return f(n)},y=function(e,t){if(t>64)throw Error(`ui64_ror: invalid number of bits to shift`);let n=Array(16),r;for(r=0;r<8;r++)n[r+8]=e[r],n[r]=0;let i=Math.floor(t/8),a=t%8;for(r=i;r<15;r++)n[r-i]=(n[r]>>>a|n[r+1]<<8-a)&255;for(n[15-i]=n[15]>>>a&255,r=15-i+1;r<16;r++)n[r]=0;for(r=0;r<8;r++)e[r]=n[r+8];return n.slice(0,8)},b=function(e,t){if(t>64)throw Error(`ui64_rol: invalid number of bits to shift`);let n=Array(16),r;for(r=0;r<8;r++)n[r+8]=0,n[r]=e[r];let i=Math.floor(t/8),a=t%8;for(r=7-i;r>0;r--)n[r+i]=(n[r]<<a|n[r-1]>>>8-a)&255;for(n[0+i]=n[0]<<a&255,r=0+i-1;r>=0;r--)n[r]=0;for(r=0;r<8;r++)e[r]=n[r];return n.slice(8,16)},x=function(e,t){for(let n=0;n<8;n++)e[n]^=t[n]},S=function(e,t){let n=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(n>>16)<<16|n&65535},C=function(e,t){return e<<t&4294967295|e>>>32-t&4294967295},w=function(e,t){function n(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function r(e){return e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514}e[t>>5]|=128<<24-t%32,e[(t+64>>9<<4)+15]=t;let i=Array(80),a=1732584193,o=-271733879,s=-1732584194,c=271733878,l=-1009589776;for(let t=0;t<e.length;t+=16){let u=a,d=o,f=s,p=c,m=l;for(let u=0;u<80;u++){u<16?i[u]=e[t+u]:i[u]=C(i[u-3]^i[u-8]^i[u-14]^i[u-16],1);let d=S(S(C(a,5),n(u,o,s,c)),S(S(l,i[u]),r(u)));l=c,c=s,s=C(o,30),o=a,a=d}a=S(a,u),o=S(o,d),s=S(s,f),c=S(c,p),l=S(l,m)}return[a,o,s,c,l]},T=function(e){return s(w(o(e,{ibits:8,obits:32,obigendian:!0}),e.length*8),{ibits:32,ibigendian:!0})},E=function(e,t){function n(e,t,n,r,i,a){return S(C(S(S(t,e),S(r,a)),i),n)}function r(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function i(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}e[t>>5]|=128<<t%32,e[(t+64>>>9<<4)+14]=t;let s=1732584193,c=-271733879,l=-1732584194,u=271733878;for(let t=0;t<e.length;t+=16){let n=s,d=c,f=l,p=u;s=r(s,c,l,u,e[t+0],7,-680876936),u=r(u,s,c,l,e[t+1],12,-389564586),l=r(l,u,s,c,e[t+2],17,606105819),c=r(c,l,u,s,e[t+3],22,-1044525330),s=r(s,c,l,u,e[t+4],7,-176418897),u=r(u,s,c,l,e[t+5],12,1200080426),l=r(l,u,s,c,e[t+6],17,-1473231341),c=r(c,l,u,s,e[t+7],22,-45705983),s=r(s,c,l,u,e[t+8],7,1770035416),u=r(u,s,c,l,e[t+9],12,-1958414417),l=r(l,u,s,c,e[t+10],17,-42063),c=r(c,l,u,s,e[t+11],22,-1990404162),s=r(s,c,l,u,e[t+12],7,1804603682),u=r(u,s,c,l,e[t+13],12,-40341101),l=r(l,u,s,c,e[t+14],17,-1502002290),c=r(c,l,u,s,e[t+15],22,1236535329),s=i(s,c,l,u,e[t+1],5,-165796510),u=i(u,s,c,l,e[t+6],9,-1069501632),l=i(l,u,s,c,e[t+11],14,643717713),c=i(c,l,u,s,e[t+0],20,-373897302),s=i(s,c,l,u,e[t+5],5,-701558691),u=i(u,s,c,l,e[t+10],9,38016083),l=i(l,u,s,c,e[t+15],14,-660478335),c=i(c,l,u,s,e[t+4],20,-405537848),s=i(s,c,l,u,e[t+9],5,568446438),u=i(u,s,c,l,e[t+14],9,-1019803690),l=i(l,u,s,c,e[t+3],14,-187363961),c=i(c,l,u,s,e[t+8],20,1163531501),s=i(s,c,l,u,e[t+13],5,-1444681467),u=i(u,s,c,l,e[t+2],9,-51403784),l=i(l,u,s,c,e[t+7],14,1735328473),c=i(c,l,u,s,e[t+12],20,-1926607734),s=a(s,c,l,u,e[t+5],4,-378558),u=a(u,s,c,l,e[t+8],11,-2022574463),l=a(l,u,s,c,e[t+11],16,1839030562),c=a(c,l,u,s,e[t+14],23,-35309556),s=a(s,c,l,u,e[t+1],4,-1530992060),u=a(u,s,c,l,e[t+4],11,1272893353),l=a(l,u,s,c,e[t+7],16,-155497632),c=a(c,l,u,s,e[t+10],23,-1094730640),s=a(s,c,l,u,e[t+13],4,681279174),u=a(u,s,c,l,e[t+0],11,-358537222),l=a(l,u,s,c,e[t+3],16,-722521979),c=a(c,l,u,s,e[t+6],23,76029189),s=a(s,c,l,u,e[t+9],4,-640364487),u=a(u,s,c,l,e[t+12],11,-421815835),l=a(l,u,s,c,e[t+15],16,530742520),c=a(c,l,u,s,e[t+2],23,-995338651),s=o(s,c,l,u,e[t+0],6,-198630844),u=o(u,s,c,l,e[t+7],10,1126891415),l=o(l,u,s,c,e[t+14],15,-1416354905),c=o(c,l,u,s,e[t+5],21,-57434055),s=o(s,c,l,u,e[t+12],6,1700485571),u=o(u,s,c,l,e[t+3],10,-1894986606),l=o(l,u,s,c,e[t+10],15,-1051523),c=o(c,l,u,s,e[t+1],21,-2054922799),s=o(s,c,l,u,e[t+8],6,1873313359),u=o(u,s,c,l,e[t+15],10,-30611744),l=o(l,u,s,c,e[t+6],15,-1560198380),c=o(c,l,u,s,e[t+13],21,1309151649),s=o(s,c,l,u,e[t+4],6,-145523070),u=o(u,s,c,l,e[t+11],10,-1120210379),l=o(l,u,s,c,e[t+2],15,718787259),c=o(c,l,u,s,e[t+9],21,-343485551),s=S(s,n),c=S(c,d),l=S(l,f),u=S(u,p)}return[s,c,l,u]},D=function(e){return s(E(o(e,{ibits:8,obits:32,obigendian:!1}),e.length*8),{ibits:32,ibigendian:!1})},O=function(e){this.mul=c(88,81,244,45,76,149,127,45),this.inc=c(20,5,123,126,247,103,129,79),this.mask=c(0,0,0,0,255,255,255,255),this.state=u(this.inc),this.next(),g(this.state,this.mask);let t;e===void 0?typeof window==`object`&&typeof window.crypto==`object`&&typeof window.crypto.getRandomValues==`function`?(t=new Uint32Array(2),window.crypto.getRandomValues(t),e=_(d(t[0]>>>0),y(d(t[1]>>>0),32))):typeof globalThis==`object`&&typeof globalThis.crypto==`object`&&typeof globalThis.crypto.getRandomValues==`function`?(t=new Uint32Array(2),globalThis.crypto.getRandomValues(t),e=_(d(t[0]>>>0),y(d(t[1]>>>0),32))):(e=d(Math.random()*4294967295>>>0),_(e,y(d(new Date().getTime()),32))):e=d(e>>>0),_(this.state,e),this.next()};O.prototype.next=function(){let e=u(this.state);h(this.state,this.mul),p(this.state,this.inc);let t=u(e);y(t,18),x(t,e),y(t,27);let n=u(e);y(n,59),g(t,this.mask);let r=f(n),i=u(t);return b(i,32-r),y(t,r),x(t,i),f(t)},O.prototype.reseed=function(e){if(typeof e!=`string`)throw Error(`UUID: PCG: seed: invalid argument (string expected)`);let t=w(o(e,{ibits:8,obits:32,obigendian:!0}),e.length*8);for(let e=0;e<t.length;e++)x(k.state,d(t[e]>>>0))};let k=new O;O.reseed=function(e){k.reseed(e)};let A=function(e,t){let n=[];for(let r=0;r<e;r++)n[r]=k.next()%t;return n},ee=0,j=0,M=function(){if(arguments.length===1&&typeof arguments[0]==`string`)this.parse.apply(this,arguments);else if(arguments.length>=1&&typeof arguments[0]==`number`)this.make.apply(this,arguments);else if(arguments.length>=1)throw Error(`UUID: constructor: invalid arguments`);else for(let e=0;e<16;e++)this[e]=0};return M.prototype=typeof Uint8Array<`u`?new Uint8Array(16):typeof Buffer<`u`?Buffer.alloc(16):Array(16),M.prototype.constructor=M,M.prototype.make=function(e){let t,n=this;if(e===1){let e=new Date().getTime();e===ee?j++:j=0,ee=e;let r=d(e);m(r,1e4),p(r,c(1,178,29,210,19,129,64,0)),j>0&&p(r,d(j));let i;i=v(r,8),n[3]=i&255,i=v(r,8),n[2]=i&255,i=v(r,8),n[1]=i&255,i=v(r,8),n[0]=i&255,i=v(r,8),n[5]=i&255,i=v(r,8),n[4]=i&255,i=v(r,8),n[7]=i&255,i=v(r,8),n[6]=i&15;let a=A(2,255);n[8]=a[0],n[9]=a[1];let o=A(6,255);for(o[0]|=3,t=0;t<6;t++)n[10+t]=o[t]}else if(e===4){let e=A(16,255);for(t=0;t<16;t++)this[t]=e[t]}else if(e===3||e===5){let r=``,i=typeof arguments[1]==`object`&&arguments[1]instanceof M?arguments[1]:new M().parse(arguments[1]);for(t=0;t<16;t++)r+=String.fromCharCode(i[t]);r+=arguments[2];let a=e===3?D(r):T(r);for(t=0;t<16;t++)n[t]=a.charCodeAt(t)}else throw Error(`UUID: make: invalid version`);return n[6]&=15,n[6]|=e<<4,n[8]&=63,n[8]|=128,n},M.prototype.format=function(t){let n,r;if(t===`z85`)n=i(this,16);else if(t===`b16`)r=Array(32),e(this,0,15,!0,r,0),n=r.join(``);else if(t===void 0||t===`std`)r=Array(36),e(this,0,3,!1,r,0),r[8]=`-`,e(this,4,5,!1,r,9),r[13]=`-`,e(this,6,7,!1,r,14),r[18]=`-`,e(this,8,9,!1,r,19),r[23]=`-`,e(this,10,15,!1,r,24),n=r.join(``);else throw Error(`UUID: format: invalid type argument`);return n},M.prototype.toString=function(e){return this.format(e)},M.prototype.toJSON=function(){return this.format(`std`)},M.prototype.parse=function(e,n){if(typeof e!=`string`)throw Error(`UUID: parse: invalid argument (type string expected)`);if(n===`z85`)a(e,this);else if(n===`b16`)t(e,0,35,this,0);else if(n===void 0||n===`std`){let n={nil:`00000000-0000-0000-0000-000000000000`,"ns:DNS":`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,"ns:URL":`6ba7b811-9dad-11d1-80b4-00c04fd430c8`,"ns:OID":`6ba7b812-9dad-11d1-80b4-00c04fd430c8`,"ns:X500":`6ba7b814-9dad-11d1-80b4-00c04fd430c8`};if(n[e]!==void 0)e=n[e];else if(!e.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/))throw Error(`UUID: parse: invalid string representation (expected "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")`);t(e,0,7,this,0),t(e,9,12,this,4),t(e,14,17,this,6),t(e,19,22,this,8),t(e,24,35,this,10)}return this},M.prototype.export=function(){let e=Array(16);for(let t=0;t<16;t++)e[t]=this[t];return e},M.prototype.import=function(e){if(!(typeof e==`object`&&e instanceof Array))throw Error(`UUID: import: invalid argument (type Array expected)`);if(e.length!==16)throw Error(`UUID: import: invalid argument (Array of length 16 expected)`);for(let t=0;t<16;t++){if(typeof e[t]!=`number`)throw Error(`UUID: import: invalid array element #`+t+` (type Number expected)`);if(!(isFinite(e[t])&&Math.floor(e[t])===e[t]))throw Error(`UUID: import: invalid array element #`+t+` (Number with integer value expected)`);if(!(e[t]>=0&&e[t]<=255))throw Error(`UUID: import: invalid array element #`+t+` (Number with integer value in range 0...255 expected)`);this[t]=e[t]}return this},M.prototype.compare=function(e){if(typeof e!=`object`||!(e instanceof M))throw Error(`UUID: compare: invalid argument (type UUID expected)`);for(let t=0;t<16;t++)if(this[t]<e[t])return-1;else if(this[t]>e[t])return 1;return 0},M.prototype.equal=function(e){return this.compare(e)===0},M.prototype.fold=function(e){if(e===void 0)throw Error(`UUID: fold: invalid argument (number of fold operations expected)`);if(e<1||e>4)throw Error(`UUID: fold: invalid argument (1-4 fold operations expected)`);let t=16/2**e,n=Array(t);for(let e=0;e<t;e++){let r=0;for(let n=0;e+n<16;n+=t)r^=this[e+n];n[e]=r}return n},M.PCG=O,M})}))(),1),Se=e=>e.replace(/[\\"']/g,`\\$&`).replace(/[\r\n\f]/g,` `),Ce=new xe.default(5,`ns:URL`,`https://github.com/rse/gradia`).format(),we=e=>`gradia-${new xe.default(5,Ce,e).format(`b16`).toLowerCase()}`,Te=18,Ee=12,De=2,Oe=(e,t,n)=>{let{nodes:r,cx:i,cy:a,boxW:o,boxH:s}=e,c=r.map(e=>[i(e.id)-o.get(e.id)/2,a(e.id)-s.get(e.id)/2,i(e.id)+o.get(e.id)/2,a(e.id)+s.get(e.id)/2]);for(let t of e.groups??[])c.push([t.x+Te,t.y+Ee,t.x+Te+y(t.name,24),t.y+Ee+24*1.2]);for(let t of e.containers??[])c.push([t.x+Te,t.y+Ee,t.x+Te+y(t.node.name,24),t.y+D(t.node)]);let l=[];e.polys.forEach((e,r)=>{for(let i=0;i<e.length-1;i++){let[a,o]=[e[i],e[i+1]];l.push([Math.min(a[0],o[0])-De,Math.min(a[1],o[1])-De,Math.max(a[0],o[0])+De,Math.max(a[1],o[1])+De]);for(let e of t[r].get(i)??[])l.push([e-n,a[1]-n,e+n,a[1]])}});let u=(e,t)=>e.filter(e=>t[0]<e[2]&&t[2]>e[0]&&t[1]<e[3]&&t[3]>e[1]).length;return{claim:e=>{let t=e[0],n=1/0;for(let r of e){let e=u(c,r)*(l.length+1)+u(l,r);if(e<n&&(t=r,n=e),e===0)break}return c.push(t),t},occupied:c}},ke=(e,t,n,r,i,a)=>{let{cx:o,cy:s,boxW:c,boxH:l,contentH:u}=t,d=c.get(e.id),f=l.get(e.id),p=o(e.id)-d/2,m=s(e.id)-f/2,h=te(e,a),g=M(e),_=[];_.push(`<rect x="${p}" y="${m}" width="${d}" height="${f}" rx="6" style="fill: ${i(n.fill)}; stroke: ${i(n.stroke)}" stroke-width="4.0"${n.dash===void 0?``:` stroke-dasharray="${x(n.dash)}"`}/>`);let v=s(e.id)-u.get(e.id)/2,y=h.type.length*26,b=(h.name.length-1)*34,S=h.attrs.length>0?v+y+28+30*.36:s(e.id)+y/2+30*.36-b/2;return h.type.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${S-36-(h.type.length-1-a)*26}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),h.name.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${S+a*34}" text-anchor="middle" font-size="30" font-weight="600" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),h.attrs.forEach((t,a)=>{_.push(`<text x="${o(e.id)}" y="${v+y+b+56+12+a*30}" text-anchor="middle" font-size="22" style="font-family: ${r}; fill: ${i(n.text)}">${x(t)}</text>`)}),g===void 0?_:[`<a href="${x(g)}" xlink:href="${x(g)}">`,..._,`</a>`]},Ae=(e,t,n)=>{let{polys:r}=e,[i,a,o,s]=[1/0,1/0,-1/0,-1/0];for(let[e,n,r,c]of t)i=Math.min(i,e),a=Math.min(a,n),o=Math.max(o,r),s=Math.max(s,c);for(let e of r)for(let[t,n]of e)i=Math.min(i,t),a=Math.min(a,n),o=Math.max(o,t),s=Math.max(s,n);return Number.isFinite(i)||([i,a,o,s]=[0,0,0,0]),{x:Math.floor(i-n/2),y:Math.floor(a-n/2),w:Math.ceil(o-i+n),h:Math.ceil(s-a+n)}},je=(e,t,n,r,i)=>{let a=`stroke-width="4.5" paint-order="stroke" stroke-linejoin="round"`,o=[];if(e.name!==void 0){let s=y(e.name,16),c=[];for(let e of[.5,.4,.6,.3,.7,.2,.8]){let n=fe(t,e);n.horizontal?(c.push([n.x-s/2,n.y-23,n.x+s/2,n.y-3]),c.push([n.x-s/2,n.y+3,n.x+s/2,n.y+23])):(c.push([n.x+5,n.y-10,n.x+5+s,n.y+10]),c.push([n.x-5-s,n.y-10,n.x-5,n.y+10]))}let l=n(c);o.push(`<text x="${(l[0]+l[2])/2}" y="${l[3]-3}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(`color-edge-name`)}; stroke: ${i(`color-edge-halo`)}" ${a}>${x(e.name)}</text>`)}if(e.arity!==void 0){let s=y(e.arity,16),c=fe(t,1),l=fe(t,.999),u;if(c.horizontal){let e=Math.sign(c.x-l.x)||1,t=c.x-e*(24+s/2);u=[[t-s/2,c.y-17,t+s/2,c.y-4],[t-s/2,c.y+4,t+s/2,c.y+17],[t-s/2-e*14,c.y-17,t+s/2-e*14,c.y-4]]}else{let e=Math.sign(c.y-l.y)||1,t=c.y-e*24;u=[[c.x+6,t-7,c.x+6+s,t+6],[c.x-6-s,t-7,c.x-6,t+6],[c.x+6,t-7-e*14,c.x+6+s,t+6-e*14]]}let d=n(u);o.push(`<text x="${(d[0]+d[2])/2}" y="${d[3]-3}" text-anchor="middle" font-size="16" style="font-family: ${r}; fill: ${i(`color-edge-arity`)}; stroke: ${i(`color-edge-halo`)}" ${a}>${x(e.arity)}</text>`)}return o},Me=(e,t,n)=>[`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="12" style="fill: ${n(`color-group-box`)}; stroke: ${n(`color-group-border`)}" stroke-width="3.0"/>`,`<text x="${e.x+Te}" y="${e.y+Ee+24}" font-size="24" font-weight="600" style="font-family: ${t}; fill: ${n(`color-group-name`)}">${x(e.name)}</text>`],Ne=(e,t,n)=>{let r=w(e.node),i=M(e.node),a=[`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" rx="12" style="fill: ${n(`color-container-box`)}; stroke: ${n(`color-container-border`)}" stroke-width="3.0" stroke-dasharray="10 6"/>`,...r===void 0?[]:[`<text x="${e.x+Te}" y="${e.y+Ee+16}" font-size="16" style="font-family: ${t}; fill: ${n(`color-container-name`)}">${x(r)}</text>`],`<text x="${e.x+Te}" y="${e.y+D(e.node)-34+Ee+24}" font-size="24" font-weight="600" style="font-family: ${t}; fill: ${n(`color-container-name`)}">${x(e.node.name)}</text>`];return i===void 0?a:[`<a href="${x(i)}" xlink:href="${x(i)}">`,...a,`</a>`]},Pe=(e,t,n,r)=>{let{nodes:i,edges:a,polys:o}=e,s=e.groups??[],c=e.containers??[],l=e.styleOf??C,u=e=>x(m(n,e)),d=`${we(r)}-arrow`,{family:f,embed:p,weight:h}=v(t),g=x(`${Object.hasOwn(n,`font-family`)?`'${Se(f)}'`:`var(--gradia-font-family, '${Se(f)}')`}, ui-sans-serif, -apple-system, Helvetica, Arial, sans-serif`),_=le(o),{claim:y,occupied:b}=Oe(e,_,t[`size-edge-hop-radius`]),S=[],w=[];a.forEach((e,n)=>{S.push(`<path d="${de(o[n],_[n],t[`size-edge-corner-radius`],t[`size-edge-hop-radius`])}" fill="none" style="stroke: ${u(`color-edge-line`)}" stroke-width="3.0" marker-end="url(#${d})"/>`),w.push(...je(e,o[n],y,g,u))});let T=i.flatMap(n=>ke(n,e,l(n),g,u,t)),E=s.flatMap(e=>Me(e,g,u)),D=c.flatMap(e=>Ne(e,g,u)),O=s.map(e=>[e.x,e.y,e.x+e.w,e.y+e.h]),k=c.map(e=>[e.x,e.y,e.x+e.w,e.y+e.h]),A=Ae(e,[...b,...O,...k],t[`size-canvas-margin`]);return[`<?xml version="1.0" encoding="UTF-8"?>`,`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="${A.x} ${A.y} ${A.w} ${A.h}" width="${A.w}" height="${A.h}">`,`<defs>`,...p===void 0?[]:[`<style>`,`@font-face { font-family: "${x(Se(f))}"; `+(h===void 0?``:`font-weight: ${x(Se(h))}; `)+`src: url(data:font/woff2;base64,${p}) format("woff2"); }`,`</style>`],`<marker id="${d}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="21" markerHeight="21" markerUnits="userSpaceOnUse" orient="auto-start-reverse">`,`<path d="M 0 1 L 9 5 L 0 9 z" style="fill: ${u(`color-edge-line`)}"/>`,`</marker>`,`</defs>`,...E,...D,...S,...T,...w,`</svg>`,``].join(`
|
|
5
|
+
`)};function Fe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}var Ie={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow},z=class extends Error{constructor(e,t,n){super(e),this.position=t,this.token=n,this.name=`ExpressionError`}},B;(function(e){e[e.STRING=0]=`STRING`,e[e.NUMBER=1]=`NUMBER`,e[e.BOOLEAN=2]=`BOOLEAN`,e[e.NULL=3]=`NULL`,e[e.IDENTIFIER=4]=`IDENTIFIER`,e[e.OPERATOR=5]=`OPERATOR`,e[e.FUNCTION=6]=`FUNCTION`,e[e.DOT=7]=`DOT`,e[e.BRACKET_LEFT=8]=`BRACKET_LEFT`,e[e.BRACKET_RIGHT=9]=`BRACKET_RIGHT`,e[e.PAREN_LEFT=10]=`PAREN_LEFT`,e[e.PAREN_RIGHT=11]=`PAREN_RIGHT`,e[e.COMMA=12]=`COMMA`,e[e.QUESTION=13]=`QUESTION`,e[e.COLON=14]=`COLON`,e[e.DOLLAR=15]=`DOLLAR`})(B||={});var Le=new Set([32,9,10,13]),Re=new Set([43,45,42,47,37,33,38,124,61,60,62]),ze=new Map([[`true`,B.BOOLEAN],[`false`,B.BOOLEAN],[`null`,B.NULL]]),Be=new Map([[`===`,!0],[`!==`,!0],[`<=`,!0],[`>=`,!0],[`&&`,!0],[`||`,!0],[`+`,!0],[`-`,!0],[`*`,!0],[`/`,!0],[`%`,!0],[`!`,!0],[`<`,!0],[`>`,!0]]),Ve=new Map([[46,B.DOT],[91,B.BRACKET_LEFT],[93,B.BRACKET_RIGHT],[40,B.PAREN_LEFT],[41,B.PAREN_RIGHT],[44,B.COMMA],[63,B.QUESTION],[58,B.COLON],[36,B.DOLLAR]]),He=new Map;for(let[e,t]of Ve.entries())He.set(e,{type:t,value:String.fromCharCode(e)});function Ue(e){return e>=48&&e<=57}function We(e){return e>=97&&e<=122||e>=65&&e<=90||e===95}function Ge(e){return We(e)||Ue(e)}function Ke(e){return Re.has(e)}var V;(function(e){e[e.Program=0]=`Program`,e[e.Literal=1]=`Literal`,e[e.Identifier=2]=`Identifier`,e[e.MemberExpression=3]=`MemberExpression`,e[e.CallExpression=4]=`CallExpression`,e[e.BinaryExpression=5]=`BinaryExpression`,e[e.UnaryExpression=6]=`UnaryExpression`,e[e.ConditionalExpression=7]=`ConditionalExpression`})(V||={});var qe=new Map([[`||`,2],[`&&`,3],[`===`,4],[`!==`,4],[`>`,5],[`>=`,5],[`<`,5],[`<=`,5],[`+`,6],[`-`,6],[`*`,7],[`/`,7],[`%`,7],[`!`,8]]),Je={type:V.Literal,value:null},Ye={type:V.Literal,value:!0},Xe={type:V.Literal,value:!1},Ze=e=>{let t=0,n=e.length,r=()=>t>=n?null:e[t],i=()=>e[t++],a=e=>{let t=r();return t!==null&&t.type===e},o=e=>e.type===B.OPERATOR?qe.get(e.value)||-1:e.type===B.DOT||e.type===B.BRACKET_LEFT?9:e.type===B.QUESTION?1:-1,s=e=>{let n,o;if(i().type===B.DOT){if(!a(B.IDENTIFIER)){let e=r();throw new z(`Expected property name`,t,e?e.value:`<end of input>`)}let e=i();n={type:V.Identifier,name:e.value},o=!1}else{if(n=l(0),!a(B.BRACKET_RIGHT)){let e=r();throw new z(`Expected closing bracket`,t,e?e.value:`<end of input>`)}i(),o=!0}return{type:V.MemberExpression,object:e,property:n,computed:o}},c=()=>{let e=r();if(!e)throw new z(`Unexpected end of input`,t,`<end of input>`);if(e.type===B.OPERATOR&&(e.value===`!`||e.value===`-`)){i();let t=c();return{type:V.UnaryExpression,operator:e.value,argument:t,prefix:!0}}switch(e.type){case B.NUMBER:return i(),{type:V.Literal,value:Number(e.value)};case B.STRING:return i(),{type:V.Literal,value:e.value};case B.BOOLEAN:return i(),e.value===`true`?Ye:Xe;case B.NULL:return i(),Je;case B.IDENTIFIER:return i(),{type:V.Identifier,name:e.value};case B.FUNCTION:return(()=>{let e=i(),n=[];if(!a(B.PAREN_LEFT)){let e=r();throw new z(`Expected opening parenthesis after function name`,t,e?e.value:`<end of input>`)}for(i();;){if(a(B.PAREN_RIGHT)){i();break}if(!r()){let e=r();throw new z(`Expected closing parenthesis`,t,e?e.value:`<end of input>`)}if(n.length>0){if(!a(B.COMMA)){let e=r();throw new z(`Expected comma between function arguments`,t,e?e.value:`<end of input>`)}i()}let e=l(0);n.push(e)}return{type:V.CallExpression,callee:{type:V.Identifier,name:e.value},arguments:n}})();case B.PAREN_LEFT:{i();let e=l(0);if(!a(B.PAREN_RIGHT)){let e=r();throw new z(`Expected closing parenthesis`,t,e?e.value:`<end of input>`)}return i(),e}default:throw new z(`Unexpected token: ${e.type}`,t,e.value)}},l=(u=0)=>{let d=c();for(;t<n;){let n=e[t],c=o(n);if(c<=u)break;if(n.type!==B.QUESTION){if(n.type!==B.OPERATOR){if(n.type!==B.DOT&&n.type!==B.BRACKET_LEFT)break;d=s(d)}else{i();let e=l(c);d={type:V.BinaryExpression,operator:n.value,left:d,right:e}}}else{i();let e=l(0);if(!a(B.COLON)){let e=r();throw new z(`Expected : in conditional expression`,t,e?e.value:`<end of input>`)}i();let n=l(0);d={type:V.ConditionalExpression,test:d,consequent:e,alternate:n}}}return d},u=l();return{type:V.Program,body:u}},Qe=(e,t,n)=>{let r=t;n&&(r={...t,context:{...t.context,...n}});let i=e=>{switch(e.type){case V.Literal:return(e=>e.value)(e);case V.Identifier:return(e=>{if(!(e.name in r.context))throw new z(`Undefined variable: ${e.name}`);return r.context[e.name]})(e);case V.MemberExpression:return(e=>{let t=i(e.object);if(t==null)throw new z(`Cannot access property of null or undefined`);return t[e.computed?i(e.property):e.property.name]})(e);case V.CallExpression:return(e=>{let t=r.functions[e.callee.name];if(!t)throw new z(`Undefined function: ${e.callee.name}`);return t(...e.arguments.map((e=>i(e))))})(e);case V.BinaryExpression:return(e=>{if(e.operator===`&&`)return i(e.left)&&i(e.right);if(e.operator===`||`)return i(e.left)||i(e.right);let t=i(e.left),n=i(e.right);switch(e.operator){case`+`:return t+n;case`-`:return t-n;case`*`:return t*n;case`/`:return t/n;case`%`:return t%n;case`===`:return t===n;case`!==`:return t!==n;case`>`:return t>n;case`>=`:return t>=n;case`<`:return t<n;case`<=`:return t<=n;default:throw new z(`Unknown operator: ${e.operator}`)}})(e);case V.UnaryExpression:return(e=>{let t=i(e.argument);if(e.prefix)switch(e.operator){case`!`:return!t;case`-`:if(typeof t!=`number`)throw new z(`Cannot apply unary - to non-number: ${t}`);return-t;default:throw new z(`Unknown operator: ${e.operator}`)}throw new z(`Postfix operators are not supported: ${e.operator}`)})(e);case V.ConditionalExpression:return(e=>{let t=i(e.test);return i(t?e.consequent:e.alternate)})(e);default:throw new z(`Evaluation error: Unsupported node type: ${e.type}`)}};return i(e.body)};function $e(e){let t=Ze((e=>{let t=e,n=t.length,r=Array(Math.ceil(n/3)),i=0,a=0;function o(e){let r=a+1;a++;let i=``,o=!1;for(;a<n;){let n=t.charCodeAt(a);if(n===e)return o||(i=t.substring(r,a)),a++,{type:B.STRING,value:i};n===92?(o||=(i=t.substring(r,a),!0),a++,i+=t[a]):o&&(i+=t[a]),a++}throw new z(`Unterminated string starting with ${String.fromCharCode(e)}`,a,t.substring(Math.max(0,a-10),a))}function s(){let e=a;for(t.charCodeAt(a)===45&&a++;a<n&&Ue(t.charCodeAt(a));)a++;if(a<n&&t.charCodeAt(a)===46)for(a++;a<n&&Ue(t.charCodeAt(a));)a++;let r=t.slice(e,a);return{type:B.NUMBER,value:r}}function c(){a++;let e=a;if(a<n&&We(t.charCodeAt(a)))for(a++;a<n&&Ge(t.charCodeAt(a));)a++;let r=t.slice(e,a);return{type:B.FUNCTION,value:r}}function l(){let e=a++;for(;a<n&&Ge(t.charCodeAt(a));)a++;let r=t.slice(e,a),i=ze.get(r);return i?{type:i,value:r}:{type:B.IDENTIFIER,value:r}}function u(){if(a+2<n){let e=t.substring(a,a+3);if(Be.has(e))return a+=3,{type:B.OPERATOR,value:e}}if(a+1<n){let e=t.substring(a,a+2);if(Be.has(e))return a+=2,{type:B.OPERATOR,value:e}}let e=t[a];if(Be.has(e))return a++,{type:B.OPERATOR,value:e};throw new z(`Unknown operator at position ${a}: ${t.substring(a,a+1)}`,a,t.substring(Math.max(0,a-10),a))}for(;a<n;){let e=t.charCodeAt(a);if(d=e,Le.has(d)){a++;continue}let f=He.get(e);if(f)r[i++]=f,a++;else if(e!==34&&e!==39){if(Ue(e)||e===45&&a+1<n&&Ue(t.charCodeAt(a+1)))r[i++]=s();else if(e!==64){if(We(e))r[i++]=l();else{if(!Ke(e))throw new z(`Unexpected character: ${t[a]}`,a,t.substring(Math.max(0,a-10),a));r[i++]=u()}}else r[i++]=c()}else r[i++]=o(e)}var d;return i===r.length?r:r.slice(0,i)})(e)),n=((e={},t={})=>({context:e,functions:t}))({},Ie);return(e={})=>Qe(t,n,e)}function et(e,t={}){return $e(e)(t)}function tt(e,t){if(typeof e!=`string`)return;let n=e.trim();if(n)try{return $e(n),et(n,t)}catch{return}}function nt(e){return typeof e==`number`}function rt(e){if(!e)return[0,0,0];if(nt(e))return[e,e,e];if(Array.isArray(e)&&e.length===0)return[0,0,0];let[t,n=t,r=t]=e;return[t,n,r]}function it(e){return nt(e)?!0:Array.isArray(e)?e.every(e=>nt(e)):!1}function H(e){return e==null}function at(e){return typeof e==`string`}function ot(e){return typeof e==`function`}function st(e,t){if(typeof e==`function`)return e;if(typeof e==`string`){let n=e;return(...e)=>{let r={};for(let n=0;n<t.length;n++)r[t[n]]=e[n];return tt(n,r)}}return()=>e}function ct(e,t,n=`node`){if(H(e))return()=>t;if(at(e)){let r=st(e,[n]);return e=>{let n=r(e);return nt(n)?n:t}}return ot(e)?e:nt(e)?()=>e:()=>t}function lt(e,t=10,n=`node`){if(H(e))return()=>t;if(at(e)){let r=st(e,[n]);return e=>{let n=r(e);return it(n)?n:t}}return ot(e)?e:nt(e)||Array.isArray(e)?()=>e:()=>t}function ut(e){return[e.x,e.y,e.z??0]}var dt=class{constructor(e,t={}){this.edgeIdCounter=new Map,this.nodeMap=mt(e.nodes,t.node),this.edgeMap=ht(e.edges||[],t.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(e){this.nodeMap=e.nodes,this.edgeMap=e.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(e){return this.nodeMap.get(e)}nodeAt(e){this.indexNodeCache||this.buildNodeIndexCache();let t=this.indexNodeCache.get(e);return t?this.nodeMap.get(t):void 0}nodeIndexOf(e){return this.nodeIndexCache||this.buildNodeIndexCache(),this.nodeIndexCache.get(e)??-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(e){let t=0;this.nodeMap.forEach(n=>e(n,t++))}originalNode(e){return this.nodeMap.get(e)?._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(e){return this.edgeMap.get(e)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(e){let t=0;this.edgeMap.forEach(n=>e(n,t++))}originalEdge(e){return this.edgeMap.get(e)?._original}edgeCount(){return this.edgeMap.size}getEdgeId(e){if(e.id)return e.id;let t=`${e.source}-${e.target}`,n=this.edgeIdCounter.get(t)||0,r=n===0?t:`${t}-${n}`;return this.edgeIdCounter.set(t,n+1),r}degree(e,t=`both`){this.degreeCache||this.buildDegreeCache();let n=this.degreeCache.get(e);return n?n[t]:0}neighbors(e,t=`both`){if((!this.outAdjacencyCache||!this.inAdjacencyCache)&&this.buildAdjacencyCache(),t===`out`)return Array.from(this.outAdjacencyCache.get(e)||[]);if(t===`in`)return Array.from(this.inAdjacencyCache.get(e)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(e)||[]);let n=this.inAdjacencyCache.get(e),r=this.outAdjacencyCache.get(e);if(!n&&!r)return[];if(!n)return Array.from(r);if(!r)return Array.from(n);let i=new Set;return n.forEach(e=>i.add(e)),r.forEach(e=>i.add(e)),Array.from(i)}successors(e){return this.neighbors(e,`out`)}predecessors(e){return this.neighbors(e,`in`)}setNodeOrder(e){let t=new Map;for(let n of e)t.set(n.id,n);this.nodeMap=t,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(let e of this.edges()){let{source:t,target:n}=e;if(e.source===e.target)continue;this.degreeCache.has(t)||this.degreeCache.set(t,{in:0,out:0,both:0});let r=this.degreeCache.get(e.source);r&&(r.out++,r.both++),this.degreeCache.has(n)||this.degreeCache.set(n,{in:0,out:0,both:0});let i=this.degreeCache.get(e.target);i&&(i.in++,i.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(let e of this.edges())!this.nodeMap.has(e.source)||!this.nodeMap.has(e.target)||(this.outAdjacencyCache.has(e.source)||this.outAdjacencyCache.set(e.source,new Set),this.outAdjacencyCache.get(e.source).add(e.target),this.inAdjacencyCache.has(e.target)||this.inAdjacencyCache.set(e.target,new Set),this.inAdjacencyCache.get(e.target).add(e.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let e=0;this.nodeMap.forEach((t,n)=>{this.nodeIndexCache.set(n,e),this.indexNodeCache.set(e,n),e++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}},ft=[`id`,`x`,`y`,`z`,`vx`,`vy`,`vz`,`fx`,`fy`,`fz`,`parentId`],pt=[`id`,`source`,`target`,`points`];function mt(e,t){if(!e)throw Error(`Data.nodes is required`);let n=new Map;for(let r of e){let e={_original:r};for(let t of ft){let n=r[t];H(n)||(e[t]=n)}if(t){let n=t(r);for(let t in n){let r=n[t];H(r)||(e[t]=r)}}if(H(e.id))throw Error(`Node is missing id field`);n.set(e.id,e)}return n}function ht(e,t,n){let r=new Map;for(let i of e){let e={_original:i};for(let t of pt){let n=i[t];H(n)||(e[t]=n)}if(t){let n=t(i);for(let t in n){let r=n[t];H(r)||(e[t]=r)}}if(H(e.source)||H(e.target))throw Error(`Edge is missing source or target field`);H(e.id)&&(e.id=n?.(i)),r.set(e.id,e)}return r}var gt=class{constructor(e,t={}){this.graph=new dt(e,t)}export(){return this.graph.data()}replace(e){this.graph.replace(e)}forEachNode(e){this.graph.forEachNode(e)}forEachEdge(e){this.graph.forEachEdge((t,n)=>{t.sourceNode=this.graph.node(t.source),t.targetNode=this.graph.node(t.target),e(t,n)})}destroy(){this.graph.destroy()}},_t=Symbol(`Comlink.proxy`),vt=Symbol(`Comlink.endpoint`),yt=Symbol(`Comlink.releaseProxy`),bt=Symbol(`Comlink.finalizer`),xt=Symbol(`Comlink.thrown`),St=e=>typeof e==`object`&&!!e||typeof e==`function`,Ct=new Map([[`proxy`,{canHandle:e=>St(e)&&e[_t],serialize(e){let{port1:t,port2:n}=new MessageChannel;return Tt(e,t),[n,[n]]},deserialize(e){return e.start(),Ot(e)}}],[`throw`,{canHandle:e=>St(e)&&xt in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function wt(e,t){for(let n of e)if(t===n||n===`*`||n instanceof RegExp&&n.test(t))return!0;return!1}function Tt(e,t=globalThis,n=[`*`]){t.addEventListener(`message`,function r(i){if(!i||!i.data)return;if(!wt(n,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}let{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(Ht),l;try{let t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(o){case`GET`:l=n;break;case`SET`:t[s.slice(-1)[0]]=Ht(i.data.value),l=!0;break;case`APPLY`:l=n.apply(t,c);break;case`CONSTRUCT`:l=Bt(new n(...c));break;case`ENDPOINT`:{let{port1:t,port2:n}=new MessageChannel;Tt(e,n),l=zt(t,[t])}break;case`RELEASE`:l=void 0;break;default:return}}catch(e){l={value:e,[xt]:0}}Promise.resolve(l).catch(e=>({value:e,[xt]:0})).then(n=>{let[i,s]=Vt(n);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),o===`RELEASE`&&(t.removeEventListener(`message`,r),Dt(t),bt in e&&typeof e[bt]==`function`&&e[bt]())}).catch(e=>{let[n,r]=Vt({value:TypeError(`Unserializable return value`),[xt]:0});t.postMessage(Object.assign(Object.assign({},n),{id:a}),r)})}),t.start&&t.start()}function Et(e){return e.constructor.name===`MessagePort`}function Dt(e){Et(e)&&e.close()}function Ot(e,t){let n=new Map;return e.addEventListener(`message`,function(e){let{data:t}=e;if(!t||!t.id)return;let r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),Ft(e,n,[],t)}function kt(e){if(e)throw Error(`Proxy has been released and is not useable`)}function At(e){return Ut(e,new Map,{type:`RELEASE`}).then(()=>{Dt(e)})}var jt=new WeakMap,Mt=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(jt.get(e)||0)-1;jt.set(e,t),t===0&&At(e)});function Nt(e,t){let n=(jt.get(t)||0)+1;jt.set(t,n),Mt&&Mt.register(e,t,e)}function Pt(e){Mt&&Mt.unregister(e)}function Ft(e,t,n=[],r=function(){}){let i=!1,a=new Proxy(r,{get(r,o){if(kt(i),o===yt)return()=>{Pt(a),At(e),t.clear(),i=!0};if(o===`then`){if(n.length===0)return{then:()=>a};let r=Ut(e,t,{type:`GET`,path:n.map(e=>e.toString())}).then(Ht);return r.then.bind(r)}return Ft(e,t,[...n,o])},set(r,a,o){kt(i);let[s,c]=Vt(o);return Ut(e,t,{type:`SET`,path:[...n,a].map(e=>e.toString()),value:s},c).then(Ht)},apply(r,a,o){kt(i);let s=n[n.length-1];if(s===vt)return Ut(e,t,{type:`ENDPOINT`}).then(Ht);if(s===`bind`)return Ft(e,t,n.slice(0,-1));let[c,l]=Lt(o);return Ut(e,t,{type:`APPLY`,path:n.map(e=>e.toString()),argumentList:c},l).then(Ht)},construct(r,a){kt(i);let[o,s]=Lt(a);return Ut(e,t,{type:`CONSTRUCT`,path:n.map(e=>e.toString()),argumentList:o},s).then(Ht)}});return Nt(a,e),a}function It(e){return Array.prototype.concat.apply([],e)}function Lt(e){let t=e.map(Vt);return[t.map(e=>e[0]),It(t.map(e=>e[1]))]}var Rt=new WeakMap;function zt(e,t){return Rt.set(e,t),e}function Bt(e){return Object.assign(e,{[_t]:!0})}function Vt(e){for(let[t,n]of Ct)if(n.canHandle(e)){let[r,i]=n.serialize(e);return[{type:`HANDLER`,name:t,value:r},i]}return[{type:`RAW`,value:e},Rt.get(e)||[]]}function Ht(e){switch(e.type){case`HANDLER`:return Ct.get(e.name).deserialize(e.value);case`RAW`:return e.value}}function Ut(e,t,n,r){return new Promise(i=>{let a=Wt();t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},n),r)})}function Wt(){return[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)}var Gt=class{constructor(){this.worker=null,this.workerApi=null}execute(e,t,n){return Fe(this,void 0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw Error(`Worker API not initialized`);return yield this.workerApi.execute(e,t,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return Fe(this,void 0,void 0,function*(){let e=this.resolveWorkerPath(),t=e.includes(`/lib/`)||e.endsWith(`.mjs`)?`module`:`classic`;this.worker=new Worker(e,{type:t}),this.workerApi=Ot(this.worker)})}resolveWorkerPath(){let e=(()=>{if(typeof document>`u`)return null;let e=document.currentScript;if(e?.src)return e.src;let t=document.getElementsByTagName(`script`);for(let e=t.length-1;e>=0;e--){let n=t[e].src;if(n&&(n.includes(`index.js`)||n.includes(`index.min.js`)))return n}return null})();if(e){if(e.includes(`index.js`)||e.includes(`index.min.js`)){let t=e.replace(/index(\.min)?\.(m?js)(\?.*)?$/,`worker.js`);if(t!==e)return t}let t=e.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,`/worker.js`);if(t!==e)return t;let n=e.replace(/\/[^/]+\.(m?js)(\?.*)?$/,`/worker.js`);if(n!==e)return n}return`./worker.js`}},Kt=class{constructor(e){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),e)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(e,t){return Object.assign({},e,t||{})}execute(e,t){return Fe(this,void 0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,t);let{node:n,edge:r,enableWorker:i}=this.runtimeOptions;this.context=new gt(e,{node:n,edge:r}),this.model=this.context.graph,i&&typeof Worker<`u`?yield this.layoutInWorker(e,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(e,t){var n;return Fe(this,void 0,void 0,function*(){try{this.supervisor||=new Gt;let r=yield this.supervisor.execute(this.id,e,t);(n=this.context)==null||n.replace(r)}catch(e){console.error(`Layout in worker failed, fallback to main thread layout.`,e),yield this.layout(t)}})}forEachNode(e){this.context.forEachNode(e)}forEachEdge(e){this.context.forEachEdge(e)}destroy(){var e;(e=this.context)==null||e.destroy(),this.model=null,this.context=null,this.supervisor&&=(this.supervisor.destroy(),null)}};function qt(e){return Array.isArray(e)}var Jt=(function(e){var t=typeof e;return e!==null&&t===`object`||t===`function`}),Yt=function(e){return typeof e==`object`&&!!e},Xt={}.toString,Zt=function(e,t){return Xt.call(e)===`[object `+t+`]`},Qt=function(e){if(!Yt(e)||!Zt(e,`Object`))return!1;if(Object.getPrototypeOf(e)===null)return!0;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},$t=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function en(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function tn(e){throw Error(`Could not dynamically require "`+e+`". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.`)}var nn,rn;function an(){if(rn)return nn;rn=1;function e(){this.__data__=[],this.size=0}return nn=e,nn}var on,sn;function cn(){if(sn)return on;sn=1;function e(e,t){return e===t||e!==e&&t!==t}return on=e,on}var ln,un;function dn(){if(un)return ln;un=1;var e=cn();function t(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}return ln=t,ln}var fn,pn;function mn(){if(pn)return fn;pn=1;var e=dn(),t=Array.prototype.splice;function n(n){var r=this.__data__,i=e(r,n);return i<0?!1:(i==r.length-1?r.pop():t.call(r,i,1),--this.size,!0)}return fn=n,fn}var hn,gn;function _n(){if(gn)return hn;gn=1;var e=dn();function t(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}return hn=t,hn}var vn,yn;function bn(){if(yn)return vn;yn=1;var e=dn();function t(t){return e(this.__data__,t)>-1}return vn=t,vn}var xn,Sn;function Cn(){if(Sn)return xn;Sn=1;var e=dn();function t(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this}return xn=t,xn}var wn,Tn;function En(){if(Tn)return wn;Tn=1;var e=an(),t=mn(),n=_n(),r=bn(),i=Cn();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,wn=a,wn}var Dn,On;function kn(){if(On)return Dn;On=1;var e=En();function t(){this.__data__=new e,this.size=0}return Dn=t,Dn}var An,jn;function Mn(){if(jn)return An;jn=1;function e(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}return An=e,An}var Nn,Pn;function Fn(){if(Pn)return Nn;Pn=1;function e(e){return this.__data__.get(e)}return Nn=e,Nn}var In,Ln;function Rn(){if(Ln)return In;Ln=1;function e(e){return this.__data__.has(e)}return In=e,In}var zn,Bn;function Vn(){return Bn?zn:(Bn=1,zn=typeof $t==`object`&&$t&&$t.Object===Object&&$t,zn)}var Hn,Un;function U(){if(Un)return Hn;Un=1;var e=Vn(),t=typeof self==`object`&&self&&self.Object===Object&&self;return Hn=e||t||Function(`return this`)(),Hn}var Wn,Gn;function Kn(){return Gn?Wn:(Gn=1,Wn=U().Symbol,Wn)}var qn,Jn;function Yn(){if(Jn)return qn;Jn=1;var e=Kn(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(e){var t=n.call(e,i),a=e[i];try{e[i]=void 0;var o=!0}catch{}var s=r.call(e);return o&&(t?e[i]=a:delete e[i]),s}return qn=a,qn}var Xn,Zn;function Qn(){if(Zn)return Xn;Zn=1;var e=Object.prototype.toString;function t(t){return e.call(t)}return Xn=t,Xn}var $n,er;function tr(){if(er)return $n;er=1;var e=Kn(),t=Yn(),n=Qn(),r=`[object Null]`,i=`[object Undefined]`,a=e?e.toStringTag:void 0;function o(e){return e==null?e===void 0?i:r:a&&a in Object(e)?t(e):n(e)}return $n=o,$n}var nr,rr;function W(){if(rr)return nr;rr=1;function e(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}return nr=e,nr}var ir,ar;function or(){if(ar)return ir;ar=1;var e=tr(),t=W(),n=`[object AsyncFunction]`,r=`[object Function]`,i=`[object GeneratorFunction]`,a=`[object Proxy]`;function o(o){if(!t(o))return!1;var s=e(o);return s==r||s==i||s==n||s==a}return ir=o,ir}var sr,cr;function lr(){return cr?sr:(cr=1,sr=U()[`__core-js_shared__`],sr)}var ur,dr;function fr(){if(dr)return ur;dr=1;var e=lr(),t=function(){var t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||``);return t?`Symbol(src)_1.`+t:``}();function n(e){return!!t&&t in e}return ur=n,ur}var pr,mr;function hr(){if(mr)return pr;mr=1;var e=Function.prototype.toString;function t(t){if(t!=null){try{return e.call(t)}catch{}try{return t+``}catch{}}return``}return pr=t,pr}var gr,_r;function vr(){if(_r)return gr;_r=1;var e=or(),t=fr(),n=W(),r=hr(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=RegExp(`^`+c.call(l).replace(i,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function d(i){return!n(i)||t(i)?!1:(e(i)?u:a).test(r(i))}return gr=d,gr}var yr,br;function xr(){if(br)return yr;br=1;function e(e,t){return e?.[t]}return yr=e,yr}var Sr,Cr;function wr(){if(Cr)return Sr;Cr=1;var e=vr(),t=xr();function n(n,r){var i=t(n,r);return e(i)?i:void 0}return Sr=n,Sr}var Tr,Er;function Dr(){return Er?Tr:(Er=1,Tr=wr()(U(),`Map`),Tr)}var Or,kr;function Ar(){return kr?Or:(kr=1,Or=wr()(Object,`create`),Or)}var jr,Mr;function Nr(){if(Mr)return jr;Mr=1;var e=Ar();function t(){this.__data__=e?e(null):{},this.size=0}return jr=t,jr}var Pr,Fr;function Ir(){if(Fr)return Pr;Fr=1;function e(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}return Pr=e,Pr}var Lr,Rr;function zr(){if(Rr)return Lr;Rr=1;var e=Ar(),t=`__lodash_hash_undefined__`,n=Object.prototype.hasOwnProperty;function r(r){var i=this.__data__;if(e){var a=i[r];return a===t?void 0:a}return n.call(i,r)?i[r]:void 0}return Lr=r,Lr}var Br,Vr;function Hr(){if(Vr)return Br;Vr=1;var e=Ar(),t=Object.prototype.hasOwnProperty;function n(n){var r=this.__data__;return e?r[n]!==void 0:t.call(r,n)}return Br=n,Br}var Ur,Wr;function Gr(){if(Wr)return Ur;Wr=1;var e=Ar(),t=`__lodash_hash_undefined__`;function n(n,r){var i=this.__data__;return this.size+=+!this.has(n),i[n]=e&&r===void 0?t:r,this}return Ur=n,Ur}var Kr,qr;function Jr(){if(qr)return Kr;qr=1;var e=Nr(),t=Ir(),n=zr(),r=Hr(),i=Gr();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,Kr=a,Kr}var Yr,Xr;function Zr(){if(Xr)return Yr;Xr=1;var e=Jr(),t=En(),n=Dr();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Yr=r,Yr}var Qr,$r;function ei(){if($r)return Qr;$r=1;function e(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}return Qr=e,Qr}var ti,ni;function ri(){if(ni)return ti;ni=1;var e=ei();function t(t,n){var r=t.__data__;return e(n)?r[typeof n==`string`?`string`:`hash`]:r.map}return ti=t,ti}var ii,ai;function oi(){if(ai)return ii;ai=1;var e=ri();function t(t){var n=e(this,t).delete(t);return this.size-=+!!n,n}return ii=t,ii}var si,ci;function li(){if(ci)return si;ci=1;var e=ri();function t(t){return e(this,t).get(t)}return si=t,si}var ui,di;function fi(){if(di)return ui;di=1;var e=ri();function t(t){return e(this,t).has(t)}return ui=t,ui}var pi,mi;function hi(){if(mi)return pi;mi=1;var e=ri();function t(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this}return pi=t,pi}var gi,_i;function vi(){if(_i)return gi;_i=1;var e=Zr(),t=oi(),n=li(),r=fi(),i=hi();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,gi=a,gi}var yi,bi;function xi(){if(bi)return yi;bi=1;var e=En(),t=Dr(),n=vi(),r=200;function i(i,a){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<r-1)return s.push([i,a]),this.size=++o.size,this;o=this.__data__=new n(s)}return o.set(i,a),this.size=o.size,this}return yi=i,yi}var Si,Ci;function wi(){if(Ci)return Si;Ci=1;var e=En(),t=kn(),n=Mn(),r=Fn(),i=Rn(),a=xi();function o(t){var n=this.__data__=new e(t);this.size=n.size}return o.prototype.clear=t,o.prototype.delete=n,o.prototype.get=r,o.prototype.has=i,o.prototype.set=a,Si=o,Si}var Ti,Ei;function Di(){if(Ei)return Ti;Ei=1;function e(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}return Ti=e,Ti}var Oi,ki;function Ai(){if(ki)return Oi;ki=1;var e=wr();return Oi=function(){try{var t=e(Object,`defineProperty`);return t({},``,{}),t}catch{}}(),Oi}var ji,Mi;function Ni(){if(Mi)return ji;Mi=1;var e=Ai();function t(t,n,r){n==`__proto__`&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}return ji=t,ji}var Pi,Fi;function Ii(){if(Fi)return Pi;Fi=1;var e=Ni(),t=cn(),n=Object.prototype.hasOwnProperty;function r(r,i,a){var o=r[i];(!(n.call(r,i)&&t(o,a))||a===void 0&&!(i in r))&&e(r,i,a)}return Pi=r,Pi}var Li,Ri;function zi(){if(Ri)return Li;Ri=1;var e=Ii(),t=Ni();function n(n,r,i,a){var o=!i;i||={};for(var s=-1,c=r.length;++s<c;){var l=r[s],u=a?a(i[l],n[l],l,i,n):void 0;u===void 0&&(u=n[l]),o?t(i,l,u):e(i,l,u)}return i}return Li=n,Li}var Bi,Vi;function Hi(){if(Vi)return Bi;Vi=1;function e(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}return Bi=e,Bi}var Ui,Wi;function G(){if(Wi)return Ui;Wi=1;function e(e){return typeof e==`object`&&!!e}return Ui=e,Ui}var Gi,Ki;function qi(){if(Ki)return Gi;Ki=1;var e=tr(),t=G(),n=`[object Arguments]`;function r(r){return t(r)&&e(r)==n}return Gi=r,Gi}var Ji,Yi;function Xi(){if(Yi)return Ji;Yi=1;var e=qi(),t=G(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable;return Ji=e(function(){return arguments}())?e:function(e){return t(e)&&r.call(e,`callee`)&&!i.call(e,`callee`)},Ji}var Zi,Qi;function K(){return Qi?Zi:(Qi=1,Zi=Array.isArray,Zi)}var $i={exports:{}},ea,ta;function na(){if(ta)return ea;ta=1;function e(){return!1}return ea=e,ea}$i.exports;var ra;function ia(){return ra?$i.exports:(ra=1,(function(e,t){var n=U(),r=na(),i=t&&!t.nodeType&&t,a=i&&e&&!e.nodeType&&e,o=a&&a.exports===i?n.Buffer:void 0;e.exports=(o?o.isBuffer:void 0)||r})($i,$i.exports),$i.exports)}var aa,oa;function sa(){if(oa)return aa;oa=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(n,r){var i=typeof n;return r??=e,!!r&&(i==`number`||i!=`symbol`&&t.test(n))&&n>-1&&n%1==0&&n<r}return aa=n,aa}var ca,la;function ua(){if(la)return ca;la=1;var e=9007199254740991;function t(t){return typeof t==`number`&&t>-1&&t%1==0&&t<=e}return ca=t,ca}var da,fa;function pa(){if(fa)return da;fa=1;var e=tr(),t=ua(),n=G(),r=`[object Arguments]`,i=`[object Array]`,a=`[object Boolean]`,o=`[object Date]`,s=`[object Error]`,c=`[object Function]`,l=`[object Map]`,u=`[object Number]`,d=`[object Object]`,f=`[object RegExp]`,p=`[object Set]`,m=`[object String]`,h=`[object WeakMap]`,g=`[object ArrayBuffer]`,_=`[object DataView]`,v=`[object Float32Array]`,y=`[object Float64Array]`,b=`[object Int8Array]`,x=`[object Int16Array]`,S=`[object Int32Array]`,C=`[object Uint8Array]`,w=`[object Uint8ClampedArray]`,T=`[object Uint16Array]`,E=`[object Uint32Array]`,D={};D[v]=D[y]=D[b]=D[x]=D[S]=D[C]=D[w]=D[T]=D[E]=!0,D[r]=D[i]=D[g]=D[a]=D[_]=D[o]=D[s]=D[c]=D[l]=D[u]=D[d]=D[f]=D[p]=D[m]=D[h]=!1;function O(r){return n(r)&&t(r.length)&&!!D[e(r)]}return da=O,da}var ma,ha;function ga(){if(ha)return ma;ha=1;function e(e){return function(t){return e(t)}}return ma=e,ma}var _a={exports:{}};_a.exports;var va;function ya(){return va?_a.exports:(va=1,(function(e,t){var n=Vn(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,a=i&&i.exports===r&&n.process;e.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})(_a,_a.exports),_a.exports)}var ba,xa;function Sa(){if(xa)return ba;xa=1;var e=pa(),t=ga(),n=ya(),r=n&&n.isTypedArray;return ba=r?t(r):e,ba}var Ca,wa;function Ta(){if(wa)return Ca;wa=1;var e=Hi(),t=Xi(),n=K(),r=ia(),i=sa(),a=Sa(),o=Object.prototype.hasOwnProperty;function s(s,c){var l=n(s),u=!l&&t(s),d=!l&&!u&&r(s),f=!l&&!u&&!d&&a(s),p=l||u||d||f,m=p?e(s.length,String):[],h=m.length;for(var g in s)(c||o.call(s,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||i(g,h)))&&m.push(g);return m}return Ca=s,Ca}var Ea,Da;function Oa(){if(Da)return Ea;Da=1;var e=Object.prototype;function t(t){var n=t&&t.constructor;return t===(typeof n==`function`&&n.prototype||e)}return Ea=t,Ea}var ka,Aa;function ja(){if(Aa)return ka;Aa=1;function e(e,t){return function(n){return e(t(n))}}return ka=e,ka}var Ma,Na;function Pa(){return Na?Ma:(Na=1,Ma=ja()(Object.keys,Object),Ma)}var Fa,Ia;function La(){if(Ia)return Fa;Ia=1;var e=Oa(),t=Pa(),n=Object.prototype.hasOwnProperty;function r(r){if(!e(r))return t(r);var i=[];for(var a in Object(r))n.call(r,a)&&a!=`constructor`&&i.push(a);return i}return Fa=r,Fa}var Ra,za;function q(){if(za)return Ra;za=1;var e=or(),t=ua();function n(n){return n!=null&&t(n.length)&&!e(n)}return Ra=n,Ra}var Ba,Va;function J(){if(Va)return Ba;Va=1;var e=Ta(),t=La(),n=q();function r(r){return n(r)?e(r):t(r)}return Ba=r,Ba}var Ha,Ua;function Wa(){if(Ua)return Ha;Ua=1;var e=zi(),t=J();function n(n,r){return n&&e(r,t(r),n)}return Ha=n,Ha}var Ga,Ka;function qa(){if(Ka)return Ga;Ka=1;function e(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return Ga=e,Ga}var Ja,Ya;function Xa(){if(Ya)return Ja;Ya=1;var e=W(),t=Oa(),n=qa(),r=Object.prototype.hasOwnProperty;function i(i){if(!e(i))return n(i);var a=t(i),o=[];for(var s in i)s==`constructor`&&(a||!r.call(i,s))||o.push(s);return o}return Ja=i,Ja}var Za,Qa;function $a(){if(Qa)return Za;Qa=1;var e=Ta(),t=Xa(),n=q();function r(r){return n(r)?e(r,!0):t(r)}return Za=r,Za}var eo,to;function no(){if(to)return eo;to=1;var e=zi(),t=$a();function n(n,r){return n&&e(r,t(r),n)}return eo=n,eo}var ro={exports:{}};ro.exports;var io;function ao(){return io?ro.exports:(io=1,(function(e,t){var n=U(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,a=i&&i.exports===r?n.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}e.exports=s})(ro,ro.exports),ro.exports)}var oo,so;function co(){if(so)return oo;so=1;function e(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}return oo=e,oo}var lo,uo;function fo(){if(uo)return lo;uo=1;function e(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}return lo=e,lo}var po,mo;function ho(){if(mo)return po;mo=1;function e(){return[]}return po=e,po}var go,_o;function vo(){if(_o)return go;_o=1;var e=fo(),t=ho(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return go=r?function(t){return t==null?[]:(t=Object(t),e(r(t),function(e){return n.call(t,e)}))}:t,go}var yo,bo;function xo(){if(bo)return yo;bo=1;var e=zi(),t=vo();function n(n,r){return e(n,t(n),r)}return yo=n,yo}var So,Co;function wo(){if(Co)return So;Co=1;function e(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}return So=e,So}var To,Eo;function Do(){return Eo?To:(Eo=1,To=ja()(Object.getPrototypeOf,Object),To)}var Oo,ko;function Ao(){if(ko)return Oo;ko=1;var e=wo(),t=Do(),n=vo(),r=ho();return Oo=Object.getOwnPropertySymbols?function(r){for(var i=[];r;)e(i,n(r)),r=t(r);return i}:r,Oo}var jo,Mo;function No(){if(Mo)return jo;Mo=1;var e=zi(),t=Ao();function n(n,r){return e(n,t(n),r)}return jo=n,jo}var Po,Fo;function Io(){if(Fo)return Po;Fo=1;var e=wo(),t=K();function n(n,r,i){var a=r(n);return t(n)?a:e(a,i(n))}return Po=n,Po}var Lo,Ro;function zo(){if(Ro)return Lo;Ro=1;var e=Io(),t=vo(),n=J();function r(r){return e(r,n,t)}return Lo=r,Lo}var Bo,Vo;function Ho(){if(Vo)return Bo;Vo=1;var e=Io(),t=Ao(),n=$a();function r(r){return e(r,n,t)}return Bo=r,Bo}var Uo,Wo;function Go(){return Wo?Uo:(Wo=1,Uo=wr()(U(),`DataView`),Uo)}var Ko,qo;function Jo(){return qo?Ko:(qo=1,Ko=wr()(U(),`Promise`),Ko)}var Yo,Xo;function Zo(){return Xo?Yo:(Xo=1,Yo=wr()(U(),`Set`),Yo)}var Qo,$o;function es(){return $o?Qo:($o=1,Qo=wr()(U(),`WeakMap`),Qo)}var ts,ns;function rs(){if(ns)return ts;ns=1;var e=Go(),t=Dr(),n=Jo(),r=Zo(),i=es(),a=tr(),o=hr(),s=`[object Map]`,c=`[object Object]`,l=`[object Promise]`,u=`[object Set]`,d=`[object WeakMap]`,f=`[object DataView]`,p=o(e),m=o(t),h=o(n),g=o(r),_=o(i),v=a;return(e&&v(new e(new ArrayBuffer(1)))!=f||t&&v(new t)!=s||n&&v(n.resolve())!=l||r&&v(new r)!=u||i&&v(new i)!=d)&&(v=function(e){var t=a(e),n=t==c?e.constructor:void 0,r=n?o(n):``;if(r)switch(r){case p:return f;case m:return s;case h:return l;case g:return u;case _:return d}return t}),ts=v,ts}var is,as;function os(){if(as)return is;as=1;var e=Object.prototype.hasOwnProperty;function t(t){var n=t.length,r=new t.constructor(n);return n&&typeof t[0]==`string`&&e.call(t,`index`)&&(r.index=t.index,r.input=t.input),r}return is=t,is}var ss,cs;function ls(){return cs?ss:(cs=1,ss=U().Uint8Array,ss)}var us,ds;function fs(){if(ds)return us;ds=1;var e=ls();function t(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return us=t,us}var ps,ms;function hs(){if(ms)return ps;ms=1;var e=fs();function t(t,n){var r=n?e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}return ps=t,ps}var gs,_s;function vs(){if(_s)return gs;_s=1;var e=/\w*$/;function t(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return gs=t,gs}var ys,bs;function xs(){if(bs)return ys;bs=1;var e=Kn(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(e){return n?Object(n.call(e)):{}}return ys=r,ys}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=fs();function t(t,n){var r=n?e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}return Ss=t,Ss}var Ts,Es;function Ds(){if(Es)return Ts;Es=1;var e=fs(),t=hs(),n=vs(),r=xs(),i=ws(),a=`[object Boolean]`,o=`[object Date]`,s=`[object Map]`,c=`[object Number]`,l=`[object RegExp]`,u=`[object Set]`,d=`[object String]`,f=`[object Symbol]`,p=`[object ArrayBuffer]`,m=`[object DataView]`,h=`[object Float32Array]`,g=`[object Float64Array]`,_=`[object Int8Array]`,v=`[object Int16Array]`,y=`[object Int32Array]`,b=`[object Uint8Array]`,x=`[object Uint8ClampedArray]`,S=`[object Uint16Array]`,C=`[object Uint32Array]`;function w(w,T,E){var D=w.constructor;switch(T){case p:return e(w);case a:case o:return new D(+w);case m:return t(w,E);case h:case g:case _:case v:case y:case b:case x:case S:case C:return i(w,E);case s:return new D;case c:case d:return new D(w);case l:return n(w);case u:return new D;case f:return r(w)}}return Ts=w,Ts}var Os,ks;function As(){if(ks)return Os;ks=1;var e=W(),t=Object.create;return Os=function(){function n(){}return function(r){if(!e(r))return{};if(t)return t(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}(),Os}var js,Ms;function Ns(){if(Ms)return js;Ms=1;var e=As(),t=Do(),n=Oa();function r(r){return typeof r.constructor==`function`&&!n(r)?e(t(r)):{}}return js=r,js}var Ps,Fs;function Is(){if(Fs)return Ps;Fs=1;var e=rs(),t=G(),n=`[object Map]`;function r(r){return t(r)&&e(r)==n}return Ps=r,Ps}var Ls,Rs;function zs(){if(Rs)return Ls;Rs=1;var e=Is(),t=ga(),n=ya(),r=n&&n.isMap;return Ls=r?t(r):e,Ls}var Bs,Vs;function Hs(){if(Vs)return Bs;Vs=1;var e=rs(),t=G(),n=`[object Set]`;function r(r){return t(r)&&e(r)==n}return Bs=r,Bs}var Us,Ws;function Gs(){if(Ws)return Us;Ws=1;var e=Hs(),t=ga(),n=ya(),r=n&&n.isSet;return Us=r?t(r):e,Us}var Ks,qs;function Js(){if(qs)return Ks;qs=1;var e=wi(),t=Di(),n=Ii(),r=Wa(),i=no(),a=ao(),o=co(),s=xo(),c=No(),l=zo(),u=Ho(),d=rs(),f=os(),p=Ds(),m=Ns(),h=K(),g=ia(),_=zs(),v=W(),y=Gs(),b=J(),x=$a(),S=1,C=2,w=4,T=`[object Arguments]`,E=`[object Array]`,D=`[object Boolean]`,O=`[object Date]`,k=`[object Error]`,A=`[object Function]`,ee=`[object GeneratorFunction]`,j=`[object Map]`,M=`[object Number]`,te=`[object Object]`,N=`[object RegExp]`,P=`[object Set]`,F=`[object String]`,I=`[object Symbol]`,ne=`[object WeakMap]`,L=`[object ArrayBuffer]`,re=`[object DataView]`,ie=`[object Float32Array]`,ae=`[object Float64Array]`,oe=`[object Int8Array]`,se=`[object Int16Array]`,ce=`[object Int32Array]`,le=`[object Uint8Array]`,ue=`[object Uint8ClampedArray]`,de=`[object Uint16Array]`,fe=`[object Uint32Array]`,R={};R[T]=R[E]=R[L]=R[re]=R[D]=R[O]=R[ie]=R[ae]=R[oe]=R[se]=R[ce]=R[j]=R[M]=R[te]=R[N]=R[P]=R[F]=R[I]=R[le]=R[ue]=R[de]=R[fe]=!0,R[k]=R[A]=R[ne]=!1;function pe(E,D,O,k,j,M){var N,P=D&S,F=D&C,I=D&w;if(O&&(N=j?O(E,k,j,M):O(E)),N!==void 0)return N;if(!v(E))return E;var ne=h(E);if(ne){if(N=f(E),!P)return o(E,N)}else{var L=d(E),re=L==A||L==ee;if(g(E))return a(E,P);if(L==te||L==T||re&&!j){if(N=F||re?{}:m(E),!P)return F?c(E,i(N,E)):s(E,r(N,E))}else{if(!R[L])return j?E:{};N=p(E,L,P)}}M||=new e;var ie=M.get(E);if(ie)return ie;M.set(E,N),y(E)?E.forEach(function(e){N.add(pe(e,D,O,e,E,M))}):_(E)&&E.forEach(function(e,t){N.set(t,pe(e,D,O,t,E,M))});var ae=ne?void 0:(I?F?u:l:F?x:b)(E);return t(ae||E,function(e,t){ae&&(t=e,e=E[t]),n(N,t,pe(e,D,O,t,E,M))}),N}return Ks=pe,Ks}var Ys,Xs;function Zs(){if(Xs)return Ys;Xs=1;var e=Js(),t=4;function n(n){return e(n,t)}return Ys=n,Ys}var Qs,$s;function ec(){if($s)return Qs;$s=1;function e(e){return function(){return e}}return Qs=e,Qs}var tc,nc;function rc(){if(nc)return tc;nc=1;function e(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}return tc=e,tc}var ic,ac;function oc(){return ac?ic:(ac=1,ic=rc()(),ic)}var sc,cc;function lc(){if(cc)return sc;cc=1;var e=oc(),t=J();function n(n,r){return n&&e(n,r,t)}return sc=n,sc}var uc,dc;function fc(){if(dc)return uc;dc=1;var e=q();function t(t,n){return function(r,i){if(r==null)return r;if(!e(r))return t(r,i);for(var a=r.length,o=n?a:-1,s=Object(r);(n?o--:++o<a)&&i(s[o],o,s)!==!1;);return r}}return uc=t,uc}var pc,mc;function hc(){if(mc)return pc;mc=1;var e=lc();return pc=fc()(e),pc}var gc,_c;function vc(){if(_c)return gc;_c=1;function e(e){return e}return gc=e,gc}var yc,bc;function xc(){if(bc)return yc;bc=1;var e=vc();function t(t){return typeof t==`function`?t:e}return yc=t,yc}var Sc,Cc;function wc(){if(Cc)return Sc;Cc=1;var e=Di(),t=hc(),n=xc(),r=K();function i(i,a){return(r(i)?e:t)(i,n(a))}return Sc=i,Sc}var Tc,Ec;function Dc(){return Ec?Tc:(Ec=1,Tc=wc(),Tc)}var Oc,kc;function Ac(){if(kc)return Oc;kc=1;var e=hc();function t(t,n){var r=[];return e(t,function(e,t,i){n(e,t,i)&&r.push(e)}),r}return Oc=t,Oc}var jc,Mc;function Nc(){if(Mc)return jc;Mc=1;var e=`__lodash_hash_undefined__`;function t(t){return this.__data__.set(t,e),this}return jc=t,jc}var Pc,Fc;function Ic(){if(Fc)return Pc;Fc=1;function e(e){return this.__data__.has(e)}return Pc=e,Pc}var Lc,Rc;function zc(){if(Rc)return Lc;Rc=1;var e=vi(),t=Nc(),n=Ic();function r(t){var n=-1,r=t==null?0:t.length;for(this.__data__=new e;++n<r;)this.add(t[n])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,Lc=r,Lc}var Bc,Vc;function Hc(){if(Vc)return Bc;Vc=1;function e(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}return Bc=e,Bc}var Uc,Wc;function Gc(){if(Wc)return Uc;Wc=1;function e(e,t){return e.has(t)}return Uc=e,Uc}var Kc,qc;function Jc(){if(qc)return Kc;qc=1;var e=zc(),t=Hc(),n=Gc(),r=1,i=2;function a(a,o,s,c,l,u){var d=s&r,f=a.length,p=o.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(a),h=u.get(o);if(m&&h)return m==o&&h==a;var g=-1,_=!0,v=s&i?new e:void 0;for(u.set(a,o),u.set(o,a);++g<f;){var y=a[g],b=o[g];if(c)var x=d?c(b,y,g,o,a,u):c(y,b,g,a,o,u);if(x!==void 0){if(x)continue;_=!1;break}if(v){if(!t(o,function(e,t){if(!n(v,t)&&(y===e||l(y,e,s,c,u)))return v.push(t)})){_=!1;break}}else if(!(y===b||l(y,b,s,c,u))){_=!1;break}}return u.delete(a),u.delete(o),_}return Kc=a,Kc}var Yc,Xc;function Zc(){if(Xc)return Yc;Xc=1;function e(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}return Yc=e,Yc}var Qc,$c;function el(){if($c)return Qc;$c=1;function e(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}return Qc=e,Qc}var tl,nl;function rl(){if(nl)return tl;nl=1;var e=Kn(),t=ls(),n=cn(),r=Jc(),i=Zc(),a=el(),o=1,s=2,c=`[object Boolean]`,l=`[object Date]`,u=`[object Error]`,d=`[object Map]`,f=`[object Number]`,p=`[object RegExp]`,m=`[object Set]`,h=`[object String]`,g=`[object Symbol]`,_=`[object ArrayBuffer]`,v=`[object DataView]`,y=e?e.prototype:void 0,b=y?y.valueOf:void 0;function x(e,y,x,S,C,w,T){switch(x){case v:if(e.byteLength!=y.byteLength||e.byteOffset!=y.byteOffset)return!1;e=e.buffer,y=y.buffer;case _:return!(e.byteLength!=y.byteLength||!w(new t(e),new t(y)));case c:case l:case f:return n(+e,+y);case u:return e.name==y.name&&e.message==y.message;case p:case h:return e==y+``;case d:var E=i;case m:var D=S&o;if(E||=a,e.size!=y.size&&!D)return!1;var O=T.get(e);if(O)return O==y;S|=s,T.set(e,y);var k=r(E(e),E(y),S,C,w,T);return T.delete(e),k;case g:if(b)return b.call(e)==b.call(y)}return!1}return tl=x,tl}var il,al;function ol(){if(al)return il;al=1;var e=zo(),t=1,n=Object.prototype.hasOwnProperty;function r(r,i,a,o,s,c){var l=a&t,u=e(r),d=u.length;if(d!=e(i).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in i:n.call(i,p)))return!1}var m=c.get(r),h=c.get(i);if(m&&h)return m==i&&h==r;var g=!0;c.set(r,i),c.set(i,r);for(var _=l;++f<d;){p=u[f];var v=r[p],y=i[p];if(o)var b=l?o(y,v,p,i,r,c):o(v,y,p,r,i,c);if(!(b===void 0?v===y||s(v,y,a,o,c):b)){g=!1;break}_||=p==`constructor`}if(g&&!_){var x=r.constructor,S=i.constructor;x!=S&&`constructor`in r&&`constructor`in i&&!(typeof x==`function`&&x instanceof x&&typeof S==`function`&&S instanceof S)&&(g=!1)}return c.delete(r),c.delete(i),g}return il=r,il}var sl,cl;function ll(){if(cl)return sl;cl=1;var e=wi(),t=Jc(),n=rl(),r=ol(),i=rs(),a=K(),o=ia(),s=Sa(),c=1,l=`[object Arguments]`,u=`[object Array]`,d=`[object Object]`,f=Object.prototype.hasOwnProperty;function p(p,m,h,g,_,v){var y=a(p),b=a(m),x=y?u:i(p),S=b?u:i(m);x=x==l?d:x,S=S==l?d:S;var C=x==d,w=S==d,T=x==S;if(T&&o(p)){if(!o(m))return!1;y=!0,C=!1}if(T&&!C)return v||=new e,y||s(p)?t(p,m,h,g,_,v):n(p,m,x,h,g,_,v);if(!(h&c)){var E=C&&f.call(p,`__wrapped__`),D=w&&f.call(m,`__wrapped__`);if(E||D){var O=E?p.value():p,k=D?m.value():m;return v||=new e,_(O,k,h,g,v)}}return T?(v||=new e,r(p,m,h,g,_,v)):!1}return sl=p,sl}var ul,dl;function fl(){if(dl)return ul;dl=1;var e=ll(),t=G();function n(r,i,a,o,s){return r===i?!0:r==null||i==null||!t(r)&&!t(i)?r!==r&&i!==i:e(r,i,a,o,n,s)}return ul=n,ul}var pl,ml;function hl(){if(ml)return pl;ml=1;var e=wi(),t=fl(),n=1,r=2;function i(i,a,o,s){var c=o.length,l=c,u=!s;if(i==null)return!l;for(i=Object(i);c--;){var d=o[c];if(u&&d[2]?d[1]!==i[d[0]]:!(d[0]in i))return!1}for(;++c<l;){d=o[c];var f=d[0],p=i[f],m=d[1];if(u&&d[2]){if(p===void 0&&!(f in i))return!1}else{var h=new e;if(s)var g=s(p,m,f,i,a,h);if(!(g===void 0?t(m,p,n|r,s,h):g))return!1}}return!0}return pl=i,pl}var gl,_l;function vl(){if(_l)return gl;_l=1;var e=W();function t(t){return t===t&&!e(t)}return gl=t,gl}var yl,bl;function xl(){if(bl)return yl;bl=1;var e=vl(),t=J();function n(n){for(var r=t(n),i=r.length;i--;){var a=r[i],o=n[a];r[i]=[a,o,e(o)]}return r}return yl=n,yl}var Sl,Cl;function wl(){if(Cl)return Sl;Cl=1;function e(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}return Sl=e,Sl}var Tl,El;function Dl(){if(El)return Tl;El=1;var e=hl(),t=xl(),n=wl();function r(r){var i=t(r);return i.length==1&&i[0][2]?n(i[0][0],i[0][1]):function(t){return t===r||e(t,r,i)}}return Tl=r,Tl}var Ol,kl;function Al(){if(kl)return Ol;kl=1;var e=tr(),t=G(),n=`[object Symbol]`;function r(r){return typeof r==`symbol`||t(r)&&e(r)==n}return Ol=r,Ol}var jl,Ml;function Nl(){if(Ml)return jl;Ml=1;var e=K(),t=Al(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(i,a){if(e(i))return!1;var o=typeof i;return o==`number`||o==`symbol`||o==`boolean`||i==null||t(i)?!0:r.test(i)||!n.test(i)||a!=null&&i in Object(a)}return jl=i,jl}var Pl,Fl;function Il(){if(Fl)return Pl;Fl=1;var e=vi(),t=`Expected a function`;function n(r,i){if(typeof r!=`function`||i!=null&&typeof i!=`function`)throw TypeError(t);var a=function(){var e=arguments,t=i?i.apply(this,e):e[0],n=a.cache;if(n.has(t))return n.get(t);var o=r.apply(this,e);return a.cache=n.set(t,o)||n,o};return a.cache=new(n.Cache||e),a}return n.Cache=e,Pl=n,Pl}var Ll,Rl;function zl(){if(Rl)return Ll;Rl=1;var e=Il(),t=500;function n(n){var r=e(n,function(e){return i.size===t&&i.clear(),e}),i=r.cache;return r}return Ll=n,Ll}var Bl,Vl;function Hl(){if(Vl)return Bl;Vl=1;var e=zl(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g;return Bl=e(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(``),e.replace(t,function(e,t,i,a){r.push(i?a.replace(n,`$1`):t||e)}),r}),Bl}var Ul,Wl;function Gl(){if(Wl)return Ul;Wl=1;function e(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}return Ul=e,Ul}var Kl,ql;function Jl(){if(ql)return Kl;ql=1;var e=Kn(),t=Gl(),n=K(),r=Al(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(e){if(typeof e==`string`)return e;if(n(e))return t(e,o)+``;if(r(e))return a?a.call(e):``;var i=e+``;return i==`0`&&1/e==-1/0?`-0`:i}return Kl=o,Kl}var Yl,Xl;function Zl(){if(Xl)return Yl;Xl=1;var e=Jl();function t(t){return t==null?``:e(t)}return Yl=t,Yl}var Ql,$l;function eu(){if($l)return Ql;$l=1;var e=K(),t=Nl(),n=Hl(),r=Zl();function i(i,a){return e(i)?i:t(i,a)?[i]:n(r(i))}return Ql=i,Ql}var tu,nu;function ru(){if(nu)return tu;nu=1;var e=Al();function t(t){if(typeof t==`string`||e(t))return t;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n}return tu=t,tu}var iu,au;function ou(){if(au)return iu;au=1;var e=eu(),t=ru();function n(n,r){r=e(r,n);for(var i=0,a=r.length;n!=null&&i<a;)n=n[t(r[i++])];return i&&i==a?n:void 0}return iu=n,iu}var su,cu;function lu(){if(cu)return su;cu=1;var e=ou();function t(t,n,r){var i=t==null?void 0:e(t,n);return i===void 0?r:i}return su=t,su}var uu,du;function fu(){if(du)return uu;du=1;function e(e,t){return e!=null&&t in Object(e)}return uu=e,uu}var pu,mu;function hu(){if(mu)return pu;mu=1;var e=eu(),t=Xi(),n=K(),r=sa(),i=ua(),a=ru();function o(o,s,c){s=e(s,o);for(var l=-1,u=s.length,d=!1;++l<u;){var f=a(s[l]);if(!(d=o!=null&&c(o,f)))break;o=o[f]}return d||++l!=u?d:(u=o==null?0:o.length,!!u&&i(u)&&r(f,u)&&(n(o)||t(o)))}return pu=o,pu}var gu,_u;function vu(){if(_u)return gu;_u=1;var e=fu(),t=hu();function n(n,r){return n!=null&&t(n,r,e)}return gu=n,gu}var yu,bu;function xu(){if(bu)return yu;bu=1;var e=fl(),t=lu(),n=vu(),r=Nl(),i=vl(),a=wl(),o=ru(),s=1,c=2;function l(l,u){return r(l)&&i(u)?a(o(l),u):function(r){var i=t(r,l);return i===void 0&&i===u?n(r,l):e(u,i,s|c)}}return yu=l,yu}var Su,Cu;function wu(){if(Cu)return Su;Cu=1;function e(e){return function(t){return t?.[e]}}return Su=e,Su}var Tu,Eu;function Du(){if(Eu)return Tu;Eu=1;var e=ou();function t(t){return function(n){return e(n,t)}}return Tu=t,Tu}var Ou,ku;function Au(){if(ku)return Ou;ku=1;var e=wu(),t=Du(),n=Nl(),r=ru();function i(i){return n(i)?e(r(i)):t(i)}return Ou=i,Ou}var ju,Mu;function Y(){if(Mu)return ju;Mu=1;var e=Dl(),t=xu(),n=vc(),r=K(),i=Au();function a(a){return typeof a==`function`?a:a==null?n:typeof a==`object`?r(a)?t(a[0],a[1]):e(a):i(a)}return ju=a,ju}var Nu,Pu;function Fu(){if(Pu)return Nu;Pu=1;var e=fo(),t=Ac(),n=Y(),r=K();function i(i,a){return(r(i)?e:t)(i,n(a,3))}return Nu=i,Nu}var Iu,Lu;function Ru(){if(Lu)return Iu;Lu=1;var e=Object.prototype.hasOwnProperty;function t(t,n){return t!=null&&e.call(t,n)}return Iu=t,Iu}var zu,Bu;function Vu(){if(Bu)return zu;Bu=1;var e=Ru(),t=hu();function n(n,r){return n!=null&&t(n,r,e)}return zu=n,zu}var Hu,Uu;function Wu(){if(Uu)return Hu;Uu=1;var e=La(),t=rs(),n=Xi(),r=K(),i=q(),a=ia(),o=Oa(),s=Sa(),c=`[object Map]`,l=`[object Set]`,u=Object.prototype.hasOwnProperty;function d(d){if(d==null)return!0;if(i(d)&&(r(d)||typeof d==`string`||typeof d.splice==`function`||a(d)||s(d)||n(d)))return!d.length;var f=t(d);if(f==c||f==l)return!d.size;if(o(d))return!e(d).length;for(var p in d)if(u.call(d,p))return!1;return!0}return Hu=d,Hu}var Gu,Ku;function qu(){if(Ku)return Gu;Ku=1;function e(e){return e===void 0}return Gu=e,Gu}var Ju,Yu;function Xu(){if(Yu)return Ju;Yu=1;var e=hc(),t=q();function n(n,r){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(e,t,n){a[++i]=r(e,t,n)}),a}return Ju=n,Ju}var Zu,Qu;function $u(){if(Qu)return Zu;Qu=1;var e=Gl(),t=Y(),n=Xu(),r=K();function i(i,a){return(r(i)?e:n)(i,t(a,3))}return Zu=i,Zu}var ed,td;function nd(){if(td)return ed;td=1;function e(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}return ed=e,ed}var rd,id;function ad(){if(id)return rd;id=1;function e(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}return rd=e,rd}var od,sd;function cd(){if(sd)return od;sd=1;var e=nd(),t=hc(),n=Y(),r=ad(),i=K();function a(a,o,s){var c=i(a)?e:r,l=arguments.length<3;return c(a,n(o,4),s,l,t)}return od=a,od}var ld,ud;function dd(){if(ud)return ld;ud=1;var e=tr(),t=K(),n=G(),r=`[object String]`;function i(i){return typeof i==`string`||!t(i)&&n(i)&&e(i)==r}return ld=i,ld}var fd,pd;function md(){return pd?fd:(pd=1,fd=wu()(`length`),fd)}var hd,gd;function _d(){if(gd)return hd;gd=1;var e=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`);function t(t){return e.test(t)}return hd=t,hd}var vd,yd;function bd(){if(yd)return vd;yd=1;var e=`\\ud800-\\udfff`,t=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,n=`\\ufe0e\\ufe0f`,r=`[`+e+`]`,i=`[`+t+`]`,a=`\\ud83c[\\udffb-\\udfff]`,o=`(?:`+i+`|`+a+`)`,s=`[^`+e+`]`,c=`(?:\\ud83c[\\udde6-\\uddff]){2}`,l=`[\\ud800-\\udbff][\\udc00-\\udfff]`,u=`\\u200d`,d=o+`?`,f=`[`+n+`]?`,p=`(?:`+u+`(?:`+[s,c,l].join(`|`)+`)`+f+d+`)*`,m=f+d+p,h=`(?:`+[s+i+`?`,i,c,l,r].join(`|`)+`)`,g=RegExp(a+`(?=`+a+`)|`+h+m,`g`);function _(e){for(var t=g.lastIndex=0;g.test(e);)++t;return t}return vd=_,vd}var xd,Sd;function Cd(){if(Sd)return xd;Sd=1;var e=md(),t=_d(),n=bd();function r(r){return t(r)?n(r):e(r)}return xd=r,xd}var wd,Td;function Ed(){if(Td)return wd;Td=1;var e=La(),t=rs(),n=q(),r=dd(),i=Cd(),a=`[object Map]`,o=`[object Set]`;function s(s){if(s==null)return 0;if(n(s))return r(s)?i(s):s.length;var c=t(s);return c==a||c==o?s.size:e(s).length}return wd=s,wd}var Dd,Od;function kd(){if(Od)return Dd;Od=1;var e=Di(),t=As(),n=lc(),r=Y(),i=Do(),a=K(),o=ia(),s=or(),c=W(),l=Sa();function u(u,d,f){var p=a(u),m=p||o(u)||l(u);if(d=r(d,4),f==null){var h=u&&u.constructor;f=m?p?new h:[]:c(u)&&s(h)?t(i(u)):{}}return(m?e:n)(u,function(e,t,n){return d(f,e,t,n)}),f}return Dd=u,Dd}var Ad,jd;function Md(){if(jd)return Ad;jd=1;var e=Kn(),t=Xi(),n=K(),r=e?e.isConcatSpreadable:void 0;function i(e){return n(e)||t(e)||!!(r&&e&&e[r])}return Ad=i,Ad}var Nd,Pd;function Fd(){if(Pd)return Nd;Pd=1;var e=wo(),t=Md();function n(r,i,a,o,s){var c=-1,l=r.length;for(a||=t,s||=[];++c<l;){var u=r[c];i>0&&a(u)?i>1?n(u,i-1,a,o,s):e(s,u):o||(s[s.length]=u)}return s}return Nd=n,Nd}var Id,Ld;function Rd(){if(Ld)return Id;Ld=1;function e(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return Id=e,Id}var zd,Bd;function Vd(){if(Bd)return zd;Bd=1;var e=Rd(),t=Math.max;function n(n,r,i){return r=t(r===void 0?n.length-1:r,0),function(){for(var a=arguments,o=-1,s=t(a.length-r,0),c=Array(s);++o<s;)c[o]=a[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=a[o];return l[r]=i(c),e(n,this,l)}}return zd=n,zd}var Hd,Ud;function Wd(){if(Ud)return Hd;Ud=1;var e=ec(),t=Ai(),n=vc();return Hd=t?function(n,r){return t(n,`toString`,{configurable:!0,enumerable:!1,value:e(r),writable:!0})}:n,Hd}var Gd,Kd;function qd(){if(Kd)return Gd;Kd=1;var e=800,t=16,n=Date.now;function r(r){var i=0,a=0;return function(){var o=n(),s=t-(o-a);if(a=o,s>0){if(++i>=e)return arguments[0]}else i=0;return r.apply(void 0,arguments)}}return Gd=r,Gd}var Jd,Yd;function Xd(){if(Yd)return Jd;Yd=1;var e=Wd();return Jd=qd()(e),Jd}var Zd,Qd;function $d(){if(Qd)return Zd;Qd=1;var e=vc(),t=Vd(),n=Xd();function r(r,i){return n(t(r,i,e),r+``)}return Zd=r,Zd}var ef,tf;function nf(){if(tf)return ef;tf=1;function e(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}return ef=e,ef}var rf,af;function of(){if(af)return rf;af=1;function e(e){return e!==e}return rf=e,rf}var sf,cf;function lf(){if(cf)return sf;cf=1;function e(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}return sf=e,sf}var uf,df;function ff(){if(df)return uf;df=1;var e=nf(),t=of(),n=lf();function r(r,i,a){return i===i?n(r,i,a):e(r,t,a)}return uf=r,uf}var pf,mf;function hf(){if(mf)return pf;mf=1;var e=ff();function t(t,n){return!!(t!=null&&t.length)&&e(t,n,0)>-1}return pf=t,pf}var gf,_f;function vf(){if(_f)return gf;_f=1;function e(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}return gf=e,gf}var yf,bf;function xf(){if(bf)return yf;bf=1;function e(){}return yf=e,yf}var Sf,Cf;function wf(){if(Cf)return Sf;Cf=1;var e=Zo(),t=xf(),n=el();return Sf=e&&1/n(new e([,-0]))[1]==1/0?function(t){return new e(t)}:t,Sf}var Tf,Ef;function Df(){if(Ef)return Tf;Ef=1;var e=zc(),t=hf(),n=vf(),r=Gc(),i=wf(),a=el(),o=200;function s(s,c,l){var u=-1,d=t,f=s.length,p=!0,m=[],h=m;if(l)p=!1,d=n;else if(f>=o){var g=c?null:i(s);if(g)return a(g);p=!1,d=r,h=new e}else h=c?[]:m;outer:for(;++u<f;){var _=s[u],v=c?c(_):_;if(_=l||_!==0?_:0,p&&v===v){for(var y=h.length;y--;)if(h[y]===v)continue outer;c&&h.push(v),m.push(_)}else d(h,v,l)||(h!==m&&h.push(v),m.push(_))}return m}return Tf=s,Tf}var Of,kf;function Af(){if(kf)return Of;kf=1;var e=q(),t=G();function n(n){return t(n)&&e(n)}return Of=n,Of}var jf,Mf;function Nf(){if(Mf)return jf;Mf=1;var e=Fd(),t=$d(),n=Df(),r=Af();return jf=t(function(t){return n(e(t,1,r,!0))}),jf}var Pf,Ff;function If(){if(Ff)return Pf;Ff=1;var e=Gl();function t(t,n){return e(n,function(e){return t[e]})}return Pf=t,Pf}var Lf,Rf;function zf(){if(Rf)return Lf;Rf=1;var e=If(),t=J();function n(n){return n==null?[]:e(n,t(n))}return Lf=n,Lf}var Bf,Vf;function X(){if(Vf)return Bf;Vf=1;var e;if(typeof tn==`function`)try{e={clone:Zs(),constant:ec(),each:Dc(),filter:Fu(),has:Vu(),isArray:K(),isEmpty:Wu(),isFunction:or(),isUndefined:qu(),keys:J(),map:$u(),reduce:cd(),size:Ed(),transform:kd(),union:Nf(),values:zf()}}catch{}return e||=window._,Bf=e,Bf}var Hf,Uf;function Wf(){if(Uf)return Hf;Uf=1;var e=X();Hf=i;var t=`\0`,n=`\0`,r=``;function i(t){this._isDirected=!e.has(t,`directed`)||t.directed,this._isMultigraph=e.has(t,`multigraph`)?t.multigraph:!1,this._isCompound=e.has(t,`compound`)?t.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(e){return this._label=e,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultNodeLabelFn=t,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var t=this;return e.filter(this.nodes(),function(n){return e.isEmpty(t._in[n])})},i.prototype.sinks=function(){var t=this;return e.filter(this.nodes(),function(n){return e.isEmpty(t._out[n])})},i.prototype.setNodes=function(t,n){var r=arguments,i=this;return e.each(t,function(e){r.length>1?i.setNode(e,n):i.setNode(e)}),this},i.prototype.setNode=function(t,r){return e.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=r),this):(this._nodes[t]=arguments.length>1?r:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=n,this._children[t]={},this._children[n][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},i.prototype.node=function(e){return this._nodes[e]},i.prototype.hasNode=function(t){return e.has(this._nodes,t)},i.prototype.removeNode=function(t){var n=this;if(e.has(this._nodes,t)){var r=function(e){n.removeEdge(n._edgeObjs[e])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],e.each(this.children(t),function(e){n.setParent(e)}),delete this._children[t]),e.each(e.keys(this._in[t]),r),delete this._in[t],delete this._preds[t],e.each(e.keys(this._out[t]),r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},i.prototype.setParent=function(t,r){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(e.isUndefined(r))r=n;else{r+=``;for(var i=r;!e.isUndefined(i);i=this.parent(i))if(i===t)throw Error(`Setting `+r+` as parent of `+t+` would create a cycle`);this.setNode(r)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=r,this._children[r][t]=!0,this},i.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},i.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==n)return t}},i.prototype.children=function(t){if(e.isUndefined(t)&&(t=n),this._isCompound){var r=this._children[t];if(r)return e.keys(r)}else if(t===n)return this.nodes();else if(this.hasNode(t))return[]},i.prototype.predecessors=function(t){var n=this._preds[t];if(n)return e.keys(n)},i.prototype.successors=function(t){var n=this._sucs[t];if(n)return e.keys(n)},i.prototype.neighbors=function(t){var n=this.predecessors(t);if(n)return e.union(n,this.successors(t))},i.prototype.isLeaf=function(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0},i.prototype.filterNodes=function(t){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;e.each(this._nodes,function(e,r){t(r)&&n.setNode(r,e)}),e.each(this._edgeObjs,function(e){n.hasNode(e.v)&&n.hasNode(e.w)&&n.setEdge(e,r.edge(e))});var i={};function a(e){var t=r.parent(e);return t===void 0||n.hasNode(t)?(i[e]=t,t):t in i?i[t]:a(t)}return this._isCompound&&e.each(n.nodes(),function(e){n.setParent(e,a(e))}),n},i.prototype.setDefaultEdgeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultEdgeLabelFn=t,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(t,n){var r=this,i=arguments;return e.reduce(t,function(e,t){return i.length>1?r.setEdge(e,t,n):r.setEdge(e,t),t}),this},i.prototype.setEdge=function(){var t,n,r,i,o=!1,l=arguments[0];typeof l==`object`&&l&&`v`in l?(t=l.v,n=l.w,r=l.name,arguments.length===2&&(i=arguments[1],o=!0)):(t=l,n=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],o=!0)),t=``+t,n=``+n,e.isUndefined(r)||(r=``+r);var u=s(this._isDirected,t,n,r);if(e.has(this._edgeLabels,u))return o&&(this._edgeLabels[u]=i),this;if(!e.isUndefined(r)&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(t),this.setNode(n),this._edgeLabels[u]=o?i:this._defaultEdgeLabelFn(t,n,r);var d=c(this._isDirected,t,n,r);return t=d.v,n=d.w,Object.freeze(d),this._edgeObjs[u]=d,a(this._preds[n],t),a(this._sucs[t],n),this._in[n][u]=d,this._out[t][u]=d,this._edgeCount++,this},i.prototype.edge=function(e,t,n){var r=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,e,t,n);return this._edgeLabels[r]},i.prototype.hasEdge=function(t,n,r){var i=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,t,n,r);return e.has(this._edgeLabels,i)},i.prototype.removeEdge=function(e,t,n){var r=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],o(this._preds[t],e),o(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this},i.prototype.inEdges=function(t,n){var r=this._in[t];if(r){var i=e.values(r);return n?e.filter(i,function(e){return e.v===n}):i}},i.prototype.outEdges=function(t,n){var r=this._out[t];if(r){var i=e.values(r);return n?e.filter(i,function(e){return e.w===n}):i}},i.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))};function a(e,t){e[t]?e[t]++:e[t]=1}function o(e,t){--e[t]||delete e[t]}function s(n,i,a,o){var s=``+i,c=``+a;if(!n&&s>c){var l=s;s=c,c=l}return s+r+c+r+(e.isUndefined(o)?t:o)}function c(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function l(e,t){return s(e,t.v,t.w,t.name)}return Hf}var Gf,Kf;function qf(){return Kf?Gf:(Kf=1,Gf=`2.1.8`,Gf)}var Jf,Yf;function Xf(){return Yf?Jf:(Yf=1,Jf={Graph:Wf(),version:qf()},Jf)}var Zf,Qf;function $f(){if(Qf)return Zf;Qf=1;var e=X(),t=Wf();Zf={write:n,read:a};function n(t){var n={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:r(t),edges:i(t)};return e.isUndefined(t.graph())||(n.value=e.clone(t.graph())),n}function r(t){return e.map(t.nodes(),function(n){var r=t.node(n),i=t.parent(n),a={v:n};return e.isUndefined(r)||(a.value=r),e.isUndefined(i)||(a.parent=i),a})}function i(t){return e.map(t.edges(),function(n){var r=t.edge(n),i={v:n.v,w:n.w};return e.isUndefined(n.name)||(i.name=n.name),e.isUndefined(r)||(i.value=r),i})}function a(n){var r=new t(n.options).setGraph(n.value);return e.each(n.nodes,function(e){r.setNode(e.v,e.value),e.parent&&r.setParent(e.v,e.parent)}),e.each(n.edges,function(e){r.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),r}return Zf}var ep,tp;function np(){if(tp)return ep;tp=1;var e=X();ep=t;function t(t){var n={},r=[],i;function a(r){e.has(n,r)||(n[r]=!0,i.push(r),e.each(t.successors(r),a),e.each(t.predecessors(r),a))}return e.each(t.nodes(),function(e){i=[],a(e),i.length&&r.push(i)}),r}return ep}var rp,ip;function ap(){if(ip)return rp;ip=1;var e=X();rp=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(e){return e.key})},t.prototype.has=function(t){return e.has(this._keyIndices,t)},t.prototype.priority=function(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority},t.prototype.min=function(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key},t.prototype.add=function(t,n){var r=this._keyIndices;if(t=String(t),!e.has(r,t)){var i=this._arr,a=i.length;return r[t]=a,i.push({key:t,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},t.prototype.decrease=function(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)},t.prototype._heapify=function(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))},t.prototype._decrease=function(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r},t.prototype._swap=function(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t},rp}var op,sp;function cp(){if(sp)return op;sp=1;var e=X(),t=ap();op=r;var n=e.constant(1);function r(e,t,r,a){return i(e,String(t),r||n,a||function(t){return e.outEdges(t)})}function i(e,n,r,i){var a={},o=new t,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<n.distance&&(n.distance=l,n.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var t=e===n?0:1/0;a[e]={distance:t},o.add(e,t)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}return op}var lp,up;function dp(){if(up)return lp;up=1;var e=cp(),t=X();lp=n;function n(n,r,i){return t.transform(n.nodes(),function(t,a){t[a]=e(n,a,r,i)},{})}return lp}var fp,pp;function mp(){if(pp)return fp;pp=1;var e=X();fp=t;function t(t){var n=0,r=[],i={},a=[];function o(s){var c=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),t.successors(s).forEach(function(t){e.has(i,t)?i[t].onStack&&(c.lowlink=Math.min(c.lowlink,i[t].index)):(o(t),c.lowlink=Math.min(c.lowlink,i[t].lowlink))}),c.lowlink===c.index){var l=[],u;do u=r.pop(),i[u].onStack=!1,l.push(u);while(s!==u);a.push(l)}}return t.nodes().forEach(function(t){e.has(i,t)||o(t)}),a}return fp}var hp,gp;function _p(){if(gp)return hp;gp=1;var e=X(),t=mp();hp=n;function n(n){return e.filter(t(n),function(e){return e.length>1||e.length===1&&n.hasEdge(e[0],e[0])})}return hp}var vp,yp;function bp(){if(yp)return vp;yp=1;var e=X();vp=n;var t=e.constant(1);function n(e,n,i){return r(e,n||t,i||function(t){return e.outEdges(t)})}function r(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}return vp}var xp,Sp;function Cp(){if(Sp)return xp;Sp=1;var e=X();xp=t,t.CycleException=n;function t(t){var r={},i={},a=[];function o(s){if(e.has(i,s))throw new n;e.has(r,s)||(i[s]=!0,r[s]=!0,e.each(t.predecessors(s),o),delete i[s],a.push(s))}if(e.each(t.sinks(),o),e.size(r)!==t.nodeCount())throw new n;return a}function n(){}return n.prototype=Error(),xp}var wp,Tp;function Ep(){if(Tp)return wp;Tp=1;var e=Cp();wp=t;function t(t){try{e(t)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}return wp}var Dp,Op;function kp(){if(Op)return Dp;Op=1;var e=X();Dp=t;function t(t,r,i){e.isArray(r)||(r=[r]);var a=(t.isDirected()?t.successors:t.neighbors).bind(t),o=[],s={};return e.each(r,function(e){if(!t.hasNode(e))throw Error(`Graph does not have node: `+e);n(t,e,i===`post`,s,a,o)}),o}function n(t,r,i,a,o,s){e.has(a,r)||(a[r]=!0,i||s.push(r),e.each(o(r),function(e){n(t,e,i,a,o,s)}),i&&s.push(r))}return Dp}var Ap,jp;function Mp(){if(jp)return Ap;jp=1;var e=kp();Ap=t;function t(t,n){return e(t,n,`post`)}return Ap}var Np,Pp;function Fp(){if(Pp)return Np;Pp=1;var e=kp();Np=t;function t(t,n){return e(t,n,`pre`)}return Np}var Ip,Lp;function Rp(){if(Lp)return Ip;Lp=1;var e=X(),t=Wf(),n=ap();Ip=r;function r(r,i){var a=new t,o={},s=new n,c;function l(e){var t=e.v===c?e.w:e.v,n=s.priority(t);if(n!==void 0){var r=i(e);r<n&&(o[t]=c,s.decrease(t,r))}}if(r.nodeCount()===0)return a;e.each(r.nodes(),function(e){s.add(e,1/0),a.setNode(e)}),s.decrease(r.nodes()[0],0);for(var u=!1;s.size()>0;){if(c=s.removeMin(),e.has(o,c))a.setEdge(c,o[c]);else if(u)throw Error(`Input graph is not connected: `+r);else u=!0;r.nodeEdges(c).forEach(l)}return a}return Ip}var zp,Bp;function Vp(){return Bp?zp:(Bp=1,zp={components:np(),dijkstra:cp(),dijkstraAll:dp(),findCycles:_p(),floydWarshall:bp(),isAcyclic:Ep(),postorder:Mp(),preorder:Fp(),prim:Rp(),tarjan:mp(),topsort:Cp()},zp)}var Hp,Up;function Wp(){if(Up)return Hp;Up=1;var e=Xf();return Hp={Graph:e.Graph,json:$f(),alg:Vp(),version:e.version},Hp}var Gp,Kp;function Z(){if(Kp)return Gp;Kp=1;var e;if(typeof tn==`function`)try{e=Wp()}catch{}return e||=window.graphlib,Gp=e,Gp}var qp,Jp;function Yp(){if(Jp)return qp;Jp=1;var e=Js(),t=1,n=4;function r(r){return e(r,t|n)}return qp=r,qp}var Xp,Zp;function Qp(){if(Zp)return Xp;Zp=1;var e=cn(),t=q(),n=sa(),r=W();function i(i,a,o){if(!r(o))return!1;var s=typeof a;return(s==`number`?t(o)&&n(a,o.length):s==`string`&&a in o)?e(o[a],i):!1}return Xp=i,Xp}var $p,em;function tm(){if(em)return $p;em=1;var e=$d(),t=cn(),n=Qp(),r=$a(),i=Object.prototype,a=i.hasOwnProperty;return $p=e(function(e,o){e=Object(e);var s=-1,c=o.length,l=c>2?o[2]:void 0;for(l&&n(o[0],o[1],l)&&(c=1);++s<c;)for(var u=o[s],d=r(u),f=-1,p=d.length;++f<p;){var m=d[f],h=e[m];(h===void 0||t(h,i[m])&&!a.call(e,m))&&(e[m]=u[m])}return e}),$p}var nm,rm;function im(){if(rm)return nm;rm=1;var e=Y(),t=q(),n=J();function r(r){return function(i,a,o){var s=Object(i);if(!t(i)){var c=e(a,3);i=n(i),a=function(e){return c(s[e],e,s)}}var l=r(i,a,o);return l>-1?s[c?i[l]:l]:void 0}}return nm=r,nm}var am,om;function sm(){if(om)return am;om=1;var e=/\s/;function t(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return am=t,am}var cm,lm;function um(){if(lm)return cm;lm=1;var e=sm(),t=/^\s+/;function n(n){return n&&n.slice(0,e(n)+1).replace(t,``)}return cm=n,cm}var dm,fm;function pm(){if(fm)return dm;fm=1;var e=um(),t=W(),n=Al(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function c(c){if(typeof c==`number`)return c;if(n(c))return r;if(t(c)){var l=typeof c.valueOf==`function`?c.valueOf():c;c=t(l)?l+``:l}if(typeof c!=`string`)return c===0?c:+c;c=e(c);var u=a.test(c);return u||o.test(c)?s(c.slice(2),u?2:8):i.test(c)?r:+c}return dm=c,dm}var mm,hm;function gm(){if(hm)return mm;hm=1;var e=pm(),t=1/0,n=17976931348623157e292;function r(r){return r?(r=e(r),r===t||r===-t?(r<0?-1:1)*n:r===r?r:0):r===0?r:0}return mm=r,mm}var _m,vm;function ym(){if(vm)return _m;vm=1;var e=gm();function t(t){var n=e(t),r=n%1;return n===n?r?n-r:n:0}return _m=t,_m}var bm,xm;function Sm(){if(xm)return bm;xm=1;var e=nf(),t=Y(),n=ym(),r=Math.max;function i(i,a,o){var s=i==null?0:i.length;if(!s)return-1;var c=o==null?0:n(o);return c<0&&(c=r(s+c,0)),e(i,t(a,3),c)}return bm=i,bm}var Cm,wm;function Tm(){return wm?Cm:(wm=1,Cm=im()(Sm()),Cm)}var Em,Dm;function Om(){if(Dm)return Em;Dm=1;var e=Fd();function t(t){return t!=null&&t.length?e(t,1):[]}return Em=t,Em}var km,Am;function jm(){if(Am)return km;Am=1;var e=oc(),t=xc(),n=$a();function r(r,i){return r==null?r:e(r,t(i),n)}return km=r,km}var Mm,Nm;function Pm(){if(Nm)return Mm;Nm=1;function e(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return Mm=e,Mm}var Fm,Im;function Lm(){if(Im)return Fm;Im=1;var e=Ni(),t=lc(),n=Y();function r(r,i){var a={};return i=n(i,3),t(r,function(t,n,r){e(a,n,i(t,n,r))}),a}return Fm=r,Fm}var Rm,zm;function Bm(){if(zm)return Rm;zm=1;var e=Al();function t(t,n,r){for(var i=-1,a=t.length;++i<a;){var o=t[i],s=n(o);if(s!=null&&(c===void 0?s===s&&!e(s):r(s,c)))var c=s,l=o}return l}return Rm=t,Rm}var Vm,Hm;function Um(){if(Hm)return Vm;Hm=1;function e(e,t){return e>t}return Vm=e,Vm}var Wm,Gm;function Km(){if(Gm)return Wm;Gm=1;var e=Bm(),t=Um(),n=vc();function r(r){return r&&r.length?e(r,n,t):void 0}return Wm=r,Wm}var qm,Jm;function Ym(){if(Jm)return qm;Jm=1;var e=Ni(),t=cn();function n(n,r,i){(i!==void 0&&!t(n[r],i)||i===void 0&&!(r in n))&&e(n,r,i)}return qm=n,qm}var Xm,Zm;function Qm(){if(Zm)return Xm;Zm=1;var e=tr(),t=Do(),n=G(),r=`[object Object]`,i=Function.prototype,a=Object.prototype,o=i.toString,s=a.hasOwnProperty,c=o.call(Object);function l(i){if(!n(i)||e(i)!=r)return!1;var a=t(i);if(a===null)return!0;var l=s.call(a,`constructor`)&&a.constructor;return typeof l==`function`&&l instanceof l&&o.call(l)==c}return Xm=l,Xm}var $m,eh;function th(){if(eh)return $m;eh=1;function e(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}return $m=e,$m}var nh,rh;function ih(){if(rh)return nh;rh=1;var e=zi(),t=$a();function n(n){return e(n,t(n))}return nh=n,nh}var ah,oh;function sh(){if(oh)return ah;oh=1;var e=Ym(),t=ao(),n=ws(),r=co(),i=Ns(),a=Xi(),o=K(),s=Af(),c=ia(),l=or(),u=W(),d=Qm(),f=Sa(),p=th(),m=ih();function h(h,g,_,v,y,b,x){var S=p(h,_),C=p(g,_),w=x.get(C);if(w){e(h,_,w);return}var T=b?b(S,C,_+``,h,g,x):void 0,E=T===void 0;if(E){var D=o(C),O=!D&&c(C),k=!D&&!O&&f(C);T=C,D||O||k?o(S)?T=S:s(S)?T=r(S):O?(E=!1,T=t(C,!0)):k?(E=!1,T=n(C,!0)):T=[]:d(C)||a(C)?(T=S,a(S)?T=m(S):(!u(S)||l(S))&&(T=i(C))):E=!1}E&&(x.set(C,T),y(T,C,v,b,x),x.delete(C)),e(h,_,T)}return ah=h,ah}var ch,lh;function uh(){if(lh)return ch;lh=1;var e=wi(),t=Ym(),n=oc(),r=sh(),i=W(),a=$a(),o=th();function s(c,l,u,d,f){c!==l&&n(l,function(n,a){if(f||=new e,i(n))r(c,l,a,u,s,d,f);else{var p=d?d(o(c,a),n,a+``,c,l,f):void 0;p===void 0&&(p=n),t(c,a,p)}},a)}return ch=s,ch}var dh,fh;function ph(){if(fh)return dh;fh=1;var e=$d(),t=Qp();function n(n){return e(function(e,r){var i=-1,a=r.length,o=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(o=n.length>3&&typeof o==`function`?(a--,o):void 0,s&&t(r[0],r[1],s)&&(o=a<3?void 0:o,a=1),e=Object(e);++i<a;){var c=r[i];c&&n(e,c,i,o)}return e})}return dh=n,dh}var mh,hh;function gh(){if(hh)return mh;hh=1;var e=uh();return mh=ph()(function(t,n,r){e(t,n,r)}),mh}var _h,vh;function yh(){if(vh)return _h;vh=1;function e(e,t){return e<t}return _h=e,_h}var bh,xh;function Sh(){if(xh)return bh;xh=1;var e=Bm(),t=yh(),n=vc();function r(r){return r&&r.length?e(r,n,t):void 0}return bh=r,bh}var Ch,wh;function Th(){if(wh)return Ch;wh=1;var e=Bm(),t=Y(),n=yh();function r(r,i){return r&&r.length?e(r,t(i,2),n):void 0}return Ch=r,Ch}var Eh,Dh;function Oh(){if(Dh)return Eh;Dh=1;var e=U();return Eh=function(){return e.Date.now()},Eh}var kh,Ah;function jh(){if(Ah)return kh;Ah=1;var e=Ii(),t=eu(),n=sa(),r=W(),i=ru();function a(a,o,s,c){if(!r(a))return a;o=t(o,a);for(var l=-1,u=o.length,d=u-1,f=a;f!=null&&++l<u;){var p=i(o[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return a;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=r(h)?h:n(o[l+1])?[]:{})}e(f,p,m),f=f[p]}return a}return kh=a,kh}var Mh,Nh;function Ph(){if(Nh)return Mh;Nh=1;var e=ou(),t=jh(),n=eu();function r(r,i,a){for(var o=-1,s=i.length,c={};++o<s;){var l=i[o],u=e(r,l);a(u,l)&&t(c,n(l,r),u)}return c}return Mh=r,Mh}var Fh,Ih;function Lh(){if(Ih)return Fh;Ih=1;var e=Ph(),t=vu();function n(n,r){return e(n,r,function(e,r){return t(n,r)})}return Fh=n,Fh}var Rh,zh;function Bh(){if(zh)return Rh;zh=1;var e=Om(),t=Vd(),n=Xd();function r(r){return n(t(r,void 0,e),r+``)}return Rh=r,Rh}var Vh,Hh;function Uh(){if(Hh)return Vh;Hh=1;var e=Lh();return Vh=Bh()(function(t,n){return t==null?{}:e(t,n)}),Vh}var Wh,Gh;function Kh(){if(Gh)return Wh;Gh=1;var e=Math.ceil,t=Math.max;function n(n,r,i,a){for(var o=-1,s=t(e((r-n)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=n,n+=i;return c}return Wh=n,Wh}var qh,Jh;function Yh(){if(Jh)return qh;Jh=1;var e=Kh(),t=Qp(),n=gm();function r(r){return function(i,a,o){return o&&typeof o!=`number`&&t(i,a,o)&&(a=o=void 0),i=n(i),a===void 0?(a=i,i=0):a=n(a),o=o===void 0?i<a?1:-1:n(o),e(i,a,o,r)}}return qh=r,qh}var Xh,Zh;function Qh(){return Zh?Xh:(Zh=1,Xh=Yh()(),Xh)}var $h,eg;function tg(){if(eg)return $h;eg=1;function e(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}return $h=e,$h}var ng,rg;function ig(){if(rg)return ng;rg=1;var e=Al();function t(t,n){if(t!==n){var r=t!==void 0,i=t===null,a=t===t,o=e(t),s=n!==void 0,c=n===null,l=n===n,u=e(n);if(!c&&!u&&!o&&t>n||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&t<n||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}return ng=t,ng}var ag,og;function sg(){if(og)return ag;og=1;var e=ig();function t(t,n,r){for(var i=-1,a=t.criteria,o=n.criteria,s=a.length,c=r.length;++i<s;){var l=e(a[i],o[i]);if(l)return i>=c?l:l*(r[i]==`desc`?-1:1)}return t.index-n.index}return ag=t,ag}var cg,lg;function ug(){if(lg)return cg;lg=1;var e=Gl(),t=ou(),n=Y(),r=Xu(),i=tg(),a=ga(),o=sg(),s=vc(),c=K();function l(l,u,d){u=u.length?e(u,function(e){return c(e)?function(n){return t(n,e.length===1?e[0]:e)}:e}):[s];var f=-1;return u=e(u,a(n)),i(r(l,function(t,n,r){return{criteria:e(u,function(e){return e(t)}),index:++f,value:t}}),function(e,t){return o(e,t,d)})}return cg=l,cg}var dg,fg;function pg(){if(fg)return dg;fg=1;var e=Fd(),t=ug(),n=$d(),r=Qp();return dg=n(function(n,i){if(n==null)return[];var a=i.length;return a>1&&r(n,i[0],i[1])?i=[]:a>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),t(n,e(i,1),[])}),dg}var mg,hg;function gg(){if(hg)return mg;hg=1;var e=Zl(),t=0;function n(n){var r=++t;return e(n)+r}return mg=n,mg}var _g,vg;function yg(){if(vg)return _g;vg=1;function e(e,t,n){for(var r=-1,i=e.length,a=t.length,o={};++r<i;){var s=r<a?t[r]:void 0;n(o,e[r],s)}return o}return _g=e,_g}var bg,xg;function Sg(){if(xg)return bg;xg=1;var e=Ii(),t=yg();function n(n,r){return t(n||[],r||[],e)}return bg=n,bg}var Cg,wg;function Q(){if(wg)return Cg;wg=1;var e;if(typeof tn==`function`)try{e={cloneDeep:Yp(),constant:ec(),defaults:tm(),each:Dc(),filter:Fu(),find:Tm(),flatten:Om(),forEach:wc(),forIn:jm(),has:Vu(),isUndefined:qu(),last:Pm(),map:$u(),mapValues:Lm(),max:Km(),merge:gh(),min:Sh(),minBy:Th(),now:Oh(),pick:Uh(),range:Qh(),reduce:cd(),sortBy:pg(),uniqueId:gg(),values:zf(),zipObject:Sg()}}catch{}return e||=window._,Cg=e,Cg}var Tg,Eg;function Dg(){if(Eg)return Tg;Eg=1,Tg=e;function e(){var e={};e._next=e._prev=e,this._sentinel=e}e.prototype.dequeue=function(){var e=this._sentinel,n=e._prev;if(n!==e)return t(n),n},e.prototype.enqueue=function(e){var n=this._sentinel;e._prev&&e._next&&t(e),e._next=n._next,n._next._prev=e,n._next=e,e._prev=n},e.prototype.toString=function(){for(var e=[],t=this._sentinel,r=t._prev;r!==t;)e.push(JSON.stringify(r,n)),r=r._prev;return`[`+e.join(`, `)+`]`};function t(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n(e,t){if(e!==`_next`&&e!==`_prev`)return t}return Tg}var Og,kg;function Ag(){if(kg)return Og;kg=1;var e=Q(),t=Z().Graph,n=Dg();Og=i;var r=e.constant(1);function i(t,n){if(t.nodeCount()<=1)return[];var i=s(t,n||r),o=a(i.graph,i.buckets,i.zeroIdx);return e.flatten(e.map(o,function(e){return t.outEdges(e.v,e.w)}),!0)}function a(e,t,n){for(var r=[],i=t[t.length-1],a=t[0],s;e.nodeCount();){for(;s=a.dequeue();)o(e,t,n,s);for(;s=i.dequeue();)o(e,t,n,s);if(e.nodeCount()){for(var c=t.length-2;c>0;--c)if(s=t[c].dequeue(),s){r=r.concat(o(e,t,n,s,!0));break}}}return r}function o(t,n,r,i,a){var o=a?[]:void 0;return e.forEach(t.inEdges(i.v),function(e){var i=t.edge(e),s=t.node(e.v);a&&o.push({v:e.v,w:e.w}),s.out-=i,c(n,r,s)}),e.forEach(t.outEdges(i.v),function(e){var i=t.edge(e),a=e.w,o=t.node(a);o.in-=i,c(n,r,o)}),t.removeNode(i.v),o}function s(r,i){var a=new t,o=0,s=0;e.forEach(r.nodes(),function(e){a.setNode(e,{v:e,in:0,out:0})}),e.forEach(r.edges(),function(e){var t=a.edge(e.v,e.w)||0,n=i(e),r=t+n;a.setEdge(e.v,e.w,r),s=Math.max(s,a.node(e.v).out+=n),o=Math.max(o,a.node(e.w).in+=n)});var l=e.range(s+o+3).map(function(){return new n}),u=o+1;return e.forEach(a.nodes(),function(e){c(l,u,a.node(e))}),{graph:a,buckets:l,zeroIdx:u}}function c(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}return Og}var jg,Mg;function Ng(){if(Mg)return jg;Mg=1;var e=Q(),t=Ag();jg={run:n,undo:i};function n(n){var i=n.graph().acyclicer===`greedy`?t(n,a(n)):r(n);e.forEach(i,function(t){var r=n.edge(t);n.removeEdge(t),r.forwardName=t.name,r.reversed=!0,n.setEdge(t.w,t.v,r,e.uniqueId(`rev`))});function a(e){return function(t){return e.edge(t).weight}}}function r(t){var n=[],r={},i={};function a(o){e.has(i,o)||(i[o]=!0,r[o]=!0,e.forEach(t.outEdges(o),function(t){e.has(r,t.w)?n.push(t):a(t.w)}),delete r[o])}return e.forEach(t.nodes(),a),n}function i(t){e.forEach(t.edges(),function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}})}return jg}var Pg,Fg;function $(){if(Fg)return Pg;Fg=1;var e=Q(),t=Z().Graph;Pg={addDummyNode:n,simplify:r,asNonCompoundGraph:i,successorWeights:a,predecessorWeights:o,intersectRect:s,buildLayerMatrix:c,normalizeRanks:l,removeEmptyRanks:u,addBorderNode:d,maxRank:f,partition:p,time:m,notime:h};function n(t,n,r,i){var a;do a=e.uniqueId(i);while(t.hasNode(a));return r.dummy=n,t.setNode(a,r),a}function r(n){var r=new t().setGraph(n.graph());return e.forEach(n.nodes(),function(e){r.setNode(e,n.node(e))}),e.forEach(n.edges(),function(e){var t=r.edge(e.v,e.w)||{weight:0,minlen:1},i=n.edge(e);r.setEdge(e.v,e.w,{weight:t.weight+i.weight,minlen:Math.max(t.minlen,i.minlen)})}),r}function i(n){var r=new t({multigraph:n.isMultigraph()}).setGraph(n.graph());return e.forEach(n.nodes(),function(e){n.children(e).length||r.setNode(e,n.node(e))}),e.forEach(n.edges(),function(e){r.setEdge(e,n.edge(e))}),r}function a(t){var n=e.map(t.nodes(),function(n){var r={};return e.forEach(t.outEdges(n),function(e){r[e.w]=(r[e.w]||0)+t.edge(e).weight}),r});return e.zipObject(t.nodes(),n)}function o(t){var n=e.map(t.nodes(),function(n){var r={};return e.forEach(t.inEdges(n),function(e){r[e.v]=(r[e.v]||0)+t.edge(e).weight}),r});return e.zipObject(t.nodes(),n)}function s(e,t){var n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);var c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function c(t){var n=e.map(e.range(f(t)+1),function(){return[]});return e.forEach(t.nodes(),function(r){var i=t.node(r),a=i.rank;e.isUndefined(a)||(n[a][i.order]=r)}),n}function l(t){var n=e.min(e.map(t.nodes(),function(e){return t.node(e).rank}));e.forEach(t.nodes(),function(r){var i=t.node(r);e.has(i,`rank`)&&(i.rank-=n)})}function u(t){var n=e.min(e.map(t.nodes(),function(e){return t.node(e).rank})),r=[];e.forEach(t.nodes(),function(e){var i=t.node(e).rank-n;r[i]||(r[i]=[]),r[i].push(e)});var i=0,a=t.graph().nodeRankFactor;e.forEach(r,function(n,r){e.isUndefined(n)&&r%a!==0?--i:i&&e.forEach(n,function(e){t.node(e).rank+=i})})}function d(e,t,r,i){var a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=i),n(e,`border`,a,t)}function f(t){return e.max(e.map(t.nodes(),function(n){var r=t.node(n).rank;if(!e.isUndefined(r))return r}))}function p(t,n){var r={lhs:[],rhs:[]};return e.forEach(t,function(e){n(e)?r.lhs.push(e):r.rhs.push(e)}),r}function m(t,n){var r=e.now();try{return n()}finally{console.log(t+` time: `+(e.now()-r)+`ms`)}}function h(e,t){return t()}return Pg}var Ig,Lg;function Rg(){if(Lg)return Ig;Lg=1;var e=Q(),t=$();Ig={run:n,undo:i};function n(t){t.graph().dummyChains=[],e.forEach(t.edges(),function(e){r(t,e)})}function r(e,n){var r=n.v,i=e.node(r).rank,a=n.w,o=e.node(a).rank,s=n.name,c=e.edge(n),l=c.labelRank;if(o!==i+1){e.removeEdge(n);var u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:n,rank:i},u=t.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(r,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),r=u;e.setEdge(r,a,{weight:c.weight},s)}}function i(t){e.forEach(t.graph().dummyChains,function(e){var n=t.node(e),r=n.edgeLabel,i;for(t.setEdge(n.edgeObj,r);n.dummy;)i=t.successors(e)[0],t.removeNode(e),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),e=i,n=t.node(e)})}return Ig}var zg,Bg;function Vg(){if(Bg)return zg;Bg=1;var e=Q();zg={longestPath:t,slack:n};function t(t){var n={};function r(i){var a=t.node(i);if(e.has(n,i))return a.rank;n[i]=!0;var o=e.min(e.map(t.outEdges(i),function(e){return r(e.w)-t.edge(e).minlen}));return(o===1/0||o==null)&&(o=0),a.rank=o}e.forEach(t.sources(),r)}function n(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}return zg}var Hg,Ug;function Wg(){if(Ug)return Hg;Ug=1;var e=Q(),t=Z().Graph,n=Vg().slack;Hg=r;function r(e){var r=new t({directed:!1}),s=e.nodes()[0],c=e.nodeCount();r.setNode(s,{});for(var l,u;i(r,e)<c;)l=a(r,e),u=r.hasNode(l.v)?n(e,l):-n(e,l),o(r,e,u);return r}function i(t,r){function i(a){e.forEach(r.nodeEdges(a),function(e){var o=e.v,s=a===o?e.w:o;!t.hasNode(s)&&!n(r,e)&&(t.setNode(s,{}),t.setEdge(a,s,{}),i(s))})}return e.forEach(t.nodes(),i),t.nodeCount()}function a(t,r){return e.minBy(r.edges(),function(e){if(t.hasNode(e.v)!==t.hasNode(e.w))return n(r,e)})}function o(t,n,r){e.forEach(t.nodes(),function(e){n.node(e).rank+=r})}return Hg}var Gg,Kg;function qg(){if(Kg)return Gg;Kg=1;var e=Q(),t=Wg(),n=Vg().slack,r=Vg().longestPath,i=Z().alg.preorder,a=Z().alg.postorder,o=$().simplify;Gg=s,s.initLowLimValues=d,s.initCutValues=c,s.calcCutValue=u,s.leaveEdge=p,s.enterEdge=m,s.exchangeEdges=h;function s(e){e=o(e),r(e);var n=t(e);d(n),c(n,e);for(var i,a;i=p(n);)a=m(n,e,i),h(n,e,i,a)}function c(t,n){var r=a(t,t.nodes());r=r.slice(0,r.length-1),e.forEach(r,function(e){l(t,n,e)})}function l(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=u(e,t,n)}function u(t,n,r){var i=t.node(r).parent,a=!0,o=n.edge(r,i),s=0;return o||=(a=!1,n.edge(i,r)),s=o.weight,e.forEach(n.nodeEdges(r),function(e){var o=e.v===r,c=o?e.w:e.v;if(c!==i){var l=o===a,u=n.edge(e).weight;if(s+=l?u:-u,_(t,r,c)){var d=t.edge(r,c).cutvalue;s+=l?-d:d}}}),s}function d(e,t){arguments.length<2&&(t=e.nodes()[0]),f(e,{},1,t)}function f(t,n,r,i,a){var o=r,s=t.node(i);return n[i]=!0,e.forEach(t.neighbors(i),function(a){e.has(n,a)||(r=f(t,n,r,a,i))}),s.low=o,s.lim=r++,a?s.parent=a:delete s.parent,r}function p(t){return e.find(t.edges(),function(e){return t.edge(e).cutvalue<0})}function m(t,r,i){var a=i.v,o=i.w;r.hasEdge(a,o)||(a=i.w,o=i.v);var s=t.node(a),c=t.node(o),l=s,u=!1;s.lim>c.lim&&(l=c,u=!0);var d=e.filter(r.edges(),function(e){return u===v(t,t.node(e.v),l)&&u!==v(t,t.node(e.w),l)});return e.minBy(d,function(e){return n(r,e)})}function h(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),d(e),c(e,t),g(e,t)}function g(t,n){var r=i(t,e.find(t.nodes(),function(e){return!n.node(e).parent}));r=r.slice(1),e.forEach(r,function(e){var r=t.node(e).parent,i=n.edge(e,r),a=!1;i||(i=n.edge(r,e),a=!0),n.node(e).rank=n.node(r).rank+(a?i.minlen:-i.minlen)})}function _(e,t,n){return e.hasEdge(t,n)}function v(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}return Gg}var Jg,Yg;function Xg(){if(Yg)return Jg;Yg=1;var e=Vg().longestPath,t=Wg(),n=qg();Jg=r;function r(e){switch(e.graph().ranker){case`network-simplex`:o(e);break;case`tight-tree`:a(e);break;case`longest-path`:i(e);break;default:o(e)}}var i=e;function a(n){e(n),t(n)}function o(e){n(e)}return Jg}var Zg,Qg;function $g(){if(Qg)return Zg;Qg=1;var e=Q();Zg=t;function t(t){var i=r(t);e.forEach(t.graph().dummyChains,function(e){for(var r=t.node(e),a=r.edgeObj,o=n(t,i,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;e!==a.w;){if(r=t.node(e),d){for(;(u=s[l])!==c&&t.node(u).maxRank<r.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&t.node(u=s[l+1]).minRank<=r.rank;)l++;u=s[l]}t.setParent(e,u),e=t.successors(e)[0]}})}function n(e,t,n,r){var i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c=n,l;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function r(t){var n={},r=0;function i(a){var o=r;e.forEach(t.children(a),i),n[a]={low:o,lim:r++}}return e.forEach(t.children(),i),n}return Zg}var e_,t_;function n_(){if(t_)return e_;t_=1;var e=Q(),t=$();e_={run:n,cleanup:o};function n(n){var o=t.addDummyNode(n,`root`,{},`_root`),s=i(n),c=e.max(e.values(s))-1,l=2*c+1;n.graph().nestingRoot=o,e.forEach(n.edges(),function(e){n.edge(e).minlen*=l});var u=a(n)+1;e.forEach(n.children(),function(e){r(n,o,l,u,c,s,e)}),n.graph().nodeRankFactor=l}function r(n,i,a,o,s,c,l){var u=n.children(l);if(!u.length){l!==i&&n.setEdge(i,l,{weight:0,minlen:a});return}var d=t.addBorderNode(n,`_bt`),f=t.addBorderNode(n,`_bb`),p=n.node(l);n.setParent(d,l),p.borderTop=d,n.setParent(f,l),p.borderBottom=f,e.forEach(u,function(e){r(n,i,a,o,s,c,e);var t=n.node(e),u=t.borderTop?t.borderTop:e,p=t.borderBottom?t.borderBottom:e,m=t.borderTop?o:2*o,h=u===p?s-c[l]+1:1;n.setEdge(d,u,{weight:m,minlen:h,nestingEdge:!0}),n.setEdge(p,f,{weight:m,minlen:h,nestingEdge:!0})}),n.parent(l)||n.setEdge(i,d,{weight:0,minlen:s+c[l]})}function i(t){var n={};function r(i,a){var o=t.children(i);o&&o.length&&e.forEach(o,function(e){r(e,a+1)}),n[i]=a}return e.forEach(t.children(),function(e){r(e,1)}),n}function a(t){return e.reduce(t.edges(),function(e,n){return e+t.edge(n).weight},0)}function o(t){var n=t.graph();t.removeNode(n.nestingRoot),delete n.nestingRoot,e.forEach(t.edges(),function(e){t.edge(e).nestingEdge&&t.removeEdge(e)})}return e_}var r_,i_;function a_(){if(i_)return r_;i_=1;var e=Q(),t=$();r_=n;function n(t){function n(i){var a=t.children(i),o=t.node(i);if(a.length&&e.forEach(a,n),e.has(o,`minRank`)){o.borderLeft=[],o.borderRight=[];for(var s=o.minRank,c=o.maxRank+1;s<c;++s)r(t,`borderLeft`,`_bl`,i,o,s),r(t,`borderRight`,`_br`,i,o,s)}}e.forEach(t.children(),n)}function r(e,n,r,i,a,o){var s={width:0,height:0,rank:o,borderType:n},c=a[n][o-1],l=t.addDummyNode(e,`border`,s,r);a[n][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}return r_}var o_,s_;function c_(){if(s_)return o_;s_=1;var e=Q();o_={adjust:t,undo:n};function t(e){var t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&r(e)}function n(e){var t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&a(e),(t===`lr`||t===`rl`)&&(s(e),r(e))}function r(t){e.forEach(t.nodes(),function(e){i(t.node(e))}),e.forEach(t.edges(),function(e){i(t.edge(e))})}function i(e){var t=e.width;e.width=e.height,e.height=t}function a(t){e.forEach(t.nodes(),function(e){o(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.forEach(r.points,o),e.has(r,`y`)&&o(r)})}function o(e){e.y=-e.y}function s(t){e.forEach(t.nodes(),function(e){c(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.forEach(r.points,c),e.has(r,`x`)&&c(r)})}function c(e){var t=e.x;e.x=e.y,e.y=t}return o_}var l_,u_;function d_(){if(u_)return l_;u_=1;var e=Q();l_=t;function t(t){var n={},r=e.filter(t.nodes(),function(e){return!t.children(e).length}),i=e.max(e.map(r,function(e){return t.node(e).rank})),a=e.map(e.range(i+1),function(){return[]});function o(r){e.has(n,r)||(n[r]=!0,a[t.node(r).rank].push(r),e.forEach(t.successors(r),o))}var s=e.sortBy(r,function(e){return t.node(e).rank});return e.forEach(s,o),a}return l_}var f_,p_;function m_(){if(p_)return f_;p_=1;var e=Q();f_=t;function t(e,t){for(var r=0,i=1;i<t.length;++i)r+=n(e,t[i-1],t[i]);return r}function n(t,n,r){for(var i=e.zipObject(r,e.map(r,function(e,t){return t})),a=e.flatten(e.map(n,function(n){return e.sortBy(e.map(t.outEdges(n),function(e){return{pos:i[e.w],weight:t.edge(e).weight}}),`pos`)}),!0),o=1;o<r.length;)o<<=1;var s=2*o-1;--o;var c=e.map(Array(s),function(){return 0}),l=0;return e.forEach(a.forEach(function(e){var t=e.pos+o;c[t]+=e.weight;for(var n=0;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n})),l}return f_}var h_,g_;function __(){if(g_)return h_;g_=1;var e=Q();h_=t;function t(t,n){return e.map(n,function(n){var r=t.inEdges(n);if(r.length){var i=e.reduce(r,function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}return{v:n}})}return h_}var v_,y_;function b_(){if(y_)return v_;y_=1;var e=Q();v_=t;function t(t,r){var i={};return e.forEach(t,function(t,n){var r=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:n};e.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)}),e.forEach(r.edges(),function(t){var n=i[t.v],r=i[t.w];!e.isUndefined(n)&&!e.isUndefined(r)&&(r.indegree++,n.out.push(i[t.w]))}),n(e.filter(i,function(e){return!e.indegree}))}function n(t){var n=[];function i(t){return function(n){n.merged||(e.isUndefined(n.barycenter)||e.isUndefined(t.barycenter)||n.barycenter>=t.barycenter)&&r(t,n)}}function a(e){return function(n){n.in.push(e),--n.indegree===0&&t.push(n)}}for(;t.length;){var o=t.pop();n.push(o),e.forEach(o.in.reverse(),i(o)),e.forEach(o.out,a(o))}return e.map(e.filter(n,function(e){return!e.merged}),function(t){return e.pick(t,[`vs`,`i`,`barycenter`,`weight`])})}function r(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}return v_}var x_,S_;function C_(){if(S_)return x_;S_=1;var e=Q(),t=$();x_=n;function n(n,a){var o=t.partition(n,function(t){return e.has(t,`barycenter`)}),s=o.lhs,c=e.sortBy(o.rhs,function(e){return-e.i}),l=[],u=0,d=0,f=0;s.sort(i(!!a)),f=r(l,c,f),e.forEach(s,function(e){f+=e.vs.length,l.push(e.vs),u+=e.barycenter*e.weight,d+=e.weight,f=r(l,c,f)});var p={vs:e.flatten(l,!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function r(t,n,r){for(var i;n.length&&(i=e.last(n)).i<=r;)n.pop(),t.push(i.vs),r++;return r}function i(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}return x_}var w_,T_;function E_(){if(T_)return w_;T_=1;var e=Q(),t=__(),n=b_(),r=C_();w_=i;function i(s,c,l,u){var d=s.children(c),f=s.node(c),p=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,h={};p&&(d=e.filter(d,function(e){return e!==p&&e!==m}));var g=t(s,d);e.forEach(g,function(t){if(s.children(t.v).length){var n=i(s,t.v,l,u);h[t.v]=n,e.has(n,`barycenter`)&&o(t,n)}});var _=n(g,l);a(_,h);var v=r(_,u);if(p&&(v.vs=e.flatten([p,v.vs,m],!0),s.predecessors(p).length)){var y=s.node(s.predecessors(p)[0]),b=s.node(s.predecessors(m)[0]);e.has(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.order+b.order)/(v.weight+2),v.weight+=2}return v}function a(t,n){e.forEach(t,function(t){t.vs=e.flatten(t.vs.map(function(e){return n[e]?n[e].vs:e}),!0)})}function o(t,n){e.isUndefined(t.barycenter)?(t.barycenter=n.barycenter,t.weight=n.weight):(t.barycenter=(t.barycenter*t.weight+n.barycenter*n.weight)/(t.weight+n.weight),t.weight+=n.weight)}return w_}var D_,O_;function k_(){if(O_)return D_;O_=1;var e=Q(),t=Z().Graph;D_=n;function n(n,i,a){var o=r(n),s=new t({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(e){return n.node(e)});return e.forEach(n.nodes(),function(t){var r=n.node(t),c=n.parent(t);(r.rank===i||r.minRank<=i&&i<=r.maxRank)&&(s.setNode(t),s.setParent(t,c||o),e.forEach(n[a](t),function(r){var i=r.v===t?r.w:r.v,a=s.edge(i,t),o=e.isUndefined(a)?0:a.weight;s.setEdge(i,t,{weight:n.edge(r).weight+o})}),e.has(r,`minRank`)&&s.setNode(t,{borderLeft:r.borderLeft[i],borderRight:r.borderRight[i]}))}),s}function r(t){for(var n;t.hasNode(n=e.uniqueId(`_root`)););return n}return D_}var A_,j_;function M_(){if(j_)return A_;j_=1;var e=Q();A_=t;function t(t,n,r){var i={},a;e.forEach(r,function(e){for(var r=t.parent(e),o,s;r;){if(o=t.parent(r),o?(s=i[o],i[o]=r):(s=a,a=r),s&&s!==r){n.setEdge(s,r);return}r=o}})}return A_}var N_,P_;function F_(){if(P_)return N_;P_=1;var e=Q(),t=d_(),n=m_(),r=E_(),i=k_(),a=M_(),o=Z().Graph,s=$();N_=c;function c(r){var i=s.maxRank(r),a=l(r,e.range(1,i+1),`inEdges`),o=l(r,e.range(i-1,-1,-1),`outEdges`),c=t(r);d(r,c);for(var f=1/0,p,m=0,h=0;h<4;++m,++h){u(m%2?a:o,m%4>=2),c=s.buildLayerMatrix(r);var g=n(r,c);g<f&&(h=0,p=e.cloneDeep(c),f=g)}d(r,p)}function l(t,n,r){return e.map(n,function(e){return i(t,e,r)})}function u(t,n){var i=new o;e.forEach(t,function(t){var o=t.graph().root,s=r(t,o,i,n);e.forEach(s.vs,function(e,n){t.node(e).order=n}),a(t,i,s.vs)})}function d(t,n){e.forEach(n,function(n){e.forEach(n,function(e,n){t.node(e).order=n})})}return N_}var I_,L_;function R_(){if(L_)return I_;L_=1;var e=Q(),t=Z().Graph,n=$();I_={positionX:m,findType1Conflicts:r,findType2Conflicts:i,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:l,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function r(t,n){var r={};function i(n,i){var s=0,c=0,l=n.length,u=e.last(i);return e.forEach(i,function(n,d){var f=a(t,n),p=f?t.node(f).order:l;(f||n===u)&&(e.forEach(i.slice(c,d+1),function(n){e.forEach(t.predecessors(n),function(e){var i=t.node(e),a=i.order;(a<s||p<a)&&!(i.dummy&&t.node(n).dummy)&&o(r,e,n)})}),c=d+1,s=p)}),i}return e.reduce(n,i),r}function i(t,n){var r={};function i(n,i,a,s,c){var l;e.forEach(e.range(i,a),function(i){l=n[i],t.node(l).dummy&&e.forEach(t.predecessors(l),function(e){var n=t.node(e);n.dummy&&(n.order<s||n.order>c)&&o(r,e,l)})})}function a(n,r){var a=-1,o,s=0;return e.forEach(r,function(e,c){if(t.node(e).dummy===`border`){var l=t.predecessors(e);l.length&&(o=t.node(l[0]).order,i(r,s,c,a,o),s=c,a=o)}i(r,s,r.length,o,n.length)}),r}return e.reduce(n,a),r}function a(t,n){if(t.node(n).dummy)return e.find(t.predecessors(n),function(e){return t.node(e).dummy})}function o(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function s(t,n,r){if(n>r){var i=n;n=r,r=i}return e.has(t[n],r)}function c(t,n,r,i){var a={},o={},c={};return e.forEach(n,function(t){e.forEach(t,function(e,t){a[e]=e,o[e]=e,c[e]=t})}),e.forEach(n,function(t){var n=-1;e.forEach(t,function(t){var l=i(t);if(l.length){l=e.sortBy(l,function(e){return c[e]});for(var u=(l.length-1)/2,d=Math.floor(u),f=Math.ceil(u);d<=f;++d){var p=l[d];o[t]===t&&n<c[p]&&!s(r,t,p)&&(o[p]=t,o[t]=a[t]=a[p],n=c[p])}}})}),{root:a,align:o}}function l(t,n,r,i,a){var o={},s=u(t,n,r,a),c=a?`borderLeft`:`borderRight`;function l(e,t){for(var n=s.nodes(),r=n.pop(),i={};r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function d(e){o[e]=s.inEdges(e).reduce(function(e,t){return Math.max(e,o[t.v]+s.edge(t))},0)}function f(e){var n=s.outEdges(e).reduce(function(e,t){return Math.min(e,o[t.w]-s.edge(t))},1/0),r=t.node(e);n!==1/0&&r.borderType!==c&&(o[e]=Math.max(o[e],n))}return l(d,s.predecessors.bind(s)),l(f,s.successors.bind(s)),e.forEach(i,function(e){o[e]=o[r[e]]}),o}function u(n,r,i,a){var o=new t,s=n.graph(),c=h(s.nodesep,s.edgesep,a);return e.forEach(r,function(t){var r;e.forEach(t,function(e){var t=i[e];if(o.setNode(t),r){var a=i[r],s=o.edge(a,t);o.setEdge(a,t,Math.max(c(n,e,r),s||0))}r=e})}),o}function d(t,n){return e.minBy(e.values(n),function(n){var r=-1/0,i=1/0;return e.forIn(n,function(e,n){var a=g(t,n)/2;r=Math.max(e+a,r),i=Math.min(e-a,i)}),r-i})}function f(t,n){var r=e.values(n),i=e.min(r),a=e.max(r);e.forEach([`u`,`d`],function(r){e.forEach([`l`,`r`],function(o){var s=r+o,c=t[s],l;if(c!==n){var u=e.values(c);l=o===`l`?i-e.min(u):a-e.max(u),l&&(t[s]=e.mapValues(c,function(e){return e+l}))}})})}function p(t,n){return e.mapValues(t.ul,function(r,i){if(n)return t[n.toLowerCase()][i];var a=e.sortBy(e.map(t,i));return(a[1]+a[2])/2})}function m(t){var a=n.buildLayerMatrix(t),o=e.merge(r(t,a),i(t,a)),s={},u;return e.forEach([`u`,`d`],function(n){u=n===`u`?a:e.values(a).reverse(),e.forEach([`l`,`r`],function(r){r===`r`&&(u=e.map(u,function(t){return e.values(t).reverse()}));var i=(n===`u`?t.predecessors:t.successors).bind(t),a=c(t,u,o,i),d=l(t,u,a.root,a.align,r===`r`);r===`r`&&(d=e.mapValues(d,function(e){return-e})),s[n+r]=d})}),f(s,d(t,s)),p(s,t.graph().align)}function h(t,n,r){return function(i,a,o){var s=i.node(a),c=i.node(o),l=0,u;if(l+=s.width/2,e.has(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:u=-s.width/2;break;case`r`:u=s.width/2}if(u&&(l+=r?u:-u),u=0,l+=(s.dummy?n:t)/2,l+=(c.dummy?n:t)/2,l+=c.width/2,e.has(c,`labelpos`))switch(c.labelpos.toLowerCase()){case`l`:u=c.width/2;break;case`r`:u=-c.width/2}return u&&(l+=r?u:-u),u=0,l}}function g(e,t){return e.node(t).width}return I_}var z_,B_;function V_(){if(B_)return z_;B_=1;var e=Q(),t=$(),n=R_().positionX;z_=r;function r(r){r=t.asNonCompoundGraph(r),i(r),e.forEach(n(r),function(e,t){r.node(t).x=e})}function i(n){var r=t.buildLayerMatrix(n),i=n.graph().ranksep,a=0;e.forEach(r,function(t){var r=e.max(e.map(t,function(e){return n.node(e).height}));e.forEach(t,function(e){n.node(e).y=a+r/2}),a+=r+i})}return z_}var H_,U_;function W_(){if(U_)return H_;U_=1;var e=Q(),t=Ng(),n=Rg(),r=Xg(),i=$().normalizeRanks,a=$g(),o=$().removeEmptyRanks,s=n_(),c=a_(),l=c_(),u=F_(),d=V_(),f=$(),p=Z().Graph;H_=m;function m(e,t){var n=t&&t.debugTiming?f.time:f.notime;n(`layout`,function(){var t=n(` buildLayoutGraph`,function(){return T(e)});n(` runLayout`,function(){h(t,n)}),n(` updateInputGraph`,function(){g(e,t)})})}function h(e,p){p(` makeSpaceForEdgeLabels`,function(){E(e)}),p(` removeSelfEdges`,function(){N(e)}),p(` acyclic`,function(){t.run(e)}),p(` nestingGraph.run`,function(){s.run(e)}),p(` rank`,function(){r(f.asNonCompoundGraph(e))}),p(` injectEdgeLabelProxies`,function(){D(e)}),p(` removeEmptyRanks`,function(){o(e)}),p(` nestingGraph.cleanup`,function(){s.cleanup(e)}),p(` normalizeRanks`,function(){i(e)}),p(` assignRankMinMax`,function(){O(e)}),p(` removeEdgeLabelProxies`,function(){k(e)}),p(` normalize.run`,function(){n.run(e)}),p(` parentDummyChains`,function(){a(e)}),p(` addBorderSegments`,function(){c(e)}),p(` order`,function(){u(e)}),p(` insertSelfEdges`,function(){P(e)}),p(` adjustCoordinateSystem`,function(){l.adjust(e)}),p(` position`,function(){d(e)}),p(` positionSelfEdges`,function(){F(e)}),p(` removeBorderNodes`,function(){te(e)}),p(` normalize.undo`,function(){n.undo(e)}),p(` fixupEdgeLabelCoords`,function(){j(e)}),p(` undoCoordinateSystem`,function(){l.undo(e)}),p(` translateGraph`,function(){A(e)}),p(` assignNodeIntersects`,function(){ee(e)}),p(` reversePoints`,function(){M(e)}),p(` acyclic.undo`,function(){t.undo(e)})}function g(t,n){e.forEach(t.nodes(),function(e){var r=t.node(e),i=n.node(e);r&&(r.x=i.x,r.y=i.y,n.children(e).length&&(r.width=i.width,r.height=i.height))}),e.forEach(t.edges(),function(r){var i=t.edge(r),a=n.edge(r);i.points=a.points,e.has(a,`x`)&&(i.x=a.x,i.y=a.y)}),t.graph().width=n.graph().width,t.graph().height=n.graph().height}var _=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],v={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},y=[`acyclicer`,`ranker`,`rankdir`,`align`],b=[`width`,`height`],x={width:0,height:0},S=[`minlen`,`weight`,`width`,`height`,`labeloffset`],C={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},w=[`labelpos`];function T(t){var n=new p({multigraph:!0,compound:!0}),r=ne(t.graph());return n.setGraph(e.merge({},v,I(r,_),e.pick(r,y))),e.forEach(t.nodes(),function(r){var i=ne(t.node(r));n.setNode(r,e.defaults(I(i,b),x)),n.setParent(r,t.parent(r))}),e.forEach(t.edges(),function(r){var i=ne(t.edge(r));n.setEdge(r,e.merge({},C,I(i,S),e.pick(i,w)))}),n}function E(t){var n=t.graph();n.ranksep/=2,e.forEach(t.edges(),function(e){var r=t.edge(e);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(n.rankdir===`TB`||n.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function D(t){e.forEach(t.edges(),function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e};f.addDummyNode(t,`edge-proxy`,i,`_ep`)}})}function O(t){var n=0;e.forEach(t.nodes(),function(r){var i=t.node(r);i.borderTop&&(i.minRank=t.node(i.borderTop).rank,i.maxRank=t.node(i.borderBottom).rank,n=e.max(n,i.maxRank))}),t.graph().maxRank=n}function k(t){e.forEach(t.nodes(),function(e){var n=t.node(e);n.dummy===`edge-proxy`&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))})}function A(t){var n=1/0,r=0,i=1/0,a=0,o=t.graph(),s=o.marginx||0,c=o.marginy||0;function l(e){var t=e.x,o=e.y,s=e.width,c=e.height;n=Math.min(n,t-s/2),r=Math.max(r,t+s/2),i=Math.min(i,o-c/2),a=Math.max(a,o+c/2)}e.forEach(t.nodes(),function(e){l(t.node(e))}),e.forEach(t.edges(),function(n){var r=t.edge(n);e.has(r,`x`)&&l(r)}),n-=s,i-=c,e.forEach(t.nodes(),function(e){var r=t.node(e);r.x-=n,r.y-=i}),e.forEach(t.edges(),function(r){var a=t.edge(r);e.forEach(a.points,function(e){e.x-=n,e.y-=i}),e.has(a,`x`)&&(a.x-=n),e.has(a,`y`)&&(a.y-=i)}),o.width=r-n+s,o.height=a-i+c}function ee(t){e.forEach(t.edges(),function(e){var n=t.edge(e),r=t.node(e.v),i=t.node(e.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(f.intersectRect(r,a)),n.points.push(f.intersectRect(i,o))})}function j(t){e.forEach(t.edges(),function(n){var r=t.edge(n);if(e.has(r,`x`))switch((r.labelpos===`l`||r.labelpos===`r`)&&(r.width-=r.labeloffset),r.labelpos){case`l`:r.x-=r.width/2+r.labeloffset;break;case`r`:r.x+=r.width/2+r.labeloffset}})}function M(t){e.forEach(t.edges(),function(e){var n=t.edge(e);n.reversed&&n.points.reverse()})}function te(t){e.forEach(t.nodes(),function(n){if(t.children(n).length){var r=t.node(n),i=t.node(r.borderTop),a=t.node(r.borderBottom),o=t.node(e.last(r.borderLeft)),s=t.node(e.last(r.borderRight));r.width=Math.abs(s.x-o.x),r.height=Math.abs(a.y-i.y),r.x=o.x+r.width/2,r.y=i.y+r.height/2}}),e.forEach(t.nodes(),function(e){t.node(e).dummy===`border`&&t.removeNode(e)})}function N(t){e.forEach(t.edges(),function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||=[],n.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e)}})}function P(t){var n=f.buildLayerMatrix(t);e.forEach(n,function(n){var r=0;e.forEach(n,function(n,i){var a=t.node(n);a.order=i+r,e.forEach(a.selfEdges,function(e){f.addDummyNode(t,`selfedge`,{width:e.label.width,height:e.label.height,rank:a.rank,order:i+ ++r,e:e.e,label:e.label},`_se`)}),delete a.selfEdges})})}function F(t){e.forEach(t.nodes(),function(e){var n=t.node(e);if(n.dummy===`selfedge`){var r=t.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function I(t,n){return e.mapValues(e.pick(t,n),Number)}function ne(t){var n={};return e.forEach(t,function(e,t){n[t.toLowerCase()]=e}),n}return H_}var G_,K_;function q_(){if(K_)return G_;K_=1;var e=Q(),t=$(),n=Z().Graph;G_={debugOrdering:r};function r(r){var i=t.buildLayerMatrix(r),a=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(r.nodes(),function(e){a.setNode(e,{label:e}),a.setParent(e,`layer`+r.node(e).rank)}),e.forEach(r.edges(),function(e){a.setEdge(e.v,e.w,{},e.name)}),e.forEach(i,function(t,n){var r=`layer`+n;a.setNode(r,{rank:`same`}),e.reduce(t,function(e,t){return a.setEdge(e,t,{style:`invis`}),t})}),a}return G_}var J_,Y_;function X_(){return Y_?J_:(Y_=1,J_=`0.8.5`,J_)}var Z_,Q_;function $_(){return Q_?Z_:(Q_=1,Z_={graphlib:Z(),layout:W_(),debug:q_(),util:{time:$().time,notime:$().notime},version:X_()},Z_)}var ev=$_(),tv=en(ev),nv=function(e){return Zt(e,`Boolean`)};function rv(e,t){if(e){var n;if(qt(e))for(var r=0,i=e.length;r<i&&(n=t(e[r],r),n!==!1);r++);else if(Jt(e)){for(var a in e)if(e.hasOwnProperty(a)&&(n=t(e[a],a),n===!1))break}}}var iv=Object.prototype.hasOwnProperty,av=(function(e,t){if(e===null||!Qt(e))return{};var n={};return rv(t,function(t){iv.call(e,t)&&(n[t]=e[t])}),n}),ov=class extends Kt{constructor(){super(...arguments),this.id=`dagre`,this.isCompoundGraph=null,this.config={graphAttributes:[`rankdir`,`align`,`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`,`acyclicer`,`ranker`],nodeAttributes:[`width`,`height`],edgeAttributes:[`minlen`,`weight`,`width`,`height`,`labelpos`,`labeloffset`]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:`TB`,align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:`network-simplex`,nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:`r`,edgeLabelOffset:10}}layout(){return Fe(this,void 0,void 0,function*(){let e=new ev.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});e.setGraph(av(this.options,this.config.graphAttributes)),e.setDefaultEdgeLabel(()=>({}));let t=lt(this.options.nodeSize,0);this.model.forEachNode(n=>{let r=n._original,[i,a]=rt(t(r)),o={width:i,height:a};if(e.setNode(String(n.id),o),this.isCompound()){if(H(n.parentId))return;e.setParent(String(n.id),String(n.parentId))}});let{edgeLabelSize:n,edgeLabelOffset:r,edgeLabelPos:i,edgeMinLen:a,edgeWeight:o}=this.options,s=lt(n,0,`edge`),c=ct(r,10,`edge`),l=typeof i==`string`?()=>i:st(i,[`edge`]),u=ct(a,1,`edge`),d=ct(o,1,`edge`);this.model.forEachEdge(t=>{let n=t._original,[r,i]=rt(s(n)),a={width:r,height:i,labelpos:l(n),labeloffset:c(n),minlen:u(n),weight:d(n)};e.setEdge(String(t.source),String(t.target),a,String(t.id))}),tv.layout(e),this.model.forEachNode(t=>{let n=e.node(String(t.id));n&&(t.x=n.x,t.y=n.y,t.size=[n.width,n.height])}),this.model.forEachEdge(t=>{let n=e.edge(String(t.source),String(t.target),String(t.id));if(!n)return;let{width:r,height:i,weight:a,minlen:o,labelpos:s,labeloffset:c,points:l}=n;t.labelSize=[r,i],t.weight=a,t.minLen=o,t.labelPos=s,t.labelOffset=c,t.points=l.map(ut)})})}isCompound(){return this.isCompoundGraph===null?nv(this.options.compound)?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(e=>!H(e.parentId)),this.isCompoundGraph):this.isCompoundGraph}},sv=26,cv=72,lv=24,uv=28,dv=16,fv=8,pv=20,mv=24,hv=12,gv=22,_v=52,vv=24,yv=3,bv=(e,t,n)=>{let r=(e,t)=>{let n=Array.from(new Set(e)).sort((e,t)=>e-t),r=[];for(let e of n)(r.length===0||e-r[r.length-1]>t)&&r.push(e);return r},i=r(e.map(e=>t.get(e.id)),sv),a=r(e.map(e=>n.get(e.id)),cv),o=(e,t)=>{let n=0;for(let r=1;r<e.length;r++)Math.abs(e[r]-t)<Math.abs(e[n]-t)&&(n=r);return n},s=new Map,c=new Map;for(let n of e)s.set(n.id,o(i,t.get(n.id)));for(;;){for(let t of e)c.set(t.id,o(a,n.get(t.id)));let t=new Map,r;for(let i of e){let e=`${s.get(i.id)}:${c.get(i.id)}`,o=t.get(e);if(o===void 0){t.set(e,i);continue}let l=a[c.get(i.id)];r=Math.abs(n.get(i.id)-l)>Math.abs(n.get(o.id)-l)?n.get(i.id):n.get(o.id);break}if(r===void 0)break;a.push(r),a.sort((e,t)=>e-t)}return{col:s,row:c,ncols:i.length,nrows:a.length}},xv=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,[n]):r.push(n)},Sv=(e,t,n,r)=>{let i=new Set;for(let t of e)i.add(`${n.get(t.id)}:${r.get(t.id)}`);let a=new Map;for(let e of t)e.source!==e.target&&(xv(a,e.source,e.target),xv(a,e.target,e.source));for(let t of e){let e=a.get(t.id);if(e===void 0)continue;let o=e.map(e=>r.get(e)).sort((e,t)=>e-t),s=o[Math.floor((o.length-1)/2)],c=r.get(t.id),l=Math.abs(s-c);if(l===0)continue;let u=Math.sign(s-c),d;if(l===1){if(!e.some(e=>r.get(e)===s&&Math.abs(n.get(e)-n.get(t.id))===1))continue;d=s}else d=c+u*Math.ceil(l/2);for(let e=d;e!==c;e-=u)if(!i.has(`${n.get(t.id)}:${e}`)){i.delete(`${n.get(t.id)}:${c}`),i.add(`${n.get(t.id)}:${e}`),r.set(t.id,e);break}}},Cv=(e,t,n,r)=>{let i=new Set;for(let t of e)i.add(`${n.get(t.id)}:${r.get(t.id)}`);let a=new Set;for(let e of t)a.add(e.source),a.add(e.target);let o=e.filter(e=>!a.has(e.id)).sort((e,t)=>r.get(e.id)-r.get(t.id));for(let e of o){let t=n.get(e.id);for(let n=0;n<r.get(e.id);n++)if(!i.has(`${t}:${n}`)){i.delete(`${t}:${r.get(e.id)}`),i.add(`${t}:${n}`),r.set(e.id,n);break}}let s=new Map;for(let t of e)xv(s,r.get(t.id),t);let c=Math.max(...s.keys()),l=new Map,u=-1,d=new Set;for(let e=0;e<=c;e++){let t=s.get(e)??[];(u<0||t.some(e=>d.has(n.get(e.id))))&&(u++,d=new Set);for(let e of t)d.add(n.get(e.id));l.set(e,u)}for(let t of e)r.set(t.id,l.get(r.get(t.id)));return u+1},wv=(e,t,n,r,i,a)=>{let o=Array.from(e).filter(([,e])=>e===`in`).map(([e])=>e),s=Array.from(e).filter(([,e])=>e===`out`).map(([e])=>e);if(o.length>0){for(let e of n.keys())n.set(e,n.get(e)+1);i++}s.length>0&&i++;let c=(e,i)=>{let o=new Map;for(let n of e){let e=t.find(e=>e.source===n||e.target===n);o.set(n,e.source===n?e.target:e.source)}let s=e=>r.get(o.get(e));e.sort((e,t)=>s(e)-s(t));let c=[];for(let t of e){let e=s(t),o=e=>c.some(t=>r.get(t)===e),l;for(let t=0;l===void 0&&t<a;t++)e+t<a&&!o(e+t)?l=e+t:e-t>=0&&!o(e-t)&&(l=e-t);if(l===void 0){for(let[t,n]of r)n>e&&r.set(t,n+1);a++,l=e+1}n.set(t,i),r.set(t,l),c.push(t)}};return c(o,0),c(s,i-1),{ncols:i,nrows:a}},Tv=e=>e.gate===`t`?[e.chans[0]]:e.gate===`s`?[e.chans[1]]:e.chans,Ev=(e,t,n,r,i)=>{let a=(e,t)=>({mirror:e===`r`,hairpin:e===t}),o=e.map((e,o)=>{let s=t.get(e.source);if(e.source===e.target)return{chans:[s],guts:[],flags:[a(`l`,`l`)]};let c=t.get(e.target),l=n.get(e.source),u=n.get(e.target),d=r[o].s===`e`?s:s-1,f=r[o].t===`w`?c-1:c,p=r[o].s===`e`?`l`:`r`,m=r[o].t===`w`?`r`:`l`;if(d===f)return{chans:[d],guts:[],flags:[a(p,m)]};let h=f>d?`r`:`l`,g=i.has(e.target)?`t`:i.has(e.source)?`s`:void 0;return{chans:[d,f],guts:[u>l?u-1:u],flags:[a(p,h),a(h===`r`?`l`:`r`,m)],gate:g}}),s=new Map,c=new Map,l=new Map,u=new Map,d=(e,t)=>l.set(e,Math.max(l.get(e)??0,t));o.forEach((t,n)=>{let r=Tv(t);for(let e of r)s.set(e,(s.get(e)??0)+1);for(let e of t.guts)c.set(e,(c.get(e)??0)+1);let{name:i,arity:a,source:o,target:l}=e[n];o!==l&&(i!==void 0&&t.chans.length===1?d(t.chans[0],y(i,16)+16):i!==void 0&&t.guts.length>0&&u.set(t.guts[0],(u.get(t.guts[0])??0)+1),a!==void 0&&r.length>0&&d(r[r.length-1],24+y(a,16)+fv))});let f=new Map,p=new Map;for(let t of e.filter(e=>e.source===e.target)){let e=(f.get(t.source)??0)+1;f.set(t.source,e);let r=n.get(t.source)-1;p.set(r,Math.max(p.get(r)??0,e))}return{plans:o,chanCnt:s,gutCnt:c,chanLbl:l,gutLbl:u,gutLoop:p}},Dv=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=Array.from({length:a},()=>0),m=Array.from({length:o},()=>0);for(let a of e)p[t.get(a.id)]=Math.max(p[t.get(a.id)],r.get(a.id)),m[n.get(a.id)]=Math.max(m[n.get(a.id)],i.get(a.id));let h=Array.from({length:a},(e,t)=>{let n=s.get(t)??0;return Math.min(f[`graph-channel-width-max`],Math.max(f[`graph-channel-width-min`],n===0?lv:uv+(n-1)*f[`size-edge-track-gap`],l.get(t)??0))}),g=Array.from({length:o},(e,t)=>{let n=c.get(t)??0,r=u.get(t)??0,i=d.get(t)??0;return Math.min(f[`graph-gutter-height-max`],Math.max(f[`graph-gutter-height-min`],n===0?pv:mv+(n-1)*f[`size-edge-track-gap`],r>0?mv+r*gv:0,i>0?_v+(i-1)*f[`size-edge-track-gap`]+hv:0))}),_=[],v=[],y=f[`size-canvas-margin`];for(let e=0;e<p.length;e++)_.push(y+p[e]/2),y+=p[e]+h[e];let b=f[`size-canvas-margin`];for(let e=0;e<m.length;e++)v.push(b+m[e]/2),b+=m[e]+g[e];return{colWidth:p,rowHeight:m,chanW:h,gutH:g,colCX:_,rowCY:v}},Ov=(e,t,n,r,i)=>{let{colWidth:a,rowHeight:o,chanW:s,gutH:c,colCX:l,rowCY:u}=r,d=e=>u[e]+o[e]/2+c[e]/2,f=new Map;e.forEach((e,r)=>{let{chans:i,guts:a,flags:o,gate:s}=t[r];if(i.length===0)return;let c=n.get(`${r}:s`),l=n.get(`${r}:t`);if(e.source===e.target)xv(f,i[0],{edge:r,posIn:c.y,posOut:l.y-_v,...o[0]});else if(i.length===1)xv(f,i[0],{edge:r,posIn:c.y,posOut:l.y,...o[0]});else{let e=d(a[0]);s!==`s`&&xv(f,i[0],{edge:r,posIn:c.y,posOut:e,...o[0]}),s!==`t`&&xv(f,i[1],{edge:r,posIn:e,posOut:l.y,...o[1]})}});let p=new Map;for(let[e,t]of f)for(let[n,r]of ce(t,s[e],dv,i[`size-edge-track-gap`]))p.set(`${e}:${n}`,r);let m=(e,t)=>l[e]+a[e]/2+s[e]/2+p.get(`${e}:${t}`),h=new Map;e.forEach((e,r)=>{let{chans:i,guts:a,gate:o}=t[r];if(a.length===0)return;let s=n.get(`${r}:s`),c=n.get(`${r}:t`);xv(h,a[0],{edge:r,posIn:o===`s`?s.x:m(i[0],r),posOut:o===`t`?c.x:m(i[1],r),mirror:s.y>d(a[0])})});let g=new Map;for(let[e,t]of h)for(let[n,r]of ce(t,c[e],hv,i[`size-edge-track-gap`]))g.set(`${e}:${n}`,r);return{chanX:m,gutY:(e,t)=>d(e)+g.get(`${e}:${t}`)}},kv=(e,t,n,r,i,a,o)=>{let s=new Map;return e.forEach((e,n)=>{e.source===e.target&&s.set(e.source,Math.min(s.get(e.source)??1/0,a(t[n].chans[0],n)))}),e.map((e,c)=>{let l=n.get(`${c}:s`),u=n.get(`${c}:t`),{chans:d,guts:f,flags:p}=t[c],m;if(e.source===e.target){let t=a(d[0],c),n=i(e.source)-r.get(e.source)/2-_v-(t-s.get(e.source));m=[[l.x,l.y],[t,l.y],[t,n],[u.x,n],[u.x,u.y]]}else if(d.length===1){let e=a(d[0],c);m=!p[0].hairpin&&l.y===u.y?[[l.x,l.y],[u.x,u.y]]:[[l.x,l.y],[e,l.y],[e,u.y],[u.x,u.y]]}else{let e=a(d[0],c),n=a(d[1],c),r=o(f[0],c);m=t[c].gate===`t`?[[l.x,l.y],[e,l.y],[e,r],[u.x,r]]:t[c].gate===`s`?[[l.x,r],[n,r],[n,u.y],[u.x,u.y]]:[[l.x,l.y],[e,l.y],[e,r],[n,r],[n,u.y],[u.x,u.y]]}return F(m)})},Av=(e,t,n,r,i,a,o,s,c,l)=>{let u=Ov(e,t,I(e,n,a,o,r,i,c[`size-edge-port-gap`],void 0,l.fixedPort),s,c),d=I(e,n,a,o,r,i,c[`size-edge-port-gap`],e=>t[e].guts.length>0?u.gutY(t[e].guts[0],e):void 0,l.fixedPort),{chanX:f,gutY:p}=Ov(e,t,d,s,c),m=kv(e,t,d,i,o,f,p);return{portPos:d,gutY:p,polys:m,hops:le(m).reduce((e,t)=>e+Array.from(t.values()).reduce((e,t)=>e+t.length,0),0)}},jv=(e,t,n,r,i,a,o,s,c,l)=>{let u=(e,a)=>!n.some(t=>t.guts[0]===e&&Math.min(...t.chans)<a&&a<=Math.max(...t.chans)+ +(t.gate===`t`))&&!t.some(t=>t.source===t.target&&i.get(t.source)===e+1&&r.get(t.source)===a),d=e=>{let t=i.get(e),n=r.get(e),c=(o.rowHeight[t]-a.get(e))/2,l=t>0&&u(t-1,n)?o.gutH[t-1]-pv:0,d=t<s-1&&u(t,n)?o.gutH[t]-pv:0;return[-(c+l),c+d]},f=(e,r)=>t.every((t,a)=>{let o=t.source===e?`s`:t.target===e?`t`:null;if(o===null||n[a].guts.length===0)return!0;let s=n[a].guts[0],c=r.portPos.get(`${a}:${o}`).y-r.gutY(s,a);return i.get(e)>s?c>=vv:c<=-24}),p=t.map((e,t)=>n[t].chans.length===1&&!n[t].flags[0].hairpin&&i.get(e.source)===i.get(e.target)),m=e=>t.filter((t,n)=>p[n]&&e.portPos.get(`${n}:s`).y!==e.portPos.get(`${n}:t`).y).length,h=(e,t)=>e.hops<t.hops||e.hops===t.hops&&m(e)<m(t),g=l();for(let n=0;n<yv;n++){let n=!1;for(let r of e){let[e,i]=d(r.id),a=new Set;t.forEach((e,t)=>{if(!p[t])return;let n=g.portPos.get(`${t}:s`),i=g.portPos.get(`${t}:t`);e.source===r.id?a.add(i.y-n.y):e.target===r.id&&a.add(n.y-i.y)});let o=c.get(r.id)??0,s;for(let t of a){if(t===0||o+t<e||o+t>i)continue;c.set(r.id,o+t);let n=l();f(r.id,n)&&h(n,s?.routing??g)&&(s={shift:o+t,routing:n})}c.set(r.id,s?.shift??o),s!==void 0&&(g=s.routing,n=!0)}if(!n)break}return g},Mv=(e,t,n)=>e.map((e,r)=>{let i=t.get(e.source),a=t.get(e.target);return e.source===e.target?{s:`e`,t:`n`}:{s:n.fixedPort?.(r,`s`)===void 0?i<=a?`e`:`w`:`e`,t:n.fixedPort?.(r,`t`)===void 0?i<a?`w`:`e`:`w`}}),Nv=(e,t,n,r,i,a)=>{let o=new Map;t.forEach((e,t)=>{o.set(`${n[t].s}:${e.source}`,(o.get(`${n[t].s}:${e.source}`)??0)+1),o.set(`${n[t].t}:${e.target}`,(o.get(`${n[t].t}:${e.target}`)??0)+1)});for(let t of e){if(a.fixedSize?.has(t.id))continue;let e=Math.max(o.get(`w:${t.id}`)??0,o.get(`e:${t.id}`)??0);e>i[`graph-node-degree-max`]&&r.set(t.id,r.get(t.id)+(e-i[`graph-node-degree-max`])*i[`size-edge-port-gap`])}},Pv=async(e,t,n={})=>{let r=Array.from(e.nodes.values()),i=e.edges,a=n.gates??new Map,o=r.filter(e=>!a.has(e.id)),s=i.filter(e=>!a.has(e.source)&&!a.has(e.target)),{boxW:c,boxH:l,contentH:u}=N(r,t,()=>t[`size-node-height-scale`]/2,n.fixedSize),d=Math.max(Math.floor(t[`graph-columns-max`]),1),f=new Map,p=new Map,m,h;if(o.some(e=>O(e)!==void 0)){let e=e=>O(e)??1/0,t=Array.from(new Set(o.map(e))).sort((e,t)=>e-t);m=1,h=0;for(let n of t){let t=o.filter(t=>e(t)===n);t.forEach((e,t)=>{f.set(e.id,t%d),p.set(e.id,h+Math.floor(t/d))}),m=Math.max(m,Math.min(t.length,d)),h+=Math.ceil(t.length/d)}}else{let e=new Map,n=new Map;if(o.length>0){let r=new ov({rankdir:`LR`,nodesep:t[`graph-node-separation`],ranksep:t[`graph-rank-separation`],nodeSize:e=>e.size});await r.execute({nodes:o.map(e=>({id:e.id,size:[c.get(e.id),l.get(e.id)]})),edges:s.map((e,t)=>({id:`e${t}`,source:e.source,target:e.target}))}),r.forEachNode(t=>{e.set(String(t.id),t.x),n.set(String(t.id),t.y)})}let r=bv(o,e,n);for(let[e,t]of r.col)f.set(e,t);for(let[e,t]of r.row)p.set(e,t);if(Sv(o,s,f,p),r.ncols>d)for(let e of o){let t=f.get(e.id);f.set(e.id,t%d),p.set(e.id,p.get(e.id)+Math.floor(t/d)*r.nrows)}m=Math.min(r.ncols,d),h=Cv(o,s,f,p)}({ncols:m,nrows:h}=wv(a,i,f,p,m,h));let g=Mv(i,f,n),_=Ev(i,f,p,g,a);if(_.plans.some(e=>e.chans.some(e=>e<0))){for(let e of r)f.set(e.id,f.get(e.id)+1);m++,_=Ev(i,f,p,g,a)}let{plans:v,chanCnt:y,gutCnt:b,chanLbl:x,gutLbl:S,gutLoop:C}=_;Nv(r,i,g,l,t,n);let w=Dv(r,f,p,c,l,m,h,y,b,x,S,C,t),T=new Map,E=e=>w.colCX[f.get(e)],D=e=>w.rowCY[p.get(e)]+(T.get(e)??0);return{nodes:r,edges:i,cx:E,cy:D,boxW:c,boxH:l,contentH:u,polys:jv(r,i,v,f,p,l,w,h,T,()=>Av(i,v,g,c,l,E,D,w,t,n)).polys}},Fv=`\0`,Iv=28,Lv=16,Rv=e=>{let t=Array.from(e.nodes.values());for(let e of t)if(e.id.includes(Fv))throw Error(`node id ${JSON.stringify(e.id)} contains a reserved control character`);let n=t.filter(S);if(n.length!==1)throw Error(`expected exactly one node annotated with "primary: true" (found ${n.length})`);let r=n[0],i=new Set,a=new Set;for(let t of e.edges)if(t.source===r.id&&t.target===r.id)throw Error(`self-loop on primary node "${r.id}" not supported`);else if(t.target===r.id)i.add(t.source);else if(t.source===r.id)a.add(t.target);else throw Error(`edge "${t.source}" --> "${t.target}" does not connect to primary node "${r.id}"`);let o=new Set,s=[],c=[];for(let e of t){if(e.id===r.id)continue;let t=i.has(e.id),n=a.has(e.id);if(!t&&!n)throw Error(`node "${e.id}" is neither input nor output of primary node "${r.id}"`);t&&n?(o.add(e.id),s.push({...e,id:e.id+`\0in`}),c.push({...e,id:e.id+`\0out`})):t?s.push(e):c.push(e)}let l=e.edges.map(e=>e.target===r.id&&o.has(e.source)?{...e,source:e.source+`\0in`}:e.source===r.id&&o.has(e.target)?{...e,target:e.target+`\0out`}:e);return{center:r,inputs:s,outputs:c,nodes:[r,...s,...c],edges:l}},zv={graph:{render:Pv,gated:!0},hub:{render:async(e,t,n={})=>{let{center:r,inputs:i,outputs:a,nodes:o,edges:s}=Rv(e),c=new Set(i.map(e=>e.id)),l=t[`size-canvas-margin`],u=t[`hub-node-gap`],d=t[`size-node-height-scale`],f=e=>e===r.id?1:c.has(e)?0:2,p=s.map(()=>({s:`e`,t:`w`})),{boxW:m,boxH:h,contentH:g}=N(o,t,()=>d/2,n.fixedSize),_=new Map;s.forEach((e,t)=>{_.set(`${p[t].s}:${e.source}`,(_.get(`${p[t].s}:${e.source}`)??0)+1),_.set(`${p[t].t}:${e.target}`,(_.get(`${p[t].t}:${e.target}`)??0)+1)});for(let e of o){if(n.fixedSize?.has(e.id))continue;let r=Math.max(_.get(`w:${e.id}`)??0,_.get(`e:${e.id}`)??0);r>t[`hub-node-degree-max`]&&h.set(e.id,h.get(e.id)+(r-t[`hub-node-degree-max`])*t[`size-edge-port-gap`])}let v=e=>e.reduce((e,t)=>e+h.get(t.id),0)+Math.max(e.length-1,0)*u,y=Math.max(v(i),h.get(r.id),v(a)),b=new Map,x=e=>{let t=l+(y-v(e))/2;for(let n of e)b.set(n.id,t+h.get(n.id)/2),t+=h.get(n.id)+u};x(i),x(a),b.set(r.id,l+y/2);let S=[i.reduce((e,t)=>Math.max(e,m.get(t.id)),0),m.get(r.id),a.reduce((e,t)=>Math.max(e,m.get(t.id)),0)],w=e=>Math.min(f(e.source),f(e.target)),T=[s.filter(e=>w(e)===0).length,s.filter(e=>w(e)===1).length].map(e=>Math.min(t[`hub-channel-width-max`],Math.max(t[`hub-channel-width-min`],Iv+(e-1)*t[`size-edge-track-gap`]))),E=[],D=l;for(let e=0;e<3;e++)E.push(D),D+=S[e]+(e<2?T[e]:0);let O=e=>{let t=f(e);return t===0?E[0]+S[0]-m.get(e)/2:t===2?E[2]+m.get(e)/2:E[1]+S[1]/2},k=e=>b.get(e),A=I(s,p,O,k,m,h,t[`size-edge-port-gap`],void 0,n.fixedPort),ee=[[],[]];s.forEach((e,t)=>{ee[w(e)].push({edge:t,posIn:A.get(`${t}:s`).y,posOut:A.get(`${t}:t`).y,mirror:!1})});let j=new Map;ee.forEach((e,n)=>{for(let[r,i]of ce(e,T[n],Lv,t[`size-edge-track-gap`]))j.set(`${n}:${r}`,i)});let M=(e,t)=>E[e]+S[e]+T[e]/2+j.get(`${e}:${t}`);return{nodes:o,edges:s,cx:O,cy:k,boxW:m,boxH:h,contentH:g,polys:s.map((e,t)=>{let n=A.get(`${t}:s`),r=A.get(`${t}:t`),i=M(w(e),t),a;return a=n.y===r.y?[[n.x,n.y],[r.x,r.y]]:[[n.x,n.y],[i,n.y],[i,r.y],[r.x,r.y]],F(a)}),styleOf:e=>e.id.endsWith(`\0out`)?{fill:`color-node-ghost-box`,stroke:`color-node-ghost-border`,text:`color-node-ghost-name`,dash:`10 6`}:C(e)}},gated:!1},grid:{render:async(e,t,n={})=>{let r=Array.from(e.nodes.values()).sort((e,t)=>(O(e)??1/0)-(O(t)??1/0)||0),i=t[`size-canvas-margin`],a=t[`grid-gap-horizontal`],o=t[`grid-gap-vertical`],s=Math.max(Math.floor(t[`grid-columns-max`]),1),c=Math.max(Math.floor(t[`grid-columns-min`]),1);if(e.edges.length>0){let t=e.edges[0];throw Error(`diagram type "grid" does not support edges (found ${e.edges.length}, first is "${t.source}" --> "${t.target}")`)}let{boxW:l,boxH:u,contentH:d}=N(r,t,()=>t[`size-node-height-scale`]/2,n.fixedSize),f=e=>n.fixedSize?.has(e.id)??!1,p=r.reduce((e,t)=>f(t)?e:Math.max(e,u.get(t.id)),0),m=r.reduce((e,t)=>Math.max(e,l.get(t.id)),0);for(let e of r)t[`grid-node-height-equal`]&&!f(e)&&u.set(e.id,p),t[`grid-node-width-equal`]&&l.set(e.id,m);let h=Math.max(Math.min(Math.max(Math.ceil(Math.sqrt(r.length)),c),s,r.length),1),g=Math.ceil(r.length/h),_=Array.from({length:h},()=>0),v=Array.from({length:g},()=>0);r.forEach((e,t)=>{let[n,r]=[t%h,Math.floor(t/h)];_[n]=Math.max(_[n],l.get(e.id)),v[r]=Math.max(v[r],u.get(e.id))});let y=[],b=i;for(let e=0;e<h;e++)y.push(b),b+=_[e]+a;let x=[],S=i;for(let e=0;e<g;e++)x.push(S),S+=v[e]+o;let C=new Map,w=new Map;return r.forEach((e,t)=>{C.set(e.id,y[t%h]+l.get(e.id)/2),w.set(e.id,x[Math.floor(t/h)]+u.get(e.id)/2)}),{nodes:r,edges:[],cx:e=>C.get(e),cy:e=>w.get(e),boxW:l,boxH:u,contentH:d,polys:[]}},gated:!1}},Bv=Object.keys(zv),Vv=`graph`,Hv=e=>{let t;for(let n of e.split(/\r?\n/)){let e=/^[ \t]*#type[ \t]+([a-z][a-z0-9-]*)[ \t]*$/.exec(n);e===null||!Object.hasOwn(zv,e[1])||(t=e[1])}return t},Uv=[`svg:standalone`,`svg:embedded`,`url:xml`,`url:base64`];e.Gradia=class e{static config=Object.freeze({...p});static parse(e){return d(e)}static async generate(e,t={}){let n=t.type??`graph`;if(!Object.hasOwn(zv,n))throw Error(`invalid diagram type "${n}"`);let r=t.format??`svg:standalone`;if(!Uv.includes(r))throw Error(`invalid output format "${r}"`);let i=h(t.config??{},{trusted:!0}),a={...p,...i};for(let[t,n]of e.nodes)if(n.id!==t)throw Error(`node id "${n.id}" does not match its map key "${t}"`);for(let t of e.edges)for(let n of[t.source,t.target])if(!e.nodes.has(n))throw Error(`endpoint "${n}" of edge "${t.source}" --> "${t.target}" is not a declared node`);let o=R(e,Bv),s=e=>ge(e,o,n,zv,a),c=ye(e,o),l=Pe(c===null?await s(e):be(c,await Promise.all(c.map(e=>s(e.graph))),a),a,i,JSON.stringify({type:n,config:a,explicit:Object.keys(i).sort(),nodes:Array.from(e.nodes.values()),edges:e.edges}));return r===`svg:embedded`?l.replace(/^<\?xml[^?]*\?>\n/,``):r===`url:xml`?`data:image/svg+xml,${encodeURIComponent(l)}`:r===`url:base64`?`data:image/svg+xml;base64,${btoa(Array.from(new TextEncoder().encode(l),e=>String.fromCharCode(e)).join(``))}`:l}static async render(t,n={}){let r=e.parse(t),i=n.type??Hv(t),a={...g(t),...n.config??{}};return e.generate(r,{...n,type:i,config:a})}},e.diagramFormatDefault=`svg:standalone`,e.diagramFormats=Uv,e.diagramTypeDefault=Vv,e.diagramTypes=Bv});
|
package/dst/gradia-mcp.js
CHANGED
|
@@ -208,8 +208,10 @@ ${configOptions}
|
|
|
208
208
|
The "size-*", "group-*", "container-*", "graph-*", "hub-*", and "grid-*" options
|
|
209
209
|
control the rendering geometry (canvas margin, node box sizing, edge routing,
|
|
210
210
|
group and container box spacing, and the per-diagram-type layout) and take
|
|
211
|
-
non-negative numbers, except the
|
|
212
|
-
all node boxes of a "grid" diagram to
|
|
211
|
+
non-negative numbers, except the booleans "grid-node-width-equal" and
|
|
212
|
+
"grid-node-height-equal", which force all node boxes of a "grid" diagram to
|
|
213
|
+
the width of the widest one and to the height of the tallest one (a nested
|
|
214
|
+
container box taking part in the width unification only).
|
|
213
215
|
|
|
214
216
|
The "size-node-width-max" option additionally enables the word-wrapping of the
|
|
215
217
|
node box texts: given a positive value, the node name, its type, and its
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Object Graph Diagram Rendering",
|
|
4
4
|
"keywords": [ "object", "graph", "diagram", "rendering", "svg", "layout", "api", "cli" ],
|
|
5
5
|
"publishConfig": { "access": "public" },
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.3",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Dr. Ralf S. Engelschall",
|