@zombie-mermaid/mermaid-parser 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +841 -248
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/flowchart-edge-label-space-before-pipe.test.ts +54 -0
- package/src/__tests__/pie-mermaid-spec.test.ts +308 -0
- package/src/__tests__/pie-parser.test.ts +452 -0
- package/src/flowchart-parser.ts +1327 -0
- package/src/index.ts +7 -2
- package/src/pie/parser.ts +393 -0
- package/src/pie/types.ts +109 -0
package/dist/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { applyClickStatement as e, detectDiagramType as t,
|
|
1
|
+
import { applyClickStatement as e, detectDiagramType as t, extractInitConfig as n, normalizeBrTags as r, parseStyleProps as i, splitClassShorthand as a, splitStatements as o, splitStatementsByLine as s, toDirection as c, toDirection as l, tryApplyClassAssignment as u, tryApplyClassDef as d, tryApplyCssClass as f, tryApplyStyleStatement as p } from "@zombie-mermaid/core";
|
|
2
2
|
//#region packages/mermaid-parser/src/architecture/parser.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
3
|
+
var m = String.raw`[\w-]+`, h = new RegExp(String.raw`^(group|service)\s+(${m})\s*(?:\(([^)]*)\))?\s*(?:\[([^\]]*)\])?(?:\s+in\s+(${m}))?$`), g = new RegExp(String.raw`^junction\s+(${m})(?:\s+in\s+(${m}))?$`), _ = new RegExp(String.raw`^(${m})(\{group\})?:([LRTB])\s+(<)?--(>)?\s+([LRTB]):(${m})(\{group\})?$`), v = new RegExp(String.raw`^align\s+(?:row|column)\s+${m}(?:\s+${m})+$`);
|
|
4
|
+
function y(e, t) {
|
|
5
5
|
throw Error(`Architecture diagram, line ${e.line}: ${t} — "${e.text}"`);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function b(e) {
|
|
8
8
|
return e?.trim().replace(/^"(.*)"$/, "$1") || void 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function x(e) {
|
|
11
11
|
let t = {
|
|
12
12
|
groups: [],
|
|
13
13
|
services: [],
|
|
14
14
|
junctions: [],
|
|
15
15
|
edges: []
|
|
16
|
-
},
|
|
17
|
-
|
|
16
|
+
}, n = /* @__PURE__ */ new Map(), i = [], a = [], o = (e, t, r, a) => {
|
|
17
|
+
n.has(t) && y(e, `duplicate id "${t}"`), a === t && y(e, `"${t}" cannot be inside itself`), n.set(t, r), a && i.push({
|
|
18
18
|
stmt: e,
|
|
19
19
|
parent: a
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
for (let
|
|
23
|
-
let i = e[
|
|
22
|
+
for (let n = 1; n < e.length; n++) {
|
|
23
|
+
let i = e[n], s = i.text, c = s.match(h);
|
|
24
24
|
if (c) {
|
|
25
|
-
let e = c[1],
|
|
26
|
-
o(i,
|
|
25
|
+
let e = c[1], n = c[2], a = c[4], s = c[5];
|
|
26
|
+
o(i, n, e, s);
|
|
27
27
|
let l = {
|
|
28
|
-
id:
|
|
29
|
-
icon:
|
|
30
|
-
title: a === void 0 ?
|
|
28
|
+
id: n,
|
|
29
|
+
icon: b(c[3]),
|
|
30
|
+
title: a === void 0 ? n : r(a.trim()),
|
|
31
31
|
parent: s
|
|
32
32
|
};
|
|
33
33
|
e === "group" ? t.groups.push(l) : t.services.push(l);
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
let l = s.match(
|
|
36
|
+
let l = s.match(g);
|
|
37
37
|
if (l) {
|
|
38
38
|
let e = l[1], n = l[2];
|
|
39
39
|
o(i, e, "junction", n), t.junctions.push({
|
|
@@ -42,7 +42,7 @@ function _(e) {
|
|
|
42
42
|
});
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
let u = s.match(
|
|
45
|
+
let u = s.match(_);
|
|
46
46
|
if (u) {
|
|
47
47
|
a.push({
|
|
48
48
|
stmt: i,
|
|
@@ -59,9 +59,9 @@ function _(e) {
|
|
|
59
59
|
});
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
v.test(s) || y(i, "unrecognized statement");
|
|
63
63
|
}
|
|
64
|
-
for (let { stmt: e, parent: t } of i)
|
|
64
|
+
for (let { stmt: e, parent: t } of i) n.get(t) !== "group" && y(e, `"in ${t}" must name a declared group`);
|
|
65
65
|
let s = /* @__PURE__ */ new Map();
|
|
66
66
|
for (let e of t.groups) e.parent && s.set(e.id, e.parent);
|
|
67
67
|
for (let e of t.groups) {
|
|
@@ -71,41 +71,41 @@ function _(e) {
|
|
|
71
71
|
t.add(n);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
for (let { stmt: e, edge:
|
|
75
|
-
let i = [[
|
|
76
|
-
for (let [
|
|
77
|
-
let i =
|
|
78
|
-
i ||
|
|
79
|
-
let o = [...t.services, ...t.junctions].find((e) => e.id ===
|
|
80
|
-
a && !o &&
|
|
81
|
-
}
|
|
82
|
-
t.edges.push(
|
|
74
|
+
for (let { stmt: e, edge: r } of a) {
|
|
75
|
+
let i = [[r.source, r.sourceGroup], [r.target, r.targetGroup]];
|
|
76
|
+
for (let [r, a] of i) {
|
|
77
|
+
let i = n.get(r);
|
|
78
|
+
i || y(e, `unknown id "${r}"`), i === "group" && y(e, `edges connect services or junctions, not the group "${r}"`);
|
|
79
|
+
let o = [...t.services, ...t.junctions].find((e) => e.id === r)?.parent;
|
|
80
|
+
a && !o && y(e, `"{group}" needs "${r}" to be declared inside a group`);
|
|
81
|
+
}
|
|
82
|
+
t.edges.push(r);
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region packages/mermaid-parser/src/architecture/to-graph.ts
|
|
88
|
-
var
|
|
88
|
+
var S = {
|
|
89
89
|
database: "cylinder",
|
|
90
90
|
disk: "cylinder",
|
|
91
91
|
cloud: "stadium",
|
|
92
92
|
internet: "circle"
|
|
93
|
-
},
|
|
94
|
-
function
|
|
93
|
+
}, C = /* @__PURE__ */ new Set(["L", "R"]);
|
|
94
|
+
function ee(e) {
|
|
95
95
|
let t = 0, n = 0;
|
|
96
|
-
for (let r of e) for (let e of [r.sourcePort, r.targetPort])
|
|
96
|
+
for (let r of e) for (let e of [r.sourcePort, r.targetPort]) C.has(e) ? t++ : n++;
|
|
97
97
|
return n > t ? "TB" : "LR";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function te(e, t) {
|
|
100
100
|
let [n, r] = t === "LR" || t === "RL" ? ["L", "R"] : ["T", "B"];
|
|
101
101
|
return e.sourcePort === r || e.targetPort === n ? !1 : e.sourcePort === n || e.targetPort === r;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function ne(e) {
|
|
104
104
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
105
105
|
for (let r of e.services) t.set(r.id, {
|
|
106
106
|
id: r.id,
|
|
107
107
|
label: r.title,
|
|
108
|
-
shape: r.icon &&
|
|
108
|
+
shape: r.icon && S[r.icon] || "rectangle"
|
|
109
109
|
}), n.set(r.id, r.parent);
|
|
110
110
|
for (let r of e.junctions) t.set(r.id, {
|
|
111
111
|
id: r.id,
|
|
@@ -125,12 +125,12 @@ function S(e) {
|
|
|
125
125
|
n ? n.children.push(e) : i.push(e);
|
|
126
126
|
}
|
|
127
127
|
for (let [e, t] of n) r.get(t ?? "")?.nodeIds.push(e);
|
|
128
|
-
let a =
|
|
128
|
+
let a = ee(e.edges);
|
|
129
129
|
return {
|
|
130
130
|
direction: a,
|
|
131
131
|
nodes: t,
|
|
132
132
|
edges: e.edges.map((e) => {
|
|
133
|
-
let t = (e, t) => (t ? n.get(e) : void 0) ?? e, r = !
|
|
133
|
+
let t = (e, t) => (t ? n.get(e) : void 0) ?? e, r = !te(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
134
|
return {
|
|
135
135
|
source: i,
|
|
136
136
|
target: o,
|
|
@@ -149,17 +149,17 @@ function S(e) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region packages/mermaid-parser/src/c4/parser.ts
|
|
152
|
-
var
|
|
152
|
+
var re = {
|
|
153
153
|
c4context: "context",
|
|
154
154
|
c4container: "container",
|
|
155
155
|
c4component: "component",
|
|
156
156
|
c4dynamic: "dynamic",
|
|
157
157
|
c4deployment: "deployment"
|
|
158
|
-
},
|
|
158
|
+
}, ie = /^(?:UpdateElementStyle|UpdateRelStyle|UpdateLayoutConfig|LAYOUT_[A-Z_]+|SHOW_LEGEND|SHOW_FLOATING_LEGEND|AddElementTag|AddRelTag|AddBoundaryTag|RoleTag)\b/, ae = /^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/, oe = /^(?:Boundary|Enterprise_Boundary|System_Boundary|Container_Boundary)$/, se = /^(?:Deployment_Node|Node|Node_L|Node_R)$/, ce = /^(Rel|BiRel|Rel_U|Rel_Up|Rel_D|Rel_Down|Rel_L|Rel_Left|Rel_R|Rel_Right|Rel_Back|RelIndex)$/, le = {
|
|
159
159
|
Enterprise_Boundary: "ENTERPRISE",
|
|
160
160
|
System_Boundary: "SYSTEM",
|
|
161
161
|
Container_Boundary: "CONTAINER"
|
|
162
|
-
},
|
|
162
|
+
}, ue = {
|
|
163
163
|
Rel_U: "up",
|
|
164
164
|
Rel_Up: "up",
|
|
165
165
|
Rel_D: "down",
|
|
@@ -169,77 +169,77 @@ var C = {
|
|
|
169
169
|
Rel_R: "right",
|
|
170
170
|
Rel_Right: "right"
|
|
171
171
|
};
|
|
172
|
-
function
|
|
173
|
-
let t = e.trim(),
|
|
174
|
-
return n
|
|
172
|
+
function de(e) {
|
|
173
|
+
let t = e.trim(), n = t.length >= 2 && t.startsWith("\"") && t.endsWith("\"") ? t.slice(1, -1) : t;
|
|
174
|
+
return r(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function fe(e) {
|
|
177
177
|
let t = [], n = "", r = !1;
|
|
178
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(
|
|
179
|
+
return r ? null : (t.push(n), t.map((e) => e.trim()).filter((e) => !e.startsWith("$")).map(de));
|
|
180
180
|
}
|
|
181
|
-
var
|
|
182
|
-
function
|
|
181
|
+
var pe = /^([A-Za-z_][A-Za-z0-9_]*)\s*\((.*)\)\s*(\{)?\s*$/;
|
|
182
|
+
function w(e, t) {
|
|
183
183
|
throw Error(`C4 diagram, line ${e.line}: ${t} — "${e.text}"`);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
let t =
|
|
185
|
+
function me(e) {
|
|
186
|
+
let t = re[e[0]?.text.trim().toLowerCase() ?? ""];
|
|
187
187
|
if (!t) throw Error(`C4 diagram: expected a header of C4Context, C4Container, C4Component, C4Dynamic or C4Deployment, got "${e[0]?.text ?? ""}"`);
|
|
188
|
-
let
|
|
188
|
+
let n = {
|
|
189
189
|
variant: t,
|
|
190
190
|
elements: [],
|
|
191
191
|
boundaries: [],
|
|
192
192
|
relationships: []
|
|
193
|
-
}, i = /* @__PURE__ */ new Set(), a = [], o, s = (e, t) => (t ||
|
|
193
|
+
}, i = /* @__PURE__ */ new Set(), a = [], o, s = (e, t) => (t || w(e, "missing alias (first argument)"), i.has(t) && w(e, `duplicate alias "${t}"`), i.add(t), t);
|
|
194
194
|
for (let t = 1; t < e.length; t++) {
|
|
195
195
|
let i = e[t], c = i.text;
|
|
196
196
|
if (c === "}") {
|
|
197
|
-
a.length === 0 &&
|
|
197
|
+
a.length === 0 && w(i, "unmatched \"}\""), a.pop();
|
|
198
198
|
continue;
|
|
199
199
|
}
|
|
200
200
|
if (c === "{") {
|
|
201
|
-
o ||
|
|
201
|
+
o || w(i, "unexpected \"{\""), a.push(o), o = void 0;
|
|
202
202
|
continue;
|
|
203
203
|
}
|
|
204
204
|
o = void 0;
|
|
205
205
|
let l = c.match(/^title(?:\s+(.*))?$/i);
|
|
206
206
|
if (l) {
|
|
207
|
-
|
|
207
|
+
n.title = r((l[1] ?? "").trim());
|
|
208
208
|
continue;
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
211
|
-
let u = c.match(
|
|
212
|
-
u ||
|
|
213
|
-
let d = u[1], f = u[3] === "{", p =
|
|
214
|
-
p ||
|
|
215
|
-
let m = d.match(
|
|
210
|
+
if (ie.test(c)) continue;
|
|
211
|
+
let u = c.match(pe);
|
|
212
|
+
u || w(i, "unrecognized statement");
|
|
213
|
+
let d = u[1], f = u[3] === "{", p = fe(u[2]);
|
|
214
|
+
p || w(i, "unbalanced quotes");
|
|
215
|
+
let m = d.match(ae);
|
|
216
216
|
if (m) {
|
|
217
|
-
f &&
|
|
218
|
-
let e = m[1].toLowerCase(), t = m[2] === "Db" ? "db" : m[2] === "Queue" ? "queue" : "default",
|
|
217
|
+
f && w(i, `"${d}" cannot contain a block`);
|
|
218
|
+
let e = m[1].toLowerCase(), t = m[2] === "Db" ? "db" : m[2] === "Queue" ? "queue" : "default", r = e === "container" || e === "component", o = s(i, p[0]), c = {
|
|
219
219
|
alias: o,
|
|
220
220
|
kind: e,
|
|
221
221
|
shape: t,
|
|
222
222
|
external: m[3] !== void 0,
|
|
223
223
|
label: p[1] || o
|
|
224
|
-
}, l =
|
|
225
|
-
l && (c.technology = l), u && (c.description = u),
|
|
224
|
+
}, l = r ? p[2] : void 0, u = r ? p[3] : p[2];
|
|
225
|
+
l && (c.technology = l), u && (c.description = u), n.elements.push(c), a.at(-1)?.elementAliases.push(o);
|
|
226
226
|
continue;
|
|
227
227
|
}
|
|
228
|
-
if (
|
|
229
|
-
let e =
|
|
228
|
+
if (oe.test(d) || se.test(d)) {
|
|
229
|
+
let e = se.test(d), t = s(i, p[0]), r = {
|
|
230
230
|
alias: t,
|
|
231
231
|
label: p[1] || t,
|
|
232
232
|
elementAliases: [],
|
|
233
233
|
children: []
|
|
234
234
|
};
|
|
235
|
-
|
|
235
|
+
r.type = le[d] || (p[2] && (e || d === "Boundary") ? p[2] : e ? "node" : "system"), e && p[3] && (r.description = p[3]);
|
|
236
236
|
let c = a.at(-1);
|
|
237
|
-
c ? c.children.push(
|
|
237
|
+
c ? c.children.push(r) : n.boundaries.push(r), f ? a.push(r) : o = r;
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
|
-
if (d.match(
|
|
240
|
+
if (d.match(ce)) {
|
|
241
241
|
let e = d === "RelIndex" ? p.slice(1) : p;
|
|
242
|
-
(!e[0] || !e[1]) &&
|
|
242
|
+
(!e[0] || !e[1]) && w(i, "a relationship needs \"from\" and \"to\" aliases");
|
|
243
243
|
let t = {
|
|
244
244
|
from: e[0],
|
|
245
245
|
to: e[1],
|
|
@@ -247,22 +247,22 @@ function le(e) {
|
|
|
247
247
|
bidirectional: d === "BiRel"
|
|
248
248
|
};
|
|
249
249
|
e[3] && (t.technology = e[3]), d === "Rel_Back" && (t.reversed = !0);
|
|
250
|
-
let
|
|
251
|
-
|
|
250
|
+
let r = ue[d];
|
|
251
|
+
r && (t.layout = r), n.relationships.push(t);
|
|
252
252
|
continue;
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
w(i, `unknown C4 macro "${d}"`);
|
|
255
255
|
}
|
|
256
256
|
if (a.length > 0) throw Error(`C4 diagram: boundary "${a.at(-1).alias}" is missing its closing "}"`);
|
|
257
|
-
|
|
257
|
+
n.variant === "dynamic" && n.relationships.forEach((e, t) => {
|
|
258
258
|
e.index = String(t + 1);
|
|
259
259
|
});
|
|
260
|
-
for (let e of
|
|
261
|
-
return
|
|
260
|
+
for (let e of n.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 n;
|
|
262
262
|
}
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region packages/mermaid-parser/src/c4/format.ts
|
|
265
|
-
function
|
|
265
|
+
function he(e, t) {
|
|
266
266
|
let n = [];
|
|
267
267
|
for (let r of e.split("\n")) {
|
|
268
268
|
let e = "";
|
|
@@ -271,24 +271,24 @@ function ue(e, t) {
|
|
|
271
271
|
}
|
|
272
272
|
return n;
|
|
273
273
|
}
|
|
274
|
-
var
|
|
274
|
+
var ge = {
|
|
275
275
|
person: "Person",
|
|
276
276
|
system: "Software System",
|
|
277
277
|
container: "Container",
|
|
278
278
|
component: "Component"
|
|
279
279
|
};
|
|
280
|
-
function
|
|
280
|
+
function _e(e) {
|
|
281
281
|
let t = (e.kind === "container" || e.kind === "component") && e.technology ? `: ${e.technology}` : "";
|
|
282
|
-
return `[${
|
|
282
|
+
return `[${ge[e.kind]}${t}]`;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function ve(e) {
|
|
285
285
|
return e.type ? `[${e.type}]` : void 0;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ye(e) {
|
|
288
288
|
let t = [], n = [e.index ? `${e.index}:` : "", e.label].filter(Boolean).join(" ");
|
|
289
289
|
return n && t.push(n), e.technology && t.push(`[${e.technology}]`), t;
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function be(e) {
|
|
292
292
|
switch (e.layout) {
|
|
293
293
|
case "up": return {
|
|
294
294
|
source: e.to,
|
|
@@ -324,9 +324,9 @@ function he(e) {
|
|
|
324
324
|
}
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region packages/mermaid-parser/src/class/parser.ts
|
|
327
|
-
var
|
|
328
|
-
function
|
|
329
|
-
let
|
|
327
|
+
var xe = "<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--", Se = new RegExp(xe);
|
|
328
|
+
function Ce(t) {
|
|
329
|
+
let n = {
|
|
330
330
|
classes: [],
|
|
331
331
|
relationships: [],
|
|
332
332
|
namespaces: [],
|
|
@@ -335,53 +335,53 @@ function _e(t) {
|
|
|
335
335
|
classAssignments: /* @__PURE__ */ new Map(),
|
|
336
336
|
nodeStyles: /* @__PURE__ */ new Map(),
|
|
337
337
|
notes: []
|
|
338
|
-
},
|
|
339
|
-
for (let
|
|
340
|
-
let h = t[
|
|
341
|
-
if (
|
|
338
|
+
}, i = /* @__PURE__ */ new Map(), o = null, s = null, c = 0, l;
|
|
339
|
+
for (let a = 1; a < t.length; a++) {
|
|
340
|
+
let h = t[a], g = h.text;
|
|
341
|
+
if (s && c > 0) {
|
|
342
342
|
if (g === "}") {
|
|
343
|
-
|
|
343
|
+
c--, c === 0 && (s = null, l = void 0);
|
|
344
344
|
continue;
|
|
345
345
|
}
|
|
346
346
|
let e = g.match(/^<<(\w+)>>$/);
|
|
347
347
|
if (e) {
|
|
348
|
-
|
|
348
|
+
s.annotation = e[1];
|
|
349
349
|
continue;
|
|
350
350
|
}
|
|
351
351
|
if (g.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${g}" — expected "<<name>>" (e.g. "<<interface>>").`);
|
|
352
|
-
|
|
352
|
+
T(s, g, h.line);
|
|
353
353
|
continue;
|
|
354
354
|
}
|
|
355
355
|
if (/^click\s+/i.test(g)) {
|
|
356
|
-
e(g,
|
|
356
|
+
e(g, n.interactions);
|
|
357
357
|
continue;
|
|
358
358
|
}
|
|
359
359
|
let _ = g.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);
|
|
360
360
|
if (_) {
|
|
361
361
|
let e = _[1];
|
|
362
|
-
|
|
363
|
-
text:
|
|
362
|
+
n.notes.push({
|
|
363
|
+
text: r(_[2]),
|
|
364
364
|
...e ? { forClass: e } : {}
|
|
365
365
|
});
|
|
366
366
|
continue;
|
|
367
367
|
}
|
|
368
|
-
if (
|
|
368
|
+
if (d(g, n) || p(g, n) || f(g, n) || u(g, n)) continue;
|
|
369
369
|
let v = g.match(/^namespace\s+(\S+)\s*\{$/);
|
|
370
370
|
if (v) {
|
|
371
|
-
|
|
371
|
+
o = {
|
|
372
372
|
name: v[1],
|
|
373
373
|
classIds: []
|
|
374
374
|
};
|
|
375
375
|
continue;
|
|
376
376
|
}
|
|
377
|
-
if (g === "}" &&
|
|
378
|
-
|
|
377
|
+
if (g === "}" && o) {
|
|
378
|
+
n.namespaces.push(o), o = null;
|
|
379
379
|
continue;
|
|
380
380
|
}
|
|
381
381
|
let y = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);
|
|
382
382
|
if (y) {
|
|
383
383
|
let e = m(y[1], y[2]);
|
|
384
|
-
|
|
384
|
+
s = i.get(e) ?? null, c = 1, l = h.line;
|
|
385
385
|
continue;
|
|
386
386
|
}
|
|
387
387
|
let b = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);
|
|
@@ -391,44 +391,44 @@ function _e(t) {
|
|
|
391
391
|
}
|
|
392
392
|
let x = g.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);
|
|
393
393
|
if (x) {
|
|
394
|
-
let e = m(x[1], void 0), t =
|
|
394
|
+
let e = m(x[1], void 0), t = i.get(e), n = x[2], r = n.match(/^<<(\w+)>>$/);
|
|
395
395
|
if (t && r) t.annotation = r[1];
|
|
396
396
|
else if (t && n.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);
|
|
397
|
-
else t && n &&
|
|
397
|
+
else t && n && T(t, n, h.line);
|
|
398
398
|
continue;
|
|
399
399
|
}
|
|
400
400
|
let S = g.match(/^(\S+?)\s*:\s*(.+)$/);
|
|
401
401
|
if (S) {
|
|
402
402
|
let e = S[2];
|
|
403
403
|
if (!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)) {
|
|
404
|
-
|
|
404
|
+
T(we(i, S[1]), e, h.line);
|
|
405
405
|
continue;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
let C =
|
|
408
|
+
let C = De(g);
|
|
409
409
|
if (C) {
|
|
410
|
-
C.from = m(C.from, void 0, !1), C.to = m(C.to, void 0, !1),
|
|
410
|
+
C.from = m(C.from, void 0, !1), C.to = m(C.to, void 0, !1), n.relationships.push(C);
|
|
411
411
|
continue;
|
|
412
412
|
}
|
|
413
|
-
if (
|
|
413
|
+
if (Se.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 --.`);
|
|
414
414
|
}
|
|
415
|
-
if (
|
|
416
|
-
return
|
|
417
|
-
function m(e, t,
|
|
418
|
-
let { id:
|
|
419
|
-
if (!
|
|
420
|
-
let e =
|
|
421
|
-
e && (
|
|
422
|
-
}
|
|
423
|
-
let d =
|
|
424
|
-
return
|
|
415
|
+
if (s !== null) throw Error(`Line ${l}: Unclosed class body for "${s.id}" — expected a closing "}" before the diagram ends.`);
|
|
416
|
+
return n.classes = [...i.values()], n;
|
|
417
|
+
function m(e, t, r = !0) {
|
|
418
|
+
let { id: s, className: c } = a(e), l = s, u = t;
|
|
419
|
+
if (!u) {
|
|
420
|
+
let e = s.match(/^(.+?)~(\w+)~$/);
|
|
421
|
+
e && (l = e[1], u = e[2]);
|
|
422
|
+
}
|
|
423
|
+
let d = we(i, l);
|
|
424
|
+
return u && (d.label = `${l}<${u}>`), c && n.classAssignments.set(l, c), r && o && o.classIds.push(l), l;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
function
|
|
428
|
-
let r =
|
|
427
|
+
function T(e, t, n) {
|
|
428
|
+
let r = Ee(t, n);
|
|
429
429
|
r && (r.isMethod ? e.methods.push(r.member) : e.attributes.push(r.member));
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function we(e, t) {
|
|
432
432
|
let n = e.get(t);
|
|
433
433
|
return n || (n = {
|
|
434
434
|
id: t,
|
|
@@ -437,11 +437,11 @@ function O(e, t) {
|
|
|
437
437
|
methods: []
|
|
438
438
|
}, e.set(t, n)), n;
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function E(e, t) {
|
|
441
441
|
return Math.max(0, e.split(t).length - 1);
|
|
442
442
|
}
|
|
443
|
-
function
|
|
444
|
-
let t =
|
|
443
|
+
function Te(e) {
|
|
444
|
+
let t = E(e, "~");
|
|
445
445
|
if (t <= 1) return e;
|
|
446
446
|
let n = e, r = !1;
|
|
447
447
|
t % 2 != 0 && n.startsWith("~") && (n = n.slice(1), r = !0);
|
|
@@ -449,26 +449,26 @@ function ve(e) {
|
|
|
449
449
|
for (; a !== -1 && o !== -1 && a !== o;) i[a] = "<", i[o] = ">", a = i.indexOf("~"), o = i.lastIndexOf("~");
|
|
450
450
|
return r && i.unshift("~"), i.join("");
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function D(e) {
|
|
453
453
|
let t = e.split(/(,)/), n = [];
|
|
454
454
|
for (let e = 0; e < t.length; e++) {
|
|
455
455
|
let r = t[e];
|
|
456
456
|
if (r === "," && e > 0 && e + 1 < t.length) {
|
|
457
457
|
let i = t[e - 1], a = t[e + 1];
|
|
458
|
-
|
|
458
|
+
E(i, "~") === 1 && E(a, "~") === 1 && (r = `${i},${a}`, e++, n.pop());
|
|
459
459
|
}
|
|
460
|
-
n.push(
|
|
460
|
+
n.push(Te(r));
|
|
461
461
|
}
|
|
462
462
|
return n.join("");
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function Ee(e, t) {
|
|
465
465
|
let n = e.trim().replace(/;$/, "");
|
|
466
466
|
if (!n) return null;
|
|
467
467
|
let r = "", i = n, a = i[0];
|
|
468
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".`);
|
|
469
469
|
let o = i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);
|
|
470
470
|
if (o) {
|
|
471
|
-
let e =
|
|
471
|
+
let e = D(o[1].trim()), t = o[2]?.trim(), n = t ? D(t) : void 0, a = o[3]?.trim(), s = a ? D(a) : void 0, c = e.endsWith("$") || i.includes("$"), l = e.endsWith("*") || i.includes("*");
|
|
472
472
|
return {
|
|
473
473
|
member: {
|
|
474
474
|
visibility: r,
|
|
@@ -482,7 +482,7 @@ function ye(e, t) {
|
|
|
482
482
|
isMethod: !0
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
|
-
let s =
|
|
485
|
+
let s = D(i), c = s.endsWith("$"), l = s.endsWith("*");
|
|
486
486
|
return {
|
|
487
487
|
member: {
|
|
488
488
|
visibility: r,
|
|
@@ -495,12 +495,12 @@ function ye(e, t) {
|
|
|
495
495
|
isMethod: !1
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${
|
|
498
|
+
function De(e) {
|
|
499
|
+
let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${xe})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));
|
|
500
500
|
if (!t) return null;
|
|
501
|
-
let
|
|
501
|
+
let n = t[1], i = t[2], a = i ? r(i) : void 0, o = t[3].trim(), s = t[4], c = s ? r(s) : void 0, l = t[6] ? `${t[5]}:::${t[6]}` : t[5], u = t[7]?.trim(), d = u ? r(u) : void 0, f = Oe(o);
|
|
502
502
|
return f ? {
|
|
503
|
-
from:
|
|
503
|
+
from: n,
|
|
504
504
|
to: l,
|
|
505
505
|
type: f.type,
|
|
506
506
|
markerAt: f.markerAt,
|
|
@@ -509,7 +509,7 @@ function be(e) {
|
|
|
509
509
|
toCardinality: c
|
|
510
510
|
} : null;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function Oe(e) {
|
|
513
513
|
switch (e.trim()) {
|
|
514
514
|
case "<|--": return {
|
|
515
515
|
type: "inheritance",
|
|
@@ -568,51 +568,51 @@ function j(e) {
|
|
|
568
568
|
}
|
|
569
569
|
//#endregion
|
|
570
570
|
//#region packages/mermaid-parser/src/class/format.ts
|
|
571
|
-
function
|
|
571
|
+
function ke(e) {
|
|
572
572
|
return `${e.visibility ? `${e.visibility} ` : ""}${e.isMethod ? `${e.name}(${e.params || ""})` : e.name}${e.type ? `: ${e.type}` : ""}`;
|
|
573
573
|
}
|
|
574
574
|
//#endregion
|
|
575
575
|
//#region packages/mermaid-parser/src/er/parser.ts
|
|
576
|
-
function
|
|
576
|
+
function Ae(e) {
|
|
577
577
|
let t = {
|
|
578
578
|
entities: [],
|
|
579
579
|
relationships: []
|
|
580
|
-
},
|
|
581
|
-
for (let
|
|
582
|
-
let
|
|
580
|
+
}, n = /* @__PURE__ */ new Map(), i = null;
|
|
581
|
+
for (let a = 1; a < e.length; a++) {
|
|
582
|
+
let o = e[a], s = o.text;
|
|
583
583
|
if (i) {
|
|
584
|
-
if (
|
|
584
|
+
if (s === "}") {
|
|
585
585
|
i = null;
|
|
586
586
|
continue;
|
|
587
587
|
}
|
|
588
|
-
let e =
|
|
588
|
+
let e = je(s);
|
|
589
589
|
e && i.attributes.push(e);
|
|
590
590
|
continue;
|
|
591
591
|
}
|
|
592
|
-
let
|
|
593
|
-
if (
|
|
594
|
-
t.direction =
|
|
592
|
+
let c = s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
593
|
+
if (c) {
|
|
594
|
+
t.direction = l(c[1]);
|
|
595
595
|
continue;
|
|
596
596
|
}
|
|
597
|
-
let u =
|
|
597
|
+
let u = s.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);
|
|
598
598
|
if (u) {
|
|
599
|
-
let e = u[1], t = u[2], a =
|
|
599
|
+
let e = u[1], t = u[2], a = O(n, e, t === void 0 ? void 0 : r(t.trim().replace(/^["']|["']$/g, ""))), o = u[3].trim(), s = o.endsWith("}"), c = s ? o.slice(0, -1).trim() : o;
|
|
600
600
|
for (let e of c.split(";").map((e) => e.trim()).filter(Boolean)) {
|
|
601
|
-
let t =
|
|
601
|
+
let t = je(e);
|
|
602
602
|
t && a.attributes.push(t);
|
|
603
603
|
}
|
|
604
604
|
s || (i = a);
|
|
605
605
|
continue;
|
|
606
606
|
}
|
|
607
|
-
let d =
|
|
607
|
+
let d = Me(s, o.line);
|
|
608
608
|
if (d) {
|
|
609
|
-
|
|
609
|
+
O(n, d.entity1), O(n, d.entity2), t.relationships.push(d);
|
|
610
610
|
continue;
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
|
-
return t.entities = [...
|
|
613
|
+
return t.entities = [...n.values()], t;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function O(e, t, n) {
|
|
616
616
|
let r = e.get(t);
|
|
617
617
|
return r ? n !== void 0 && (r.label = n) : (r = {
|
|
618
618
|
id: t,
|
|
@@ -620,27 +620,27 @@ function P(e, t, n) {
|
|
|
620
620
|
attributes: []
|
|
621
621
|
}, e.set(t, r)), r;
|
|
622
622
|
}
|
|
623
|
-
function
|
|
623
|
+
function je(e) {
|
|
624
624
|
let t = e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);
|
|
625
625
|
if (!t) return null;
|
|
626
|
-
let
|
|
627
|
-
c && (s =
|
|
626
|
+
let n = t[1], i = t[2], a = t[3]?.trim() ?? "", o = [], s, c = a.match(/"([^"]*)"/);
|
|
627
|
+
c && (s = r(c[1]));
|
|
628
628
|
let l = a.replace(/"[^"]*"/, "").trim();
|
|
629
629
|
for (let e of l.split(/\s+/)) {
|
|
630
630
|
let t = e.toUpperCase();
|
|
631
631
|
(t === "PK" || t === "FK" || t === "UK") && o.push(t);
|
|
632
632
|
}
|
|
633
633
|
return {
|
|
634
|
-
type:
|
|
634
|
+
type: n,
|
|
635
635
|
name: i,
|
|
636
636
|
keys: o,
|
|
637
637
|
comment: s
|
|
638
638
|
};
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
let
|
|
642
|
-
if (!
|
|
643
|
-
let i =
|
|
640
|
+
function Me(e, t) {
|
|
641
|
+
let n = e.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);
|
|
642
|
+
if (!n) return null;
|
|
643
|
+
let i = n[1], a = n[2], o = n[3], s = n[4] !== void 0, c = n[4]?.trim() ?? "", l = a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/), u = l ? Ne(l[1]) : null, d = l ? Pe(l[3]) : null;
|
|
644
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{").`);
|
|
645
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".`);
|
|
646
646
|
return {
|
|
@@ -648,40 +648,40 @@ function xe(e, t) {
|
|
|
648
648
|
entity2: o,
|
|
649
649
|
cardinality1: u,
|
|
650
650
|
cardinality2: d,
|
|
651
|
-
label:
|
|
651
|
+
label: r(c.replace(/^["']|["']$/g, "")),
|
|
652
652
|
identifying: l[2] === "--"
|
|
653
653
|
};
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function Ne(e) {
|
|
656
656
|
return e === "||" ? "one" : e === "|o" ? "zero-one" : e === "}|" ? "many" : e === "}o" ? "zero-many" : null;
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function Pe(e) {
|
|
659
659
|
return e === "||" ? "one" : e === "o|" ? "zero-one" : e === "|{" ? "many" : e === "o{" ? "zero-many" : null;
|
|
660
660
|
}
|
|
661
661
|
//#endregion
|
|
662
662
|
//#region packages/mermaid-parser/src/sequence/box-color.ts
|
|
663
|
-
var
|
|
664
|
-
function
|
|
665
|
-
return
|
|
663
|
+
var Fe = 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(" ")), Ie = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Le = /^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;
|
|
664
|
+
function k(e) {
|
|
665
|
+
return Fe.has(e.toLowerCase()) || Ie.test(e) || Le.test(e);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function Re(e) {
|
|
668
668
|
let t = e.trim(), n = t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/), r = n?.[1] ?? "", i = n?.[2]?.trim() ?? "";
|
|
669
|
-
return r.toLowerCase() === "transparent" ? { label: i } : r !== "" &&
|
|
669
|
+
return r.toLowerCase() === "transparent" ? { label: i } : r !== "" && k(r) ? {
|
|
670
670
|
color: r,
|
|
671
671
|
label: i
|
|
672
672
|
} : { label: t };
|
|
673
673
|
}
|
|
674
674
|
//#endregion
|
|
675
675
|
//#region packages/mermaid-parser/src/sequence/parser.ts
|
|
676
|
-
function
|
|
676
|
+
function A(e) {
|
|
677
677
|
return e === "loop" || e === "alt" || e === "opt" || e === "par" || e === "critical" || e === "break" || e === "rect";
|
|
678
678
|
}
|
|
679
|
-
function
|
|
680
|
-
if (!
|
|
679
|
+
function j(e) {
|
|
680
|
+
if (!A(e)) throw Error(`Invalid block type: "${e}"`);
|
|
681
681
|
return e;
|
|
682
682
|
}
|
|
683
|
-
var
|
|
684
|
-
function
|
|
683
|
+
var ze = /^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/, Be = /^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;
|
|
684
|
+
function M(e) {
|
|
685
685
|
let t = {
|
|
686
686
|
actors: [],
|
|
687
687
|
messages: [],
|
|
@@ -689,7 +689,7 @@ function B(e) {
|
|
|
689
689
|
notes: [],
|
|
690
690
|
activations: [],
|
|
691
691
|
boxes: []
|
|
692
|
-
},
|
|
692
|
+
}, n = {
|
|
693
693
|
open: void 0,
|
|
694
694
|
membership: /* @__PURE__ */ new Map()
|
|
695
695
|
}, i = 0, a, o = /* @__PURE__ */ new Set(), s = [], c = {
|
|
@@ -700,12 +700,12 @@ function B(e) {
|
|
|
700
700
|
for (let d = 1; d < e.length; d++) {
|
|
701
701
|
let f = e[d], p = f.text, m = p.match(/^box(?:\s+(.*))?$/);
|
|
702
702
|
if (m) {
|
|
703
|
-
if (
|
|
704
|
-
let { color: e, label: o } =
|
|
705
|
-
label:
|
|
703
|
+
if (n.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`);
|
|
704
|
+
let { color: e, label: o } = Re(m[1] ?? ""), c = {
|
|
705
|
+
label: r(o),
|
|
706
706
|
actorIds: []
|
|
707
707
|
};
|
|
708
|
-
e !== void 0 && (c.color = e), t.boxes.push(c),
|
|
708
|
+
e !== void 0 && (c.color = e), t.boxes.push(c), n.open = t.boxes.length - 1, i = s.length, a = f.line;
|
|
709
709
|
continue;
|
|
710
710
|
}
|
|
711
711
|
let h = p.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);
|
|
@@ -714,15 +714,15 @@ function B(e) {
|
|
|
714
714
|
if (o.has(i)) throw Error(`Line ${f.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);
|
|
715
715
|
o.add(i), t.actors.push({
|
|
716
716
|
id: i,
|
|
717
|
-
label:
|
|
717
|
+
label: r(h[3]?.trim() ?? i),
|
|
718
718
|
type: e
|
|
719
|
-
}),
|
|
719
|
+
}), F(t, n, i, f.line), l = i;
|
|
720
720
|
continue;
|
|
721
721
|
}
|
|
722
722
|
let g = p.match(/^destroy\s+(.+)$/);
|
|
723
723
|
if (g) {
|
|
724
724
|
let e = g[1].trim();
|
|
725
|
-
|
|
725
|
+
P(t, o, n, e, f.line), u = e;
|
|
726
726
|
continue;
|
|
727
727
|
}
|
|
728
728
|
let _ = p.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);
|
|
@@ -733,18 +733,18 @@ function B(e) {
|
|
|
733
733
|
}
|
|
734
734
|
let v = p.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);
|
|
735
735
|
if (v) {
|
|
736
|
-
let e = v[1] === "actor" ? "actor" : "participant", i = v[2], a = v[3]?.trim() ?? i, s =
|
|
736
|
+
let e = v[1] === "actor" ? "actor" : "participant", i = v[2], a = v[3]?.trim() ?? i, s = r(a);
|
|
737
737
|
o.has(i) || (o.add(i), t.actors.push({
|
|
738
738
|
id: i,
|
|
739
739
|
label: s,
|
|
740
740
|
type: e
|
|
741
|
-
})),
|
|
741
|
+
})), F(t, n, i, f.line);
|
|
742
742
|
continue;
|
|
743
743
|
}
|
|
744
744
|
let y = p.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);
|
|
745
745
|
if (y) {
|
|
746
|
-
let e = y[1].toLowerCase(), i = y[2].trim(), a =
|
|
747
|
-
for (let e of s)
|
|
746
|
+
let e = y[1].toLowerCase(), i = y[2].trim(), a = r(y[3].trim()), s = i.split(",").map((e) => e.trim());
|
|
747
|
+
for (let e of s) P(t, o, n, e, f.line);
|
|
748
748
|
let c = "over";
|
|
749
749
|
e === "left of" ? c = "left" : e === "right of" && (c = "right"), t.notes.push({
|
|
750
750
|
actorIds: s,
|
|
@@ -756,7 +756,7 @@ function B(e) {
|
|
|
756
756
|
}
|
|
757
757
|
let b = p.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);
|
|
758
758
|
if (b) {
|
|
759
|
-
let e =
|
|
759
|
+
let e = j(b[1]), n = b[2]?.trim() ?? "", i = r(n);
|
|
760
760
|
s.push({
|
|
761
761
|
type: e,
|
|
762
762
|
label: i,
|
|
@@ -768,15 +768,15 @@ function B(e) {
|
|
|
768
768
|
}
|
|
769
769
|
let x = p.match(/^(else|and)\s*(.*)$/);
|
|
770
770
|
if (x && s.length > 0) {
|
|
771
|
-
let e = x[2]?.trim() ?? "",
|
|
771
|
+
let e = x[2]?.trim() ?? "", n = r(e);
|
|
772
772
|
s[s.length - 1].dividers.push({
|
|
773
773
|
index: t.messages.length,
|
|
774
|
-
label:
|
|
774
|
+
label: n
|
|
775
775
|
});
|
|
776
776
|
continue;
|
|
777
777
|
}
|
|
778
|
-
if (p === "end" &&
|
|
779
|
-
|
|
778
|
+
if (p === "end" && n.open !== void 0 && s.length === i) {
|
|
779
|
+
n.open = void 0, a = void 0;
|
|
780
780
|
continue;
|
|
781
781
|
}
|
|
782
782
|
if (p === "end" && s.length > 0) {
|
|
@@ -794,26 +794,26 @@ function B(e) {
|
|
|
794
794
|
let S = p.match(/^(activate|deactivate)\s+(.+)$/);
|
|
795
795
|
if (S) {
|
|
796
796
|
let e = S[2].trim();
|
|
797
|
-
|
|
797
|
+
P(t, o, n, e, f.line), t.activations.push({
|
|
798
798
|
actorId: e,
|
|
799
799
|
kind: S[1] === "activate" ? "start" : "end",
|
|
800
800
|
afterIndex: t.messages.length - 1
|
|
801
801
|
});
|
|
802
802
|
continue;
|
|
803
803
|
}
|
|
804
|
-
let C = p.match(
|
|
804
|
+
let C = p.match(ze) ?? p.match(Be);
|
|
805
805
|
if (C) {
|
|
806
|
-
let e = C[2],
|
|
807
|
-
if (
|
|
808
|
-
|
|
806
|
+
let e = C[2], r = C[4][0];
|
|
807
|
+
if (r === ">" || r === ")") throw Error(`Line ${f.line}: Malformed sequence-diagram arrow in "${p}" — "${e}${r}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);
|
|
808
|
+
Ve(t, o, n, c, C[1], C[2], C[3], C[4], C[5], f.line);
|
|
809
809
|
let i = t.messages.length - 1, a = t.messages[i];
|
|
810
810
|
if (l !== void 0) {
|
|
811
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.`);
|
|
812
|
-
|
|
812
|
+
N(t, l).createdAt = i, l = void 0;
|
|
813
813
|
}
|
|
814
814
|
if (u !== void 0) {
|
|
815
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.`);
|
|
816
|
-
|
|
816
|
+
N(t, u).destroyedAt = i, u = void 0;
|
|
817
817
|
}
|
|
818
818
|
continue;
|
|
819
819
|
}
|
|
@@ -822,27 +822,27 @@ function B(e) {
|
|
|
822
822
|
let e = s[s.length - 1];
|
|
823
823
|
throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`);
|
|
824
824
|
}
|
|
825
|
-
if (
|
|
826
|
-
let e = t.boxes[
|
|
825
|
+
if (n.open !== void 0) {
|
|
826
|
+
let e = t.boxes[n.open];
|
|
827
827
|
throw Error(`Line ${a}: Sequence diagram: unclosed "box${e.label ? ` ${e.label}` : ""}" — expected a matching "end" before the diagram ends.`);
|
|
828
828
|
}
|
|
829
829
|
return t;
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function N(e, t) {
|
|
832
832
|
let n = e.actors.find((e) => e.id === t);
|
|
833
833
|
if (n === void 0)
|
|
834
834
|
/* v8 ignore next */
|
|
835
835
|
throw Error(`Sequence diagram: unknown actor "${t}"`);
|
|
836
836
|
return n;
|
|
837
837
|
}
|
|
838
|
-
function
|
|
838
|
+
function P(e, t, n, r, i) {
|
|
839
839
|
t.has(r) || (t.add(r), e.actors.push({
|
|
840
840
|
id: r,
|
|
841
841
|
label: r,
|
|
842
842
|
type: "participant"
|
|
843
|
-
})),
|
|
843
|
+
})), F(e, n, r, i);
|
|
844
844
|
}
|
|
845
|
-
function
|
|
845
|
+
function F(e, t, n, r) {
|
|
846
846
|
let i = t.open;
|
|
847
847
|
if (i === void 0) return;
|
|
848
848
|
let a = t.membership.get(n);
|
|
@@ -854,12 +854,12 @@ function U(e, t, n, r) {
|
|
|
854
854
|
t.membership.set(n, i), e.boxes[i].actorIds.push(n);
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
|
-
function
|
|
858
|
-
|
|
857
|
+
function Ve(e, t, n, i, a, o, s, c, l, u) {
|
|
858
|
+
P(e, t, n, a, u), P(e, t, n, c, u);
|
|
859
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 = {
|
|
860
860
|
from: a,
|
|
861
861
|
to: c,
|
|
862
|
-
label:
|
|
862
|
+
label: r(l.trim()),
|
|
863
863
|
lineStyle: f,
|
|
864
864
|
arrowHead: p
|
|
865
865
|
};
|
|
@@ -867,14 +867,14 @@ function ke(e, t, r, i, a, o, s, c, l, u) {
|
|
|
867
867
|
}
|
|
868
868
|
//#endregion
|
|
869
869
|
//#region packages/mermaid-parser/src/sequence/activation-check.ts
|
|
870
|
-
function
|
|
870
|
+
function He(e, t) {
|
|
871
871
|
if (t < 0) return "before the first message";
|
|
872
872
|
let n = e.messages[t];
|
|
873
873
|
if (!n) return "at an unresolved position";
|
|
874
874
|
let r = n.label ? `: ${n.label}` : "";
|
|
875
875
|
return `after message ${t + 1} ("${n.from} -> ${n.to}${r}")`;
|
|
876
876
|
}
|
|
877
|
-
function
|
|
877
|
+
function I(e) {
|
|
878
878
|
let t = /* @__PURE__ */ new Map();
|
|
879
879
|
for (let n of e.activations) {
|
|
880
880
|
let e = t.get(n.afterIndex) ?? [];
|
|
@@ -911,13 +911,13 @@ function G(e) {
|
|
|
911
911
|
n.pop() === void 0 && a.push({
|
|
912
912
|
code: "UNMATCHED_DEACTIVATION",
|
|
913
913
|
actorId: t.actorId,
|
|
914
|
-
message: `"deactivate ${t.actorId}" ${
|
|
914
|
+
message: `"deactivate ${t.actorId}" ${He(e, t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`
|
|
915
915
|
});
|
|
916
916
|
}
|
|
917
917
|
for (let [t, n] of i) for (let r of n) a.push({
|
|
918
918
|
code: "DANGLING_ACTIVATION",
|
|
919
919
|
actorId: t,
|
|
920
|
-
message: `"activate ${t}" opened ${
|
|
920
|
+
message: `"activate ${t}" opened ${He(e, r)} is never closed with a matching "deactivate ${t}".`
|
|
921
921
|
});
|
|
922
922
|
return {
|
|
923
923
|
ok: a.length === 0,
|
|
@@ -926,10 +926,10 @@ function G(e) {
|
|
|
926
926
|
}
|
|
927
927
|
//#endregion
|
|
928
928
|
//#region packages/mermaid-parser/src/sequence/activation-fix.ts
|
|
929
|
-
function
|
|
929
|
+
function Ue(e) {
|
|
930
930
|
let n = t(e);
|
|
931
931
|
if (n !== "sequence") throw Error(`fixActivationBalance only supports sequence diagrams (source must start with "sequenceDiagram"); detected diagram type: "${n}".`);
|
|
932
|
-
let r =
|
|
932
|
+
let r = I(M(o(e)));
|
|
933
933
|
if (r.ok) return {
|
|
934
934
|
ok: !0,
|
|
935
935
|
originalDiagram: e,
|
|
@@ -937,18 +937,18 @@ function Ae(e) {
|
|
|
937
937
|
fixesApplied: [],
|
|
938
938
|
remainingIssues: []
|
|
939
939
|
};
|
|
940
|
-
let
|
|
940
|
+
let i = r.issues.filter((e) => e.code === "DANGLING_ACTIVATION"), a = r.issues.filter((e) => e.code !== "DANGLING_ACTIVATION"), s = i.map((e) => ` deactivate ${e.actorId}`).join("\n"), c = i.length === 0 ? e : `${e.replace(/\s+$/, "")}\n${s}`, l = i.map((e) => `Appended "deactivate ${e.actorId}" to close: ${e.message}`);
|
|
941
941
|
return {
|
|
942
|
-
ok:
|
|
942
|
+
ok: a.length === 0,
|
|
943
943
|
originalDiagram: e,
|
|
944
944
|
fixedDiagram: c,
|
|
945
945
|
fixesApplied: l,
|
|
946
|
-
remainingIssues:
|
|
946
|
+
remainingIssues: a
|
|
947
947
|
};
|
|
948
948
|
}
|
|
949
949
|
//#endregion
|
|
950
950
|
//#region packages/mermaid-parser/src/xychart/parser.ts
|
|
951
|
-
function
|
|
951
|
+
function We(e) {
|
|
952
952
|
let t = {}, n = {}, r = [], i, a = !1;
|
|
953
953
|
for (let o of e) {
|
|
954
954
|
let e = o.text;
|
|
@@ -963,7 +963,7 @@ function je(e) {
|
|
|
963
963
|
}
|
|
964
964
|
let c = e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);
|
|
965
965
|
if (c) {
|
|
966
|
-
c[1] && (t.title = c[1]), t.categories =
|
|
966
|
+
c[1] && (t.title = c[1]), t.categories = Ge(c[2]).map((e) => Ke(e.trim()));
|
|
967
967
|
continue;
|
|
968
968
|
}
|
|
969
969
|
let l = e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);
|
|
@@ -991,7 +991,7 @@ function je(e) {
|
|
|
991
991
|
if (f) {
|
|
992
992
|
r.push({
|
|
993
993
|
type: "bar",
|
|
994
|
-
data:
|
|
994
|
+
data: L(f[1], "bar", e, o.line)
|
|
995
995
|
});
|
|
996
996
|
continue;
|
|
997
997
|
}
|
|
@@ -999,12 +999,12 @@ function je(e) {
|
|
|
999
999
|
if (p) {
|
|
1000
1000
|
r.push({
|
|
1001
1001
|
type: "line",
|
|
1002
|
-
data:
|
|
1002
|
+
data: L(p[1], "line", e, o.line)
|
|
1003
1003
|
});
|
|
1004
1004
|
continue;
|
|
1005
1005
|
}
|
|
1006
1006
|
let m = e.match(/^(x-axis|y-axis|bar|line|title)\b/i);
|
|
1007
|
-
if (m) throw
|
|
1007
|
+
if (m) throw Je(m[1].toLowerCase(), e, o.line);
|
|
1008
1008
|
}
|
|
1009
1009
|
if (!n.range && r.length > 0) {
|
|
1010
1010
|
let e = r.flatMap((e) => e.data), t = Math.min(...e), i = Math.max(...e), a = i - t || 1;
|
|
@@ -1024,36 +1024,36 @@ function je(e) {
|
|
|
1024
1024
|
series: r
|
|
1025
1025
|
};
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1027
|
+
function Ge(e) {
|
|
1028
1028
|
let t = [], n = "", r = !1;
|
|
1029
1029
|
for (let i of e) i === "\"" ? (r = !r, n += i) : i === "," && !r ? (t.push(n), n = "") : n += i;
|
|
1030
1030
|
return t.push(n), t;
|
|
1031
1031
|
}
|
|
1032
|
-
function
|
|
1032
|
+
function Ke(e) {
|
|
1033
1033
|
return e.length >= 2 && e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1035
|
+
function L(e, t, n, r) {
|
|
1036
1036
|
return e.split(",").map((e, i) => {
|
|
1037
1037
|
let a = e.trim(), o = parseFloat(a);
|
|
1038
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.`);
|
|
1039
1039
|
return o;
|
|
1040
1040
|
});
|
|
1041
1041
|
}
|
|
1042
|
-
var
|
|
1042
|
+
var qe = {
|
|
1043
1043
|
"x-axis": "x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title",
|
|
1044
1044
|
"y-axis": "y-axis 0 --> 100 (numeric range) or y-axis \"Title\" (title only), optionally preceded by a quoted title before a range",
|
|
1045
1045
|
bar: "bar [10, 20, 30] — a comma-separated numeric array in square brackets",
|
|
1046
1046
|
line: "line [10, 20, 30] — a comma-separated numeric array in square brackets",
|
|
1047
1047
|
title: "title \"Chart Title\" — a double-quoted string"
|
|
1048
1048
|
};
|
|
1049
|
-
function
|
|
1050
|
-
let r =
|
|
1049
|
+
function Je(e, t, n) {
|
|
1050
|
+
let r = qe[e] ?? e;
|
|
1051
1051
|
return /* @__PURE__ */ Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`);
|
|
1052
1052
|
}
|
|
1053
1053
|
//#endregion
|
|
1054
1054
|
//#region packages/mermaid-parser/src/xychart/colors.ts
|
|
1055
|
-
var
|
|
1056
|
-
function
|
|
1055
|
+
var R = "#3b82f6";
|
|
1056
|
+
function z(e) {
|
|
1057
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;
|
|
1058
1058
|
if (a === o) return [
|
|
1059
1059
|
0,
|
|
@@ -1067,26 +1067,186 @@ function J(e) {
|
|
|
1067
1067
|
s * 100
|
|
1068
1068
|
];
|
|
1069
1069
|
}
|
|
1070
|
-
function
|
|
1070
|
+
function Ye(e, t, n) {
|
|
1071
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;
|
|
1072
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);
|
|
1073
1073
|
let d = (e) => Math.round((e + s) * 255).toString(16).padStart(2, "0");
|
|
1074
1074
|
return `#${d(c)}${d(l)}${d(u)}`;
|
|
1075
1075
|
}
|
|
1076
|
-
function
|
|
1076
|
+
function B(e) {
|
|
1077
1077
|
return /^#[0-9a-fA-F]{6}$/.test(e);
|
|
1078
1078
|
}
|
|
1079
|
-
function
|
|
1080
|
-
return
|
|
1079
|
+
function V(e) {
|
|
1080
|
+
return z(e)[2] < 50;
|
|
1081
1081
|
}
|
|
1082
|
-
function
|
|
1082
|
+
function Xe(e, t, n) {
|
|
1083
1083
|
if (e === 0) return t;
|
|
1084
|
-
let r =
|
|
1085
|
-
return
|
|
1084
|
+
let r = B(t) ? t : R, i = n && B(n) ? n : void 0, [a, o] = z(r), s = Math.max(55, Math.min(85, o)), c = Math.ceil(e / 2), l = e % 2 == 1, u = i && V(i) ? !l : l, d = u ? Math.max(25, 48 - c * 13) : Math.min(78, 55 + c * 11);
|
|
1085
|
+
return Ye(((a + (u ? -8 : -12) * c) % 360 + 360) % 360, s, d);
|
|
1086
|
+
}
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region packages/mermaid-parser/src/pie/parser.ts
|
|
1089
|
+
var Ze = [
|
|
1090
|
+
[null, /[\t ]+/y],
|
|
1091
|
+
["SHOW_DATA", /showData(?:(?=%%)|(?!\S))/y],
|
|
1092
|
+
["PIE", /pie(?:(?=%%)|(?!\S))/y],
|
|
1093
|
+
["COLON", /:/y],
|
|
1094
|
+
["NUMBER", /-?[0-9]+\.[0-9]+(?!\.)|-?(?:0|[1-9][0-9]*)(?!\.)/y],
|
|
1095
|
+
["ACC_DESCR", /[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*\{[^}]*\})/y],
|
|
1096
|
+
["ACC_TITLE", /[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y],
|
|
1097
|
+
["TITLE", /[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y],
|
|
1098
|
+
["STRING", /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/y],
|
|
1099
|
+
["NEWLINE", /\n/y],
|
|
1100
|
+
[null, /[\t ]*%%[^\n\r]*/y]
|
|
1101
|
+
], Qe = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi, $e = /accDescr(?:[\t ]*:([^\n\r]*)|\s*\{([^}]*)\})/, et = /accTitle[\t ]*:([^\n\r]*)/, tt = /title([\t ][^\n\r]*|)/, nt = "A pie chart is `pie [showData] [title <text>]` followed by lines of `\"Label\" : value` (label quoted with \" or '), `title <text>`, `accTitle: <text>`, or `accDescr: <text>`.";
|
|
1102
|
+
function rt(e) {
|
|
1103
|
+
return e.replace(/\r\n?/g, "\n").replace(/<(\w+)([^>]*)>/g, (e, t, n) => "<" + t + n.replace(/="([^"]*)"/g, "='$1'") + ">").replace(Qe, (e) => e.replace(/[^\n]/g, ""));
|
|
1104
|
+
}
|
|
1105
|
+
function it(e) {
|
|
1106
|
+
let t = 0;
|
|
1107
|
+
for (let n of e) n === "\n" && t++;
|
|
1108
|
+
return t;
|
|
1109
|
+
}
|
|
1110
|
+
function H(e, t, n) {
|
|
1111
|
+
/* v8 ignore next -- every caller passes a line inside `lines` */
|
|
1112
|
+
let r = (e[t - 1] ?? "").trim();
|
|
1113
|
+
return /* @__PURE__ */ Error(`Line ${t}: ${n} in "${r}". ${nt}`);
|
|
1114
|
+
}
|
|
1115
|
+
function at(e, t, n) {
|
|
1116
|
+
let r = e[t];
|
|
1117
|
+
return r === "\"" || r === "'" ? `Unterminated quoted label (missing closing ${r})` : n?.kind === "COLON" ? "Invalid slice value — expected a number like 42 or 42.5 after \":\"" : n === void 0 || n.kind === "NEWLINE" || n.kind === "PIE" || n.kind === "SHOW_DATA" ? "Unrecognized statement — slice labels must be quoted, e.g. \"Dogs\" : 42" : `Unexpected text ${JSON.stringify(e.slice(t).split("\n")[0])}`;
|
|
1118
|
+
}
|
|
1119
|
+
function ot(e, t) {
|
|
1120
|
+
let n = [], r = 0, i = 1;
|
|
1121
|
+
for (; r < e.length;) {
|
|
1122
|
+
let a = !1;
|
|
1123
|
+
for (let [t, o] of Ze) {
|
|
1124
|
+
o.lastIndex = r;
|
|
1125
|
+
let s = o.exec(e);
|
|
1126
|
+
if (s === null || s[0].length === 0) continue;
|
|
1127
|
+
let c = s[0];
|
|
1128
|
+
t !== null && n.push({
|
|
1129
|
+
kind: t,
|
|
1130
|
+
text: c,
|
|
1131
|
+
line: i
|
|
1132
|
+
}), i += it(c), r += c.length, a = !0;
|
|
1133
|
+
break;
|
|
1134
|
+
}
|
|
1135
|
+
if (!a) throw H(t, i, at(e, r, n.at(-1)));
|
|
1136
|
+
}
|
|
1137
|
+
return n;
|
|
1138
|
+
}
|
|
1139
|
+
function st(e) {
|
|
1140
|
+
let t = "";
|
|
1141
|
+
for (let n = 1; n < e.length - 1; n++) {
|
|
1142
|
+
let r = e.charAt(n);
|
|
1143
|
+
if (r !== "\\") {
|
|
1144
|
+
t += r;
|
|
1145
|
+
continue;
|
|
1146
|
+
}
|
|
1147
|
+
let i = e.charAt(++n);
|
|
1148
|
+
switch (i) {
|
|
1149
|
+
case "b":
|
|
1150
|
+
t += "\b";
|
|
1151
|
+
break;
|
|
1152
|
+
case "f":
|
|
1153
|
+
t += "\f";
|
|
1154
|
+
break;
|
|
1155
|
+
case "n":
|
|
1156
|
+
t += "\n";
|
|
1157
|
+
break;
|
|
1158
|
+
case "r":
|
|
1159
|
+
t += "\r";
|
|
1160
|
+
break;
|
|
1161
|
+
case "t":
|
|
1162
|
+
t += " ";
|
|
1163
|
+
break;
|
|
1164
|
+
case "v":
|
|
1165
|
+
t += "\v";
|
|
1166
|
+
break;
|
|
1167
|
+
case "0":
|
|
1168
|
+
t += "\0";
|
|
1169
|
+
break;
|
|
1170
|
+
default: t += i;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return t;
|
|
1174
|
+
}
|
|
1175
|
+
function ct(e, t) {
|
|
1176
|
+
let n = (e === "ACC_DESCR" ? $e : e === "ACC_TITLE" ? et : tt).exec(t);
|
|
1177
|
+
return n?.[1] === void 0 ? (n?.[2] ?? "").replace(/^\s*/gm, "").replace(/\s+$/gm, "").replace(/[\t ]{2,}/gm, " ").replace(/[\n\r]{2,}/gm, "\n") : n[1].trim().replace(/[\t ]{2,}/gm, " ");
|
|
1178
|
+
}
|
|
1179
|
+
var U = {
|
|
1180
|
+
NEWLINE: "end of line",
|
|
1181
|
+
PIE: "\"pie\"",
|
|
1182
|
+
SHOW_DATA: "\"showData\"",
|
|
1183
|
+
COLON: "\":\"",
|
|
1184
|
+
NUMBER: "number",
|
|
1185
|
+
STRING: "quoted label",
|
|
1186
|
+
TITLE: "title",
|
|
1187
|
+
ACC_TITLE: "accTitle",
|
|
1188
|
+
ACC_DESCR: "accDescr"
|
|
1189
|
+
};
|
|
1190
|
+
function lt(e) {
|
|
1191
|
+
let t = rt(e), n = t.split("\n"), r = ot(t, n), i = 0, a = (e, t) => {
|
|
1192
|
+
if (e === void 0) return H(n, n.length, `Unexpected end of input — expected ${t}`);
|
|
1193
|
+
let r = `Unexpected ${U[e.kind]} — expected ${t}`;
|
|
1194
|
+
return e.kind === "SHOW_DATA" ? r += "; showData is only allowed directly after \"pie\" on the header line" : e.kind === "PIE" && (r += "; the \"pie\" header may only appear once"), H(n, e.line, r);
|
|
1195
|
+
}, o = (e) => {
|
|
1196
|
+
let t = r[i];
|
|
1197
|
+
if (t !== void 0 && t.kind !== "NEWLINE") throw a(t, `end of line after ${e}`);
|
|
1198
|
+
};
|
|
1199
|
+
for (; r[i]?.kind === "NEWLINE";) i++;
|
|
1200
|
+
if (r[i]?.kind !== "PIE") throw a(r[i], "the \"pie\" header");
|
|
1201
|
+
i++;
|
|
1202
|
+
let s = !1;
|
|
1203
|
+
r[i]?.kind === "SHOW_DATA" && (s = !0, i++);
|
|
1204
|
+
let c = "", l = "", u = "", d = [];
|
|
1205
|
+
for (; i < r.length;) {
|
|
1206
|
+
let e = r[i];
|
|
1207
|
+
switch (e.kind) {
|
|
1208
|
+
case "NEWLINE":
|
|
1209
|
+
i++;
|
|
1210
|
+
break;
|
|
1211
|
+
case "TITLE":
|
|
1212
|
+
case "ACC_TITLE":
|
|
1213
|
+
case "ACC_DESCR": {
|
|
1214
|
+
let t = ct(e.kind, e.text);
|
|
1215
|
+
e.kind === "TITLE" ? c = t : e.kind === "ACC_TITLE" ? l = t : u = t, i++, o(U[e.kind]);
|
|
1216
|
+
break;
|
|
1217
|
+
}
|
|
1218
|
+
case "STRING": {
|
|
1219
|
+
if (i++, r[i]?.kind !== "COLON") throw a(r[i], "\":\" after the slice label");
|
|
1220
|
+
i++;
|
|
1221
|
+
let t = r[i];
|
|
1222
|
+
if (t?.kind !== "NUMBER") throw a(t, "a number after \":\"");
|
|
1223
|
+
i++, o("the slice value"), d.push({
|
|
1224
|
+
label: st(e.text),
|
|
1225
|
+
value: Number(t.text),
|
|
1226
|
+
line: e.line
|
|
1227
|
+
});
|
|
1228
|
+
break;
|
|
1229
|
+
}
|
|
1230
|
+
default: throw a(e, "a quoted slice label, title, accTitle, or accDescr");
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
let f = [], p = /* @__PURE__ */ new Set();
|
|
1234
|
+
for (let { label: e, value: t, line: n } of d) {
|
|
1235
|
+
if (t < 0) throw Error(`Line ${n}: "${e}" has invalid value: ${t}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);
|
|
1236
|
+
p.has(e) || (p.add(e), f.push({
|
|
1237
|
+
label: e,
|
|
1238
|
+
value: t === 0 ? 0 : t
|
|
1239
|
+
}));
|
|
1240
|
+
}
|
|
1241
|
+
let m = {
|
|
1242
|
+
showData: s,
|
|
1243
|
+
slices: f
|
|
1244
|
+
};
|
|
1245
|
+
return c && (m.title = c), l && (m.accTitle = l), u && (m.accDescr = u), m;
|
|
1086
1246
|
}
|
|
1087
1247
|
//#endregion
|
|
1088
1248
|
//#region packages/mermaid-parser/src/expanded-shapes.ts
|
|
1089
|
-
var
|
|
1249
|
+
var W = {
|
|
1090
1250
|
rect: "rectangle",
|
|
1091
1251
|
rectangle: "rectangle",
|
|
1092
1252
|
proc: "rectangle",
|
|
@@ -1212,28 +1372,28 @@ var Z = {
|
|
|
1212
1372
|
text: "text",
|
|
1213
1373
|
anchor: "anchor"
|
|
1214
1374
|
};
|
|
1215
|
-
function
|
|
1216
|
-
return
|
|
1375
|
+
function G(e) {
|
|
1376
|
+
return W[e.trim().toLowerCase()];
|
|
1217
1377
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return Object.keys(
|
|
1378
|
+
function ut() {
|
|
1379
|
+
return Object.keys(W).sort();
|
|
1220
1380
|
}
|
|
1221
|
-
function
|
|
1381
|
+
function K(e) {
|
|
1222
1382
|
let t = {};
|
|
1223
|
-
for (let n of
|
|
1383
|
+
for (let n of dt(e, ",")) {
|
|
1224
1384
|
let e = n.trim();
|
|
1225
1385
|
if (e.length === 0) continue;
|
|
1226
|
-
let r =
|
|
1386
|
+
let r = ft(e, ":");
|
|
1227
1387
|
if (r === -1) {
|
|
1228
|
-
t.shape ??=
|
|
1388
|
+
t.shape ??= q(e);
|
|
1229
1389
|
continue;
|
|
1230
1390
|
}
|
|
1231
|
-
let i = e.slice(0, r).trim().toLowerCase(), a =
|
|
1391
|
+
let i = e.slice(0, r).trim().toLowerCase(), a = q(e.slice(r + 1).trim());
|
|
1232
1392
|
i.length > 0 && (t[i] = a);
|
|
1233
1393
|
}
|
|
1234
1394
|
return t;
|
|
1235
1395
|
}
|
|
1236
|
-
function
|
|
1396
|
+
function dt(e, t) {
|
|
1237
1397
|
let n = [], r = "", i = null;
|
|
1238
1398
|
for (let a of e) {
|
|
1239
1399
|
if (i !== null) {
|
|
@@ -1252,7 +1412,7 @@ function Be(e, t) {
|
|
|
1252
1412
|
}
|
|
1253
1413
|
return n.push(r), n;
|
|
1254
1414
|
}
|
|
1255
|
-
function
|
|
1415
|
+
function ft(e, t) {
|
|
1256
1416
|
let n = null;
|
|
1257
1417
|
for (let r = 0; r < e.length; r++) {
|
|
1258
1418
|
let i = e[r];
|
|
@@ -1268,10 +1428,10 @@ function Ve(e, t) {
|
|
|
1268
1428
|
}
|
|
1269
1429
|
return -1;
|
|
1270
1430
|
}
|
|
1271
|
-
function
|
|
1431
|
+
function q(e) {
|
|
1272
1432
|
return e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'")) ? e.slice(1, -1) : e;
|
|
1273
1433
|
}
|
|
1274
|
-
function
|
|
1434
|
+
function J(e) {
|
|
1275
1435
|
if (!e.startsWith("@{")) return;
|
|
1276
1436
|
let t = 0, n = null;
|
|
1277
1437
|
for (let r = 1; r < e.length; r++) {
|
|
@@ -1295,6 +1455,439 @@ function He(e) {
|
|
|
1295
1455
|
}
|
|
1296
1456
|
}
|
|
1297
1457
|
//#endregion
|
|
1298
|
-
|
|
1458
|
+
//#region packages/mermaid-parser/src/flowchart-parser.ts
|
|
1459
|
+
function pt(e) {
|
|
1460
|
+
let t = e.trim();
|
|
1461
|
+
return t.length >= 2 && (t[0] === "\"" && t[t.length - 1] === "\"" || t[0] === "'" && t[t.length - 1] === "'") ? t.slice(1, -1) : t;
|
|
1462
|
+
}
|
|
1463
|
+
var mt = "\"graph <dir>\"/\"flowchart <dir>\" (dir: TD, TB, LR, BT, RL), \"stateDiagram-v2\", \"sequenceDiagram\", \"classDiagram\", \"erDiagram\", \"xychart-beta\", \"C4Context\"/\"C4Container\"/\"C4Component\"/\"C4Dynamic\"/\"C4Deployment\", \"architecture-beta\", \"pie\"";
|
|
1464
|
+
function ht(e) {
|
|
1465
|
+
let t = e.trim().toLowerCase();
|
|
1466
|
+
if (/^sequence/.test(t)) return "sequenceDiagram";
|
|
1467
|
+
if (/^class/.test(t)) return "classDiagram";
|
|
1468
|
+
if (/^er/.test(t)) return "erDiagram";
|
|
1469
|
+
if (/^xychart/.test(t)) return "xychart-beta";
|
|
1470
|
+
if (/^state/.test(t)) return "stateDiagram-v2";
|
|
1471
|
+
if (/^pie/.test(t)) return "pie";
|
|
1472
|
+
}
|
|
1473
|
+
var gt = /^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;
|
|
1474
|
+
function _t(e) {
|
|
1475
|
+
let t = [];
|
|
1476
|
+
for (let n of e) n.forEach((e, n) => {
|
|
1477
|
+
if (n === 0 && t.length > 0 && gt.test(e.text)) {
|
|
1478
|
+
let n = t[t.length - 1];
|
|
1479
|
+
t[t.length - 1] = {
|
|
1480
|
+
text: `${n.text} ${e.text}`,
|
|
1481
|
+
line: n.line
|
|
1482
|
+
};
|
|
1483
|
+
} else t.push(e);
|
|
1484
|
+
});
|
|
1485
|
+
return t;
|
|
1486
|
+
}
|
|
1487
|
+
function vt(e) {
|
|
1488
|
+
let t = n(e.split("\n").map((e) => e.trim())), r = _t(s(e));
|
|
1489
|
+
if (r.length === 0) throw Error("Empty mermaid diagram");
|
|
1490
|
+
let i = r[0], a = /^stateDiagram(-v2)?\s*$/i.test(i.text) ? bt(r) : yt(r);
|
|
1491
|
+
return a.initConfig = t, a;
|
|
1492
|
+
}
|
|
1493
|
+
function yt(e) {
|
|
1494
|
+
let t = e[0];
|
|
1495
|
+
if (t === void 0)
|
|
1496
|
+
/* v8 ignore next */
|
|
1497
|
+
throw Error("parseFlowchart called with no lines");
|
|
1498
|
+
let n = t.text, a = n.match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1499
|
+
if (!a) {
|
|
1500
|
+
let e = n.match(/^(?:graph|flowchart)\b\s*(.*)$/i);
|
|
1501
|
+
if (e) {
|
|
1502
|
+
let r = e[1].trim();
|
|
1503
|
+
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.`);
|
|
1504
|
+
}
|
|
1505
|
+
let r = ht(n), i = r && r.toLowerCase() !== n.trim().toLowerCase() ? ` Did you mean "${r}"?` : "";
|
|
1506
|
+
throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${mt}.`);
|
|
1507
|
+
}
|
|
1508
|
+
let o = {
|
|
1509
|
+
direction: l(a[1]),
|
|
1510
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1511
|
+
edges: [],
|
|
1512
|
+
subgraphs: [],
|
|
1513
|
+
classDefs: /* @__PURE__ */ new Map(),
|
|
1514
|
+
classAssignments: /* @__PURE__ */ new Map(),
|
|
1515
|
+
nodeStyles: /* @__PURE__ */ new Map(),
|
|
1516
|
+
linkStyles: /* @__PURE__ */ new Map(),
|
|
1517
|
+
interactions: /* @__PURE__ */ new Map()
|
|
1518
|
+
}, s = [];
|
|
1519
|
+
for (let t = 1; t < e.length; t++) {
|
|
1520
|
+
let n = e[t].text;
|
|
1521
|
+
if (d(n, o) || u(n, o) || p(n, o)) continue;
|
|
1522
|
+
if (/^click\s+/i.test(n)) {
|
|
1523
|
+
At(n, o);
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
if (Q(n, o)) continue;
|
|
1527
|
+
let a = n.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
|
|
1528
|
+
if (a) {
|
|
1529
|
+
let e = a[1].trim(), t = i(a[2]);
|
|
1530
|
+
if (e === "default") o.linkStyles.set("default", {
|
|
1531
|
+
...o.linkStyles.get("default"),
|
|
1532
|
+
...t
|
|
1533
|
+
});
|
|
1534
|
+
else {
|
|
1535
|
+
let n = e.split(",").map((e) => parseInt(e.trim(), 10));
|
|
1536
|
+
for (let e of n) isNaN(e) || o.linkStyles.set(e, {
|
|
1537
|
+
...o.linkStyles.get(e),
|
|
1538
|
+
...t
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
continue;
|
|
1542
|
+
}
|
|
1543
|
+
let c = n.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1544
|
+
if (c && s.length > 0) {
|
|
1545
|
+
s[s.length - 1].direction = l(c[1]);
|
|
1546
|
+
continue;
|
|
1547
|
+
}
|
|
1548
|
+
let f = n.match(/^subgraph\s+(.+)$/);
|
|
1549
|
+
if (f) {
|
|
1550
|
+
let e = f[1].trim(), t = e.match(/^([^\s[]+)\s*\[(.+)\]$/), n, i;
|
|
1551
|
+
t ? (n = t[1], i = r(pt(t[2]))) : (i = r(pt(e)), n = i.replace(/\s+/g, "_").replace(/[^\p{L}\p{N}_-]/gu, ""));
|
|
1552
|
+
let a = {
|
|
1553
|
+
id: n,
|
|
1554
|
+
label: i,
|
|
1555
|
+
nodeIds: [],
|
|
1556
|
+
children: []
|
|
1557
|
+
};
|
|
1558
|
+
s.push(a);
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
if (n === "end") {
|
|
1562
|
+
let e = s.pop();
|
|
1563
|
+
e && (s.length > 0 ? s[s.length - 1].children.push(e) : o.subgraphs.push(e));
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
Ft(n, o, s);
|
|
1567
|
+
}
|
|
1568
|
+
return o;
|
|
1569
|
+
}
|
|
1570
|
+
function bt(e) {
|
|
1571
|
+
let t = {
|
|
1572
|
+
direction: "TD",
|
|
1573
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1574
|
+
edges: [],
|
|
1575
|
+
subgraphs: [],
|
|
1576
|
+
classDefs: /* @__PURE__ */ new Map(),
|
|
1577
|
+
classAssignments: /* @__PURE__ */ new Map(),
|
|
1578
|
+
nodeStyles: /* @__PURE__ */ new Map(),
|
|
1579
|
+
linkStyles: /* @__PURE__ */ new Map(),
|
|
1580
|
+
interactions: /* @__PURE__ */ new Map()
|
|
1581
|
+
}, n = [], a = /* @__PURE__ */ new Set(), o = 0, s = 0;
|
|
1582
|
+
for (let c = 1; c < e.length; c++) {
|
|
1583
|
+
let f = e[c].text;
|
|
1584
|
+
if (d(f, t) || u(f, t) || p(f, t)) continue;
|
|
1585
|
+
let m = f.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1586
|
+
if (m) {
|
|
1587
|
+
n.length > 0 ? n[n.length - 1].direction = l(m[1]) : t.direction = l(m[1]);
|
|
1588
|
+
continue;
|
|
1589
|
+
}
|
|
1590
|
+
let h = f.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
|
|
1591
|
+
if (h) {
|
|
1592
|
+
let e = h[1].trim(), n = i(h[2]);
|
|
1593
|
+
if (e === "default") t.linkStyles.set("default", {
|
|
1594
|
+
...t.linkStyles.get("default"),
|
|
1595
|
+
...n
|
|
1596
|
+
});
|
|
1597
|
+
else {
|
|
1598
|
+
let r = e.split(",").map((e) => parseInt(e.trim(), 10));
|
|
1599
|
+
for (let e of r) isNaN(e) || t.linkStyles.set(e, {
|
|
1600
|
+
...t.linkStyles.get(e),
|
|
1601
|
+
...n
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
if (Q(f, t)) continue;
|
|
1607
|
+
let g = f.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);
|
|
1608
|
+
if (g) {
|
|
1609
|
+
let e = g[1] ?? g[2], r = g[2], i = {
|
|
1610
|
+
id: r,
|
|
1611
|
+
label: e,
|
|
1612
|
+
nodeIds: [],
|
|
1613
|
+
children: []
|
|
1614
|
+
};
|
|
1615
|
+
n.push(i), a.add(r), t.nodes.delete(r);
|
|
1616
|
+
continue;
|
|
1617
|
+
}
|
|
1618
|
+
if (f === "}") {
|
|
1619
|
+
let e = n.pop();
|
|
1620
|
+
e && (n.length > 0 ? n[n.length - 1].children.push(e) : t.subgraphs.push(e));
|
|
1621
|
+
continue;
|
|
1622
|
+
}
|
|
1623
|
+
let _ = f.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);
|
|
1624
|
+
if (_) {
|
|
1625
|
+
let e = r(_[1]), i = _[2];
|
|
1626
|
+
xt(t, n, i, e);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
let v = f.match(/^(\[\*\]|[\w\p{L}-]+)(?::::([\w][\w-]*))?\s*(?:([\w-]+)@)?-->\s*(\[\*\]|[\w\p{L}-]+)(?::::([\w][\w-]*))?(?:\s*:\s*(.+))?$/u);
|
|
1630
|
+
if (v) {
|
|
1631
|
+
let e = v[1], i = v[2], c = v[3], l = v[4], u = v[5], d = v[6]?.trim(), f = d ? r(d) : void 0;
|
|
1632
|
+
e === "[*]" ? (o++, e = `_start${o > 1 ? o : ""}`, Y(t, n, {
|
|
1633
|
+
id: e,
|
|
1634
|
+
label: "",
|
|
1635
|
+
shape: "state-start"
|
|
1636
|
+
})) : a.has(e) || X(t, n, e), l === "[*]" ? (s++, l = `_end${s > 1 ? s : ""}`, Y(t, n, {
|
|
1637
|
+
id: l,
|
|
1638
|
+
label: "",
|
|
1639
|
+
shape: "state-end"
|
|
1640
|
+
})) : a.has(l) || X(t, n, l), i !== void 0 && t.classAssignments.set(e, i), u !== void 0 && t.classAssignments.set(l, u), t.edges.push({
|
|
1641
|
+
source: e,
|
|
1642
|
+
target: l,
|
|
1643
|
+
label: f,
|
|
1644
|
+
style: "solid",
|
|
1645
|
+
hasArrowStart: !1,
|
|
1646
|
+
hasArrowEnd: !0,
|
|
1647
|
+
...c === void 0 ? {} : { id: c }
|
|
1648
|
+
});
|
|
1649
|
+
continue;
|
|
1650
|
+
}
|
|
1651
|
+
let y = f.match(/^([\w\p{L}-]+):::([\w][\w-]*)\s*$/u);
|
|
1652
|
+
if (y) {
|
|
1653
|
+
let e = y[1];
|
|
1654
|
+
a.has(e) || X(t, n, e), t.classAssignments.set(e, y[2]);
|
|
1655
|
+
continue;
|
|
1656
|
+
}
|
|
1657
|
+
let b = f.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);
|
|
1658
|
+
if (b) {
|
|
1659
|
+
let e = b[1];
|
|
1660
|
+
xt(t, n, e, r(b[2].trim()));
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
for (let e of t.classAssignments.keys()) !t.nodes.has(e) && !a.has(e) && X(t, [], e);
|
|
1665
|
+
return t;
|
|
1666
|
+
}
|
|
1667
|
+
function xt(e, t, n, r) {
|
|
1668
|
+
let i = e.nodes.get(n);
|
|
1669
|
+
i && (i.label = r), Y(e, t, {
|
|
1670
|
+
id: n,
|
|
1671
|
+
label: r,
|
|
1672
|
+
shape: "rounded"
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
function Y(e, t, n) {
|
|
1676
|
+
if (e.nodes.has(n.id) || e.nodes.set(n.id, n), t.length > 0) {
|
|
1677
|
+
let e = t[t.length - 1];
|
|
1678
|
+
e.nodeIds.includes(n.id) || e.nodeIds.push(n.id);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function X(e, t, n) {
|
|
1682
|
+
if (!e.nodes.has(n)) Y(e, t, {
|
|
1683
|
+
id: n,
|
|
1684
|
+
label: n,
|
|
1685
|
+
shape: "rounded"
|
|
1686
|
+
});
|
|
1687
|
+
else if (t.length > 0) {
|
|
1688
|
+
let e = t[t.length - 1];
|
|
1689
|
+
e.nodeIds.includes(n) || e.nodeIds.push(n);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
var St = /^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\s*\|([^|]*)\|)?/, Ct = /* @__PURE__ */ new Set(["--", "=="]);
|
|
1693
|
+
function Z(e) {
|
|
1694
|
+
if (e === "o") return "circle";
|
|
1695
|
+
if (e === "x") return "cross";
|
|
1696
|
+
}
|
|
1697
|
+
var wt = /^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/, Tt = [
|
|
1698
|
+
{
|
|
1699
|
+
regex: /^([\w\p{L}-]+)\(\(\(((?:"[^"]*"|(?!\)\)\)).)+)\)\)\)/u,
|
|
1700
|
+
shape: "doublecircle"
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
regex: /^([\w\p{L}-]+)\(\[((?:"[^"]*"|(?!\]\)).)+)\]\)/u,
|
|
1704
|
+
shape: "stadium"
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
regex: /^([\w\p{L}-]+)\(\(((?:"[^"]*"|(?!\)\)).)+)\)\)/u,
|
|
1708
|
+
shape: "circle"
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
regex: /^([\w\p{L}-]+)\[\[((?:"[^"]*"|(?!\]\]).)+)\]\]/u,
|
|
1712
|
+
shape: "subroutine"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
regex: /^([\w\p{L}-]+)\[\(((?:"[^"]*"|(?!\)\]).)+)\)\]/u,
|
|
1716
|
+
shape: "cylinder"
|
|
1717
|
+
},
|
|
1718
|
+
{
|
|
1719
|
+
regex: /^([\w\p{L}-]+)\[\/((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,
|
|
1720
|
+
shape: (e) => e === "\\" ? "trapezoid" : "parallelogram"
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
regex: /^([\w\p{L}-]+)\[\\((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,
|
|
1724
|
+
shape: (e) => e === "/" ? "trapezoid-alt" : "parallelogram-alt"
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
regex: /^([\w\p{L}-]+)>((?:"[^"]*"|(?!\]).)+)\]/u,
|
|
1728
|
+
shape: "asymmetric"
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
regex: /^([\w\p{L}-]+)\{\{((?:"[^"]*"|(?!\}\}).)+)\}\}/u,
|
|
1732
|
+
shape: "hexagon"
|
|
1733
|
+
},
|
|
1734
|
+
{
|
|
1735
|
+
regex: /^([\w\p{L}-]+)\[((?:"[^"]*"|(?!\]).)+)\]/u,
|
|
1736
|
+
shape: "rectangle"
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
regex: /^([\w\p{L}-]+)\(((?:"[^"]*"|(?!\)).)+)\)/u,
|
|
1740
|
+
shape: "rounded"
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
regex: /^([\w\p{L}-]+)\{((?:"[^"]*"|(?!\}).)+)\}/u,
|
|
1744
|
+
shape: "diamond"
|
|
1745
|
+
}
|
|
1746
|
+
], Et = /^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u, Dt = /^([\w\p{L}-]+)(?=@\{)/u;
|
|
1747
|
+
function Ot(e) {
|
|
1748
|
+
if (e.shape) return G(e.shape) ?? "rectangle";
|
|
1749
|
+
if (e.icon !== void 0 || e.img !== void 0) switch (e.form?.toLowerCase()) {
|
|
1750
|
+
case "circle": return "circle";
|
|
1751
|
+
case "rounded": return "rounded";
|
|
1752
|
+
default: return "rectangle";
|
|
1753
|
+
}
|
|
1754
|
+
return "rectangle";
|
|
1755
|
+
}
|
|
1756
|
+
function kt(e, t) {
|
|
1757
|
+
return t.label !== void 0 && t.label.length > 0 ? t.label : t.icon ? t.icon : t.img ? t.img : e;
|
|
1758
|
+
}
|
|
1759
|
+
function At(t, n) {
|
|
1760
|
+
e(t, n.interactions);
|
|
1761
|
+
}
|
|
1762
|
+
var jt = /^([\w-]+)(?=@\{)/;
|
|
1763
|
+
function Q(e, t) {
|
|
1764
|
+
let n = e.match(jt);
|
|
1765
|
+
if (!n || !t.edges.some((e) => e.id === n[1])) return !1;
|
|
1766
|
+
let r = J(e.slice(n[1].length));
|
|
1767
|
+
return r ? (Mt(t, n[1], K(r.body)), !0) : !1;
|
|
1768
|
+
}
|
|
1769
|
+
function Mt(e, t, n) {
|
|
1770
|
+
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));
|
|
1771
|
+
}
|
|
1772
|
+
var Nt = /^:::([\w][\w-]*)/, Pt = /^([\w\p{L}-]+):::([\w][\w-]*)/u;
|
|
1773
|
+
function Ft(e, t, n) {
|
|
1774
|
+
let i = e.trim(), a = It(i, t, n);
|
|
1775
|
+
if (!a || a.ids.length === 0) return;
|
|
1776
|
+
i = a.remaining.trim();
|
|
1777
|
+
let o = a.ids;
|
|
1778
|
+
for (; i.length > 0;) {
|
|
1779
|
+
let e, a, s, c, l, u, d, f = i.match(/^([\w-]+)@(?=[-=<~ox])/);
|
|
1780
|
+
f && (d = f[1], i = i.slice(f[0].length));
|
|
1781
|
+
let p = i.match(St), m = p?.[2], h = p?.[1], g = p?.[3];
|
|
1782
|
+
if (p && m !== void 0 && !(h === void 0 && g === void 0 && Ct.has(m))) {
|
|
1783
|
+
e = h !== void 0, l = Z(h);
|
|
1784
|
+
let t = p[4]?.trim();
|
|
1785
|
+
c = t ? r(t) : void 0, i = i.slice(p[0].length).trim(), a = Bt(m), s = g !== void 0, u = Z(g);
|
|
1786
|
+
} else {
|
|
1787
|
+
let t = i.match(wt);
|
|
1788
|
+
if (!t) break;
|
|
1789
|
+
e = !!t[1], l = Z(t[1]);
|
|
1790
|
+
let n = t[3].trim();
|
|
1791
|
+
c = n ? r(n) : void 0;
|
|
1792
|
+
let o = t[2], d = t[4];
|
|
1793
|
+
i = i.slice(t[0].length).trim(), a = Vt(o, d), u = Z(d.slice(-1)), s = d.endsWith(">") || u !== void 0;
|
|
1794
|
+
}
|
|
1795
|
+
let _ = It(i, t, n);
|
|
1796
|
+
if (!_ || _.ids.length === 0) break;
|
|
1797
|
+
i = _.remaining.trim();
|
|
1798
|
+
for (let n of o) for (let r of _.ids) t.edges.push({
|
|
1799
|
+
source: n,
|
|
1800
|
+
target: r,
|
|
1801
|
+
label: c,
|
|
1802
|
+
style: a,
|
|
1803
|
+
hasArrowStart: e,
|
|
1804
|
+
hasArrowEnd: s,
|
|
1805
|
+
...l === void 0 ? {} : { startMarker: l },
|
|
1806
|
+
...u === void 0 ? {} : { endMarker: u },
|
|
1807
|
+
...d === void 0 ? {} : { id: d }
|
|
1808
|
+
});
|
|
1809
|
+
o = _.ids;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function It(e, t, n) {
|
|
1813
|
+
let r = Lt(e, t, n);
|
|
1814
|
+
if (!r) return null;
|
|
1815
|
+
let i = [r.id], a = r.remaining.trim();
|
|
1816
|
+
for (; a.startsWith("&");) {
|
|
1817
|
+
a = a.slice(1).trim();
|
|
1818
|
+
let e = Lt(a, t, n);
|
|
1819
|
+
if (!e) break;
|
|
1820
|
+
i.push(e.id), a = e.remaining.trim();
|
|
1821
|
+
}
|
|
1822
|
+
return {
|
|
1823
|
+
ids: i,
|
|
1824
|
+
remaining: a
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
function Lt(e, t, n) {
|
|
1828
|
+
let i = null, a = e, o, s = a.match(Pt);
|
|
1829
|
+
s && (o = s[2], a = s[1] + a.slice(s[0].length));
|
|
1830
|
+
let c = a.match(Dt);
|
|
1831
|
+
if (c) {
|
|
1832
|
+
let e = c[1], o = J(a.slice(e.length));
|
|
1833
|
+
if (o) {
|
|
1834
|
+
let s = K(o.body);
|
|
1835
|
+
$(t, n, {
|
|
1836
|
+
id: e,
|
|
1837
|
+
label: r(kt(e, s)),
|
|
1838
|
+
shape: Ot(s)
|
|
1839
|
+
}), i = e, a = a.slice(e.length + o.length);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (i === null) for (let { regex: e, shape: o } of Tt) {
|
|
1843
|
+
let s = a.match(e);
|
|
1844
|
+
if (s) {
|
|
1845
|
+
i = s[1];
|
|
1846
|
+
let e = r(s[2]), c = typeof o == "function" ? o(s[3] ?? "") : o;
|
|
1847
|
+
$(t, n, {
|
|
1848
|
+
id: i,
|
|
1849
|
+
label: e,
|
|
1850
|
+
shape: c
|
|
1851
|
+
}), a = a.slice(s[0].length);
|
|
1852
|
+
break;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (i === null) {
|
|
1856
|
+
let e = a.match(Et);
|
|
1857
|
+
e && (i = e[1], t.nodes.has(i) ? Rt(t, n, i) || zt(n, i) : $(t, n, {
|
|
1858
|
+
id: i,
|
|
1859
|
+
label: i,
|
|
1860
|
+
shape: "rectangle"
|
|
1861
|
+
}), a = a.slice(e[0].length));
|
|
1862
|
+
}
|
|
1863
|
+
if (i === null) return null;
|
|
1864
|
+
o && t.classAssignments.set(i, o);
|
|
1865
|
+
let l = a.match(Nt);
|
|
1866
|
+
return l && (t.classAssignments.set(i, l[1]), a = a.slice(l[0].length)), {
|
|
1867
|
+
id: i,
|
|
1868
|
+
remaining: a
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function $(e, t, n) {
|
|
1872
|
+
e.nodes.has(n.id) || e.nodes.set(n.id, n), zt(t, n.id);
|
|
1873
|
+
}
|
|
1874
|
+
function Rt(e, t, n) {
|
|
1875
|
+
let r = (e) => e.nodeIds.includes(n) || e.children.some(r);
|
|
1876
|
+
return e.subgraphs.some(r) || t.some(r);
|
|
1877
|
+
}
|
|
1878
|
+
function zt(e, t) {
|
|
1879
|
+
if (e.length > 0) {
|
|
1880
|
+
let n = e[e.length - 1];
|
|
1881
|
+
n.nodeIds.includes(t) || n.nodeIds.push(t);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
function Bt(e) {
|
|
1885
|
+
return e.startsWith("~") ? "invisible" : e.includes(".") ? "dotted" : e.startsWith("=") ? "thick" : "solid";
|
|
1886
|
+
}
|
|
1887
|
+
function Vt(e, t) {
|
|
1888
|
+
return e.includes(".") || t.includes(".") ? "dotted" : e.startsWith("=") || t.startsWith("=") ? "thick" : "solid";
|
|
1889
|
+
}
|
|
1890
|
+
//#endregion
|
|
1891
|
+
export { R as CHART_ACCENT_FALLBACK, ne as architectureToGraph, ve as c4BoundaryTypeLine, be as c4Placement, ye as c4RelLabelLines, _e as c4TypeLine, I as checkActivationBalance, Ue as fixActivationBalance, ke as formatClassMember, Xe as getSeriesColor, A as isBlockType, k as isCssColor, V as isDarkBackground, B as isValidHex, ut as knownShapeNames, J as matchExpandedBlock, x as parseArchitecture, Re as parseBoxHeader, me as parseC4Diagram, Ce as parseClassDiagram, Ae as parseErDiagram, K as parseExpandedMeta, D as parseGenericTypes, vt as parseMermaid, lt as parsePieChart, M as parseSequenceDiagram, We as parseXYChart, G as resolveShapeName, j as toBlockType, c as toDirection, he as wrapC4Text };
|
|
1299
1892
|
|
|
1300
1893
|
//# sourceMappingURL=index.js.map
|