@zombie-mermaid/mermaid-parser 3.1.0 → 4.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.
package/dist/index.js CHANGED
@@ -1,7 +1,331 @@
1
1
  import { applyClickStatement as e, detectDiagramType as t, normalizeBrTags as n, splitClassShorthand as r, splitStatements as i, toDirection as a, tryApplyClassAssignment as o, tryApplyClassDef as s, tryApplyCssClass as c, tryApplyStyleStatement as l } from "@zombie-mermaid/core";
2
+ //#region packages/mermaid-parser/src/architecture/parser.ts
3
+ var u = String.raw`[\w-]+`, d = new RegExp(String.raw`^(group|service)\s+(${u})\s*(?:\(([^)]*)\))?\s*(?:\[([^\]]*)\])?(?:\s+in\s+(${u}))?$`), f = new RegExp(String.raw`^junction\s+(${u})(?:\s+in\s+(${u}))?$`), p = new RegExp(String.raw`^(${u})(\{group\})?:([LRTB])\s+(<)?--(>)?\s+([LRTB]):(${u})(\{group\})?$`), m = new RegExp(String.raw`^align\s+(?:row|column)\s+${u}(?:\s+${u})+$`);
4
+ function h(e, t) {
5
+ throw Error(`Architecture diagram, line ${e.line}: ${t} — "${e.text}"`);
6
+ }
7
+ function g(e) {
8
+ return e?.trim().replace(/^"(.*)"$/, "$1") || void 0;
9
+ }
10
+ function _(e) {
11
+ let t = {
12
+ groups: [],
13
+ services: [],
14
+ junctions: [],
15
+ edges: []
16
+ }, r = /* @__PURE__ */ new Map(), i = [], a = [], o = (e, t, n, a) => {
17
+ r.has(t) && h(e, `duplicate id "${t}"`), a === t && h(e, `"${t}" cannot be inside itself`), r.set(t, n), a && i.push({
18
+ stmt: e,
19
+ parent: a
20
+ });
21
+ };
22
+ for (let r = 1; r < e.length; r++) {
23
+ let i = e[r], s = i.text, c = s.match(d);
24
+ if (c) {
25
+ let e = c[1], r = c[2], a = c[4], s = c[5];
26
+ o(i, r, e, s);
27
+ let l = {
28
+ id: r,
29
+ icon: g(c[3]),
30
+ title: a === void 0 ? r : n(a.trim()),
31
+ parent: s
32
+ };
33
+ e === "group" ? t.groups.push(l) : t.services.push(l);
34
+ continue;
35
+ }
36
+ let l = s.match(f);
37
+ if (l) {
38
+ let e = l[1], n = l[2];
39
+ o(i, e, "junction", n), t.junctions.push({
40
+ id: e,
41
+ parent: n
42
+ });
43
+ continue;
44
+ }
45
+ let u = s.match(p);
46
+ if (u) {
47
+ a.push({
48
+ stmt: i,
49
+ edge: {
50
+ source: u[1],
51
+ sourceGroup: u[2] !== void 0,
52
+ sourcePort: u[3],
53
+ arrowStart: u[4] !== void 0,
54
+ arrowEnd: u[5] !== void 0,
55
+ targetPort: u[6],
56
+ target: u[7],
57
+ targetGroup: u[8] !== void 0
58
+ }
59
+ });
60
+ continue;
61
+ }
62
+ m.test(s) || h(i, "unrecognized statement");
63
+ }
64
+ for (let { stmt: e, parent: t } of i) r.get(t) !== "group" && h(e, `"in ${t}" must name a declared group`);
65
+ let s = /* @__PURE__ */ new Map();
66
+ for (let e of t.groups) e.parent && s.set(e.id, e.parent);
67
+ for (let e of t.groups) {
68
+ let t = /* @__PURE__ */ new Set([e.id]);
69
+ for (let n = s.get(e.id); n; n = s.get(n)) {
70
+ if (t.has(n)) throw Error(`Architecture diagram: group "${e.id}" is nested inside itself`);
71
+ t.add(n);
72
+ }
73
+ }
74
+ for (let { stmt: e, edge: n } of a) {
75
+ let i = [[n.source, n.sourceGroup], [n.target, n.targetGroup]];
76
+ for (let [n, a] of i) {
77
+ let i = r.get(n);
78
+ i || h(e, `unknown id "${n}"`), i === "group" && h(e, `edges connect services or junctions, not the group "${n}"`);
79
+ let o = [...t.services, ...t.junctions].find((e) => e.id === n)?.parent;
80
+ a && !o && h(e, `"{group}" needs "${n}" to be declared inside a group`);
81
+ }
82
+ t.edges.push(n);
83
+ }
84
+ return t;
85
+ }
86
+ //#endregion
87
+ //#region packages/mermaid-parser/src/architecture/to-graph.ts
88
+ var v = {
89
+ database: "cylinder",
90
+ disk: "cylinder",
91
+ cloud: "stadium",
92
+ internet: "circle"
93
+ }, y = /* @__PURE__ */ new Set(["L", "R"]);
94
+ function b(e) {
95
+ let t = 0, n = 0;
96
+ for (let r of e) for (let e of [r.sourcePort, r.targetPort]) y.has(e) ? t++ : n++;
97
+ return n > t ? "TB" : "LR";
98
+ }
99
+ function x(e, t) {
100
+ let [n, r] = t === "LR" || t === "RL" ? ["L", "R"] : ["T", "B"];
101
+ return e.sourcePort === r || e.targetPort === n ? !1 : e.sourcePort === n || e.targetPort === r;
102
+ }
103
+ function S(e) {
104
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
105
+ for (let r of e.services) t.set(r.id, {
106
+ id: r.id,
107
+ label: r.title,
108
+ shape: r.icon && v[r.icon] || "rectangle"
109
+ }), n.set(r.id, r.parent);
110
+ for (let r of e.junctions) t.set(r.id, {
111
+ id: r.id,
112
+ label: "",
113
+ shape: "filled-circle"
114
+ }), n.set(r.id, r.parent);
115
+ let r = /* @__PURE__ */ new Map();
116
+ for (let t of e.groups) r.set(t.id, {
117
+ id: t.id,
118
+ label: t.title,
119
+ nodeIds: [],
120
+ children: []
121
+ });
122
+ let i = [];
123
+ for (let t of e.groups) {
124
+ let e = r.get(t.id), n = t.parent ? r.get(t.parent) : void 0;
125
+ n ? n.children.push(e) : i.push(e);
126
+ }
127
+ for (let [e, t] of n) r.get(t ?? "")?.nodeIds.push(e);
128
+ let a = b(e.edges);
129
+ return {
130
+ direction: a,
131
+ nodes: t,
132
+ edges: e.edges.map((e) => {
133
+ let t = (e, t) => (t ? n.get(e) : void 0) ?? e, r = !x(e, a), [i, o] = r ? [t(e.source, e.sourceGroup), t(e.target, e.targetGroup)] : [t(e.target, e.targetGroup), t(e.source, e.sourceGroup)];
134
+ return {
135
+ source: i,
136
+ target: o,
137
+ style: "solid",
138
+ hasArrowStart: r ? e.arrowStart : e.arrowEnd,
139
+ hasArrowEnd: r ? e.arrowEnd : e.arrowStart
140
+ };
141
+ }),
142
+ subgraphs: i,
143
+ classDefs: /* @__PURE__ */ new Map(),
144
+ classAssignments: /* @__PURE__ */ new Map(),
145
+ nodeStyles: /* @__PURE__ */ new Map(),
146
+ linkStyles: /* @__PURE__ */ new Map(),
147
+ interactions: /* @__PURE__ */ new Map()
148
+ };
149
+ }
150
+ //#endregion
151
+ //#region packages/mermaid-parser/src/c4/parser.ts
152
+ var C = {
153
+ c4context: "context",
154
+ c4container: "container",
155
+ c4component: "component",
156
+ c4dynamic: "dynamic",
157
+ c4deployment: "deployment"
158
+ }, ee = /^(?:UpdateElementStyle|UpdateRelStyle|UpdateLayoutConfig|LAYOUT_[A-Z_]+|SHOW_LEGEND|SHOW_FLOATING_LEGEND|AddElementTag|AddRelTag|AddBoundaryTag|RoleTag)\b/, te = /^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/, ne = /^(?:Boundary|Enterprise_Boundary|System_Boundary|Container_Boundary)$/, w = /^(?:Deployment_Node|Node|Node_L|Node_R)$/, re = /^(Rel|BiRel|Rel_U|Rel_Up|Rel_D|Rel_Down|Rel_L|Rel_Left|Rel_R|Rel_Right|Rel_Back|RelIndex)$/, ie = {
159
+ Enterprise_Boundary: "ENTERPRISE",
160
+ System_Boundary: "SYSTEM",
161
+ Container_Boundary: "CONTAINER"
162
+ }, ae = {
163
+ Rel_U: "up",
164
+ Rel_Up: "up",
165
+ Rel_D: "down",
166
+ Rel_Down: "down",
167
+ Rel_L: "left",
168
+ Rel_Left: "left",
169
+ Rel_R: "right",
170
+ Rel_Right: "right"
171
+ };
172
+ function oe(e) {
173
+ let t = e.trim(), r = t.length >= 2 && t.startsWith("\"") && t.endsWith("\"") ? t.slice(1, -1) : t;
174
+ return n(r);
175
+ }
176
+ function se(e) {
177
+ let t = [], n = "", r = !1;
178
+ for (let i of e) i === "\"" && (r = !r), i === "," && !r ? (t.push(n), n = "") : n += i;
179
+ return r ? null : (t.push(n), t.map((e) => e.trim()).filter((e) => !e.startsWith("$")).map(oe));
180
+ }
181
+ var ce = /^([A-Za-z_][A-Za-z0-9_]*)\s*\((.*)\)\s*(\{)?\s*$/;
182
+ function T(e, t) {
183
+ throw Error(`C4 diagram, line ${e.line}: ${t} — "${e.text}"`);
184
+ }
185
+ function le(e) {
186
+ let t = C[e[0]?.text.trim().toLowerCase() ?? ""];
187
+ if (!t) throw Error(`C4 diagram: expected a header of C4Context, C4Container, C4Component, C4Dynamic or C4Deployment, got "${e[0]?.text ?? ""}"`);
188
+ let r = {
189
+ variant: t,
190
+ elements: [],
191
+ boundaries: [],
192
+ relationships: []
193
+ }, i = /* @__PURE__ */ new Set(), a = [], o, s = (e, t) => (t || T(e, "missing alias (first argument)"), i.has(t) && T(e, `duplicate alias "${t}"`), i.add(t), t);
194
+ for (let t = 1; t < e.length; t++) {
195
+ let i = e[t], c = i.text;
196
+ if (c === "}") {
197
+ a.length === 0 && T(i, "unmatched \"}\""), a.pop();
198
+ continue;
199
+ }
200
+ if (c === "{") {
201
+ o || T(i, "unexpected \"{\""), a.push(o), o = void 0;
202
+ continue;
203
+ }
204
+ o = void 0;
205
+ let l = c.match(/^title(?:\s+(.*))?$/i);
206
+ if (l) {
207
+ r.title = n((l[1] ?? "").trim());
208
+ continue;
209
+ }
210
+ if (ee.test(c)) continue;
211
+ let u = c.match(ce);
212
+ u || T(i, "unrecognized statement");
213
+ let d = u[1], f = u[3] === "{", p = se(u[2]);
214
+ p || T(i, "unbalanced quotes");
215
+ let m = d.match(te);
216
+ if (m) {
217
+ f && T(i, `"${d}" cannot contain a block`);
218
+ let e = m[1].toLowerCase(), t = m[2] === "Db" ? "db" : m[2] === "Queue" ? "queue" : "default", n = e === "container" || e === "component", o = s(i, p[0]), c = {
219
+ alias: o,
220
+ kind: e,
221
+ shape: t,
222
+ external: m[3] !== void 0,
223
+ label: p[1] || o
224
+ }, l = n ? p[2] : void 0, u = n ? p[3] : p[2];
225
+ l && (c.technology = l), u && (c.description = u), r.elements.push(c), a.at(-1)?.elementAliases.push(o);
226
+ continue;
227
+ }
228
+ if (ne.test(d) || w.test(d)) {
229
+ let e = w.test(d), t = s(i, p[0]), n = {
230
+ alias: t,
231
+ label: p[1] || t,
232
+ elementAliases: [],
233
+ children: []
234
+ };
235
+ n.type = ie[d] || (p[2] && (e || d === "Boundary") ? p[2] : e ? "node" : "system"), e && p[3] && (n.description = p[3]);
236
+ let c = a.at(-1);
237
+ c ? c.children.push(n) : r.boundaries.push(n), f ? a.push(n) : o = n;
238
+ continue;
239
+ }
240
+ if (d.match(re)) {
241
+ let e = d === "RelIndex" ? p.slice(1) : p;
242
+ (!e[0] || !e[1]) && T(i, "a relationship needs \"from\" and \"to\" aliases");
243
+ let t = {
244
+ from: e[0],
245
+ to: e[1],
246
+ label: e[2] ?? "",
247
+ bidirectional: d === "BiRel"
248
+ };
249
+ e[3] && (t.technology = e[3]), d === "Rel_Back" && (t.reversed = !0);
250
+ let n = ae[d];
251
+ n && (t.layout = n), r.relationships.push(t);
252
+ continue;
253
+ }
254
+ T(i, `unknown C4 macro "${d}"`);
255
+ }
256
+ if (a.length > 0) throw Error(`C4 diagram: boundary "${a.at(-1).alias}" is missing its closing "}"`);
257
+ r.variant === "dynamic" && r.relationships.forEach((e, t) => {
258
+ e.index = String(t + 1);
259
+ });
260
+ for (let e of r.relationships) for (let t of [e.from, e.to]) if (!i.has(t)) throw Error(`C4 diagram: relationship refers to undeclared alias "${t}"`);
261
+ return r;
262
+ }
263
+ //#endregion
264
+ //#region packages/mermaid-parser/src/c4/format.ts
265
+ function ue(e, t) {
266
+ let n = [];
267
+ for (let r of e.split("\n")) {
268
+ let e = "";
269
+ for (let i of r.split(/\s+/).filter(Boolean)) e && e.length + 1 + i.length > t ? (n.push(e), e = i) : e = e ? `${e} ${i}` : i;
270
+ n.push(e);
271
+ }
272
+ return n;
273
+ }
274
+ var de = {
275
+ person: "Person",
276
+ system: "Software System",
277
+ container: "Container",
278
+ component: "Component"
279
+ };
280
+ function fe(e) {
281
+ let t = (e.kind === "container" || e.kind === "component") && e.technology ? `: ${e.technology}` : "";
282
+ return `[${de[e.kind]}${t}]`;
283
+ }
284
+ function pe(e) {
285
+ return e.type ? `[${e.type}]` : void 0;
286
+ }
287
+ function me(e) {
288
+ let t = [], n = [e.index ? `${e.index}:` : "", e.label].filter(Boolean).join(" ");
289
+ return n && t.push(n), e.technology && t.push(`[${e.technology}]`), t;
290
+ }
291
+ function he(e) {
292
+ switch (e.layout) {
293
+ case "up": return {
294
+ source: e.to,
295
+ target: e.from,
296
+ axis: "vertical",
297
+ explicit: !0
298
+ };
299
+ case "left": return {
300
+ source: e.to,
301
+ target: e.from,
302
+ axis: "horizontal",
303
+ explicit: !0
304
+ };
305
+ case "right": return {
306
+ source: e.from,
307
+ target: e.to,
308
+ axis: "horizontal",
309
+ explicit: !0
310
+ };
311
+ case "down": return {
312
+ source: e.from,
313
+ target: e.to,
314
+ axis: "vertical",
315
+ explicit: !0
316
+ };
317
+ default: return {
318
+ source: e.from,
319
+ target: e.to,
320
+ axis: "vertical",
321
+ explicit: !1
322
+ };
323
+ }
324
+ }
325
+ //#endregion
2
326
  //#region packages/mermaid-parser/src/class/parser.ts
3
- var u = "<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--", d = new RegExp(u);
4
- function f(t) {
327
+ var E = "<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--", ge = new RegExp(E);
328
+ function _e(t) {
5
329
  let i = {
6
330
  classes: [],
7
331
  relationships: [],
@@ -11,100 +335,100 @@ function f(t) {
11
335
  classAssignments: /* @__PURE__ */ new Map(),
12
336
  nodeStyles: /* @__PURE__ */ new Map(),
13
337
  notes: []
14
- }, a = /* @__PURE__ */ new Map(), u = null, f = null, h = 0, g;
338
+ }, a = /* @__PURE__ */ new Map(), u = null, d = null, f = 0, p;
15
339
  for (let r = 1; r < t.length; r++) {
16
- let v = t[r], b = v.text;
17
- if (f && h > 0) {
18
- if (b === "}") {
19
- h--, h === 0 && (f = null, g = void 0);
340
+ let h = t[r], g = h.text;
341
+ if (d && f > 0) {
342
+ if (g === "}") {
343
+ f--, f === 0 && (d = null, p = void 0);
20
344
  continue;
21
345
  }
22
- let e = b.match(/^<<(\w+)>>$/);
346
+ let e = g.match(/^<<(\w+)>>$/);
23
347
  if (e) {
24
- f.annotation = e[1];
348
+ d.annotation = e[1];
25
349
  continue;
26
350
  }
27
- if (b.startsWith("<<")) throw Error(`Line ${v.line}: Malformed class annotation "${b}" — expected "<<name>>" (e.g. "<<interface>>").`);
28
- p(f, b, v.line);
351
+ if (g.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${g}" — expected "<<name>>" (e.g. "<<interface>>").`);
352
+ D(d, g, h.line);
29
353
  continue;
30
354
  }
31
- if (/^click\s+/i.test(b)) {
32
- e(b, i.interactions);
355
+ if (/^click\s+/i.test(g)) {
356
+ e(g, i.interactions);
33
357
  continue;
34
358
  }
35
- let x = b.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);
36
- if (x) {
37
- let e = x[1];
359
+ let _ = g.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);
360
+ if (_) {
361
+ let e = _[1];
38
362
  i.notes.push({
39
- text: n(x[2]),
363
+ text: n(_[2]),
40
364
  ...e ? { forClass: e } : {}
41
365
  });
42
366
  continue;
43
367
  }
44
- if (s(b, i) || l(b, i) || c(b, i) || o(b, i)) continue;
45
- let S = b.match(/^namespace\s+(\S+)\s*\{$/);
46
- if (S) {
368
+ if (s(g, i) || l(g, i) || c(g, i) || o(g, i)) continue;
369
+ let v = g.match(/^namespace\s+(\S+)\s*\{$/);
370
+ if (v) {
47
371
  u = {
48
- name: S[1],
372
+ name: v[1],
49
373
  classIds: []
50
374
  };
51
375
  continue;
52
376
  }
53
- if (b === "}" && u) {
377
+ if (g === "}" && u) {
54
378
  i.namespaces.push(u), u = null;
55
379
  continue;
56
380
  }
57
- let C = b.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);
58
- if (C) {
59
- let e = _(C[1], C[2]);
60
- f = a.get(e) ?? null, h = 1, g = v.line;
381
+ let y = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);
382
+ if (y) {
383
+ let e = m(y[1], y[2]);
384
+ d = a.get(e) ?? null, f = 1, p = h.line;
61
385
  continue;
62
386
  }
63
- let w = b.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);
64
- if (w) {
65
- _(w[1], w[2]);
387
+ let b = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);
388
+ if (b) {
389
+ m(b[1], b[2]);
66
390
  continue;
67
391
  }
68
- let T = b.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);
69
- if (T) {
70
- let e = _(T[1], void 0), t = a.get(e), n = T[2], r = n.match(/^<<(\w+)>>$/);
392
+ let x = g.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);
393
+ if (x) {
394
+ let e = m(x[1], void 0), t = a.get(e), n = x[2], r = n.match(/^<<(\w+)>>$/);
71
395
  if (t && r) t.annotation = r[1];
72
- else if (t && n.startsWith("<<")) throw Error(`Line ${v.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);
73
- else t && n && p(t, n, v.line);
396
+ else if (t && n.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);
397
+ else t && n && D(t, n, h.line);
74
398
  continue;
75
399
  }
76
- let E = b.match(/^(\S+?)\s*:\s*(.+)$/);
77
- if (E) {
78
- let e = E[2];
400
+ let S = g.match(/^(\S+?)\s*:\s*(.+)$/);
401
+ if (S) {
402
+ let e = S[2];
79
403
  if (!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)) {
80
- p(m(a, E[1]), e, v.line);
404
+ D(O(a, S[1]), e, h.line);
81
405
  continue;
82
406
  }
83
407
  }
84
- let D = y(b);
85
- if (D) {
86
- D.from = _(D.from, void 0, !1), D.to = _(D.to, void 0, !1), i.relationships.push(D);
408
+ let C = be(g);
409
+ if (C) {
410
+ C.from = m(C.from, void 0, !1), C.to = m(C.to, void 0, !1), i.relationships.push(C);
87
411
  continue;
88
412
  }
89
- if (d.test(b)) throw Error(`Line ${v.line}: Malformed class-diagram relationship "${b}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`);
413
+ if (ge.test(g)) throw Error(`Line ${h.line}: Malformed class-diagram relationship "${g}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`);
90
414
  }
91
- if (f !== null) throw Error(`Line ${g}: Unclosed class body for "${f.id}" — expected a closing "}" before the diagram ends.`);
415
+ if (d !== null) throw Error(`Line ${p}: Unclosed class body for "${d.id}" — expected a closing "}" before the diagram ends.`);
92
416
  return i.classes = [...a.values()], i;
93
- function _(e, t, n = !0) {
417
+ function m(e, t, n = !0) {
94
418
  let { id: o, className: s } = r(e), c = o, l = t;
95
419
  if (!l) {
96
420
  let e = o.match(/^(.+?)~(\w+)~$/);
97
421
  e && (c = e[1], l = e[2]);
98
422
  }
99
- let d = m(a, c);
423
+ let d = O(a, c);
100
424
  return l && (d.label = `${c}<${l}>`), s && i.classAssignments.set(c, s), n && u && u.classIds.push(c), c;
101
425
  }
102
426
  }
103
- function p(e, t, n) {
104
- let r = v(t, n);
427
+ function D(e, t, n) {
428
+ let r = ye(t, n);
105
429
  r && (r.isMethod ? e.methods.push(r.member) : e.attributes.push(r.member));
106
430
  }
107
- function m(e, t) {
431
+ function O(e, t) {
108
432
  let n = e.get(t);
109
433
  return n || (n = {
110
434
  id: t,
@@ -113,11 +437,11 @@ function m(e, t) {
113
437
  methods: []
114
438
  }, e.set(t, n)), n;
115
439
  }
116
- function h(e, t) {
440
+ function k(e, t) {
117
441
  return Math.max(0, e.split(t).length - 1);
118
442
  }
119
- function g(e) {
120
- let t = h(e, "~");
443
+ function ve(e) {
444
+ let t = k(e, "~");
121
445
  if (t <= 1) return e;
122
446
  let n = e, r = !1;
123
447
  t % 2 != 0 && n.startsWith("~") && (n = n.slice(1), r = !0);
@@ -125,26 +449,26 @@ function g(e) {
125
449
  for (; a !== -1 && o !== -1 && a !== o;) i[a] = "<", i[o] = ">", a = i.indexOf("~"), o = i.lastIndexOf("~");
126
450
  return r && i.unshift("~"), i.join("");
127
451
  }
128
- function _(e) {
452
+ function A(e) {
129
453
  let t = e.split(/(,)/), n = [];
130
454
  for (let e = 0; e < t.length; e++) {
131
455
  let r = t[e];
132
456
  if (r === "," && e > 0 && e + 1 < t.length) {
133
457
  let i = t[e - 1], a = t[e + 1];
134
- h(i, "~") === 1 && h(a, "~") === 1 && (r = `${i},${a}`, e++, n.pop());
458
+ k(i, "~") === 1 && k(a, "~") === 1 && (r = `${i},${a}`, e++, n.pop());
135
459
  }
136
- n.push(g(r));
460
+ n.push(ve(r));
137
461
  }
138
462
  return n.join("");
139
463
  }
140
- function v(e, t) {
464
+ function ye(e, t) {
141
465
  let n = e.trim().replace(/;$/, "");
142
466
  if (!n) return null;
143
467
  let r = "", i = n, a = i[0];
144
468
  if ((a === "+" || a === "-" || a === "#" || a === "~") && (r = a, i = i.slice(1).trim()), i.includes("(") && !i.includes(")")) throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);
145
469
  let o = i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);
146
470
  if (o) {
147
- let e = _(o[1].trim()), t = o[2]?.trim(), n = t ? _(t) : void 0, a = o[3]?.trim(), s = a ? _(a) : void 0, c = e.endsWith("$") || i.includes("$"), l = e.endsWith("*") || i.includes("*");
471
+ let e = A(o[1].trim()), t = o[2]?.trim(), n = t ? A(t) : void 0, a = o[3]?.trim(), s = a ? A(a) : void 0, c = e.endsWith("$") || i.includes("$"), l = e.endsWith("*") || i.includes("*");
148
472
  return {
149
473
  member: {
150
474
  visibility: r,
@@ -158,36 +482,34 @@ function v(e, t) {
158
482
  isMethod: !0
159
483
  };
160
484
  }
161
- let s = _(i).split(/\s+/), c, l;
162
- s.length >= 2 ? (l = s[0], c = s.slice(1).join(" ")) : c = s[0] ?? i;
163
- let u = c.endsWith("$"), d = c.endsWith("*");
485
+ let s = A(i), c = s.endsWith("$"), l = s.endsWith("*");
164
486
  return {
165
487
  member: {
166
488
  visibility: r,
167
- name: c.replace(/[$*]$/, ""),
168
- type: l || void 0,
169
- isStatic: u,
170
- isAbstract: d,
489
+ name: s.replace(/[$*]$/, ""),
490
+ type: void 0,
491
+ isStatic: c,
492
+ isAbstract: l,
171
493
  isMethod: !1
172
494
  },
173
495
  isMethod: !1
174
496
  };
175
497
  }
176
- function y(e) {
177
- let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${u})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));
498
+ function be(e) {
499
+ let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${E})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));
178
500
  if (!t) return null;
179
- let r = t[1], i = t[2], a = i ? n(i) : void 0, o = t[3].trim(), s = t[4], c = s ? n(s) : void 0, l = t[6] ? `${t[5]}:::${t[6]}` : t[5], d = t[7]?.trim(), f = d ? n(d) : void 0, p = b(o);
180
- return p ? {
501
+ let r = t[1], i = t[2], a = i ? n(i) : void 0, o = t[3].trim(), s = t[4], c = s ? n(s) : void 0, l = t[6] ? `${t[5]}:::${t[6]}` : t[5], u = t[7]?.trim(), d = u ? n(u) : void 0, f = j(o);
502
+ return f ? {
181
503
  from: r,
182
504
  to: l,
183
- type: p.type,
184
- markerAt: p.markerAt,
185
- label: f,
505
+ type: f.type,
506
+ markerAt: f.markerAt,
507
+ label: d,
186
508
  fromCardinality: a,
187
509
  toCardinality: c
188
510
  } : null;
189
511
  }
190
- function b(e) {
512
+ function j(e) {
191
513
  switch (e.trim()) {
192
514
  case "<|--": return {
193
515
  type: "inheritance",
@@ -246,12 +568,12 @@ function b(e) {
246
568
  }
247
569
  //#endregion
248
570
  //#region packages/mermaid-parser/src/class/format.ts
249
- function x(e) {
571
+ function M(e) {
250
572
  return `${e.visibility ? `${e.visibility} ` : ""}${e.isMethod ? `${e.name}(${e.params || ""})` : e.name}${e.type ? `: ${e.type}` : ""}`;
251
573
  }
252
574
  //#endregion
253
575
  //#region packages/mermaid-parser/src/er/parser.ts
254
- function S(e) {
576
+ function N(e) {
255
577
  let t = {
256
578
  entities: [],
257
579
  relationships: []
@@ -263,7 +585,7 @@ function S(e) {
263
585
  i = null;
264
586
  continue;
265
587
  }
266
- let e = w(c);
588
+ let e = F(c);
267
589
  e && i.attributes.push(e);
268
590
  continue;
269
591
  }
@@ -274,23 +596,23 @@ function S(e) {
274
596
  }
275
597
  let u = c.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);
276
598
  if (u) {
277
- let e = u[1], t = u[2], a = C(r, e, t === void 0 ? void 0 : n(t.trim().replace(/^["']|["']$/g, ""))), o = u[3].trim(), s = o.endsWith("}"), c = s ? o.slice(0, -1).trim() : o;
599
+ let e = u[1], t = u[2], a = P(r, e, t === void 0 ? void 0 : n(t.trim().replace(/^["']|["']$/g, ""))), o = u[3].trim(), s = o.endsWith("}"), c = s ? o.slice(0, -1).trim() : o;
278
600
  for (let e of c.split(";").map((e) => e.trim()).filter(Boolean)) {
279
- let t = w(e);
601
+ let t = F(e);
280
602
  t && a.attributes.push(t);
281
603
  }
282
604
  s || (i = a);
283
605
  continue;
284
606
  }
285
- let d = T(c, s.line);
607
+ let d = xe(c, s.line);
286
608
  if (d) {
287
- C(r, d.entity1), C(r, d.entity2), t.relationships.push(d);
609
+ P(r, d.entity1), P(r, d.entity2), t.relationships.push(d);
288
610
  continue;
289
611
  }
290
612
  }
291
613
  return t.entities = [...r.values()], t;
292
614
  }
293
- function C(e, t, n) {
615
+ function P(e, t, n) {
294
616
  let r = e.get(t);
295
617
  return r ? n !== void 0 && (r.label = n) : (r = {
296
618
  id: t,
@@ -298,7 +620,7 @@ function C(e, t, n) {
298
620
  attributes: []
299
621
  }, e.set(t, r)), r;
300
622
  }
301
- function w(e) {
623
+ function F(e) {
302
624
  let t = e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);
303
625
  if (!t) return null;
304
626
  let r = t[1], i = t[2], a = t[3]?.trim() ?? "", o = [], s, c = a.match(/"([^"]*)"/);
@@ -315,10 +637,10 @@ function w(e) {
315
637
  comment: s
316
638
  };
317
639
  }
318
- function T(e, t) {
640
+ function xe(e, t) {
319
641
  let r = e.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);
320
642
  if (!r) return null;
321
- let i = r[1], a = r[2], o = r[3], s = r[4] !== void 0, c = r[4]?.trim() ?? "", l = a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/), u = l ? E(l[1]) : null, d = l ? D(l[3]) : null;
643
+ let i = r[1], a = r[2], o = r[3], s = r[4] !== void 0, c = r[4]?.trim() ?? "", l = a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/), u = l ? Se(l[1]) : null, d = l ? Ce(l[3]) : null;
322
644
  if (!u || !d) throw Error(`Line ${t}: Invalid ER relationship cardinality "${a}" in "${e}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);
323
645
  if (!s || c.length === 0) throw Error(`Line ${t}: ER relationship "${i} ${a} ${o}" is missing a ": label" — expected e.g. "${i} ${a} ${o} : label".`);
324
646
  return {
@@ -330,36 +652,36 @@ function T(e, t) {
330
652
  identifying: l[2] === "--"
331
653
  };
332
654
  }
333
- function E(e) {
655
+ function Se(e) {
334
656
  return e === "||" ? "one" : e === "|o" ? "zero-one" : e === "}|" ? "many" : e === "}o" ? "zero-many" : null;
335
657
  }
336
- function D(e) {
658
+ function Ce(e) {
337
659
  return e === "||" ? "one" : e === "o|" ? "zero-one" : e === "|{" ? "many" : e === "o{" ? "zero-many" : null;
338
660
  }
339
661
  //#endregion
340
662
  //#region packages/mermaid-parser/src/sequence/box-color.ts
341
- var ee = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")), O = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, k = /^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;
342
- function A(e) {
343
- return ee.has(e.toLowerCase()) || O.test(e) || k.test(e);
663
+ var we = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")), Te = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Ee = /^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;
664
+ function I(e) {
665
+ return we.has(e.toLowerCase()) || Te.test(e) || Ee.test(e);
344
666
  }
345
- function j(e) {
667
+ function L(e) {
346
668
  let t = e.trim(), n = t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/), r = n?.[1] ?? "", i = n?.[2]?.trim() ?? "";
347
- return r.toLowerCase() === "transparent" ? { label: i } : r !== "" && A(r) ? {
669
+ return r.toLowerCase() === "transparent" ? { label: i } : r !== "" && I(r) ? {
348
670
  color: r,
349
671
  label: i
350
672
  } : { label: t };
351
673
  }
352
674
  //#endregion
353
675
  //#region packages/mermaid-parser/src/sequence/parser.ts
354
- function M(e) {
676
+ function R(e) {
355
677
  return e === "loop" || e === "alt" || e === "opt" || e === "par" || e === "critical" || e === "break" || e === "rect";
356
678
  }
357
- function N(e) {
358
- if (!M(e)) throw Error(`Invalid block type: "${e}"`);
679
+ function z(e) {
680
+ if (!R(e)) throw Error(`Invalid block type: "${e}"`);
359
681
  return e;
360
682
  }
361
- var te = /^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/, ne = /^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;
362
- function P(e) {
683
+ var De = /^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/, Oe = /^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;
684
+ function B(e) {
363
685
  let t = {
364
686
  actors: [],
365
687
  messages: [],
@@ -379,7 +701,7 @@ function P(e) {
379
701
  let f = e[d], p = f.text, m = p.match(/^box(?:\s+(.*))?$/);
380
702
  if (m) {
381
703
  if (r.open !== void 0) throw Error(`Line ${f.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);
382
- let { color: e, label: o } = j(m[1] ?? ""), c = {
704
+ let { color: e, label: o } = L(m[1] ?? ""), c = {
383
705
  label: n(o),
384
706
  actorIds: []
385
707
  };
@@ -394,13 +716,13 @@ function P(e) {
394
716
  id: i,
395
717
  label: n(h[3]?.trim() ?? i),
396
718
  type: e
397
- }), L(t, r, i, f.line), l = i;
719
+ }), U(t, r, i, f.line), l = i;
398
720
  continue;
399
721
  }
400
722
  let g = p.match(/^destroy\s+(.+)$/);
401
723
  if (g) {
402
724
  let e = g[1].trim();
403
- I(t, o, r, e, f.line), u = e;
725
+ H(t, o, r, e, f.line), u = e;
404
726
  continue;
405
727
  }
406
728
  let _ = p.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);
@@ -416,13 +738,13 @@ function P(e) {
416
738
  id: i,
417
739
  label: s,
418
740
  type: e
419
- })), L(t, r, i, f.line);
741
+ })), U(t, r, i, f.line);
420
742
  continue;
421
743
  }
422
744
  let y = p.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);
423
745
  if (y) {
424
746
  let e = y[1].toLowerCase(), i = y[2].trim(), a = n(y[3].trim()), s = i.split(",").map((e) => e.trim());
425
- for (let e of s) I(t, o, r, e, f.line);
747
+ for (let e of s) H(t, o, r, e, f.line);
426
748
  let c = "over";
427
749
  e === "left of" ? c = "left" : e === "right of" && (c = "right"), t.notes.push({
428
750
  actorIds: s,
@@ -434,7 +756,7 @@ function P(e) {
434
756
  }
435
757
  let b = p.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);
436
758
  if (b) {
437
- let e = N(b[1]), r = b[2]?.trim() ?? "", i = n(r);
759
+ let e = z(b[1]), r = b[2]?.trim() ?? "", i = n(r);
438
760
  s.push({
439
761
  type: e,
440
762
  label: i,
@@ -472,26 +794,26 @@ function P(e) {
472
794
  let S = p.match(/^(activate|deactivate)\s+(.+)$/);
473
795
  if (S) {
474
796
  let e = S[2].trim();
475
- I(t, o, r, e, f.line), t.activations.push({
797
+ H(t, o, r, e, f.line), t.activations.push({
476
798
  actorId: e,
477
799
  kind: S[1] === "activate" ? "start" : "end",
478
800
  afterIndex: t.messages.length - 1
479
801
  });
480
802
  continue;
481
803
  }
482
- let C = p.match(te) ?? p.match(ne);
804
+ let C = p.match(De) ?? p.match(Oe);
483
805
  if (C) {
484
806
  let e = C[2], n = C[4][0];
485
807
  if (n === ">" || n === ")") throw Error(`Line ${f.line}: Malformed sequence-diagram arrow in "${p}" — "${e}${n}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);
486
- R(t, o, r, c, C[1], C[2], C[3], C[4], C[5], f.line);
808
+ ke(t, o, r, c, C[1], C[2], C[3], C[4], C[5], f.line);
487
809
  let i = t.messages.length - 1, a = t.messages[i];
488
810
  if (l !== void 0) {
489
811
  if (a.to !== l) throw Error(`Line ${f.line}: The created participant ${l} does not have an associated creating message after its declaration. Please check the sequence diagram.`);
490
- F(t, l).createdAt = i, l = void 0;
812
+ V(t, l).createdAt = i, l = void 0;
491
813
  }
492
814
  if (u !== void 0) {
493
815
  if (a.from !== u && a.to !== u) throw Error(`Line ${f.line}: The destroyed participant ${u} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);
494
- F(t, u).destroyedAt = i, u = void 0;
816
+ V(t, u).destroyedAt = i, u = void 0;
495
817
  }
496
818
  continue;
497
819
  }
@@ -506,21 +828,21 @@ function P(e) {
506
828
  }
507
829
  return t;
508
830
  }
509
- function F(e, t) {
831
+ function V(e, t) {
510
832
  let n = e.actors.find((e) => e.id === t);
511
833
  if (n === void 0)
512
834
  /* v8 ignore next */
513
835
  throw Error(`Sequence diagram: unknown actor "${t}"`);
514
836
  return n;
515
837
  }
516
- function I(e, t, n, r, i) {
838
+ function H(e, t, n, r, i) {
517
839
  t.has(r) || (t.add(r), e.actors.push({
518
840
  id: r,
519
841
  label: r,
520
842
  type: "participant"
521
- })), L(e, n, r, i);
843
+ })), U(e, n, r, i);
522
844
  }
523
- function L(e, t, n, r) {
845
+ function U(e, t, n, r) {
524
846
  let i = t.open;
525
847
  if (i === void 0) return;
526
848
  let a = t.membership.get(n);
@@ -532,8 +854,8 @@ function L(e, t, n, r) {
532
854
  t.membership.set(n, i), e.boxes[i].actorIds.push(n);
533
855
  }
534
856
  }
535
- function R(e, t, r, i, a, o, s, c, l, u) {
536
- I(e, t, r, a, u), I(e, t, r, c, u);
857
+ function ke(e, t, r, i, a, o, s, c, l, u) {
858
+ H(e, t, r, a, u), H(e, t, r, c, u);
537
859
  let d = o === "<<->>" || o === "<<-->>", f = d ? o === "<<-->>" ? "dashed" : "solid" : o.startsWith("--") ? "dashed" : "solid", p = o.includes(">>") || o.includes("x") ? "filled" : "open", m = o.includes("x"), h = {
538
860
  from: a,
539
861
  to: c,
@@ -545,14 +867,14 @@ function R(e, t, r, i, a, o, s, c, l, u) {
545
867
  }
546
868
  //#endregion
547
869
  //#region packages/mermaid-parser/src/sequence/activation-check.ts
548
- function z(e, t) {
870
+ function W(e, t) {
549
871
  if (t < 0) return "before the first message";
550
872
  let n = e.messages[t];
551
873
  if (!n) return "at an unresolved position";
552
874
  let r = n.label ? `: ${n.label}` : "";
553
875
  return `after message ${t + 1} ("${n.from} -> ${n.to}${r}")`;
554
876
  }
555
- function B(e) {
877
+ function G(e) {
556
878
  let t = /* @__PURE__ */ new Map();
557
879
  for (let n of e.activations) {
558
880
  let e = t.get(n.afterIndex) ?? [];
@@ -589,13 +911,13 @@ function B(e) {
589
911
  n.pop() === void 0 && a.push({
590
912
  code: "UNMATCHED_DEACTIVATION",
591
913
  actorId: t.actorId,
592
- message: `"deactivate ${t.actorId}" ${z(e, t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`
914
+ message: `"deactivate ${t.actorId}" ${W(e, t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`
593
915
  });
594
916
  }
595
917
  for (let [t, n] of i) for (let r of n) a.push({
596
918
  code: "DANGLING_ACTIVATION",
597
919
  actorId: t,
598
- message: `"activate ${t}" opened ${z(e, r)} is never closed with a matching "deactivate ${t}".`
920
+ message: `"activate ${t}" opened ${W(e, r)} is never closed with a matching "deactivate ${t}".`
599
921
  });
600
922
  return {
601
923
  ok: a.length === 0,
@@ -604,10 +926,10 @@ function B(e) {
604
926
  }
605
927
  //#endregion
606
928
  //#region packages/mermaid-parser/src/sequence/activation-fix.ts
607
- function re(e) {
929
+ function Ae(e) {
608
930
  let n = t(e);
609
931
  if (n !== "sequence") throw Error(`fixActivationBalance only supports sequence diagrams (source must start with "sequenceDiagram"); detected diagram type: "${n}".`);
610
- let r = B(P(i(e)));
932
+ let r = G(B(i(e)));
611
933
  if (r.ok) return {
612
934
  ok: !0,
613
935
  originalDiagram: e,
@@ -626,7 +948,7 @@ function re(e) {
626
948
  }
627
949
  //#endregion
628
950
  //#region packages/mermaid-parser/src/xychart/parser.ts
629
- function ie(e) {
951
+ function je(e) {
630
952
  let t = {}, n = {}, r = [], i, a = !1;
631
953
  for (let o of e) {
632
954
  let e = o.text;
@@ -641,7 +963,7 @@ function ie(e) {
641
963
  }
642
964
  let c = e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);
643
965
  if (c) {
644
- c[1] && (t.title = c[1]), t.categories = V(c[2]).map((e) => H(e.trim()));
966
+ c[1] && (t.title = c[1]), t.categories = Me(c[2]).map((e) => Ne(e.trim()));
645
967
  continue;
646
968
  }
647
969
  let l = e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);
@@ -669,7 +991,7 @@ function ie(e) {
669
991
  if (f) {
670
992
  r.push({
671
993
  type: "bar",
672
- data: U(f[1], "bar", e, o.line)
994
+ data: K(f[1], "bar", e, o.line)
673
995
  });
674
996
  continue;
675
997
  }
@@ -677,12 +999,12 @@ function ie(e) {
677
999
  if (p) {
678
1000
  r.push({
679
1001
  type: "line",
680
- data: U(p[1], "line", e, o.line)
1002
+ data: K(p[1], "line", e, o.line)
681
1003
  });
682
1004
  continue;
683
1005
  }
684
1006
  let m = e.match(/^(x-axis|y-axis|bar|line|title)\b/i);
685
- if (m) throw G(m[1].toLowerCase(), e, o.line);
1007
+ if (m) throw Fe(m[1].toLowerCase(), e, o.line);
686
1008
  }
687
1009
  if (!n.range && r.length > 0) {
688
1010
  let e = r.flatMap((e) => e.data), t = Math.min(...e), i = Math.max(...e), a = i - t || 1;
@@ -702,36 +1024,36 @@ function ie(e) {
702
1024
  series: r
703
1025
  };
704
1026
  }
705
- function V(e) {
1027
+ function Me(e) {
706
1028
  let t = [], n = "", r = !1;
707
1029
  for (let i of e) i === "\"" ? (r = !r, n += i) : i === "," && !r ? (t.push(n), n = "") : n += i;
708
1030
  return t.push(n), t;
709
1031
  }
710
- function H(e) {
1032
+ function Ne(e) {
711
1033
  return e.length >= 2 && e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
712
1034
  }
713
- function U(e, t, n, r) {
1035
+ function K(e, t, n, r) {
714
1036
  return e.split(",").map((e, i) => {
715
1037
  let a = e.trim(), o = parseFloat(a);
716
1038
  if (a.length === 0 || Number.isNaN(o)) throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i + 1} in "${n}". Every value in a ${t} [...] list must be a number.`);
717
1039
  return o;
718
1040
  });
719
1041
  }
720
- var W = {
1042
+ var Pe = {
721
1043
  "x-axis": "x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title",
722
1044
  "y-axis": "y-axis 0 --> 100 (numeric range) or y-axis \"Title\" (title only), optionally preceded by a quoted title before a range",
723
1045
  bar: "bar [10, 20, 30] — a comma-separated numeric array in square brackets",
724
1046
  line: "line [10, 20, 30] — a comma-separated numeric array in square brackets",
725
1047
  title: "title \"Chart Title\" — a double-quoted string"
726
1048
  };
727
- function G(e, t, n) {
728
- let r = W[e] ?? e;
1049
+ function Fe(e, t, n) {
1050
+ let r = Pe[e] ?? e;
729
1051
  return /* @__PURE__ */ Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`);
730
1052
  }
731
1053
  //#endregion
732
1054
  //#region packages/mermaid-parser/src/xychart/colors.ts
733
- var K = "#3b82f6";
734
- function q(e) {
1055
+ var q = "#3b82f6";
1056
+ function J(e) {
735
1057
  let t = e.replace("#", ""), n = parseInt(t.substring(0, 2), 16) / 255, r = parseInt(t.substring(2, 4), 16) / 255, i = parseInt(t.substring(4, 6), 16) / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = (a + o) / 2;
736
1058
  if (a === o) return [
737
1059
  0,
@@ -745,7 +1067,7 @@ function q(e) {
745
1067
  s * 100
746
1068
  ];
747
1069
  }
748
- function J(e, t, n) {
1070
+ function Ie(e, t, n) {
749
1071
  let r = t / 100, i = n / 100, a = (1 - Math.abs(2 * i - 1)) * r, o = a * (1 - Math.abs(e / 60 % 2 - 1)), s = i - a / 2, c, l, u;
750
1072
  e < 60 ? (c = a, l = o, u = 0) : e < 120 ? (c = o, l = a, u = 0) : e < 180 ? (c = 0, l = a, u = o) : e < 240 ? (c = 0, l = o, u = a) : e < 300 ? (c = o, l = 0, u = a) : (c = a, l = 0, u = o);
751
1073
  let d = (e) => Math.round((e + s) * 255).toString(16).padStart(2, "0");
@@ -755,12 +1077,12 @@ function Y(e) {
755
1077
  return /^#[0-9a-fA-F]{6}$/.test(e);
756
1078
  }
757
1079
  function X(e) {
758
- return q(e)[2] < 50;
1080
+ return J(e)[2] < 50;
759
1081
  }
760
- function ae(e, t, n) {
1082
+ function Le(e, t, n) {
761
1083
  if (e === 0) return t;
762
- let r = Y(t) ? t : K, i = n && Y(n) ? n : void 0, [a, o] = q(r), s = Math.max(55, Math.min(85, o)), c = Math.ceil(e / 2), l = e % 2 == 1, u = i && X(i) ? !l : l, d = u ? Math.max(25, 48 - c * 13) : Math.min(78, 55 + c * 11);
763
- return J(((a + (u ? -8 : 12) * c) % 360 + 360) % 360, s, d);
1084
+ let r = Y(t) ? t : q, i = n && Y(n) ? n : void 0, [a, o] = J(r), s = Math.max(55, Math.min(85, o)), c = Math.ceil(e / 2), l = e % 2 == 1, u = i && X(i) ? !l : l, d = u ? Math.max(25, 48 - c * 13) : Math.min(78, 55 + c * 11);
1085
+ return Ie(((a + (u ? -8 : -12) * c) % 360 + 360) % 360, s, d);
764
1086
  }
765
1087
  //#endregion
766
1088
  //#region packages/mermaid-parser/src/expanded-shapes.ts
@@ -890,18 +1212,18 @@ var Z = {
890
1212
  text: "text",
891
1213
  anchor: "anchor"
892
1214
  };
893
- function oe(e) {
1215
+ function Re(e) {
894
1216
  return Z[e.trim().toLowerCase()];
895
1217
  }
896
- function se() {
1218
+ function Q() {
897
1219
  return Object.keys(Z).sort();
898
1220
  }
899
- function Q(e) {
1221
+ function ze(e) {
900
1222
  let t = {};
901
- for (let n of ce(e, ",")) {
1223
+ for (let n of Be(e, ",")) {
902
1224
  let e = n.trim();
903
1225
  if (e.length === 0) continue;
904
- let r = le(e, ":");
1226
+ let r = Ve(e, ":");
905
1227
  if (r === -1) {
906
1228
  t.shape ??= $(e);
907
1229
  continue;
@@ -911,7 +1233,7 @@ function Q(e) {
911
1233
  }
912
1234
  return t;
913
1235
  }
914
- function ce(e, t) {
1236
+ function Be(e, t) {
915
1237
  let n = [], r = "", i = null;
916
1238
  for (let a of e) {
917
1239
  if (i !== null) {
@@ -930,7 +1252,7 @@ function ce(e, t) {
930
1252
  }
931
1253
  return n.push(r), n;
932
1254
  }
933
- function le(e, t) {
1255
+ function Ve(e, t) {
934
1256
  let n = null;
935
1257
  for (let r = 0; r < e.length; r++) {
936
1258
  let i = e[r];
@@ -949,7 +1271,7 @@ function le(e, t) {
949
1271
  function $(e) {
950
1272
  return e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'")) ? e.slice(1, -1) : e;
951
1273
  }
952
- function ue(e) {
1274
+ function He(e) {
953
1275
  if (!e.startsWith("@{")) return;
954
1276
  let t = 0, n = null;
955
1277
  for (let r = 1; r < e.length; r++) {
@@ -973,6 +1295,6 @@ function ue(e) {
973
1295
  }
974
1296
  }
975
1297
  //#endregion
976
- export { K as CHART_ACCENT_FALLBACK, B as checkActivationBalance, re as fixActivationBalance, x as formatClassMember, ae as getSeriesColor, M as isBlockType, A as isCssColor, X as isDarkBackground, Y as isValidHex, se as knownShapeNames, ue as matchExpandedBlock, j as parseBoxHeader, f as parseClassDiagram, S as parseErDiagram, Q as parseExpandedMeta, _ as parseGenericTypes, P as parseSequenceDiagram, ie as parseXYChart, oe as resolveShapeName, N as toBlockType };
1298
+ export { q as CHART_ACCENT_FALLBACK, S as architectureToGraph, pe as c4BoundaryTypeLine, he as c4Placement, me as c4RelLabelLines, fe as c4TypeLine, G as checkActivationBalance, Ae as fixActivationBalance, M as formatClassMember, Le as getSeriesColor, R as isBlockType, I as isCssColor, X as isDarkBackground, Y as isValidHex, Q as knownShapeNames, He as matchExpandedBlock, _ as parseArchitecture, L as parseBoxHeader, le as parseC4Diagram, _e as parseClassDiagram, N as parseErDiagram, ze as parseExpandedMeta, A as parseGenericTypes, B as parseSequenceDiagram, je as parseXYChart, Re as resolveShapeName, z as toBlockType, ue as wrapC4Text };
977
1299
 
978
1300
  //# sourceMappingURL=index.js.map