@p10node/mermaid 0.13.0 → 0.13.2
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 +204 -200
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function e(e, t, n, r) {
|
|
|
178
178
|
for (let n of e.items) n.node >= 0 ? c.push(n.node) : (c.push(F[n.cluster][t]), l(n), c.push(I[n.cluster][t]));
|
|
179
179
|
};
|
|
180
180
|
return l(r), c;
|
|
181
|
-
},
|
|
181
|
+
}, ae = (e) => {
|
|
182
182
|
let t = 0;
|
|
183
183
|
for (let n = 0; n + 1 < e.length; n++) {
|
|
184
184
|
let r = [];
|
|
@@ -193,40 +193,40 @@ function e(e, t, n, r) {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
return t;
|
|
196
|
-
},
|
|
196
|
+
}, oe = (e, t) => {
|
|
197
197
|
let n = 0, r = 0;
|
|
198
198
|
for (let [i, a] of t[e]) n += z[i] * a, r += a;
|
|
199
199
|
return r ? n / r : z[e];
|
|
200
200
|
};
|
|
201
201
|
for (let e of R) for (let t of e) V[t] = z[t];
|
|
202
202
|
U(), R = R.map((e, t) => W(e, t)), B();
|
|
203
|
-
let
|
|
204
|
-
for (let e = 0; e < 24 &&
|
|
203
|
+
let se = R.map((e) => [...e]), G = ae(R);
|
|
204
|
+
for (let e = 0; e < 24 && G > 0; e++) {
|
|
205
205
|
U();
|
|
206
206
|
let t = e % 2 == 0;
|
|
207
207
|
for (let e = 1; e <= y; e++) {
|
|
208
208
|
let n = t ? e : y - e, r = t ? A : j;
|
|
209
|
-
for (let e of R[n]) V[e] =
|
|
209
|
+
for (let e of R[n]) V[e] = oe(e, r);
|
|
210
210
|
R[n] = W(R[n], n), R[n].forEach((e, t) => z[e] = t);
|
|
211
211
|
}
|
|
212
|
-
let n =
|
|
213
|
-
n <
|
|
214
|
-
}
|
|
215
|
-
R =
|
|
216
|
-
let
|
|
217
|
-
n.forEach((e, t) => e.parent >= 0 &&
|
|
218
|
-
let
|
|
219
|
-
for (let e = 0; e < a; e++) N[e] > P[e] || (
|
|
220
|
-
let
|
|
221
|
-
for (let e = 0; e <= y; e++)
|
|
222
|
-
let
|
|
212
|
+
let n = ae(R);
|
|
213
|
+
n < G && (G = n, se = R.map((e) => [...e]));
|
|
214
|
+
}
|
|
215
|
+
R = se, B();
|
|
216
|
+
let ce = R.map((e) => e.reduce((e, t) => Math.max(e, C[t]), 0)), le = Array.from({ length: a }, () => []);
|
|
217
|
+
n.forEach((e, t) => e.parent >= 0 && le[e.parent].push(t));
|
|
218
|
+
let K = (e) => n[e].pad[2] + Math.max(0, ...le[e].filter((t) => N[t] === N[e]).map(K)), ue = (e) => n[e].pad[3] + Math.max(0, ...le[e].filter((t) => P[t] === P[e]).map(ue)), de = Array(y + 1).fill(0), q = Array(y + 1).fill(0);
|
|
219
|
+
for (let e = 0; e < a; e++) N[e] > P[e] || (de[N[e]] = Math.max(de[N[e]], K(e)), q[P[e]] = Math.max(q[P[e]], ue(e)));
|
|
220
|
+
let fe = [];
|
|
221
|
+
for (let e = 0; e <= y; e++) fe[e] = e === 0 ? ce[0] / 2 + de[0] : fe[e - 1] + ce[e - 1] / 2 + q[e - 1] + r.ranksep + de[e] + ce[e] / 2;
|
|
222
|
+
let J = fe[y] + ce[y] / 2 + q[y], Y = (e) => w[e] === 2 || w[e] === 3 ? 0 : S[e] / 2, pe = (e, t) => {
|
|
223
223
|
let i = D[e], a = w[e], o = w[t];
|
|
224
|
-
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep),
|
|
225
|
-
},
|
|
226
|
-
for (let e of R) for (let t = 1; t < e.length; t++)
|
|
227
|
-
let
|
|
224
|
+
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep), Y(e) + Y(t) + i;
|
|
225
|
+
}, X = new Float64Array(L);
|
|
226
|
+
for (let e of R) for (let t = 1; t < e.length; t++) X[e[t]] = X[e[t - 1]] + pe(e[t - 1], e[t]);
|
|
227
|
+
let me = (e, t, n) => {
|
|
228
228
|
let r = e.length, i = [0];
|
|
229
|
-
for (let t = 1; t < r; t++) i[t] = i[t - 1] +
|
|
229
|
+
for (let t = 1; t < r; t++) i[t] = i[t - 1] + pe(e[t - 1], e[t]);
|
|
230
230
|
let a = [];
|
|
231
231
|
for (let e = 0; e < r; e++) for (a.push({
|
|
232
232
|
s: e,
|
|
@@ -238,7 +238,7 @@ function e(e, t, n, r) {
|
|
|
238
238
|
if (e.wt / e.w < t.wt / t.w) break;
|
|
239
239
|
e.e = t.e, e.w += t.w, e.wt += t.wt, a.pop();
|
|
240
240
|
}
|
|
241
|
-
for (let t of a) for (let n = t.s; n <= t.e; n++)
|
|
241
|
+
for (let t of a) for (let n = t.s; n <= t.e; n++) X[e[n]] = t.wt / t.w + i[n];
|
|
242
242
|
};
|
|
243
243
|
for (let e = 0; e < 10; e++) {
|
|
244
244
|
let t = e >= 8, n = e % 2 == 0;
|
|
@@ -248,24 +248,24 @@ function e(e, t, n, r) {
|
|
|
248
248
|
let a = [], o = [];
|
|
249
249
|
for (let e of i) {
|
|
250
250
|
let r = 0, i = 0, s = (e) => {
|
|
251
|
-
for (let [t, n] of e) r +=
|
|
251
|
+
for (let [t, n] of e) r += X[t] * n, i += n;
|
|
252
252
|
};
|
|
253
|
-
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ie[e]), a.push(i ? r / i :
|
|
253
|
+
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ie[e]), a.push(i ? r / i : X[e]), o.push(i || .01);
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
me(i, a, o);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
let
|
|
258
|
+
let he = L, Z = (e) => w[e] === 2 ? he + 2 * O[e] : w[e] === 3 ? he + 2 * O[e] + 1 : e;
|
|
259
259
|
if (a) {
|
|
260
260
|
let e = L + 2 * a, t = new Float64Array(e);
|
|
261
|
-
for (let e = 0; e < L; e++) t[e] =
|
|
262
|
-
for (let e = 0; e < a; e++) t[
|
|
263
|
-
for (let e = 0; e < L; e++) w[e] === 2 && (t[
|
|
261
|
+
for (let e = 0; e < L; e++) t[e] = X[e];
|
|
262
|
+
for (let e = 0; e < a; e++) t[he + 2 * e] = Infinity, t[he + 2 * e + 1] = -Infinity;
|
|
263
|
+
for (let e = 0; e < L; e++) w[e] === 2 && (t[Z(e)] = Math.min(t[Z(e)], X[e])), w[e] === 3 && (t[Z(e)] = Math.max(t[Z(e)], X[e]));
|
|
264
264
|
let r = Array.from({ length: e }, () => []), i = new Int32Array(e), o = (e, t, n) => {
|
|
265
265
|
r[e].push([t, n]), i[t]++;
|
|
266
266
|
};
|
|
267
|
-
for (let e of R) for (let t = 1; t < e.length; t++) o(
|
|
268
|
-
for (let e = 0; e < a; e++) N[e] <= P[e] && o(
|
|
267
|
+
for (let e of R) for (let t = 1; t < e.length; t++) o(Z(e[t - 1]), Z(e[t]), pe(e[t - 1], e[t]));
|
|
268
|
+
for (let e = 0; e < a; e++) N[e] <= P[e] && o(he + 2 * e, he + 2 * e + 1, Math.max(n[e].minW, n[e].pad[0] + n[e].pad[1]));
|
|
269
269
|
let s = [];
|
|
270
270
|
for (let t = 0; t < e; t++) i[t] || s.push(t);
|
|
271
271
|
let c = 0, l = new Float64Array(t);
|
|
@@ -274,15 +274,15 @@ function e(e, t, n, r) {
|
|
|
274
274
|
c++;
|
|
275
275
|
for (let [t, n] of r[e]) Number.isFinite(l[e]) && (l[t] = Math.max(l[t], l[e] + n)), --i[t] || s.push(t);
|
|
276
276
|
}
|
|
277
|
-
if (c === e) for (let e = 0; e < L; e++)
|
|
277
|
+
if (c === e) for (let e = 0; e < L; e++) X[e] = l[Z(e)];
|
|
278
278
|
}
|
|
279
|
-
let
|
|
280
|
-
for (let e = 0; e < L; e++)
|
|
281
|
-
Number.isFinite(
|
|
282
|
-
for (let e = 0; e < L; e++)
|
|
279
|
+
let ge = Infinity, Q = -Infinity;
|
|
280
|
+
for (let e = 0; e < L; e++) ge = Math.min(ge, X[e] - Y(e)), Q = Math.max(Q, X[e] + Y(e) + D[e]);
|
|
281
|
+
Number.isFinite(ge) || (ge = Q = 0);
|
|
282
|
+
for (let e = 0; e < L; e++) X[e] -= ge;
|
|
283
283
|
let _e = (e) => ({
|
|
284
|
-
x:
|
|
285
|
-
y:
|
|
284
|
+
x: X[e],
|
|
285
|
+
y: fe[E[e]]
|
|
286
286
|
}), ve = /* @__PURE__ */ new Map();
|
|
287
287
|
{
|
|
288
288
|
let t = /* @__PURE__ */ new Map(), n = (e, n, r) => {
|
|
@@ -294,14 +294,14 @@ function e(e, t, n, r) {
|
|
|
294
294
|
};
|
|
295
295
|
f.forEach((t, r) => {
|
|
296
296
|
let i = M[r];
|
|
297
|
-
i && !re[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r,
|
|
297
|
+
i && !re[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r, X[i[1]]), e[i[i.length - 1]]?.spread && n(`${i[i.length - 1]}:t`, r, X[i[i.length - 2]]));
|
|
298
298
|
});
|
|
299
299
|
for (let [e, n] of t) {
|
|
300
300
|
if (n.length < 2) continue;
|
|
301
301
|
let t = Number(e.split(":")[0]);
|
|
302
302
|
n.sort((e, t) => e.nx - t.nx || e.i - t.i);
|
|
303
303
|
let r = Math.min(36, S[t] * .7 / (n.length - 1));
|
|
304
|
-
n.forEach((i, a) => ve.set(`${e}:${i.i}`,
|
|
304
|
+
n.forEach((i, a) => ve.set(`${e}:${i.i}`, X[t] + (a - (n.length - 1) / 2) * r));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
let ye = f.map((e, n) => {
|
|
@@ -334,7 +334,7 @@ function e(e, t, n, r) {
|
|
|
334
334
|
y: o.y + C[r[0]] / 2
|
|
335
335
|
});
|
|
336
336
|
for (let e = 1; e + 1 < r.length; e++) {
|
|
337
|
-
let t = _e(r[e]), n =
|
|
337
|
+
let t = _e(r[e]), n = ce[E[r[e]]] / 2;
|
|
338
338
|
n > .5 ? (i.push({
|
|
339
339
|
x: t.x,
|
|
340
340
|
y: t.y - n
|
|
@@ -403,11 +403,11 @@ function e(e, t, n, r) {
|
|
|
403
403
|
segs: m,
|
|
404
404
|
label: p
|
|
405
405
|
};
|
|
406
|
-
}),
|
|
406
|
+
}), be = n.map((e, t) => {
|
|
407
407
|
if (N[t] > P[t]) return null;
|
|
408
408
|
let n = Infinity, r = -Infinity;
|
|
409
|
-
for (let e = N[t]; e <= P[t]; e++) n = Math.min(n,
|
|
410
|
-
let i =
|
|
409
|
+
for (let e = N[t]; e <= P[t]; e++) n = Math.min(n, X[F[t][e]]), r = Math.max(r, X[I[t][e]]);
|
|
410
|
+
let i = fe[N[t]] - ce[N[t]] / 2 - K(t), a = fe[P[t]] + ce[P[t]] / 2 + ue(t);
|
|
411
411
|
return {
|
|
412
412
|
x: n,
|
|
413
413
|
y: i,
|
|
@@ -418,9 +418,9 @@ function e(e, t, n, r) {
|
|
|
418
418
|
return {
|
|
419
419
|
nodes: Array.from({ length: i }, (e, t) => _e(t)),
|
|
420
420
|
edges: ye,
|
|
421
|
-
clusters:
|
|
422
|
-
w:
|
|
423
|
-
h:
|
|
421
|
+
clusters: be,
|
|
422
|
+
w: Q - ge,
|
|
423
|
+
h: J
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
// src/core/diagram/svg.ts
|
|
@@ -1308,8 +1308,8 @@ function F(t) {
|
|
|
1308
1308
|
let t = 0;
|
|
1309
1309
|
for (let n = d(e); n >= 0; n = d(n)) t++;
|
|
1310
1310
|
return t;
|
|
1311
|
-
},
|
|
1312
|
-
for (let e of
|
|
1311
|
+
}, ae = t.clusters.map((e, t) => t).sort((e, t) => W(e) - W(t)), oe = t.clusters.map(() => null), se = [];
|
|
1312
|
+
for (let e of ae) {
|
|
1313
1313
|
let r = A.clusters[e];
|
|
1314
1314
|
if (!r) continue;
|
|
1315
1315
|
let a = t.clusters[e], o = V({
|
|
@@ -1319,7 +1319,7 @@ function F(t) {
|
|
|
1319
1319
|
x: r.x + r.w,
|
|
1320
1320
|
y: r.y + r.h
|
|
1321
1321
|
}), l = Math.min(o.x, c.x), d = Math.min(o.y, c.y), f = Math.abs(c.x - o.x), p = Math.abs(c.y - o.y), m = a.style ?? {};
|
|
1322
|
-
if (
|
|
1322
|
+
if (oe[e] = {
|
|
1323
1323
|
x: l,
|
|
1324
1324
|
y: d,
|
|
1325
1325
|
w: f,
|
|
@@ -1331,7 +1331,7 @@ function F(t) {
|
|
|
1331
1331
|
dash: m.dash
|
|
1332
1332
|
}, 4), a.label) {
|
|
1333
1333
|
let e = w(a.label), t = n === "BT" ? d + p - 8 - e.length * i(b) / 2 : d + 8 + e.length * i(b) / 2;
|
|
1334
|
-
|
|
1334
|
+
se.push({
|
|
1335
1335
|
x: l + f / 2,
|
|
1336
1336
|
y: t,
|
|
1337
1337
|
text: e,
|
|
@@ -1340,7 +1340,7 @@ function F(t) {
|
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
1342
|
}
|
|
1343
|
-
let
|
|
1343
|
+
let G = [];
|
|
1344
1344
|
v.forEach(({ e, v: t }, n) => {
|
|
1345
1345
|
if (e.line === "hidden") return;
|
|
1346
1346
|
let r = ne(e), i = {
|
|
@@ -1398,7 +1398,7 @@ function F(t) {
|
|
|
1398
1398
|
p: e.p
|
|
1399
1399
|
}))]), i), te(s, y, p, x, r), e.label) {
|
|
1400
1400
|
let t = a(w(e.label), b);
|
|
1401
|
-
|
|
1401
|
+
G.push({
|
|
1402
1402
|
p: o ? {
|
|
1403
1403
|
x: h.x + t.w / 2 + 4,
|
|
1404
1404
|
y: h.y
|
|
@@ -1421,7 +1421,7 @@ function F(t) {
|
|
|
1421
1421
|
}, { cv: u, cw: d } = v[n];
|
|
1422
1422
|
if (u >= 0 && !f(v[n].w, u) || d >= 0 && !f(v[n].v, d)) {
|
|
1423
1423
|
let e = L(l.start, l.segs);
|
|
1424
|
-
u >= 0 &&
|
|
1424
|
+
u >= 0 && oe[u] && (e = R(e, oe[u], !0)), d >= 0 && oe[d] && (e = R(e, oe[d], !1)), e.length > 1 && (l = {
|
|
1425
1425
|
start: e[0],
|
|
1426
1426
|
segs: e.slice(1).map((e) => ({
|
|
1427
1427
|
c: "L",
|
|
@@ -1452,14 +1452,14 @@ function F(t) {
|
|
|
1452
1452
|
p: e.p
|
|
1453
1453
|
}))]), i), p !== "none" && te(s, p, _, y, r), h !== "none" && te(s, h, C, S, r), e.label) {
|
|
1454
1454
|
let t = l.label ?? I(l.start, _);
|
|
1455
|
-
|
|
1455
|
+
G.push({
|
|
1456
1456
|
p: t,
|
|
1457
1457
|
text: w(e.label)
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
1460
|
let D = (e, t, n) => {
|
|
1461
1461
|
let r = a(w(n), b), i = -t.y, o = t.x, s = Math.abs(i) * (r.w / 2 + 5) + Math.abs(o) * (r.h / 2 + 3);
|
|
1462
|
-
|
|
1462
|
+
G.push({
|
|
1463
1463
|
p: {
|
|
1464
1464
|
x: e.x - t.x * (16 + r.h / 2) + i * s,
|
|
1465
1465
|
y: e.y - t.y * (14 + r.h / 2) + o * s
|
|
@@ -1470,7 +1470,7 @@ function F(t) {
|
|
|
1470
1470
|
};
|
|
1471
1471
|
e.headLabel && D(_, y, e.headLabel), e.tailLabel && D(C, S, e.tailLabel);
|
|
1472
1472
|
});
|
|
1473
|
-
for (let e of
|
|
1473
|
+
for (let e of se) {
|
|
1474
1474
|
let t = a(e.text, b, !0);
|
|
1475
1475
|
s.rect(e.x - t.w / 2 - 4, e.y - t.h / 2 - 1, t.w + 8, t.h + 2, { fill: e.bg }, 2), s.text(e.x, e.y, e.text, {
|
|
1476
1476
|
anchor: "middle",
|
|
@@ -1484,7 +1484,7 @@ function F(t) {
|
|
|
1484
1484
|
let n = V(A.nodes[t]);
|
|
1485
1485
|
k(s, e, g[t], n.x, n.y);
|
|
1486
1486
|
});
|
|
1487
|
-
for (let e of
|
|
1487
|
+
for (let e of G) {
|
|
1488
1488
|
let t = a(e.text, b);
|
|
1489
1489
|
e.plain || s.rect(e.p.x - t.w / 2 - 3, e.p.y - t.h / 2 - 1, t.w + 6, t.h + 2, {
|
|
1490
1490
|
fill: u.label,
|
|
@@ -1600,8 +1600,8 @@ function V(e) {
|
|
|
1600
1600
|
h: Math.ceil(m)
|
|
1601
1601
|
};
|
|
1602
1602
|
}
|
|
1603
|
-
var H = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100), U = 36e5, W = 24 * U,
|
|
1604
|
-
function
|
|
1603
|
+
var H = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100), U = 36e5, W = 24 * U, ae = (e) => String(e).padStart(2, "0");
|
|
1604
|
+
function oe(e) {
|
|
1605
1605
|
let t = e.sections.flatMap((e) => e.tasks);
|
|
1606
1606
|
if (!t.length) throw Error("The Gantt chart has no tasks");
|
|
1607
1607
|
let n = Math.min(...t.map((e) => e.start)), i = Math.max(...t.map((e) => Math.max(e.end, e.start))), a = Math.max(i - n, U), s = Math.min(180, Math.max(0, ...e.sections.map((e) => r(e.name, 13, !0))) + 24), c = Math.max(560, Math.min(1100, t.length * 60)), l = c / a, d = e.title ? 36 : 0, f = z + s, m = z + d, h = (e) => f + (e - n) * l, g = new p(), _ = m + t.length * 28 + 24 + z + 6, v = [
|
|
@@ -1618,7 +1618,7 @@ function ae(e) {
|
|
|
1618
1618
|
365 * W
|
|
1619
1619
|
].find((e) => a / e <= 12) ?? 365 * W, y = Math.ceil(n / v) * v, b = (e) => {
|
|
1620
1620
|
let t = new Date(e);
|
|
1621
|
-
return v < W ? `${
|
|
1621
|
+
return v < W ? `${ae(t.getUTCHours())}:${ae(t.getUTCMinutes())}` : v >= 365 * W ? String(t.getUTCFullYear()) : v >= 30 * W ? `${t.getUTCFullYear()}-${ae(t.getUTCMonth() + 1)}` : `${t.getUTCFullYear()}-${ae(t.getUTCMonth() + 1)}-${ae(t.getUTCDate())}`;
|
|
1622
1622
|
}, x = m + t.length * 28 + 4;
|
|
1623
1623
|
for (let e = y; e <= i; e += v) {
|
|
1624
1624
|
let t = h(e);
|
|
@@ -1680,8 +1680,8 @@ function ae(e) {
|
|
|
1680
1680
|
h: Math.ceil(_)
|
|
1681
1681
|
};
|
|
1682
1682
|
}
|
|
1683
|
-
var
|
|
1684
|
-
function
|
|
1683
|
+
var se = 44, G = 12;
|
|
1684
|
+
function ce(e, t) {
|
|
1685
1685
|
let n = new p(), i = (e, t) => {
|
|
1686
1686
|
let n = t === 0 ? 16 : t === 1 ? 14 : 13, r = o(e.label.split("\n"), 220, n, t === 0), i = a(r, n, t === 0), s = e.shape === "circle", c = Math.max(i.w, i.h) + 20;
|
|
1687
1687
|
return {
|
|
@@ -1691,7 +1691,7 @@ function se(e, t) {
|
|
|
1691
1691
|
fs: n
|
|
1692
1692
|
};
|
|
1693
1693
|
}, s = (e, t, n) => {
|
|
1694
|
-
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) *
|
|
1694
|
+
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) * G);
|
|
1695
1695
|
return {
|
|
1696
1696
|
n: e,
|
|
1697
1697
|
w: r.w,
|
|
@@ -1712,13 +1712,13 @@ function se(e, t) {
|
|
|
1712
1712
|
} else l = c.kids;
|
|
1713
1713
|
let f = (e, t, n, r) => {
|
|
1714
1714
|
e.x = t;
|
|
1715
|
-
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) *
|
|
1716
|
-
for (let n of e.kids) f(n, t + r * (e.w / 2 +
|
|
1715
|
+
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) * G)) / 2;
|
|
1716
|
+
for (let n of e.kids) f(n, t + r * (e.w / 2 + se + n.w / 2), i, r), i += n.span + G;
|
|
1717
1717
|
e.y = e.kids.length ? (e.kids[0].y + e.kids[e.kids.length - 1].y) / 2 : n + e.span / 2;
|
|
1718
|
-
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) *
|
|
1719
|
-
for (let e of l) f(e, c.w / 2 +
|
|
1718
|
+
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) * G, g = h(l), _ = h(d), v = Math.max(c.h, g, _), y = (v - g) / 2;
|
|
1719
|
+
for (let e of l) f(e, c.w / 2 + se + e.w / 2, y, 1), y += e.span + G;
|
|
1720
1720
|
y = (v - _) / 2;
|
|
1721
|
-
for (let e of d) f(e, -(c.w / 2 +
|
|
1721
|
+
for (let e of d) f(e, -(c.w / 2 + se + e.w / 2), y, -1), y += e.span + G;
|
|
1722
1722
|
c.x = 0, c.y = v / 2;
|
|
1723
1723
|
let b = Infinity, x = -Infinity, S = Infinity, C = -Infinity, w = [], T = (e) => {
|
|
1724
1724
|
w.push(e), b = Math.min(b, e.x - e.w / 2), x = Math.max(x, e.x + e.w / 2), S = Math.min(S, e.y - e.h / 2), C = Math.max(C, e.y + e.h / 2), e.kids.forEach(T);
|
|
@@ -1758,7 +1758,7 @@ function se(e, t) {
|
|
|
1758
1758
|
});
|
|
1759
1759
|
}
|
|
1760
1760
|
for (let e of w) {
|
|
1761
|
-
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color :
|
|
1761
|
+
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color : le(e.color), c = e.depth <= 1 ? "#ffffff" : u.ink;
|
|
1762
1762
|
if (o === "none") n.line(i, a + e.h, i + e.w, a + e.h, {
|
|
1763
1763
|
stroke: e.color,
|
|
1764
1764
|
sw: 1.5
|
|
@@ -1810,7 +1810,7 @@ function se(e, t) {
|
|
|
1810
1810
|
h: Math.ceil(j)
|
|
1811
1811
|
};
|
|
1812
1812
|
}
|
|
1813
|
-
function
|
|
1813
|
+
function le(e) {
|
|
1814
1814
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
1815
1815
|
return t ? "#" + [
|
|
1816
1816
|
t[1],
|
|
@@ -1819,7 +1819,7 @@ function ce(e) {
|
|
|
1819
1819
|
].map((e) => Math.round(parseInt(e, 16) * .22 + 198.9).toString(16).padStart(2, "0")).join("") : "#f1f3f7";
|
|
1820
1820
|
}
|
|
1821
1821
|
// src/core/diagram/sequence.ts
|
|
1822
|
-
var
|
|
1822
|
+
var K = (e) => Math.round(e * 100) / 100, ue = class {
|
|
1823
1823
|
s = {
|
|
1824
1824
|
participants: [],
|
|
1825
1825
|
events: []
|
|
@@ -1841,9 +1841,9 @@ var q = (e) => Math.round(e * 100) / 100, le = class {
|
|
|
1841
1841
|
push(e) {
|
|
1842
1842
|
e.t === "msg" ? (this.participant(e.from), this.participant(e.to)) : e.t === "note" ? e.who.forEach((e) => this.participant(e)) : (e.t === "act" || e.t === "destroy") && this.participant(e.who), this.s.events.push(e);
|
|
1843
1843
|
}
|
|
1844
|
-
},
|
|
1845
|
-
function
|
|
1846
|
-
let t =
|
|
1844
|
+
}, de = 14, q = 13, fe = i(q), J = 16, Y = (e) => e ? e.split("\n") : [];
|
|
1845
|
+
function pe(e) {
|
|
1846
|
+
let t = Y(e.label), n = a(t, de);
|
|
1847
1847
|
switch (e.kind) {
|
|
1848
1848
|
case "actor": return {
|
|
1849
1849
|
w: Math.max(44, n.w + 8),
|
|
@@ -1869,7 +1869,7 @@ function fe(e) {
|
|
|
1869
1869
|
};
|
|
1870
1870
|
}
|
|
1871
1871
|
}
|
|
1872
|
-
function
|
|
1872
|
+
function X(e, t, n, r, a) {
|
|
1873
1873
|
let o = t.fill ?? u.fill, s = {
|
|
1874
1874
|
fill: o,
|
|
1875
1875
|
stroke: u.stroke,
|
|
@@ -1878,7 +1878,7 @@ function Z(e, t, n, r, a) {
|
|
|
1878
1878
|
fill: "none",
|
|
1879
1879
|
stroke: u.dark,
|
|
1880
1880
|
sw: 1.5
|
|
1881
|
-
}, l = (t) => e.text(r, t + n.text.length * i(
|
|
1881
|
+
}, l = (t) => e.text(r, t + n.text.length * i(de) / 2, n.text, { anchor: "middle" }), d = r - n.w / 2;
|
|
1882
1882
|
switch (t.kind) {
|
|
1883
1883
|
case "actor":
|
|
1884
1884
|
e.circle(r, a + 8, 7, {
|
|
@@ -1901,7 +1901,7 @@ function Z(e, t, n, r, a) {
|
|
|
1901
1901
|
return;
|
|
1902
1902
|
case "database": {
|
|
1903
1903
|
let t = n.w, i = n.h;
|
|
1904
|
-
e.path(`M${
|
|
1904
|
+
e.path(`M${K(d)} ${K(a + 6)} A${K(t / 2)} 6 0 0 1 ${K(d + t)} ${K(a + 6)} L${K(d + t)} ${K(a + i - 6)} A${K(t / 2)} 6 0 0 1 ${K(d)} ${K(a + i - 6)} Z`, s), e.path(`M${K(d)} ${K(a + 6)} A${K(t / 2)} 6 0 0 0 ${K(d + t)} ${K(a + 6)}`, {
|
|
1905
1905
|
...s,
|
|
1906
1906
|
fill: "none"
|
|
1907
1907
|
}), e.text(r, a + i / 2 + 3, n.text, { anchor: "middle" });
|
|
@@ -1917,7 +1917,7 @@ function Z(e, t, n, r, a) {
|
|
|
1917
1917
|
}
|
|
1918
1918
|
e.text(r, a + n.h / 2, n.text, { anchor: "middle" });
|
|
1919
1919
|
}
|
|
1920
|
-
function
|
|
1920
|
+
function me(e, t, n, r, i) {
|
|
1921
1921
|
let a = u.line;
|
|
1922
1922
|
switch (t) {
|
|
1923
1923
|
case "filled":
|
|
@@ -1956,11 +1956,11 @@ function pe(e, t, n, r, i) {
|
|
|
1956
1956
|
});
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
|
-
function
|
|
1959
|
+
function he(e) {
|
|
1960
1960
|
let t = e.participants;
|
|
1961
1961
|
if (!t.length) throw new _("The sequence diagram has no participants");
|
|
1962
1962
|
if (t.length > 300 || e.events.length > 8e3) throw new _("The sequence diagram is too large to draw");
|
|
1963
|
-
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(
|
|
1963
|
+
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(pe), o = t.length, s = Array(o).fill(0);
|
|
1964
1964
|
for (let e = 1; e < o; e++) s[e] = (i[e - 1].w + i[e].w) / 2 + 28;
|
|
1965
1965
|
let c = 0, l = 0, d = (e, t, n) => {
|
|
1966
1966
|
if (e > t && ([e, t] = [t, e]), e === t) return;
|
|
@@ -1972,10 +1972,10 @@ function me(e) {
|
|
|
1972
1972
|
}, f = (t) => e.autonumber ? r(String(t), 10) + 14 : 0, m = 0;
|
|
1973
1973
|
for (let t of e.events) if (t.t === "msg") {
|
|
1974
1974
|
m++;
|
|
1975
|
-
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...
|
|
1975
|
+
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...Y(t.text).map((e) => r(e, q))) + f(m);
|
|
1976
1976
|
e === a ? e + 1 < o ? d(e, e + 1, i[e + 1].w / 2 + s + 44) : l = Math.max(l, s + 44 - i[e].w / 2) : d(e, a, s + 30);
|
|
1977
1977
|
} else if (t.t === "note") {
|
|
1978
|
-
let e = a(
|
|
1978
|
+
let e = a(Y(t.text), q).w + 20, r = t.who.map((e) => n.get(e)), s = Math.min(...r), u = Math.max(...r);
|
|
1979
1979
|
t.pos === "over" ? s !== u && d(s, u, e - 50) : t.pos === "left" ? s > 0 ? d(s - 1, s, e + 16 + i[s - 1].w / 2) : c = Math.max(c, e + 16 - i[0].w / 2) : u + 1 < o ? d(u, u + 1, e + 16 + i[u + 1].w / 2) : l = Math.max(l, e + 16 - i[u].w / 2);
|
|
1980
1980
|
}
|
|
1981
1981
|
let h = [], g = (() => {
|
|
@@ -1983,9 +1983,9 @@ function me(e) {
|
|
|
1983
1983
|
for (let r of e.events) r.t === "block" ? n = Math.max(n, ++t) : r.t === "end" && (t = Math.max(0, t - 1));
|
|
1984
1984
|
return n;
|
|
1985
1985
|
})(), v = g ? 12 + g * 8 : 0;
|
|
1986
|
-
h[0] =
|
|
1986
|
+
h[0] = J + Math.max(i[0].w / 2, c + i[0].w / 2, v + 10);
|
|
1987
1987
|
for (let e = 1; e < o; e++) h[e] = h[e - 1] + s[e];
|
|
1988
|
-
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) +
|
|
1988
|
+
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) + J, b = J + (e.title ? 34 : 0), x = Math.max(...i.map((e) => e.h)), S = b + x + 18, C = new p(), w = new p(), T = new p(), E = t.map(() => []), D = [], O = [], k = [], A = /* @__PURE__ */ new Map(), j = (e, t) => {
|
|
1989
1989
|
for (let n of k) n.lo = Math.min(n.lo, e), n.hi = Math.max(n.hi, t);
|
|
1990
1990
|
}, ee = (e, t) => {
|
|
1991
1991
|
let n = E[e].length;
|
|
@@ -2003,7 +2003,7 @@ function me(e) {
|
|
|
2003
2003
|
for (let t of e.events) switch (t.t) {
|
|
2004
2004
|
case "msg": {
|
|
2005
2005
|
m++;
|
|
2006
|
-
let i = n.get(t.from), a = n.get(t.to), o =
|
|
2006
|
+
let i = n.get(t.from), a = n.get(t.to), o = Y(t.text), s = o.length * fe, c = {
|
|
2007
2007
|
stroke: u.line,
|
|
2008
2008
|
sw: 1.4,
|
|
2009
2009
|
dash: t.dashed ? "6 4" : void 0
|
|
@@ -2016,17 +2016,17 @@ function me(e) {
|
|
|
2016
2016
|
[n + 34, S],
|
|
2017
2017
|
[n + 34, S + 20],
|
|
2018
2018
|
[n + 2, S + 20]
|
|
2019
|
-
], c, !1),
|
|
2019
|
+
], c, !1), me(w, t.head, n, S + 20, -1), T.text(n + 6 + l, S - 4 - s / 2, o, { size: q }), e.autonumber && Z(T, n, S, m), j(h[i] - 10, n + 34 + 6 + l + Math.max(...o.map((e) => r(e, q)))), S += 20, t.activate && te(a, S), t.deactivate && M(i, S), S += 14;
|
|
2020
2020
|
break;
|
|
2021
2021
|
}
|
|
2022
2022
|
S += s + 6;
|
|
2023
2023
|
let d = a > i ? 1 : -1;
|
|
2024
2024
|
t.activate && te(a, S);
|
|
2025
2025
|
let p = ee(i, d), g = ee(a, -d);
|
|
2026
|
-
w.line(p, S, g, S, c),
|
|
2026
|
+
w.line(p, S, g, S, c), me(w, t.head, g, S, d), t.both && me(w, t.head, p, S, -d), T.text((p + g) / 2 + d * l / 2, S - 5 - s / 2, o, {
|
|
2027
2027
|
anchor: "middle",
|
|
2028
|
-
size:
|
|
2029
|
-
}), e.autonumber &&
|
|
2028
|
+
size: q
|
|
2029
|
+
}), e.autonumber && Z(T, p, S, m), t.deactivate && M(i, S), j(Math.min(h[i], h[a]), Math.max(h[i], h[a])), S += 14;
|
|
2030
2030
|
break;
|
|
2031
2031
|
}
|
|
2032
2032
|
case "act": {
|
|
@@ -2035,7 +2035,7 @@ function me(e) {
|
|
|
2035
2035
|
break;
|
|
2036
2036
|
}
|
|
2037
2037
|
case "note": {
|
|
2038
|
-
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o =
|
|
2038
|
+
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o = Y(t.text), s = a(o, q), c = Math.max(s.w + 20, t.pos === "over" && r !== i ? h[i] - h[r] + 50 : 0, 60), l = s.h + 12;
|
|
2039
2039
|
S += 6;
|
|
2040
2040
|
let d = t.pos === "left" ? h[r] - 12 - c : t.pos === "right" ? h[i] + 12 : (h[r] + h[i]) / 2 - c / 2;
|
|
2041
2041
|
T.poly([
|
|
@@ -2048,7 +2048,7 @@ function me(e) {
|
|
|
2048
2048
|
fill: u.note,
|
|
2049
2049
|
stroke: u.noteStroke,
|
|
2050
2050
|
sw: 1
|
|
2051
|
-
}), T.text(d + 10, S + l / 2, o, { size:
|
|
2051
|
+
}), T.text(d + 10, S + l / 2, o, { size: q }), j(d, d + c), S += l + 8;
|
|
2052
2052
|
break;
|
|
2053
2053
|
}
|
|
2054
2054
|
case "block": {
|
|
@@ -2084,28 +2084,28 @@ function me(e) {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
case "divider": {
|
|
2086
2086
|
S += 16;
|
|
2087
|
-
let e = a(
|
|
2088
|
-
T.line(
|
|
2087
|
+
let e = a(Y(t.text), q);
|
|
2088
|
+
T.line(J / 2, S - 2, y - J / 2, S - 2, {
|
|
2089
2089
|
stroke: u.muted,
|
|
2090
2090
|
sw: 1
|
|
2091
|
-
}).line(
|
|
2091
|
+
}).line(J / 2, S + 2, y - J / 2, S + 2, {
|
|
2092
2092
|
stroke: u.muted,
|
|
2093
2093
|
sw: 1
|
|
2094
2094
|
}), t.text && (T.rect(y / 2 - e.w / 2 - 10, S - e.h / 2 - 4, e.w + 20, e.h + 8, {
|
|
2095
2095
|
fill: "#ffffff",
|
|
2096
2096
|
stroke: u.muted,
|
|
2097
2097
|
sw: 1
|
|
2098
|
-
}, 3), T.text(y / 2, S,
|
|
2098
|
+
}, 3), T.text(y / 2, S, Y(t.text), {
|
|
2099
2099
|
anchor: "middle",
|
|
2100
|
-
size:
|
|
2100
|
+
size: q,
|
|
2101
2101
|
bold: !0
|
|
2102
2102
|
})), S += 22;
|
|
2103
2103
|
break;
|
|
2104
2104
|
}
|
|
2105
2105
|
case "delay":
|
|
2106
|
-
S += 14, t.text && T.text(y / 2, S,
|
|
2106
|
+
S += 14, t.text && T.text(y / 2, S, Y(t.text), {
|
|
2107
2107
|
anchor: "middle",
|
|
2108
|
-
size:
|
|
2108
|
+
size: q,
|
|
2109
2109
|
italic: !0,
|
|
2110
2110
|
color: u.muted
|
|
2111
2111
|
}), S += 18;
|
|
@@ -2128,7 +2128,7 @@ function me(e) {
|
|
|
2128
2128
|
for (let e = 0; e < o; e++) for (; E[e].length;) M(e, S);
|
|
2129
2129
|
for (let e of k.splice(0)) e.y1 = S;
|
|
2130
2130
|
S += 14;
|
|
2131
|
-
let ne = e.footer !== !1, re = S + (ne ? x : 0) +
|
|
2131
|
+
let ne = e.footer !== !1, re = S + (ne ? x : 0) + J;
|
|
2132
2132
|
for (let e of O) {
|
|
2133
2133
|
let t = 12 + (g - e.depth) * 8;
|
|
2134
2134
|
e.lo > e.hi && (e.lo = h[0], e.hi = h[o - 1]);
|
|
@@ -2185,7 +2185,7 @@ function me(e) {
|
|
|
2185
2185
|
});
|
|
2186
2186
|
}
|
|
2187
2187
|
return N.raw(w.body()), N.raw(T.body()), t.forEach((e, t) => {
|
|
2188
|
-
|
|
2188
|
+
X(N, e, i[t], h[t], b + x - i[t].h), ne && !A.has(t) && X(N, e, i[t], h[t], S);
|
|
2189
2189
|
}), e.title && (y = Math.max(y, r(e.title, 16, !0) + 32), N.text(y / 2, 28, e.title, {
|
|
2190
2190
|
anchor: "middle",
|
|
2191
2191
|
size: 16,
|
|
@@ -2196,7 +2196,7 @@ function me(e) {
|
|
|
2196
2196
|
h: Math.ceil(re)
|
|
2197
2197
|
};
|
|
2198
2198
|
}
|
|
2199
|
-
function
|
|
2199
|
+
function Z(e, t, n, i) {
|
|
2200
2200
|
let a = Math.max(8, r(String(i), 10) / 2 + 4);
|
|
2201
2201
|
e.circle(t, n, a, { fill: u.dark }), e.text(t, n, String(i), {
|
|
2202
2202
|
anchor: "middle",
|
|
@@ -2206,25 +2206,29 @@ function Q(e, t, n, i) {
|
|
|
2206
2206
|
});
|
|
2207
2207
|
}
|
|
2208
2208
|
// src/core/diagram/model.ts
|
|
2209
|
-
function
|
|
2209
|
+
function ge(e) {
|
|
2210
2210
|
switch (e.t) {
|
|
2211
2211
|
case "graph": return F(e.graph);
|
|
2212
|
-
case "sequence": return
|
|
2212
|
+
case "sequence": return he(e.seq);
|
|
2213
2213
|
case "pie": return V(e.pie);
|
|
2214
|
-
case "gantt": return
|
|
2215
|
-
case "tree": return
|
|
2214
|
+
case "gantt": return oe(e.gantt);
|
|
2215
|
+
case "tree": return ce(e.root, e.title);
|
|
2216
2216
|
}
|
|
2217
2217
|
}
|
|
2218
|
+
// src/core/dict.ts
|
|
2219
|
+
function Q(e) {
|
|
2220
|
+
return Object.assign(Object.create(null), e);
|
|
2221
|
+
}
|
|
2218
2222
|
// src/core/diagram/mermaid.ts
|
|
2219
|
-
function
|
|
2223
|
+
function _e(e) {
|
|
2220
2224
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n, r = /^\s*---\n([\s\S]*?)\n---[ \t]*(\n|$)/.exec(t);
|
|
2221
2225
|
return r && (n = /^title:\s*(.+)$/m.exec(r[1])?.[1].trim().replace(/^(["'])(.*)\1$/, "$2"), t = t.slice(r[0].length)), t = t.replace(/%%\{[\s\S]*?\}%%/g, ""), {
|
|
2222
2226
|
lines: t.split("\n").filter((e) => !/^\s*%%/.test(e)),
|
|
2223
2227
|
title: n
|
|
2224
2228
|
};
|
|
2225
2229
|
}
|
|
2226
|
-
function
|
|
2227
|
-
let { lines: t, title: n } =
|
|
2230
|
+
function ve(e) {
|
|
2231
|
+
let { lines: t, title: n } = _e(e), r = t.findIndex((e) => e.trim());
|
|
2228
2232
|
if (r < 0) throw new _("The diagram is empty");
|
|
2229
2233
|
let i = t[r].trim(), a = /^[\w-]+/.exec(i)?.[0] ?? i, o = t.slice(r + 1);
|
|
2230
2234
|
switch (a) {
|
|
@@ -2232,54 +2236,54 @@ function _e(e) {
|
|
|
2232
2236
|
case "flowchart":
|
|
2233
2237
|
case "flowchart-elk": return {
|
|
2234
2238
|
t: "graph",
|
|
2235
|
-
graph:
|
|
2239
|
+
graph: Ae(i, o, n)
|
|
2236
2240
|
};
|
|
2237
2241
|
case "sequenceDiagram": return {
|
|
2238
2242
|
t: "sequence",
|
|
2239
|
-
seq:
|
|
2243
|
+
seq: Ne(o, n)
|
|
2240
2244
|
};
|
|
2241
2245
|
case "classDiagram":
|
|
2242
2246
|
case "classDiagram-v2": return {
|
|
2243
2247
|
t: "graph",
|
|
2244
|
-
graph:
|
|
2248
|
+
graph: Ie(o, n)
|
|
2245
2249
|
};
|
|
2246
2250
|
case "stateDiagram":
|
|
2247
2251
|
case "stateDiagram-v2": return {
|
|
2248
2252
|
t: "graph",
|
|
2249
|
-
graph:
|
|
2253
|
+
graph: Le(o, n)
|
|
2250
2254
|
};
|
|
2251
2255
|
case "erDiagram": return {
|
|
2252
2256
|
t: "graph",
|
|
2253
|
-
graph:
|
|
2257
|
+
graph: Be(o, n)
|
|
2254
2258
|
};
|
|
2255
2259
|
case "pie": return {
|
|
2256
2260
|
t: "pie",
|
|
2257
|
-
pie:
|
|
2261
|
+
pie: Ve(i, o, n)
|
|
2258
2262
|
};
|
|
2259
2263
|
case "gantt": return {
|
|
2260
2264
|
t: "gantt",
|
|
2261
|
-
gantt:
|
|
2265
|
+
gantt: We(o, n)
|
|
2262
2266
|
};
|
|
2263
2267
|
case "mindmap": return {
|
|
2264
2268
|
t: "tree",
|
|
2265
|
-
root:
|
|
2269
|
+
root: Ke(o),
|
|
2266
2270
|
title: n
|
|
2267
2271
|
};
|
|
2268
2272
|
default: throw new _(`Mermaid “${a}” diagrams are not supported yet`);
|
|
2269
2273
|
}
|
|
2270
2274
|
}
|
|
2271
|
-
var
|
|
2275
|
+
var ye = (e) => ge(ve(e)), be = Q({
|
|
2272
2276
|
TB: "TB",
|
|
2273
2277
|
TD: "TB",
|
|
2274
2278
|
BT: "BT",
|
|
2275
2279
|
LR: "LR",
|
|
2276
2280
|
RL: "RL"
|
|
2277
|
-
};
|
|
2281
|
+
});
|
|
2278
2282
|
function $(e) {
|
|
2279
2283
|
let t = e.trim();
|
|
2280
2284
|
return /^".*"$/s.test(t) && (t = t.slice(1, -1)), /^`.*`$/s.test(t) && (t = g(t.slice(1, -1))), t = t.replace(/\bfa[bkrs]?:fa-[\w-]+\s*/g, ""), h(t).trim();
|
|
2281
2285
|
}
|
|
2282
|
-
function
|
|
2286
|
+
function xe(e) {
|
|
2283
2287
|
let t = {};
|
|
2284
2288
|
for (let n of e.split(/,(?![^(]*\))/)) {
|
|
2285
2289
|
let e = n.indexOf(":");
|
|
@@ -2289,12 +2293,12 @@ function be(e) {
|
|
|
2289
2293
|
}
|
|
2290
2294
|
return t;
|
|
2291
2295
|
}
|
|
2292
|
-
var
|
|
2296
|
+
var Se = (e, t) => {
|
|
2293
2297
|
let n = { ...e };
|
|
2294
2298
|
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
|
|
2295
2299
|
return n;
|
|
2296
2300
|
};
|
|
2297
|
-
function
|
|
2301
|
+
function Ce(e, t) {
|
|
2298
2302
|
let n = [], r = 0, i = "", a = "";
|
|
2299
2303
|
for (let o of e) {
|
|
2300
2304
|
if (i) o === i && (i = "");
|
|
@@ -2309,7 +2313,7 @@ function Se(e, t) {
|
|
|
2309
2313
|
}
|
|
2310
2314
|
return n.push(a), n;
|
|
2311
2315
|
}
|
|
2312
|
-
var
|
|
2316
|
+
var we = [
|
|
2313
2317
|
[
|
|
2314
2318
|
"(((",
|
|
2315
2319
|
[")))"],
|
|
@@ -2370,7 +2374,7 @@ var Ce = [
|
|
|
2370
2374
|
["]"],
|
|
2371
2375
|
["flag"]
|
|
2372
2376
|
]
|
|
2373
|
-
],
|
|
2377
|
+
], Te = Q({
|
|
2374
2378
|
rect: "rect",
|
|
2375
2379
|
rectangle: "rect",
|
|
2376
2380
|
proc: "rect",
|
|
@@ -2428,10 +2432,10 @@ var Ce = [
|
|
|
2428
2432
|
card: "note",
|
|
2429
2433
|
"f-circ": "point",
|
|
2430
2434
|
junction: "point"
|
|
2431
|
-
},
|
|
2432
|
-
function
|
|
2435
|
+
}), Ee = /^[\p{L}\p{N}_$]+(?:-[\p{L}\p{N}_$]+)*/u;
|
|
2436
|
+
function De(e, t, n) {
|
|
2433
2437
|
for (; e[t] === " " || e[t] === " ";) t++;
|
|
2434
|
-
let r =
|
|
2438
|
+
let r = Ee.exec(e.slice(t));
|
|
2435
2439
|
if (!r) return null;
|
|
2436
2440
|
let i = r[0];
|
|
2437
2441
|
t += i.length;
|
|
@@ -2440,9 +2444,9 @@ function Ee(e, t, n) {
|
|
|
2440
2444
|
let n = e.indexOf("}", t);
|
|
2441
2445
|
if (n > 0) {
|
|
2442
2446
|
let r = e.slice(t + 2, n), i = /shape\s*:\s*["']?([\w-]+)/.exec(r)?.[1], o = /label\s*:\s*("([^"]*)"|'([^']*)'|[^,]+)/.exec(r);
|
|
2443
|
-
i &&
|
|
2447
|
+
i && Te[i] && (a.shape = Te[i]), o && (a.label = $(o[2] ?? o[3] ?? o[1])), t = n + 1;
|
|
2444
2448
|
}
|
|
2445
|
-
} else for (let [n, r, i] of
|
|
2449
|
+
} else for (let [n, r, i] of we) {
|
|
2446
2450
|
if (!e.startsWith(n, t)) continue;
|
|
2447
2451
|
let o = t + n.length, s = "";
|
|
2448
2452
|
for (; e[o] === " ";) o++;
|
|
@@ -2469,12 +2473,12 @@ function Ee(e, t, n) {
|
|
|
2469
2473
|
}
|
|
2470
2474
|
return [i, t];
|
|
2471
2475
|
}
|
|
2472
|
-
var
|
|
2476
|
+
var Oe = Q({
|
|
2473
2477
|
">": "arrow",
|
|
2474
2478
|
o: "circle",
|
|
2475
2479
|
x: "cross"
|
|
2476
|
-
};
|
|
2477
|
-
function
|
|
2480
|
+
});
|
|
2481
|
+
function ke(e, t) {
|
|
2478
2482
|
let n = e.slice(t), r = /^\s*([<ox]?)(--|==|-\.)\s+(.+?)\s*(-{2,}|={2,}|\.+-)([>ox]?)(?=[\s\p{L}\p{N}_$"]|$)/u.exec(n), i, a = "", o = "", s = "", c = !1;
|
|
2479
2483
|
if (r) [, a, , i, o, s] = r, c = r[2] === "-.";
|
|
2480
2484
|
else {
|
|
@@ -2490,19 +2494,19 @@ function Oe(e, t) {
|
|
|
2490
2494
|
let d = o.includes("="), f = c ? (o.match(/\./g)?.length ?? 1) - 1 : o.length - (s ? 2 : 3);
|
|
2491
2495
|
return [{
|
|
2492
2496
|
label: i !== void 0 && i.trim() ? $(i) : void 0,
|
|
2493
|
-
head:
|
|
2497
|
+
head: Oe[s] ?? "none",
|
|
2494
2498
|
tail: a === "<" ? "arrow" : a === "o" ? "circle" : a === "x" ? "cross" : "none",
|
|
2495
2499
|
line: d ? "thick" : c ? "dashed" : "solid",
|
|
2496
2500
|
minlen: 1 + Math.max(0, Math.min(f, 6))
|
|
2497
2501
|
}, t + l];
|
|
2498
2502
|
}
|
|
2499
|
-
function
|
|
2500
|
-
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(
|
|
2503
|
+
function Ae(e, t, n) {
|
|
2504
|
+
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(be[r ?? "TB"] ?? "TB", "rect"), a = {
|
|
2501
2505
|
b: i,
|
|
2502
2506
|
clusters: [],
|
|
2503
2507
|
classes: /* @__PURE__ */ new Map(),
|
|
2504
2508
|
defs: /* @__PURE__ */ new Map()
|
|
2505
|
-
}, o = [], s = t.flatMap((e) =>
|
|
2509
|
+
}, o = [], s = t.flatMap((e) => Ce(e, ";")).map((e) => e.trim()).filter(Boolean), c = Ce(e, ";").slice(1).map((e) => e.trim()).filter(Boolean);
|
|
2506
2510
|
for (let e of [...c, ...s]) {
|
|
2507
2511
|
let t;
|
|
2508
2512
|
if (t = /^subgraph\s+(.*)$/.exec(e)) {
|
|
@@ -2518,7 +2522,7 @@ function ke(e, t, n) {
|
|
|
2518
2522
|
}
|
|
2519
2523
|
if (/^direction\s+\w+$/.test(e)) continue;
|
|
2520
2524
|
if (t = /^classDef\s+([\w,-]+)\s+(.+)$/.exec(e)) {
|
|
2521
|
-
for (let e of t[1].split(",")) a.defs.set(e.trim(),
|
|
2525
|
+
for (let e of t[1].split(",")) a.defs.set(e.trim(), Se(a.defs.get(e.trim()), xe(t[2])));
|
|
2522
2526
|
continue;
|
|
2523
2527
|
}
|
|
2524
2528
|
if (t = /^class\s+([^\s]+)\s+([\w-]+)$/.exec(e)) {
|
|
@@ -2526,15 +2530,15 @@ function ke(e, t, n) {
|
|
|
2526
2530
|
continue;
|
|
2527
2531
|
}
|
|
2528
2532
|
if (t = /^style\s+([^\s]+)\s+(.+)$/.exec(e)) {
|
|
2529
|
-
let e =
|
|
2533
|
+
let e = xe(t[2]);
|
|
2530
2534
|
for (let n of t[1].split(",")) if (i.isCluster(n)) {
|
|
2531
2535
|
let t = i.g.clusters.find((e) => e.id === n);
|
|
2532
|
-
t.style =
|
|
2533
|
-
} else i.node(n).style =
|
|
2536
|
+
t.style = Se(t.style, e);
|
|
2537
|
+
} else i.node(n).style = Se(i.get(n)?.style, e);
|
|
2534
2538
|
continue;
|
|
2535
2539
|
}
|
|
2536
2540
|
if (t = /^linkStyle\s+([\d,\s]+|default)\s+(.+)$/.exec(e)) {
|
|
2537
|
-
o.push([t[1].trim(),
|
|
2541
|
+
o.push([t[1].trim(), xe(t[2])]);
|
|
2538
2542
|
continue;
|
|
2539
2543
|
}
|
|
2540
2544
|
if (/^(click|accTitle|accDescr|callback)\b/.test(e)) continue;
|
|
@@ -2542,7 +2546,7 @@ function ke(e, t, n) {
|
|
|
2542
2546
|
for (;;) {
|
|
2543
2547
|
let t = [];
|
|
2544
2548
|
for (;;) {
|
|
2545
|
-
let r =
|
|
2549
|
+
let r = De(e, n, a);
|
|
2546
2550
|
if (!r) break;
|
|
2547
2551
|
t.push(r[0]), n = r[1];
|
|
2548
2552
|
let i = /^\s*&\s*/.exec(e.slice(n));
|
|
@@ -2556,19 +2560,19 @@ function ke(e, t, n) {
|
|
|
2556
2560
|
to: n
|
|
2557
2561
|
});
|
|
2558
2562
|
r = t;
|
|
2559
|
-
let o =
|
|
2563
|
+
let o = ke(e, n);
|
|
2560
2564
|
if (!o) break;
|
|
2561
2565
|
s = o[0], n = o[1];
|
|
2562
2566
|
}
|
|
2563
2567
|
}
|
|
2564
2568
|
let l = a.defs.get("default");
|
|
2565
2569
|
for (let e of i.g.nodes) {
|
|
2566
|
-
let t = l ?
|
|
2567
|
-
l && e.style && (t =
|
|
2568
|
-
for (let n of a.classes.get(e.id) ?? []) t =
|
|
2570
|
+
let t = l ? Se(void 0, l) : e.style;
|
|
2571
|
+
l && e.style && (t = Se(t, e.style));
|
|
2572
|
+
for (let n of a.classes.get(e.id) ?? []) t = Se(t, a.defs.get(n) ?? {});
|
|
2569
2573
|
t && (e.style = t);
|
|
2570
2574
|
}
|
|
2571
|
-
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style =
|
|
2575
|
+
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style = Se(e.style, a.defs.get(t) ?? {});
|
|
2572
2576
|
for (let [e, t] of o) {
|
|
2573
2577
|
let n = e === "default" ? i.g.edges.map((e, t) => t) : e.split(",").map((e) => Number(e.trim()));
|
|
2574
2578
|
for (let e of n) {
|
|
@@ -2578,7 +2582,7 @@ function ke(e, t, n) {
|
|
|
2578
2582
|
}
|
|
2579
2583
|
return i.g.title = n, i.g;
|
|
2580
2584
|
}
|
|
2581
|
-
var
|
|
2585
|
+
var je = [
|
|
2582
2586
|
[
|
|
2583
2587
|
"<<-->>",
|
|
2584
2588
|
!0,
|
|
@@ -2639,7 +2643,7 @@ var Ae = [
|
|
|
2639
2643
|
"none",
|
|
2640
2644
|
!1
|
|
2641
2645
|
]
|
|
2642
|
-
],
|
|
2646
|
+
], Me = Q({
|
|
2643
2647
|
participant: "participant",
|
|
2644
2648
|
actor: "actor",
|
|
2645
2649
|
boundary: "boundary",
|
|
@@ -2648,11 +2652,11 @@ var Ae = [
|
|
|
2648
2652
|
database: "database",
|
|
2649
2653
|
collections: "collections",
|
|
2650
2654
|
queue: "queue"
|
|
2651
|
-
};
|
|
2652
|
-
function
|
|
2653
|
-
let n = new
|
|
2655
|
+
});
|
|
2656
|
+
function Ne(e, t) {
|
|
2657
|
+
let n = new ue();
|
|
2654
2658
|
n.s.title = t;
|
|
2655
|
-
let r = [], i = RegExp(`^(.+?)\\s*(${
|
|
2659
|
+
let r = [], i = RegExp(`^(.+?)\\s*(${je.map(([e]) => e.replace(/[()|]/g, "\\$&")).join("|")})\\s*([+-]?)\\s*([^:]+?)\\s*(?::(.*))?$`);
|
|
2656
2660
|
for (let t of e) {
|
|
2657
2661
|
let e = t.trim();
|
|
2658
2662
|
if (!e) continue;
|
|
@@ -2660,7 +2664,7 @@ function Me(e, t) {
|
|
|
2660
2664
|
if (a = /^(?:create\s+)?(participant|actor)\s+(.+?)(?:@\{(.*)\})?(?:\s+as\s+(.+))?$/.exec(e)) {
|
|
2661
2665
|
let e = a[2].trim(), t = a[3] ? /"type"\s*:\s*"(\w+)"/.exec(a[3])?.[1] : void 0;
|
|
2662
2666
|
n.participant(e, {
|
|
2663
|
-
kind:
|
|
2667
|
+
kind: Me[t ?? a[1]] ?? "participant",
|
|
2664
2668
|
label: a[4] ? $(a[4]) : e
|
|
2665
2669
|
});
|
|
2666
2670
|
} else if (a = /^destroy\s+(.+)$/.exec(e)) n.push({
|
|
@@ -2698,7 +2702,7 @@ function Me(e, t) {
|
|
|
2698
2702
|
});
|
|
2699
2703
|
else if (e === "end") r.pop() === "frag" && n.push({ t: "end" });
|
|
2700
2704
|
else if (a = i.exec(e)) {
|
|
2701
|
-
let e =
|
|
2705
|
+
let e = je.find(([e]) => e === a[2]);
|
|
2702
2706
|
n.push({
|
|
2703
2707
|
t: "msg",
|
|
2704
2708
|
from: a[1].trim(),
|
|
@@ -2714,7 +2718,7 @@ function Me(e, t) {
|
|
|
2714
2718
|
}
|
|
2715
2719
|
return n.s;
|
|
2716
2720
|
}
|
|
2717
|
-
var
|
|
2721
|
+
var Pe = (e) => e.replace(/~([^~]*)~/g, "<$1>"), Fe = Q({
|
|
2718
2722
|
"<|": "triangle",
|
|
2719
2723
|
"|>": "triangle",
|
|
2720
2724
|
"*": "diamond",
|
|
@@ -2722,17 +2726,17 @@ var Ne = (e) => e.replace(/~([^~]*)~/g, "<$1>"), Pe = {
|
|
|
2722
2726
|
"<": "open",
|
|
2723
2727
|
">": "open",
|
|
2724
2728
|
"()": "ocircle"
|
|
2725
|
-
};
|
|
2726
|
-
function
|
|
2729
|
+
});
|
|
2730
|
+
function Ie(e, t) {
|
|
2727
2731
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = [], a = (e) => {
|
|
2728
2732
|
let t = e.replace(/~.*~$/, "");
|
|
2729
2733
|
return r.has(t) || r.set(t, {
|
|
2730
2734
|
attrs: [],
|
|
2731
2735
|
methods: [],
|
|
2732
|
-
label: e === t ? void 0 :
|
|
2736
|
+
label: e === t ? void 0 : Pe(e)
|
|
2733
2737
|
}), n.node(t, {}, i[i.length - 1]), r.get(t);
|
|
2734
2738
|
}, o = (e, t) => {
|
|
2735
|
-
let n =
|
|
2739
|
+
let n = Pe(t.trim());
|
|
2736
2740
|
if (!n) return;
|
|
2737
2741
|
let r = /^<<(.+)>>$/.exec(n);
|
|
2738
2742
|
r ? e.stereo = r[1] : n.includes("(") ? e.methods.push(n.replace(/[$*]$/, "")) : e.attrs.push(n.replace(/[$*]$/, ""));
|
|
@@ -2745,7 +2749,7 @@ function Fe(e, t) {
|
|
|
2745
2749
|
continue;
|
|
2746
2750
|
}
|
|
2747
2751
|
let r;
|
|
2748
|
-
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
2752
|
+
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir = be[r[1].toUpperCase()] ?? "TB";
|
|
2749
2753
|
else if (r = /^namespace\s+([\w.]+)\s*\{$/.exec(e)) n.cluster(r[1], r[1], i[i.length - 1]), i.push(r[1]);
|
|
2750
2754
|
else if (e === "}" && i.length) i.pop();
|
|
2751
2755
|
else if (r = /^class\s+([\w$~,<>.-]+?)(?:\["([^"]*)"\])?(?::::[\w-]+)?\s*(\{)?\s*(\})?$/.exec(e)) {
|
|
@@ -2773,8 +2777,8 @@ function Fe(e, t) {
|
|
|
2773
2777
|
a(e), a(l), n.edge({
|
|
2774
2778
|
from: e.replace(/~.*~$/, ""),
|
|
2775
2779
|
to: l.replace(/~.*~$/, ""),
|
|
2776
|
-
tail: i ?
|
|
2777
|
-
head: s ?
|
|
2780
|
+
tail: i ? Fe[i] : "none",
|
|
2781
|
+
head: s ? Fe[s] : "none",
|
|
2778
2782
|
line: o === ".." ? "dashed" : "solid",
|
|
2779
2783
|
label: u ? $(u) : void 0,
|
|
2780
2784
|
tailLabel: t || void 0,
|
|
@@ -2797,7 +2801,7 @@ function Fe(e, t) {
|
|
|
2797
2801
|
}
|
|
2798
2802
|
return n.g.title = t, n.g;
|
|
2799
2803
|
}
|
|
2800
|
-
function
|
|
2804
|
+
function Le(e, t) {
|
|
2801
2805
|
let n = new v("TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = 0, c = null, l = null, u = () => r[r.length - 1], d = (e, t) => {
|
|
2802
2806
|
let r = e.trim(), i = /:::([\w-]+)$/.exec(r);
|
|
2803
2807
|
if (i && (r = r.slice(0, i.index), o.set(r, [...o.get(r) ?? [], i[1]])), r === "[*]") {
|
|
@@ -2832,7 +2836,7 @@ function Ie(e, t) {
|
|
|
2832
2836
|
}
|
|
2833
2837
|
if (!e || e === "--") continue;
|
|
2834
2838
|
let f;
|
|
2835
|
-
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir =
|
|
2839
|
+
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir = be[f[1].toUpperCase()] ?? "TB");
|
|
2836
2840
|
else if (f = /^state\s+(?:"([^"]+)"\s+as\s+)?([\w.-]+)\s*(<<(fork|join|choice)>>)?\s*(\{)?$/.exec(e)) {
|
|
2837
2841
|
let e = f[2];
|
|
2838
2842
|
if (f[5]) {
|
|
@@ -2867,7 +2871,7 @@ function Ie(e, t) {
|
|
|
2867
2871
|
head: "none"
|
|
2868
2872
|
});
|
|
2869
2873
|
} else c = [], l = { id: e };
|
|
2870
|
-
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1],
|
|
2874
|
+
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1], xe(f[2]));
|
|
2871
2875
|
else if (f = /^class\s+([\w,\s-]+?)\s+([\w-]+)$/.exec(e)) for (let e of f[1].split(",")) o.set(e.trim(), [...o.get(e.trim()) ?? [], f[2]]);
|
|
2872
2876
|
else if (f = /^(.+?)\s*-->\s*([^:]+?)\s*(?::\s*(.*))?$/.exec(e)) {
|
|
2873
2877
|
let e = d(f[1], !1), t = d(f[2], !0);
|
|
@@ -2886,11 +2890,11 @@ function Ie(e, t) {
|
|
|
2886
2890
|
bold: !0,
|
|
2887
2891
|
center: !0
|
|
2888
2892
|
}, { rows: t.map((e) => [e]) }]);
|
|
2889
|
-
for (let t of o.get(e.id) ?? []) e.style =
|
|
2893
|
+
for (let t of o.get(e.id) ?? []) e.style = Se(e.style, a.get(t) ?? {});
|
|
2890
2894
|
}
|
|
2891
2895
|
return n.g.title = t, n.g;
|
|
2892
2896
|
}
|
|
2893
|
-
var
|
|
2897
|
+
var Re = Q({
|
|
2894
2898
|
"|o": "zero-one",
|
|
2895
2899
|
"o|": "zero-one",
|
|
2896
2900
|
"||": "one",
|
|
@@ -2898,7 +2902,7 @@ var Le = {
|
|
|
2898
2902
|
"o{": "zero-many",
|
|
2899
2903
|
"}|": "one-many",
|
|
2900
2904
|
"|{": "one-many"
|
|
2901
|
-
},
|
|
2905
|
+
}), ze = Q({
|
|
2902
2906
|
"one or zero": "zero-one",
|
|
2903
2907
|
"zero or one": "zero-one",
|
|
2904
2908
|
"one or more": "one-many",
|
|
@@ -2911,12 +2915,12 @@ var Le = {
|
|
|
2911
2915
|
"0+": "zero-many",
|
|
2912
2916
|
"only one": "one",
|
|
2913
2917
|
1: "one"
|
|
2914
|
-
};
|
|
2915
|
-
function
|
|
2918
|
+
});
|
|
2919
|
+
function Be(e, t) {
|
|
2916
2920
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = null, o = (e) => {
|
|
2917
2921
|
let t = /^([\w-]+)(?:\[\s*"?([^"\]]*)"?\s*\])?$/.exec(e.trim().replace(/^"(.*)"$/, "$1")), a = t ? t[1] : e.trim().replace(/^"(.*)"$/, "$1");
|
|
2918
2922
|
return t?.[2] && i.set(a, t[2]), n.node(a), r.has(a) || r.set(a, []), a;
|
|
2919
|
-
}, s = Object.keys(
|
|
2923
|
+
}, s = Object.keys(ze).sort((e, t) => t.length - e.length).map((e) => e.replace(/[()+]/g, "\\$&")).join("|"), c = /^(\S+)\s+(\|o|\|\||\}o|\}\|)(--|\.\.)(o\||\|\||o\{|\|\{)\s+(\S+)\s*:\s*(.*)$/, l = RegExp(`^(\\S+)\\s+(${s})\\s+(to|optionally to)\\s+(${s})\\s+(\\S+)\\s*:\\s*(.*)$`, "i");
|
|
2920
2924
|
for (let t of e) {
|
|
2921
2925
|
let e = t.trim();
|
|
2922
2926
|
if (!e) continue;
|
|
@@ -2935,15 +2939,15 @@ function ze(e, t) {
|
|
|
2935
2939
|
continue;
|
|
2936
2940
|
}
|
|
2937
2941
|
let i;
|
|
2938
|
-
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
2942
|
+
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir = be[i[1].toUpperCase()] ?? "TB";
|
|
2939
2943
|
else if (i = /^(.+?)\s*\{$/.exec(e)) a = o(i[1]);
|
|
2940
2944
|
else if (i = c.exec(e)) {
|
|
2941
2945
|
let e = o(i[1]), t = o(i[5]);
|
|
2942
2946
|
n.edge({
|
|
2943
2947
|
from: e,
|
|
2944
2948
|
to: t,
|
|
2945
|
-
tail:
|
|
2946
|
-
head:
|
|
2949
|
+
tail: Re[i[2]],
|
|
2950
|
+
head: Re[i[4]],
|
|
2947
2951
|
line: i[3] === ".." ? "dashed" : "solid",
|
|
2948
2952
|
label: $(i[6]) || void 0
|
|
2949
2953
|
});
|
|
@@ -2952,8 +2956,8 @@ function ze(e, t) {
|
|
|
2952
2956
|
n.edge({
|
|
2953
2957
|
from: e,
|
|
2954
2958
|
to: t,
|
|
2955
|
-
tail:
|
|
2956
|
-
head:
|
|
2959
|
+
tail: ze[i[2].toLowerCase()],
|
|
2960
|
+
head: ze[i[4].toLowerCase()],
|
|
2957
2961
|
line: i[3].toLowerCase() === "to" ? "solid" : "dashed",
|
|
2958
2962
|
label: $(i[6]) || void 0
|
|
2959
2963
|
});
|
|
@@ -2969,7 +2973,7 @@ function ze(e, t) {
|
|
|
2969
2973
|
}
|
|
2970
2974
|
return n.g.title = t, n.g;
|
|
2971
2975
|
}
|
|
2972
|
-
function
|
|
2976
|
+
function Ve(e, t, n) {
|
|
2973
2977
|
let r = /\bshowData\b/.test(e), i = /\btitle\s+(.+)$/.exec(e)?.[1] ?? n, a = [];
|
|
2974
2978
|
for (let e of t) {
|
|
2975
2979
|
let t = e.trim(), n;
|
|
@@ -2984,7 +2988,7 @@ function Be(e, t, n) {
|
|
|
2984
2988
|
slices: a
|
|
2985
2989
|
};
|
|
2986
2990
|
}
|
|
2987
|
-
var
|
|
2991
|
+
var He = Q({
|
|
2988
2992
|
ms: 1,
|
|
2989
2993
|
s: 1e3,
|
|
2990
2994
|
m: 6e4,
|
|
@@ -2993,8 +2997,8 @@ var Ve = {
|
|
|
2993
2997
|
w: 6048e5,
|
|
2994
2998
|
M: 2592e6,
|
|
2995
2999
|
y: 31536e6
|
|
2996
|
-
};
|
|
2997
|
-
function
|
|
3000
|
+
});
|
|
3001
|
+
function Ue(e, t) {
|
|
2998
3002
|
if (e = e.trim(), t === "X") return Number(e) * 1e3;
|
|
2999
3003
|
if (t === "x") return Number(e);
|
|
3000
3004
|
let n = [], r = t.replace(/YYYY|YY|MM|M|DD|D|HH|H|mm|ss|SSS|[.*+?^${}()|[\]\\]/g, (e) => /^[.*+?^${}()|[\]\\]$/.test(e) ? "\\" + e : (n.push(e), e === "YYYY" ? "(\\d{4})" : e === "SSS" ? "(\\d{3})" : e.length === 1 ? "(\\d{1,2})" : "(\\d{2})")), i = RegExp(`^${r}$`).exec(e);
|
|
@@ -3007,7 +3011,7 @@ function He(e, t) {
|
|
|
3007
3011
|
let o = a.Y === void 0 ? 1970 : n.includes("YY") ? 2e3 + a.Y : a.Y;
|
|
3008
3012
|
return Date.UTC(o, (a.M ?? 1) - 1, a.D ?? 1, a.H ?? 0, a.m ?? 0, a.s ?? 0, a.S ?? 0);
|
|
3009
3013
|
}
|
|
3010
|
-
function
|
|
3014
|
+
function We(e, t) {
|
|
3011
3015
|
let n = "YYYY-MM-DD", r = t, i = [], a = /* @__PURE__ */ new Map(), o, s = (() => {
|
|
3012
3016
|
let e = /* @__PURE__ */ new Date();
|
|
3013
3017
|
return Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate());
|
|
@@ -3036,17 +3040,17 @@ function Ue(e, t) {
|
|
|
3036
3040
|
let l;
|
|
3037
3041
|
t.length >= 3 && (l = t.shift());
|
|
3038
3042
|
let u, d;
|
|
3039
|
-
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) &&
|
|
3043
|
+
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) && Ue(u, n) === void 0 && !/^\d/.test(u) && (l = u, u = void 0), r.start = ((e) => {
|
|
3040
3044
|
if (!e) return o ? o.end : s;
|
|
3041
3045
|
let t = /^after\s+(.+)$/.exec(e);
|
|
3042
3046
|
if (t) {
|
|
3043
3047
|
let e = t[1].split(/\s+/).map((e) => a.get(e)?.end).filter((e) => e !== void 0);
|
|
3044
3048
|
return e.length ? Math.max(...e) : o ? o.end : s;
|
|
3045
3049
|
}
|
|
3046
|
-
return
|
|
3050
|
+
return Ue(e, n) ?? (o ? o.end : s);
|
|
3047
3051
|
})(u);
|
|
3048
3052
|
let f = d && /^([\d.]+)\s*(ms|s|m|h|d|w|M|y)$/.exec(d), p = d && /^until\s+(.+)$/.exec(d);
|
|
3049
|
-
r.end = f ? r.start + Number(f[1]) *
|
|
3053
|
+
r.end = f ? r.start + Number(f[1]) * He[f[2]] : p ? a.get(p[1].trim())?.start ?? r.start : d ? Ue(d, n) ?? r.start + 864e5 : r.start + 864e5, r.milestone && (r.end = r.start), l && a.set(l, r), i.length || i.push({
|
|
3050
3054
|
name: "",
|
|
3051
3055
|
tasks: []
|
|
3052
3056
|
}), i[i.length - 1].tasks.push(r), o = r;
|
|
@@ -3057,7 +3061,7 @@ function Ue(e, t) {
|
|
|
3057
3061
|
sections: i
|
|
3058
3062
|
};
|
|
3059
3063
|
}
|
|
3060
|
-
var
|
|
3064
|
+
var Ge = [
|
|
3061
3065
|
[/^[\w-]*\(\((.*)\)\)$/, "circle"],
|
|
3062
3066
|
[/^[\w-]*\)\)(.*)\(\($/, "cloud"],
|
|
3063
3067
|
[/^[\w-]*\)(.*)\($/, "cloud"],
|
|
@@ -3065,14 +3069,14 @@ var We = [
|
|
|
3065
3069
|
[/^[\w-]*\[(.*)\]$/, "rect"],
|
|
3066
3070
|
[/^[\w-]*\((.*)\)$/, "round"]
|
|
3067
3071
|
];
|
|
3068
|
-
function
|
|
3072
|
+
function Ke(e) {
|
|
3069
3073
|
let t = [], n;
|
|
3070
3074
|
for (let r of e) {
|
|
3071
3075
|
if (!r.trim()) continue;
|
|
3072
3076
|
let e = r.trim().replace(/:::[\w\s-]+$/, "").trim();
|
|
3073
3077
|
if (/^::icon\(/.test(e) || !e) continue;
|
|
3074
3078
|
let i = r.replace(/\t/g, " ").search(/\S/), a = e, o;
|
|
3075
|
-
for (let [t, n] of
|
|
3079
|
+
for (let [t, n] of Ge) {
|
|
3076
3080
|
let r = t.exec(e);
|
|
3077
3081
|
if (r) {
|
|
3078
3082
|
a = r[1], o = n;
|
|
@@ -3100,7 +3104,7 @@ function Ge(e) {
|
|
|
3100
3104
|
return n;
|
|
3101
3105
|
}
|
|
3102
3106
|
// packages/diagram/src/dom.ts
|
|
3103
|
-
async function
|
|
3107
|
+
async function qe(e, t = 2) {
|
|
3104
3108
|
let n = (t) => Number(RegExp(`<svg[^>]*\\s${t}="([\\d.]+)"`).exec(e)?.[1] ?? 0), r = n("width"), i = n("height");
|
|
3105
3109
|
if (!r || !i) throw Error("Not a picture with a size");
|
|
3106
3110
|
let a = new Image();
|
|
@@ -3111,34 +3115,34 @@ async function Ke(e, t = 2) {
|
|
|
3111
3115
|
if (!s) throw Error("No 2D canvas");
|
|
3112
3116
|
return s.scale(t, t), s.drawImage(a, 0, 0, r, i), new Promise((e, t) => o.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("PNG export failed")), "image/png"));
|
|
3113
3117
|
}
|
|
3114
|
-
function
|
|
3118
|
+
function Je(e, t) {
|
|
3115
3119
|
e.innerHTML = t.join("");
|
|
3116
3120
|
}
|
|
3117
3121
|
// packages/mermaid/src/index.ts
|
|
3118
|
-
var
|
|
3122
|
+
var Ye = class extends Error {
|
|
3119
3123
|
constructor(e) {
|
|
3120
3124
|
super(e), this.name = "DiagramError";
|
|
3121
3125
|
}
|
|
3122
3126
|
};
|
|
3123
|
-
function
|
|
3127
|
+
function Xe(e) {
|
|
3124
3128
|
try {
|
|
3125
|
-
let t =
|
|
3129
|
+
let t = ye(e);
|
|
3126
3130
|
return {
|
|
3127
3131
|
svg: t.svg,
|
|
3128
3132
|
width: t.w,
|
|
3129
3133
|
height: t.h
|
|
3130
3134
|
};
|
|
3131
3135
|
} catch (e) {
|
|
3132
|
-
throw new
|
|
3136
|
+
throw new Ye(e.message);
|
|
3133
3137
|
}
|
|
3134
3138
|
}
|
|
3135
|
-
function
|
|
3136
|
-
let n =
|
|
3137
|
-
return
|
|
3139
|
+
function Ze(e, t) {
|
|
3140
|
+
let n = Xe(t);
|
|
3141
|
+
return Je(e, [n.svg]), n;
|
|
3138
3142
|
}
|
|
3139
|
-
function
|
|
3140
|
-
return
|
|
3143
|
+
function Qe(e, t = 2) {
|
|
3144
|
+
return qe(e, t);
|
|
3141
3145
|
}
|
|
3142
|
-
export {
|
|
3146
|
+
export { Ye as DiagramError, Xe as render, Ze as renderTo, Qe as toPng };
|
|
3143
3147
|
|
|
3144
3148
|
//# sourceMappingURL=index.js.map
|