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