@zombie-mermaid/ascii-renderer 2.2.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.cjs +7 -7
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1245 -1203
  4. package/dist/index.js.map +1 -1
  5. package/package.json +3 -3
  6. package/src/__tests__/ascii-decision-lr-box-start.test.ts +1 -1
  7. package/src/__tests__/ascii-er-attribute-column-order-1134.test.ts +69 -0
  8. package/src/__tests__/ascii-er-corner-glyphs.test.ts +27 -4
  9. package/src/__tests__/ascii-er-relationship-label-corruption-350.test.ts +13 -3
  10. package/src/__tests__/ascii-er-relationship-overwrite.test.ts +107 -0
  11. package/src/__tests__/ascii-er-stray-connectors.test.ts +15 -9
  12. package/src/__tests__/ascii-sequence-activation.test.ts +171 -0
  13. package/src/__tests__/ascii-shape-diamond.test.ts +1 -1
  14. package/src/__tests__/ascii-shape-rounded.test.ts +1 -1
  15. package/src/__tests__/ascii-shapes-circle.test.ts +1 -1
  16. package/src/__tests__/ascii-shapes-hexagon.test.ts +1 -1
  17. package/src/__tests__/ascii-shapes-special.test.ts +35 -0
  18. package/src/__tests__/ascii-validate.test.ts +1 -42
  19. package/src/__tests__/ascii.test.ts +1 -1
  20. package/src/__tests__/testdata/ascii/er_attributes.txt +9 -9
  21. package/src/__tests__/testdata/ascii/er_identifying.txt +8 -8
  22. package/src/__tests__/testdata/unicode/er_attributes.txt +9 -9
  23. package/src/__tests__/testdata/unicode/er_identifying.txt +8 -8
  24. package/src/{validate.ts → __tests__/validate.ts} +3 -40
  25. package/src/draw-boxes.ts +14 -0
  26. package/src/er-diagram.ts +134 -31
  27. package/src/sequence.ts +87 -1
  28. package/src/shapes/index.ts +47 -5
  29. package/src/shapes/circle.ts +0 -31
  30. package/src/shapes/diamond.ts +0 -31
  31. package/src/shapes/hexagon.ts +0 -35
  32. package/src/shapes/rounded.ts +0 -31
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { MIX as e, applyClickStatement as t, detectDiagramType as n, extractInitConfig as r, isWideChar as i, mixHexColors as a, normalizeBrTags as o, parseHexRgba as s, parseStyleProps as c, safeHref as l, splitStatements as u, splitStatementsByLine as d, stripFormattingTags as f, toDirection as p, tryApplyClassAssignment as m, tryApplyClassDef as h, tryApplyStyleStatement as g, withDirectionOverride as _ } from "@zombie-mermaid/core";
2
2
  import { CHART_ACCENT_FALLBACK as v, formatClassMember as y, getSeriesColor as b, matchExpandedBlock as x, parseClassDiagram as S, parseErDiagram as C, parseExpandedMeta as w, parseSequenceDiagram as ee, parseXYChart as T, resolveShapeName as E } from "@zombie-mermaid/mermaid-parser";
3
3
  //#region packages/ascii-renderer/src/hyperlinks.ts
