@draftably/runtime 0.5.0 → 0.6.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/assets/render.worker-CDf818A5.js +9040 -0
- package/dist/compile-CvMiDEcR.js +7837 -0
- package/dist/element.js +1 -1
- package/dist/graph.js +1 -1
- package/dist/index.js +2 -2
- package/dist/render-DU-eRw6k.js +1250 -0
- package/dist/types/src/dsl/compile.d.ts +2 -0
- package/dist/types/src/dsl/sequence-layout.d.ts +87 -0
- package/dist/types/src/dsl/syntax.d.ts +8 -2
- package/dist/types/src/engines/layout/arrange.d.ts +36 -0
- package/dist/types/src/engines/layout/compute.d.ts +7 -0
- package/dist/types/src/engines/layout/forces.d.ts +8 -0
- package/dist/types/src/engines/layout/grid.d.ts +10 -0
- package/dist/types/src/engines/layout/intent.d.ts +14 -0
- package/dist/types/src/engines/layout/layered.d.ts +5 -0
- package/dist/types/src/engines/layout/objective.d.ts +6 -0
- package/dist/types/src/engines/layout/packing.d.ts +7 -0
- package/dist/types/src/engines/layout/report.d.ts +7 -0
- package/dist/types/src/engines/layout/scene.d.ts +53 -0
- package/dist/types/src/engines/layout/seed.d.ts +3 -0
- package/dist/types/src/engines/layout/separation.d.ts +17 -0
- package/dist/types/src/engines/layout/settings.d.ts +6 -0
- package/dist/types/src/engines/layout/topology.d.ts +18 -0
- package/dist/types/src/engines/layout/trees.d.ts +8 -0
- package/dist/types/src/engines/layout/types.d.ts +133 -0
- package/dist/types/src/engines/layout/util.d.ts +19 -0
- package/dist/types/src/engines/layout-engine.d.ts +14 -119
- package/dist/types/src/engines/routing/compute.d.ts +6 -0
- package/dist/types/src/engines/routing/conflicts.d.ts +36 -0
- package/dist/types/src/engines/routing/context.d.ts +37 -0
- package/dist/types/src/engines/routing/cost.d.ts +13 -0
- package/dist/types/src/engines/routing/doglegs.d.ts +16 -0
- package/dist/types/src/engines/routing/find.d.ts +6 -0
- package/dist/types/src/engines/routing/geometry.d.ts +24 -0
- package/dist/types/src/engines/routing/heap.d.ts +20 -0
- package/dist/types/src/engines/routing/improve.d.ts +7 -0
- package/dist/types/src/engines/routing/nudge.d.ts +7 -0
- package/dist/types/src/engines/routing/paths.d.ts +8 -0
- package/dist/types/src/engines/routing/planned.d.ts +7 -0
- package/dist/types/src/engines/routing/ports.d.ts +10 -0
- package/dist/types/src/engines/routing/repair.d.ts +9 -0
- package/dist/types/src/engines/routing/score.d.ts +12 -0
- package/dist/types/src/engines/routing/search.d.ts +16 -0
- package/dist/types/src/engines/routing/settings.d.ts +4 -0
- package/dist/types/src/engines/routing/sidepairs.d.ts +20 -0
- package/dist/types/src/engines/routing/tidy-ports.d.ts +13 -0
- package/dist/types/src/engines/routing/tidy.d.ts +10 -0
- package/dist/types/src/engines/routing/tuning.d.ts +9 -0
- package/dist/types/src/engines/routing/types.d.ts +157 -0
- package/dist/types/src/engines/routing-engine.d.ts +19 -107
- package/dist/types/src/model/appearance.d.ts +10 -1
- package/dist/types/src/model/labels.d.ts +23 -0
- package/dist/types/src/model/markers.d.ts +7 -0
- package/dist/types/src/model/note.d.ts +11 -2
- package/dist/types/src/model/routes.d.ts +2 -0
- package/dist/types/src/model/status.d.ts +18 -0
- package/dist/types/src/model/types.d.ts +20 -1
- package/dist/types/src/runtime/svg-renderer.d.ts +3 -2
- package/dist/version-D7YCY2pU.js +4 -0
- package/dist/viewer.js +27 -27
- package/package.json +1 -1
- package/dist/assets/render.worker-D11vTqoO.js +0 -8548
- package/dist/compile-BAIrdu-8.js +0 -7405
- package/dist/render-CsJYFD3o.js +0 -1188
- package/dist/types/src/engines/explorer-engine.d.ts +0 -67
- package/dist/types/src/engines/sculpt-engine.d.ts +0 -71
- package/dist/version-CO7i33cq.js +0 -4
|
@@ -0,0 +1,1250 @@
|
|
|
1
|
+
import { h as Ft, s as N, i as B, j as re, k as Ee, G as Q, m as W, l as Nt, n as jt, o as Ct, t as Pt, u as Bt, N as et, w as Se, x as _e, M as Le, y as tt, z as nt, A as ye, B as Ht, C as qt, D as Re, E as at, F as je, H as zt, I as rt, J as Ut, P as Vt, K as Xt, S as ae, L as Gt, O as Kt, v as Ie, Q as st, R as it, T as xe, U as se, V as ot, g as Wt, W as Zt, X as Qt, Y as Yt, Z as Ce, _ as Jt, $ as en, a0 as Pe, a1 as tn, a2 as nn, a3 as an, a4 as rn, a5 as sn, a6 as on, a7 as ln, a8 as cn, a9 as hn, aa as dn, ab as Be, ac as fn, ad as un, ae as pn, a as lt, af as ie, e as mn, ag as gn, d as $n } from "./compile-CvMiDEcR.js";
|
|
2
|
+
import { r as He } from "./version-D7YCY2pU.js";
|
|
3
|
+
import { p as yn, f as xn } from "./geometry-DfUVE8b2.js";
|
|
4
|
+
const wn = {
|
|
5
|
+
group: '<path d="M7 3H3v4m14-4h4v4M3 17v4h4m14-4v4h-4"/><rect x="7" y="7" width="10" height="10" rx="1.5"/>'
|
|
6
|
+
}, we = {
|
|
7
|
+
added: "added",
|
|
8
|
+
changed: "changed",
|
|
9
|
+
removed: "removed",
|
|
10
|
+
context: "shown for context"
|
|
11
|
+
}, qe = (e) => `${e} line${e === 1 ? "" : "s"}`, bn = ({ status: e, count: t, lines: a }) => t ? `${t} ${we[e]}${a ? ` · ${qe(a)}` : ""}` : `${qe(a)} ${we[e]}`, oe = { added: "green", changed: "amber", removed: "red" }, Tn = { added: 500, changed: 500, removed: 700 }, ct = (e, t) => e.dark ? B(e, oe[t], 400).fill : re(B(e, oe[t], Tn[t]).fill, e.canvas, 3), be = { r: 7, inset: 2 }, X = 4, ht = (e) => re(B(e, "secondary", e.dark ? 300 : 500).fill, e.canvas, 3), ze = { opacity: 1, strike: !1 }, Mn = 2.4;
|
|
12
|
+
function H(e, t, a) {
|
|
13
|
+
const n = vn(e, t);
|
|
14
|
+
return a === "focus" || a === "ring" ? { ...n, width: Math.max(n.width ?? 0, Mn), halo: a === "ring" } : a === "dim" ? { ...n, opacity: Math.min(n.opacity, dt) } : n;
|
|
15
|
+
}
|
|
16
|
+
const dt = 0.45;
|
|
17
|
+
function vn(e, t) {
|
|
18
|
+
const a = t && oe[t] ? ct(e, t) : void 0;
|
|
19
|
+
switch (t) {
|
|
20
|
+
case "added":
|
|
21
|
+
case "changed":
|
|
22
|
+
return { stroke: a, width: 2, opacity: 1, strike: !1 };
|
|
23
|
+
case "removed":
|
|
24
|
+
return {
|
|
25
|
+
stroke: a,
|
|
26
|
+
width: 2,
|
|
27
|
+
dash: "6 4",
|
|
28
|
+
opacity: 1,
|
|
29
|
+
strike: e.strikeRemoved,
|
|
30
|
+
inkFade: 0.8,
|
|
31
|
+
marker: !0
|
|
32
|
+
};
|
|
33
|
+
case "context":
|
|
34
|
+
return { ...ze, opacity: dt };
|
|
35
|
+
default:
|
|
36
|
+
return ze;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const U = (e) => !!e.appearance.compare || Object.values(e.styles).some((t) => t.status) || e.graph.edges.some((t) => t.status);
|
|
40
|
+
function Te(e, t, a) {
|
|
41
|
+
const n = oe[t ?? "same"];
|
|
42
|
+
if (!n)
|
|
43
|
+
return a === "group" ? { fill: e.canvas, stroke: e.muted, ink: e.text } : e.node;
|
|
44
|
+
const o = t === "removed";
|
|
45
|
+
return {
|
|
46
|
+
fill: o && a === "group" && !e.dark ? e.canvas : B(e, n, e.dark ? 900 : a === "group" || o ? 50 : 100).fill,
|
|
47
|
+
stroke: ct(e, t),
|
|
48
|
+
ink: B(e, n, e.dark ? 100 : 900).fill
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const le = (e, t, a) => H(e, t.status).stroke ?? (t.spot === "ring" ? ht(e) : a || t.spot === "dim" ? e.muted : e.connection);
|
|
52
|
+
function ft(e, t) {
|
|
53
|
+
const a = e.appearance.states?.find((d) => d.id === t);
|
|
54
|
+
if (!a) return e;
|
|
55
|
+
const n = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const d of a.ids)
|
|
57
|
+
if (n.add(d), e.graph.groups.some((g) => g.id === d)) for (const g of Ft(e, d)) n.add(g);
|
|
58
|
+
const o = new Map(
|
|
59
|
+
[...e.graph.nodes, ...e.graph.groups].map((d) => [d.id, d.parentId])
|
|
60
|
+
), r = /* @__PURE__ */ new Set();
|
|
61
|
+
for (const d of n) for (let g = o.get(d); g; g = o.get(g)) r.add(g);
|
|
62
|
+
const s = a.rest === "dim" ? "dim" : void 0, l = a.rest === "dim" ? "focus" : "ring", i = (d) => n.has(d) ? l : r.has(d) ? void 0 : s, c = { ...e.styles };
|
|
63
|
+
for (const d of [...e.graph.nodes, ...e.graph.groups]) {
|
|
64
|
+
const g = i(d.id);
|
|
65
|
+
g && (c[d.id] = { ...N(e, d.id), spot: g });
|
|
66
|
+
}
|
|
67
|
+
const h = e.graph.edges.map((d) => {
|
|
68
|
+
const g = n.has(d.id) || n.has(d.from) && n.has(d.to) ? l : s;
|
|
69
|
+
return g ? { ...d, spot: g } : d;
|
|
70
|
+
});
|
|
71
|
+
return { ...e, styles: c, graph: { ...e.graph, edges: h } };
|
|
72
|
+
}
|
|
73
|
+
function ut(e) {
|
|
74
|
+
const t = new Set([...e.graph.nodes, ...e.graph.groups].map((n) => n.id)), a = Object.entries(e.styles).filter(([n]) => t.has(n)).map(([, n]) => n.status);
|
|
75
|
+
return Object.keys(we).map((n) => ({
|
|
76
|
+
status: n,
|
|
77
|
+
count: a.filter((o) => o === n).length,
|
|
78
|
+
lines: e.graph.edges.filter((o) => o.status === n).length
|
|
79
|
+
})).filter((n) => n.count || n.lines);
|
|
80
|
+
}
|
|
81
|
+
const pt = (e) => U(e) ? [] : [
|
|
82
|
+
...e.appearance.legend ?? [],
|
|
83
|
+
...En(e),
|
|
84
|
+
// Bars are drawn only with `activations=on`, and only then need a row.
|
|
85
|
+
...e.layout.sequence?.activations?.length ? [{ activation: !0, label: "at work on a call" }] : [],
|
|
86
|
+
// A sequence's rows stand at even steps, so every one says that they are not a clock.
|
|
87
|
+
...e.layout.sequence ? [{ caption: !0, label: kn }] : []
|
|
88
|
+
], kn = "Rows show order, not elapsed time.";
|
|
89
|
+
function An(e) {
|
|
90
|
+
if (!e.layout.sequence) return;
|
|
91
|
+
const t = new Map(e.graph.nodes.map((r) => [r.id, r.title.split(`
|
|
92
|
+
`)[0]])), a = new Map(e.graph.edges.map((r, s) => [r.id, s + 1])), n = (r) => r.message === "reply" ? r.replyTo && a.has(r.replyTo) ? `reply to step ${a.get(r.replyTo)}` : "reply" : r.message && r.message !== "interaction" && r.message !== "action" ? Me[r.message] : "", o = e.graph.edges.map((r, s) => {
|
|
93
|
+
const l = r.label.replace(/\s+/g, " ").trim(), i = r.message === "action" ? `${t.get(r.from)} does` : r.from === r.to ? `${t.get(r.from)} to itself` : `${t.get(r.from)} to ${t.get(r.to)}`;
|
|
94
|
+
return `${s + 1}. ${i}${l ? `: ${l}` : ""}${n(r) ? ` (${n(r)})` : ""}.`;
|
|
95
|
+
});
|
|
96
|
+
return [
|
|
97
|
+
`Sequence between ${[...t.values()].join(", ")}, in order from top to bottom.`,
|
|
98
|
+
...o
|
|
99
|
+
].join(" ");
|
|
100
|
+
}
|
|
101
|
+
const Me = {
|
|
102
|
+
interaction: "message",
|
|
103
|
+
call: "call: the sender waits",
|
|
104
|
+
send: "send: the sender does not wait",
|
|
105
|
+
reply: "reply",
|
|
106
|
+
outcome: "result shown",
|
|
107
|
+
action: "local action"
|
|
108
|
+
};
|
|
109
|
+
function En(e) {
|
|
110
|
+
const t = new Set(e.graph.edges.flatMap((n) => n.message ? [n.message] : []));
|
|
111
|
+
if (!t.size) return [];
|
|
112
|
+
e.graph.edges.some((n) => !n.message && !n.dashed && n.directed) && t.add("interaction");
|
|
113
|
+
const a = ["interaction", "outcome"].filter((n) => t.has(n));
|
|
114
|
+
return [
|
|
115
|
+
...a.length ? [{ message: a[0], label: a.map((n) => Me[n]).join(" / ") }] : [],
|
|
116
|
+
...["call", "send", "reply", "action"].filter((n) => t.has(n)).map((n) => ({ message: n, label: Me[n] }))
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
function mt(e) {
|
|
120
|
+
const t = { ...e.styles }, a = e.layout.sequence, n = a?.before?.grow ?? 0;
|
|
121
|
+
for (const s of e.graph.nodes)
|
|
122
|
+
s.wasShape && (t[s.id] = { ...t[s.id], shape: s.wasShape });
|
|
123
|
+
const o = { ...e.layout.edges }, r = { ...e.layout.nodes };
|
|
124
|
+
for (const [s, l] of Object.entries(a?.before?.rows ?? {}))
|
|
125
|
+
o[s] = { ...o[s], row: l };
|
|
126
|
+
if (n)
|
|
127
|
+
for (const s of e.graph.groups) r[s.id] = { ...r[s.id], h: r[s.id].h + n };
|
|
128
|
+
return {
|
|
129
|
+
...e,
|
|
130
|
+
styles: t,
|
|
131
|
+
layout: {
|
|
132
|
+
...e.layout,
|
|
133
|
+
edges: o,
|
|
134
|
+
nodes: r,
|
|
135
|
+
...a?.before ? {
|
|
136
|
+
sequence: {
|
|
137
|
+
...a,
|
|
138
|
+
phases: a.before.phases,
|
|
139
|
+
activations: a.before.activations,
|
|
140
|
+
panel: { ...a.panel, h: a.panel.h + n }
|
|
141
|
+
}
|
|
142
|
+
} : {}
|
|
143
|
+
},
|
|
144
|
+
graph: {
|
|
145
|
+
nodes: e.graph.nodes.map((s) => ({
|
|
146
|
+
...s,
|
|
147
|
+
title: s.was ?? s.title,
|
|
148
|
+
...s.wasCount !== void 0 ? { count: s.wasCount === 1 ? void 0 : s.wasCount } : {},
|
|
149
|
+
...s.lifeline ? { lifeline: s.lifeline + n } : {}
|
|
150
|
+
})),
|
|
151
|
+
groups: e.graph.groups.map((s) => ({ ...s, title: s.was ?? s.title })),
|
|
152
|
+
edges: e.graph.edges.map((s) => ({ ...s, label: s.was ?? s.label }))
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function gt(e) {
|
|
157
|
+
const t = e.layout.sequence;
|
|
158
|
+
if (!t?.inner) return e;
|
|
159
|
+
const { inner: a, notes: n, phaseX: o, ...r } = t;
|
|
160
|
+
return { ...e, layout: { ...e.layout, sequence: { ...r, panel: a } } };
|
|
161
|
+
}
|
|
162
|
+
function Ue(e, t) {
|
|
163
|
+
const a = t === "before" ? "added" : "removed", n = (i) => e.styles[i]?.status !== a, o = gt(e), r = t === "before" ? mt(o) : o, s = r.graph.nodes.filter((i) => n(i.id)), l = new Set(s.map((i) => i.id));
|
|
164
|
+
return Sn(
|
|
165
|
+
{
|
|
166
|
+
...r,
|
|
167
|
+
graph: {
|
|
168
|
+
nodes: s,
|
|
169
|
+
groups: r.graph.groups.filter((i) => n(i.id)),
|
|
170
|
+
edges: r.graph.edges.filter(
|
|
171
|
+
(i) => i.status !== a && l.has(i.from) && l.has(i.to)
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
new Set(
|
|
176
|
+
e.graph.groups.filter((i) => !n(i.id)).map((i) => i.id).concat(e.graph.nodes.filter((i) => !n(i.id)).map((i) => i.id))
|
|
177
|
+
),
|
|
178
|
+
e
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function Sn(e, t, a) {
|
|
182
|
+
if (!t.size) return e;
|
|
183
|
+
const n = new Map(
|
|
184
|
+
[...a.graph.nodes, ...a.graph.groups].map((c) => [c.id, c.parentId])
|
|
185
|
+
), o = /* @__PURE__ */ new Set();
|
|
186
|
+
for (const c of t) for (let h = n.get(c); h; h = n.get(h)) o.add(h);
|
|
187
|
+
const r = Ee(e.appearance), s = { ...e.layout.nodes }, l = (c) => {
|
|
188
|
+
let h = 0;
|
|
189
|
+
for (let d = n.get(c); d; d = n.get(d)) h++;
|
|
190
|
+
return h;
|
|
191
|
+
}, i = [...e.graph.nodes, ...e.graph.groups];
|
|
192
|
+
for (const c of e.graph.groups.filter((h) => o.has(h.id)).sort((h, d) => l(d.id) - l(h.id))) {
|
|
193
|
+
const h = s[c.id], d = i.filter((w) => w.parentId === c.id).map((w) => s[w.id]);
|
|
194
|
+
if (!h || !d.length) continue;
|
|
195
|
+
const g = Math.min(
|
|
196
|
+
h.x + h.w,
|
|
197
|
+
Math.max(...d.map((w) => w.x + w.w)) + Q
|
|
198
|
+
), u = Math.min(h.y + h.h, Math.max(...d.map((w) => w.y + w.h)) + Q), f = W(c.title, r.groupTitle) + Nt, m = Math.max(h.x, Math.min(...d.map((w) => w.x)) - Q), $ = Math.max(h.y, Math.min(...d.map((w) => w.y)) - r.groupHeader), T = Math.max(h.x, Math.min(m, g - f)), M = Math.max(h.y, Math.min($, u - r.groupHeader - Q));
|
|
199
|
+
s[c.id] = {
|
|
200
|
+
...h,
|
|
201
|
+
x: T,
|
|
202
|
+
y: M,
|
|
203
|
+
w: Math.min(h.x + h.w, Math.max(g, T + f)) - T,
|
|
204
|
+
h: u - M
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return { ...e, layout: { ...e.layout, nodes: s } };
|
|
208
|
+
}
|
|
209
|
+
const _n = [6, 3];
|
|
210
|
+
function Ln(e) {
|
|
211
|
+
if (typeof e == "string" || e < 1e3) return `×${e}`;
|
|
212
|
+
const t = e / 1e3;
|
|
213
|
+
return `×${t < 10 ? t.toFixed(1).replace(/\.0$/, "") : Math.round(t)}k`;
|
|
214
|
+
}
|
|
215
|
+
const Rn = 24, In = 10, Ve = 4, On = 16;
|
|
216
|
+
function Dn(e, t, a) {
|
|
217
|
+
const n = Pt(e).subtitle, o = t.filter((i) => i.mark).map((i) => W(i.mark, n)), r = o.length ? Math.ceil(Math.max(...o)) + 10 : 0;
|
|
218
|
+
let s = In;
|
|
219
|
+
const l = t.map((i) => {
|
|
220
|
+
const c = Bt(i.text, Math.max(80, a - r), n), h = { note: i, lines: c, y: s };
|
|
221
|
+
return s += c.length * n.lineHeight + Ve, h;
|
|
222
|
+
});
|
|
223
|
+
return { type: n, gutter: r, items: l, h: l.length ? s - Ve + On : 0 };
|
|
224
|
+
}
|
|
225
|
+
function Fn(e, t, a) {
|
|
226
|
+
const { type: n, gutter: o } = e;
|
|
227
|
+
return e.items.flatMap(
|
|
228
|
+
(r, s) => r.lines.map((l, i) => ({
|
|
229
|
+
entry: s,
|
|
230
|
+
runs: l,
|
|
231
|
+
x: t + o,
|
|
232
|
+
y: a + r.y + i * n.lineHeight
|
|
233
|
+
}))
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
function $t(e, t, a, n, o = (r) => r) {
|
|
237
|
+
if (!t.items.length) return "";
|
|
238
|
+
const { type: r } = t, s = `font-family="${r.family.replace(/"/g, """)}" font-size="${r.size}" font-weight="${r.weight}"`, l = jt(e, e.canvas), i = (d) => d + r.lineHeight / 2, c = t.items.filter((d) => d.note.mark).map(
|
|
239
|
+
(d) => `<text x="${a}" y="${i(n + d.y)}" dominant-baseline="central" ${s} fill="${e.muted}">${Nn(d.note.mark)}</text>`
|
|
240
|
+
), h = Fn(t, a, n).map(
|
|
241
|
+
(d) => `<text x="${d.x}" y="${i(d.y)}" dominant-baseline="central" ${s} fill="${e.text}">${Ct(d.runs, l, o)}</text>`
|
|
242
|
+
);
|
|
243
|
+
return `<g class="diagram-footnotes"><line x1="${a}" x2="${a + Rn}" y1="${n}" y2="${n}" stroke="${e.muted}" stroke-opacity="0.6"/>` + c.join("") + h.join("") + "</g>";
|
|
244
|
+
}
|
|
245
|
+
const Nn = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), Y = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), yt = (e, t, a, n, o = be.r) => `<circle cx="${e}" cy="${t}" r="${o}" fill="${a}" stroke="${n}" stroke-width="${o / 4.5}"/><path d="M${e - o / 2},${t} h${o}" stroke="${n}" stroke-width="${o / 4}" stroke-linecap="round"/>`, jn = 24, Oe = (e) => e?.caption ? -8 : e?.message && e.message !== "action" ? 28 : 16, Cn = (e, t, a) => Oe(a) + 8 + W(t, e.annotation);
|
|
246
|
+
function Xe(e, t, a, n, o) {
|
|
247
|
+
if (e === "none") return "";
|
|
248
|
+
const r = Le[e];
|
|
249
|
+
return `<path transform="${n ? `translate(${t + r.stop + r.x} ${a - r.h / 2}) scale(-1 1)` : `translate(${t - r.stop - r.x} ${a - r.h / 2})`}" d="${r.d}" fill="${nt(e, o.connection, o.canvas)}" stroke="${o.connection}" stroke-width="${tt}" stroke-linecap="round" stroke-linejoin="round"/>`;
|
|
250
|
+
}
|
|
251
|
+
function Pn(e, t, a, n) {
|
|
252
|
+
const o = n.connection;
|
|
253
|
+
if (e.message === "action")
|
|
254
|
+
return `<rect x="${t}" y="${a - 6}" width="16" height="12" rx="3" fill="none" stroke="${o}" stroke-width="1.4"/>`;
|
|
255
|
+
const r = { message: e.message }, [s, l] = [Se(r), _e(r)], i = (h) => h === "none" ? 0 : Le[h].stop, c = t + Oe(e);
|
|
256
|
+
return `<line x1="${t + i(l)}" y1="${a}" x2="${c - i(s)}" y2="${a}" stroke="${o}" stroke-width="1.4" stroke-linecap="round"${e.message === "reply" ? ' stroke-dasharray="5 5"' : ""}/>` + Xe(l, t, a, !0, n) + Xe(s, c, a, !1, n);
|
|
257
|
+
}
|
|
258
|
+
function Bn(e, t = [], a = [], n = 1 / 0) {
|
|
259
|
+
const o = Math.round(e.annotation.lineHeight + 8), r = [
|
|
260
|
+
...t.map((h) => ({ legend: h, label: h.label })),
|
|
261
|
+
...a.map((h) => ({ status: h, label: bn(h) }))
|
|
262
|
+
];
|
|
263
|
+
let s = 0, l = 0, i = 0;
|
|
264
|
+
const c = r.map((h) => {
|
|
265
|
+
const d = Cn(e, h.label, h.legend);
|
|
266
|
+
s && s + d > n && (s = 0, l += o);
|
|
267
|
+
const g = { ...h, x: s, y: l };
|
|
268
|
+
return i = Math.max(i, s + d), s += d + jn, g;
|
|
269
|
+
});
|
|
270
|
+
return { w: i, h: c.length ? l + o + 12 : 0, row: o, items: c };
|
|
271
|
+
}
|
|
272
|
+
function xt(e, t, a, n) {
|
|
273
|
+
const { row: o } = t, { family: r, size: s, weight: l } = e.annotation;
|
|
274
|
+
return t.items.map((i) => {
|
|
275
|
+
const c = a + i.x, h = n + 12 + i.y, d = h + o / 2;
|
|
276
|
+
let g;
|
|
277
|
+
if (i.legend?.caption)
|
|
278
|
+
return `<text x="${c}" y="${d}" dominant-baseline="central" font-family="${Y(r)}" font-size="${s}" font-weight="${l}" fill="${e.muted}">${Y(i.label)}</text>`;
|
|
279
|
+
if (i.legend?.activation)
|
|
280
|
+
g = `<line x1="${c + 8}" y1="${d - 9}" x2="${c + 8}" y2="${d + 9}" stroke="${e.muted}" stroke-width="1" stroke-dasharray="3 3"/><rect x="${c + 4}" y="${d - 6}" width="8" height="12" rx="1.5" fill="${e.canvas}" stroke="${e.connection}" stroke-width="1.2"/>`;
|
|
281
|
+
else if (i.legend?.message) g = Pn(i.legend, c, d, e);
|
|
282
|
+
else if (i.legend?.line)
|
|
283
|
+
g = `<line x1="${c}" y1="${d}" x2="${c + 16}" y2="${d}" stroke="${e.connection}" stroke-width="1.4"${i.legend.line === "dashed" ? ' stroke-dasharray="5 5"' : ""}/>`;
|
|
284
|
+
else if (i.legend) {
|
|
285
|
+
const u = B(e, i.legend.family, i.legend.shade ?? et, "node");
|
|
286
|
+
g = Ge(c, h, o, `fill="${u.fill}" stroke="${u.stroke}"`);
|
|
287
|
+
} else {
|
|
288
|
+
const u = i.status.status, f = H(e, u), m = Te(e, u, "node");
|
|
289
|
+
g = Ge(
|
|
290
|
+
c,
|
|
291
|
+
h,
|
|
292
|
+
o,
|
|
293
|
+
`fill="${m.fill}" stroke="${m.stroke}" stroke-width="${f.width ?? 1}"${f.dash ? ' stroke-dasharray="3 2"' : ""} opacity="${f.opacity}"`
|
|
294
|
+
) + (f.marker ? yt(c + 16, h + (o - 12) / 2, m.stroke, e.canvas, 4) : "");
|
|
295
|
+
}
|
|
296
|
+
return g + `<text x="${c + Oe(i.legend) + 8}" y="${d}" dominant-baseline="central" font-family="${Y(r)}" font-size="${s}" font-weight="${l}" fill="${e.text}">${Y(i.label)}</text>`;
|
|
297
|
+
}).join("");
|
|
298
|
+
}
|
|
299
|
+
const Ge = (e, t, a, n) => `<rect x="${e}" y="${t + (a - 12) / 2}" width="16" height="12" rx="3" ${n}/>`, C = 40, J = 8;
|
|
300
|
+
function wt(e, t, a, n, o, r = [], s = []) {
|
|
301
|
+
const l = r.filter((y) => !y.inFrame).map((y) => y.rect), i = l.length ? ye([o, ye(l, C)]) : o, c = r.filter((y) => y.inFrame), h = Ht(e, (t?.width ?? i.w) - C * 2), d = qt(e, t, h), g = c.reduce((y, p) => y + p.rect.h + J, d.h ? 0 : -J), u = c.length ? { w: Math.max(d.w, ...c.map((y) => y.rect.w)), h: (d.h || 20) + g } : d, f = Math.max(i.w, u.w + C * 2, t?.width ?? 0) - C * 2, m = Bn(e, a, n, f), $ = Dn(e, s, f), T = $.h && !m.h ? $.h + C / 2 : $.h, M = Math.max(i.w, u.w + C * 2, m.w + C * 2), w = i.y - u.h, x = i.x + C;
|
|
302
|
+
let k = w + 28 + (d.h ? d.h - 20 + J : 0);
|
|
303
|
+
const b = r.map((y) => {
|
|
304
|
+
if (!y.inFrame) return y;
|
|
305
|
+
const p = { ...y.rect, x, y: k };
|
|
306
|
+
return k += y.rect.h + J, { ...y, rect: p };
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
x: i.x,
|
|
310
|
+
y: w,
|
|
311
|
+
w: Math.max(M, t?.width ?? 0),
|
|
312
|
+
h: i.h + u.h + T + m.h,
|
|
313
|
+
/** Width without the heading's `width`, which a drag never narrows past. */
|
|
314
|
+
natural: M,
|
|
315
|
+
head: u,
|
|
316
|
+
key: m,
|
|
317
|
+
heading: { x, y: w + 28, wrap: h },
|
|
318
|
+
legend: { x, y: i.y + i.h - 12 + $.h },
|
|
319
|
+
/** The footnote block's top-left corner and layout. */
|
|
320
|
+
foot: { ...$, x, y: i.y + i.h - 12 },
|
|
321
|
+
/** Every note, placed. */
|
|
322
|
+
notes: b
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const Hn = 1, qn = 3, Ke = (e) => e.dark ? 950 : 50;
|
|
326
|
+
function De(e, t, a) {
|
|
327
|
+
const n = N(e, a), o = rt(e, a), r = n.color, s = o && !!e.layout.sequence && n.shade === void 0;
|
|
328
|
+
if (!r || r === "auto") return s ? Ke(t) : n.shade;
|
|
329
|
+
const l = n.shade ?? me(
|
|
330
|
+
t,
|
|
331
|
+
r,
|
|
332
|
+
s ? Ke(t) : o ? Ut(t.theme) : et
|
|
333
|
+
), i = Re(e, a)?.parentId, c = i ? at(e, i) : void 0;
|
|
334
|
+
if (!c || N(e, c.id).color !== r) return l;
|
|
335
|
+
const h = De(e, t, c.id);
|
|
336
|
+
if (h === void 0) return l;
|
|
337
|
+
const d = !!Vt[t.theme]?.dark;
|
|
338
|
+
if (!o && n.shade === void 0 && (d ? h >= 700 : h <= 300))
|
|
339
|
+
return me(t, r, Xt(t.theme));
|
|
340
|
+
const g = o ? Hn : qn, u = d ? -1 : 1, f = ae.indexOf(l), m = ae.indexOf(h);
|
|
341
|
+
return (f - m) * u >= g || (m - f) * u > 2 ? l : me(t, r, ae[Un(m + g * u)]);
|
|
342
|
+
}
|
|
343
|
+
function V(e, t, a, n) {
|
|
344
|
+
if (U(e)) return Te(t, N(e, a).status, n);
|
|
345
|
+
if (N(e, a).spot === "dim") return Te(t, void 0, n);
|
|
346
|
+
const o = B(t, N(e, a).color, De(e, t, a), n);
|
|
347
|
+
if (n === "node" && e.layout.sequence) {
|
|
348
|
+
const r = Re(e, a)?.parentId;
|
|
349
|
+
return {
|
|
350
|
+
fill: r && at(e, r)?.frame !== "none" ? V(e, t, r, "group").fill : t.canvas,
|
|
351
|
+
stroke: bt(e, t, a) ?? o.stroke,
|
|
352
|
+
ink: t.text
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return o;
|
|
356
|
+
}
|
|
357
|
+
function bt(e, t, a) {
|
|
358
|
+
if (!e.layout.sequence || !Re(e, a) || rt(e, a) || U(e) || N(e, a).spot === "dim") return;
|
|
359
|
+
const n = De(e, t, a), o = N(e, a).color;
|
|
360
|
+
if (!((!o || o === "auto") && n === void 0))
|
|
361
|
+
return B(t, o, n, "node").fill;
|
|
362
|
+
}
|
|
363
|
+
function zn(e, t) {
|
|
364
|
+
return t.fill === e.node.fill && t.ink === e.node.ink ? re(e.muted, t.fill, je.connection) : re(zt(t.ink, t.fill, 0.3), t.fill, je.connection);
|
|
365
|
+
}
|
|
366
|
+
const Un = (e) => Math.max(0, Math.min(ae.length - 1, e));
|
|
367
|
+
function me(e, t, a) {
|
|
368
|
+
const n = Gt(e, t);
|
|
369
|
+
return !n.length || n.includes(a) ? a : n.reduce((o, r) => Math.abs(r - a) < Math.abs(o - a) ? r : o);
|
|
370
|
+
}
|
|
371
|
+
const ee = 4;
|
|
372
|
+
function Vn(e, t, a, n, o = 0) {
|
|
373
|
+
const r = [];
|
|
374
|
+
for (const s of t.nodes) {
|
|
375
|
+
const l = a.get(s.id);
|
|
376
|
+
l && r.push(Kt(e, s.id, s.title, l)), l && s.lifeline && r.push({ x: l.x + l.w / 2, y: l.y + l.h, w: 1, h: s.lifeline });
|
|
377
|
+
}
|
|
378
|
+
for (const s of t.groups) {
|
|
379
|
+
const l = a.get(s.id);
|
|
380
|
+
l && r.push(l);
|
|
381
|
+
}
|
|
382
|
+
e.layout.sequence && r.push(e.layout.sequence.panel);
|
|
383
|
+
for (const s of n) {
|
|
384
|
+
for (const i of s.points)
|
|
385
|
+
r.push({ x: i.x - ee, y: i.y - ee, w: ee * 2, h: ee * 2 });
|
|
386
|
+
const l = s.label;
|
|
387
|
+
l && r.push({ x: l.x - l.w / 2, y: l.y - l.h / 2, w: l.w, h: l.h });
|
|
388
|
+
}
|
|
389
|
+
return ye(r, o);
|
|
390
|
+
}
|
|
391
|
+
const ge = (e, t) => e.x >= t.x && e.x <= t.x + t.w && e.y >= t.y && e.y <= t.y + t.h, Tt = (e) => e % 2 ? 0.03 : 0.12;
|
|
392
|
+
function Mt(e) {
|
|
393
|
+
if (!e.layout.sequence) return !1;
|
|
394
|
+
const t = new Set(e.graph.groups.filter((a) => a.frame !== "none").map((a) => a.id));
|
|
395
|
+
return e.graph.nodes.some((a) => a.lifeline && !(a.parentId && t.has(a.parentId)));
|
|
396
|
+
}
|
|
397
|
+
function Xn(e, t) {
|
|
398
|
+
const { vg: a, rects: n } = Ie(e), o = e.layout.sequence, r = !!o && Mt(e);
|
|
399
|
+
return (s) => {
|
|
400
|
+
let l = t.canvas;
|
|
401
|
+
o && r && ge(s, o.panel) && (l = st(t).fill);
|
|
402
|
+
for (const c of a.groups) {
|
|
403
|
+
const h = n.get(c.id);
|
|
404
|
+
if (!h || c.frame === "none") continue;
|
|
405
|
+
(c.frame === "soft" && c.hull?.length ? c.hull : [{ x: 0, y: 0, w: h.w, h: h.h }]).some((g) => ge(s, { x: h.x + g.x, y: h.y + g.y, w: g.w, h: g.h })) && (l = V(e, t, c.id, "group").fill);
|
|
406
|
+
}
|
|
407
|
+
const i = o ? o.phases.findIndex((c) => s.y >= c.y && s.y <= c.y + c.h) : -1;
|
|
408
|
+
return i < 0 || !ge(s, o.panel) ? { fill: l } : {
|
|
409
|
+
fill: l,
|
|
410
|
+
tint: { fill: it(t).stroke, opacity: Tt(i) }
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function Gn(e, t) {
|
|
415
|
+
const a = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const n of t.matchAll(/M([-\d.]+) ([-\d.]+)L([-\d.]+) ([-\d.]+)/g)) {
|
|
417
|
+
const [o, r, s, l] = n.slice(1).map(Number), i = e({ x: (o + s) / 2, y: (r + l) / 2 }), c = JSON.stringify(i), h = a.get(c);
|
|
418
|
+
h ? h.d += n[0] : a.set(c, { surface: i, d: n[0] });
|
|
419
|
+
}
|
|
420
|
+
return [...a.values()];
|
|
421
|
+
}
|
|
422
|
+
const S = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
423
|
+
class ve extends Error {
|
|
424
|
+
}
|
|
425
|
+
const Kn = new TextEncoder();
|
|
426
|
+
class vt extends Array {
|
|
427
|
+
constructor(t = 1 / 0) {
|
|
428
|
+
super(), this.limit = t;
|
|
429
|
+
}
|
|
430
|
+
bytes = 0;
|
|
431
|
+
push(...t) {
|
|
432
|
+
for (const a of t) {
|
|
433
|
+
if (this.bytes += Kn.encode(a).length + (this.length ? 1 : 0), this.bytes > this.limit) throw new ve("SVG output exceeds maxOutputBytes.");
|
|
434
|
+
super.push(a);
|
|
435
|
+
}
|
|
436
|
+
return this.length;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function $e(e, t, a) {
|
|
440
|
+
if (!e) return t;
|
|
441
|
+
const n = fn(e).kind === "url";
|
|
442
|
+
return [
|
|
443
|
+
`<a class="link" href="${S(a.href?.(e) ?? e)}"${a.linkTarget === "_self" ? ' target="_self"' : a.linkTarget === "_blank" || n ? ' target="_blank" rel="noopener noreferrer"' : ""}>`,
|
|
444
|
+
...t,
|
|
445
|
+
"</a>"
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
const We = (e, t, a, n) => `<path class="link-mark" transform="translate(${t + e.x},${a + e.y}) scale(${e.size / 10})" d="${un}" fill="none" stroke="${n}" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`, ce = (e) => e.textHref ?? ((t) => e.href?.(t) ?? t), Wn = "a.link{cursor:pointer}a.link:hover .shape{stroke-width:2.4px}a.link:hover .link-mark{stroke-width:2px}", te = (e) => (e.strike ? ' text-decoration="line-through"' : "") + (e.inkFade ? ` fill-opacity="${e.inkFade}"` : ""), Ze = (e, t, a, n) => e.marker ? yt(t.x + t.w - be.inset, t.y + be.inset, a, n) : "", z = (e) => e.opacity < 1 ? ` opacity="${e.opacity}"` : "", F = (e) => `font-family="${S(e.family)}" font-size="${e.size}" font-weight="${e.weight}"`;
|
|
449
|
+
function ke(e, t, a, n, o = "") {
|
|
450
|
+
if (e === "diamond")
|
|
451
|
+
return `<path d="M${t.x + t.w / 2},${t.y} L${t.x + t.w},${t.y + t.h / 2} L${t.x + t.w / 2},${t.y + t.h} L${t.x},${t.y + t.h / 2} Z" ${n}/>`;
|
|
452
|
+
if (e === "circle")
|
|
453
|
+
return `<ellipse cx="${t.x + t.w / 2}" cy="${t.y + t.h / 2}" rx="${t.w / 2}" ry="${t.h / 2}" ${n}/>`;
|
|
454
|
+
if (e === "text") return "";
|
|
455
|
+
if (e === "marker")
|
|
456
|
+
return `<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" rx="2" fill="${o}"/>`;
|
|
457
|
+
const r = e === "pill" ? t.h / 2 : a;
|
|
458
|
+
return `<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" rx="${r}" ${n}/>`;
|
|
459
|
+
}
|
|
460
|
+
const Qe = (e, t, a) => ke(
|
|
461
|
+
e === "text" ? "box" : e,
|
|
462
|
+
{ x: t.x - X, y: t.y - X, w: t.w + 2 * X, h: t.h + 2 * X },
|
|
463
|
+
a.radius + X,
|
|
464
|
+
`fill="none" stroke="${ht(a)}" stroke-width="2"`
|
|
465
|
+
);
|
|
466
|
+
function Zn(e, t, a, n) {
|
|
467
|
+
const o = e.layout.containers[a]?.cellsChrome, r = V(e, t, a, "group").ink;
|
|
468
|
+
return o ? [
|
|
469
|
+
...(o.ruler?.ticks ?? []).map(
|
|
470
|
+
(s) => `<text x="${n.x + s.x}" y="${n.y + o.ruler.y + o.ruler.h / 2}" text-anchor="middle" dominant-baseline="central" ${F(t.annotation)} fill="${r}">${S(s.label)}</text>`
|
|
471
|
+
),
|
|
472
|
+
...Object.entries(o.pieces ?? {}).flatMap(([s, l]) => {
|
|
473
|
+
const i = V(e, t, s, "node"), c = e.graph.nodes.find((h) => h.id === s)?.title ?? "";
|
|
474
|
+
return l.map(
|
|
475
|
+
(h) => `<rect x="${n.x + h.x}" y="${n.y + h.y}" width="${h.w}" height="${h.h}" fill="${i.fill}" stroke="${i.stroke}" stroke-width="1.2"/><text x="${n.x + h.x + h.w / 2}" y="${n.y + h.y + h.h / 2}" text-anchor="middle" dominant-baseline="central" ${F(t.annotation)} fill="${i.ink}" opacity="0.75">${S(se(`… ${c}`, Math.max(0, h.w - 8), t.annotation))}</text>`
|
|
476
|
+
);
|
|
477
|
+
})
|
|
478
|
+
] : [];
|
|
479
|
+
}
|
|
480
|
+
function fe(e) {
|
|
481
|
+
const { vg: t, rects: a } = Ie(e);
|
|
482
|
+
return Wt(e, t, a, { previous: [] }).routes;
|
|
483
|
+
}
|
|
484
|
+
function Qn(e, t) {
|
|
485
|
+
const a = new Set(e.graph.nodes.filter((s) => s.wasShape).map((s) => s.id)), n = new Set(e.graph.edges.filter((s) => s.was !== void 0).map((s) => s.id)), o = !!e.layout.sequence;
|
|
486
|
+
if (!o && !a.size && !n.size) return t;
|
|
487
|
+
const r = fe(mt(e));
|
|
488
|
+
return t.map((s) => {
|
|
489
|
+
const l = e.graph.edges.find((i) => i.id === s.id);
|
|
490
|
+
return o || a.has(l.from) || a.has(l.to) || n.has(l.id) ? r.find((i) => i.id === s.id) : s;
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function kt(e, t, a, n, o) {
|
|
494
|
+
const { vg: r, rects: s } = Ie(e), l = new Set(e.graph.edges.map((u) => u.id)), i = o ? o.filter((u) => l.has(u.id)) : fe(e), c = new vt(n.maxOutputBytes), h = U(e), d = Jn(e, t);
|
|
495
|
+
c.push(...d.panel);
|
|
496
|
+
for (const u of r.groups) {
|
|
497
|
+
const f = s.get(u.id), m = V(e, t, u.id, "group"), $ = H(t, N(e, u.id).status, N(e, u.id).spot), T = Zt(e, u.id), M = T ? T / 2 : t.groupHeader / 2 - 7, w = T ? 12 : 33, x = T ? [se(u.title, Math.max(40, f.w - w - 12), t.groupTitle)] : Qt(u.title, f.w, t, u.titleLines);
|
|
498
|
+
if (u.frame !== "none") {
|
|
499
|
+
if (u.frame === "soft") {
|
|
500
|
+
const k = u.hull?.length ? u.hull : [{ x: 0, y: 0, w: f.w, h: f.h }];
|
|
501
|
+
c.push(
|
|
502
|
+
...$e(
|
|
503
|
+
u.href,
|
|
504
|
+
[
|
|
505
|
+
`<g data-id="${S(u.id)}"${z($)}>`,
|
|
506
|
+
...k.map(
|
|
507
|
+
(b) => `<rect x="${f.x + b.x}" y="${f.y + b.y}" width="${b.w}" height="${b.h}" rx="${Yt}" fill="${m.fill}"/>`
|
|
508
|
+
),
|
|
509
|
+
`<text x="${f.x + k[0].x + Ce.x}" y="${f.y + k[0].y + Ce.y}" dominant-baseline="central" ${F(t.annotation)} fill="${m.ink}"${te($)}>${S(se(u.title, Math.max(40, k[0].w - 2 * Jt), t.annotation))}</text>`,
|
|
510
|
+
"</g>"
|
|
511
|
+
],
|
|
512
|
+
n
|
|
513
|
+
)
|
|
514
|
+
);
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
c.push(
|
|
518
|
+
...$e(
|
|
519
|
+
u.href,
|
|
520
|
+
[
|
|
521
|
+
`<g data-id="${S(u.id)}"${z($)}>`,
|
|
522
|
+
$.halo ? Qe("box", f, { ...t, radius: Math.min(10, t.radius + 4) }) : "",
|
|
523
|
+
`<rect class="shape" x="${f.x}" y="${f.y}" width="${f.w}" height="${f.h}" rx="${T ? Math.min(4, t.radius) : Math.min(10, t.radius + 4)}" fill="${m.fill}" stroke="${m.stroke}" stroke-width="${$.width ?? 1}" stroke-opacity="${$.stroke ? 1 : 0.65}"${$.dash ? ` stroke-dasharray="${$.dash}"` : ""}/>`,
|
|
524
|
+
T ? "" : `<svg x="${f.x + 12}" y="${f.y + M - 6.5}" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="${m.ink}" stroke-width="1.65" stroke-linecap="round" stroke-linejoin="round">${wn.group}</svg>`,
|
|
525
|
+
...Zn(e, t, u.id, f),
|
|
526
|
+
...x.map(
|
|
527
|
+
(k, b) => `<text x="${f.x + w}" y="${f.y + M + b * t.groupTitle.lineHeight}" dominant-baseline="central" ${F(t.groupTitle)} fill="${m.ink}"${te($)}>${S(k)}</text>`
|
|
528
|
+
),
|
|
529
|
+
u.href ? We(
|
|
530
|
+
en(
|
|
531
|
+
x[x.length - 1],
|
|
532
|
+
t.groupTitle,
|
|
533
|
+
M + (x.length - 1) * t.groupTitle.lineHeight
|
|
534
|
+
),
|
|
535
|
+
f.x,
|
|
536
|
+
f.y,
|
|
537
|
+
m.ink
|
|
538
|
+
) : "",
|
|
539
|
+
Ze($, f, m.stroke, t.canvas),
|
|
540
|
+
"</g>"
|
|
541
|
+
],
|
|
542
|
+
n
|
|
543
|
+
)
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
c.push(...d.phases);
|
|
548
|
+
for (const u of r.nodes) {
|
|
549
|
+
const f = s.get(u.id);
|
|
550
|
+
if (!f || !u.lifeline) continue;
|
|
551
|
+
const m = f.x + f.w / 2;
|
|
552
|
+
c.push(
|
|
553
|
+
`<line x1="${m}" y1="${f.y + f.h}" x2="${m}" y2="${f.y + f.h + u.lifeline}" stroke="${t.muted}" stroke-width="${Pe.width}" stroke-dasharray="${Pe.dash}"/>`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
c.push(...d.bars);
|
|
557
|
+
const g = Xn(e, t);
|
|
558
|
+
for (const u of i) {
|
|
559
|
+
const f = e.graph.edges.find((p) => p.id === u.id), m = H(t, f.status, f.spot), $ = le(t, f, h), T = m.dash ?? (f.dashed ? "5 5" : ""), M = Se(f), w = _e(f);
|
|
560
|
+
c.push(
|
|
561
|
+
`<g data-id="${S(f.id)}"${z(m)}>`,
|
|
562
|
+
...Gn(g, u.halo).flatMap(
|
|
563
|
+
({ surface: p, d: _ }) => Ye(
|
|
564
|
+
p,
|
|
565
|
+
(L) => `<path d="${_}" fill="none" stroke-width="${pn}" ${L}/>`,
|
|
566
|
+
"stroke"
|
|
567
|
+
)
|
|
568
|
+
),
|
|
569
|
+
`<path d="${u.path}" fill="none" stroke="${$}" stroke-width="${m.width ? m.width - 0.5 : 1.4}" stroke-linecap="round" stroke-linejoin="round"${T ? ` stroke-dasharray="${T}"` : ""}${M === "none" ? "" : ` marker-end="url(#${a(M, $)})"`}${w === "none" ? "" : ` marker-start="url(#${a(w, $, !0)})"`}/>`
|
|
570
|
+
);
|
|
571
|
+
const x = u.label, k = e.layout.edges[u.id]?.row !== void 0, b = tn(t, k), y = nn(f.label, t, k);
|
|
572
|
+
x && c.push(
|
|
573
|
+
...Ye(
|
|
574
|
+
g(x),
|
|
575
|
+
(p) => `<rect x="${x.x - x.w / 2}" y="${x.y - x.h / 2}" width="${x.w}" height="${x.h}" rx="4" ${p}/>`
|
|
576
|
+
),
|
|
577
|
+
`<text x="${x.x}" y="${x.y - (y.length - 1) * b.lineHeight / 2}" text-anchor="middle" dominant-baseline="central" ${F(b)} fill="${$}"${te(m)}>${y.length === 1 ? S(y[0]) : y.map((p, _) => `<tspan x="${x.x}" dy="${_ ? b.lineHeight : 0}">${S(p)}</tspan>`).join("")}</text>`
|
|
578
|
+
), c.push("</g>");
|
|
579
|
+
}
|
|
580
|
+
for (const u of r.nodes) {
|
|
581
|
+
const f = s.get(u.id), m = N(e, u.id), $ = V(e, t, u.id, "node"), T = H(t, m.status, m.spot), M = an(e, u.id) ? 0 : t.radius, w = rn(e, u.id, u.title, f), x = w.mode === "center" && m.shape !== "text", k = x ? $.ink : t.text, b = `font-size="${t.detail.size}" font-weight="${t.detail.weight}" fill="${x ? zn(t, $) : t.muted}"`, y = bt(e, t, u.id), p = `class="shape" fill="${$.fill}" stroke="${$.stroke}" stroke-width="${T.width ?? (y ? 1.5 : 1.2)}"${T.dash ? ` stroke-dasharray="${T.dash}"` : ""}`, _ = u.count ? Ln(u.count) : "", L = W(_, t.annotation) + 12, E = t.annotation.lineHeight + 4, R = u.href ? sn(m.shape, f.w, f.h, _ ? L : 0) : void 0;
|
|
582
|
+
c.push(
|
|
583
|
+
...$e(
|
|
584
|
+
u.href,
|
|
585
|
+
[
|
|
586
|
+
`<g data-id="${S(u.id)}"${z(T)}>`,
|
|
587
|
+
...u.count && m.shape !== "text" ? _n.map(
|
|
588
|
+
(I) => ke(m.shape, { ...f, x: f.x + I, y: f.y + I }, M, p)
|
|
589
|
+
) : [],
|
|
590
|
+
T.halo ? Qe(m.shape, f, t) : "",
|
|
591
|
+
on(e, u.id) ? `<path d="${ln(f)}" ${p}/>` : ke(m.shape, f, M, p, t.text),
|
|
592
|
+
y && m.shape === "box" ? `<path d="${ea(f, M)}" fill="${y}"/>` : "",
|
|
593
|
+
`<text x="${f.x + w.x}" y="${f.y + w.y}" text-anchor="middle" dominant-baseline="central" ${F(t.title)} fill="${k}"${te(T)}>` + w.lines.map(
|
|
594
|
+
(I, D) => `<tspan x="${f.x + w.x}" y="${f.y + w.y + w.offsets[D]}"${I.detail ? ` ${b}` : ""}>${S(I.text)}</tspan>`
|
|
595
|
+
).join("") + "</text>",
|
|
596
|
+
_ ? `<rect x="${f.x + f.w - L + 6}" y="${f.y - E / 2}" width="${L}" height="${E}" rx="${E / 2}" fill="${$.stroke}"/><text x="${f.x + f.w - L / 2 + 6}" y="${f.y}" text-anchor="middle" dominant-baseline="central" ${F(t.annotation)} fill="${t.canvas}">${S(_)}</text>` : "",
|
|
597
|
+
R ? We(R, f.x, f.y, R.inside ? $.ink : t.muted) : "",
|
|
598
|
+
_ ? "" : Ze(T, f, $.stroke, t.canvas),
|
|
599
|
+
"</g>"
|
|
600
|
+
],
|
|
601
|
+
n
|
|
602
|
+
)
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
for (const u of i) {
|
|
606
|
+
if (!u.cross) continue;
|
|
607
|
+
const f = e.graph.edges.find((w) => w.id === u.id), m = H(t, f.status), $ = le(t, f, h), [T, M] = u.cross;
|
|
608
|
+
c.push(
|
|
609
|
+
`<g${z(m)}>`,
|
|
610
|
+
`<line x1="${T.x}" y1="${T.y}" x2="${M.x}" y2="${M.y}" stroke="${$}" stroke-width="${m.width ? m.width - 0.5 : 1.4}"${m.dash || f.dashed ? ` stroke-dasharray="${m.dash ?? "5 5"}"` : ""}/>`,
|
|
611
|
+
`<circle cx="${M.x}" cy="${M.y}" r="3.5" fill="${$}"/>`,
|
|
612
|
+
"</g>"
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
return {
|
|
616
|
+
markup: c.join(`
|
|
617
|
+
`),
|
|
618
|
+
bounds: Vn(e, r, s, i, 40),
|
|
619
|
+
rects: s,
|
|
620
|
+
routes: i
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
const Ae = 24, G = 0;
|
|
624
|
+
function At(e, t, a = "") {
|
|
625
|
+
const n = [
|
|
626
|
+
.../* @__PURE__ */ new Set([
|
|
627
|
+
e.connection,
|
|
628
|
+
...t.flatMap((l) => l.graph.edges.map((i) => le(e, i, U(l))))
|
|
629
|
+
])
|
|
630
|
+
], o = (l, i, c = !1) => {
|
|
631
|
+
const h = n.indexOf(i);
|
|
632
|
+
return `${a}${l}${h ? `-${h}` : ""}${c ? "-tail" : ""}`;
|
|
633
|
+
}, r = /* @__PURE__ */ new Map(), s = (l, i, c = !1) => {
|
|
634
|
+
if (l === "none") return;
|
|
635
|
+
const h = hn(l, c), d = o(l, i, c);
|
|
636
|
+
r.set(
|
|
637
|
+
d,
|
|
638
|
+
`<marker id="${d}" markerWidth="${h.markerWidth}" markerHeight="${h.markerHeight}" refX="${h.refX}" refY="${h.refY}" orient="${h.orient}" markerUnits="userSpaceOnUse"><path d="${Le[l].d}" fill="${nt(l, i, e.canvas)}" stroke="${i}" stroke-width="${tt}" stroke-linecap="round" stroke-linejoin="round"/></marker>`
|
|
639
|
+
);
|
|
640
|
+
};
|
|
641
|
+
for (const l of n) s("arrow", l);
|
|
642
|
+
for (const l of t)
|
|
643
|
+
for (const i of l.graph.edges) {
|
|
644
|
+
const c = le(e, i, U(l));
|
|
645
|
+
s(Se(i), c), s(_e(i), c, !0);
|
|
646
|
+
}
|
|
647
|
+
return { defs: [...r.values()].join(""), marker: o };
|
|
648
|
+
}
|
|
649
|
+
function Et(e, t, a, { x: n, y: o, w: r, h: s, heading: l }, i) {
|
|
650
|
+
const c = i.idPrefix ?? "draft", h = i.description ?? An(e), d = Wn.replace(/a\.link/g, `#${c}-svg a.link`), g = new vt(i.maxOutputBytes);
|
|
651
|
+
return g.push(
|
|
652
|
+
`<svg xmlns="http://www.w3.org/2000/svg" id="${c}-svg" role="img" aria-labelledby="${c}-title${h ? ` ${c}-description` : ""}" viewBox="${n} ${o} ${r} ${s}" width="${r}" height="${s}" data-theme="${t.theme}">`,
|
|
653
|
+
`<title id="${c}-title">${S(i.title ?? e.title)}</title>`,
|
|
654
|
+
h ? `<desc id="${c}-description">${S(h)}</desc>` : "",
|
|
655
|
+
i.metadata ?? "",
|
|
656
|
+
`<defs><style${i.styleNonce ? ` nonce="${S(i.styleNonce)}"` : ""}>${i.fontCss ?? ""}${e.graph.nodes.some((u) => u.href) || e.graph.groups.some((u) => u.href) ? d : ""}</style>` + a + "</defs>",
|
|
657
|
+
`<rect x="${n}" y="${o}" width="${r}" height="${s}" fill="${t.canvas}"/>`,
|
|
658
|
+
// The title and subtitle sit above the drawing, left-aligned with the legend under it.
|
|
659
|
+
cn(t, e.appearance.heading, l.x, l.y, l.wrap)
|
|
660
|
+
), g;
|
|
661
|
+
}
|
|
662
|
+
function Yn(e, t, a) {
|
|
663
|
+
const n = e.appearance.states ?? [], o = n.map((b) => ft(gt(e), b.id)), { defs: r, marker: s } = At(t, o, a.idPrefix ? `${a.idPrefix}-` : ""), l = fe(e), i = o.map((b) => kt(b, t, s, a, l)), c = i.map((b) => b.bounds).reduce(St), h = Math.floor(c.x), d = Math.floor(c.y), g = Math.ceil(c.x + c.w) - h, u = Math.ceil(c.y + c.h) - d + Ae, f = ut(e), m = pt(e), $ = xe(e, t, /* @__PURE__ */ new Map(), []), T = e.appearance.compare?.aspect ?? 1.6, M = (b) => {
|
|
664
|
+
const y = Math.ceil(n.length / b), p = wt(
|
|
665
|
+
t,
|
|
666
|
+
e.appearance.heading,
|
|
667
|
+
m,
|
|
668
|
+
f,
|
|
669
|
+
{ x: h, y: d, w: b * g, h: y * u },
|
|
670
|
+
$,
|
|
671
|
+
e.appearance.footnotes
|
|
672
|
+
);
|
|
673
|
+
return { cols: b, frame: p, w: p.w, h: p.h };
|
|
674
|
+
}, { cols: w, frame: x } = n.map((b, y) => M(y + 1)).reduce(
|
|
675
|
+
(b, y) => Math.abs(Math.log(y.w / y.h / T)) < Math.abs(Math.log(b.w / b.h / T)) ? y : b
|
|
676
|
+
), k = Et(e, t, r, x, a);
|
|
677
|
+
return i.forEach((b, y) => {
|
|
678
|
+
const p = y % w, _ = Math.floor(y / w), L = h + p * g, E = d + _ * u;
|
|
679
|
+
k.push(
|
|
680
|
+
`<text x="${L + 40}" y="${E + 36}" dominant-baseline="central" ${F(t.groupTitle)} fill="${t.text}">${S(n[y].label)}</text>`
|
|
681
|
+
), p && k.push(
|
|
682
|
+
`<line x1="${L}" x2="${L}" y1="${E + 16}" y2="${E + u - 16}" stroke="${t.muted}" stroke-opacity="0.35"/>`
|
|
683
|
+
), _ && !p && k.push(
|
|
684
|
+
`<line x1="${h + 40}" x2="${h + w * g - 40}" y1="${E}" y2="${E}" stroke="${t.muted}" stroke-opacity="0.35"/>`
|
|
685
|
+
), k.push(
|
|
686
|
+
`<g data-state="${S(n[y].id)}" transform="translate(${p * g},${_ * u + Ae})">`,
|
|
687
|
+
b.markup,
|
|
688
|
+
"</g>"
|
|
689
|
+
);
|
|
690
|
+
}), k.push($t(t, x.foot, x.foot.x, x.foot.y, ce(a))), k.push(xt(t, x.key, x.legend.x, x.legend.y)), k.push(ot(t, x.notes, ce(a))), k.push(`</svg>
|
|
691
|
+
`), k.join(`
|
|
692
|
+
`);
|
|
693
|
+
}
|
|
694
|
+
function Jn(e, t) {
|
|
695
|
+
const a = e.layout.sequence;
|
|
696
|
+
if (!a) return { panel: [], phases: [], bars: [] };
|
|
697
|
+
const { panel: n } = a, o = it(t), r = a.phaseX ?? n.x;
|
|
698
|
+
return {
|
|
699
|
+
panel: [
|
|
700
|
+
Mt(e) && `<rect class="sequence-panel" x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" rx="${Math.min(10, t.radius + 4)}" fill="${st(t).fill}" stroke="${o.stroke}" stroke-opacity="0.6"/>`
|
|
701
|
+
].filter(Boolean),
|
|
702
|
+
// Activation bars go over the lifelines and under the messages, which end on their sides.
|
|
703
|
+
bars: (a.activations ?? []).map((s) => {
|
|
704
|
+
const l = e.graph.edges.find((i) => i.id === s.call)?.spot === "dim";
|
|
705
|
+
return `<rect class="sequence-activation" data-call="${S(s.call)}" x="${s.x}" y="${s.y}" width="${s.w}" height="${s.h}" rx="1.5" fill="${t.canvas}" stroke="${t.connection}" stroke-width="1.2"${l ? z(H(t, void 0, "dim")) : ""}/>`;
|
|
706
|
+
}),
|
|
707
|
+
// Alternate phases are tinted, so neighbours read apart even without their divider.
|
|
708
|
+
phases: a.phases.flatMap((s, l) => [
|
|
709
|
+
`<rect class="sequence-phase" data-phase="${S(s.id)}" x="${n.x}" y="${s.y}" width="${n.w}" height="${s.h}" fill="${o.stroke}" fill-opacity="${Tt(l)}"/>`,
|
|
710
|
+
`<line x1="${n.x}" x2="${n.x + n.w}" y1="${s.y}" y2="${s.y}" stroke="${o.stroke}" stroke-opacity="0.5"/>`,
|
|
711
|
+
...dn(s.label, t).map(
|
|
712
|
+
(i, c) => `<text x="${r + Be}" y="${s.y + Be + (c + 0.5) * t.annotation.lineHeight}" dominant-baseline="central" ${F(t.annotation)} fill="${t.muted}">${S(i)}</text>`
|
|
713
|
+
)
|
|
714
|
+
])
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function Ye(e, t, a = "fill") {
|
|
718
|
+
const n = e.tint;
|
|
719
|
+
return [
|
|
720
|
+
t(`${a}="${e.fill}"`),
|
|
721
|
+
n ? t(`${a}="${n.fill}" ${a}-opacity="${n.opacity}"`) : ""
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
function ea(e, t) {
|
|
725
|
+
const a = Math.min(t, e.w / 2, 4), n = 4;
|
|
726
|
+
return `M${e.x} ${e.y + n}V${e.y + a}Q${e.x} ${e.y} ${e.x + a} ${e.y}H${e.x + e.w - a}Q${e.x + e.w} ${e.y} ${e.x + e.w} ${e.y + a}V${e.y + n}Z`;
|
|
727
|
+
}
|
|
728
|
+
function ta(e, t = {}) {
|
|
729
|
+
const a = Ee(e.appearance), n = e.appearance.compare;
|
|
730
|
+
if (t.states) return Yn(e, a, t);
|
|
731
|
+
const { defs: o, marker: r } = At(a, [e], t.idPrefix ? `${t.idPrefix}-` : ""), s = n ? fe(e) : void 0, l = s ? [Qn(e, s), s] : [], i = (n ? [Ue(e, "before"), Ue(e, "after")] : [e]).map(
|
|
732
|
+
(R, I) => kt(R, a, r, t, l[I] ?? (n ? void 0 : t.routes))
|
|
733
|
+
), c = i.map((R) => R.bounds).reduce(St), h = Math.floor(c.x), d = Math.floor(c.y), g = Math.ceil(c.x + c.w) - h, u = Math.ceil(c.y + c.h) - d, f = n ? Ae : 0, m = ut(e), $ = pt(e), T = n ? xe(e, a, /* @__PURE__ */ new Map(), []) : xe(e, a, i[0].rects, i[0].routes), M = (R) => {
|
|
734
|
+
const I = i.map(
|
|
735
|
+
({ bounds: O }) => R ? { from: Math.floor(O.y), size: Math.ceil(O.y + O.h) - Math.floor(O.y) } : { from: Math.floor(O.x), size: Math.ceil(O.x + O.w) - Math.floor(O.x) }
|
|
736
|
+
), D = I.map(
|
|
737
|
+
(O, pe) => I.slice(0, pe).reduce((Ot, Dt) => Ot + Dt.size + G + (R ? f : 0), 0)
|
|
738
|
+
), j = D.at(-1) + I.at(-1).size, ue = R ? g : j, Z = R ? j + f : u + f, q = wt(
|
|
739
|
+
a,
|
|
740
|
+
e.appearance.heading,
|
|
741
|
+
$,
|
|
742
|
+
m,
|
|
743
|
+
{ x: h, y: d, w: ue, h: Z },
|
|
744
|
+
T,
|
|
745
|
+
e.appearance.footnotes
|
|
746
|
+
);
|
|
747
|
+
return { stacked: R, spans: I, starts: D, areaH: Z, frame: q, w: q.w, h: q.h };
|
|
748
|
+
}, w = n?.aspect ?? 1.6, x = (R) => Math.abs(Math.log(R.w / R.h / w)), k = n?.direction ? [M(n.direction === "down")] : [M(!0), M(!1)], { stacked: b, spans: y, starts: p, areaH: _, frame: L } = k.reduce((R, I) => x(I) < x(R) ? I : R), E = Et(e, a, o, L, t);
|
|
749
|
+
return n || t.onDrawn?.({ rects: i[0].rects, routes: i[0].routes }), i.forEach((R, I) => {
|
|
750
|
+
const D = b ? h : h + p[I], j = b ? d + p[I] : d, ue = b ? 0 : D - y[I].from, Z = (b ? j - y[I].from : 0) + f;
|
|
751
|
+
if (n) {
|
|
752
|
+
const q = I ? n.after : n.before;
|
|
753
|
+
if (E.push(
|
|
754
|
+
`<text x="${D + 40}" y="${j + 36}" dominant-baseline="central" ${F(a.groupTitle)} fill="${a.text}">${S(q)}</text>`
|
|
755
|
+
), !I && n.undrawn) {
|
|
756
|
+
const O = D + 40 + W(q, a.groupTitle) + 12, pe = (b ? g : y[0].size) - (O - D) - 40;
|
|
757
|
+
E.push(
|
|
758
|
+
`<text x="${O}" y="${j + 36}" dominant-baseline="central" ${F(a.annotation)} fill="${a.muted}">${S(se(`Drawn as new: ${n.undrawn}`, pe, a.annotation))}</text>`
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
I && E.push(
|
|
762
|
+
b ? `<line x1="${h + 40}" x2="${h + g - 40}" y1="${j - G / 2}" y2="${j - G / 2}" stroke="${a.muted}" stroke-opacity="0.35"/>` : `<line x1="${D - G / 2}" x2="${D - G / 2}" y1="${d}" y2="${d + _}" stroke="${a.muted}" stroke-opacity="0.35"/>`
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
E.push(`<g transform="translate(${ue},${Z})">`, R.markup, "</g>");
|
|
766
|
+
}), E.push($t(a, L.foot, L.foot.x, L.foot.y, ce(t))), E.push(xt(a, L.key, L.legend.x, L.legend.y)), E.push(ot(a, L.notes, ce(t))), E.push(`</svg>
|
|
767
|
+
`), E.join(`
|
|
768
|
+
`);
|
|
769
|
+
}
|
|
770
|
+
const St = (e, t) => {
|
|
771
|
+
const a = Math.min(e.x, t.x), n = Math.min(e.y, t.y);
|
|
772
|
+
return { x: a, y: n, w: Math.max(e.x + e.w, t.x + t.w) - a, h: Math.max(e.y + e.h, t.y + t.h) - n };
|
|
773
|
+
};
|
|
774
|
+
function na(e) {
|
|
775
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
776
|
+
throw new TypeError("Render options must be an object.");
|
|
777
|
+
if (e.target !== void 0 && !["image", "inline"].includes(e.target))
|
|
778
|
+
throw new TypeError("target must be image or inline.");
|
|
779
|
+
if (e.target === "inline") {
|
|
780
|
+
if (!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e.idPrefix ?? ""))
|
|
781
|
+
throw new TypeError(
|
|
782
|
+
"Inline output needs an idPrefix with 1–64 letters, digits, underscores or hyphens, starting with a letter."
|
|
783
|
+
);
|
|
784
|
+
} else if (e.idPrefix !== void 0 || e.fonts === "host")
|
|
785
|
+
throw new TypeError("idPrefix and host fonts require target: inline.");
|
|
786
|
+
if (e.fonts !== void 0 && !["host", "embed"].includes(e.fonts))
|
|
787
|
+
throw new TypeError("fonts must be embed or host.");
|
|
788
|
+
for (const a of ["title", "description", "styleNonce", "sourceId"])
|
|
789
|
+
if (e[a] !== void 0 && typeof e[a] != "string")
|
|
790
|
+
throw new TypeError(`${a} must be a string.`);
|
|
791
|
+
if (e.state !== void 0 && e.state !== null && typeof e.state != "string")
|
|
792
|
+
throw new TypeError("state must be a string or null.");
|
|
793
|
+
if (e.includeSource !== void 0 && typeof e.includeSource != "boolean")
|
|
794
|
+
throw new TypeError("includeSource must be a boolean.");
|
|
795
|
+
if (e.colorScheme !== void 0 && !["light", "dark", "auto"].includes(e.colorScheme))
|
|
796
|
+
throw new TypeError("colorScheme must be light, dark or auto.");
|
|
797
|
+
const t = e.links;
|
|
798
|
+
if (t !== void 0) {
|
|
799
|
+
if (!t || !["none", "safe"].includes(t.mode))
|
|
800
|
+
throw new TypeError("links.mode must be none or safe.");
|
|
801
|
+
if (t.mode === "safe") {
|
|
802
|
+
if (t.target !== void 0 && !["_self", "_blank"].includes(t.target))
|
|
803
|
+
throw new TypeError("links.target must be _self or _blank.");
|
|
804
|
+
if (t.resolve !== void 0 && typeof t.resolve != "function")
|
|
805
|
+
throw new TypeError("links.resolve must be a function.");
|
|
806
|
+
if (t.baseUrl !== void 0 && !Fe(t.baseUrl))
|
|
807
|
+
throw new TypeError("links.baseUrl must be an absolute HTTP(S) URL.");
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function Fe(e, t) {
|
|
812
|
+
if (typeof e != "string" || [...e].some((a) => a.charCodeAt(0) <= 32 || a.charCodeAt(0) === 127))
|
|
813
|
+
return null;
|
|
814
|
+
try {
|
|
815
|
+
const a = new URL(e, t);
|
|
816
|
+
return a.protocol === "https:" || a.protocol === "http:" ? a.href : null;
|
|
817
|
+
} catch {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
const aa = (e) => (t) => e.links?.mode === "safe" ? Fe(t, e.links.baseUrl) : null;
|
|
822
|
+
function ra(e, t) {
|
|
823
|
+
const a = [];
|
|
824
|
+
for (const n of [...e.graph.nodes, ...e.graph.groups]) {
|
|
825
|
+
if (!n.href) continue;
|
|
826
|
+
const o = t.links, r = o?.mode === "safe" ? o.resolve ? o.resolve({ itemId: n.id, href: n.href }) : n.href : null, s = r === null ? null : Fe(r, o?.mode === "safe" ? o.baseUrl : void 0);
|
|
827
|
+
s ? n.href = s : (delete n.href, o?.mode === "safe" && a.push({
|
|
828
|
+
severity: "warning",
|
|
829
|
+
code: "DRAFT_LINK_BLOCKED",
|
|
830
|
+
message: "The host link policy blocked this destination.",
|
|
831
|
+
itemIds: [n.id]
|
|
832
|
+
}));
|
|
833
|
+
}
|
|
834
|
+
return a;
|
|
835
|
+
}
|
|
836
|
+
const ne = /#[0-9a-fA-F]{3,8}\b|rgba?\([^)]*\)/g;
|
|
837
|
+
function sa(e, t) {
|
|
838
|
+
const a = /data-theme="[^"]*"/.exec(e)?.[0];
|
|
839
|
+
a && (t = t.replace(/data-theme="[^"]*"/, a));
|
|
840
|
+
const n = e.split(ne), o = t.split(ne);
|
|
841
|
+
if (n.length !== o.length || n.some((i, c) => i !== o[c])) return null;
|
|
842
|
+
const r = e.match(ne) ?? [], s = t.match(ne) ?? [];
|
|
843
|
+
let l = n[0];
|
|
844
|
+
for (let i = 0; i < r.length; i++)
|
|
845
|
+
l += (r[i].toLowerCase() === s[i].toLowerCase() ? r[i] : `light-dark(${r[i]}, ${s[i]})`) + n[i + 1];
|
|
846
|
+
return l;
|
|
847
|
+
}
|
|
848
|
+
const P = {
|
|
849
|
+
maxSourceChars: 3e5,
|
|
850
|
+
maxSourceBytes: 1e6,
|
|
851
|
+
maxObjects: 500,
|
|
852
|
+
maxEdges: 1200,
|
|
853
|
+
maxDepth: 12,
|
|
854
|
+
maxOutputBytes: 8e6
|
|
855
|
+
}, _t = new TextEncoder(), Je = (e) => e === 9 || e === 10 || e === 13 || e >= 32 && e <= 55295 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
|
|
856
|
+
function K(e) {
|
|
857
|
+
for (let t = 0; t < e.length; t++) {
|
|
858
|
+
const a = e.charCodeAt(t);
|
|
859
|
+
if (a >= 55296 && a <= 56319) {
|
|
860
|
+
const n = e.charCodeAt(t + 1);
|
|
861
|
+
if (!(n >= 56320 && n <= 57343) || (t++, !Je(65536 + (a - 55296 << 10) + (n - 56320)))) return !1;
|
|
862
|
+
} else {
|
|
863
|
+
if (a >= 56320 && a <= 57343) return !1;
|
|
864
|
+
if (!Je(a)) return !1;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return !0;
|
|
868
|
+
}
|
|
869
|
+
function he(e, t = /* @__PURE__ */ new Set()) {
|
|
870
|
+
return typeof e == "string" ? !K(e) : !e || typeof e != "object" || t.has(e) ? !1 : (t.add(e), Array.isArray(e) ? e.some((a) => he(a, t)) : Object.values(e).some((a) => he(a, t)));
|
|
871
|
+
}
|
|
872
|
+
function Lt(e, t = !1) {
|
|
873
|
+
if (e !== void 0 && (!e || typeof e != "object" || Array.isArray(e)))
|
|
874
|
+
throw new TypeError("limits must be an object.");
|
|
875
|
+
const a = t ? Object.keys(P).filter((o) => o !== "maxOutputBytes") : Object.keys(P);
|
|
876
|
+
for (const o of Object.keys(e ?? {}))
|
|
877
|
+
if (!a.includes(o)) throw new RangeError(`Unknown limit ${o}.`);
|
|
878
|
+
const n = { ...P, ...e };
|
|
879
|
+
for (const o of a) {
|
|
880
|
+
const r = n[o];
|
|
881
|
+
if (!Number.isSafeInteger(r) || r <= 0 || r > P[o])
|
|
882
|
+
throw new RangeError(
|
|
883
|
+
`${o} must be a positive safe integer no greater than ${P[o]}.`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
return n;
|
|
887
|
+
}
|
|
888
|
+
const v = (e, t, a, n, o, r, s = []) => ({
|
|
889
|
+
code: e,
|
|
890
|
+
severity: "error",
|
|
891
|
+
message: t,
|
|
892
|
+
...n ? { location: { ...a ? { sourceId: a } : {}, line: n, ...o ? { column: o } : {} } } : {},
|
|
893
|
+
itemIds: [...s],
|
|
894
|
+
...r ? { nativeCode: r } : {}
|
|
895
|
+
});
|
|
896
|
+
function A(e, t) {
|
|
897
|
+
return { ok: !1, reason: e, diagnostics: [t] };
|
|
898
|
+
}
|
|
899
|
+
function Ne(e, t) {
|
|
900
|
+
return e instanceof ie && /Limit:/.test(e.message) ? v(
|
|
901
|
+
"DRAFT_LIMIT",
|
|
902
|
+
e.message.replace(/^Line \d+(?:, column \d+)?: /, ""),
|
|
903
|
+
t,
|
|
904
|
+
e.line || void 0,
|
|
905
|
+
e.column || void 0
|
|
906
|
+
) : e instanceof ie ? v(
|
|
907
|
+
"DRAFT_PARSE",
|
|
908
|
+
e.message.replace(/^Line \d+(?:, column \d+)?: /, ""),
|
|
909
|
+
t,
|
|
910
|
+
e.line || void 0,
|
|
911
|
+
e.column || void 0
|
|
912
|
+
) : v("DRAFT_INTERNAL", "The diagram could not be compiled.", t);
|
|
913
|
+
}
|
|
914
|
+
function Rt(e, t, a) {
|
|
915
|
+
const n = e.objects.length;
|
|
916
|
+
if (n > t.maxObjects)
|
|
917
|
+
return v(
|
|
918
|
+
"DRAFT_LIMIT",
|
|
919
|
+
`The diagram has ${n} objects; the limit is ${t.maxObjects}.`,
|
|
920
|
+
a
|
|
921
|
+
);
|
|
922
|
+
if (e.edges.length > t.maxEdges)
|
|
923
|
+
return v(
|
|
924
|
+
"DRAFT_LIMIT",
|
|
925
|
+
`The diagram has ${e.edges.length} edges; the limit is ${t.maxEdges}.`,
|
|
926
|
+
a
|
|
927
|
+
);
|
|
928
|
+
const o = e.byId;
|
|
929
|
+
for (const r of e.objects) {
|
|
930
|
+
let s = 1, l = r.parent;
|
|
931
|
+
for (; l !== "root"; )
|
|
932
|
+
s++, l = o.get(l)?.parent ?? "root";
|
|
933
|
+
if (s > t.maxDepth)
|
|
934
|
+
return v(
|
|
935
|
+
"DRAFT_LIMIT",
|
|
936
|
+
`The diagram has containment depth ${s}; the limit is ${t.maxDepth}.`,
|
|
937
|
+
a,
|
|
938
|
+
r.line
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
function ia(e, t, a) {
|
|
943
|
+
if (e.objects.length > t.maxObjects)
|
|
944
|
+
return v(
|
|
945
|
+
"DRAFT_LIMIT",
|
|
946
|
+
`The diagram has ${e.objects.length} objects; the limit is ${t.maxObjects}.`,
|
|
947
|
+
a
|
|
948
|
+
);
|
|
949
|
+
if (e.edges.length > t.maxEdges)
|
|
950
|
+
return v(
|
|
951
|
+
"DRAFT_LIMIT",
|
|
952
|
+
`The diagram has ${e.edges.length} edges; the limit is ${t.maxEdges}.`,
|
|
953
|
+
a
|
|
954
|
+
);
|
|
955
|
+
const n = new Map(e.objects.map((o) => [o.id, o]));
|
|
956
|
+
for (const o of e.objects) {
|
|
957
|
+
let r = 1, s = o.parent;
|
|
958
|
+
for (; s !== "root"; )
|
|
959
|
+
r++, s = n.get(s)?.parent ?? "root";
|
|
960
|
+
if (r > t.maxDepth)
|
|
961
|
+
return v(
|
|
962
|
+
"DRAFT_LIMIT",
|
|
963
|
+
`The diagram has containment depth ${r}; the limit is ${t.maxDepth}.`,
|
|
964
|
+
a,
|
|
965
|
+
o.line
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function It(e, t, a) {
|
|
970
|
+
if (!(t.maxObjects === P.maxObjects && t.maxEdges === P.maxEdges && t.maxDepth === P.maxDepth))
|
|
971
|
+
try {
|
|
972
|
+
return ia($n(e), t, a);
|
|
973
|
+
} catch (n) {
|
|
974
|
+
return Ne(n, a);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
const de = (e) => e.code === "DRAFT_INTERNAL" ? "internal" : e.code === "DRAFT_LIMIT" ? "limit" : "input";
|
|
978
|
+
async function oa(e, t = {}) {
|
|
979
|
+
if (na(t), typeof e != "string") throw new TypeError("source must be a string.");
|
|
980
|
+
const a = Lt(t.limits), n = t.sourceId;
|
|
981
|
+
if (t.signal?.aborted)
|
|
982
|
+
return {
|
|
983
|
+
result: A("aborted", v("DRAFT_ABORTED", "Rendering was aborted.", n))
|
|
984
|
+
};
|
|
985
|
+
if (e.length > a.maxSourceChars || _t.encode(e).byteLength > a.maxSourceBytes)
|
|
986
|
+
return {
|
|
987
|
+
result: A(
|
|
988
|
+
"limit",
|
|
989
|
+
v("DRAFT_LIMIT", "The source exceeds the configured size limit.", n)
|
|
990
|
+
)
|
|
991
|
+
};
|
|
992
|
+
if (!K(e) || [t.title, t.description, t.styleNonce].some(
|
|
993
|
+
(p) => p !== void 0 && !K(p)
|
|
994
|
+
))
|
|
995
|
+
return {
|
|
996
|
+
result: A(
|
|
997
|
+
"input",
|
|
998
|
+
v(
|
|
999
|
+
"DRAFT_TEXT_INVALID",
|
|
1000
|
+
"The source contains text that XML cannot represent.",
|
|
1001
|
+
n
|
|
1002
|
+
)
|
|
1003
|
+
)
|
|
1004
|
+
};
|
|
1005
|
+
const o = It(e, a, n);
|
|
1006
|
+
if (o) return { result: A(de(o), o) };
|
|
1007
|
+
let r;
|
|
1008
|
+
try {
|
|
1009
|
+
r = await lt(e);
|
|
1010
|
+
} catch (p) {
|
|
1011
|
+
const _ = Ne(p, n);
|
|
1012
|
+
return {
|
|
1013
|
+
result: A(
|
|
1014
|
+
p instanceof ie && /Limit:/.test(p.message) ? "limit" : de(_),
|
|
1015
|
+
_
|
|
1016
|
+
)
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
if (t.signal?.aborted)
|
|
1020
|
+
return {
|
|
1021
|
+
result: A("aborted", v("DRAFT_ABORTED", "Rendering was aborted.", n))
|
|
1022
|
+
};
|
|
1023
|
+
const s = Rt(r, a, n);
|
|
1024
|
+
if (s) return { result: A("limit", s), scene: r };
|
|
1025
|
+
if (r.diagnostics.some((p) => p.level === "error")) {
|
|
1026
|
+
const p = r.diagnostics.find((_) => _.level === "error");
|
|
1027
|
+
return {
|
|
1028
|
+
result: A(
|
|
1029
|
+
"input",
|
|
1030
|
+
v("DRAFT_COMPILE", p.message, n, p.line, void 0, p.code, p.ids)
|
|
1031
|
+
),
|
|
1032
|
+
scene: r
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
if (he(r))
|
|
1036
|
+
return {
|
|
1037
|
+
result: A(
|
|
1038
|
+
"input",
|
|
1039
|
+
v(
|
|
1040
|
+
"DRAFT_TEXT_INVALID",
|
|
1041
|
+
"A decoded diagram label contains text that XML cannot represent.",
|
|
1042
|
+
n
|
|
1043
|
+
)
|
|
1044
|
+
),
|
|
1045
|
+
scene: r
|
|
1046
|
+
};
|
|
1047
|
+
if (t.state != null && !(r.model.appearance.states ?? []).some((p) => p.id === t.state))
|
|
1048
|
+
return {
|
|
1049
|
+
result: A(
|
|
1050
|
+
"input",
|
|
1051
|
+
v("DRAFT_STATE_UNKNOWN", `Unknown state ${t.state}.`, n)
|
|
1052
|
+
),
|
|
1053
|
+
scene: r
|
|
1054
|
+
};
|
|
1055
|
+
if (t.signal?.aborted)
|
|
1056
|
+
return {
|
|
1057
|
+
result: A("aborted", v("DRAFT_ABORTED", "Rendering was aborted.", n))
|
|
1058
|
+
};
|
|
1059
|
+
let l = mn(r);
|
|
1060
|
+
t.state && (l = ft(l, t.state));
|
|
1061
|
+
const i = t.colorScheme ?? "light", c = i === "light" ? l.appearance : gn(l.appearance), h = i === "auto" && c !== l.appearance;
|
|
1062
|
+
i === "dark" && (l = { ...l, appearance: c });
|
|
1063
|
+
const d = ra(l, t), g = t.target === "inline" ? t.idPrefix : "draft", u = (p) => p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), f = t.includeSource ? `<metadata id="${g}-source" data-draftably-source="1" data-draftably-version="${He}">${u(e)}</metadata>` : void 0;
|
|
1064
|
+
let m = "";
|
|
1065
|
+
try {
|
|
1066
|
+
t.fonts !== "host" && (m = (await import("./font-data-DME3E71S.js")).fontFaceCss(Ee(l.appearance)));
|
|
1067
|
+
} catch {
|
|
1068
|
+
return {
|
|
1069
|
+
result: A(
|
|
1070
|
+
"environment",
|
|
1071
|
+
v("DRAFT_ENVIRONMENT", "Bundled fonts could not be loaded.", n)
|
|
1072
|
+
)
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
if (t.signal?.aborted)
|
|
1076
|
+
return {
|
|
1077
|
+
result: A("aborted", v("DRAFT_ABORTED", "Rendering was aborted.", n))
|
|
1078
|
+
};
|
|
1079
|
+
let $, T;
|
|
1080
|
+
try {
|
|
1081
|
+
const p = h ? "/*draft-fonts*/" : m, _ = (L, E) => ta(L, {
|
|
1082
|
+
routes: E,
|
|
1083
|
+
onDrawn: (R) => T = R,
|
|
1084
|
+
idPrefix: g,
|
|
1085
|
+
fontCss: p,
|
|
1086
|
+
title: t.title,
|
|
1087
|
+
description: t.description,
|
|
1088
|
+
styleNonce: t.styleNonce,
|
|
1089
|
+
linkTarget: t.links?.mode === "safe" ? t.links.target ?? "_self" : "_self",
|
|
1090
|
+
textHref: aa(t),
|
|
1091
|
+
metadata: f,
|
|
1092
|
+
maxOutputBytes: a.maxOutputBytes
|
|
1093
|
+
});
|
|
1094
|
+
if ($ = _(l), h) {
|
|
1095
|
+
const L = T?.routes;
|
|
1096
|
+
$ = sa($, _({ ...l, appearance: c }, L)) ?? $;
|
|
1097
|
+
const E = $.indexOf(p);
|
|
1098
|
+
if ($ = $.slice(0, E) + m + $.slice(E + p.length), new TextEncoder().encode($).length > a.maxOutputBytes)
|
|
1099
|
+
throw new ve(`The SVG is larger than ${a.maxOutputBytes} bytes.`);
|
|
1100
|
+
}
|
|
1101
|
+
} catch (p) {
|
|
1102
|
+
return {
|
|
1103
|
+
result: p instanceof ve ? A("limit", v("DRAFT_LIMIT", p.message, n)) : A(
|
|
1104
|
+
"internal",
|
|
1105
|
+
v("DRAFT_INTERNAL", "The diagram could not be drawn.", n)
|
|
1106
|
+
),
|
|
1107
|
+
scene: r
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
if (!K($))
|
|
1111
|
+
return {
|
|
1112
|
+
result: A(
|
|
1113
|
+
"input",
|
|
1114
|
+
v(
|
|
1115
|
+
"DRAFT_TEXT_INVALID",
|
|
1116
|
+
"The generated SVG contains text that XML cannot represent.",
|
|
1117
|
+
n
|
|
1118
|
+
)
|
|
1119
|
+
),
|
|
1120
|
+
scene: r
|
|
1121
|
+
};
|
|
1122
|
+
const M = /<svg[^>]*viewBox="([\d.-]+) ([\d.-]+) ([\d.]+) ([\d.]+)"[^>]*width="([\d.]+)"[^>]*height="([\d.]+)"/.exec(
|
|
1123
|
+
$
|
|
1124
|
+
);
|
|
1125
|
+
if (!M)
|
|
1126
|
+
return {
|
|
1127
|
+
result: A(
|
|
1128
|
+
"internal",
|
|
1129
|
+
v("DRAFT_INTERNAL", "The SVG dimensions could not be read.", n)
|
|
1130
|
+
),
|
|
1131
|
+
scene: r
|
|
1132
|
+
};
|
|
1133
|
+
const w = [
|
|
1134
|
+
...r.objects.map((p) => ({ id: p.id, kind: p.type, label: p.label, line: p.line })),
|
|
1135
|
+
...r.edges.map((p) => ({
|
|
1136
|
+
id: p.id,
|
|
1137
|
+
kind: "edge",
|
|
1138
|
+
label: p.label ?? "",
|
|
1139
|
+
line: p.line,
|
|
1140
|
+
from: p.source,
|
|
1141
|
+
to: p.target
|
|
1142
|
+
}))
|
|
1143
|
+
], x = [Number(M[1]), Number(M[2]), Number(M[3]), Number(M[4])], k = T ? {
|
|
1144
|
+
revision: 0,
|
|
1145
|
+
frame: { x: x[0], y: x[1], width: x[2], height: x[3] },
|
|
1146
|
+
...yn(l, T.rects, T.routes)
|
|
1147
|
+
} : null, b = {
|
|
1148
|
+
svg: $,
|
|
1149
|
+
title: t.title ?? r.title,
|
|
1150
|
+
...t.description !== void 0 ? { description: t.description } : {},
|
|
1151
|
+
width: Number(M[5]),
|
|
1152
|
+
height: Number(M[6]),
|
|
1153
|
+
viewBox: x,
|
|
1154
|
+
items: w,
|
|
1155
|
+
geometry: k,
|
|
1156
|
+
states: (r.model.appearance.states ?? []).map((p) => ({ id: p.id, label: p.label })),
|
|
1157
|
+
activeState: t.state ?? null,
|
|
1158
|
+
provenance: {
|
|
1159
|
+
runtimeVersion: He,
|
|
1160
|
+
fontMetricsVersion: xn,
|
|
1161
|
+
dslVersion: 1,
|
|
1162
|
+
renderContextVersion: "1"
|
|
1163
|
+
}
|
|
1164
|
+
}, y = r.diagnostics.map((p) => ({
|
|
1165
|
+
code: p.code === "fit" ? "DRAFT_LAYOUT_NOTE" : "DRAFT_COMPILE",
|
|
1166
|
+
severity: p.level,
|
|
1167
|
+
message: p.message,
|
|
1168
|
+
...p.line ? { location: { ...n ? { sourceId: n } : {}, line: p.line } } : {},
|
|
1169
|
+
itemIds: [...p.ids],
|
|
1170
|
+
nativeCode: p.code
|
|
1171
|
+
}));
|
|
1172
|
+
return t.signal?.aborted ? {
|
|
1173
|
+
result: A("aborted", v("DRAFT_ABORTED", "Rendering was aborted.", n)),
|
|
1174
|
+
scene: r
|
|
1175
|
+
} : { result: { ok: !0, value: b, diagnostics: [...y, ...d] }, scene: r };
|
|
1176
|
+
}
|
|
1177
|
+
async function da(e, t) {
|
|
1178
|
+
return (await oa(e, t)).result;
|
|
1179
|
+
}
|
|
1180
|
+
async function fa(e, t = {}) {
|
|
1181
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
1182
|
+
throw new TypeError("Validation options must be an object.");
|
|
1183
|
+
if (t.sourceId !== void 0 && typeof t.sourceId != "string")
|
|
1184
|
+
throw new TypeError("sourceId must be a string.");
|
|
1185
|
+
if (typeof e != "string") throw new TypeError("source must be a string.");
|
|
1186
|
+
const a = Lt(t.limits, !0), n = t.sourceId;
|
|
1187
|
+
if (t.signal?.aborted)
|
|
1188
|
+
return A("aborted", v("DRAFT_ABORTED", "Validation was aborted.", n));
|
|
1189
|
+
if (e.length > a.maxSourceChars || _t.encode(e).byteLength > a.maxSourceBytes)
|
|
1190
|
+
return A(
|
|
1191
|
+
"limit",
|
|
1192
|
+
v("DRAFT_LIMIT", "The source exceeds the configured size limit.", n)
|
|
1193
|
+
);
|
|
1194
|
+
if (!K(e))
|
|
1195
|
+
return A(
|
|
1196
|
+
"input",
|
|
1197
|
+
v(
|
|
1198
|
+
"DRAFT_TEXT_INVALID",
|
|
1199
|
+
"The source contains text that XML cannot represent.",
|
|
1200
|
+
n
|
|
1201
|
+
)
|
|
1202
|
+
);
|
|
1203
|
+
const o = It(e, a, n);
|
|
1204
|
+
if (o) return A(de(o), o);
|
|
1205
|
+
try {
|
|
1206
|
+
const r = await lt(e);
|
|
1207
|
+
if (t.signal?.aborted)
|
|
1208
|
+
return A("aborted", v("DRAFT_ABORTED", "Validation was aborted.", n));
|
|
1209
|
+
const s = Rt(r, a, n);
|
|
1210
|
+
if (s) return A("limit", s);
|
|
1211
|
+
if (he(r))
|
|
1212
|
+
return A(
|
|
1213
|
+
"input",
|
|
1214
|
+
v(
|
|
1215
|
+
"DRAFT_TEXT_INVALID",
|
|
1216
|
+
"A decoded diagram label contains text that XML cannot represent.",
|
|
1217
|
+
n
|
|
1218
|
+
)
|
|
1219
|
+
);
|
|
1220
|
+
const l = r.diagnostics.filter((i) => i.level === "error");
|
|
1221
|
+
return l.length ? {
|
|
1222
|
+
ok: !1,
|
|
1223
|
+
reason: "input",
|
|
1224
|
+
diagnostics: l.map(
|
|
1225
|
+
(i) => v("DRAFT_COMPILE", i.message, n, i.line, void 0, i.code, i.ids)
|
|
1226
|
+
)
|
|
1227
|
+
} : {
|
|
1228
|
+
ok: !0,
|
|
1229
|
+
diagnostics: r.diagnostics.map((i) => ({
|
|
1230
|
+
code: "DRAFT_COMPILE",
|
|
1231
|
+
severity: i.level,
|
|
1232
|
+
message: i.message,
|
|
1233
|
+
...i.line ? { location: { ...n ? { sourceId: n } : {}, line: i.line } } : {},
|
|
1234
|
+
itemIds: [...i.ids],
|
|
1235
|
+
nativeCode: i.code
|
|
1236
|
+
}))
|
|
1237
|
+
};
|
|
1238
|
+
} catch (r) {
|
|
1239
|
+
const s = Ne(r, n);
|
|
1240
|
+
return A(
|
|
1241
|
+
r instanceof ie && /Limit:/.test(r.message) ? "limit" : de(s),
|
|
1242
|
+
s
|
|
1243
|
+
);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
export {
|
|
1247
|
+
da as renderSvg,
|
|
1248
|
+
oa as renderWithScene,
|
|
1249
|
+
fa as validate
|
|
1250
|
+
};
|