4
- function D(e) {
4
+ function te(e) {
5
5
  return [e.length - 1, (e[0]?.length ?? 1) - 1];
6
6
  }
7
- var O = "\x1B]8;;\x1B\\";
8
- function k(e) {
7
+ var D = "\x1B]8;;\x1B\\";
8
+ function O(e) {
9
9
  return `\x1b]8;;${e.replace(/[^\x21-\x7e]/gu, (e) => encodeURIComponent(e))}\x1b\\`;
10
10
  }
11
- var te = /\x1b\]8;[^\x07\x1b]*(?:\x1b\\|\x07)/g;
12
- function ne(e) {
13
- return e.replace(te, "");
11
+ var ne = /\x1b\]8;[^\x07\x1b]*(?:\x1b\\|\x07)/g;
12
+ function re(e) {
13
+ return e.replace(ne, "");
14
14
  }
15
- function A(e, t) {
15
+ function k(e, t) {
16
16
  let n = [];
17
17
  for (let r = 0; r <= e; r++) {
18
18
  let e = [];
@@ -21,51 +21,51 @@ function A(e, t) {
21
21
  }
22
22
  return n;
23
23
  }
24
- function j(e, t, n, r) {
24
+ function A(e, t, n, r) {
25
25
  let i = e[t];
26
26
  i === void 0 || n < 0 || n >= i.length || (i[n] = r);
27
27
  }
28
- function re(e) {
28
+ function ie(e) {
29
29
  for (let t of e) t.reverse();
30
30
  return e;
31
31
  }
32
- function ie(e, t, n, r, i) {
33
- let [a, o] = D(t), s = Math.max(1, i?.from ?? 1), c = Math.min(o - 1, i?.to ?? o - 1);
32
+ function ae(e, t, n, r, i) {
33
+ let [a, o] = te(t), s = Math.max(1, i?.from ?? 1), c = Math.min(o - 1, i?.to ?? o - 1);
34
34
  for (let i = s; i <= c; i++) {
35
35
  let o = -1, s = -1;
36
36
  for (let e = 1; e <= a - 1; e++) t[e]?.[i] !== " " && (o === -1 && (o = e), s = e);
37
- if (o !== -1) for (let t = o; t <= s; t++) j(e, t + n.x, i + n.y, r);
37
+ if (o !== -1) for (let t = o; t <= s; t++) A(e, t + n.x, i + n.y, r);
38
38
  }
39
39
  }
40
- function ae(e, t) {
41
- let [n, r] = D(e.canvas), i = A(n, r);
40
+ function oe(e, t) {
41
+ let [n, r] = te(e.canvas), i = k(n, r);
42
42
  for (let n of e.nodes) {
43
43
  if (!n.drawing || !n.drawingCoord) continue;
44
44
  let e = l(t.get(n.name)?.href);
45
- e !== void 0 && ie(i, n.drawing, n.drawingCoord, e);
45
+ e !== void 0 && ae(i, n.drawing, n.drawingCoord, e);
46
46
  }
47
47
  return i;
48
48
  }
49
- var M = class {
49
+ var j = class {
50
50
  current = null;
51
51
  advance(e) {
52
52
  if (e === this.current) return "";
53
- let t = this.current === null ? "" : O;
54
- return e !== null && (t += k(e)), this.current = e, t;
53
+ let t = this.current === null ? "" : D;
54
+ return e !== null && (t += O(e)), this.current = e, t;
55
55
  }
56
56
  finish() {
57
- let e = this.current === null ? "" : O;
57
+ let e = this.current === null ? "" : D;
58
58
  return this.current = null, e;
59
59
  }
60
60
  };
61
- function N(e, t) {
62
- let n = new M(), r = "";
61
+ function M(e, t) {
62
+ let n = new j(), r = "";
63
63
  for (let [i, a] of e.entries()) r += n.advance(t[i] ?? null) + a;
64
64
  return r + n.finish();
65
65
  }
66
66
  //#endregion
67
67
  //#region packages/ascii-renderer/src/ansi.ts
68
- var P = {
68
+ var N = {
69
69
  fg: "#27272a",
70
70
  border: "#a1a1aa",
71
71
  line: "#71717a",
@@ -73,7 +73,7 @@ var P = {
73
73
  corner: "#71717a",
74
74
  junction: "#a1a1aa"
75
75
  };
76
- function oe(t) {
76
+ function se(t) {
77
77
  let n = t.line ?? a(t.fg, t.bg, e.line), r = t.border ?? a(t.fg, t.bg, e.nodeStroke);
78
78
  return {
79
79
  fg: t.fg,
@@ -86,7 +86,7 @@ function oe(t) {
86
86
  junction: r
87
87
  };
88
88
  }
89
- function F() {
89
+ function P() {
90
90
  let e = globalThis.process;
91
91
  if (e) {
92
92
  if (!e.stdout?.isTTY) return "none";
@@ -95,7 +95,7 @@ function F() {
95
95
  }
96
96
  return typeof document < "u" ? "html" : "none";
97
97
  }
98
- function se(e) {
98
+ function F(e) {
99
99
  return s(e.startsWith("#") ? e : `#${e}`) ?? {
100
100
  r: 0,
101
101
  g: 0,
@@ -103,11 +103,11 @@ function se(e) {
103
103
  };
104
104
  }
105
105
  var ce = "\x1B[", I = `${ce}0m`;
106
- function L(e) {
107
- let { r: t, g: n, b: r } = se(e);
106
+ function le(e) {
107
+ let { r: t, g: n, b: r } = F(e);
108
108
  return `${ce}38;2;${t};${n};${r}m`;
109
109
  }
110
- function le(e, t, n) {
110
+ function ue(e, t, n) {
111
111
  let r = (e + t + n) / 3;
112
112
  if (Math.max(Math.abs(e - r), Math.abs(t - r), Math.abs(n - r)) < 10) {
113
113
  let e = Math.round(r / 255 * 23);
@@ -116,21 +116,21 @@ function le(e, t, n) {
116
116
  let i = (e) => e < 48 ? 0 : e < 115 ? 1 : Math.min(5, Math.floor((e - 35) / 40)), a = i(e), o = i(t), s = i(n);
117
117
  return 16 + 36 * a + 6 * o + s;
118
118
  }
119
- function R(e) {
120
- let { r: t, g: n, b: r } = se(e);
121
- return `${ce}38;5;${le(t, n, r)}m`;
119
+ function de(e) {
120
+ let { r: t, g: n, b: r } = F(e);
121
+ return `${ce}38;5;${ue(t, n, r)}m`;
122
122
  }
123
- function ue(e) {
124
- let { r: t, g: n, b: r } = se(e), i = .299 * t + .587 * n + .114 * r, a = i > 100 ? 0 : 60, o;
123
+ function L(e) {
124
+ let { r: t, g: n, b: r } = F(e), i = .299 * t + .587 * n + .114 * r, a = i > 100 ? 0 : 60, o;
125
125
  return o = t > 180 && n < 100 && r < 100 ? 31 : n > 180 && t < 100 && r < 100 ? 32 : t > 150 && n > 150 && r < 100 ? 33 : r > 180 && t < 100 && n < 100 ? 34 : t > 150 && r > 150 && n < 100 ? 35 : n > 150 && r > 150 && t < 100 ? 36 : i > 200 ? 37 : i < 50 ? 30 : 37, `${ce}${o + a}m`;
126
126
  }
127
- function de(e) {
127
+ function fe(e) {
128
128
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
129
129
  }
130
- function fe(e, t) {
131
- return `<span style="color:${e}">${de(t)}</span>`;
132
- }
133
130
  function pe(e, t) {
131
+ return `<span style="color:${e}">${fe(t)}</span>`;
132
+ }
133
+ function me(e, t) {
134
134
  switch (e) {
135
135
  case "text": return t.fg;
136
136
  case "border": return t.border;
@@ -141,37 +141,37 @@ function pe(e, t) {
141
141
  default: return t.fg;
142
142
  }
143
143
  }
144
- function me(e, t, n) {
144
+ function he(e, t, n) {
145
145
  if (n === "none") return "";
146
- let r = pe(e, t);
146
+ let r = me(e, t);
147
147
  switch (n) {
148
- case "truecolor": return L(r);
149
- case "ansi256": return R(r);
150
- case "ansi16": return ue(r);
148
+ case "truecolor": return le(r);
149
+ case "ansi256": return de(r);
150
+ case "ansi16": return L(r);
151
151
  default: return "";
152
152
  }
153
153
  }
154
- function he(e, t, n, r, i) {
155
- if (r === "none") return i ? N(e, i) : e.join("");
156
- if (r === "html") return ge(e, t, n);
157
- let a = new M(), o = "", s = null, c = "";
154
+ function ge(e, t, n, r, i) {
155
+ if (r === "none") return i ? M(e, i) : e.join("");
156
+ if (r === "html") return _e(e, t, n);
157
+ let a = new j(), o = "", s = null, c = "";
158
158
  for (let [l, u] of e.entries()) {
159
159
  let e = t[l] ?? null, d = i ? a.advance(i[l] ?? null) : "";
160
160
  if (u === " ") {
161
- c.length > 0 && (o += s === null ? c : me(s, n, r) + c + I, c = "", s = null), o += d + u;
161
+ c.length > 0 && (o += s === null ? c : he(s, n, r) + c + I, c = "", s = null), o += d + u;
162
162
  continue;
163
163
  }
164
164
  if (e === s) {
165
165
  c += d + u;
166
166
  continue;
167
167
  }
168
- c.length > 0 && (o += s === null ? c : me(s, n, r) + c + I), c = d + u, s = e;
168
+ c.length > 0 && (o += s === null ? c : he(s, n, r) + c + I), c = d + u, s = e;
169
169
  }
170
- return c.length > 0 && s !== null ? o += me(s, n, r) + c + I : c.length > 0 && (o += c), o + a.finish();
170
+ return c.length > 0 && s !== null ? o += he(s, n, r) + c + I : c.length > 0 && (o += c), o + a.finish();
171
171
  }
172
- function ge(e, t, n) {
172
+ function _e(e, t, n) {
173
173
  let r = "", i = null, a = "", o = () => {
174
- a.length !== 0 && (r += i === null ? de(a) : fe(pe(i, n), a), a = "", i = null);
174
+ a.length !== 0 && (r += i === null ? fe(a) : pe(me(i, n), a), a = "", i = null);
175
175
  };
176
176
  for (let [n, s] of e.entries()) {
177
177
  let e = t[n] ?? null;
@@ -187,56 +187,56 @@ function ge(e, t, n) {
187
187
  }
188
188
  return o(), r;
189
189
  }
190
- function _e(e, t, n) {
190
+ function ve(e, t, n) {
191
191
  if (n === "none" || e.length === 0) return e;
192
- if (n === "html") return fe(t, e);
192
+ if (n === "html") return pe(t, e);
193
193
  let r;
194
194
  switch (n) {
195
195
  case "truecolor":
196
- r = L(t);
196
+ r = le(t);
197
197
  break;
198
198
  case "ansi256":
199
- r = R(t);
199
+ r = de(t);
200
200
  break;
201
201
  case "ansi16":
202
- r = ue(t);
202
+ r = L(t);
203
203
  break;
204
204
  default: return e;
205
205
  }
206
206
  return `${r}${e}${I}`;
207
207
  }
208
- var ve = /\p{Mn}|\p{Me}/u;
209
- function ye(e) {
210
- return ve.test(e);
208
+ var ye = /\p{Mn}|\p{Me}/u;
209
+ function be(e) {
210
+ return ye.test(e);
211
211
  }
212
- var z = new Intl.Segmenter(void 0, { granularity: "grapheme" }), be = "️";
213
- function xe(e) {
212
+ var xe = new Intl.Segmenter(void 0, { granularity: "grapheme" }), R = "️";
213
+ function Se(e) {
214
214
  let t = [];
215
- for (let { segment: n } of z.segment(e)) t.push(n);
215
+ for (let { segment: n } of xe.segment(e)) t.push(n);
216
216
  return t;
217
217
  }
218
- function Se(e) {
219
- if (e.includes(be)) return 2;
218
+ function Ce(e) {
219
+ if (e.includes(R)) return 2;
220
220
  let t = !1, n = !1;
221
- for (let r of e) i(r) && (t = !0), ye(r) || (n = !0);
221
+ for (let r of e) i(r) && (t = !0), be(r) || (n = !0);
222
222
  return t ? 2 : +!!n;
223
223
  }
224
- function B(e) {
224
+ function z(e) {
225
225
  let t = 0;
226
- for (let n of xe(e)) t += Se(n);
226
+ for (let n of Se(e)) t += Ce(n);
227
227
  return t;
228
228
  }
229
- function Ce(e) {
229
+ function we(e) {
230
230
  let t = [];
231
- for (let n of xe(e)) {
232
- let e = Se(n);
231
+ for (let n of Se(e)) {
232
+ let e = Ce(n);
233
233
  e !== 0 && (t.push(n), e === 2 && t.push(""));
234
234
  }
235
235
  return t;
236
236
  }
237
237
  //#endregion
238
238
  //#region packages/ascii-renderer/src/canvas.ts
239
- function V(e, t) {
239
+ function B(e, t) {
240
240
  let n = [];
241
241
  for (let r = 0; r <= e; r++) {
242
242
  let e = [];
@@ -245,11 +245,11 @@ function V(e, t) {
245
245
  }
246
246
  return n;
247
247
  }
248
- function H(e) {
249
- let [t, n] = De(e);
250
- return V(t, n);
248
+ function V(e) {
249
+ let [t, n] = Oe(e);
250
+ return B(t, n);
251
251
  }
252
- function we(e, t) {
252
+ function Te(e, t) {
253
253
  let n = [];
254
254
  for (let r = 0; r <= e; r++) {
255
255
  let e = [];
@@ -258,27 +258,27 @@ function we(e, t) {
258
258
  }
259
259
  return n;
260
260
  }
261
- function Te(e, t, n) {
262
- let r = e.length - 1, i = (e[0]?.length ?? 1) - 1, a = we(Math.max(t, r), Math.max(n, i));
261
+ function Ee(e, t, n) {
262
+ let r = e.length - 1, i = (e[0]?.length ?? 1) - 1, a = Te(Math.max(t, r), Math.max(n, i));
263
263
  for (let t = 0; t < a.length; t++) for (let n = 0; n < (a[0]?.length ?? 0); n++) t < e.length && n < (e[0]?.length ?? 0) && (a[t][n] = e[t][n]);
264
264
  return e.length = 0, e.push(...a), e;
265
265
  }
266
- function Ee(e, t, n, r) {
267
- (t >= e.length || n >= (e[0]?.length ?? 0)) && Te(e, t, n), e[t][n] = r;
266
+ function De(e, t, n, r) {
267
+ (t >= e.length || n >= (e[0]?.length ?? 0)) && Ee(e, t, n), e[t][n] = r;
268
268
  }
269
- function De(e) {
269
+ function Oe(e) {
270
270
  return [e.length - 1, (e[0]?.length ?? 1) - 1];
271
271
  }
272
- function Oe(e, t, n) {
273
- let [r, i] = De(e), a = V(Math.max(t, r), Math.max(n, i));
272
+ function ke(e, t, n) {
273
+ let [r, i] = Oe(e), a = B(Math.max(t, r), Math.max(n, i));
274
274
  for (let t = 0; t < a.length; t++) for (let n = 0; n < (a[0]?.length ?? 0); n++) t < e.length && n < (e[0]?.length ?? 0) && (a[t][n] = e[t][n]);
275
275
  return e.length = 0, e.push(...a), e;
276
276
  }
277
- function U(e, t, n, r, i) {
278
- let [a, o] = De(e);
279
- t < 0 || t > a || n < 0 || n > o || (e[t][n] = r, i && Ee(i.roleCanvas, t, n, i.role));
277
+ function H(e, t, n, r, i) {
278
+ let [a, o] = Oe(e);
279
+ t < 0 || t > a || n < 0 || n > o || (e[t][n] = r, i && De(i.roleCanvas, t, n, i.role));
280
280
  }
281
- var ke = /* @__PURE__ */ new Set([
281
+ var Ae = /* @__PURE__ */ new Set([
282
282
  "─",
283
283
  "│",
284
284
  "┌",
@@ -295,13 +295,13 @@ var ke = /* @__PURE__ */ new Set([
295
295
  "╶",
296
296
  "╷"
297
297
  ]);
298
- function Ae(e) {
299
- return ke.has(e);
298
+ function U(e) {
299
+ return Ae.has(e);
300
300
  }
301
301
  function je(e) {
302
302
  return /^[a-zA-Z0-9]$/.test(e);
303
303
  }
304
- var W = {
304
+ var Me = {
305
305
  "─": {
306
306
  "│": "┼",
307
307
  "┌": "┬",
@@ -413,19 +413,19 @@ var W = {
413
413
  "┬": "┼"
414
414
  }
415
415
  };
416
- function Me(e, t) {
417
- return W[e]?.[t] ?? e;
416
+ function W(e, t) {
417
+ return Me[e]?.[t] ?? e;
418
418
  }
419
419
  function Ne(e) {
420
420
  let t = /* @__PURE__ */ new Map(), n = [];
421
421
  for (let r of e) {
422
- let [e, i] = De(r), a = H(r);
422
+ let [e, i] = Oe(r), a = V(r);
423
423
  for (let n = 0; n <= e; n++) for (let e = 0; e <= i; e++) {
424
424
  let i = r[n]?.[e];
425
425
  if (i === void 0 || i === " ") continue;
426
426
  let o = `${n},${e}`, s = t.get(o);
427
427
  if (s !== void 0) {
428
- if (!(s !== i && Ae(s) && Ae(i))) continue;
428
+ if (!(s !== i && U(s) && U(i))) continue;
429
429
  } else t.set(o, i);
430
430
  a[n][e] = i;
431
431
  }
@@ -434,35 +434,35 @@ function Ne(e) {
434
434
  return n;
435
435
  }
436
436
  function Pe(e, t, n, ...r) {
437
- let [i, a] = De(e);
437
+ let [i, a] = Oe(e);
438
438
  for (let e of r) {
439
- let [n, r] = De(e);
439
+ let [n, r] = Oe(e);
440
440
  i = Math.max(i, n + t.x), a = Math.max(a, r + t.y);
441
441
  }
442
- let o = V(i, a);
442
+ let o = B(i, a);
443
443
  for (let t = 0; t <= i; t++) for (let n = 0; n <= a; n++) t < e.length && n < (e[0]?.length ?? 0) && (o[t][n] = e[t][n]);
444
444
  for (let e of r) for (let r = 0; r < e.length; r++) for (let i = 0; i < (e[0]?.length ?? 0); i++) {
445
445
  let a = e[r][i];
446
446
  if (a !== " ") {
447
447
  let e = r + t.x, s = i + t.y, c = o[e][s];
448
- !n && Ae(a) && Ae(c) ? o[e][s] = Me(c, a) : je(c) && je(a) || (o[e][s] = a);
448
+ !n && U(a) && U(c) ? o[e][s] = W(c, a) : je(c) && je(a) || (o[e][s] = a);
449
449
  }
450
450
  }
451
451
  return o;
452
452
  }
453
453
  function Fe(e, t) {
454
- let [n, r] = De(e), i = [], a = t?.roleCanvas, o = t?.colorMode ?? "none", s = t?.theme ?? P, c = o === "html" ? void 0 : t?.linkCanvas;
454
+ let [n, r] = Oe(e), i = [], a = t?.roleCanvas, o = t?.colorMode ?? "none", s = t?.theme ?? N, c = o === "html" ? void 0 : t?.linkCanvas;
455
455
  for (let t = 0; t <= r; t++) if (o === "none" || !a) {
456
456
  let r = [];
457
457
  for (let i = 0; i <= n; i++) r.push(e[i][t]);
458
458
  if (c) {
459
459
  let e = r.map((e, n) => c[n]?.[t] ?? null);
460
- i.push(N(r, e));
460
+ i.push(M(r, e));
461
461
  } else i.push(r.join(""));
462
462
  } else {
463
463
  let r = [], l = [], u = [];
464
464
  for (let i = 0; i <= n; i++) r.push(e[i][t]), l.push(a[i]?.[t] ?? null), u.push(c?.[i]?.[t] ?? null);
465
- i.push(he(r, l, s, o, c ? u : void 0));
465
+ i.push(ge(r, l, s, o, c ? u : void 0));
466
466
  }
467
467
  return i.join("\n");
468
468
  }
@@ -497,8 +497,8 @@ function Re(e) {
497
497
  return e;
498
498
  }
499
499
  function ze(e, t, n, r = !1) {
500
- let i = Ce(n);
501
- Oe(e, t.x + i.length, t.y);
500
+ let i = we(n);
501
+ ke(e, t.x + i.length, t.y);
502
502
  for (let [n, a] of i.entries()) {
503
503
  let i = t.x + n, o = e[i][t.y];
504
504
  (r || o === " ") && (e[i][t.y] = a);
@@ -508,13 +508,13 @@ function Be(e, t, n, r = 0, i = 0) {
508
508
  let a = r, o = i;
509
509
  for (let e of t.values()) a += e;
510
510
  for (let e of n.values()) o += e;
511
- Oe(e, a - 1, o - 1);
511
+ ke(e, a - 1, o - 1);
512
512
  }
513
513
  function Ve(e, t, n, r = 0, i = 0) {
514
514
  let a = r, o = i;
515
515
  for (let e of t.values()) a += e;
516
516
  for (let e of n.values()) o += e;
517
- Te(e, a - 1, o - 1);
517
+ Ee(e, a - 1, o - 1);
518
518
  }
519
519
  //#endregion
520
520
  //#region packages/ascii-renderer/src/xychart.ts
@@ -569,15 +569,15 @@ function Ye(e, t, n, r) {
569
569
  if (!a)
570
570
  /* v8 ignore next */
571
571
  throw Error("XY chart: y-axis range was not set by the parser");
572
- let o = lt(a.min, a.max), s = o.map((e) => ut(e)), c = Math.max(...s.map((e) => e.length)) + 1, l = Math.max(He, i * 6), u = Ue, d = Math.floor(l / i), f = ct(e, i), p = !!e.title, m = !!e.xAxis.title, h = !!e.yAxis.title, g = e.series.length > 1, _ = p ? 0 : -1, v = (p ? 2 : 0) + +!!g, y = h ? 2 : 0, b = y + c + 1, x = b + d * i + 2, S = v + u, C = S + 1, w = m ? C + 1 : -1, ee = C + 1 + +!!m + 0, T = et(x, ee), E = tt(x, ee), D = nt(x, ee), O = Ke(e.series.length, r), k = (e) => {
572
+ let o = lt(a.min, a.max), s = o.map((e) => ut(e)), c = Math.max(...s.map((e) => e.length)) + 1, l = Math.max(He, i * 6), u = Ue, d = Math.floor(l / i), f = ct(e, i), p = !!e.title, m = !!e.xAxis.title, h = !!e.yAxis.title, g = e.series.length > 1, _ = p ? 0 : -1, v = (p ? 2 : 0) + +!!g, y = h ? 2 : 0, b = y + c + 1, x = b + d * i + 2, S = v + u, C = S + 1, w = m ? C + 1 : -1, ee = C + 1 + +!!m + 0, T = et(x, ee), E = tt(x, ee), te = nt(x, ee), D = Ke(e.series.length, r), O = (e) => {
573
573
  let t = (e - a.min) / (a.max - a.min || 1);
574
574
  return Math.round(t * 19);
575
- }, te = (e) => b + Math.floor(d * (e + .5));
576
- e.title && _ >= 0 && it(T, E, _, Math.floor(x / 2 - e.title.length / 2), e.title, "text"), g && $e(T, E, D, e, +!!p, x, t, O);
575
+ }, ne = (e) => b + Math.floor(d * (e + .5));
576
+ e.title && _ >= 0 && it(T, E, _, Math.floor(x / 2 - e.title.length / 2), e.title, "text"), g && $e(T, E, te, e, +!!p, x, t, D);
577
577
  for (let e = 0; e < u; e++) G(T, E, v + (19 - e), b - 1, t.vLine, "border");
578
578
  G(T, E, S, b - 1, t.origin, "border");
579
579
  for (let e of o) {
580
- let n = k(e);
580
+ let n = O(e);
581
581
  if (n < 0 || n >= u) continue;
582
582
  let r = v + (19 - n), i = ut(e);
583
583
  G(T, E, r, b - 1, n === 0 ? t.origin : t.yTick, "border");
@@ -586,7 +586,7 @@ function Ye(e, t, n, r) {
586
586
  }
587
587
  for (let e = b; e < b + d * i; e++) G(T, E, S, e, t.hLine, "border");
588
588
  for (let e = 0; e < i; e++) {
589
- let n = te(e);
589
+ let n = ne(e);
590
590
  G(T, E, S, n, t.xTick, "border");
591
591
  let r = f[e], i = n - Math.floor(r.length / 2);
592
592
  it(T, E, C, Math.max(0, i), r, "text");
@@ -604,40 +604,40 @@ function Ye(e, t, n, r) {
604
604
  }
605
605
  }
606
606
  for (let e of o) {
607
- let n = k(e);
607
+ let n = O(e);
608
608
  if (n < 0 || n >= u) continue;
609
609
  let r = v + (19 - n);
610
610
  for (let e = b; e < b + d * i; e++) rt(T, r, e) === " " && G(T, E, r, e, t.grid, "line");
611
611
  }
612
- let ne = [];
613
- for (let t = 0; t < e.series.length; t++) e.series[t].type === "bar" && ne.push({
612
+ let re = [];
613
+ for (let t = 0; t < e.series.length; t++) e.series[t].type === "bar" && re.push({
614
614
  data: e.series[t].data,
615
615
  globalIdx: t
616
616
  });
617
- if (ne.length > 0) {
618
- let e = Math.max(1, d - 2), n = Math.max(1, Math.min(e, 8)), r = k(Math.max(0, a.min));
619
- for (let e = 0; e < ne.length; e++) {
620
- let i = ne[e], a = O[i.globalIdx];
617
+ if (re.length > 0) {
618
+ let e = Math.max(1, d - 2), n = Math.max(1, Math.min(e, 8)), r = O(Math.max(0, a.min));
619
+ for (let e = 0; e < re.length; e++) {
620
+ let i = re[e], a = D[i.globalIdx];
621
621
  for (let e = 0; e < i.data.length; e++) {
622
- let o = te(e) - Math.floor(n / 2), s = k(i.data[e]), c = Math.min(r, s), l = Math.max(r, s);
622
+ let o = ne(e) - Math.floor(n / 2), s = O(i.data[e]), c = Math.min(r, s), l = Math.max(r, s);
623
623
  for (let e = c; e <= l; e++) {
624
624
  let r = v + (19 - e);
625
- for (let e = o; e < o + n; e++) G(T, E, r, e, t.bar, "arrow", D, a);
625
+ for (let e = o; e < o + n; e++) G(T, E, r, e, t.bar, "arrow", te, a);
626
626
  }
627
627
  }
628
628
  }
629
629
  }
630
- let A = [];
631
- for (let t = 0; t < e.series.length; t++) e.series[t].type === "line" && A.push({
630
+ let k = [];
631
+ for (let t = 0; t < e.series.length; t++) e.series[t].type === "line" && k.push({
632
632
  data: e.series[t].data,
633
633
  globalIdx: t
634
634
  });
635
- for (let e of A) {
635
+ for (let e of k) {
636
636
  if (e.data.length === 0) continue;
637
- let n = O[e.globalIdx];
638
- Ze(T, E, e.data, te, k, v, u, b, d * i, t, D, n);
637
+ let n = D[e.globalIdx];
638
+ Ze(T, E, e.data, ne, O, v, u, b, d * i, t, te, n);
639
639
  }
640
- return at(T, E, D, n, r);
640
+ return at(T, E, te, n, r);
641
641
  }
642
642
  function Xe(e, t, n, r) {
643
643
  let i = st(e);
@@ -784,16 +784,16 @@ function $e(e, t, n, r, i, a, o, s) {
784
784
  }
785
785
  }
786
786
  function et(e, t) {
787
- return V(e - 1, t - 1);
787
+ return B(e - 1, t - 1);
788
788
  }
789
789
  function tt(e, t) {
790
- return we(e - 1, t - 1);
790
+ return Te(e - 1, t - 1);
791
791
  }
792
792
  function nt(e, t) {
793
793
  return Array.from({ length: e }, () => Array.from({ length: t }).fill(null));
794
794
  }
795
795
  function G(e, t, n, r, i, a, o, s) {
796
- r >= 0 && r < e.length && n >= 0 && n < (e[0]?.length ?? 0) && (U(e, r, n, i, {
796
+ r >= 0 && r < e.length && n >= 0 && n < (e[0]?.length ?? 0) && (H(e, r, n, i, {
797
797
  role: a,
798
798
  roleCanvas: t
799
799
  }), o && s && (o[r][n] = s));
@@ -823,13 +823,13 @@ function ot(e, t, n, r, i) {
823
823
  for (let c = 0; c < e.length; c++) {
824
824
  let l = e[c];
825
825
  if (l === " ") {
826
- s.length > 0 && (a += o ? _e(s, o, i) : s, s = "", o = null), a += " ";
826
+ s.length > 0 && (a += o ? ve(s, o, i) : s, s = "", o = null), a += " ";
827
827
  continue;
828
828
  }
829
829
  let u = n[c] ?? null, d = t[c] ?? null, f = u ?? (d ? qe(d, r) : null);
830
- f === o ? s += l : (s.length > 0 && (a += o ? _e(s, o, i) : s), s = l, o = f);
830
+ f === o ? s += l : (s.length > 0 && (a += o ? ve(s, o, i) : s), s = l, o = f);
831
831
  }
832
- return s.length > 0 && (a += o ? _e(s, o, i) : s), a;
832
+ return s.length > 0 && (a += o ? ve(s, o, i) : s), a;
833
833
  }
834
834
  function st(e) {
835
835
  if (e.xAxis.categories) return e.xAxis.categories.length;
@@ -1192,10 +1192,10 @@ function Gt(e) {
1192
1192
  }
1193
1193
  function Kt(e, t) {
1194
1194
  if (e.length < 2) return !1;
1195
- let n = e[0].style, r = Tn(t, e[0].from), i = Tn(t, e[0].to);
1195
+ let n = e[0].style, r = Vn(t, e[0].from), i = Vn(t, e[0].to);
1196
1196
  for (let a of e) {
1197
1197
  if (a.style !== n || a.text.length > 0) return !1;
1198
- let e = Tn(t, a.from), o = Tn(t, a.to);
1198
+ let e = Vn(t, a.from), o = Vn(t, a.to);
1199
1199
  if (e !== r || o !== i || e !== o) return !1;
1200
1200
  }
1201
1201
  let a = e.every((t) => t.to === e[0].to), o = a ? e.map((e) => e.from) : e.map((e) => e.to);
@@ -1318,7 +1318,7 @@ function Q(e) {
1318
1318
  }
1319
1319
  function an(e) {
1320
1320
  let t = Q(e);
1321
- return Math.max(...t.map((e) => B(e)), 0);
1321
+ return Math.max(...t.map((e) => z(e)), 0);
1322
1322
  }
1323
1323
  function on(e) {
1324
1324
  return Q(e).length;
@@ -1880,7 +1880,7 @@ function cn(e, t) {
1880
1880
  //#endregion
1881
1881
  //#region packages/ascii-renderer/src/shapes/rectangle.ts
1882
1882
  function ln(e, t) {
1883
- let n = Q(e), r = Math.max(...n.map((e) => B(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 2, s = i + 2 * t.padding, c = s % 2 == 0 ? s + 1 : s;
1883
+ let n = Q(e), r = Math.max(...n.map((e) => z(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 2, s = i + 2 * t.padding, c = s % 2 == 0 ? s + 1 : s;
1884
1884
  return {
1885
1885
  width: o,
1886
1886
  height: c + 2,
@@ -1903,7 +1903,7 @@ function ln(e, t) {
1903
1903
  };
1904
1904
  }
1905
1905
  function un(e, t, n, r) {
1906
- let { width: i, height: a } = t, o = V(i - 1, a - 1), s = {
1906
+ let { width: i, height: a } = t, o = B(i - 1, a - 1), s = {
1907
1907
  x: 0,
1908
1908
  y: 0
1909
1909
  }, c = {
@@ -1915,7 +1915,7 @@ function un(e, t, n, r) {
1915
1915
  o[s.x][s.y] = n.tl, o[c.x][s.y] = n.tr, o[s.x][c.y] = n.bl, o[c.x][c.y] = n.br;
1916
1916
  let d = Q(e), f = i - 1, p = a - 1, m = Math.floor(p / 2) - Math.floor((d.length - 1) / 2);
1917
1917
  for (let e = 0; e < d.length; e++) {
1918
- let t = d[e], n = Math.floor(f / 2) - Math.ceil(B(t) / 2) + 1, r = Ce(t);
1918
+ let t = d[e], n = Math.floor(f / 2) - Math.ceil(z(t) / 2) + 1, r = we(t);
1919
1919
  for (let t = 0; t < r.length; t++) {
1920
1920
  let i = n + t, a = m + e;
1921
1921
  i >= 0 && i < o.length && a >= 0 && a < o[0].length && (o[i][a] = r[t]);
@@ -1960,330 +1960,318 @@ var fn = {
1960
1960
  return un(e, t, cn("rectangle", n.useAscii), n.useAscii);
1961
1961
  },
1962
1962
  getAttachmentPoint: dn
1963
- }, pn = /* @__PURE__ */ new Map([
1964
- ["rectangle", fn],
1965
- ["rounded", {
1966
- getDimensions: ln,
1967
- render(e, t, n) {
1968
- return un(e, t, cn("rounded", n.useAscii), n.useAscii);
1969
- },
1970
- getAttachmentPoint: dn
1971
- }],
1972
- ["diamond", {
1973
- getDimensions: ln,
1974
- render(e, t, n) {
1975
- return un(e, t, cn("diamond", n.useAscii), n.useAscii);
1976
- },
1977
- getAttachmentPoint: dn
1978
- }],
1979
- ["stadium", {
1980
- getDimensions(e, t) {
1981
- let n = Q(e), r = Math.max(...n.map((e) => B(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 4, s = i + 2 * t.padding;
1982
- return {
1983
- width: o,
1984
- height: Math.max(s + 2, 3),
1985
- labelArea: {
1986
- x: 2 + t.padding,
1987
- y: 1 + t.padding,
1988
- width: r,
1989
- height: i
1990
- },
1991
- gridColumns: [
1992
- 2,
1993
- a,
1994
- 2
1995
- ],
1996
- gridRows: [
1997
- 1,
1998
- s,
1999
- 1
2000
- ]
2001
- };
2002
- },
2003
- render(e, t, n) {
2004
- let { width: r, height: i } = t, a = V(r - 1, i - 1), o = Math.floor(i / 2), s = n.useAscii ? "-" : "─";
2005
- if (i === 3) a[0][o] = "(", a[r - 1][o] = ")";
2006
- else if (n.useAscii) {
2007
- for (let e = 0; e < i; e++) a[0][e] = "(", a[r - 1][e] = ")";
2008
- for (let e = 1; e < r - 1; e++) a[e][0] = s, a[e][i - 1] = s;
2009
- } else {
2010
- a[0][0] = "╭";
2011
- for (let e = 1; e < r - 1; e++) a[e][0] = s;
2012
- a[r - 1][0] = "╮";
2013
- for (let e = 1; e < i - 1; e++) a[0][e] = "│", a[r - 1][e] = "│";
2014
- a[0][i - 1] = "╰";
2015
- for (let e = 1; e < r - 1; e++) a[e][i - 1] = s;
2016
- a[r - 1][i - 1] = "╯";
2017
- }
2018
- let c = Q(e), l = o - Math.floor((c.length - 1) / 2);
2019
- for (let e = 0; e < c.length; e++) {
2020
- let t = c[e], n = Math.floor(r / 2) - Math.floor(B(t) / 2), o = Ce(t);
2021
- for (let t = 0; t < o.length; t++) {
2022
- let s = n + t, c = l + e;
2023
- s > 0 && s < r - 1 && c >= 0 && c < i && (a[s][c] = o[t]);
2024
- }
1963
+ }, pn = {
1964
+ getDimensions(e, t) {
1965
+ return {
1966
+ width: 5,
1967
+ height: 3,
1968
+ labelArea: {
1969
+ x: 2,
1970
+ y: 1,
1971
+ width: 1,
1972
+ height: 1
1973
+ },
1974
+ gridColumns: [
1975
+ 1,
1976
+ 3,
1977
+ 1
1978
+ ],
1979
+ gridRows: [
1980
+ 1,
1981
+ 1,
1982
+ 1
1983
+ ]
1984
+ };
1985
+ },
1986
+ render(e, t, n) {
1987
+ let { width: r, height: i } = t, a = B(r - 1, i - 1), o = Math.floor(r / 2);
1988
+ return n.useAscii ? (a[0][0] = ".", a[1][0] = "-", a[2][0] = "-", a[3][0] = "-", a[4][0] = ".", a[0][1] = "|", a[o][1] = "*", a[4][1] = "|", a[0][2] = "'", a[1][2] = "-", a[2][2] = "-", a[3][2] = "-", a[4][2] = "'") : (a[0][0] = "╭", a[1][0] = "─", a[2][0] = "─", a[3][0] = "─", a[4][0] = "╮", a[0][1] = "│", a[o][1] = "●", a[4][1] = "│", a[0][2] = "╰", a[1][2] = "─", a[2][2] = "─", a[3][2] = "─", a[4][2] = "╯"), a;
1989
+ },
1990
+ getAttachmentPoint(e, t, n) {
1991
+ let { width: r, height: i } = t, a = n.x + Math.floor(r / 2), o = n.y + Math.floor(i / 2);
1992
+ return X(e, K) ? {
1993
+ x: a,
1994
+ y: n.y
1995
+ } : X(e, q) ? {
1996
+ x: a,
1997
+ y: n.y + i - 1
1998
+ } : X(e, J) ? {
1999
+ x: n.x,
2000
+ y: o
2001
+ } : X(e, Y) ? {
2002
+ x: n.x + r - 1,
2003
+ y: o
2004
+ } : {
2005
+ x: a,
2006
+ y: o
2007
+ };
2008
+ }
2009
+ }, mn = {
2010
+ getDimensions(e, t) {
2011
+ return {
2012
+ width: 5,
2013
+ height: 3,
2014
+ labelArea: {
2015
+ x: 2,
2016
+ y: 1,
2017
+ width: 1,
2018
+ height: 1
2019
+ },
2020
+ gridColumns: [
2021
+ 1,
2022
+ 3,
2023
+ 1
2024
+ ],
2025
+ gridRows: [
2026
+ 1,
2027
+ 1,
2028
+ 1
2029
+ ]
2030
+ };
2031
+ },
2032
+ render(e, t, n) {
2033
+ let { width: r, height: i } = t, a = B(r - 1, i - 1), o = Math.floor(r / 2);
2034
+ return n.useAscii ? (a[0][0] = "#", a[1][0] = "=", a[2][0] = "=", a[3][0] = "=", a[4][0] = "#", a[0][1] = "#", a[o][1] = "*", a[4][1] = "#", a[0][2] = "#", a[1][2] = "=", a[2][2] = "=", a[3][2] = "=", a[4][2] = "#") : (a[0][0] = "╔", a[1][0] = "═", a[2][0] = "═", a[3][0] = "═", a[4][0] = "╗", a[0][1] = "║", a[o][1] = "◎", a[4][1] = "║", a[0][2] = "╚", a[1][2] = "═", a[2][2] = "═", a[3][2] = "═", a[4][2] = "╝"), a;
2035
+ },
2036
+ getAttachmentPoint(e, t, n) {
2037
+ let { width: r, height: i } = t, a = n.x + Math.floor(r / 2), o = n.y + Math.floor(i / 2);
2038
+ return X(e, K) ? {
2039
+ x: a,
2040
+ y: n.y
2041
+ } : X(e, q) ? {
2042
+ x: a,
2043
+ y: n.y + i - 1
2044
+ } : X(e, J) ? {
2045
+ x: n.x,
2046
+ y: o
2047
+ } : X(e, Y) ? {
2048
+ x: n.x + r - 1,
2049
+ y: o
2050
+ } : {
2051
+ x: a,
2052
+ y: o
2053
+ };
2054
+ }
2055
+ }, hn = {
2056
+ getDimensions(e, t) {
2057
+ let n = Q(e), r = Math.max(...n.map((e) => z(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 4, s = i + 2 * t.padding;
2058
+ return {
2059
+ width: o,
2060
+ height: Math.max(s + 2, 3),
2061
+ labelArea: {
2062
+ x: 2 + t.padding,
2063
+ y: 1 + t.padding,
2064
+ width: r,
2065
+ height: i
2066
+ },
2067
+ gridColumns: [
2068
+ 2,
2069
+ a,
2070
+ 2
2071
+ ],
2072
+ gridRows: [
2073
+ 1,
2074
+ s,
2075
+ 1
2076
+ ]
2077
+ };
2078
+ },
2079
+ render(e, t, n) {
2080
+ let { width: r, height: i } = t, a = B(r - 1, i - 1), o = Math.floor(i / 2), s = n.useAscii ? "-" : "─";
2081
+ if (i === 3) a[0][o] = "(", a[r - 1][o] = ")";
2082
+ else if (n.useAscii) {
2083
+ for (let e = 0; e < i; e++) a[0][e] = "(", a[r - 1][e] = ")";
2084
+ for (let e = 1; e < r - 1; e++) a[e][0] = s, a[e][i - 1] = s;
2085
+ } else {
2086
+ a[0][0] = "╭";
2087
+ for (let e = 1; e < r - 1; e++) a[e][0] = s;
2088
+ a[r - 1][0] = "╮";
2089
+ for (let e = 1; e < i - 1; e++) a[0][e] = "│", a[r - 1][e] = "│";
2090
+ a[0][i - 1] = "╰";
2091
+ for (let e = 1; e < r - 1; e++) a[e][i - 1] = s;
2092
+ a[r - 1][i - 1] = "╯";
2093
+ }
2094
+ let c = Q(e), l = o - Math.floor((c.length - 1) / 2);
2095
+ for (let e = 0; e < c.length; e++) {
2096
+ let t = c[e], n = Math.floor(r / 2) - Math.floor(z(t) / 2), o = we(t);
2097
+ for (let t = 0; t < o.length; t++) {
2098
+ let s = n + t, c = l + e;
2099
+ s > 0 && s < r - 1 && c >= 0 && c < i && (a[s][c] = o[t]);
2025
2100
  }
2026
- return a;
2027
- },
2028
- getAttachmentPoint: dn
2029
- }],
2030
- ["circle", {
2031
- getDimensions: ln,
2032
- render(e, t, n) {
2033
- return un(e, t, cn("circle", n.useAscii), n.useAscii);
2034
- },
2035
- getAttachmentPoint: dn
2036
- }],
2037
- ["subroutine", {
2038
- getDimensions(e, t) {
2039
- let n = Q(e), r = Math.max(...n.map((e) => B(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 4, s = i + 2 * t.padding;
2040
- return {
2041
- width: o,
2042
- height: s + 2,
2043
- labelArea: {
2044
- x: 2 + t.padding,
2045
- y: 1 + t.padding,
2046
- width: r,
2047
- height: i
2048
- },
2049
- gridColumns: [
2050
- 2,
2051
- a,
2052
- 2
2053
- ],
2054
- gridRows: [
2055
- 1,
2056
- s,
2057
- 1
2058
- ]
2059
- };
2060
- },
2061
- render(e, t, n) {
2062
- let { width: r, height: i } = t, a = V(r - 1, i - 1), o = n.useAscii ? "-" : "─", s = n.useAscii ? "|" : "│";
2063
- a[0][0] = n.useAscii ? "+" : "┌", a[1][0] = n.useAscii ? "+" : "┬";
2064
- for (let e = 2; e < r - 2; e++) a[e][0] = o;
2065
- a[r - 2][0] = n.useAscii ? "+" : "┬", a[r - 1][0] = n.useAscii ? "+" : "┐";
2066
- for (let e = 1; e < i - 1; e++) a[0][e] = s, a[1][e] = s, a[r - 2][e] = s, a[r - 1][e] = s;
2067
- a[0][i - 1] = n.useAscii ? "+" : "└", a[1][i - 1] = n.useAscii ? "+" : "┴";
2068
- for (let e = 2; e < r - 2; e++) a[e][i - 1] = o;
2069
- a[r - 2][i - 1] = n.useAscii ? "+" : "┴", a[r - 1][i - 1] = n.useAscii ? "+" : "┘";
2070
- let c = Q(e), l = Math.floor(i / 2) - Math.floor((c.length - 1) / 2);
2071
- for (let e = 0; e < c.length; e++) {
2072
- let t = c[e], n = Math.floor(r / 2) - Math.floor(B(t) / 2), o = Ce(t);
2073
- for (let t = 0; t < o.length; t++) {
2074
- let s = n + t, c = l + e;
2075
- s > 1 && s < r - 2 && c > 0 && c < i - 1 && (a[s][c] = o[t]);
2076
- }
2101
+ }
2102
+ return a;
2103
+ },
2104
+ getAttachmentPoint: dn
2105
+ }, gn = {
2106
+ getDimensions(e, t) {
2107
+ let n = Q(e), r = Math.max(...n.map((e) => z(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 4, s = i + 2 * t.padding;
2108
+ return {
2109
+ width: o,
2110
+ height: s + 2,
2111
+ labelArea: {
2112
+ x: 2 + t.padding,
2113
+ y: 1 + t.padding,
2114
+ width: r,
2115
+ height: i
2116
+ },
2117
+ gridColumns: [
2118
+ 2,
2119
+ a,
2120
+ 2
2121
+ ],
2122
+ gridRows: [
2123
+ 1,
2124
+ s,
2125
+ 1
2126
+ ]
2127
+ };
2128
+ },
2129
+ render(e, t, n) {
2130
+ let { width: r, height: i } = t, a = B(r - 1, i - 1), o = n.useAscii ? "-" : "─", s = n.useAscii ? "|" : "│";
2131
+ a[0][0] = n.useAscii ? "+" : "┌", a[1][0] = n.useAscii ? "+" : "┬";
2132
+ for (let e = 2; e < r - 2; e++) a[e][0] = o;
2133
+ a[r - 2][0] = n.useAscii ? "+" : "┬", a[r - 1][0] = n.useAscii ? "+" : "┐";
2134
+ for (let e = 1; e < i - 1; e++) a[0][e] = s, a[1][e] = s, a[r - 2][e] = s, a[r - 1][e] = s;
2135
+ a[0][i - 1] = n.useAscii ? "+" : "└", a[1][i - 1] = n.useAscii ? "+" : "┴";
2136
+ for (let e = 2; e < r - 2; e++) a[e][i - 1] = o;
2137
+ a[r - 2][i - 1] = n.useAscii ? "+" : "┴", a[r - 1][i - 1] = n.useAscii ? "+" : "┘";
2138
+ let c = Q(e), l = Math.floor(i / 2) - Math.floor((c.length - 1) / 2);
2139
+ for (let e = 0; e < c.length; e++) {
2140
+ let t = c[e], n = Math.floor(r / 2) - Math.floor(z(t) / 2), o = we(t);
2141
+ for (let t = 0; t < o.length; t++) {
2142
+ let s = n + t, c = l + e;
2143
+ s > 1 && s < r - 2 && c > 0 && c < i - 1 && (a[s][c] = o[t]);
2077
2144
  }
2078
- return a;
2079
- },
2080
- getAttachmentPoint: dn
2081
- }],
2082
- ["doublecircle", {
2083
- getDimensions: ln,
2084
- render(e, t, n) {
2085
- return un(e, t, cn("doublecircle", n.useAscii), n.useAscii);
2086
- },
2087
- getAttachmentPoint: dn
2088
- }],
2089
- ["hexagon", {
2090
- getDimensions: ln,
2091
- render(e, t, n) {
2092
- return un(e, t, cn("hexagon", n.useAscii), n.useAscii);
2093
- },
2094
- getAttachmentPoint: dn
2095
- }],
2096
- ["cylinder", {
2097
- getDimensions(e, t) {
2098
- let n = Q(e), r = Math.max(...n.map((e) => B(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 2, s = i + 2 * t.padding + 2;
2099
- return {
2100
- width: o,
2101
- height: s + 2,
2102
- labelArea: {
2103
- x: 1 + t.padding,
2104
- y: 2 + t.padding,
2105
- width: r,
2106
- height: i
2107
- },
2108
- gridColumns: [
2109
- 1,
2110
- a,
2111
- 1
2112
- ],
2113
- gridRows: [
2114
- 2,
2115
- s - 2,
2116
- 2
2117
- ]
2118
- };
2119
- },
2120
- render(e, t, n) {
2121
- let { width: r, height: i } = t, a = V(r - 1, i - 1), o = n.useAscii ? "-" : "─", s = n.useAscii ? "|" : "│";
2122
- a[0][0] = n.useAscii ? "." : "╭";
2123
- for (let e = 1; e < r - 1; e++) a[e][0] = o;
2124
- a[r - 1][0] = n.useAscii ? "." : "╮", a[0][1] = s;
2125
- for (let e = 1; e < r - 1; e++) a[e][1] = o;
2126
- a[r - 1][1] = s;
2127
- for (let e = 2; e < i - 2; e++) a[0][e] = s, a[r - 1][e] = s;
2128
- a[0][i - 2] = s;
2129
- for (let e = 1; e < r - 1; e++) a[e][i - 2] = o;
2130
- a[r - 1][i - 2] = s, a[0][i - 1] = n.useAscii ? "'" : "╰";
2131
- for (let e = 1; e < r - 1; e++) a[e][i - 1] = o;
2132
- a[r - 1][i - 1] = n.useAscii ? "'" : "╯";
2133
- let c = Q(e), l = Math.floor(i / 2) - Math.floor((c.length - 1) / 2);
2134
- for (let e = 0; e < c.length; e++) {
2135
- let t = c[e], n = Math.floor(r / 2) - Math.floor(B(t) / 2), o = Ce(t);
2136
- for (let t = 0; t < o.length; t++) {
2137
- let s = n + t, c = l + e;
2138
- s > 0 && s < r - 1 && c > 1 && c < i - 2 && (a[s][c] = o[t]);
2139
- }
2145
+ }
2146
+ return a;
2147
+ },
2148
+ getAttachmentPoint: dn
2149
+ }, _n = {
2150
+ getDimensions: ln,
2151
+ render(e, t, n) {
2152
+ return un(e, t, cn("doublecircle", n.useAscii), n.useAscii);
2153
+ },
2154
+ getAttachmentPoint: dn
2155
+ }, vn = {
2156
+ getDimensions(e, t) {
2157
+ let n = Q(e), r = Math.max(...n.map((e) => z(e)), 0), i = n.length, a = 2 * t.padding + r, o = a + 2, s = i + 2 * t.padding + 2;
2158
+ return {
2159
+ width: o,
2160
+ height: s + 2,
2161
+ labelArea: {
2162
+ x: 1 + t.padding,
2163
+ y: 2 + t.padding,
2164
+ width: r,
2165
+ height: i
2166
+ },
2167
+ gridColumns: [
2168
+ 1,
2169
+ a,
2170
+ 1
2171
+ ],
2172
+ gridRows: [
2173
+ 2,
2174
+ s - 2,
2175
+ 2
2176
+ ]
2177
+ };
2178
+ },
2179
+ render(e, t, n) {
2180
+ let { width: r, height: i } = t, a = B(r - 1, i - 1), o = n.useAscii ? "-" : "─", s = n.useAscii ? "|" : "│";
2181
+ a[0][0] = n.useAscii ? "." : "╭";
2182
+ for (let e = 1; e < r - 1; e++) a[e][0] = o;
2183
+ a[r - 1][0] = n.useAscii ? "." : "╮", a[0][1] = s;
2184
+ for (let e = 1; e < r - 1; e++) a[e][1] = o;
2185
+ a[r - 1][1] = s;
2186
+ for (let e = 2; e < i - 2; e++) a[0][e] = s, a[r - 1][e] = s;
2187
+ a[0][i - 2] = s;
2188
+ for (let e = 1; e < r - 1; e++) a[e][i - 2] = o;
2189
+ a[r - 1][i - 2] = s, a[0][i - 1] = n.useAscii ? "'" : "╰";
2190
+ for (let e = 1; e < r - 1; e++) a[e][i - 1] = o;
2191
+ a[r - 1][i - 1] = n.useAscii ? "'" : "╯";
2192
+ let c = Q(e), l = Math.floor(i / 2) - Math.floor((c.length - 1) / 2);
2193
+ for (let e = 0; e < c.length; e++) {
2194
+ let t = c[e], n = Math.floor(r / 2) - Math.floor(z(t) / 2), o = we(t);
2195
+ for (let t = 0; t < o.length; t++) {
2196
+ let s = n + t, c = l + e;
2197
+ s > 0 && s < r - 1 && c > 1 && c < i - 2 && (a[s][c] = o[t]);
2140
2198
  }
2141
- return a;
2142
- },
2143
- getAttachmentPoint: dn
2144
- }],
2145
- ["asymmetric", {
2146
- getDimensions: ln,
2147
- render(e, t, n) {
2148
- return un(e, t, cn("asymmetric", n.useAscii), n.useAscii);
2149
- },
2150
- getAttachmentPoint: dn
2151
- }],
2152
- ["trapezoid", {
2153
- getDimensions: ln,
2154
- render(e, t, n) {
2155
- return un(e, t, cn("trapezoid", n.useAscii), n.useAscii);
2156
- },
2157
- getAttachmentPoint: dn
2158
- }],
2159
- ["trapezoid-alt", {
2160
- getDimensions: ln,
2161
- render(e, t, n) {
2162
- return un(e, t, cn("trapezoid-alt", n.useAscii), n.useAscii);
2163
- },
2164
- getAttachmentPoint: dn
2165
- }],
2166
- ["parallelogram", {
2167
- getDimensions: ln,
2168
- render(e, t, n) {
2169
- return un(e, t, cn("parallelogram", n.useAscii), n.useAscii);
2170
- },
2171
- getAttachmentPoint: dn
2172
- }],
2173
- ["parallelogram-alt", {
2199
+ }
2200
+ return a;
2201
+ },
2202
+ getAttachmentPoint: dn
2203
+ }, yn = {
2204
+ getDimensions: ln,
2205
+ render(e, t, n) {
2206
+ return un(e, t, cn("asymmetric", n.useAscii), n.useAscii);
2207
+ },
2208
+ getAttachmentPoint: dn
2209
+ }, bn = {
2210
+ getDimensions: ln,
2211
+ render(e, t, n) {
2212
+ return un(e, t, cn("trapezoid", n.useAscii), n.useAscii);
2213
+ },
2214
+ getAttachmentPoint: dn
2215
+ }, xn = {
2216
+ getDimensions: ln,
2217
+ render(e, t, n) {
2218
+ return un(e, t, cn("trapezoid-alt", n.useAscii), n.useAscii);
2219
+ },
2220
+ getAttachmentPoint: dn
2221
+ }, Sn = {
2222
+ getDimensions: ln,
2223
+ render(e, t, n) {
2224
+ return un(e, t, cn("parallelogram", n.useAscii), n.useAscii);
2225
+ },
2226
+ getAttachmentPoint: dn
2227
+ }, Cn = {
2228
+ getDimensions: ln,
2229
+ render(e, t, n) {
2230
+ return un(e, t, cn("parallelogram-alt", n.useAscii), n.useAscii);
2231
+ },
2232
+ getAttachmentPoint: dn
2233
+ };
2234
+ //#endregion
2235
+ //#region packages/ascii-renderer/src/shapes/index.ts
2236
+ function wn(e) {
2237
+ return {
2174
2238
  getDimensions: ln,
2175
- render(e, t, n) {
2176
- return un(e, t, cn("parallelogram-alt", n.useAscii), n.useAscii);
2239
+ render(t, n, r) {
2240
+ return un(t, n, cn(e, r.useAscii), r.useAscii);
2177
2241
  },
2178
2242
  getAttachmentPoint: dn
2179
- }],
2180
- ["state-start", {
2181
- getDimensions(e, t) {
2182
- return {
2183
- width: 5,
2184
- height: 3,
2185
- labelArea: {
2186
- x: 2,
2187
- y: 1,
2188
- width: 1,
2189
- height: 1
2190
- },
2191
- gridColumns: [
2192
- 1,
2193
- 3,
2194
- 1
2195
- ],
2196
- gridRows: [
2197
- 1,
2198
- 1,
2199
- 1
2200
- ]
2201
- };
2202
- },
2203
- render(e, t, n) {
2204
- let { width: r, height: i } = t, a = V(r - 1, i - 1), o = Math.floor(r / 2);
2205
- return n.useAscii ? (a[0][0] = ".", a[1][0] = "-", a[2][0] = "-", a[3][0] = "-", a[4][0] = ".", a[0][1] = "|", a[o][1] = "*", a[4][1] = "|", a[0][2] = "'", a[1][2] = "-", a[2][2] = "-", a[3][2] = "-", a[4][2] = "'") : (a[0][0] = "╭", a[1][0] = "─", a[2][0] = "─", a[3][0] = "─", a[4][0] = "╮", a[0][1] = "│", a[o][1] = "●", a[4][1] = "│", a[0][2] = "╰", a[1][2] = "─", a[2][2] = "─", a[3][2] = "─", a[4][2] = "╯"), a;
2206
- },
2207
- getAttachmentPoint(e, t, n) {
2208
- let { width: r, height: i } = t, a = n.x + Math.floor(r / 2), o = n.y + Math.floor(i / 2);
2209
- return X(e, K) ? {
2210
- x: a,
2211
- y: n.y
2212
- } : X(e, q) ? {
2213
- x: a,
2214
- y: n.y + i - 1
2215
- } : X(e, J) ? {
2216
- x: n.x,
2217
- y: o
2218
- } : X(e, Y) ? {
2219
- x: n.x + r - 1,
2220
- y: o
2221
- } : {
2222
- x: a,
2223
- y: o
2224
- };
2225
- }
2226
- }],
2227
- ["state-end", {
2228
- getDimensions(e, t) {
2229
- return {
2230
- width: 5,
2231
- height: 3,
2232
- labelArea: {
2233
- x: 2,
2234
- y: 1,
2235
- width: 1,
2236
- height: 1
2237
- },
2238
- gridColumns: [
2239
- 1,
2240
- 3,
2241
- 1
2242
- ],
2243
- gridRows: [
2244
- 1,
2245
- 1,
2246
- 1
2247
- ]
2248
- };
2249
- },
2250
- render(e, t, n) {
2251
- let { width: r, height: i } = t, a = V(r - 1, i - 1), o = Math.floor(r / 2);
2252
- return n.useAscii ? (a[0][0] = "#", a[1][0] = "=", a[2][0] = "=", a[3][0] = "=", a[4][0] = "#", a[0][1] = "#", a[o][1] = "*", a[4][1] = "#", a[0][2] = "#", a[1][2] = "=", a[2][2] = "=", a[3][2] = "=", a[4][2] = "#") : (a[0][0] = "╔", a[1][0] = "═", a[2][0] = "═", a[3][0] = "═", a[4][0] = "╗", a[0][1] = "║", a[o][1] = "◎", a[4][1] = "║", a[0][2] = "╚", a[1][2] = "═", a[2][2] = "═", a[3][2] = "═", a[4][2] = "╝"), a;
2253
- },
2254
- getAttachmentPoint(e, t, n) {
2255
- let { width: r, height: i } = t, a = n.x + Math.floor(r / 2), o = n.y + Math.floor(i / 2);
2256
- return X(e, K) ? {
2257
- x: a,
2258
- y: n.y
2259
- } : X(e, q) ? {
2260
- x: a,
2261
- y: n.y + i - 1
2262
- } : X(e, J) ? {
2263
- x: n.x,
2264
- y: o
2265
- } : X(e, Y) ? {
2266
- x: n.x + r - 1,
2267
- y: o
2268
- } : {
2269
- x: a,
2270
- y: o
2271
- };
2272
- }
2273
- }]
2243
+ };
2244
+ }
2245
+ var Tn = wn("circle"), En = wn("diamond"), Dn = wn("rounded"), On = wn("hexagon"), kn = /* @__PURE__ */ new Map([
2246
+ ["rectangle", fn],
2247
+ ["rounded", Dn],
2248
+ ["diamond", En],
2249
+ ["stadium", hn],
2250
+ ["circle", Tn],
2251
+ ["subroutine", gn],
2252
+ ["doublecircle", _n],
2253
+ ["hexagon", On],
2254
+ ["cylinder", vn],
2255
+ ["asymmetric", yn],
2256
+ ["trapezoid", bn],
2257
+ ["trapezoid-alt", xn],
2258
+ ["parallelogram", Sn],
2259
+ ["parallelogram-alt", Cn],
2260
+ ["state-start", pn],
2261
+ ["state-end", mn]
2274
2262
  ]);
2275
- function mn(e) {
2276
- return pn.get(e) ?? fn;
2263
+ function An(e) {
2264
+ return kn.get(e) ?? fn;
2277
2265
  }
2278
- function hn(e, t, n) {
2279
- return mn(e).getDimensions(t, n);
2266
+ function jn(e, t, n) {
2267
+ return An(e).getDimensions(t, n);
2280
2268
  }
2281
- function gn(e, t, n, r) {
2282
- return mn(e).getAttachmentPoint(t, n, r);
2269
+ function Mn(e, t, n, r) {
2270
+ return An(e).getAttachmentPoint(t, n, r);
2283
2271
  }
2284
2272
  //#endregion
2285
2273
  //#region packages/ascii-renderer/src/grid.ts
2286
- function _n(e, t, n) {
2274
+ function Nn(e, t, n) {
2287
2275
  let r = n ? {
2288
2276
  x: t.x + n.x,
2289
2277
  y: t.y + n.y
@@ -2297,21 +2285,21 @@ function _n(e, t, n) {
2297
2285
  y: a + Math.floor(s / 2) + e.offsetY
2298
2286
  };
2299
2287
  }
2300
- function vn(e, t) {
2301
- return t.map((t) => _n(e, t));
2288
+ function Pn(e, t) {
2289
+ return t.map((t) => Nn(e, t));
2302
2290
  }
2303
- function yn(e, t, n, r) {
2304
- let i = r ?? An(e, t);
2305
- return kt(e.grid, n, 3) ? (At(e.grid, n, 3), t.gridCoord = n, n) : i === "LR" ? yn(e, t, {
2291
+ function Fn(e, t, n, r) {
2292
+ let i = r ?? Kn(e, t);
2293
+ return kt(e.grid, n, 3) ? (At(e.grid, n, 3), t.gridCoord = n, n) : i === "LR" ? Fn(e, t, {
2306
2294
  x: n.x,
2307
2295
  y: n.y + 4
2308
- }, i) : yn(e, t, {
2296
+ }, i) : Fn(e, t, {
2309
2297
  x: n.x + 4,
2310
2298
  y: n.y
2311
2299
  }, i);
2312
2300
  }
2313
- function bn(e, t) {
2314
- let n = Z(t), r = e.config.boxBorderPadding, i = hn(t.shape, t.displayLabel, {
2301
+ function In(e, t) {
2302
+ let n = Z(t), r = e.config.boxBorderPadding, i = jn(t.shape, t.displayLabel, {
2315
2303
  useAscii: e.config.useAscii,
2316
2304
  padding: r
2317
2305
  }), a = i.gridColumns, o = i.gridRows;
@@ -2329,36 +2317,36 @@ function bn(e, t) {
2329
2317
  }
2330
2318
  if (n.y > 0) {
2331
2319
  let r = e.config.paddingY;
2332
- jn(e, t) && (r += 4);
2320
+ qn(e, t) && (r += 4);
2333
2321
  let i = e.rowHeight.get(n.y - 1) ?? 0;
2334
2322
  e.rowHeight.set(n.y - 1, Math.max(i, r));
2335
2323
  }
2336
2324
  }
2337
- function xn(e, t) {
2325
+ function Ln(e, t) {
2338
2326
  for (let n of t) e.columnWidth.has(n.x) || e.columnWidth.set(n.x, Math.floor(e.config.paddingX / 2)), e.rowHeight.has(n.y) || e.rowHeight.set(n.y, Math.floor(e.config.paddingY / 2));
2339
2327
  }
2340
- var Sn = 8;
2341
- function Cn(e, t, n, r, i) {
2328
+ var Rn = 8;
2329
+ function zn(e, t, n, r, i) {
2342
2330
  let a = [];
2343
2331
  try {
2344
- for (let o = 0; o < Sn; o++) {
2332
+ for (let o = 0; o < Rn; o++) {
2345
2333
  let o = Zt(i, n, t.path, t.style) ?? nn(i, r, t.path, t);
2346
2334
  if (!o) return;
2347
- e.grid.add(St(o)), a.push(o), ir(e, t);
2335
+ e.grid.add(St(o)), a.push(o), br(e, t);
2348
2336
  }
2349
2337
  } finally {
2350
2338
  for (let t of a) e.grid.delete(St(t));
2351
2339
  }
2352
2340
  }
2353
- function wn(e, t) {
2341
+ function Bn(e, t) {
2354
2342
  return e.subgraphs.some((e) => e.nodes.includes(t));
2355
2343
  }
2356
- function Tn(e, t) {
2344
+ function Vn(e, t) {
2357
2345
  let n = null;
2358
- for (let r of e.subgraphs) r.nodes.includes(t) && (!n || En(n, r)) && (n = r);
2346
+ for (let r of e.subgraphs) r.nodes.includes(t) && (!n || Hn(n, r)) && (n = r);
2359
2347
  return n;
2360
2348
  }
2361
- function En(e, t) {
2349
+ function Hn(e, t) {
2362
2350
  let n = t;
2363
2351
  for (; n !== null;) {
2364
2352
  if (n === e) return !0;
@@ -2366,39 +2354,39 @@ function En(e, t) {
2366
2354
  }
2367
2355
  return !1;
2368
2356
  }
2369
- function Dn(e, t) {
2370
- let n = Tn(e, t);
2357
+ function Un(e, t) {
2358
+ let n = Vn(e, t);
2371
2359
  if (!n) return null;
2372
2360
  let r = n;
2373
2361
  for (; r.parent;) r = r.parent;
2374
2362
  return r;
2375
2363
  }
2376
- function On(e) {
2364
+ function Wn(e) {
2377
2365
  let t = [...e.nodes];
2378
- for (let n of e.children) t.push(...On(n));
2366
+ for (let n of e.children) t.push(...Wn(n));
2379
2367
  return t;
2380
2368
  }
2381
- function kn(e, t, n) {
2369
+ function Gn(e, t, n) {
2382
2370
  if (t === n) return !0;
2383
2371
  let r = /* @__PURE__ */ new Set([t]), i = [t];
2384
2372
  for (; i.length > 0;) {
2385
2373
  let t = i.shift();
2386
- for (let a of Kn(e, t)) {
2374
+ for (let a of cr(e, t)) {
2387
2375
  if (a === n) return !0;
2388
2376
  r.has(a) || (r.add(a), i.push(a));
2389
2377
  }
2390
2378
  }
2391
2379
  return !1;
2392
2380
  }
2393
- function An(e, t) {
2394
- let n = Tn(e, t);
2381
+ function Kn(e, t) {
2382
+ let n = Vn(e, t);
2395
2383
  return n?.direction ? n.direction : e.config.graphDirection;
2396
2384
  }
2397
- function jn(e, t) {
2398
- let n = Tn(e, t);
2385
+ function qn(e, t) {
2386
+ let n = Vn(e, t);
2399
2387
  if (!n) return !1;
2400
2388
  let r = !1;
2401
- for (let i of e.edges) if (i.to === t && Tn(e, i.from) !== n) {
2389
+ for (let i of e.edges) if (i.to === t && Vn(e, i.from) !== n) {
2402
2390
  r = !0;
2403
2391
  break;
2404
2392
  }
@@ -2407,7 +2395,7 @@ function jn(e, t) {
2407
2395
  for (let r of n.nodes) {
2408
2396
  if (r === t || !r.gridCoord) continue;
2409
2397
  let a = !1;
2410
- for (let t of e.edges) if (t.to === r && Tn(e, t.from) !== n) {
2398
+ for (let t of e.edges) if (t.to === r && Vn(e, t.from) !== n) {
2411
2399
  a = !0;
2412
2400
  break;
2413
2401
  }
@@ -2415,34 +2403,34 @@ function jn(e, t) {
2415
2403
  }
2416
2404
  return !0;
2417
2405
  }
2418
- function Mn(e, t) {
2406
+ function Jn(e, t) {
2419
2407
  if (t.nodes.length === 0) return;
2420
2408
  let n = 1e6, r = 1e6, i = -1e6, a = -1e6;
2421
- for (let o of t.children) Mn(e, o), o.nodes.length > 0 && (n = Math.min(n, o.minX), r = Math.min(r, o.minY), i = Math.max(i, o.maxX), a = Math.max(a, o.maxY));
2409
+ for (let o of t.children) Jn(e, o), o.nodes.length > 0 && (n = Math.min(n, o.minX), r = Math.min(r, o.minY), i = Math.max(i, o.maxX), a = Math.max(a, o.maxY));
2422
2410
  for (let e of t.nodes) {
2423
2411
  if (!e.drawingCoord || !e.drawing) continue;
2424
2412
  let t = e.drawingCoord.x, o = e.drawingCoord.y, s = t + e.drawing.length - 1, c = o + e.drawing[0].length - 1;
2425
2413
  n = Math.min(n, t), r = Math.min(r, o), i = Math.max(i, s), a = Math.max(a, c);
2426
2414
  }
2427
2415
  t.minX = n - 2, t.minY = r - 2 - 2, t.maxX = i + 2, t.maxY = a + 2;
2428
- let o = Math.max(0, ...Q(t.name).map((e) => B(e))), s = t.maxX - t.minX, c = o + 1;
2416
+ let o = Math.max(0, ...Q(t.name).map((e) => z(e))), s = t.maxX - t.minX, c = o + 1;
2429
2417
  if (c > s) {
2430
2418
  let e = c - s, n = Math.floor(e / 2), r = e - n;
2431
2419
  t.minX -= n, t.maxX += r;
2432
2420
  }
2433
2421
  }
2434
- function Nn(e) {
2422
+ function Yn(e) {
2435
2423
  let t = e.subgraphs.filter((e) => e.parent === null && e.nodes.length > 0);
2436
2424
  for (let e = 0; e < t.length; e++) for (let n = e + 1; n < t.length; n++) {
2437
2425
  let r = t[e], i = t[n];
2438
2426
  r.minX < i.maxX && r.maxX > i.minX && (r.maxY >= i.minY - 1 && r.minY < i.minY ? i.minY = r.maxY + 1 + 1 : i.maxY >= r.minY - 1 && i.minY < r.minY && (r.minY = i.maxY + 1 + 1)), r.minY < i.maxY && r.maxY > i.minY && (r.maxX >= i.minX - 1 && r.minX < i.minX ? i.minX = r.maxX + 1 + 1 : i.maxX >= r.minX - 1 && i.minX < r.minX && (r.minX = i.maxX + 1 + 1));
2439
2427
  }
2440
2428
  }
2441
- function Pn(e) {
2442
- for (let t of e.subgraphs) Mn(e, t);
2443
- Nn(e);
2429
+ function Xn(e) {
2430
+ for (let t of e.subgraphs) Jn(e, t);
2431
+ Yn(e);
2444
2432
  }
2445
- function Fn(e) {
2433
+ function Zn(e) {
2446
2434
  if (e.subgraphs.length === 0) return;
2447
2435
  let t = 0, n = 0;
2448
2436
  for (let r of e.subgraphs) t = Math.min(t, r.minX), n = Math.min(n, r.minY);
@@ -2453,9 +2441,9 @@ function Fn(e) {
2453
2441
  for (let t of e.nodes) t.drawingCoord && (t.drawingCoord.x += r, t.drawingCoord.y += i);
2454
2442
  }
2455
2443
  }
2456
- function In(e, t) {
2444
+ function Qn(e, t) {
2457
2445
  let n = (t) => {
2458
- let n = Kn(e, t);
2446
+ let n = cr(e, t);
2459
2447
  return n.length > 0 ? n[0].name : null;
2460
2448
  }, r = /* @__PURE__ */ new Map(), i = t.map((e, t) => {
2461
2449
  let i = n(e);
@@ -2468,14 +2456,14 @@ function In(e, t) {
2468
2456
  i: t
2469
2457
  })).sort((e, t) => i[e.i] - i[t.i] || e.i - t.i).map(({ node: e }) => e);
2470
2458
  }
2471
- function Ln(e, t) {
2459
+ function $n(e, t) {
2472
2460
  let n = /* @__PURE__ */ new Set(), r = (t) => {
2473
2461
  let r = [t];
2474
2462
  for (; r.length > 0;) {
2475
2463
  let t = r.shift();
2476
2464
  if (!n.has(t.name)) {
2477
2465
  n.add(t.name);
2478
- for (let n of Kn(e, t)) r.push(n);
2466
+ for (let n of cr(e, t)) r.push(n);
2479
2467
  }
2480
2468
  }
2481
2469
  };
@@ -2484,10 +2472,10 @@ function Ln(e, t) {
2484
2472
  for (let t of e.nodes) n.has(t.name) || (i.push(t), r(t));
2485
2473
  return i;
2486
2474
  }
2487
- function Rn(e, t) {
2475
+ function er(e, t) {
2488
2476
  return e.nodes.find((e) => e.gridCoord !== null && e.gridCoord.x === t.x && e.gridCoord.y === t.y);
2489
2477
  }
2490
- function zn(e, t, n, r, i) {
2478
+ function tr(e, t, n, r, i) {
2491
2479
  let a = r === "x" ? "y" : "x", o = (i) => {
2492
2480
  let o = 4;
2493
2481
  for (;;) {
@@ -2501,26 +2489,26 @@ function zn(e, t, n, r, i) {
2501
2489
  y: s
2502
2490
  };
2503
2491
  if (kt(e.grid, c, 3)) return c;
2504
- let l = Rn(e, c);
2505
- if (!l || Dn(e, l) !== n) return null;
2492
+ let l = er(e, c);
2493
+ if (!l || Un(e, l) !== n) return null;
2506
2494
  o += 4;
2507
2495
  }
2508
2496
  };
2509
2497
  return o(i) ?? o(i * -1);
2510
2498
  }
2511
- function Bn(e, t, n, r) {
2512
- let i = Dn(e, t);
2499
+ function nr(e, t, n, r) {
2500
+ let i = Un(e, t);
2513
2501
  if (!i) return;
2514
2502
  let a = n.get(i);
2515
2503
  if (!a) return;
2516
2504
  n.delete(i);
2517
- let o = Z(t), s = An(e, t) === "LR" ? "y" : "x";
2505
+ let o = Z(t), s = Kn(e, t) === "LR" ? "y" : "x";
2518
2506
  for (let t of a) {
2519
- let n = An(e, t), a = zn(e, o, i, s, 1);
2520
- yn(e, e.nodes[t.index], a ?? o, n), r.add(t);
2507
+ let n = Kn(e, t), a = tr(e, o, i, s, 1);
2508
+ Fn(e, e.nodes[t.index], a ?? o, n), r.add(t);
2521
2509
  }
2522
2510
  }
2523
- function Vn(e, t) {
2511
+ function rr(e, t) {
2524
2512
  let n = !0;
2525
2513
  for (; n;) {
2526
2514
  n = !1;
@@ -2528,10 +2516,10 @@ function Vn(e, t) {
2528
2516
  for (let r of i) {
2529
2517
  let i = r.gridCoord;
2530
2518
  if (i === null) continue;
2531
- let a = [...Kn(e, r)].sort((t, n) => Gn(e, t, n));
2519
+ let a = [...cr(e, r)].sort((t, n) => sr(e, t, n));
2532
2520
  for (let o of a) {
2533
2521
  if (o.gridCoord !== null) continue;
2534
- let a = Tn(e, r), s = Tn(e, o), c = a && a === s && a.direction ? a.direction : e.config.graphDirection, l = c === "LR" ? i.x + 4 : i.y + 4, u;
2522
+ let a = Vn(e, r), s = Vn(e, o), c = a && a === s && a.direction ? a.direction : e.config.graphDirection, l = c === "LR" ? i.x + 4 : i.y + 4, u;
2535
2523
  u = c === e.config.graphDirection ? t[l] ?? 0 : c === "LR" ? i.y : i.x;
2536
2524
  let d = c === "LR" ? {
2537
2525
  x: l,
@@ -2540,33 +2528,33 @@ function Vn(e, t) {
2540
2528
  x: u,
2541
2529
  y: l
2542
2530
  };
2543
- yn(e, e.nodes[o.index], d, c), c === e.config.graphDirection && (t[l] = u + 4), n = !0;
2531
+ Fn(e, e.nodes[o.index], d, c), c === e.config.graphDirection && (t[l] = u + 4), n = !0;
2544
2532
  }
2545
2533
  }
2546
2534
  }
2547
2535
  }
2548
- function Hn(e) {
2536
+ function ir(e) {
2549
2537
  let t = e.config.graphDirection, n = [], r = /* @__PURE__ */ new Set();
2550
2538
  for (let t of e.edges) t.from !== t.to && r.add(t.to.name);
2551
- let i = Ln(e, e.nodes.filter((e) => !r.has(e.name))).filter((t) => {
2552
- let n = Tn(e, t);
2539
+ let i = $n(e, e.nodes.filter((e) => !r.has(e.name))).filter((t) => {
2540
+ let n = Vn(e, t);
2553
2541
  if (!n) return !0;
2554
- for (let r of e.edges) if (r.to === t && Tn(e, r.from) !== n) return !1;
2542
+ for (let r of e.edges) if (r.to === t && Vn(e, r.from) !== n) return !1;
2555
2543
  return !0;
2556
2544
  }), a = new Set(i), o = [], s = [];
2557
2545
  for (let t of i) {
2558
- let n = Dn(e, t);
2559
- n !== null && On(n).some((n) => n !== t && !a.has(n) && !kn(e, t, n)) ? o.push(t) : s.push(t);
2546
+ let n = Un(e, t);
2547
+ n !== null && Wn(n).some((n) => n !== t && !a.has(n) && !Gn(e, t, n)) ? o.push(t) : s.push(t);
2560
2548
  }
2561
- let c = In(e, s), l = /* @__PURE__ */ new Map();
2549
+ let c = Qn(e, s), l = /* @__PURE__ */ new Map();
2562
2550
  for (let t of o) {
2563
- let n = Dn(e, t), r = l.get(n);
2551
+ let n = Un(e, t), r = l.get(n);
2564
2552
  r ? r.push(t) : l.set(n, [t]);
2565
2553
  }
2566
2554
  let u = /* @__PURE__ */ new Set(), d = !1, f = !1;
2567
- for (let t of c) wn(e, t) ? Kn(e, t).length > 0 && (f = !0) : d = !0;
2555
+ for (let t of c) Bn(e, t) ? cr(e, t).length > 0 && (f = !0) : d = !0;
2568
2556
  let p = t === "LR" && d && f, m, h = [];
2569
- p ? (m = c.filter((t) => !wn(e, t)), h = c.filter((t) => wn(e, t))) : m = c;
2557
+ p ? (m = c.filter((t) => !Bn(e, t)), h = c.filter((t) => Bn(e, t))) : m = c;
2570
2558
  for (let r of m) {
2571
2559
  let i = t === "LR" ? {
2572
2560
  x: 0,
@@ -2575,7 +2563,7 @@ function Hn(e) {
2575
2563
  x: n[0] ?? 0,
2576
2564
  y: 0
2577
2565
  };
2578
- yn(e, e.nodes[r.index], i), n[0] = (n[0] ?? 0) + 4, Bn(e, r, l, u);
2566
+ Fn(e, e.nodes[r.index], i), n[0] = (n[0] ?? 0) + 4, nr(e, r, l, u);
2579
2567
  }
2580
2568
  if (p && h.length > 0) for (let r of h) {
2581
2569
  let i = t === "LR" ? {
@@ -2585,17 +2573,17 @@ function Hn(e) {
2585
2573
  x: n[4] ?? 0,
2586
2574
  y: 4
2587
2575
  };
2588
- yn(e, e.nodes[r.index], i), n[4] = (n[4] ?? 0) + 4, Bn(e, r, l, u);
2576
+ Fn(e, e.nodes[r.index], i), n[4] = (n[4] ?? 0) + 4, nr(e, r, l, u);
2589
2577
  }
2590
- Vn(e, n);
2578
+ rr(e, n);
2591
2579
  for (let t of o) {
2592
2580
  if (u.has(t)) continue;
2593
- let r = Dn(e, t), i = An(e, t), a = On(r).filter((e) => e !== t && e.gridCoord !== null), o;
2581
+ let r = Un(e, t), i = Kn(e, t), a = Wn(r).filter((e) => e !== t && e.gridCoord !== null), o;
2594
2582
  if (a.length > 0) {
2595
2583
  let t = a[0];
2596
2584
  for (let e of a) (i === "LR" ? e.gridCoord.x < t.gridCoord.x : e.gridCoord.y < t.gridCoord.y) && (t = e);
2597
2585
  let n = i === "LR" ? "y" : "x";
2598
- o = zn(e, t.gridCoord, r, n, 1) ?? {
2586
+ o = tr(e, t.gridCoord, r, n, 1) ?? {
2599
2587
  x: t.gridCoord.x,
2600
2588
  y: t.gridCoord.y
2601
2589
  };
@@ -2608,48 +2596,48 @@ function Hn(e) {
2608
2596
  x: n[0] ?? 0,
2609
2597
  y: 0
2610
2598
  }, n[0] = (n[0] ?? 0) + 4;
2611
- yn(e, e.nodes[t.index], o, i);
2599
+ Fn(e, e.nodes[t.index], o, i);
2612
2600
  }
2613
- Vn(e, n);
2614
- for (let t of e.nodes) bn(e, t);
2615
- e.pathBudget = Rt(), nr(e), e.bundles = Gt(e), Yt(e);
2601
+ rr(e, n);
2602
+ for (let t of e.nodes) In(e, t);
2603
+ e.pathBudget = Rt(), vr(e), e.bundles = Gt(e), Yt(e);
2616
2604
  let g = Xt(), _ = $t(), v = Et(e.grid);
2617
2605
  for (let t of e.edges) {
2618
2606
  if (t.bundle && t.path.length > 0) {
2619
- xn(e, t.path), Qt(v, g, t.path, t.style), rn(v, _, t.path, t), sr(e, t);
2607
+ Ln(e, t.path), Qt(v, g, t.path, t.style), rn(v, _, t.path, t), Cr(e, t);
2620
2608
  continue;
2621
2609
  }
2622
- ir(e, t), Cn(e, t, g, _, v), xn(e, t.path), Qt(v, g, t.path, t.style), rn(v, _, t.path, t), sr(e, t);
2610
+ br(e, t), zn(e, t, g, _, v), Ln(e, t.path), Qt(v, g, t.path, t.style), rn(v, _, t.path, t), Cr(e, t);
2623
2611
  }
2624
- for (let t of e.nodes) t.drawingCoord = _n(e, Z(t)), t.drawing = Br(t, e);
2625
- Pn(e), Fn(e), Be(e.canvas, e.columnWidth, e.rowHeight, e.offsetX, e.offsetY), Ve(e.roleCanvas, e.columnWidth, e.rowHeight, e.offsetX, e.offsetY);
2612
+ for (let t of e.nodes) t.drawingCoord = Nn(e, Z(t)), t.drawing = ni(t, e);
2613
+ Xn(e), Zn(e), Be(e.canvas, e.columnWidth, e.rowHeight, e.offsetX, e.offsetY), Ve(e.roleCanvas, e.columnWidth, e.rowHeight, e.offsetX, e.offsetY);
2626
2614
  }
2627
- function Un(e, t) {
2615
+ function ar(e, t) {
2628
2616
  return e.edges.filter((e) => e.from.name === t.name);
2629
2617
  }
2630
- function Wn(e, t) {
2631
- let n = Tn(e, t), r = [], i = n;
2618
+ function or(e, t) {
2619
+ let n = Vn(e, t), r = [], i = n;
2632
2620
  for (; i !== null;) r.unshift(i), i = i.parent;
2633
2621
  return r;
2634
2622
  }
2635
- function Gn(e, t, n) {
2636
- let r = Wn(e, t), i = Wn(e, n), a = 0;
2623
+ function sr(e, t, n) {
2624
+ let r = or(e, t), i = or(e, n), a = 0;
2637
2625
  for (; a < r.length && a < i.length && r[a] === i[a];) a++;
2638
2626
  let o = r[a], s = i[a];
2639
2627
  return !o || !s || o === s ? 0 : e.subgraphs.indexOf(s) - e.subgraphs.indexOf(o);
2640
2628
  }
2641
- function Kn(e, t) {
2642
- return Un(e, t).map((e) => e.to);
2629
+ function cr(e, t) {
2630
+ return ar(e, t).map((e) => e.to);
2643
2631
  }
2644
2632
  //#endregion
2645
2633
  //#region packages/ascii-renderer/src/edge-routing.ts
2646
- function qn(e) {
2634
+ function lr(e) {
2647
2635
  return e === K ? q : e === q ? K : e === J ? Y : e === Y ? J : e === dt ? mt : e === ft ? pt : e === pt ? ft : e === mt ? dt : ht;
2648
2636
  }
2649
2637
  function $(e, t) {
2650
2638
  return e.x === t.x ? e.y < t.y ? q : K : e.y === t.y ? e.x < t.x ? Y : J : e.x < t.x ? e.y < t.y ? pt : dt : e.y < t.y ? mt : ft;
2651
2639
  }
2652
- function Jn(e) {
2640
+ function ur(e) {
2653
2641
  return e === "LR" ? [
2654
2642
  Y,
2655
2643
  q,
@@ -2662,41 +2650,41 @@ function Jn(e) {
2662
2650
  q
2663
2651
  ];
2664
2652
  }
2665
- function Yn(e, t) {
2666
- if (e.from === e.to) return Jn(t);
2653
+ function dr(e, t) {
2654
+ if (e.from === e.to) return ur(t);
2667
2655
  let n = $(Z(e.from), Z(e.to)), r, i, a, o, s = t === "LR" ? X(n, J) || X(n, ft) || X(n, mt) : X(n, K) || X(n, ft) || X(n, dt);
2668
- return X(n, pt) ? t === "LR" ? (r = q, i = J, a = Y, o = K) : (r = Y, i = K, a = q, o = J) : X(n, dt) ? t === "LR" ? (r = K, i = J, a = Y, o = q) : (r = Y, i = q, a = K, o = J) : X(n, mt) ? t === "LR" ? (r = q, i = q, a = J, o = K) : (r = J, i = K, a = q, o = Y) : X(n, ft) ? t === "LR" ? (r = q, i = q, a = J, o = q) : (r = Y, i = Y, a = K, o = Y) : s ? t === "LR" && X(n, J) ? (r = q, i = q, a = J, o = Y) : t === "TD" && X(n, K) ? (r = Y, i = Y, a = K, o = q) : (r = n, i = qn(n), a = n, o = qn(n)) : (r = n, i = qn(n), a = n, o = qn(n)), [
2656
+ return X(n, pt) ? t === "LR" ? (r = q, i = J, a = Y, o = K) : (r = Y, i = K, a = q, o = J) : X(n, dt) ? t === "LR" ? (r = K, i = J, a = Y, o = q) : (r = Y, i = q, a = K, o = J) : X(n, mt) ? t === "LR" ? (r = q, i = q, a = J, o = K) : (r = J, i = K, a = q, o = Y) : X(n, ft) ? t === "LR" ? (r = q, i = q, a = J, o = q) : (r = Y, i = Y, a = K, o = Y) : s ? t === "LR" && X(n, J) ? (r = q, i = q, a = J, o = Y) : t === "TD" && X(n, K) ? (r = Y, i = Y, a = K, o = q) : (r = n, i = lr(n), a = n, o = lr(n)) : (r = n, i = lr(n), a = n, o = lr(n)), [
2669
2657
  r,
2670
2658
  i,
2671
2659
  a,
2672
2660
  o
2673
2661
  ];
2674
2662
  }
2675
- var Xn = 2, Zn = 200;
2676
- function Qn(e, t) {
2663
+ var fr = 2, pr = 200;
2664
+ function mr(e, t) {
2677
2665
  let n = e.gridCoord;
2678
2666
  return n ? t.x >= n.x && t.x <= n.x + 2 && t.y >= n.y && t.y <= n.y + 2 : !1;
2679
2667
  }
2680
- function $n(e, t, n = []) {
2668
+ function hr(e, t, n = []) {
2681
2669
  for (let r = 1; r < t.length - 1; r++) {
2682
2670
  let i = t[r];
2683
- if (Dt(e.grid, i) && !n.some((e) => Qn(e, i))) return !1;
2671
+ if (Dt(e.grid, i) && !n.some((e) => mr(e, i))) return !1;
2684
2672
  }
2685
2673
  return !0;
2686
2674
  }
2687
- function er(e) {
2675
+ function gr(e) {
2688
2676
  let t = e.from.gridCoord, n = e.to.gridCoord;
2689
2677
  return !t || !n ? !1 : t.y === n.y && t.x !== n.x;
2690
2678
  }
2691
- function tr(e) {
2679
+ function _r(e) {
2692
2680
  let t = e.from.name, n = e.to.name;
2693
- return er(e) && n < t ? JSON.stringify([n, t]) : JSON.stringify([t, n]);
2681
+ return gr(e) && n < t ? JSON.stringify([n, t]) : JSON.stringify([t, n]);
2694
2682
  }
2695
- function nr(e) {
2683
+ function vr(e) {
2696
2684
  let t = /* @__PURE__ */ new Map();
2697
2685
  for (let n of e.edges) {
2698
2686
  if (n.from === n.to) continue;
2699
- let e = tr(n), r = t.get(e);
2687
+ let e = _r(n), r = t.get(e);
2700
2688
  r ? r.push(n) : t.set(e, [n]);
2701
2689
  }
2702
2690
  for (let e of t.values()) {
@@ -2709,7 +2697,7 @@ function nr(e) {
2709
2697
  };
2710
2698
  }
2711
2699
  }
2712
- function rr(e, t, n, r, i) {
2700
+ function yr(e, t, n, r, i) {
2713
2701
  let a = xt(Z(t.from), n), o = xt(Z(t.to), r), s = X(n, J) || X(n, Y), c = [t.from, t.to], l = t.parallelLane.usedOffsets, u = X(n, Y) ? 1 : X(n, J) ? -1 : X(n, q) ? 1 : -1, d = X(r, Y) ? 1 : X(r, J) ? -1 : X(r, q) ? 1 : -1, f = s ? {
2714
2702
  x: a.x + u,
2715
2703
  y: a.y
@@ -2722,8 +2710,8 @@ function rr(e, t, n, r, i) {
2722
2710
  } : {
2723
2711
  x: o.x,
2724
2712
  y: o.y + d
2725
- }, m = [a, o], h = [a, o], g = Xn * i;
2726
- for (let t = 0; t < Zn; t++) {
2713
+ }, m = [a, o], h = [a, o], g = fr * i;
2714
+ for (let t = 0; t < pr; t++) {
2727
2715
  let n = g + t;
2728
2716
  if (l.has(n)) continue;
2729
2717
  let r = a.y + n, i = a.x + n, u = s ? [{
@@ -2743,7 +2731,7 @@ function rr(e, t, n, r, i) {
2743
2731
  ...u,
2744
2732
  o
2745
2733
  ]);
2746
- if ($n(e, Mt(d), c)) return l.add(n), {
2734
+ if (hr(e, Mt(d), c)) return l.add(n), {
2747
2735
  path: d,
2748
2736
  labelSegment: u
2749
2737
  };
@@ -2799,7 +2787,7 @@ function rr(e, t, n, r, i) {
2799
2787
  p,
2800
2788
  o
2801
2789
  ]);
2802
- if ($n(e, Mt(y), c)) return l.add(n), {
2790
+ if (hr(e, Mt(y), c)) return l.add(n), {
2803
2791
  path: y,
2804
2792
  labelSegment: v
2805
2793
  };
@@ -2812,13 +2800,13 @@ function rr(e, t, n, r, i) {
2812
2800
  labelSegment: h
2813
2801
  };
2814
2802
  }
2815
- function ir(e, t) {
2816
- let n = Tn(e, t.from), r = Tn(e, t.to), [i, a, o, s] = Yn(t, n && n === r && n.direction ? n.direction : e.config.graphDirection);
2803
+ function br(e, t) {
2804
+ let n = Vn(e, t.from), r = Vn(e, t.to), [i, a, o, s] = dr(t, n && n === r && n.direction ? n.direction : e.config.graphDirection);
2817
2805
  if (t.parallelLane && t.parallelLane.index > 0) {
2818
2806
  let n = X(i, a), r = n ? o : i, c = n ? s : a;
2819
2807
  t.startDir = r, t.endDir = c;
2820
- let l = rr(e, t, r, c, t.parallelLane.index);
2821
- t.path = l.path, t.text.length > 0 && lr(e, t, l.labelSegment, B(t.text));
2808
+ let l = yr(e, t, r, c, t.parallelLane.index);
2809
+ t.path = l.path, t.text.length > 0 && Tr(e, t, l.labelSegment, z(t.text));
2822
2810
  return;
2823
2811
  }
2824
2812
  let c = xt(Z(t.from), i), l = xt(Z(t.to), a), u = Wt(e, c, l, _t(i)), d = Wt(e, xt(Z(t.from), o), xt(Z(t.to), s), _t(o));
@@ -2834,30 +2822,30 @@ function ir(e, t) {
2834
2822
  t.startDir = o, t.endDir = s, t.path = d;
2835
2823
  return;
2836
2824
  }
2837
- t.startDir = i, t.endDir = a, t.path = cr([c, l]);
2825
+ t.startDir = i, t.endDir = a, t.path = wr([c, l]);
2838
2826
  }
2839
- function ar(e, t) {
2827
+ function xr(e, t) {
2840
2828
  for (let n of e.nodes) {
2841
2829
  let e = n.gridCoord;
2842
2830
  if (e && t >= e.x && t <= e.x + 2) return !0;
2843
2831
  }
2844
2832
  return !1;
2845
2833
  }
2846
- function or(e, t, n, r) {
2847
- if (!ar(e, r)) return r;
2834
+ function Sr(e, t, n, r) {
2835
+ if (!xr(e, r)) return r;
2848
2836
  for (let i = 1; i <= n - t; i++) {
2849
2837
  let a = r + i;
2850
- if (a <= n && !ar(e, a)) return a;
2838
+ if (a <= n && !xr(e, a)) return a;
2851
2839
  let o = r - i;
2852
- if (o >= t && !ar(e, o)) return o;
2840
+ if (o >= t && !xr(e, o)) return o;
2853
2841
  }
2854
2842
  return r;
2855
2843
  }
2856
- function sr(e, t) {
2844
+ function Cr(e, t) {
2857
2845
  if (t.text.length === 0 || t.parallelLane && t.parallelLane.index > 0) return;
2858
- let n = B(t.text), r = cr(t.path), i = r.length, a = [];
2846
+ let n = z(t.text), r = wr(t.path), i = r.length, a = [];
2859
2847
  for (let t = 1; t < i; t++) {
2860
- let n = r[t - 1], i = r[t], o = [n, i], s = ur(e, o), c = n.x === i.x;
2848
+ let n = r[t - 1], i = r[t], o = [n, i], s = Er(e, o), c = n.x === i.x;
2861
2849
  a.push({
2862
2850
  line: o,
2863
2851
  width: s,
@@ -2865,7 +2853,7 @@ function sr(e, t) {
2865
2853
  isVertical: c
2866
2854
  });
2867
2855
  }
2868
- let o = (t) => $n(e, Mt(t)), s = (e) => e.index === 1 || e.index === a.length, c = a.filter((e) => e.width >= n && !s(e) && o(e.line)), l;
2856
+ let o = (t) => hr(e, Mt(t)), s = (e) => e.index === 1 || e.index === a.length, c = a.filter((e) => e.width >= n && !s(e) && o(e.line)), l;
2869
2857
  if (c.length > 0) c.sort((e, t) => t.index - e.index), l = c[0].line;
2870
2858
  else {
2871
2859
  let e = a.filter((e) => e.width >= n && o(e.line));
@@ -2882,9 +2870,9 @@ function sr(e, t) {
2882
2870
  }
2883
2871
  }
2884
2872
  }
2885
- lr(e, t, l, n);
2873
+ Tr(e, t, l, n);
2886
2874
  }
2887
- function cr(e) {
2875
+ function wr(e) {
2888
2876
  let t = [];
2889
2877
  for (let n of e) {
2890
2878
  let e = t[t.length - 1];
@@ -2895,18 +2883,18 @@ function cr(e) {
2895
2883
  }
2896
2884
  return t;
2897
2885
  }
2898
- function lr(e, t, n, r) {
2899
- let i = Math.min(n[0].x, n[1].x), a = Math.max(n[0].x, n[1].x), o = or(e, i, a, i + Math.floor((a - i) / 2)), s = e.columnWidth.get(o) ?? 0;
2886
+ function Tr(e, t, n, r) {
2887
+ let i = Math.min(n[0].x, n[1].x), a = Math.max(n[0].x, n[1].x), o = Sr(e, i, a, i + Math.floor((a - i) / 2)), s = e.columnWidth.get(o) ?? 0;
2900
2888
  e.columnWidth.set(o, Math.max(s, r + 2)), t.labelLine = [n[0], n[1]];
2901
2889
  }
2902
- function ur(e, t) {
2890
+ function Er(e, t) {
2903
2891
  let n = 0, r = Math.min(t[0].x, t[1].x), i = Math.max(t[0].x, t[1].x);
2904
2892
  for (let t = r; t <= i; t++) n += e.columnWidth.get(t) ?? 0;
2905
2893
  return n;
2906
2894
  }
2907
2895
  //#endregion
2908
2896
  //#region packages/ascii-renderer/src/draw-lines.ts
2909
- var dr = {
2897
+ var Dr = {
2910
2898
  solid: {
2911
2899
  h: {
2912
2900
  unicode: "─",
@@ -2948,74 +2936,74 @@ var dr = {
2948
2936
  }
2949
2937
  }
2950
2938
  };
2951
- function fr(e, t, n, r, i, a, o = "solid") {
2952
- let s = $(t, n), c = [], l = dr[o], u = a ? l.h.ascii : l.h.unicode, d = a ? l.v.ascii : l.v.unicode;
2939
+ function Or(e, t, n, r, i, a, o = "solid") {
2940
+ let s = $(t, n), c = [], l = Dr[o], u = a ? l.h.ascii : l.h.unicode, d = a ? l.v.ascii : l.v.unicode;
2953
2941
  if (X(s, K)) for (let a = t.y - r; a >= n.y - i; a--) c.push({
2954
2942
  x: t.x,
2955
2943
  y: a
2956
- }), U(e, t.x, a, d);
2944
+ }), H(e, t.x, a, d);
2957
2945
  else if (X(s, q)) for (let a = t.y + r; a <= n.y + i; a++) c.push({
2958
2946
  x: t.x,
2959
2947
  y: a
2960
- }), U(e, t.x, a, d);
2948
+ }), H(e, t.x, a, d);
2961
2949
  else if (X(s, J)) for (let a = t.x - r; a >= n.x - i; a--) c.push({
2962
2950
  x: a,
2963
2951
  y: t.y
2964
- }), U(e, a, t.y, u);
2952
+ }), H(e, a, t.y, u);
2965
2953
  else if (X(s, Y)) for (let a = t.x + r; a <= n.x + i; a++) c.push({
2966
2954
  x: a,
2967
2955
  y: t.y
2968
- }), U(e, a, t.y, u);
2956
+ }), H(e, a, t.y, u);
2969
2957
  else if (X(s, ft)) {
2970
2958
  for (let i = t.x - r; i >= n.x; i--) c.push({
2971
2959
  x: i,
2972
2960
  y: t.y
2973
- }), U(e, i, t.y, u);
2961
+ }), H(e, i, t.y, u);
2974
2962
  for (let r = t.y - 1; r >= n.y - i; r--) c.push({
2975
2963
  x: n.x,
2976
2964
  y: r
2977
- }), U(e, n.x, r, d);
2965
+ }), H(e, n.x, r, d);
2978
2966
  } else if (X(s, dt)) {
2979
2967
  for (let i = t.x + r; i <= n.x; i++) c.push({
2980
2968
  x: i,
2981
2969
  y: t.y
2982
- }), U(e, i, t.y, u);
2970
+ }), H(e, i, t.y, u);
2983
2971
  for (let r = t.y - 1; r >= n.y - i; r--) c.push({
2984
2972
  x: n.x,
2985
2973
  y: r
2986
- }), U(e, n.x, r, d);
2974
+ }), H(e, n.x, r, d);
2987
2975
  } else if (X(s, mt)) {
2988
2976
  for (let i = t.x - r; i >= n.x; i--) c.push({
2989
2977
  x: i,
2990
2978
  y: t.y
2991
- }), U(e, i, t.y, u);
2979
+ }), H(e, i, t.y, u);
2992
2980
  for (let r = t.y + 1; r <= n.y + i; r++) c.push({
2993
2981
  x: n.x,
2994
2982
  y: r
2995
- }), U(e, n.x, r, d);
2983
+ }), H(e, n.x, r, d);
2996
2984
  } else if (X(s, pt)) {
2997
2985
  if (n.x - t.x <= 1) for (let a = t.y + r; a <= n.y + i; a++) c.push({
2998
2986
  x: t.x,
2999
2987
  y: a
3000
- }), U(e, t.x, a, d);
2988
+ }), H(e, t.x, a, d);
3001
2989
  else {
3002
2990
  for (let i = t.x + r; i <= n.x; i++) c.push({
3003
2991
  x: i,
3004
2992
  y: t.y
3005
- }), U(e, i, t.y, u);
2993
+ }), H(e, i, t.y, u);
3006
2994
  for (let r = t.y + 1; r <= n.y + i; r++) c.push({
3007
2995
  x: n.x,
3008
2996
  y: r
3009
- }), U(e, n.x, r, d);
2997
+ }), H(e, n.x, r, d);
3010
2998
  }
3011
2999
  }
3012
3000
  return c;
3013
3001
  }
3014
3002
  //#endregion
3015
3003
  //#region packages/ascii-renderer/src/draw-arrows.ts
3016
- function pr(e, t) {
3004
+ function kr(e, t) {
3017
3005
  if (t.path.length === 0) {
3018
- let t = H(e.canvas);
3006
+ let t = V(e.canvas);
3019
3007
  return [
3020
3008
  t,
3021
3009
  t,
@@ -3025,17 +3013,17 @@ function pr(e, t) {
3025
3013
  t
3026
3014
  ];
3027
3015
  }
3028
- let n = Tr(e, t), [r, i, a] = hr(e, t.path, t.style), o = i.length > 0, s = t.style === "invisible", c = o && !s ? vr(e, t.path, i[0], t.from) : H(e.canvas), l;
3029
- l = t.hasArrowEnd && o ? Sr(e, i[i.length - 1], a[a.length - 1], t.endMarker) : H(e.canvas);
3016
+ let n = Vr(e, t), [r, i, a] = jr(e, t.path, t.style), o = i.length > 0, s = t.style === "invisible", c = o && !s ? Pr(e, t.path, i[0], t.from) : V(e.canvas), l;
3017
+ l = t.hasArrowEnd && o ? Rr(e, i[i.length - 1], a[a.length - 1], t.endMarker) : V(e.canvas);
3030
3018
  let u;
3031
3019
  if (t.hasArrowStart && o) {
3032
- let n = i[0][0], r = mr(a[0]), o = {
3020
+ let n = i[0][0], r = Ar(a[0]), o = {
3033
3021
  x: n.x,
3034
3022
  y: n.y
3035
3023
  };
3036
- X(a[0], Y) ? o.x = n.x - 1 : X(a[0], J) ? o.x = n.x + 1 : X(a[0], q) ? o.y = n.y - 1 : X(a[0], K) && (o.y = n.y + 1), u = Sr(e, [n, o], r, t.startMarker);
3037
- } else u = H(e.canvas);
3038
- let d = s ? H(e.canvas) : Cr(e, t.path);
3024
+ X(a[0], Y) ? o.x = n.x - 1 : X(a[0], J) ? o.x = n.x + 1 : X(a[0], q) ? o.y = n.y - 1 : X(a[0], K) && (o.y = n.y + 1), u = Rr(e, [n, o], r, t.startMarker);
3025
+ } else u = V(e.canvas);
3026
+ let d = s ? V(e.canvas) : zr(e, t.path);
3039
3027
  return [
3040
3028
  r,
3041
3029
  c,
@@ -3045,18 +3033,18 @@ function pr(e, t) {
3045
3033
  n
3046
3034
  ];
3047
3035
  }
3048
- function mr(e) {
3036
+ function Ar(e) {
3049
3037
  return X(e, K) ? q : X(e, q) ? K : X(e, J) ? Y : X(e, Y) ? J : X(e, ft) ? pt : X(e, dt) ? mt : X(e, mt) ? dt : X(e, pt) ? ft : ht;
3050
3038
  }
3051
- function hr(e, t, n = "solid") {
3052
- let r = H(e.canvas), i = t[0], a = [], o = [];
3039
+ function jr(e, t, n = "solid") {
3040
+ let r = V(e.canvas), i = t[0], a = [], o = [];
3053
3041
  for (let s = 1; s < t.length; s++) {
3054
- let c = t[s], l = _n(e, i), u = _n(e, c);
3042
+ let c = t[s], l = Nn(e, i), u = Nn(e, c);
3055
3043
  if (bt(l, u)) {
3056
3044
  i = c;
3057
3045
  continue;
3058
3046
  }
3059
- let d = $(i, c), f = fr(r, l, u, 1, -1, e.config.useAscii, n);
3047
+ let d = $(i, c), f = Or(r, l, u, 1, -1, e.config.useAscii, n);
3060
3048
  f.length === 0 && f.push(l), a.push(f), o.push(d), i = c;
3061
3049
  }
3062
3050
  return [
@@ -3065,7 +3053,7 @@ function hr(e, t, n = "solid") {
3065
3053
  o
3066
3054
  ];
3067
3055
  }
3068
- var gr = /* @__PURE__ */ new Set([
3056
+ var Mr = /* @__PURE__ */ new Set([
3069
3057
  "│",
3070
3058
  "┃",
3071
3059
  "║",
@@ -3073,7 +3061,7 @@ var gr = /* @__PURE__ */ new Set([
3073
3061
  "┊",
3074
3062
  "|",
3075
3063
  "‖"
3076
- ]), _r = /* @__PURE__ */ new Set([
3064
+ ]), Nr = /* @__PURE__ */ new Set([
3077
3065
  "─",
3078
3066
  "━",
3079
3067
  "═",
@@ -3082,31 +3070,31 @@ var gr = /* @__PURE__ */ new Set([
3082
3070
  "-",
3083
3071
  "="
3084
3072
  ]);
3085
- function vr(e, t, n, r) {
3086
- let i = H(e.canvas), a = e.config.useAscii;
3073
+ function Pr(e, t, n, r) {
3074
+ let i = V(e.canvas), a = e.config.useAscii;
3087
3075
  if (r.shape === "state-start" || r.shape === "state-end") return i;
3088
3076
  let o = n[0], s = $(t[0], t[1]), c = a ? "+" : null, l = (t, n) => e.canvas[t]?.[n];
3089
3077
  if (X(s, K)) {
3090
3078
  let e = o.x, t = o.y + 1, n = l(e, t);
3091
- U(i, e, t, n !== void 0 && _r.has(n) ? c ?? "┴" : a ? "|" : "│");
3079
+ H(i, e, t, n !== void 0 && Nr.has(n) ? c ?? "┴" : a ? "|" : "│");
3092
3080
  } else if (X(s, q)) {
3093
3081
  let e = o.x, t = o.y - 1, n = l(e, t);
3094
- U(i, e, t, n !== void 0 && _r.has(n) ? c ?? "┬" : a ? "|" : "│");
3082
+ H(i, e, t, n !== void 0 && Nr.has(n) ? c ?? "┬" : a ? "|" : "│");
3095
3083
  } else if (X(s, J) || X(s, Y)) {
3096
3084
  let e = r.drawingCoord, t = r.drawing;
3097
3085
  if (e === null || t === null)
3098
3086
  /* v8 ignore next */
3099
3087
  throw Error(`drawBoxStart: node "${r.name}" has no drawingCoord/drawing assigned`);
3100
3088
  let n = t.length, u = X(s, J) ? e.x : e.x + n - 1, d = o.y, f = l(u, d);
3101
- U(i, u, d, f !== void 0 && gr.has(f) ? c ?? (X(s, J) ? "┤" : "├") : a ? "-" : "─");
3089
+ H(i, u, d, f !== void 0 && Mr.has(f) ? c ?? (X(s, J) ? "┤" : "├") : a ? "-" : "─");
3102
3090
  }
3103
3091
  return i;
3104
3092
  }
3105
- function yr(e, t) {
3093
+ function Fr(e, t) {
3106
3094
  if (t === "circle") return e ? "o" : "○";
3107
3095
  if (t === "cross") return e ? "x" : "✕";
3108
3096
  }
3109
- function br(e) {
3097
+ function Ir(e) {
3110
3098
  if (X(e, K)) return "▲";
3111
3099
  if (X(e, q)) return "▼";
3112
3100
  if (X(e, J)) return "◄";
@@ -3116,53 +3104,53 @@ function br(e) {
3116
3104
  if (X(e, pt)) return "↘";
3117
3105
  if (X(e, mt)) return "↙";
3118
3106
  }
3119
- function xr(e) {
3107
+ function Lr(e) {
3120
3108
  if (X(e, K)) return "^";
3121
3109
  if (X(e, q)) return "v";
3122
3110
  if (X(e, J)) return "<";
3123
3111
  if (X(e, Y)) return ">";
3124
3112
  }
3125
- function Sr(e, t, n, r) {
3126
- let i = H(e.canvas);
3113
+ function Rr(e, t, n, r) {
3114
+ let i = V(e.canvas);
3127
3115
  if (t.length === 0) return i;
3128
3116
  let a = t[t.length - 1], o = $(t.length >= 2 ? t[t.length - 2] : t[0], a);
3129
3117
  (t.length === 1 || X(o, ht)) && (o = n);
3130
- let s = yr(e.config.useAscii, r), c;
3118
+ let s = Fr(e.config.useAscii, r), c;
3131
3119
  if (s !== void 0) c = s;
3132
3120
  else if (e.config.useAscii) {
3133
- let e = xr(o);
3121
+ let e = Lr(o);
3134
3122
  /* v8 ignore else */
3135
- c = e === void 0 ? xr(n) ?? "*" : e;
3123
+ c = e === void 0 ? Lr(n) ?? "*" : e;
3136
3124
  } else {
3137
- let e = br(o);
3125
+ let e = Ir(o);
3138
3126
  /* v8 ignore else */
3139
- c = e === void 0 ? br(n) ?? "●" : e;
3127
+ c = e === void 0 ? Ir(n) ?? "●" : e;
3140
3128
  }
3141
- return U(i, a.x, a.y, c), i;
3129
+ return H(i, a.x, a.y, c), i;
3142
3130
  }
3143
- function Cr(e, t) {
3144
- let n = H(e.canvas);
3131
+ function zr(e, t) {
3132
+ let n = V(e.canvas);
3145
3133
  for (let r = 1; r < t.length - 1; r++) {
3146
- let i = t[r], a = _n(e, i), o = $(t[r - 1], i), s = $(i, t[r + 1]), c;
3147
- c = e.config.useAscii ? "+" : X(o, Y) && X(s, q) || X(o, K) && X(s, J) ? "┐" : X(o, Y) && X(s, K) || X(o, q) && X(s, J) ? "┘" : X(o, J) && X(s, q) || X(o, K) && X(s, Y) ? "┌" : X(o, J) && X(s, K) || X(o, q) && X(s, Y) ? "└" : "+", U(n, a.x, a.y, c);
3134
+ let i = t[r], a = Nn(e, i), o = $(t[r - 1], i), s = $(i, t[r + 1]), c;
3135
+ c = e.config.useAscii ? "+" : X(o, Y) && X(s, q) || X(o, K) && X(s, J) ? "┐" : X(o, Y) && X(s, K) || X(o, q) && X(s, J) ? "┘" : X(o, J) && X(s, q) || X(o, K) && X(s, Y) ? "┌" : X(o, J) && X(s, K) || X(o, q) && X(s, Y) ? "└" : "+", H(n, a.x, a.y, c);
3148
3136
  }
3149
3137
  return n;
3150
3138
  }
3151
- function wr(e, t) {
3139
+ function Br(e, t) {
3152
3140
  return e.edges.some((e) => e !== t && e.from === t.to && e.to === t.from);
3153
3141
  }
3154
- function Tr(e, t) {
3155
- let n = H(e.canvas);
3142
+ function Vr(e, t) {
3143
+ let n = V(e.canvas);
3156
3144
  if (t.text.length === 0) return n;
3157
- let r = vn(e, t.labelLine), i;
3145
+ let r = Pn(e, t.labelLine), i;
3158
3146
  if (t.path.length >= 2) {
3159
3147
  let e = t.path[0].y, n = t.path[t.path.length - 1].y;
3160
3148
  n < e ? i = !0 : n > e && (i = !1);
3161
3149
  }
3162
- let a = wr(e, t);
3163
- return Er(n, r, t.text, i, a), n;
3150
+ let a = Br(e, t);
3151
+ return Hr(n, r, t.text, i, a), n;
3164
3152
  }
3165
- function Er(e, t, n, r, i = !1) {
3153
+ function Hr(e, t, n, r, i = !1) {
3166
3154
  if (t.length < 2) return;
3167
3155
  let a = Math.min(t[0].x, t[1].x), o = Math.max(t[0].x, t[1].x), s = Math.min(t[0].y, t[1].y), c = Math.max(t[0].y, t[1].y), l = a + Math.floor((o - a) / 2), u = s + Math.floor((c - s) / 2);
3168
3156
  if (r !== void 0 && a === o) {
@@ -3173,14 +3161,14 @@ function Er(e, t, n, r, i = !1) {
3173
3161
  for (let t = 0; t < d.length; t++) {
3174
3162
  let n = d[t];
3175
3163
  ze(e, {
3176
- x: l - Math.floor(B(n) / 2),
3164
+ x: l - Math.floor(z(n) / 2),
3177
3165
  y: f + t
3178
3166
  }, n);
3179
3167
  }
3180
3168
  }
3181
3169
  //#endregion
3182
3170
  //#region packages/ascii-renderer/src/draw-bundles.ts
3183
- function Dr(e, t, n) {
3171
+ function Ur(e, t, n) {
3184
3172
  let r = Z(t), i = 0;
3185
3173
  for (let t = 0; t < 2; t++) i += e.columnWidth.get(r.x + t) ?? 0;
3186
3174
  let a = 0;
@@ -3208,10 +3196,10 @@ function Dr(e, t, n) {
3208
3196
  if (s === null)
3209
3197
  /* v8 ignore next */
3210
3198
  throw Error(`Node "${t.name}" has no drawingCoord; grid layout must run before bundled-edge drawing`);
3211
- return gn(t.shape, n, o, s);
3199
+ return Mn(t.shape, n, o, s);
3212
3200
  }
3213
- function Or(e, t, n) {
3214
- let r = H(e.canvas), i = t.pathToJunction;
3201
+ function Wr(e, t, n) {
3202
+ let r = V(e.canvas), i = t.pathToJunction;
3215
3203
  if (!i || i.length === 0) return [
3216
3204
  r,
3217
3205
  r,
@@ -3220,20 +3208,20 @@ function Or(e, t, n) {
3220
3208
  r,
3221
3209
  r
3222
3210
  ];
3223
- let a = H(e.canvas), o = e.config.useAscii, s = i.map((r, a) => n.type === "fan-in" && a === 0 ? Dr(e, t.from, t.startDir) : n.type === "fan-out" && a === i.length - 1 ? Dr(e, t.to, t.endDir) : _n(e, r));
3211
+ let a = V(e.canvas), o = e.config.useAscii, s = i.map((r, a) => n.type === "fan-in" && a === 0 ? Ur(e, t.from, t.startDir) : n.type === "fan-out" && a === i.length - 1 ? Ur(e, t.to, t.endDir) : Nn(e, r));
3224
3212
  for (let e = 1; e < s.length; e++) {
3225
3213
  let n = s[e - 1], r = s[e];
3226
- bt(n, r) || fr(a, n, r, 1, -1, o, t.style);
3214
+ bt(n, r) || Or(a, n, r, 1, -1, o, t.style);
3227
3215
  }
3228
- let c = H(e.canvas);
3216
+ let c = V(e.canvas);
3229
3217
  for (let t = 1; t < i.length - 1; t++) {
3230
- let n = i[t], r = _n(e, n), a = $(i[t - 1], n), s = $(n, i[t + 1]), l;
3231
- l = o ? "+" : X(a, Y) && X(s, q) || X(a, K) && X(s, J) ? "┐" : X(a, Y) && X(s, K) || X(a, q) && X(s, J) ? "┘" : X(a, J) && X(s, q) || X(a, K) && X(s, Y) ? "┌" : X(a, J) && X(s, K) || X(a, q) && X(s, Y) ? "└" : "+", U(c, r.x, r.y, l);
3218
+ let n = i[t], r = Nn(e, n), a = $(i[t - 1], n), s = $(n, i[t + 1]), l;
3219
+ l = o ? "+" : X(a, Y) && X(s, q) || X(a, K) && X(s, J) ? "┐" : X(a, Y) && X(s, K) || X(a, q) && X(s, J) ? "┘" : X(a, J) && X(s, q) || X(a, K) && X(s, Y) ? "┌" : X(a, J) && X(s, K) || X(a, q) && X(s, Y) ? "└" : "+", H(c, r.x, r.y, l);
3232
3220
  }
3233
- let l = H(e.canvas);
3221
+ let l = V(e.canvas);
3234
3222
  if (n.type === "fan-in" && i.length >= 2) {
3235
3223
  let e = s[0], t = $(i[0], i[1]), n = o ? "+" : null;
3236
- X(t, K) ? U(l, e.x, e.y, n ?? "┴") : X(t, q) ? U(l, e.x, e.y, n ?? "┬") : X(t, J) ? U(l, e.x, e.y, n ?? "┤") : X(t, Y) && U(l, e.x, e.y, n ?? "├");
3224
+ X(t, K) ? H(l, e.x, e.y, n ?? "┴") : X(t, q) ? H(l, e.x, e.y, n ?? "┬") : X(t, J) ? H(l, e.x, e.y, n ?? "┤") : X(t, Y) && H(l, e.x, e.y, n ?? "├");
3237
3225
  }
3238
3226
  return [
3239
3227
  a,
@@ -3241,72 +3229,72 @@ function Or(e, t, n) {
3241
3229
  r,
3242
3230
  r,
3243
3231
  c,
3244
- H(e.canvas)
3232
+ V(e.canvas)
3245
3233
  ];
3246
3234
  }
3247
- function kr(e, t) {
3248
- let n = H(e.canvas), r = H(e.canvas);
3235
+ function Gr(e, t) {
3236
+ let n = V(e.canvas), r = V(e.canvas);
3249
3237
  if (t.sharedPath.length < 2) return [n, r];
3250
3238
  let i = e.config.useAscii, a = t.edges[0]?.style ?? "solid", o = e.config.graphDirection, s = t.sharedPath.map((n, r) => {
3251
3239
  if (t.type === "fan-in" && r === t.sharedPath.length - 1) {
3252
3240
  let n = o === "TD" ? K : J;
3253
- return Dr(e, t.sharedNode, n);
3241
+ return Ur(e, t.sharedNode, n);
3254
3242
  }
3255
3243
  if (t.type === "fan-out" && r === 0) {
3256
3244
  let n = o === "TD" ? q : Y;
3257
- return Dr(e, t.sharedNode, n);
3245
+ return Ur(e, t.sharedNode, n);
3258
3246
  }
3259
- return _n(e, n);
3247
+ return Nn(e, n);
3260
3248
  });
3261
3249
  for (let e = 1; e < s.length; e++) {
3262
3250
  let t = s[e - 1], r = s[e];
3263
- bt(t, r) || fr(n, t, r, 1, -1, i, a);
3251
+ bt(t, r) || Or(n, t, r, 1, -1, i, a);
3264
3252
  }
3265
3253
  for (let n = 1; n < t.sharedPath.length - 1; n++) {
3266
- let a = t.sharedPath[n], o = _n(e, a), s = $(t.sharedPath[n - 1], a), c = $(a, t.sharedPath[n + 1]), l;
3267
- l = i ? "+" : X(s, Y) && X(c, q) || X(s, K) && X(c, J) ? "┐" : X(s, Y) && X(c, K) || X(s, q) && X(c, J) ? "┘" : X(s, J) && X(c, q) || X(s, K) && X(c, Y) ? "┌" : X(s, J) && X(c, K) || X(s, q) && X(c, Y) ? "└" : "+", U(r, o.x, o.y, l);
3254
+ let a = t.sharedPath[n], o = Nn(e, a), s = $(t.sharedPath[n - 1], a), c = $(a, t.sharedPath[n + 1]), l;
3255
+ l = i ? "+" : X(s, Y) && X(c, q) || X(s, K) && X(c, J) ? "┐" : X(s, Y) && X(c, K) || X(s, q) && X(c, J) ? "┘" : X(s, J) && X(c, q) || X(s, K) && X(c, Y) ? "┌" : X(s, J) && X(c, K) || X(s, q) && X(c, Y) ? "└" : "+", H(r, o.x, o.y, l);
3268
3256
  }
3269
3257
  return [n, r];
3270
3258
  }
3271
- function Ar(e, t) {
3272
- let n = H(e.canvas);
3259
+ function Kr(e, t) {
3260
+ let n = V(e.canvas);
3273
3261
  if (t.sharedPath.length < 2) return n;
3274
- let r = t.sharedPath.length - 1, i = t.sharedPath[r - 1], a = t.sharedPath[r], o = $(i, a), s = e.config.graphDirection, c = s === "TD" ? K : J, l = Dr(e, t.sharedNode, c);
3262
+ let r = t.sharedPath.length - 1, i = t.sharedPath[r - 1], a = t.sharedPath[r], o = $(i, a), s = e.config.graphDirection, c = s === "TD" ? K : J, l = Ur(e, t.sharedNode, c);
3275
3263
  s === "TD" ? --l.y : --l.x;
3276
- let u = t.edges[0]?.endMarker, d = t.edges.every((e) => e.endMarker === u) ? u : void 0, f = yr(e.config.useAscii, d), p;
3277
- return p = f === void 0 ? e.config.useAscii ? X(o, K) ? "^" : X(o, q) ? "v" : X(o, J) ? "<" : X(o, Y) ? ">" : "v" : X(o, K) ? "▲" : X(o, q) ? "▼" : X(o, J) ? "◄" : X(o, Y) ? "►" : "▼" : f, U(n, l.x, l.y, p), n;
3264
+ let u = t.edges[0]?.endMarker, d = t.edges.every((e) => e.endMarker === u) ? u : void 0, f = Fr(e.config.useAscii, d), p;
3265
+ return p = f === void 0 ? e.config.useAscii ? X(o, K) ? "^" : X(o, q) ? "v" : X(o, J) ? "<" : X(o, Y) ? ">" : "v" : X(o, K) ? "▲" : X(o, q) ? "▼" : X(o, J) ? "◄" : X(o, Y) ? "►" : "▼" : f, H(n, l.x, l.y, p), n;
3278
3266
  }
3279
- function jr(e, t) {
3280
- let n = H(e.canvas);
3267
+ function qr(e, t) {
3268
+ let n = V(e.canvas);
3281
3269
  if (!t.pathToJunction || t.pathToJunction.length < 2) return n;
3282
- let r = t.pathToJunction.length - 1, i = t.pathToJunction[r - 1], a = t.pathToJunction[r], o = $(i, a), s = e.config.graphDirection, c = s === "TD" ? K : J, l = Dr(e, t.to, c);
3270
+ let r = t.pathToJunction.length - 1, i = t.pathToJunction[r - 1], a = t.pathToJunction[r], o = $(i, a), s = e.config.graphDirection, c = s === "TD" ? K : J, l = Ur(e, t.to, c);
3283
3271
  s === "TD" ? --l.y : --l.x;
3284
- let u = yr(e.config.useAscii, t.endMarker), d;
3285
- return d = u === void 0 ? e.config.useAscii ? X(o, K) ? "^" : X(o, q) ? "v" : X(o, J) ? "<" : X(o, Y) ? ">" : "v" : X(o, K) ? "▲" : X(o, q) ? "▼" : X(o, J) ? "◄" : X(o, Y) ? "►" : "▼" : u, U(n, l.x, l.y, d), n;
3272
+ let u = Fr(e.config.useAscii, t.endMarker), d;
3273
+ return d = u === void 0 ? e.config.useAscii ? X(o, K) ? "^" : X(o, q) ? "v" : X(o, J) ? "<" : X(o, Y) ? ">" : "v" : X(o, K) ? "▲" : X(o, q) ? "▼" : X(o, J) ? "◄" : X(o, Y) ? "►" : "▼" : u, H(n, l.x, l.y, d), n;
3286
3274
  }
3287
- function Mr(e) {
3275
+ function Jr(e) {
3288
3276
  return X(e, K) ? q : X(e, q) ? K : X(e, J) ? Y : X(e, Y) ? J : e;
3289
3277
  }
3290
- function Nr(e, t) {
3291
- let n = H(e.canvas);
3278
+ function Yr(e, t) {
3279
+ let n = V(e.canvas);
3292
3280
  if (t.sharedPath.length < 2) return n;
3293
- let r = t.sharedPath[0], i = t.sharedPath[1], a = Mr($(r, i)), o = e.config.graphDirection, s = o === "TD" ? q : Y, c = Dr(e, t.sharedNode, s);
3281
+ let r = t.sharedPath[0], i = t.sharedPath[1], a = Jr($(r, i)), o = e.config.graphDirection, s = o === "TD" ? q : Y, c = Ur(e, t.sharedNode, s);
3294
3282
  o === "TD" ? c.y += 1 : c.x += 1;
3295
3283
  let l;
3296
- return l = e.config.useAscii ? X(a, K) ? "^" : X(a, q) ? "v" : X(a, J) ? "<" : X(a, Y) ? ">" : "^" : X(a, K) ? "▲" : X(a, q) ? "▼" : X(a, J) ? "◄" : X(a, Y) ? "►" : "▲", U(n, c.x, c.y, l), n;
3284
+ return l = e.config.useAscii ? X(a, K) ? "^" : X(a, q) ? "v" : X(a, J) ? "<" : X(a, Y) ? ">" : "^" : X(a, K) ? "▲" : X(a, q) ? "▼" : X(a, J) ? "◄" : X(a, Y) ? "►" : "▲", H(n, c.x, c.y, l), n;
3297
3285
  }
3298
- function Pr(e, t) {
3299
- let n = H(e.canvas);
3286
+ function Xr(e, t) {
3287
+ let n = V(e.canvas);
3300
3288
  if (!t.pathToJunction || t.pathToJunction.length < 2) return n;
3301
- let r = t.pathToJunction[0], i = t.pathToJunction[1], a = Mr($(r, i)), o = Dr(e, t.from, t.startDir);
3289
+ let r = t.pathToJunction[0], i = t.pathToJunction[1], a = Jr($(r, i)), o = Ur(e, t.from, t.startDir);
3302
3290
  X(t.startDir, K) ? --o.y : X(t.startDir, q) ? o.y += 1 : X(t.startDir, J) ? --o.x : X(t.startDir, Y) && (o.x += 1);
3303
3291
  let s;
3304
- return s = e.config.useAscii ? X(a, K) ? "^" : X(a, q) ? "v" : X(a, J) ? "<" : X(a, Y) ? ">" : "v" : X(a, K) ? "▲" : X(a, q) ? "▼" : X(a, J) ? "◄" : X(a, Y) ? "►" : "▼", U(n, o.x, o.y, s), n;
3292
+ return s = e.config.useAscii ? X(a, K) ? "^" : X(a, q) ? "v" : X(a, J) ? "<" : X(a, Y) ? ">" : "v" : X(a, K) ? "▲" : X(a, q) ? "▼" : X(a, J) ? "◄" : X(a, Y) ? "►" : "▼", H(n, o.x, o.y, s), n;
3305
3293
  }
3306
- function Fr(e, t) {
3307
- let n = H(e.canvas);
3294
+ function Zr(e, t) {
3295
+ let n = V(e.canvas);
3308
3296
  if (!t.junctionPoint) return n;
3309
- let r = _n(e, t.junctionPoint), i = e.config.useAscii, a = !1, o = !1, s = !1, c = !1;
3297
+ let r = Nn(e, t.junctionPoint), i = e.config.useAscii, a = !1, o = !1, s = !1, c = !1;
3310
3298
  if (t.sharedPath.length >= 2) {
3311
3299
  let e = t.type === "fan-in" ? 0 : t.sharedPath.length - 1, n = t.type === "fan-in" ? 1 : t.sharedPath.length - 2, r = $(t.sharedPath[e], t.sharedPath[n]);
3312
3300
  X(r, q) ? o = !0 : X(r, K) ? a = !0 : X(r, Y) ? c = !0 : X(r, J) && (s = !0);
@@ -3316,51 +3304,51 @@ function Fr(e, t) {
3316
3304
  X(i, q) ? a = !0 : X(i, K) ? o = !0 : X(i, Y) ? s = !0 : X(i, J) && (c = !0);
3317
3305
  }
3318
3306
  let l;
3319
- return l = i ? "+" : a && o && s && c ? "┼" : o && s && c && !a ? "┬" : a && s && c && !o ? "┴" : a && o && c && !s ? "├" : a && o && s && !c ? "┤" : s && c ? "─" : a && o ? "│" : o && c ? "┌" : o && s ? "┐" : a && c ? "└" : a && s ? "┘" : "┼", U(n, r.x, r.y, l), n;
3307
+ return l = i ? "+" : a && o && s && c ? "┼" : o && s && c && !a ? "┬" : a && s && c && !o ? "┴" : a && o && c && !s ? "├" : a && o && s && !c ? "┤" : s && c ? "─" : a && o ? "│" : o && c ? "┌" : o && s ? "┐" : a && c ? "└" : a && s ? "┘" : "┼", H(n, r.x, r.y, l), n;
3320
3308
  }
3321
3309
  //#endregion
3322
3310
  //#region packages/ascii-renderer/src/draw-subgraphs.ts
3323
- function Ir(e, t) {
3311
+ function Qr(e, t) {
3324
3312
  let n = e.maxX - e.minX, r = e.maxY - e.minY;
3325
- if (n <= 0 || r <= 0) return V(0, 0);
3313
+ if (n <= 0 || r <= 0) return B(0, 0);
3326
3314
  let i = {
3327
3315
  x: 0,
3328
3316
  y: 0
3329
3317
  }, a = {
3330
3318
  x: n,
3331
3319
  y: r
3332
- }, o = V(n, r);
3320
+ }, o = B(n, r);
3333
3321
  if (t.config.useAscii) {
3334
- for (let e = i.x + 1; e < a.x; e++) U(o, e, i.y, "-");
3335
- for (let e = i.x + 1; e < a.x; e++) U(o, e, a.y, "-");
3336
- for (let e = i.y + 1; e < a.y; e++) U(o, i.x, e, "|");
3337
- for (let e = i.y + 1; e < a.y; e++) U(o, a.x, e, "|");
3338
- U(o, i.x, i.y, "+"), U(o, a.x, i.y, "+"), U(o, i.x, a.y, "+"), U(o, a.x, a.y, "+");
3322
+ for (let e = i.x + 1; e < a.x; e++) H(o, e, i.y, "-");
3323
+ for (let e = i.x + 1; e < a.x; e++) H(o, e, a.y, "-");
3324
+ for (let e = i.y + 1; e < a.y; e++) H(o, i.x, e, "|");
3325
+ for (let e = i.y + 1; e < a.y; e++) H(o, a.x, e, "|");
3326
+ H(o, i.x, i.y, "+"), H(o, a.x, i.y, "+"), H(o, i.x, a.y, "+"), H(o, a.x, a.y, "+");
3339
3327
  } else {
3340
- for (let e = i.x + 1; e < a.x; e++) U(o, e, i.y, "─");
3341
- for (let e = i.x + 1; e < a.x; e++) U(o, e, a.y, "─");
3342
- for (let e = i.y + 1; e < a.y; e++) U(o, i.x, e, "│");
3343
- for (let e = i.y + 1; e < a.y; e++) U(o, a.x, e, "│");
3344
- U(o, i.x, i.y, "┌"), U(o, a.x, i.y, "┐"), U(o, i.x, a.y, "└"), U(o, a.x, a.y, "┘");
3328
+ for (let e = i.x + 1; e < a.x; e++) H(o, e, i.y, "─");
3329
+ for (let e = i.x + 1; e < a.x; e++) H(o, e, a.y, "─");
3330
+ for (let e = i.y + 1; e < a.y; e++) H(o, i.x, e, "│");
3331
+ for (let e = i.y + 1; e < a.y; e++) H(o, a.x, e, "│");
3332
+ H(o, i.x, i.y, "┌"), H(o, a.x, i.y, "┐"), H(o, i.x, a.y, "└"), H(o, a.x, a.y, "┘");
3345
3333
  }
3346
3334
  return o;
3347
3335
  }
3348
- function Lr(e, t) {
3336
+ function $r(e, t) {
3349
3337
  let n = e.maxX - e.minX, r = e.maxY - e.minY;
3350
3338
  if (n <= 0 || r <= 0) return [
3351
- V(0, 0),
3339
+ B(0, 0),
3352
3340
  {
3353
3341
  x: 0,
3354
3342
  y: 0
3355
3343
  },
3356
3344
  []
3357
3345
  ];
3358
- let i = V(n, r), a = [], o = Q(e.name);
3346
+ let i = B(n, r), a = [], o = Q(e.name);
3359
3347
  for (let e = 0; e < o.length; e++) {
3360
- let t = o[e], s = 1 + e, c = 1 + Math.ceil((n - 1 - B(t)) / 2);
3348
+ let t = o[e], s = 1 + e, c = 1 + Math.ceil((n - 1 - z(t)) / 2);
3361
3349
  c < 1 && (c = 1);
3362
- let l = Ce(t);
3363
- for (let e = 0; e < l.length; e++) c + e >= n || s >= r || (U(i, c + e, s, l[e]), a.push({
3350
+ let l = we(t);
3351
+ for (let e = 0; e < l.length; e++) c + e >= n || s >= r || (H(i, c + e, s, l[e]), a.push({
3364
3352
  x: c + e,
3365
3353
  y: s
3366
3354
  }));
@@ -3376,10 +3364,10 @@ function Lr(e, t) {
3376
3364
  }
3377
3365
  //#endregion
3378
3366
  //#region packages/ascii-renderer/src/draw-boxes.ts
3379
- function Rr(e, t) {
3380
- return zr(e, t);
3367
+ function ei(e, t) {
3368
+ return ti(e, t);
3381
3369
  }
3382
- function zr(e, t) {
3370
+ function ti(e, t) {
3383
3371
  let n = Z(e), r = t.config.useAscii, i = 0;
3384
3372
  for (let e = 0; e < 2; e++) i += t.columnWidth.get(n.x + e) ?? 0;
3385
3373
  let a = 0;
@@ -3390,7 +3378,7 @@ function zr(e, t) {
3390
3378
  }, s = {
3391
3379
  x: i,
3392
3380
  y: a
3393
- }, c = V(Math.max(o.x, s.x), Math.max(o.y, s.y)), l = cn(e.shape, r), u = e.shape === "state-end", d = r ? u ? "=" : "-" : u ? "═" : "─", f = r ? u ? "‖" : "|" : u ? "║" : "│", p = u ? r ? {
3381
+ }, c = B(Math.max(o.x, s.x), Math.max(o.y, s.y)), l = cn(e.shape, r), u = e.shape === "state-end", d = r ? u ? "=" : "-" : u ? "═" : "─", f = r ? u ? "‖" : "|" : u ? "║" : "│", p = u ? r ? {
3394
3382
  tl: "#",
3395
3383
  tr: "#",
3396
3384
  bl: "#",
@@ -3401,27 +3389,30 @@ function zr(e, t) {
3401
3389
  bl: "╚",
3402
3390
  br: "╝"
3403
3391
  } : l;
3404
- for (let e = o.x + 1; e < s.x; e++) U(c, e, o.y, d);
3405
- for (let e = o.x + 1; e < s.x; e++) U(c, e, s.y, d);
3406
- for (let e = o.y + 1; e < s.y; e++) U(c, o.x, e, f);
3407
- for (let e = o.y + 1; e < s.y; e++) U(c, s.x, e, f);
3408
- U(c, o.x, o.y, p.tl), U(c, s.x, o.y, p.tr), U(c, o.x, s.y, p.bl), U(c, s.x, s.y, p.br);
3392
+ for (let e = o.x + 1; e < s.x; e++) H(c, e, o.y, d);
3393
+ for (let e = o.x + 1; e < s.x; e++) H(c, e, s.y, d);
3394
+ for (let e = o.y + 1; e < s.y; e++) H(c, o.x, e, f);
3395
+ for (let e = o.y + 1; e < s.y; e++) H(c, s.x, e, f);
3396
+ if (H(c, o.x, o.y, p.tl), H(c, s.x, o.y, p.tr), H(c, o.x, s.y, p.bl), H(c, s.x, s.y, p.br), e.shape === "cylinder" && s.y - o.y >= 4) for (let e of [o.y + 1, s.y - 1]) {
3397
+ for (let t = o.x + 1; t < s.x; t++) H(c, t, e, d);
3398
+ H(c, o.x, e, f), H(c, s.x, e, f);
3399
+ }
3409
3400
  let m = e.displayLabel, h = Q(m), g = o.y + Math.floor(a / 2) - Math.floor((h.length - 1) / 2);
3410
3401
  for (let e = 0; e < h.length; e++) {
3411
- let t = h[e], n = B(t), r = o.x + Math.floor(i / 2) - Math.ceil(n / 2) + 1, a = Ce(t);
3412
- for (let t = 0; t < a.length; t++) U(c, r + t, g + e, a[t]);
3402
+ let t = h[e], n = z(t), r = o.x + Math.floor(i / 2) - Math.ceil(n / 2) + 1, a = we(t);
3403
+ for (let t = 0; t < a.length; t++) H(c, r + t, g + e, a[t]);
3413
3404
  }
3414
3405
  return c;
3415
3406
  }
3416
- function Br(e, t) {
3417
- return Rr(e, t);
3407
+ function ni(e, t) {
3408
+ return ei(e, t);
3418
3409
  }
3419
- function Vr(e) {
3410
+ function ri(e) {
3420
3411
  return /^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|]$/.test(e) ? "border" : "text";
3421
3412
  }
3422
- function Hr(e, t = 1) {
3413
+ function ii(e, t = 1) {
3423
3414
  let n = Math.max(0, t), r = 0;
3424
- for (let t of e) for (let e of t) r = Math.max(r, B(e));
3415
+ for (let t of e) for (let e of t) r = Math.max(r, z(e));
3425
3416
  let i = 0;
3426
3417
  for (let t of e) i += Math.max(t.length, 1);
3427
3418
  return {
@@ -3429,119 +3420,119 @@ function Hr(e, t = 1) {
3429
3420
  height: i + (e.length - 1) + 2
3430
3421
  };
3431
3422
  }
3432
- function Ur(e, t, n = 1) {
3433
- let r = Math.max(0, n), { width: i, height: a } = Hr(e, r), o = t ? "-" : "─", s = t ? "|" : "│", c = t ? "+" : "┌", l = t ? "+" : "┐", u = t ? "+" : "└", d = t ? "+" : "┘", f = t ? "+" : "├", p = t ? "+" : "┤", m = V(i - 1, a - 1);
3434
- U(m, 0, 0, c);
3435
- for (let e = 1; e < i - 1; e++) U(m, e, 0, o);
3436
- U(m, i - 1, 0, l), U(m, 0, a - 1, u);
3437
- for (let e = 1; e < i - 1; e++) U(m, e, a - 1, o);
3438
- U(m, i - 1, a - 1, d);
3439
- for (let e = 1; e < a - 1; e++) U(m, 0, e, s), U(m, i - 1, e, s);
3423
+ function ai(e, t, n = 1) {
3424
+ let r = Math.max(0, n), { width: i, height: a } = ii(e, r), o = t ? "-" : "─", s = t ? "|" : "│", c = t ? "+" : "┌", l = t ? "+" : "┐", u = t ? "+" : "└", d = t ? "+" : "┘", f = t ? "+" : "├", p = t ? "+" : "┤", m = B(i - 1, a - 1);
3425
+ H(m, 0, 0, c);
3426
+ for (let e = 1; e < i - 1; e++) H(m, e, 0, o);
3427
+ H(m, i - 1, 0, l), H(m, 0, a - 1, u);
3428
+ for (let e = 1; e < i - 1; e++) H(m, e, a - 1, o);
3429
+ H(m, i - 1, a - 1, d);
3430
+ for (let e = 1; e < a - 1; e++) H(m, 0, e, s), H(m, i - 1, e, s);
3440
3431
  let h = 1;
3441
3432
  for (let t = 0; t < e.length; t++) {
3442
3433
  let n = e[t], a = n.length > 0 ? n : [""];
3443
3434
  for (let e of a) {
3444
- let t = 1 + r, n = Ce(e);
3445
- for (let e = 0; e < n.length; e++) U(m, t + e, h, n[e]);
3435
+ let t = 1 + r, n = we(e);
3436
+ for (let e = 0; e < n.length; e++) H(m, t + e, h, n[e]);
3446
3437
  h++;
3447
3438
  }
3448
3439
  if (t < e.length - 1) {
3449
- U(m, 0, h, f);
3450
- for (let e = 1; e < i - 1; e++) U(m, e, h, o);
3451
- U(m, i - 1, h, p), h++;
3440
+ H(m, 0, h, f);
3441
+ for (let e = 1; e < i - 1; e++) H(m, e, h, o);
3442
+ H(m, i - 1, h, p), h++;
3452
3443
  }
3453
3444
  }
3454
3445
  return m;
3455
3446
  }
3456
3447
  //#endregion
3457
3448
  //#region packages/ascii-renderer/src/draw.ts
3458
- function Wr(e) {
3449
+ function oi(e) {
3459
3450
  function t(e) {
3460
3451
  return e.parent === null ? 0 : 1 + t(e.parent);
3461
3452
  }
3462
3453
  let n = [...e];
3463
3454
  return n.sort((e, n) => t(e) - t(n)), n;
3464
3455
  }
3465
- function Gr(e, t, n, r) {
3456
+ function si(e, t, n, r) {
3466
3457
  for (let i = 0; i < t.length; i++) for (let a = 0; a < (t[0]?.length ?? 0); a++) {
3467
3458
  let o = t[i]?.[a];
3468
3459
  if (o && o !== " ") {
3469
3460
  let t = i + n.x, o = a + n.y;
3470
- t >= 0 && o >= 0 && Ee(e, t, o, r);
3461
+ t >= 0 && o >= 0 && De(e, t, o, r);
3471
3462
  }
3472
3463
  }
3473
3464
  }
3474
- function Kr(e, t, n, r) {
3475
- for (let i of t) Gr(e, i, n, r);
3465
+ function ci(e, t, n, r) {
3466
+ for (let i of t) si(e, i, n, r);
3476
3467
  }
3477
- function qr(e, t, n) {
3468
+ function li(e, t, n) {
3478
3469
  let r = (e) => /^[┌┐└┘├┤┬┴┼│─╭╮╰╯+\-|.':]$/.test(e);
3479
3470
  for (let i = 0; i < t.length; i++) for (let a = 0; a < (t[0]?.length ?? 0); a++) {
3480
3471
  let o = t[i]?.[a];
3481
3472
  if (o && o !== " ") {
3482
3473
  let t = i + n.x, s = a + n.y;
3483
- t >= 0 && s >= 0 && Ee(e, t, s, r(o) ? "border" : "text");
3474
+ t >= 0 && s >= 0 && De(e, t, s, r(o) ? "border" : "text");
3484
3475
  }
3485
3476
  }
3486
3477
  }
3487
- function Jr(e) {
3478
+ function ui(e) {
3488
3479
  let t = e.config.useAscii, n = {
3489
3480
  x: 0,
3490
3481
  y: 0
3491
- }, r = Wr(e.subgraphs);
3482
+ }, r = oi(e.subgraphs);
3492
3483
  for (let n of r) {
3493
- let r = Ir(n, e), i = {
3484
+ let r = Qr(n, e), i = {
3494
3485
  x: n.minX,
3495
3486
  y: n.minY
3496
3487
  };
3497
- e.canvas = Pe(e.canvas, i, t, r), Gr(e.roleCanvas, r, i, "border");
3488
+ e.canvas = Pe(e.canvas, i, t, r), si(e.roleCanvas, r, i, "border");
3498
3489
  }
3499
- for (let n of e.nodes) !n.drawn && n.drawingCoord && n.drawing && (e.canvas = Pe(e.canvas, n.drawingCoord, t, n.drawing), qr(e.roleCanvas, n.drawing, n.drawingCoord), n.drawn = !0);
3490
+ for (let n of e.nodes) !n.drawn && n.drawingCoord && n.drawing && (e.canvas = Pe(e.canvas, n.drawingCoord, t, n.drawing), li(e.roleCanvas, n.drawing, n.drawingCoord), n.drawn = !0);
3500
3491
  let i = [], a = [], o = [], s = [], c = [], l = [], u = [], d = /* @__PURE__ */ new Set();
3501
3492
  for (let t of e.edges) if (t.bundle && t.pathToJunction) {
3502
- let n = t.bundle, [r, f, , , p, m] = Or(e, t, n);
3493
+ let n = t.bundle, [r, f, , , p, m] = Wr(e, t, n);
3503
3494
  if (i.push(r), a.push(p), c.push(f), l.push(m), n.type === "fan-in" && t.hasArrowStart) {
3504
- let n = Pr(e, t);
3495
+ let n = Xr(e, t);
3505
3496
  s.push(n);
3506
3497
  }
3507
3498
  if (!d.has(n)) {
3508
3499
  d.add(n);
3509
- let [t, r] = kr(e, n);
3500
+ let [t, r] = Gr(e, n);
3510
3501
  if (i.push(t), a.push(r), n.type === "fan-in") {
3511
- let t = Ar(e, n);
3502
+ let t = Kr(e, n);
3512
3503
  o.push(t);
3513
3504
  }
3514
3505
  if (n.type === "fan-out" && n.edges.every((e) => e.hasArrowStart)) {
3515
- let t = Nr(e, n);
3506
+ let t = Yr(e, n);
3516
3507
  s.push(t);
3517
3508
  }
3518
- let c = Fr(e, n);
3509
+ let c = Zr(e, n);
3519
3510
  u.push(c);
3520
3511
  }
3521
3512
  if (n.type === "fan-out" && t.hasArrowEnd) {
3522
- let n = jr(e, t);
3513
+ let n = qr(e, t);
3523
3514
  o.push(n);
3524
3515
  }
3525
3516
  } else {
3526
- let [n, r, u, d, f, p] = pr(e, t);
3517
+ let [n, r, u, d, f, p] = kr(e, t);
3527
3518
  i.push(n), a.push(f), o.push(u), s.push(d), c.push(r), l.push(p);
3528
3519
  }
3529
3520
  let f = Ne(i);
3530
- e.canvas = Pe(e.canvas, n, t, ...f), Kr(e.roleCanvas, f, n, "line"), e.canvas = Pe(e.canvas, n, t, ...a), Kr(e.roleCanvas, a, n, "corner"), e.canvas = Pe(e.canvas, n, t, ...u), Kr(e.roleCanvas, u, n, "junction"), e.canvas = Pe(e.canvas, n, t, ...o), Kr(e.roleCanvas, o, n, "arrow"), e.canvas = Pe(e.canvas, n, t, ...c), Kr(e.roleCanvas, c, n, "junction"), e.canvas = Pe(e.canvas, n, t, ...s), Kr(e.roleCanvas, s, n, "arrow"), e.canvas = Pe(e.canvas, n, t, ...l), Kr(e.roleCanvas, l, n, "text");
3521
+ e.canvas = Pe(e.canvas, n, t, ...f), ci(e.roleCanvas, f, n, "line"), e.canvas = Pe(e.canvas, n, t, ...a), ci(e.roleCanvas, a, n, "corner"), e.canvas = Pe(e.canvas, n, t, ...u), ci(e.roleCanvas, u, n, "junction"), e.canvas = Pe(e.canvas, n, t, ...o), ci(e.roleCanvas, o, n, "arrow"), e.canvas = Pe(e.canvas, n, t, ...c), ci(e.roleCanvas, c, n, "junction"), e.canvas = Pe(e.canvas, n, t, ...s), ci(e.roleCanvas, s, n, "arrow"), e.canvas = Pe(e.canvas, n, t, ...l), ci(e.roleCanvas, l, n, "text");
3531
3522
  for (let n of e.subgraphs) {
3532
3523
  if (n.nodes.length === 0) continue;
3533
- let [r, i, a] = Lr(n, e);
3534
- e.canvas = Pe(e.canvas, i, t, r), Gr(e.roleCanvas, r, i, "text");
3524
+ let [r, i, a] = $r(n, e);
3525
+ e.canvas = Pe(e.canvas, i, t, r), si(e.roleCanvas, r, i, "text");
3535
3526
  for (let { x: t, y: n } of a) {
3536
3527
  let a = r[t]?.[n];
3537
- a === " " && (U(e.canvas, t + i.x, n + i.y, a), Ee(e.roleCanvas, t + i.x, n + i.y, "text"));
3528
+ a === " " && (H(e.canvas, t + i.x, n + i.y, a), De(e.roleCanvas, t + i.x, n + i.y, "text"));
3538
3529
  }
3539
3530
  }
3540
3531
  return e.canvas;
3541
3532
  }
3542
3533
  //#endregion
3543
3534
  //#region packages/ascii-renderer/src/lane-search.ts
3544
- function Yr(e, t, n, r) {
3535
+ function di(e, t, n, r) {
3545
3536
  if (r(e)) return e;
3546
3537
  let i = Math.max(e - t, n - e);
3547
3538
  for (let a = 1; a <= i; a++) {
@@ -3553,14 +3544,15 @@ function Yr(e, t, n, r) {
3553
3544
  }
3554
3545
  //#endregion
3555
3546
  //#region packages/ascii-renderer/src/er-diagram.ts
3556
- function Xr(e) {
3557
- return `${e.keys.length > 0 ? e.keys.join(",") + " " : " "}${e.type} ${e.name}`;
3547
+ function fi(e) {
3548
+ let t = e.keys.length > 0 ? " " + e.keys.join(",") : "";
3549
+ return `${e.type} ${e.name}${t}`;
3558
3550
  }
3559
- function Zr(e) {
3560
- let t = Q(e.label), n = e.attributes.map(Xr);
3551
+ function pi(e) {
3552
+ let t = Q(e.label), n = e.attributes.map(fi);
3561
3553
  return n.length === 0 ? [t] : [t, n];
3562
3554
  }
3563
- function Qr(e, t, n = !1, r = !1) {
3555
+ function mi(e, t, n = !1, r = !1) {
3564
3556
  if (t) switch (e) {
3565
3557
  case "one": return r ? "+" : "|";
3566
3558
  case "zero-one": return n ? "o|" : "|o";
@@ -3574,7 +3566,7 @@ function Qr(e, t, n = !1, r = !1) {
3574
3566
  case "zero-many": return n ? "○╟" : "╢○";
3575
3567
  }
3576
3568
  }
3577
- function $r(e) {
3569
+ function hi(e) {
3578
3570
  let t = /* @__PURE__ */ new Set(), n = [], r = /* @__PURE__ */ new Map();
3579
3571
  for (let t of e.entities) r.set(t.id, /* @__PURE__ */ new Set());
3580
3572
  for (let t of e.relationships) r.get(t.entity1)?.add(t.entity2), r.get(t.entity2)?.add(t.entity1);
@@ -3594,14 +3586,14 @@ function $r(e) {
3594
3586
  }
3595
3587
  return n;
3596
3588
  }
3597
- function ei(e, t, n) {
3589
+ function gi(e, t, n) {
3598
3590
  let r = e.get(t);
3599
3591
  if (r === void 0)
3600
3592
  /* v8 ignore next */
3601
3593
  throw Error(`ER diagram layout: missing ${n} for entity "${t}"`);
3602
3594
  return r;
3603
3595
  }
3604
- function ti(e, t, n, r) {
3596
+ function _i(e, t, n, r) {
3605
3597
  let i = u(e), a = C(i);
3606
3598
  if (a.entities.length === 0) return "";
3607
3599
  let o = t.useAscii, s = vt(t.paddingX, 5, 6, 6), c = vt(t.paddingY, 5, 4, 2), l = vt(t.paddingY, 5, 2, 1), d = Math.max(...[
@@ -3609,12 +3601,12 @@ function ti(e, t, n, r) {
3609
3601
  "zero-one",
3610
3602
  "many",
3611
3603
  "zero-many"
3612
- ].flatMap((e) => [Qr(e, o, !1).length, Qr(e, o, !0).length])), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
3604
+ ].flatMap((e) => [mi(e, o, !1).length, mi(e, o, !0).length])), f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
3613
3605
  for (let e of a.entities) {
3614
3606
  h.set(e.id, e);
3615
- let n = Zr(e);
3607
+ let n = pi(e);
3616
3608
  f.set(e.id, n);
3617
- let { width: r, height: i } = Hr(n, t.boxBorderPadding);
3609
+ let { width: r, height: i } = ii(n, t.boxBorderPadding);
3618
3610
  p.set(e.id, r), m.set(e.id, i);
3619
3611
  }
3620
3612
  let g = /* @__PURE__ */ new Map();
@@ -3623,14 +3615,14 @@ function ti(e, t, n, r) {
3623
3615
  let t = [e.entity1, e.entity2].sort().join("|"), n = an(e.label);
3624
3616
  g.set(t, Math.max(g.get(t) ?? 0, n));
3625
3617
  }
3626
- let _ = $r(a), v = /* @__PURE__ */ new Map(), y = 0;
3618
+ let _ = hi(a), v = /* @__PURE__ */ new Map(), y = 0;
3627
3619
  for (let e of _) {
3628
3620
  let t = a.entities.filter((t) => e.has(t.id)), n = Math.max(2, Math.ceil(Math.sqrt(t.length))), r = 0, i = 0, o = 0;
3629
3621
  for (let e = 0; e < t.length; e++) {
3630
- let a = t[e], l = ei(p, a.id, "box width"), u = ei(m, a.id, "box height");
3622
+ let a = t[e], l = gi(p, a.id, "box width"), u = gi(m, a.id, "box height");
3631
3623
  o >= n && (y += i + c, r = 0, i = 0, o = 0), v.set(a.id, {
3632
3624
  entity: a,
3633
- sections: ei(f, a.id, "sections"),
3625
+ sections: gi(f, a.id, "sections"),
3634
3626
  x: r,
3635
3627
  y,
3636
3628
  width: l,
@@ -3648,9 +3640,9 @@ function ti(e, t, n, r) {
3648
3640
  let b = 0, x = 0;
3649
3641
  for (let e of v.values()) b = Math.max(b, e.x + e.width), x = Math.max(x, e.y + e.height);
3650
3642
  b += 4, x += 2;
3651
- let S = V(b - 1, x - 1), w = we(b - 1, x - 1);
3643
+ let S = B(b - 1, x - 1), w = Te(b - 1, x - 1);
3652
3644
  function ee(e, t, n, r) {
3653
- U(S, e, t, n, {
3645
+ H(S, e, t, n, {
3654
3646
  role: r,
3655
3647
  roleCanvas: w
3656
3648
  });
@@ -3666,79 +3658,85 @@ function ti(e, t, n, r) {
3666
3658
  }
3667
3659
  return !0;
3668
3660
  }
3669
- function D(e, t, n, r, i) {
3661
+ function te(e, t, n, r, i, a) {
3670
3662
  for (let a = 0; a < e.length; a++) {
3671
3663
  let e = t + a;
3672
- if (!(e < r || e > i) && (T(e, n) || w[e]?.[n] === "arrow" || O.has(`${e},${n}`))) return !1;
3664
+ if (!(e < r || e > i) && (T(e, n) || w[e]?.[n] === "arrow" || D.has(`${e},${n}`))) return !1;
3673
3665
  }
3666
+ if (!a) return !0;
3667
+ for (let a = t - 2; a <= t + e.length; a++) if (!(a < r - 2 || a > i + 1) && w[a]?.[n] === "line" && !ue.has(`${a},${n}`)) return !1;
3674
3668
  return !0;
3675
3669
  }
3676
3670
  for (let e of v.values()) {
3677
- let n = Ur(e.sections, o, t.boxBorderPadding);
3671
+ let n = ai(e.sections, o, t.boxBorderPadding);
3678
3672
  for (let t = 0; t < n.length; t++) for (let r = 0; r < n[0].length; r++) {
3679
3673
  let i = n[t][r];
3680
3674
  if (i !== " ") {
3681
3675
  let n = e.x + t, a = e.y + r;
3682
- n < b && a < x && ee(n, a, i, Vr(i));
3676
+ n < b && a < x && ee(n, a, i, ri(i));
3683
3677
  }
3684
3678
  }
3685
3679
  }
3686
- let O = /* @__PURE__ */ new Set();
3687
- for (let e of v.values()) for (let t = 0; t < e.height; t++) for (let n = 0; n < e.width; n++) O.add(`${e.x + n},${e.y + t}`);
3688
- function k(e, t, n, r) {
3689
- O.has(`${e},${t}`) || (r === "text" || w[e]?.[t] !== "text") && ee(e, t, n, r);
3690
- }
3691
- function te(e, t, n, r) {
3692
- w[e - 1]?.[t] !== "text" && w[e + 1]?.[t] !== "text" && k(e, t, n, r);
3680
+ let D = /* @__PURE__ */ new Set();
3681
+ for (let e of v.values()) for (let t = 0; t < e.height; t++) for (let n = 0; n < e.width; n++) D.add(`${e.x + n},${e.y + t}`);
3682
+ function O(e, t, n, r) {
3683
+ D.has(`${e},${t}`) || (r === "text" || w[e]?.[t] !== "text") && (se(n) !== "dashed" || se(S[e]?.[t]) !== "solid") && (ee(e, t, n, r), r === "line" && ue.add(`${e},${t}`));
3693
3684
  }
3694
3685
  function ne(e, t, n, r) {
3686
+ w[e - 1]?.[t] !== "text" && w[e + 1]?.[t] !== "text" && O(e, t, n, r);
3687
+ }
3688
+ function re(e, t, n, r) {
3695
3689
  for (let i = n; i <= r; i++) for (let n = e; n <= t; n++) {
3696
3690
  let e = S[n]?.[i];
3697
3691
  if (e !== void 0 && e !== " ") return !1;
3698
3692
  }
3699
3693
  return !0;
3700
3694
  }
3701
- let A = [];
3702
- function j(e, t, n) {
3703
- for (let r of A) if (Math.abs(r.x - e) === 1 && t <= r.yEnd && n >= r.yStart) return !0;
3695
+ let k = [];
3696
+ function A(e, t, n) {
3697
+ for (let r of k) if (Math.abs(r.x - e) === 1 && t <= r.yEnd && n >= r.yStart) return !0;
3704
3698
  return !1;
3705
3699
  }
3706
- function re(e, t, n) {
3707
- for (let r of A) if (!(Math.abs(r.x - e) > 1) && t <= r.yEnd && n >= r.yStart) return !0;
3700
+ function ie(e, t, n) {
3701
+ for (let r of k) if (!(Math.abs(r.x - e) > 1) && t <= r.yEnd && n >= r.yStart) return !0;
3708
3702
  return !1;
3709
3703
  }
3710
- function ie(e, t, n) {
3711
- A.push({
3704
+ function ae(e, t, n) {
3705
+ k.push({
3712
3706
  x: e,
3713
3707
  yStart: t,
3714
3708
  yEnd: n
3715
3709
  });
3716
3710
  }
3717
- let ae = o ? "-" : "─", M = o ? "|" : "│", N = o ? "." : "╌", P = o ? ":" : "┊";
3718
- function oe(e, t) {
3711
+ let oe = o ? "-" : "─", j = o ? "|" : "│", M = o ? "." : "╌", N = o ? ":" : "┊";
3712
+ function se(e) {
3713
+ if (e === oe || e === j) return "solid";
3714
+ if (e === M || e === N) return "dashed";
3715
+ }
3716
+ function P(e, t) {
3719
3717
  return o ? "+" : e === "down" ? t === "right" ? "┌" : "┐" : t === "right" ? "└" : "┘";
3720
3718
  }
3721
3719
  function F(e, t, n, r) {
3722
- k(e, t, oe(n, r), "line");
3720
+ O(e, t, P(n, r), "line");
3723
3721
  }
3724
- let se = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map();
3722
+ let ce = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
3725
3723
  for (let e of a.relationships) {
3726
3724
  let t = v.get(e.entity1), n = v.get(e.entity2);
3727
3725
  if (!t || !n) continue;
3728
3726
  let r = t.y + Math.floor(t.height / 2), i = n.y + Math.floor(n.height / 2);
3729
3727
  if (Math.abs(r - i) < Math.max(t.height, n.height)) continue;
3730
- let [a, o] = r < i ? [t, n] : [n, t], s = a.x + Math.floor(a.width / 2), c = o.x + Math.floor(o.width / 2), l = ce.get(a.entity.id);
3731
- l || (l = [], ce.set(a.entity.id, l)), l.push({
3728
+ let [a, o] = r < i ? [t, n] : [n, t], s = a.x + Math.floor(a.width / 2), c = o.x + Math.floor(o.width / 2), l = I.get(a.entity.id);
3729
+ l || (l = [], I.set(a.entity.id, l)), l.push({
3732
3730
  rel: e,
3733
3731
  otherCenterX: c
3734
3732
  });
3735
- let u = se.get(o.entity.id);
3736
- u || (u = [], se.set(o.entity.id, u)), u.push({
3733
+ let u = ce.get(o.entity.id);
3734
+ u || (u = [], ce.set(o.entity.id, u)), u.push({
3737
3735
  rel: e,
3738
3736
  otherCenterX: s
3739
3737
  });
3740
3738
  }
3741
- function I(e, t, n) {
3739
+ function le(e, t, n) {
3742
3740
  let r = n.get(e.entity.id), i = e.x + Math.floor(e.width / 2);
3743
3741
  if (!r || r.length <= 1) return i;
3744
3742
  let a = [...r].sort((e, t) => e.otherCenterX - t.otherCenterX), o = a.findIndex((e) => e.rel === t);
@@ -3746,113 +3744,118 @@ function ti(e, t, n, r) {
3746
3744
  let s = Math.min(1, Math.floor((e.width - 1) / 2)), c = Math.max(0, e.width - 1 - s * 2), l = a.length > 1 ? c / (a.length - 1) : 0;
3747
3745
  return e.x + s + Math.round(o * l);
3748
3746
  }
3747
+ let ue = /* @__PURE__ */ new Set();
3749
3748
  for (let e of a.relationships) {
3749
+ ue = /* @__PURE__ */ new Set();
3750
3750
  let t = v.get(e.entity1), n = v.get(e.entity2);
3751
3751
  if (!t || !n) continue;
3752
- let r = e.identifying ? ae : N, i = e.identifying ? M : P, a = t.x + Math.floor(t.width / 2), s = t.y + Math.floor(t.height / 2), l = n.x + Math.floor(n.width / 2), u = n.y + Math.floor(n.height / 2);
3752
+ let r = e.identifying ? oe : M, i = e.identifying ? j : N, a = t.x + Math.floor(t.width / 2), s = t.y + Math.floor(t.height / 2), l = n.x + Math.floor(n.width / 2), u = n.y + Math.floor(n.height / 2);
3753
3753
  if (Math.abs(s - u) < Math.max(t.height, n.height)) {
3754
3754
  let [s, u] = a < l ? [t, n] : [n, t], [f, p] = a < l ? [e.cardinality1, e.cardinality2] : [e.cardinality2, e.cardinality1], m = s.x + s.width, h = u.x - 1, g = s.y + Math.floor(s.height / 2), _;
3755
3755
  for (let e of v.values()) e !== s && e !== u && e.y === s.y && e.x < h + 1 && e.x + e.width > m && (_ = Math.max(_ ?? 0, e.y + e.height));
3756
- let y = h - m + 1, b = +(y >= d + 1), x = Qr(f, o, !1), C = Qr(p, o, !0), ee = +(y >= 3 && x[0] === M), T = +(y >= 3 && C[C.length - 1] === M), D = m + ee, O = h - T, A;
3756
+ let y = h - m + 1, b = +(y >= d + 1), x = mi(f, o, !1), C = mi(p, o, !0), ee = +(y >= 3 && x[0] === j), T = +(y >= 3 && C[C.length - 1] === j), te = m + ee, D = h - T, k;
3757
3757
  if (_ === void 0) {
3758
- for (let e = m; e <= h; e++) te(e, g, r, "line");
3759
- if (A = g + 1, e.label) {
3758
+ for (let e = m; e <= h; e++) ne(e, g, r, "line");
3759
+ if (k = g + 1, e.label) {
3760
3760
  let t = m + b, n = h - b, r = Q(e.label).length, i = g + 1 + Math.max(c - 1, 1);
3761
- for (; A < i && !ne(t, n, A, A + r - 1);) A++;
3761
+ for (; k < i && !re(t, n, k, k + r - 1);) k++;
3762
3762
  }
3763
3763
  } else {
3764
3764
  let t = Math.max(s.y + s.height, u.y + u.height, _), n = e.label ? Q(e.label).length : 0, a = t + 1, o = t + Math.max(c * 3, 4);
3765
- for (; a < o && !ne(m, h, a, a + n);) a++;
3766
- Oe(S, h + 1, a + n + 1), Te(w, h + 1, a + n + 1);
3767
- for (let e = g; e <= a; e++) k(m, e, i, "line"), k(h, e, i, "line");
3768
- for (let e = m; e <= h; e++) te(e, a, r, "line");
3769
- m !== h && (F(m, a, "up", "right"), F(h, a, "up", "left")), A = a + 1;
3765
+ for (; a < o && !re(m, h, a, a + n);) a++;
3766
+ ke(S, h + 1, a + n + 1), Ee(w, h + 1, a + n + 1);
3767
+ for (let e = g; e <= a; e++) O(m, e, i, "line"), O(h, e, i, "line");
3768
+ for (let e = m; e <= h; e++) ne(e, a, r, "line");
3769
+ m !== h && (F(m, a, "up", "right"), F(h, a, "up", "left")), k = a + 1;
3770
3770
  }
3771
- for (let e = 0; e < x.length; e++) k(D + e, g, x[e], "arrow");
3772
- for (let e = 0; e < C.length; e++) k(O - C.length + 1 + e, g, C[e], "arrow");
3771
+ for (let e = 0; e < x.length; e++) O(te + e, g, x[e], "arrow");
3772
+ for (let e = 0; e < C.length; e++) O(D - C.length + 1 + e, g, C[e], "arrow");
3773
3773
  if (e.label) {
3774
3774
  let t = Q(e.label), n = Math.floor((m + h) / 2), r = m + b, i = h - b;
3775
3775
  for (let e = 0; e < t.length; e++) {
3776
- let a = t[e], o = Ce(a), s = Math.max(r, n - Math.floor(o.length / 2)), c = A + e;
3777
- if (Oe(S, Math.max(s + o.length, 1), Math.max(c + 1, 1)), Te(w, Math.max(s + o.length, 1), Math.max(c + 1, 1)), E(o, s, c, r, i)) for (let e = 0; e < o.length; e++) {
3776
+ let a = t[e], o = we(a), s = Math.max(r, n - Math.floor(o.length / 2)), c = k + e;
3777
+ if (ke(S, Math.max(s + o.length, 1), Math.max(c + 1, 1)), Ee(w, Math.max(s + o.length, 1), Math.max(c + 1, 1)), E(o, s, c, r, i)) for (let e = 0; e < o.length; e++) {
3778
3778
  let t = s + e;
3779
- t >= r && t <= i && k(t, c, o[e], "text");
3779
+ t >= r && t <= i && O(t, c, o[e], "text");
3780
3780
  }
3781
3781
  }
3782
3782
  }
3783
3783
  } else {
3784
- let [a, c] = s < u ? [t, n] : [n, t], [l, d] = s < u ? [e.cardinality1, e.cardinality2] : [e.cardinality2, e.cardinality1], f = a.y + a.height, p = c.y - 1, m = I(a, e, ce), h = I(c, e, se);
3784
+ let [a, c] = s < u ? [t, n] : [n, t], [l, d] = s < u ? [e.cardinality1, e.cardinality2] : [e.cardinality2, e.cardinality1], f = a.y + a.height, p = c.y - 1, m = le(a, e, I), h = le(c, e, ce);
3785
3785
  function g(e, t, n) {
3786
- for (let r = t; r <= n; r++) if (O.has(`${e},${r}`)) return !1;
3786
+ for (let r = t; r <= n; r++) if (D.has(`${e},${r}`)) return !1;
3787
3787
  return !0;
3788
3788
  }
3789
3789
  let _ = f, y = p, b = Math.max(...[...v.values()].filter((e) => e.y === a.y).map((e) => e.y + e.height)), x = c.y, C = Math.max(f, b + 1), T = Math.min(p, x - 1);
3790
3790
  function E(e, t, n) {
3791
3791
  let r = Math.floor(C <= T ? (C + T) / 2 : (f + p) / 2);
3792
3792
  if (C > T) return r;
3793
- for (let r = C; r <= T; r++) if (ne(e, t, r, r + n)) return r;
3793
+ for (let r = C; r <= T; r++) if (re(e, t, r, r + n)) return r;
3794
3794
  return r;
3795
3795
  }
3796
- let A = m !== h, ae = Math.min(m, h), M = Math.max(m, h), N = A ? E(ae, M, 0) : p, P = A ? N - 1 : p, oe = !g(m, C, T) || !g(h, C, T) || j(m, f, A ? N : p) || A && j(h, N, p), L = m;
3797
- if (oe) {
3796
+ let k = m !== h, oe = Math.min(m, h), j = Math.max(m, h), M = k ? E(oe, j, 0) : p, N = k ? M - 1 : p, se = !g(m, C, T) || !g(h, C, T) || A(m, f, k ? M : p) || k && A(h, M, p), P = m;
3797
+ if (se) {
3798
3798
  let e = S.length, t;
3799
3799
  for (let n = 0; n <= e; n++) {
3800
3800
  let e = m + n;
3801
- if (g(e, f, p) && !re(e, f, p)) {
3801
+ if (g(e, f, p) && !ie(e, f, p)) {
3802
3802
  t = e;
3803
3803
  break;
3804
3804
  }
3805
3805
  let r = m - n;
3806
- if (n > 0 && g(r, f, p) && !re(r, f, p)) {
3806
+ if (n > 0 && g(r, f, p) && !ie(r, f, p)) {
3807
3807
  t = r;
3808
3808
  break;
3809
3809
  }
3810
3810
  }
3811
- L = t ?? m;
3812
- for (let e = f; e <= _; e++) k(m, e, i, "line");
3813
- for (let e = Math.min(m, L); e <= Math.max(m, L); e++) te(e, _, r, "line");
3814
- for (let e = _; e <= y; e++) k(L, e, i, "line");
3815
- for (let e = Math.min(L, h); e <= Math.max(L, h); e++) te(e, y, r, "line");
3816
- for (let e = y; e <= p; e++) k(h, e, i, "line");
3817
- if (m !== L) {
3818
- let e = L > m ? "right" : "left", t = e === "right" ? "left" : "right";
3819
- F(m, _, "up", e), F(L, _, "down", t);
3811
+ P = t ?? m;
3812
+ for (let e = f; e <= _; e++) O(m, e, i, "line");
3813
+ for (let e = Math.min(m, P); e <= Math.max(m, P); e++) ne(e, _, r, "line");
3814
+ for (let e = _; e <= y; e++) O(P, e, i, "line");
3815
+ for (let e = Math.min(P, h); e <= Math.max(P, h); e++) ne(e, y, r, "line");
3816
+ for (let e = y; e <= p; e++) O(h, e, i, "line");
3817
+ if (m !== P) {
3818
+ let e = P > m ? "right" : "left", t = e === "right" ? "left" : "right";
3819
+ F(m, _, "up", e), F(P, _, "down", t);
3820
3820
  }
3821
- if (L !== h) {
3822
- let e = h > L ? "right" : "left", t = e === "right" ? "left" : "right";
3823
- F(L, y, "up", e), F(h, y, "down", t);
3821
+ if (P !== h) {
3822
+ let e = h > P ? "right" : "left", t = e === "right" ? "left" : "right";
3823
+ F(P, y, "up", e), F(h, y, "down", t);
3824
3824
  }
3825
- ie(L, _, y);
3825
+ ae(P, _, y);
3826
3826
  } else {
3827
- for (let e = f; e <= P; e++) k(m, e, i, "line");
3828
- if (ie(m, f, A ? N : P), A) {
3829
- for (let e = ae; e <= M; e++) te(e, N, r, "line");
3830
- for (let e = N + 1; e <= p; e++) k(h, e, i, "line");
3831
- ie(h, N, p);
3827
+ for (let e = f; e <= N; e++) O(m, e, i, "line");
3828
+ if (ae(m, f, k ? M : N), k) {
3829
+ for (let e = oe; e <= j; e++) ne(e, M, r, "line");
3830
+ for (let e = M + 1; e <= p; e++) O(h, e, i, "line");
3831
+ ae(h, M, p);
3832
3832
  let e = h > m ? "right" : "left", t = e === "right" ? "left" : "right";
3833
- F(m, N, "up", e), F(h, N, "down", t), L = h;
3833
+ F(m, M, "up", e), F(h, M, "down", t), P = h;
3834
3834
  }
3835
3835
  }
3836
- let le = Qr(l, o, !1, !0);
3837
- for (let e = 0; e < le.length; e++) k(m - Math.floor(le.length / 2) + e, _, le[e], "arrow");
3838
- let R = m === h ? m : h, ue = Qr(d, o, !0, !0);
3839
- for (let e = 0; e < ue.length; e++) k(R - Math.floor(ue.length / 2) + e, y, ue[e], "arrow");
3836
+ let ue = mi(l, o, !1, !0);
3837
+ for (let e = 0; e < ue.length; e++) O(m - Math.floor(ue.length / 2) + e, _, ue[e], "arrow");
3838
+ let de = m === h ? m : h, L = mi(d, o, !0, !0);
3839
+ for (let e = 0; e < L.length; e++) O(de - Math.floor(L.length / 2) + e, y, L[e], "arrow");
3840
3840
  if (e.label) {
3841
- let t = Q(e.label), n = Math.max(le.length - 1 - Math.floor(le.length / 2), ue.length - 1 - Math.floor(ue.length / 2)), r = L + n + 2, i = t.map((e) => Ce(e)), a = r + Math.max(...i.map((e) => e.length)) - 1, o = t.length, s = Math.floor((f + p) / 2) - Math.floor((o - 1) / 2);
3842
- a >= 0 && (Oe(S, a + 1, p + 1), Te(w, a + 1, p + 1));
3841
+ let t = Q(e.label), n = Math.max(ue.length - 1 - Math.floor(ue.length / 2), L.length - 1 - Math.floor(L.length / 2)), r = P + n + 2, i = t.map((e) => we(e)), a = r + Math.max(...i.map((e) => e.length)) - 1, o = t.length, s = Math.floor((f + p) / 2) - Math.floor((o - 1) / 2);
3842
+ a >= 0 && (ke(S, a + 1, p + 1), Ee(w, a + 1, p + 1));
3843
3843
  let c = null;
3844
- for (let e = 0; e <= p - f && c === null; e++) {
3845
- let t = e === 0 ? [s] : [s + e, s - e];
3846
- for (let e of t) if (!(e < f || e + o - 1 > p) && i.every((t, n) => D(t, r, e + n, 0, a))) {
3847
- c = e;
3848
- break;
3844
+ for (let e of [!0, !1]) {
3845
+ for (let t = 0; t <= p - f && c === null; t++) {
3846
+ let n = t === 0 ? [s] : [s + t, s - t];
3847
+ for (let t of n) if (!(t < f || t + o - 1 > p) && i.every((n, i) => te(n, r, t + i, 0, a, e))) {
3848
+ c = t;
3849
+ break;
3850
+ }
3849
3851
  }
3852
+ if (c !== null) break;
3850
3853
  }
3851
3854
  if (c !== null) for (let e = 0; e < o; e++) {
3852
3855
  let t = i[e], n = c + e;
3853
3856
  for (let e = 0; e < t.length; e++) {
3854
3857
  let i = r + e;
3855
- i >= 0 && k(i, n, t[e], "text");
3858
+ i >= 0 && O(i, n, t[e], "text");
3856
3859
  }
3857
3860
  w[r - 1]?.[n] === "line" && ee(r - 1, n, " ", "line");
3858
3861
  let a = r + t.length;
@@ -3869,168 +3872,168 @@ function ti(e, t, n, r) {
3869
3872
  }
3870
3873
  //#endregion
3871
3874
  //#region packages/ascii-renderer/src/sequence.ts
3872
- var ni = 4, ri = [
3875
+ var vi = 4, yi = [
3873
3876
  "O",
3874
3877
  "/|\\",
3875
3878
  "/ \\"
3876
- ], ii = 3, ai = 4;
3877
- function oi(e) {
3878
- return e.seqNumber === void 0 ? ni : ni + String(e.seqNumber).length;
3879
+ ], bi = 3, xi = 4;
3880
+ function Si(e) {
3881
+ return e.seqNumber === void 0 ? vi : vi + String(e.seqNumber).length;
3879
3882
  }
3880
- function si(e, t, n, r) {
3883
+ function Ci(e, t, n, r) {
3881
3884
  let i = u(e), a = ee(i);
3882
3885
  if (a.actors.length === 0) return "";
3883
- let o = t.useAscii, s = o ? "-" : "─", c = o ? "|" : "│", l = o ? "+" : "┌", d = o ? "+" : "┐", f = o ? "+" : "└", p = o ? "+" : "┘", m = o ? "+" : "┬", h = o ? "+" : "┴", g = o ? "+" : "├", _ = o ? "+" : "┤", v = /* @__PURE__ */ new Map();
3884
- a.actors.forEach((e, t) => v.set(e.id, t));
3885
- function y(e) {
3886
- let t = v.get(e);
3886
+ let o = t.useAscii, s = o ? "-" : "─", c = o ? "|" : "│", l = o ? "+" : "┌", d = o ? "+" : "┐", f = o ? "+" : "└", p = o ? "+" : "┘", m = o ? "+" : "┬", h = o ? "+" : "┴", g = o ? "+" : "├", _ = o ? "+" : "┤", v = o ? "‖" : "║", y = /* @__PURE__ */ new Map();
3887
+ a.actors.forEach((e, t) => y.set(e.id, t));
3888
+ function b(e) {
3889
+ let t = y.get(e);
3887
3890
  if (t === void 0)
3888
3891
  /* v8 ignore next */
3889
3892
  throw Error(`Sequence diagram: unknown actor "${e}"`);
3890
3893
  return t;
3891
3894
  }
3892
- function b(e) {
3895
+ function x(e) {
3893
3896
  let t = an(e.label ? `${e.type} [${e.label}]` : e.type);
3894
3897
  for (let n of e.dividers) n.label && (t = Math.max(t, an(`[${n.label}]`)));
3895
3898
  return t;
3896
3899
  }
3897
- let x = Math.max(0, t.boxBorderPadding), S = (e) => Math.max(an(e.label), e.type === "actor" ? ii : 0), C = (e) => on(e.label) + (e.type === "actor" ? ri.length : 0), w = a.actors.map((e) => S(e) + 2 * x + 2), T = w.map((e) => Math.ceil(e / 2)), E = a.actors.map((e) => C(e) + 2), D = Math.max(...E, 3), O = (e, t) => t - Math.floor(w[e] / 2), k = Math.floor((D - 1) / 2), te = D - 1 - k, ne = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
3900
+ let S = Math.max(0, t.boxBorderPadding), C = (e) => Math.max(an(e.label), e.type === "actor" ? bi : 0), w = (e) => on(e.label) + (e.type === "actor" ? yi.length : 0), T = a.actors.map((e) => C(e) + 2 * S + 2), E = T.map((e) => Math.ceil(e / 2)), te = a.actors.map((e) => w(e) + 2), D = Math.max(...te, 3), O = (e, t) => t - Math.floor(T[e] / 2), ne = Math.floor((D - 1) / 2), re = D - 1 - ne, k = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
3898
3901
  a.actors.forEach((e, t) => {
3899
- e.createdAt !== void 0 && ne.set(e.createdAt, t), e.destroyedAt !== void 0 && A.set(e.destroyedAt, t);
3902
+ e.createdAt !== void 0 && k.set(e.createdAt, t), e.destroyedAt !== void 0 && A.set(e.destroyedAt, t);
3900
3903
  });
3901
- let j = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map(), ie = a.boxes.filter((e) => e.actorIds.length > 0).map((e) => {
3902
- let t = e.actorIds.map(y);
3904
+ let ie = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map(), oe = a.boxes.filter((e) => e.actorIds.length > 0).map((e) => {
3905
+ let t = e.actorIds.map(b);
3903
3906
  return {
3904
3907
  label: e.label,
3905
3908
  lo: Math.min(...t),
3906
3909
  hi: Math.max(...t)
3907
3910
  };
3908
- }), ae = ie.length > 0, M = a.actors.map((e, t) => ie.findIndex((e) => e.lo <= t && t <= e.hi)), N = +!!ae, P = (e) => e === "" ? 0 : an(e) + 6, oe = Array(Math.max(a.actors.length - 1, 0)).fill(0);
3911
+ }), j = oe.length > 0, M = a.actors.map((e, t) => oe.findIndex((e) => e.lo <= t && t <= e.hi)), N = +!!j, se = (e) => e === "" ? 0 : an(e) + 6, P = Array(Math.max(a.actors.length - 1, 0)).fill(0);
3909
3912
  for (let e of a.messages) {
3910
- let t = y(e.from), n = y(e.to);
3913
+ let t = b(e.from), n = b(e.to);
3911
3914
  if (t === n) continue;
3912
3915
  let r = Math.min(t, n), i = Math.max(t, n), a = an(e.label) + 4, o = i - r, s = Math.ceil(a / o);
3913
- for (let e = r; e < i; e++) oe[e] = Math.max(oe[e], s);
3916
+ for (let e = r; e < i; e++) P[e] = Math.max(P[e], s);
3914
3917
  }
3915
3918
  function F(e) {
3916
3919
  let t = Q(e.text);
3917
- return Math.max(...t.map((e) => B(e))) + 2 + 2 * x;
3920
+ return Math.max(...t.map((e) => z(e))) + 2 + 2 * S;
3918
3921
  }
3919
- let se = Array(a.actors.length).fill(0), ce = Array(a.actors.length).fill(0), I = Array(a.actors.length).fill(0), L = Array(a.actors.length).fill(0);
3922
+ let ce = Array(a.actors.length).fill(0), I = Array(a.actors.length).fill(0), le = Array(a.actors.length).fill(0), ue = Array(a.actors.length).fill(0);
3920
3923
  for (let e of a.notes) if (e.position === "left" || e.position === "right") {
3921
- let t = y(e.actorIds[0]), n = F(e);
3922
- e.position === "left" ? se[t] = Math.max(se[t], n) : ce[t] = Math.max(ce[t], n);
3924
+ let t = b(e.actorIds[0]), n = F(e);
3925
+ e.position === "left" ? ce[t] = Math.max(ce[t], n) : I[t] = Math.max(I[t], n);
3923
3926
  } else if (e.position === "over" && e.actorIds.length === 1) {
3924
- let t = y(e.actorIds[0]), n = F(e), r = Math.floor(n / 2), i = n - r;
3925
- I[t] = Math.max(I[t], r), L[t] = Math.max(L[t], i);
3927
+ let t = b(e.actorIds[0]), n = F(e), r = Math.floor(n / 2), i = n - r;
3928
+ le[t] = Math.max(le[t], r), ue[t] = Math.max(ue[t], i);
3926
3929
  }
3927
- let le = vt(t.paddingX, 5, 10, 4), R = [Math.max(T[0] + (M[0] === -1 ? 0 : 2), se[0] + 1, I[0])];
3930
+ let de = vt(t.paddingX, 5, 10, 4), L = [Math.max(E[0] + (M[0] === -1 ? 0 : 2), ce[0] + 1, le[0])];
3928
3931
  for (let e = 1; e < a.actors.length; e++) {
3929
- let t = M[e - 1], n = M[e], r = t === n ? 0 : (t === -1 ? 0 : 1) + (n === -1 ? 0 : 1), i = r === 0 ? 0 : r * 2 - 1, a = Math.max(ce[e - 1], se[e], L[e - 1], I[e]) + 2, o = Math.max(T[e - 1] + T[e] + 2 + i, oe[e - 1] + 2, a, le);
3930
- R[e] = R[e - 1] + o;
3932
+ let t = M[e - 1], n = M[e], r = t === n ? 0 : (t === -1 ? 0 : 1) + (n === -1 ? 0 : 1), i = r === 0 ? 0 : r * 2 - 1, a = Math.max(I[e - 1], ce[e], ue[e - 1], le[e]) + 2, o = Math.max(E[e - 1] + E[e] + 2 + i, P[e - 1] + 2, a, de);
3933
+ L[e] = L[e - 1] + o;
3931
3934
  }
3932
- let ue = (e) => O(e.lo, R[e.lo]) - 1 - 1, de = (e) => Math.max(O(e.hi, R[e.hi]) + w[e.hi] - 1 + 1 + 1, ue(e) + P(e.label) - 1);
3933
- for (let e of ie) {
3935
+ let fe = (e) => O(e.lo, L[e.lo]) - 1 - 1, pe = (e) => Math.max(O(e.hi, L[e.hi]) + T[e.hi] - 1 + 1 + 1, fe(e) + se(e.label) - 1);
3936
+ for (let e of oe) {
3934
3937
  if (e.hi + 1 >= a.actors.length) continue;
3935
- let t = O(e.hi + 1, R[e.hi + 1]), n = M[e.hi + 1] === -1 ? 0 : 2, r = de(e) + 1 + 1 + n - t;
3938
+ let t = O(e.hi + 1, L[e.hi + 1]), n = M[e.hi + 1] === -1 ? 0 : 2, r = pe(e) + 1 + 1 + n - t;
3936
3939
  if (r > 0) {
3937
- let t = R.slice(e.hi + 1).map((e) => e + r);
3938
- R.splice(e.hi + 1, t.length, ...t);
3940
+ let t = L.slice(e.hi + 1).map((e) => e + r);
3941
+ L.splice(e.hi + 1, t.length, ...t);
3939
3942
  }
3940
3943
  }
3941
3944
  for (let e of a.blocks) {
3942
3945
  let t = -1, n = -1, r = Infinity, i = -1;
3943
3946
  for (let o = e.startIndex; o <= e.endIndex && !(o >= a.messages.length); o++) {
3944
- let e = a.messages[o], s = y(e.from), c = y(e.to);
3945
- if (t = t === -1 ? Math.min(s, c) : Math.min(t, s, c), n = Math.max(n, s, c), r = Math.min(r, R[Math.min(s, c)]), i = Math.max(i, R[Math.max(s, c)]), s === c) {
3946
- let t = R[s] + ni + 2 + an(e.label);
3947
+ let e = a.messages[o], s = b(e.from), c = b(e.to);
3948
+ if (t = t === -1 ? Math.min(s, c) : Math.min(t, s, c), n = Math.max(n, s, c), r = Math.min(r, L[Math.min(s, c)]), i = Math.max(i, L[Math.max(s, c)]), s === c) {
3949
+ let t = L[s] + vi + 2 + an(e.label);
3947
3950
  i = Math.max(i, t);
3948
3951
  }
3949
3952
  }
3950
3953
  if (n === -1 || n + 1 >= a.actors.length) continue;
3951
- let o = Math.max(0, r - ai), s = i + ai, c = o + 1 + b(e), l = Math.max(s, c), u = R[n + 1], d = l + 2 - u;
3954
+ let o = Math.max(0, r - xi), s = i + xi, c = o + 1 + x(e), l = Math.max(s, c), u = L[n + 1], d = l + 2 - u;
3952
3955
  if (d > 0) {
3953
- let e = R.slice(n + 1).map((e) => e + d);
3954
- R.splice(n + 1, e.length, ...e);
3956
+ let e = L.slice(n + 1).map((e) => e + d);
3957
+ L.splice(n + 1, e.length, ...e);
3955
3958
  }
3956
3959
  }
3957
- let fe = [], pe = [], me = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new Map(), ge = /* @__PURE__ */ new Map(), _e = [], ve = N, ye = ve + D, z = ye + N, be = vt(t.paddingY, 5, 1, 0), xe = Math.max(be, 1);
3960
+ let me = [], he = [], ge = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map(), ye = [], be = N, xe = be + D, R = xe + N, Se = vt(t.paddingY, 5, 1, 0), Ce = Math.max(Se, 1);
3958
3961
  for (let e of a.notes) {
3959
3962
  if (e.afterIndex !== -1) continue;
3960
- z += be;
3961
- let t = Q(e.text), n = F(e), r = t.length + 2, i = v.get(e.actorIds[0]) ?? 0, a;
3962
- if (e.position === "left") a = R[i] - n - 1;
3963
- else if (e.position === "right") a = R[i] + 2;
3963
+ R += Se;
3964
+ let t = Q(e.text), n = F(e), r = t.length + 2, i = y.get(e.actorIds[0]) ?? 0, a;
3965
+ if (e.position === "left") a = L[i] - n - 1;
3966
+ else if (e.position === "right") a = L[i] + 2;
3964
3967
  else if (e.actorIds.length >= 2) {
3965
- let t = v.get(e.actorIds[1]) ?? i;
3966
- a = Math.floor((R[i] + R[t]) / 2) - Math.floor(n / 2);
3967
- } else a = R[i] - Math.floor(n / 2);
3968
- a = Math.max(0, a), _e.push({
3968
+ let t = y.get(e.actorIds[1]) ?? i;
3969
+ a = Math.floor((L[i] + L[t]) / 2) - Math.floor(n / 2);
3970
+ } else a = L[i] - Math.floor(n / 2);
3971
+ a = Math.max(0, a), ye.push({
3969
3972
  x: a,
3970
- y: z,
3973
+ y: R,
3971
3974
  width: n,
3972
3975
  height: r,
3973
3976
  lines: t
3974
- }), z += r;
3977
+ }), R += r;
3975
3978
  }
3976
3979
  for (let e = 0; e < a.messages.length; e++) {
3977
- for (let t = 0; t < a.blocks.length; t++) a.blocks[t].startIndex === e && (z += be + 1, me.set(t, z - 1));
3978
- for (let t = 0; t < a.blocks.length; t++) for (let n = 0; n < a.blocks[t].dividers.length; n++) a.blocks[t].dividers[n].index === e && (z += be, ge.set(`${t}:${n}`, z), z += xe);
3979
- z += be;
3980
- let t = a.messages[e], n = t.from === t.to, r = on(t.label), i = n ? void 0 : ne.get(e), o = A.get(e);
3981
- if (n) pe[e] = z + 1, fe[e] = z, z += 2 + r;
3980
+ for (let t = 0; t < a.blocks.length; t++) a.blocks[t].startIndex === e && (R += Se + 1, ge.set(t, R - 1));
3981
+ for (let t = 0; t < a.blocks.length; t++) for (let n = 0; n < a.blocks[t].dividers.length; n++) a.blocks[t].dividers[n].index === e && (R += Se, ve.set(`${t}:${n}`, R), R += Ce);
3982
+ R += Se;
3983
+ let t = a.messages[e], n = t.from === t.to, r = on(t.label), i = n ? void 0 : k.get(e), o = A.get(e);
3984
+ if (n) he[e] = R + 1, me[e] = R, R += 2 + r;
3982
3985
  else {
3983
- let t = i === void 0 ? 0 : k, n = i === void 0 ? 0 : te;
3984
- pe[e] = z, fe[e] = z + r + t, z += r + t + 1 + n, i !== void 0 && j.set(i, fe[e] - t);
3986
+ let t = i === void 0 ? 0 : ne, n = i === void 0 ? 0 : re;
3987
+ he[e] = R, me[e] = R + r + t, R += r + t + 1 + n, i !== void 0 && ie.set(i, me[e] - t);
3985
3988
  }
3986
- o !== void 0 && (re.set(o, z), z += 1);
3989
+ o !== void 0 && (ae.set(o, R), R += 1);
3987
3990
  for (let t = 0; t < a.notes.length; t++) if (a.notes[t].afterIndex === e) {
3988
- z += be;
3989
- let e = a.notes[t], n = Q(e.text), r = F(e), i = n.length + 2, o = v.get(e.actorIds[0]) ?? 0, s;
3990
- if (e.position === "left") s = R[o] - r - 1;
3991
- else if (e.position === "right") s = R[o] + 2;
3991
+ R += Se;
3992
+ let e = a.notes[t], n = Q(e.text), r = F(e), i = n.length + 2, o = y.get(e.actorIds[0]) ?? 0, s;
3993
+ if (e.position === "left") s = L[o] - r - 1;
3994
+ else if (e.position === "right") s = L[o] + 2;
3992
3995
  else if (e.actorIds.length >= 2) {
3993
- let t = v.get(e.actorIds[1]) ?? o;
3994
- s = Math.floor((R[o] + R[t]) / 2) - Math.floor(r / 2);
3995
- } else s = R[o] - Math.floor(r / 2);
3996
- s = Math.max(0, s), _e.push({
3996
+ let t = y.get(e.actorIds[1]) ?? o;
3997
+ s = Math.floor((L[o] + L[t]) / 2) - Math.floor(r / 2);
3998
+ } else s = L[o] - Math.floor(r / 2);
3999
+ s = Math.max(0, s), ye.push({
3997
4000
  x: s,
3998
- y: z,
4001
+ y: R,
3999
4002
  width: r,
4000
4003
  height: i,
4001
4004
  lines: n
4002
- }), z += i;
4005
+ }), R += i;
4003
4006
  }
4004
- for (let t = 0; t < a.blocks.length; t++) a.blocks[t].endIndex === e && (z += be, he.set(t, z), z += xe);
4007
+ for (let t = 0; t < a.blocks.length; t++) a.blocks[t].endIndex === e && (R += Se, _e.set(t, R), R += Ce);
4005
4008
  }
4006
- z += xe;
4007
- let Se = z, H = Se + N, Ee = H + D + N, ke = (R[R.length - 1] ?? 0) + (T[T.length - 1] ?? 0) + 2;
4008
- for (let e of ie) ke = Math.max(ke, de(e) + 2);
4009
+ R += Ce;
4010
+ let V = R, De = V + N, Ae = De + D + N, U = (L[L.length - 1] ?? 0) + (E[E.length - 1] ?? 0) + 2;
4011
+ for (let e of oe) U = Math.max(U, pe(e) + 2);
4009
4012
  for (let e = 0; e < a.messages.length; e++) {
4010
4013
  let t = a.messages[e];
4011
4014
  if (t.from === t.to) {
4012
- let e = R[y(t.from)] + oi(t) + 2 + 2 + an(t.label);
4013
- ke = Math.max(ke, e + 1);
4015
+ let e = L[b(t.from)] + Si(t) + 2 + 2 + an(t.label);
4016
+ U = Math.max(U, e + 1);
4014
4017
  }
4015
4018
  }
4016
- for (let e of _e) ke = Math.max(ke, e.x + e.width + 1);
4017
- let Ae = V(ke, Ee - 1), je = we(ke, Ee - 1);
4019
+ for (let e of ye) U = Math.max(U, e.x + e.width + 1);
4020
+ let je = B(U, Ae - 1), Me = Te(U, Ae - 1);
4018
4021
  function W(e, t, n, r) {
4019
- U(Ae, e, t, n, {
4022
+ H(je, e, t, n, {
4020
4023
  role: r,
4021
- roleCanvas: je
4024
+ roleCanvas: Me
4022
4025
  });
4023
4026
  }
4024
- function Me(e, t, n, r, i) {
4025
- let a = Ce(n);
4027
+ function Ne(e, t, n, r, i) {
4028
+ let a = we(n);
4026
4029
  for (let n = 0; n < a.length; n++) {
4027
4030
  let o = e + n;
4028
4031
  if (i !== void 0 && o >= i || a[n + 1] === "" && i !== void 0 && o + 1 >= i) break;
4029
4032
  W(o, t, a[n], r);
4030
4033
  }
4031
4034
  }
4032
- function Ne(e, t, n, r, i) {
4033
- let a = r === "actor" ? ri : [], o = [...a, ...Q(n)], u = Math.max(an(n), a.length > 0 ? ii : 0), m = u + 2 * x + 2, h = i, g = h - 2, _ = e - Math.floor(m / 2);
4035
+ function Pe(e, t, n, r, i) {
4036
+ let a = r === "actor" ? yi : [], o = [...a, ...Q(n)], u = Math.max(an(n), a.length > 0 ? bi : 0), m = u + 2 * S + 2, h = i, g = h - 2, _ = e - Math.floor(m / 2);
4034
4037
  W(_, t, l, "border");
4035
4038
  for (let e = 1; e < m - 1; e++) W(_ + e, t, s, "border");
4036
4039
  W(_ + m - 1, t, d, "border");
@@ -4038,42 +4041,81 @@ function si(e, t, n, r) {
4038
4041
  let n = t + 1 + e;
4039
4042
  W(_, n, c, "border"), W(_ + m - 1, n, c, "border");
4040
4043
  let r = o[e];
4041
- r !== void 0 && Me(_ + 1 + x + Math.floor((u - B(r)) / 2), n, r, "text");
4044
+ r !== void 0 && Ne(_ + 1 + S + Math.floor((u - z(r)) / 2), n, r, "text");
4042
4045
  }
4043
4046
  let v = t + h - 1;
4044
4047
  W(_, v, f, "border");
4045
4048
  for (let e = 1; e < m - 1; e++) W(_ + e, v, s, "border");
4046
4049
  W(_ + m - 1, v, p, "border");
4047
4050
  }
4048
- let Pe = (e) => {
4049
- let t = j.get(e);
4050
- return t === void 0 ? ye : t + D;
4051
- }, Ie = (e) => re.get(e) ?? Se;
4051
+ let Ie = (e) => {
4052
+ let t = ie.get(e);
4053
+ return t === void 0 ? xe : t + D;
4054
+ }, Le = (e) => ae.get(e) ?? V, Re = /* @__PURE__ */ new Map(), ze = /* @__PURE__ */ new Map();
4055
+ function Be(e, t) {
4056
+ let n = ze.get(e) ?? [];
4057
+ ze.set(e, n), n.push(t);
4058
+ }
4059
+ function Ve(e, t) {
4060
+ let n = ze.get(e)?.pop();
4061
+ if (n === void 0) return;
4062
+ let r = Re.get(e) ?? [];
4063
+ Re.set(e, r), r.push({
4064
+ topRow: n,
4065
+ bottomRow: t
4066
+ });
4067
+ }
4068
+ let He = /* @__PURE__ */ new Map();
4069
+ for (let e of a.activations) {
4070
+ let t = He.get(e.afterIndex) ?? [];
4071
+ t.push(e), He.set(e.afterIndex, t);
4072
+ }
4073
+ function Ue(e, t) {
4074
+ for (let n of He.get(e) ?? []) n.kind === "start" ? Be(n.actorId, t) : Ve(n.actorId, t);
4075
+ }
4076
+ Ue(-1, xe);
4077
+ for (let e = 0; e < a.messages.length; e++) {
4078
+ let t = a.messages[e], n = me[e];
4079
+ t.activate && Be(t.to, n), t.deactivate && Ve(t.from, n), Ue(e, n);
4080
+ }
4081
+ for (let [e, t] of ze) {
4082
+ if (t.length === 0) continue;
4083
+ let n = Le(b(e)), r = Re.get(e) ?? [];
4084
+ Re.set(e, r);
4085
+ for (let e of t) r.push({
4086
+ topRow: e,
4087
+ bottomRow: n
4088
+ });
4089
+ }
4090
+ function We(e, t) {
4091
+ let n = Re.get(e);
4092
+ return n ? n.some((e) => t >= e.topRow && t <= e.bottomRow) : !1;
4093
+ }
4052
4094
  for (let e = 0; e < a.actors.length; e++) {
4053
- let t = R[e];
4054
- for (let n = Pe(e); n <= Ie(e); n++) W(t, n, c, "line");
4095
+ let t = L[e], n = a.actors[e].id;
4096
+ for (let r = Ie(e); r <= Le(e); r++) W(t, r, We(n, r) ? v : c, "line");
4055
4097
  }
4056
- let Le = o ? "+" : "┼";
4057
- function Re(e, t, n) {
4058
- let r = ue(e), i = de(e), a = t + D + 1;
4098
+ let Ge = o ? "+" : "┼";
4099
+ function Ke(e, t, n) {
4100
+ let r = fe(e), i = pe(e), a = t + D + 1;
4059
4101
  W(r, t, l, "border"), W(i, t, d, "border"), W(r, a, f, "border"), W(i, a, p, "border");
4060
4102
  for (let e = r + 1; e < i; e++) W(e, t, s, "border"), W(e, a, s, "border");
4061
4103
  for (let e = t + 1; e < a; e++) W(r, e, c, "border"), W(i, e, c, "border");
4062
- n !== "" && Me(r + 2, t, ` ${Q(n)[0]} `, "text");
4104
+ n !== "" && Ne(r + 2, t, ` ${Q(n)[0]} `, "text");
4063
4105
  for (let n = e.lo; n <= e.hi; n++) {
4064
- let e = R[n];
4065
- Pe(n) <= t && t <= Ie(n) && W(e, t, Le, "junction"), Pe(n) <= a && a <= Ie(n) && W(e, a, Le, "junction");
4106
+ let e = L[n];
4107
+ Ie(n) <= t && t <= Le(n) && W(e, t, Ge, "junction"), Ie(n) <= a && a <= Le(n) && W(e, a, Ge, "junction");
4066
4108
  }
4067
4109
  }
4068
- for (let e of ie) Re(e, 0, e.label), Re(e, Se, "");
4110
+ for (let e of oe) Ke(e, 0, e.label), Ke(e, V, "");
4069
4111
  for (let e = 0; e < a.actors.length; e++) {
4070
- let t = a.actors[e], n = j.get(e) ?? ve, r = re.has(e);
4071
- Ne(R[e], n, t.label, t.type, D), r || Ne(R[e], H, t.label, t.type, D), o || (W(R[e], n + D - 1, m, "junction"), r || W(R[e], H, h, "junction"));
4112
+ let t = a.actors[e], n = ie.get(e) ?? be, r = ae.has(e);
4113
+ Pe(L[e], n, t.label, t.type, D), r || Pe(L[e], De, t.label, t.type, D), o || (W(L[e], n + D - 1, m, "junction"), r || W(L[e], De, h, "junction"));
4072
4114
  }
4073
4115
  for (let e = 0; e < a.messages.length; e++) {
4074
- let t = a.messages[e], n = y(t.from), r = y(t.to), i = R[n], l = R[r], u = n === r, d = t.lineStyle === "dashed", f = t.arrowHead === "filled", p = t.isLost === !0, m = o ? "x" : "✕", h = d ? o ? "." : "╌" : s;
4116
+ let t = a.messages[e], n = b(t.from), r = b(t.to), i = L[n], l = L[r], u = n === r, d = t.lineStyle === "dashed", f = t.arrowHead === "filled", p = t.isLost === !0, m = o ? "x" : "✕", h = d ? o ? "." : "╌" : s;
4075
4117
  if (u) {
4076
- let n = fe[e], r = oi(t), a = t.seqNumber === void 0 ? void 0 : String(t.seqNumber), s = Q(t.label);
4118
+ let n = me[e], r = Si(t), a = t.seqNumber === void 0 ? void 0 : String(t.seqNumber), s = Q(t.label);
4077
4119
  W(i, n, g, "junction");
4078
4120
  let l = i + 1;
4079
4121
  if (a !== void 0) {
@@ -4085,22 +4127,22 @@ function si(e, t, n, r) {
4085
4127
  let u = i + r + 2;
4086
4128
  for (let e = 0; e < s.length; e++) {
4087
4129
  let t = n + 1 + e;
4088
- W(i + r, t, c, "line"), Me(u, t, s[e], "text", ke);
4130
+ W(i + r, t, c, "line"), Ne(u, t, s[e], "text", U);
4089
4131
  }
4090
4132
  let d = n + 1 + s.length;
4091
4133
  W(i, d, p ? m : f ? o ? "<" : "◀" : o ? "<" : "◁", "arrow");
4092
4134
  for (let e = i + 1; e < i + r; e++) W(e, d, h, "line");
4093
4135
  W(i + r, d, o ? "+" : "┘", "corner");
4094
4136
  } else {
4095
- let n = pe[e], a = fe[e], s = i < l, c = ne.get(e) === r, u = l;
4137
+ let n = he[e], a = me[e], s = i < l, c = k.get(e) === r, u = l;
4096
4138
  if (c) {
4097
- let e = O(r, l), t = e + w[r] - 1;
4139
+ let e = O(r, l), t = e + T[r] - 1;
4098
4140
  u = s ? e - 1 : t + 1;
4099
4141
  }
4100
4142
  let d = Math.floor((i + l) / 2), g = Q(t.label);
4101
4143
  for (let e = 0; e < g.length; e++) {
4102
4144
  let t = g[e];
4103
- Me(d - Math.floor(B(t) / 2), n + e, t, "text", ke);
4145
+ Ne(d - Math.floor(z(t) / 2), n + e, t, "text", U);
4104
4146
  }
4105
4147
  if (s) {
4106
4148
  for (let e = i + 1; e < u; e++) W(e, a, h, "line");
@@ -4121,81 +4163,81 @@ function si(e, t, n, r) {
4121
4163
  }
4122
4164
  }
4123
4165
  }
4124
- for (let [e, t] of re) W(R[e], t, o ? "x" : "✕", "arrow");
4125
- let ze = ke - 1;
4166
+ for (let [e, t] of ae) W(L[e], t, o ? "x" : "✕", "arrow");
4167
+ let qe = U - 1;
4126
4168
  for (let e = 0; e < a.blocks.length; e++) {
4127
- let t = a.blocks[e], n = me.get(e), r = he.get(e);
4169
+ let t = a.blocks[e], n = ge.get(e), r = _e.get(e);
4128
4170
  if (n === void 0 || r === void 0) continue;
4129
- let i = ke, o = 0;
4171
+ let i = U, o = 0;
4130
4172
  for (let e = t.startIndex; e <= t.endIndex && !(e >= a.messages.length); e++) {
4131
- let t = a.messages[e], n = v.get(t.from) ?? 0, r = v.get(t.to) ?? 0;
4132
- if (i = Math.min(i, R[Math.min(n, r)]), o = Math.max(o, R[Math.max(n, r)]), n === r) {
4133
- let e = R[n] + oi(t) + 2 + an(t.label);
4173
+ let t = a.messages[e], n = y.get(t.from) ?? 0, r = y.get(t.to) ?? 0;
4174
+ if (i = Math.min(i, L[Math.min(n, r)]), o = Math.max(o, L[Math.max(n, r)]), n === r) {
4175
+ let e = L[n] + Si(t) + 2 + an(t.label);
4134
4176
  o = Math.max(o, e);
4135
4177
  }
4136
4178
  }
4137
- let u = i - ai, m = o + ai, h = Infinity, y = -Infinity;
4138
- for (let e of R) e > o && e < h && (h = e), e < i && e > y && (y = e);
4139
- m >= h && (m = Math.max(o, h - ai)), u <= y && (u = Math.min(i, y + ai)), u = Math.max(0, u), m > ze && (Oe(Ae, m + 1, Ee - 1), Te(je, m + 1, Ee - 1), ze = m);
4140
- let x = t.label ? `${t.type} [${t.label}]` : t.type, S = u + 1 + b(t);
4179
+ let u = i - xi, m = o + xi, h = Infinity, v = -Infinity;
4180
+ for (let e of L) e > o && e < h && (h = e), e < i && e > v && (v = e);
4181
+ m >= h && (m = Math.max(o, h - xi)), u <= v && (u = Math.min(i, v + xi)), u = Math.max(0, u), m > qe && (ke(je, m + 1, Ae - 1), Ee(Me, m + 1, Ae - 1), qe = m);
4182
+ let b = t.label ? `${t.type} [${t.label}]` : t.type, S = u + 1 + x(t);
4141
4183
  if (S > m) {
4142
4184
  m = S;
4143
- let [e] = De(Ae);
4144
- m > e && (Oe(Ae, m, Ee - 1), Te(je, m, Ee - 1)), ke = Math.max(ke, m + 1), ze = Math.max(ze, m);
4185
+ let [e] = Oe(je);
4186
+ m > e && (ke(je, m, Ae - 1), Ee(Me, m, Ae - 1)), U = Math.max(U, m + 1), qe = Math.max(qe, m);
4145
4187
  }
4146
4188
  W(u, n, l, "border");
4147
4189
  for (let e = u + 1; e < m; e++) W(e, n, s, "border");
4148
4190
  W(m, n, d, "border");
4149
- let C = Q(x);
4150
- for (let e = 0; e < C.length && n + e < r; e++) Me(u + 1, n + e, C[e], "text", m);
4191
+ let C = Q(b);
4192
+ for (let e = 0; e < C.length && n + e < r; e++) Ne(u + 1, n + e, C[e], "text", m);
4151
4193
  W(u, r, f, "border");
4152
4194
  for (let e = u + 1; e < m; e++) W(e, r, s, "border");
4153
4195
  W(m, r, p, "border");
4154
4196
  for (let e = n + 1; e < r; e++) W(u, e, c, "border"), W(m, e, c, "border");
4155
4197
  for (let n = 0; n < t.dividers.length; n++) {
4156
- let r = ge.get(`${e}:${n}`);
4198
+ let r = ve.get(`${e}:${n}`);
4157
4199
  if (r === void 0) continue;
4158
- let i = Be();
4200
+ let i = Je();
4159
4201
  W(u, r, g, "junction");
4160
4202
  for (let e = u + 1; e < m; e++) W(e, r, i, "line");
4161
4203
  W(m, r, _, "junction");
4162
4204
  let a = t.dividers[n].label;
4163
4205
  if (a) {
4164
4206
  let e = `[${a}]`;
4165
- Me(u + 1, r, e, "text", m);
4207
+ Ne(u + 1, r, e, "text", m);
4166
4208
  }
4167
4209
  }
4168
4210
  }
4169
- for (let e of _e) {
4170
- Oe(Ae, e.x + e.width, e.y + e.height), Te(je, e.x + e.width, e.y + e.height), W(e.x, e.y, l, "border");
4211
+ for (let e of ye) {
4212
+ ke(je, e.x + e.width, e.y + e.height), Ee(Me, e.x + e.width, e.y + e.height), W(e.x, e.y, l, "border");
4171
4213
  for (let t = 1; t < e.width - 1; t++) W(e.x + t, e.y, s, "border");
4172
4214
  W(e.x + e.width - 1, e.y, d, "border");
4173
4215
  for (let t = 0; t < e.lines.length; t++) {
4174
4216
  let n = e.y + 1 + t;
4175
4217
  W(e.x, n, c, "border"), W(e.x + e.width - 1, n, c, "border");
4176
4218
  for (let t = e.x + 1; t < e.x + e.width - 1; t++) W(t, n, " ", "text");
4177
- Me(e.x + 1 + x, n, e.lines[t], "text");
4219
+ Ne(e.x + 1 + S, n, e.lines[t], "text");
4178
4220
  }
4179
4221
  let t = e.y + e.height - 1;
4180
4222
  W(e.x, t, f, "border");
4181
4223
  for (let n = 1; n < e.width - 1; n++) W(e.x + n, t, s, "border");
4182
4224
  W(e.x + e.width - 1, t, p, "border");
4183
4225
  }
4184
- return Fe(Ae, {
4185
- roleCanvas: je,
4226
+ return Fe(je, {
4227
+ roleCanvas: Me,
4186
4228
  colorMode: n,
4187
4229
  theme: r
4188
4230
  });
4189
- function Be() {
4231
+ function Je() {
4190
4232
  return o ? "-" : "╌";
4191
4233
  }
4192
4234
  }
4193
4235
  //#endregion
4194
4236
  //#region packages/ascii-renderer/src/territory.ts
4195
- function ci(e, t) {
4237
+ function wi(e, t) {
4196
4238
  return e.rowStart <= t.rowEnd && t.rowStart <= e.rowEnd;
4197
4239
  }
4198
- function li(e, t) {
4240
+ function Ti(e, t) {
4199
4241
  let n = e.map((e) => ({
4200
4242
  item: e,
4201
4243
  geom: t(e)
@@ -4203,7 +4245,7 @@ function li(e, t) {
4203
4245
  let r = n[e];
4204
4246
  if (r) for (let i = e + t; i >= 0 && i < n.length; i += t) {
4205
4247
  let e = n[i];
4206
- if (e && ci(e.geom, r.geom)) return e.geom;
4248
+ if (e && wi(e.geom, r.geom)) return e.geom;
4207
4249
  }
4208
4250
  }, i = /* @__PURE__ */ new Map();
4209
4251
  for (let [e, t] of n.entries()) {
@@ -4217,7 +4259,7 @@ function li(e, t) {
4217
4259
  }
4218
4260
  //#endregion
4219
4261
  //#region packages/ascii-renderer/src/class-diagram.ts
4220
- function ui(e) {
4262
+ function Ei(e) {
4221
4263
  let t = [];
4222
4264
  e.annotation && t.push(`<<${e.annotation}>>`);
4223
4265
  let n = Q(e.label);
@@ -4225,14 +4267,14 @@ function ui(e) {
4225
4267
  let r = e.attributes.map(y), i = e.methods.map(y), a = [t];
4226
4268
  return r.length > 0 && a.push(r), i.length > 0 && a.push(i), a;
4227
4269
  }
4228
- function di(e, t) {
4270
+ function Di(e, t) {
4229
4271
  return {
4230
4272
  type: e,
4231
4273
  markerAt: t,
4232
4274
  dashed: e === "dependency" || e === "realization"
4233
4275
  };
4234
4276
  }
4235
- function fi(e, t, n) {
4277
+ function Oi(e, t, n) {
4236
4278
  switch (e) {
4237
4279
  case "inheritance":
4238
4280
  case "realization": return n === "down" ? t ? "^" : "△" : n === "up" ? t ? "v" : "▽" : n === "left" ? t ? ">" : "◁" : t ? "<" : "▷";
@@ -4242,7 +4284,7 @@ function fi(e, t, n) {
4242
4284
  case "dependency": return n === "down" ? t ? "v" : "▼" : n === "up" ? t ? "^" : "▲" : n === "left" ? t ? "<" : "◀" : t ? ">" : "▶";
4243
4285
  }
4244
4286
  }
4245
- function pi(e, t, n, r, i) {
4287
+ function ki(e, t, n, r, i) {
4246
4288
  let a = e + t.length - 1, o = r > e, s = i < a;
4247
4289
  if (!o && !s) return {
4248
4290
  start: e,
@@ -4257,7 +4299,7 @@ function pi(e, t, n, r, i) {
4257
4299
  start: c,
4258
4300
  cells: ["…"]
4259
4301
  };
4260
- let d = Math.max(0, l - u), f = Ce(n), p = f.length <= d ? f : o && !s ? f.slice(f.length - d) : f.slice(0, d), m = [
4302
+ let d = Math.max(0, l - u), f = we(n), p = f.length <= d ? f : o && !s ? f.slice(f.length - d) : f.slice(0, d), m = [
4261
4303
  ...o ? ["…"] : [],
4262
4304
  ...p,
4263
4305
  ...s ? ["…"] : []
@@ -4267,17 +4309,17 @@ function pi(e, t, n, r, i) {
4267
4309
  cells: m
4268
4310
  };
4269
4311
  }
4270
- function mi(e) {
4271
- return Math.max(...Q(e).map((e) => B(e))) + 2;
4312
+ function Ai(e) {
4313
+ return Math.max(...Q(e).map((e) => z(e))) + 2;
4272
4314
  }
4273
- function hi(e, t, n, r, i = {}) {
4274
- let a = u(e), { diagram: o, notesById: s } = gi(S(a));
4315
+ function ji(e, t, n, r, i = {}) {
4316
+ let a = u(e), { diagram: o, notesById: s } = Mi(S(a));
4275
4317
  if (o.classes.length === 0) return "";
4276
4318
  let c = t.useAscii, d = vt(t.paddingX, 5, 4, 1), f = vt(t.paddingY, 5, 3, 1), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
4277
4319
  for (let e of o.classes) {
4278
- let n = ui(e);
4320
+ let n = Ei(e);
4279
4321
  p.set(e.id, n);
4280
- let { width: r, height: i } = Hr(n, t.boxBorderPadding);
4322
+ let { width: r, height: i } = ii(n, t.boxBorderPadding);
4281
4323
  m.set(e.id, r), h.set(e.id, i);
4282
4324
  }
4283
4325
  let g = /* @__PURE__ */ new Map();
@@ -4300,7 +4342,7 @@ function hi(e, t, n, r, i = {}) {
4300
4342
  }
4301
4343
  }
4302
4344
  for (let e of o.classes) y.has(e.id) || y.set(e.id, 0);
4303
- _i(s, y);
4345
+ Ni(s, y);
4304
4346
  let w = Math.max(...y.values(), 0), ee = Array.from({ length: w + 1 }, () => []);
4305
4347
  for (let e of o.classes) ee[y.get(e.id)].push(e.id);
4306
4348
  let T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
@@ -4314,14 +4356,14 @@ function hi(e, t, n, r, i = {}) {
4314
4356
  if (t.length < 2) continue;
4315
4357
  let e = t.length, n = Math.max(...t.map((e) => {
4316
4358
  let t = o.relationships[e].label;
4317
- return t ? mi(t) : 3;
4359
+ return t ? Ai(t) : 3;
4318
4360
  })) + 1;
4319
4361
  t.forEach((t, r) => {
4320
4362
  T.set(t, Math.round((r - (e - 1) / 2) * n)), E.set(t, (e - 1) * n);
4321
4363
  });
4322
4364
  }
4323
4365
  }
4324
- let D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
4366
+ let te = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Map();
4325
4367
  {
4326
4368
  let e = (e, t, n) => {
4327
4369
  let r = /* @__PURE__ */ new Map();
@@ -4336,28 +4378,28 @@ function hi(e, t, n, r, i = {}) {
4336
4378
  if (e.length < 2) continue;
4337
4379
  let r = e.length, i = Math.max(...e.map((e) => {
4338
4380
  let t = o.relationships[e].label;
4339
- return t ? mi(t) : 3;
4381
+ return t ? Ai(t) : 3;
4340
4382
  })) + 1;
4341
4383
  e.forEach((e, a) => {
4342
4384
  t.set(e, Math.round((a - (r - 1) / 2) * i)), n.set(e, (r - 1) * i);
4343
4385
  });
4344
4386
  }
4345
4387
  };
4346
- e((e) => e.to, k, te), e((e) => e.from, D, O);
4388
+ e((e) => e.to, O, ne), e((e) => e.from, te, D);
4347
4389
  }
4348
- let ne = /* @__PURE__ */ new Map();
4349
- for (let e of o.classes) ne.set(e.id, {
4390
+ let re = /* @__PURE__ */ new Map();
4391
+ for (let e of o.classes) re.set(e.id, {
4350
4392
  left: 0,
4351
4393
  right: 0
4352
4394
  });
4353
4395
  o.relationships.forEach((e, t) => {
4354
4396
  if (!g.has(e.from) || !g.has(e.to)) return;
4355
- let n = e.label ? mi(e.label) : 1, r = T.get(t) ?? D.get(t) ?? 0, i = T.get(t) ?? k.get(t) ?? 0, a = ne.get(e.from);
4397
+ let n = e.label ? Ai(e.label) : 1, r = T.get(t) ?? te.get(t) ?? 0, i = T.get(t) ?? O.get(t) ?? 0, a = re.get(e.from);
4356
4398
  a.left = Math.max(a.left, Math.floor(n / 2) - r), a.right = Math.max(a.right, r + n - 1 - Math.floor(n / 2));
4357
- let o = ne.get(e.to);
4399
+ let o = re.get(e.to);
4358
4400
  o.left = Math.max(o.left, Math.floor(n / 2) - i), o.right = Math.max(o.right, i + n - 1 - Math.floor(n / 2));
4359
4401
  });
4360
- let j = /* @__PURE__ */ new Map(), re = 0, ae = 0;
4402
+ let A = /* @__PURE__ */ new Map(), ie = 0, oe = 0;
4361
4403
  for (let e = 0; e <= w; e++) {
4362
4404
  let t = ee[e];
4363
4405
  if (t.length === 0) continue;
@@ -4373,20 +4415,20 @@ function hi(e, t, n, r, i = {}) {
4373
4415
  {
4374
4416
  let e = 0;
4375
4417
  for (let n of t) {
4376
- let t = m.get(n), r = ne.get(n), s = Math.max(0, r.left - Math.floor(t / 2)), c = Math.max(0, r.right - (t - 1 - Math.floor(t / 2)));
4418
+ let t = m.get(n), r = re.get(n), s = Math.max(0, r.left - Math.floor(t / 2)), c = Math.max(0, r.right - (t - 1 - Math.floor(t / 2)));
4377
4419
  i.set(n, e), a.set(n, s + t + c), o.set(n, s), e += s + t + c + d;
4378
4420
  }
4379
4421
  }
4380
4422
  let s = 0, c = 0, l = (e, t) => {
4381
4423
  let n = g.get(e), r = m.get(e), i = h.get(e), l = o.get(e), u = a.get(e);
4382
- j.set(e, {
4424
+ A.set(e, {
4383
4425
  cls: n,
4384
4426
  sections: p.get(e),
4385
4427
  x: t + l,
4386
- y: re,
4428
+ y: ie,
4387
4429
  width: r,
4388
4430
  height: i
4389
- }), ae = Math.max(ae, t + u), s = t + u + d, c = Math.max(c, i);
4431
+ }), oe = Math.max(oe, t + u), s = t + u + d, c = Math.max(c, i);
4390
4432
  }, u = /* @__PURE__ */ new Set();
4391
4433
  for (let c of t) {
4392
4434
  if (u.has(c)) continue;
@@ -4396,40 +4438,40 @@ function hi(e, t, n, r, i = {}) {
4396
4438
  continue;
4397
4439
  }
4398
4440
  let h = r.get(t), g = p.map((e) => {
4399
- let t = j.get(e);
4441
+ let t = A.get(e);
4400
4442
  return t.x + Math.floor(t.width / 2);
4401
4443
  }), v = Math.round(g.reduce((e, t) => e + t, 0) / g.length), b = 0;
4402
4444
  for (let e = 0; e < h.length; e++) b += a.get(h[e]), e < h.length - 1 && (b += d);
4403
4445
  let x = o.get(h[0]), S = h[h.length - 1], C = a.get(S) - o.get(S) - m.get(S), w = b - x - C, ee = v - x - Math.floor(w / 2), T = Math.max(ee, s, 0);
4404
4446
  for (let e of h) l(e, T), u.add(e), T = s;
4405
4447
  }
4406
- re += c + f;
4448
+ ie += c + f;
4407
4449
  }
4408
- let M = ae, N = 0;
4409
- for (let e of j.values()) M = Math.max(M, e.x + e.width), N = Math.max(N, e.y + e.height);
4410
- M += 4, N += 2;
4411
- let P = V(M - 1, N - 1), oe = we(M - 1, N - 1);
4412
- function F(e, t, n, r) {
4413
- U(P, e, t, n, {
4450
+ let j = oe, M = 0;
4451
+ for (let e of A.values()) j = Math.max(j, e.x + e.width), M = Math.max(M, e.y + e.height);
4452
+ j += 4, M += 2;
4453
+ let N = B(j - 1, M - 1), se = Te(j - 1, M - 1);
4454
+ function P(e, t, n, r) {
4455
+ H(N, e, t, n, {
4414
4456
  role: r,
4415
- roleCanvas: oe
4457
+ roleCanvas: se
4416
4458
  });
4417
4459
  }
4418
- let se = i.hyperlinks ? A(M - 1, N - 1) : void 0;
4419
- for (let e of j.values()) {
4420
- let n = Ur(e.sections, c, t.boxBorderPadding);
4460
+ let F = i.hyperlinks ? k(j - 1, M - 1) : void 0;
4461
+ for (let e of A.values()) {
4462
+ let n = ai(e.sections, c, t.boxBorderPadding);
4421
4463
  for (let t = 0; t < n.length; t++) for (let r = 0; r < n[0].length; r++) {
4422
4464
  let i = n[t][r];
4423
4465
  if (i !== " ") {
4424
4466
  let n = e.x + t, a = e.y + r;
4425
- n < M && a < N && F(n, a, i, Vr(i));
4467
+ n < j && a < M && P(n, a, i, ri(i));
4426
4468
  }
4427
4469
  }
4428
- if (se) {
4470
+ if (F) {
4429
4471
  let t = l(o.interactions.get(e.cls.id)?.href), r = e.sections[0];
4430
4472
  if (t !== void 0 && r !== void 0) {
4431
4473
  let i = 1 + +!!e.cls.annotation;
4432
- ie(se, n, {
4474
+ ae(F, n, {
4433
4475
  x: e.x,
4434
4476
  y: e.y
4435
4477
  }, t, {
@@ -4440,65 +4482,65 @@ function hi(e, t, n, r, i = {}) {
4440
4482
  }
4441
4483
  }
4442
4484
  let ce = /* @__PURE__ */ new Set();
4443
- for (let e of j.values()) for (let t = 0; t < e.height; t++) for (let n = 0; n < e.width; n++) ce.add(`${e.x + n},${e.y + t}`);
4485
+ for (let e of A.values()) for (let t = 0; t < e.height; t++) for (let n = 0; n < e.width; n++) ce.add(`${e.x + n},${e.y + t}`);
4444
4486
  function I(e, t, n, r) {
4445
- ce.has(`${e},${t}`) || F(e, t, n, r);
4487
+ ce.has(`${e},${t}`) || P(e, t, n, r);
4446
4488
  }
4447
- function L(e, t, n) {
4448
- for (let [r, i] of j.entries()) if (!n?.has(r) && e >= i.x && e <= i.x + i.width - 1 && t >= i.y && t <= i.y + i.height - 1) return !0;
4489
+ function le(e, t, n) {
4490
+ for (let [r, i] of A.entries()) if (!n?.has(r) && e >= i.x && e <= i.x + i.width - 1 && t >= i.y && t <= i.y + i.height - 1) return !0;
4449
4491
  return !1;
4450
4492
  }
4451
- function le(e, t, n, r) {
4452
- return Yr(e, 0, e + M + 9, (e) => {
4453
- for (let i = Math.min(t, n); i <= Math.max(t, n); i++) if (L(e, i, r)) return !1;
4493
+ function ue(e, t, n, r) {
4494
+ return di(e, 0, e + j + 9, (e) => {
4495
+ for (let i = Math.min(t, n); i <= Math.max(t, n); i++) if (le(e, i, r)) return !1;
4454
4496
  return !0;
4455
- }) ?? M + 2;
4497
+ }) ?? j + 2;
4456
4498
  }
4457
- let R = c ? "-" : "─", ue = c ? "|" : "│", de = c ? "." : "╌", fe = c ? ":" : "┊";
4458
- function pe(e, t, n) {
4499
+ let de = c ? "-" : "─", L = c ? "|" : "│", fe = c ? "." : "╌", pe = c ? ":" : "┊";
4500
+ function me(e, t, n) {
4459
4501
  let r = Math.floor(n / 2), i = n - 1 - r, a = t > r + i ? (r + i) / t : 1;
4460
4502
  return Math.max(-r, Math.min(i, Math.round(e * a)));
4461
4503
  }
4462
- function me(e, t, n) {
4463
- let r = T.get(e) ?? D.get(e) ?? 0, i = T.get(e) ?? k.get(e) ?? 0, a = E.get(e) ?? O.get(e) ?? 0, o = E.get(e) ?? te.get(e) ?? 0, s = t.x + Math.floor(t.width / 2), c = n.x + Math.floor(n.width / 2);
4504
+ function he(e, t, n) {
4505
+ let r = T.get(e) ?? te.get(e) ?? 0, i = T.get(e) ?? O.get(e) ?? 0, a = E.get(e) ?? D.get(e) ?? 0, o = E.get(e) ?? ne.get(e) ?? 0, s = t.x + Math.floor(t.width / 2), c = n.x + Math.floor(n.width / 2);
4464
4506
  return {
4465
4507
  fromCX: s + r,
4466
4508
  toCX: c + i,
4467
- fromAnchorX: s + pe(r, a, t.width),
4468
- toAnchorX: c + pe(i, o, n.width)
4509
+ fromAnchorX: s + me(r, a, t.width),
4510
+ toAnchorX: c + me(i, o, n.width)
4469
4511
  };
4470
4512
  }
4471
- function he(e, t, n, r) {
4472
- if (ce.has(`${e},${t}`) || oe[e]?.[t] === "arrow") return;
4473
- let i = P[e]?.[t];
4474
- if (!c && i !== void 0 && Ae(i) && Ae(n)) {
4475
- let a = Me(i, n);
4476
- F(e, t, a, a === n ? r : "junction");
4513
+ function ge(e, t, n, r) {
4514
+ if (ce.has(`${e},${t}`) || se[e]?.[t] === "arrow") return;
4515
+ let i = N[e]?.[t];
4516
+ if (!c && i !== void 0 && U(i) && U(n)) {
4517
+ let a = W(i, n);
4518
+ P(e, t, a, a === n ? r : "junction");
4477
4519
  return;
4478
4520
  }
4479
- F(e, t, n, r);
4521
+ P(e, t, n, r);
4480
4522
  }
4481
- function ge(e, t, n, r, i) {
4523
+ function _e(e, t, n, r, i) {
4482
4524
  if (t === n) return;
4483
4525
  let a = Math.min(t, n), o = Math.max(t, n);
4484
- for (let t = a + 1; t < o; t++) he(t, e, r, "line");
4526
+ for (let t = a + 1; t < o; t++) ge(t, e, r, "line");
4485
4527
  if (c) {
4486
- he(t, e, r, "line"), he(n, e, r, "line");
4528
+ ge(t, e, r, "line"), ge(n, e, r, "line");
4487
4529
  return;
4488
4530
  }
4489
4531
  let s = n > t, l = i ? s ? "└" : "┘" : s ? "┌" : "┐", u = i ? s ? "┐" : "┌" : s ? "┘" : "└";
4490
- he(t, e, l, "corner"), he(n, e, u, "corner");
4532
+ ge(t, e, l, "corner"), ge(n, e, u, "corner");
4491
4533
  }
4492
- let _e = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map();
4534
+ let ve = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map();
4493
4535
  o.relationships.forEach((e, t) => {
4494
- let n = j.get(e.from), r = j.get(e.to);
4536
+ let n = A.get(e.from), r = A.get(e.to);
4495
4537
  if (!n || !r) return;
4496
- let i = di(e.type, e.markerAt), a = i.dashed ? de : R, o = i.dashed ? fe : ue, s = /* @__PURE__ */ new Set([e.from, e.to]), { fromCX: l, toCX: u, fromAnchorX: d, toAnchorX: f } = me(t, n, r), p = n.y + n.height - 1, m = r.y;
4538
+ let i = Di(e.type, e.markerAt), a = i.dashed ? fe : de, o = i.dashed ? pe : L, s = /* @__PURE__ */ new Set([e.from, e.to]), { fromCX: l, toCX: u, fromAnchorX: d, toAnchorX: f } = he(t, n, r), p = n.y + n.height - 1, m = r.y;
4497
4539
  if (p < m) {
4498
- let e = le(l, p + 1, m - 1, s), n = e !== l;
4499
- if (e >= M && Oe(P, e + 2, N), n) {
4540
+ let e = ue(l, p + 1, m - 1, s), n = e !== l;
4541
+ if (e >= j && ke(N, e + 2, M), n) {
4500
4542
  let n = p + 1, r = m - 1;
4501
- _e.set(t, {
4543
+ ve.set(t, {
4502
4544
  routeX: e,
4503
4545
  exitY: n,
4504
4546
  entryY: r,
@@ -4508,79 +4550,79 @@ function hi(e, t, n, r, i = {}) {
4508
4550
  });
4509
4551
  let s = Math.min(d, e), u = Math.max(d, e);
4510
4552
  for (let e = s; e <= u; e++) I(e, n, a, "line");
4511
- !c && n < (P[0]?.length ?? 0) && (d < e ? (I(d, n, "└", "corner"), I(e, n, "┐", "corner")) : (I(d, n, "┘", "corner"), I(e, n, "┌", "corner")));
4553
+ !c && n < (N[0]?.length ?? 0) && (d < e ? (I(d, n, "└", "corner"), I(e, n, "┐", "corner")) : (I(d, n, "┘", "corner"), I(e, n, "┌", "corner")));
4512
4554
  for (let t = n + 1; t <= r; t++) I(e, t, o, "line");
4513
4555
  if (e !== f) {
4514
4556
  let t = Math.min(e, f), n = Math.max(e, f);
4515
4557
  for (let e = t; e <= n; e++) I(e, r, a, "line");
4516
- !c && r < (P[0]?.length ?? 0) && (e < f ? (I(e, r, "└", "corner"), I(f, r, "┐", "corner")) : (I(e, r, "┘", "corner"), I(f, r, "┌", "corner")));
4558
+ !c && r < (N[0]?.length ?? 0) && (e < f ? (I(e, r, "└", "corner"), I(f, r, "┐", "corner")) : (I(e, r, "┘", "corner"), I(f, r, "┌", "corner")));
4517
4559
  }
4518
4560
  if (i.markerAt === "to") {
4519
4561
  let e = i.type === "inheritance" || i.type === "realization";
4520
- I(f, r, fi(i.type, c, e ? "up" : "down"), "arrow");
4562
+ I(f, r, Oi(i.type, c, e ? "up" : "down"), "arrow");
4521
4563
  }
4522
4564
  if (i.markerAt === "from") {
4523
- let e = fi(i.type, c, "down");
4565
+ let e = Oi(i.type, c, "down");
4524
4566
  I(d, p + 1, e, "arrow");
4525
4567
  }
4526
4568
  } else {
4527
4569
  let e = p + Math.floor((m - p) / 2), t = l !== d, n = u !== f;
4528
- ge(p + 1, d, l, a, !0);
4570
+ _e(p + 1, d, l, a, !0);
4529
4571
  for (let n = p + (t ? 2 : 1); n <= e; n++) I(l, n, o, "line");
4530
- if (l !== u && e < (P[0]?.length ?? 0)) {
4572
+ if (l !== u && e < (N[0]?.length ?? 0)) {
4531
4573
  let t = Math.min(l, u), n = Math.max(l, u);
4532
4574
  for (let r = t; r <= n; r++) I(r, e, a, "line");
4533
4575
  c || (I(l, e, l < u ? "└" : "┘", "corner"), I(u, e, l < u ? "┐" : "┌", "corner"));
4534
4576
  }
4535
4577
  for (let t = e + 1; t < m - +!!n; t++) I(u, t, o, "line");
4536
- if (ge(m - 1, f, u, a, !1), i.markerAt === "to") {
4578
+ if (_e(m - 1, f, u, a, !1), i.markerAt === "to") {
4537
4579
  let e = i.type === "inheritance" || i.type === "realization";
4538
- I(f, m - 1, fi(i.type, c, e ? "up" : "down"), "arrow");
4580
+ I(f, m - 1, Oi(i.type, c, e ? "up" : "down"), "arrow");
4539
4581
  }
4540
- i.markerAt === "from" && I(d, p + 1, fi(i.type, c, "down"), "arrow");
4582
+ i.markerAt === "from" && I(d, p + 1, Oi(i.type, c, "down"), "arrow");
4541
4583
  }
4542
4584
  } else if (r.y + r.height - 1 < n.y) {
4543
4585
  let e = n.y, t = r.y + r.height - 1, s = t + Math.floor((e - t) / 2), p = l !== d, m = u !== f;
4544
- ge(e - 1, d, l, a, !1);
4586
+ _e(e - 1, d, l, a, !1);
4545
4587
  for (let t = e - (p ? 2 : 1); t >= s; t--) I(l, t, o, "line");
4546
4588
  if (l !== u) {
4547
4589
  let e = Math.min(l, u), t = Math.max(l, u);
4548
4590
  for (let n = e; n <= t; n++) I(n, s, a, "line");
4549
- !c && s >= 0 && s < N && (I(l, s, l < u ? "┌" : "┐", "corner"), I(u, s, l < u ? "┘" : "└", "corner"));
4591
+ !c && s >= 0 && s < M && (I(l, s, l < u ? "┌" : "┐", "corner"), I(u, s, l < u ? "┘" : "└", "corner"));
4550
4592
  }
4551
4593
  for (let e = s - 1; e > t + +!!m; e--) I(u, e, o, "line");
4552
- if (ge(t + 1, f, u, a, !0), i.markerAt === "from") {
4553
- let t = fi(i.type, c, "up"), n = e - 1;
4594
+ if (_e(t + 1, f, u, a, !0), i.markerAt === "from") {
4595
+ let t = Oi(i.type, c, "up"), n = e - 1;
4554
4596
  for (let e = 0; e < t.length; e++) I(d - Math.floor(t.length / 2) + e, n, t[e], "arrow");
4555
4597
  }
4556
4598
  if (i.markerAt === "to") {
4557
- let e = i.type === "inheritance" || i.type === "realization" ? "down" : "up", n = fi(i.type, c, e), r = t + 1;
4599
+ let e = i.type === "inheritance" || i.type === "realization" ? "down" : "up", n = Oi(i.type, c, e), r = t + 1;
4558
4600
  for (let e = 0; e < n.length; e++) I(f - Math.floor(n.length / 2) + e, r, n[e], "arrow");
4559
4601
  }
4560
4602
  } else {
4561
4603
  let s = r.y + r.height - 1, m = Math.min(l, u), h = Math.max(l, u), g = Math.max(p, s);
4562
- for (let [t, r] of j.entries()) t !== e.from && t !== e.to && r.y === n.y && r.x < h + 1 && r.x + r.width > m && (g = Math.max(g, r.y + r.height - 1));
4604
+ for (let [t, r] of A.entries()) t !== e.from && t !== e.to && r.y === n.y && r.x < h + 1 && r.x + r.width > m && (g = Math.max(g, r.y + r.height - 1));
4563
4605
  let _ = g + 2;
4564
- ve.set(t, _), Oe(P, M, _ + 1), Te(oe, M, _ + 1);
4606
+ ye.set(t, _), ke(N, j, _ + 1), Ee(se, j, _ + 1);
4565
4607
  let v = l !== d, y = u !== f;
4566
- ge(p + 1, d, l, a, !0);
4608
+ _e(p + 1, d, l, a, !0);
4567
4609
  for (let e = p + (v ? 2 : 1); e <= _; e++) I(l, e, o, "line");
4568
4610
  for (let e = m; e <= h; e++) I(e, _, a, "line");
4569
4611
  for (let e = _ - 1; e >= s + (y ? 2 : 1); e--) I(u, e, o, "line");
4570
- if (ge(s + 1, f, u, a, !0), i.markerAt === "from") {
4571
- let e = fi(i.type, c, "down"), t = p + 1;
4612
+ if (_e(s + 1, f, u, a, !0), i.markerAt === "from") {
4613
+ let e = Oi(i.type, c, "down"), t = p + 1;
4572
4614
  for (let n = 0; n < e.length; n++) I(d - Math.floor(e.length / 2) + n, t, e[n], "arrow");
4573
4615
  }
4574
4616
  if (i.markerAt === "to") {
4575
- let e = i.type === "inheritance" || i.type === "realization", t = fi(i.type, c, e ? "down" : "up"), n = r.y + r.height;
4617
+ let e = i.type === "inheritance" || i.type === "realization", t = Oi(i.type, c, e ? "down" : "up"), n = r.y + r.height;
4576
4618
  for (let e = 0; e < t.length; e++) I(f - Math.floor(t.length / 2) + e, n, t[e], "arrow");
4577
4619
  }
4578
4620
  }
4579
4621
  });
4580
- function ye(e, t, n, r) {
4581
- let { fromCX: i, toCX: a } = me(e, t, n), o = t.y + t.height - 1, s = n.y;
4622
+ function be(e, t, n, r) {
4623
+ let { fromCX: i, toCX: a } = he(e, t, n), o = t.y + t.height - 1, s = n.y;
4582
4624
  if (o < s) {
4583
- let t = _e.get(e);
4625
+ let t = ve.get(e);
4584
4626
  if (t) {
4585
4627
  let e = t.exitY + 1, n = t.entryY;
4586
4628
  if (n >= e) return {
@@ -4611,14 +4653,14 @@ function hi(e, t, n, r, i = {}) {
4611
4653
  return {
4612
4654
  idealMidX: Math.floor((i + a) / 2),
4613
4655
  /* v8 ignore next */
4614
- baseMidY: ve.get(e) ?? Math.max(o, n.y + n.height - 1) + 2
4656
+ baseMidY: ye.get(e) ?? Math.max(o, n.y + n.height - 1) + 2
4615
4657
  };
4616
4658
  }
4617
- function z(e, t, n, r, i, a, o) {
4659
+ function xe(e, t, n, r, i, a, o) {
4618
4660
  let s = r, c = Math.floor(a / 2), l = e.y + e.height - 1, u = t.y, d = !1;
4619
4661
  for (let e = 0; e < a; e++) {
4620
4662
  let t = s - c + e, r = n - Math.floor(i / 2), a = Math.max(0, r);
4621
- for (let e = a; e < a + i; e++) if (L(e, t, o)) {
4663
+ for (let e = a; e < a + i; e++) if (le(e, t, o)) {
4622
4664
  d = !0;
4623
4665
  break;
4624
4666
  }
@@ -4628,7 +4670,7 @@ function hi(e, t, n, r, i = {}) {
4628
4670
  let e = l + 1, t = u - 1;
4629
4671
  for (let r = e; r <= t; r++) {
4630
4672
  let e = !0, t = n - Math.floor(i / 2), a = Math.max(0, t);
4631
- for (let t = a; t < a + i; t++) if (L(t, r, o)) {
4673
+ for (let t = a; t < a + i; t++) if (le(t, r, o)) {
4632
4674
  e = !1;
4633
4675
  break;
4634
4676
  }
@@ -4640,15 +4682,15 @@ function hi(e, t, n, r, i = {}) {
4640
4682
  }
4641
4683
  return s;
4642
4684
  }
4643
- let be = /* @__PURE__ */ new Map(), xe = [];
4685
+ let R = /* @__PURE__ */ new Map(), Se = [];
4644
4686
  for (let [e, t] of o.relationships.entries()) {
4645
4687
  if (!t.label) continue;
4646
- let n = j.get(t.from), r = j.get(t.to);
4688
+ let n = A.get(t.from), r = A.get(t.to);
4647
4689
  if (!n || !r) continue;
4648
- let i = Q(t.label), a = Math.floor(i.length / 2), o = Math.max(...i.map(B)) + 2, { idealMidX: s, baseMidY: c } = ye(e, n, r, o), l = /* @__PURE__ */ new Set([t.from, t.to]), u = z(n, r, s, c, o, i.length, l);
4649
- be.set(t, u);
4690
+ let i = Q(t.label), a = Math.floor(i.length / 2), o = Math.max(...i.map(z)) + 2, { idealMidX: s, baseMidY: c } = be(e, n, r, o), l = /* @__PURE__ */ new Set([t.from, t.to]), u = xe(n, r, s, c, o, i.length, l);
4691
+ R.set(t, u);
4650
4692
  let d = Math.max(0, s - Math.floor(o / 2));
4651
- xe.push({
4693
+ Se.push({
4652
4694
  rel: t,
4653
4695
  idealMidX: s,
4654
4696
  naturalStart: d,
@@ -4657,39 +4699,39 @@ function hi(e, t, n, r, i = {}) {
4657
4699
  rowEnd: u + a
4658
4700
  });
4659
4701
  }
4660
- let Se = li(xe, (e) => ({
4702
+ let Ce = Ti(Se, (e) => ({
4661
4703
  idealMid: e.idealMidX,
4662
4704
  start: e.naturalStart,
4663
4705
  end: e.naturalEnd,
4664
4706
  rowStart: e.rowStart,
4665
4707
  rowEnd: e.rowEnd
4666
- })), H = /* @__PURE__ */ new Map();
4667
- for (let e of xe) {
4668
- let t = Se.get(e);
4669
- t && H.set(e.rel, t);
4708
+ })), V = /* @__PURE__ */ new Map();
4709
+ for (let e of Se) {
4710
+ let t = Ce.get(e);
4711
+ t && V.set(e.rel, t);
4670
4712
  }
4671
4713
  for (let [e, t] of o.relationships.entries()) {
4672
- let n = j.get(t.from), r = j.get(t.to);
4714
+ let n = A.get(t.from), r = A.get(t.to);
4673
4715
  if (!(!n || !r) && t.label) {
4674
- let i = Q(t.label), { idealMidX: a } = ye(e, n, r, Math.max(...i.map((e) => B(e))) + 2), o = be.get(t) - Math.floor(i.length / 2), s = H.get(t);
4716
+ let i = Q(t.label), { idealMidX: a } = be(e, n, r, Math.max(...i.map((e) => z(e))) + 2), o = R.get(t) - Math.floor(i.length / 2), s = V.get(t);
4675
4717
  for (let e = 0; e < i.length; e++) {
4676
- let t = o + e, n = i[e], r = Ce(` ${n} `), { start: c, cells: l } = pi(Math.max(0, a - Math.floor(r.length / 2)), r, n, Math.max(0, s.left), s.right), u = c + l.length;
4677
- u > 0 && t >= 0 && (Oe(P, Math.max(u, 1), Math.max(t + 1, 1)), Te(oe, Math.max(u, 1), Math.max(t + 1, 1)));
4718
+ let t = o + e, n = i[e], r = we(` ${n} `), { start: c, cells: l } = ki(Math.max(0, a - Math.floor(r.length / 2)), r, n, Math.max(0, s.left), s.right), u = c + l.length;
4719
+ u > 0 && t >= 0 && (ke(N, Math.max(u, 1), Math.max(t + 1, 1)), Ee(se, Math.max(u, 1), Math.max(t + 1, 1)));
4678
4720
  for (let e = 0; e < l.length; e++) {
4679
4721
  let n = c + e;
4680
- n >= 0 && t >= 0 && F(n, t, l[e], "text");
4722
+ n >= 0 && t >= 0 && P(n, t, l[e], "text");
4681
4723
  }
4682
4724
  }
4683
4725
  }
4684
4726
  }
4685
- return vi(s, j, P, c, F), Fe(P, {
4686
- roleCanvas: oe,
4727
+ return Pi(s, A, N, c, P), Fe(N, {
4728
+ roleCanvas: se,
4687
4729
  colorMode: n,
4688
4730
  theme: r,
4689
- linkCanvas: se
4731
+ linkCanvas: F
4690
4732
  });
4691
4733
  }
4692
- function gi(e) {
4734
+ function Mi(e) {
4693
4735
  let t = /* @__PURE__ */ new Map();
4694
4736
  if (e.notes.length === 0) return {
4695
4737
  diagram: e,
@@ -4717,14 +4759,14 @@ function gi(e) {
4717
4759
  notesById: t
4718
4760
  };
4719
4761
  }
4720
- function _i(e, t) {
4762
+ function Ni(e, t) {
4721
4763
  for (let [n, r] of e) {
4722
4764
  if (r.forClass === void 0) continue;
4723
4765
  let e = t.get(r.forClass);
4724
4766
  e !== void 0 && t.set(n, e);
4725
4767
  }
4726
4768
  }
4727
- function vi(e, t, n, r, i) {
4769
+ function Pi(e, t, n, r, i) {
4728
4770
  if (e.size === 0) return;
4729
4771
  let a = cn("rounded", r), o = r ? "." : "╌";
4730
4772
  for (let [r, s] of e) {
@@ -4740,12 +4782,12 @@ function vi(e, t, n, r, i) {
4740
4782
  }
4741
4783
  //#endregion
4742
4784
  //#region src/parser.ts
4743
- function yi(e) {
4785
+ function Fi(e) {
4744
4786
  let t = e.trim();
4745
4787
  return t.length >= 2 && (t[0] === "\"" && t[t.length - 1] === "\"" || t[0] === "'" && t[t.length - 1] === "'") ? t.slice(1, -1) : t;
4746
4788
  }
4747
- var bi = "\"graph <dir>\"/\"flowchart <dir>\" (dir: TD, TB, LR, BT, RL), \"stateDiagram-v2\", \"sequenceDiagram\", \"classDiagram\", \"erDiagram\", \"xychart-beta\"";
4748
- function xi(e) {
4789
+ var Ii = "\"graph <dir>\"/\"flowchart <dir>\" (dir: TD, TB, LR, BT, RL), \"stateDiagram-v2\", \"sequenceDiagram\", \"classDiagram\", \"erDiagram\", \"xychart-beta\"";
4790
+ function Li(e) {
4749
4791
  let t = e.trim().toLowerCase();
4750
4792
  if (/^sequence/.test(t)) return "sequenceDiagram";
4751
4793
  if (/^class/.test(t)) return "classDiagram";
@@ -4753,11 +4795,11 @@ function xi(e) {
4753
4795
  if (/^xychart/.test(t)) return "xychart-beta";
4754
4796
  if (/^state/.test(t)) return "stateDiagram-v2";
4755
4797
  }
4756
- var Si = /^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;
4757
- function Ci(e) {
4798
+ var Ri = /^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;
4799
+ function zi(e) {
4758
4800
  let t = [];
4759
4801
  for (let n of e) n.forEach((e, n) => {
4760
- if (n === 0 && t.length > 0 && Si.test(e.text)) {
4802
+ if (n === 0 && t.length > 0 && Ri.test(e.text)) {
4761
4803
  let n = t[t.length - 1];
4762
4804
  t[t.length - 1] = {
4763
4805
  text: `${n.text} ${e.text}`,
@@ -4767,13 +4809,13 @@ function Ci(e) {
4767
4809
  });
4768
4810
  return t;
4769
4811
  }
4770
- function wi(e) {
4771
- let t = r(e.split("\n").map((e) => e.trim())), n = Ci(d(e));
4812
+ function Bi(e) {
4813
+ let t = r(e.split("\n").map((e) => e.trim())), n = zi(d(e));
4772
4814
  if (n.length === 0) throw Error("Empty mermaid diagram");
4773
- let i = n[0], a = /^stateDiagram(-v2)?\s*$/i.test(i.text) ? Ei(n) : Ti(n);
4815
+ let i = n[0], a = /^stateDiagram(-v2)?\s*$/i.test(i.text) ? Hi(n) : Vi(n);
4774
4816
  return a.initConfig = t, a;
4775
4817
  }
4776
- function Ti(e) {
4818
+ function Vi(e) {
4777
4819
  let t = e[0];
4778
4820
  if (t === void 0)
4779
4821
  /* v8 ignore next */
@@ -4785,8 +4827,8 @@ function Ti(e) {
4785
4827
  let r = e[1].trim();
4786
4828
  throw Error(r.length > 0 ? `Line ${t.line}: Invalid direction "${r}" in header "${n}". Expected one of: TD, TB, LR, BT, RL.` : `Line ${t.line}: Missing direction in header "${n}". Expected e.g. "graph TD" or "flowchart LR" — one of: TD, TB, LR, BT, RL.`);
4787
4829
  }
4788
- let r = xi(n), i = r && r.toLowerCase() !== n.trim().toLowerCase() ? ` Did you mean "${r}"?` : "";
4789
- throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${bi}.`);
4830
+ let r = Li(n), i = r && r.toLowerCase() !== n.trim().toLowerCase() ? ` Did you mean "${r}"?` : "";
4831
+ throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${Ii}.`);
4790
4832
  }
4791
4833
  let i = {
4792
4834
  direction: p(r[1]),
@@ -4803,10 +4845,10 @@ function Ti(e) {
4803
4845
  let n = e[t].text;
4804
4846
  if (h(n, i) || m(n, i) || g(n, i)) continue;
4805
4847
  if (/^click\s+/i.test(n)) {
4806
- Ri(n, i);
4848
+ ea(n, i);
4807
4849
  continue;
4808
4850
  }
4809
- if (Bi(n, i)) continue;
4851
+ if (na(n, i)) continue;
4810
4852
  let r = n.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
4811
4853
  if (r) {
4812
4854
  let e = r[1].trim(), t = c(r[2]);
@@ -4831,7 +4873,7 @@ function Ti(e) {
4831
4873
  let l = n.match(/^subgraph\s+(.+)$/);
4832
4874
  if (l) {
4833
4875
  let e = l[1].trim(), t = e.match(/^([^\s[]+)\s*\[(.+)\]$/), n, r;
4834
- t ? (n = t[1], r = o(yi(t[2]))) : (r = o(yi(e)), n = r.replace(/\s+/g, "_").replace(/[^\p{L}\p{N}_-]/gu, ""));
4876
+ t ? (n = t[1], r = o(Fi(t[2]))) : (r = o(Fi(e)), n = r.replace(/\s+/g, "_").replace(/[^\p{L}\p{N}_-]/gu, ""));
4835
4877
  let i = {
4836
4878
  id: n,
4837
4879
  label: r,
@@ -4846,11 +4888,11 @@ function Ti(e) {
4846
4888
  e && (a.length > 0 ? a[a.length - 1].children.push(e) : i.subgraphs.push(e));
4847
4889
  continue;
4848
4890
  }
4849
- Wi(n, i, a);
4891
+ oa(n, i, a);
4850
4892
  }
4851
4893
  return i;
4852
4894
  }
4853
- function Ei(e) {
4895
+ function Hi(e) {
4854
4896
  let t = {
4855
4897
  direction: "TD",
4856
4898
  nodes: /* @__PURE__ */ new Map(),
@@ -4884,7 +4926,7 @@ function Ei(e) {
4884
4926
  }
4885
4927
  continue;
4886
4928
  }
4887
- if (Bi(l, t)) continue;
4929
+ if (na(l, t)) continue;
4888
4930
  let f = l.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);
4889
4931
  if (f) {
4890
4932
  let e = f[1] ?? f[2], i = f[2], a = {
@@ -4904,7 +4946,7 @@ function Ei(e) {
4904
4946
  let m = l.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);
4905
4947
  if (m) {
4906
4948
  let e = o(m[1]), r = m[2];
4907
- Di(t, n, {
4949
+ Ui(t, n, {
4908
4950
  id: r,
4909
4951
  label: e,
4910
4952
  shape: "rounded"
@@ -4914,15 +4956,15 @@ function Ei(e) {
4914
4956
  let h = l.match(/^(\[\*\]|[\w\p{L}-]+)\s*(?:([\w-]+)@)?-->\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);
4915
4957
  if (h) {
4916
4958
  let e = h[1], s = h[2], c = h[3], l = h[4]?.trim(), u = l ? o(l) : void 0;
4917
- e === "[*]" ? (i++, e = `_start${i > 1 ? i : ""}`, Di(t, n, {
4959
+ e === "[*]" ? (i++, e = `_start${i > 1 ? i : ""}`, Ui(t, n, {
4918
4960
  id: e,
4919
4961
  label: "",
4920
4962
  shape: "state-start"
4921
- })) : r.has(e) || Oi(t, n, e), c === "[*]" ? (a++, c = `_end${a > 1 ? a : ""}`, Di(t, n, {
4963
+ })) : r.has(e) || Wi(t, n, e), c === "[*]" ? (a++, c = `_end${a > 1 ? a : ""}`, Ui(t, n, {
4922
4964
  id: c,
4923
4965
  label: "",
4924
4966
  shape: "state-end"
4925
- })) : r.has(c) || Oi(t, n, c), t.edges.push({
4967
+ })) : r.has(c) || Wi(t, n, c), t.edges.push({
4926
4968
  source: e,
4927
4969
  target: c,
4928
4970
  label: u,
@@ -4936,7 +4978,7 @@ function Ei(e) {
4936
4978
  let g = l.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);
4937
4979
  if (g) {
4938
4980
  let e = g[1];
4939
- Di(t, n, {
4981
+ Ui(t, n, {
4940
4982
  id: e,
4941
4983
  label: o(g[2].trim()),
4942
4984
  shape: "rounded"
@@ -4946,14 +4988,14 @@ function Ei(e) {
4946
4988
  }
4947
4989
  return t;
4948
4990
  }
4949
- function Di(e, t, n) {
4991
+ function Ui(e, t, n) {
4950
4992
  if (e.nodes.has(n.id) || e.nodes.set(n.id, n), t.length > 0) {
4951
4993
  let e = t[t.length - 1];
4952
4994
  e.nodeIds.includes(n.id) || e.nodeIds.push(n.id);
4953
4995
  }
4954
4996
  }
4955
- function Oi(e, t, n) {
4956
- if (!e.nodes.has(n)) Di(e, t, {
4997
+ function Wi(e, t, n) {
4998
+ if (!e.nodes.has(n)) Ui(e, t, {
4957
4999
  id: n,
4958
5000
  label: n,
4959
5001
  shape: "rounded"
@@ -4963,12 +5005,12 @@ function Oi(e, t, n) {
4963
5005
  e.nodeIds.includes(n) || e.nodeIds.push(n);
4964
5006
  }
4965
5007
  }
4966
- var ki = /^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\|([^|]*)\|)?/, Ai = /* @__PURE__ */ new Set(["--", "=="]);
4967
- function ji(e) {
5008
+ var Gi = /^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\|([^|]*)\|)?/, Ki = /* @__PURE__ */ new Set(["--", "=="]);
5009
+ function qi(e) {
4968
5010
  if (e === "o") return "circle";
4969
5011
  if (e === "x") return "cross";
4970
5012
  }
4971
- var Mi = /^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/, Ni = [
5013
+ var Ji = /^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/, Yi = [
4972
5014
  {
4973
5015
  regex: /^([\w\p{L}-]+)\(\(\(((?:"[^"]*"|(?!\)\)\)).)+)\)\)\)/u,
4974
5016
  shape: "doublecircle"
@@ -5017,8 +5059,8 @@ var Mi = /^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|
5017
5059
  regex: /^([\w\p{L}-]+)\{((?:"[^"]*"|(?!\}).)+)\}/u,
5018
5060
  shape: "diamond"
5019
5061
  }
5020
- ], Pi = /^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u, Fi = /^([\w\p{L}-]+)(?=@\{)/u;
5021
- function Ii(e) {
5062
+ ], Xi = /^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u, Zi = /^([\w\p{L}-]+)(?=@\{)/u;
5063
+ function Qi(e) {
5022
5064
  if (e.shape) return E(e.shape) ?? "rectangle";
5023
5065
  if (e.icon !== void 0 || e.img !== void 0) switch (e.form?.toLowerCase()) {
5024
5066
  case "circle": return "circle";
@@ -5027,46 +5069,46 @@ function Ii(e) {
5027
5069
  }
5028
5070
  return "rectangle";
5029
5071
  }
5030
- function Li(e, t) {
5072
+ function $i(e, t) {
5031
5073
  return t.label !== void 0 && t.label.length > 0 ? t.label : t.icon ? t.icon : t.img ? t.img : e;
5032
5074
  }
5033
- function Ri(e, n) {
5075
+ function ea(e, n) {
5034
5076
  t(e, n.interactions);
5035
5077
  }
5036
- var zi = /^([\w-]+)(?=@\{)/;
5037
- function Bi(e, t) {
5038
- let n = e.match(zi);
5078
+ var ta = /^([\w-]+)(?=@\{)/;
5079
+ function na(e, t) {
5080
+ let n = e.match(ta);
5039
5081
  if (!n || !t.edges.some((e) => e.id === n[1])) return !1;
5040
5082
  let r = x(e.slice(n[1].length));
5041
- return r ? (Vi(t, n[1], w(r.body)), !0) : !1;
5083
+ return r ? (ra(t, n[1], w(r.body)), !0) : !1;
5042
5084
  }
5043
- function Vi(e, t, n) {
5085
+ function ra(e, t, n) {
5044
5086
  for (let r of e.edges) r.id === t && (n.animate !== void 0 && (r.animate = n.animate.toLowerCase() !== "false"), n.animation !== void 0 && (r.animate = !0));
5045
5087
  }
5046
- var Hi = /^:::([\w][\w-]*)/, Ui = /^([\w\p{L}-]+):::([\w][\w-]*)/u;
5047
- function Wi(e, t, n) {
5048
- let r = e.trim(), i = Gi(r, t, n);
5088
+ var ia = /^:::([\w][\w-]*)/, aa = /^([\w\p{L}-]+):::([\w][\w-]*)/u;
5089
+ function oa(e, t, n) {
5090
+ let r = e.trim(), i = sa(r, t, n);
5049
5091
  if (!i || i.ids.length === 0) return;
5050
5092
  r = i.remaining.trim();
5051
5093
  let a = i.ids;
5052
5094
  for (; r.length > 0;) {
5053
5095
  let e, i, s, c, l, u, d, f = r.match(/^([\w-]+)@(?=[-=<~ox])/);
5054
5096
  f && (d = f[1], r = r.slice(f[0].length));
5055
- let p = r.match(ki), m = p?.[2], h = p?.[1], g = p?.[3];
5056
- if (p && m !== void 0 && !(h === void 0 && g === void 0 && Ai.has(m))) {
5057
- e = h !== void 0, l = ji(h);
5097
+ let p = r.match(Gi), m = p?.[2], h = p?.[1], g = p?.[3];
5098
+ if (p && m !== void 0 && !(h === void 0 && g === void 0 && Ki.has(m))) {
5099
+ e = h !== void 0, l = qi(h);
5058
5100
  let t = p[4]?.trim();
5059
- c = t ? o(t) : void 0, r = r.slice(p[0].length).trim(), i = Yi(m), s = g !== void 0, u = ji(g);
5101
+ c = t ? o(t) : void 0, r = r.slice(p[0].length).trim(), i = da(m), s = g !== void 0, u = qi(g);
5060
5102
  } else {
5061
- let t = r.match(Mi);
5103
+ let t = r.match(Ji);
5062
5104
  if (!t) break;
5063
- e = !!t[1], l = ji(t[1]);
5105
+ e = !!t[1], l = qi(t[1]);
5064
5106
  let n = t[3].trim();
5065
5107
  c = n ? o(n) : void 0;
5066
5108
  let a = t[2], d = t[4];
5067
- r = r.slice(t[0].length).trim(), i = Xi(a, d), u = ji(d.slice(-1)), s = d.endsWith(">") || u !== void 0;
5109
+ r = r.slice(t[0].length).trim(), i = fa(a, d), u = qi(d.slice(-1)), s = d.endsWith(">") || u !== void 0;
5068
5110
  }
5069
- let _ = Gi(r, t, n);
5111
+ let _ = sa(r, t, n);
5070
5112
  if (!_ || _.ids.length === 0) break;
5071
5113
  r = _.remaining.trim();
5072
5114
  for (let n of a) for (let r of _.ids) t.edges.push({
@@ -5083,13 +5125,13 @@ function Wi(e, t, n) {
5083
5125
  a = _.ids;
5084
5126
  }
5085
5127
  }
5086
- function Gi(e, t, n) {
5087
- let r = Ki(e, t, n);
5128
+ function sa(e, t, n) {
5129
+ let r = ca(e, t, n);
5088
5130
  if (!r) return null;
5089
5131
  let i = [r.id], a = r.remaining.trim();
5090
5132
  for (; a.startsWith("&");) {
5091
5133
  a = a.slice(1).trim();
5092
- let e = Ki(a, t, n);
5134
+ let e = ca(a, t, n);
5093
5135
  if (!e) break;
5094
5136
  i.push(e.id), a = e.remaining.trim();
5095
5137
  }
@@ -5098,27 +5140,27 @@ function Gi(e, t, n) {
5098
5140
  remaining: a
5099
5141
  };
5100
5142
  }
5101
- function Ki(e, t, n) {
5102
- let r = null, i = e, a, s = i.match(Ui);
5143
+ function ca(e, t, n) {
5144
+ let r = null, i = e, a, s = i.match(aa);
5103
5145
  s && (a = s[2], i = s[1] + i.slice(s[0].length));
5104
- let c = i.match(Fi);
5146
+ let c = i.match(Zi);
5105
5147
  if (c) {
5106
5148
  let e = c[1], a = x(i.slice(e.length));
5107
5149
  if (a) {
5108
5150
  let s = w(a.body);
5109
- qi(t, n, {
5151
+ la(t, n, {
5110
5152
  id: e,
5111
- label: o(Li(e, s)),
5112
- shape: Ii(s)
5153
+ label: o($i(e, s)),
5154
+ shape: Qi(s)
5113
5155
  }), r = e, i = i.slice(e.length + a.length);
5114
5156
  }
5115
5157
  }
5116
- if (r === null) for (let { regex: e, shape: a } of Ni) {
5158
+ if (r === null) for (let { regex: e, shape: a } of Yi) {
5117
5159
  let s = i.match(e);
5118
5160
  if (s) {
5119
5161
  r = s[1];
5120
5162
  let e = o(s[2]), c = typeof a == "function" ? a(s[3] ?? "") : a;
5121
- qi(t, n, {
5163
+ la(t, n, {
5122
5164
  id: r,
5123
5165
  label: e,
5124
5166
  shape: c
@@ -5127,8 +5169,8 @@ function Ki(e, t, n) {
5127
5169
  }
5128
5170
  }
5129
5171
  if (r === null) {
5130
- let e = i.match(Pi);
5131
- e && (r = e[1], t.nodes.has(r) || qi(t, n, {
5172
+ let e = i.match(Xi);
5173
+ e && (r = e[1], t.nodes.has(r) || la(t, n, {
5132
5174
  id: r,
5133
5175
  label: r,
5134
5176
  shape: "rectangle"
@@ -5136,32 +5178,32 @@ function Ki(e, t, n) {
5136
5178
  }
5137
5179
  if (r === null) return null;
5138
5180
  a && t.classAssignments.set(r, a);
5139
- let l = i.match(Hi);
5181
+ let l = i.match(ia);
5140
5182
  return l && (t.classAssignments.set(r, l[1]), i = i.slice(l[0].length)), {
5141
5183
  id: r,
5142
5184
  remaining: i
5143
5185
  };
5144
5186
  }
5145
- function qi(e, t, n) {
5146
- e.nodes.has(n.id) || e.nodes.set(n.id, n), Ji(t, n.id);
5187
+ function la(e, t, n) {
5188
+ e.nodes.has(n.id) || e.nodes.set(n.id, n), ua(t, n.id);
5147
5189
  }
5148
- function Ji(e, t) {
5190
+ function ua(e, t) {
5149
5191
  if (e.length > 0) {
5150
5192
  let n = e[e.length - 1];
5151
5193
  n.nodeIds.includes(t) || n.nodeIds.push(t);
5152
5194
  }
5153
5195
  }
5154
- function Yi(e) {
5196
+ function da(e) {
5155
5197
  return e.startsWith("~") ? "invisible" : e.includes(".") ? "dotted" : e.startsWith("=") ? "thick" : "solid";
5156
5198
  }
5157
- function Xi(e, t) {
5199
+ function fa(e, t) {
5158
5200
  return e.includes(".") || t.includes(".") ? "dotted" : e.startsWith("=") || t.startsWith("=") ? "thick" : "solid";
5159
5201
  }
5160
5202
  //#endregion
5161
5203
  //#region packages/ascii-renderer/src/converter.ts
5162
- function Zi(e, t) {
5204
+ function pa(e, t) {
5163
5205
  let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
5164
- for (let t of e.subgraphs) Qi(t, n, r);
5206
+ for (let t of e.subgraphs) ma(t, n, r);
5165
5207
  let i = /* @__PURE__ */ new Map(), a = 0;
5166
5208
  for (let [t, r] of e.nodes) {
5167
5209
  if (n.has(t)) continue;
@@ -5183,11 +5225,11 @@ function Zi(e, t) {
5183
5225
  for (let t of e.edges) {
5184
5226
  let a = t.source, o = t.target;
5185
5227
  if (n.has(a)) {
5186
- let t = r.get(a), n = t ? ta(t, e, "exit") : void 0;
5228
+ let t = r.get(a), n = t ? _a(t, e, "exit") : void 0;
5187
5229
  n && (a = n);
5188
5230
  }
5189
5231
  if (n.has(o)) {
5190
- let t = r.get(o), n = t ? ta(t, e, "entry") : void 0;
5232
+ let t = r.get(o), n = t ? _a(t, e, "entry") : void 0;
5191
5233
  n && (o = n);
5192
5234
  }
5193
5235
  let c = i.get(a), l = i.get(o);
@@ -5213,8 +5255,8 @@ function Zi(e, t) {
5213
5255
  });
5214
5256
  }
5215
5257
  let c = [];
5216
- for (let t of e.subgraphs) na(t, null, i, c, e);
5217
- ra(e.subgraphs, c, i);
5258
+ for (let t of e.subgraphs) va(t, null, i, c, e);
5259
+ ya(e.subgraphs, c, i);
5218
5260
  let l = e.classDefs.get("default");
5219
5261
  if (l) for (let e of i.values()) e.styleClassName = "default", e.styleClass = {
5220
5262
  name: "default",
@@ -5233,8 +5275,8 @@ function Zi(e, t) {
5233
5275
  return {
5234
5276
  nodes: o,
5235
5277
  edges: s,
5236
- canvas: V(0, 0),
5237
- roleCanvas: we(0, 0),
5278
+ canvas: B(0, 0),
5279
+ roleCanvas: Te(0, 0),
5238
5280
  grid: Tt(),
5239
5281
  columnWidth: /* @__PURE__ */ new Map(),
5240
5282
  rowHeight: /* @__PURE__ */ new Map(),
@@ -5245,31 +5287,31 @@ function Zi(e, t) {
5245
5287
  bundles: []
5246
5288
  };
5247
5289
  }
5248
- function Qi(e, t, n) {
5290
+ function ma(e, t, n) {
5249
5291
  t.add(e.id), n.set(e.id, e);
5250
- for (let r of e.children) Qi(r, t, n);
5292
+ for (let r of e.children) ma(r, t, n);
5251
5293
  }
5252
- function $i(e, t) {
5294
+ function ha(e, t) {
5253
5295
  for (let n of e.nodeIds) t.add(n);
5254
- for (let n of e.children) $i(n, t);
5296
+ for (let n of e.children) ha(n, t);
5255
5297
  }
5256
- function ea(e, t) {
5298
+ function ga(e, t) {
5257
5299
  let n = /* @__PURE__ */ new Set();
5258
- if ($i(e, n), n.size === 0) return !0;
5300
+ if (ha(e, n), n.size === 0) return !0;
5259
5301
  let r = (t) => n.has(t) || t === e.id;
5260
5302
  return !t.edges.some((e) => r(e.source) !== r(e.target));
5261
5303
  }
5262
- function ta(e, t, n) {
5304
+ function _a(e, t, n) {
5263
5305
  let r = /* @__PURE__ */ new Set();
5264
- if ($i(e, r), r.size === 0) return;
5306
+ if (ha(e, r), r.size === 0) return;
5265
5307
  let i = [...t.nodes.keys()].filter((e) => r.has(e));
5266
5308
  if (i.length === 0) return;
5267
5309
  let a = i.filter((e) => n === "entry" ? !t.edges.some((t) => t.target === e && r.has(t.source)) : !t.edges.some((t) => t.source === e && r.has(t.target))), o = a.length > 0 ? a : i;
5268
5310
  return n === "entry" ? o[0] : o[o.length - 1];
5269
5311
  }
5270
- function na(e, t, n, r, i) {
5312
+ function va(e, t, n, r, i) {
5271
5313
  let a;
5272
- e.direction && ea(e, i) && (a = e.direction === "LR" || e.direction === "RL" ? "LR" : "TD");
5314
+ e.direction && ga(e, i) && (a = e.direction === "LR" || e.direction === "RL" ? "LR" : "TD");
5273
5315
  let o = {
5274
5316
  name: e.label,
5275
5317
  nodes: [],
@@ -5287,15 +5329,15 @@ function na(e, t, n, r, i) {
5287
5329
  }
5288
5330
  r.push(o);
5289
5331
  for (let t of e.children) {
5290
- let e = na(t, o, n, r, i);
5332
+ let e = va(t, o, n, r, i);
5291
5333
  o.children.push(e);
5292
5334
  for (let t of e.nodes) o.nodes.includes(t) || o.nodes.push(t);
5293
5335
  }
5294
5336
  return o;
5295
5337
  }
5296
- function ra(e, t, n) {
5338
+ function ya(e, t, n) {
5297
5339
  let r = /* @__PURE__ */ new Map();
5298
- aa(e, t, r);
5340
+ xa(e, t, r);
5299
5341
  let i = /* @__PURE__ */ new Map();
5300
5342
  function a(e) {
5301
5343
  let t = r.get(e);
@@ -5313,10 +5355,10 @@ function ra(e, t, n) {
5313
5355
  }
5314
5356
  if (!r) return !1;
5315
5357
  let a = i.get(r);
5316
- return !a || ia(e, a);
5358
+ return !a || ba(e, a);
5317
5359
  });
5318
5360
  }
5319
- function ia(e, t) {
5361
+ function ba(e, t) {
5320
5362
  let n = t;
5321
5363
  for (; n !== null;) {
5322
5364
  if (n === e) return !0;
@@ -5324,7 +5366,7 @@ function ia(e, t) {
5324
5366
  }
5325
5367
  return !1;
5326
5368
  }
5327
- function aa(e, t, n) {
5369
+ function xa(e, t, n) {
5328
5370
  let r = [];
5329
5371
  function i(e) {
5330
5372
  for (let t of e) r.push(t), i(t.children);
@@ -5337,13 +5379,13 @@ function aa(e, t, n) {
5337
5379
  }
5338
5380
  //#endregion
5339
5381
  //#region packages/ascii-renderer/src/flowchart.ts
5340
- function oa(e, t, n, r, i = {}) {
5341
- let a = _(wi(e), i.direction);
5382
+ function Sa(e, t, n, r, i = {}) {
5383
+ let a = _(Bi(e), i.direction);
5342
5384
  t.graphDirection = a.direction === "LR" || a.direction === "RL" ? "LR" : "TD";
5343
- let o = Zi(a, t);
5344
- Hn(o), Jr(o);
5345
- let s = i.hyperlinks ? ae(o, a.interactions) : void 0;
5346
- return a.direction === "BT" && (Le(o.canvas), Re(o.roleCanvas), s && re(s)), Fe(o.canvas, {
5385
+ let o = pa(a, t);
5386
+ ir(o), ui(o);
5387
+ let s = i.hyperlinks ? oe(o, a.interactions) : void 0;
5388
+ return a.direction === "BT" && (Le(o.canvas), Re(o.roleCanvas), s && ie(s)), Fe(o.canvas, {
5347
5389
  roleCanvas: o.roleCanvas,
5348
5390
  colorMode: n,
5349
5391
  theme: r,
@@ -5352,15 +5394,15 @@ function oa(e, t, n, r, i = {}) {
5352
5394
  }
5353
5395
  //#endregion
5354
5396
  //#region packages/ascii-renderer/src/registry.ts
5355
- var sa = {
5397
+ var Ca = {
5356
5398
  xychart: (e, t, n, r) => Je(e, t, n, r),
5357
- er: (e, t, n, r) => ti(e, t, n, r),
5358
- sequence: (e, t, n, r) => si(e, t, n, r),
5359
- class: (e, t, n, r, i) => hi(e, t, n, r, i),
5360
- flowchart: (e, t, n, r, i) => oa(e, t, n, r, i)
5361
- }, ca = /\x1b\[[0-9;]*m/g;
5362
- function la(e) {
5363
- let t = e.split("\n"), n = t.reduce((e, t) => Math.max(e, ne(t.replace(ca, "")).length), 0), r = String(Math.max(0, t.length - 1)).length, i = " ".repeat(r + 1);
5399
+ er: (e, t, n, r) => _i(e, t, n, r),
5400
+ sequence: (e, t, n, r) => Ci(e, t, n, r),
5401
+ class: (e, t, n, r, i) => ji(e, t, n, r, i),
5402
+ flowchart: (e, t, n, r, i) => Sa(e, t, n, r, i)
5403
+ }, wa = /\x1b\[[0-9;]*m/g;
5404
+ function Ta(e) {
5405
+ let t = e.split("\n"), n = t.reduce((e, t) => Math.max(e, re(t.replace(wa, "")).length), 0), r = String(Math.max(0, t.length - 1)).length, i = " ".repeat(r + 1);
5364
5406
  return [
5365
5407
  i + Array.from({ length: n }, (e, t) => String(Math.floor(t / 10) % 10)).join(""),
5366
5408
  i + Array.from({ length: n }, (e, t) => String(t % 10)).join(""),
@@ -5369,24 +5411,24 @@ function la(e) {
5369
5411
  }
5370
5412
  //#endregion
5371
5413
  //#region packages/ascii-renderer/src/index.ts
5372
- function ua(e, t = {}) {
5414
+ function Ea(e, t = {}) {
5373
5415
  let r = {
5374
5416
  useAscii: t.useAscii ?? !1,
5375
5417
  paddingX: t.paddingX ?? 5,
5376
5418
  paddingY: t.paddingY ?? 5,
5377
5419
  boxBorderPadding: t.boxBorderPadding ?? 1,
5378
5420
  graphDirection: "TD"
5379
- }, i = t.colorMode === "auto" || t.colorMode === void 0 ? F() : t.colorMode, a = {
5380
- ...P,
5421
+ }, i = t.colorMode === "auto" || t.colorMode === void 0 ? P() : t.colorMode, a = {
5422
+ ...N,
5381
5423
  ...t.theme
5382
- }, o = sa[n(e)](e, r, i, a, {
5424
+ }, o = Ca[n(e)](e, r, i, a, {
5383
5425
  hyperlinks: t.hyperlinks ?? !1,
5384
5426
  direction: t.direction
5385
5427
  });
5386
- return t.showCoords ? la(o) : o;
5428
+ return t.showCoords ? Ta(o) : o;
5387
5429
  }
5388
- var da = ua;
5430
+ var Da = Ea;
5389
5431
  //#endregion
5390
- export { P as DEFAULT_ASCII_THEME, F as detectColorMode, oe as diagramColorsToAsciiTheme, ua as renderMermaidASCII, da as renderMermaidAscii };
5432
+ export { N as DEFAULT_ASCII_THEME, P as detectColorMode, se as diagramColorsToAsciiTheme, Ea as renderMermaidASCII, Da as renderMermaidAscii };
5391
5433
 
5392
5434
  //# sourceMappingURL=index.js.map