@popcorn245/cornfield-components 0.48.0 → 0.49.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.
@@ -0,0 +1,2664 @@
1
+ import { n as e, r as t, t as n } from "./runtime-DFu6W5g-.js";
2
+ import { $ as r, B as i, C as a, D as o, E as s, F as c, G as l, H as u, I as d, J as f, K as p, L as m, M as h, N as g, O as _, P as v, Q as y, R as b, S as x, T as S, U as C, V as w, W as T, X as E, Z as D, _ as O, a as k, b as A, c as j, ct as M, d as N, dt as P, et as F, f as I, ft as ee, g as te, h as ne, it as L, j as R, k as z, l as B, m as V, nt as H, o as U, p as W, q as G, rt as re, s as ie, t as ae, tt as oe, v as se, w as ce, x as le, y as ue, z as de } from "./_corn-default-tokens-CoghUocx.js";
3
+ var K = 96, fe = "letters:", pe = (e) => `${fe}${e}`, me = (e) => typeof e == "string" && e.startsWith(fe), he = (e) => e.slice(8), ge = (e, t) => !!e.letters && !e.icon && e.r * 2 * t >= 14, _e = /* @__PURE__ */ new Map();
4
+ function ve(e, t = null) {
5
+ if (typeof e != "string" || !e) return null;
6
+ let n = `${typeof t == "string" ? t : ""}|${e}`;
7
+ if (_e.has(n)) return _e.get(n);
8
+ if (_e.size >= 128) return null;
9
+ let r = null;
10
+ try {
11
+ let n = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(K, K) : typeof document < "u" ? Object.assign(document.createElement("canvas"), {
12
+ width: K,
13
+ height: K
14
+ }) : null, i = n && n.getContext && n.getContext("2d");
15
+ if (i && i.fillText) {
16
+ i.font = `700 ${e.length > 1 ? 56 : 72}px ${R}`, i.textAlign = "center", i.textBaseline = "middle", i.lineJoin = "round", i.lineWidth = 10;
17
+ let a = typeof t == "string" ? t : f;
18
+ i.strokeStyle = F(a) === "#ffffff" ? "rgba(11, 18, 32, 0.92)" : "rgba(255, 255, 255, 0.92)", i.strokeText(e, K / 2, 51), i.fillStyle = a, i.fillText(e, K / 2, 51), r = n;
19
+ }
20
+ } catch {
21
+ r = null;
22
+ }
23
+ return _e.set(n, r), r;
24
+ }
25
+ // ../explorer/renderer-canvas2d.js
26
+ var ye = Math.PI * 2, be = 1.5, q = (e, t, n, r) => {
27
+ e.beginPath(), e.arc(t, n, r, 0, ye);
28
+ };
29
+ function xe(e, t, n, r, i) {
30
+ if (t === "rounded-square" || t === "square") {
31
+ let a = i * (t === "square" ? v.squareHalf : v.roundedHalf), o = i * (t === "square" ? v.squareCorner : v.roundedCorner);
32
+ e.beginPath(), e.roundRect ? e.roundRect(n - a, r - a, a * 2, a * 2, o) : e.rect(n - a, r - a, a * 2, a * 2);
33
+ } else if (t === "hexagon") {
34
+ let t = i * v.hexInradius / Math.cos(Math.PI / 6);
35
+ e.beginPath();
36
+ for (let i = 0; i < 6; i++) {
37
+ let a = Math.PI / 6 + i * Math.PI / 3, o = n + t * Math.cos(a), s = r + t * Math.sin(a);
38
+ i ? e.lineTo(o, s) : e.moveTo(o, s);
39
+ }
40
+ e.closePath();
41
+ } else if (t === "diamond") {
42
+ let t = i * v.diamondHalf;
43
+ e.beginPath(), e.moveTo(n, r - t), e.lineTo(n + t, r), e.lineTo(n, r + t), e.lineTo(n - t, r), e.closePath();
44
+ } else q(e, n, r, i);
45
+ }
46
+ function Se(e, t, n, r, i) {
47
+ let a = -n.x / n.zoom - t.margin, o = (r - n.x) / n.zoom + t.margin, s = -n.y / n.zoom - t.margin, c = (i - n.y) / n.zoom + t.margin;
48
+ e.beginPath(), e.strokeStyle = t.color, e.lineWidth = t.width;
49
+ for (let n = Math.floor(a / t.size) * t.size; n < o; n += t.size) e.moveTo(n, s), e.lineTo(n, c);
50
+ for (let n = Math.floor(s / t.size) * t.size; n < c; n += t.size) e.moveTo(a, n), e.lineTo(o, n);
51
+ e.stroke();
52
+ }
53
+ function Ce(e, t) {
54
+ e.save(), t.forEach((t) => {
55
+ e.lineWidth = t.width, e.setLineDash(t.dash), e.strokeStyle = t.color, q(e, t.x, t.y, t.r), e.stroke();
56
+ }), e.restore();
57
+ }
58
+ function we(e, t) {
59
+ e.save(), t.forEach((t) => {
60
+ e.fillStyle = t.fill, e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.beginPath(), e.roundRect(t.x, t.y, t.w, t.h, t.radius), e.fill(), e.stroke();
61
+ }), e.restore();
62
+ }
63
+ function Te(e, t, n, r, i = !0) {
64
+ if (e.save(), e.globalAlpha = t.alpha, e.beginPath(), e.moveTo(t.x1, t.y1), t.curve ? e.quadraticCurveTo(t.curve.cx, t.curve.cy, t.x2, t.y2) : e.lineTo(t.x2, t.y2), e.strokeStyle = t.color, e.lineWidth = t.mark && t.mark !== "none" ? Math.max(t.width, g.edge / r) : t.width, e.setLineDash(t.dash || []), t.glow && t.glow * r >= be) {
65
+ let n = e.lineWidth;
66
+ e.save(), e.globalAlpha = t.alpha * .3, e.strokeStyle = t.glowColor || t.color, e.lineWidth = n + t.glow * .6, e.stroke(), e.restore();
67
+ }
68
+ if (e.stroke(), e.setLineDash([]), t.mark === "removed") {
69
+ let n = m(t, .5), i = Math.hypot(t.x2 - t.x1, t.y2 - t.y1), [a, o] = i > 0 ? [(t.x2 - t.x1) / i, (t.y2 - t.y1) / i] : [1, 0];
70
+ e.beginPath(), e.moveTo(n.x - o * _.halfLength, n.y + a * _.halfLength), e.lineTo(n.x + o * _.halfLength, n.y - a * _.halfLength), e.lineWidth = Math.max(_.width, 1.5 / r), e.stroke();
71
+ }
72
+ if (t.ticks && De(e, t, r), t.arrow) {
73
+ let { cx: n, cy: i } = t.curve || {
74
+ cx: t.x1,
75
+ cy: t.y1
76
+ };
77
+ Ee(e, t, Math.atan2(t.y2 - i, t.x2 - n), r);
78
+ }
79
+ i && t.packet && Oe(e, t, n, r), e.restore();
80
+ }
81
+ function Ee(e, t, n, r) {
82
+ let i = t.end || "triangle", { x2: a, y2: o, color: c } = t, l = Math.cos(n), u = Math.sin(n), d = (e, t) => [a - l * e - u * t, o - u * e + l * t], f = Math.max(z.strokeWidth, 1.2 / r);
83
+ if (e.beginPath(), i === "triangle") e.moveTo(a, o), e.lineTo(a - Math.cos(n - s.spread) * s.length, o - Math.sin(n - s.spread) * s.length), e.lineTo(a - Math.cos(n + s.spread) * s.length, o - Math.sin(n + s.spread) * s.length), e.closePath(), e.fillStyle = c, e.fill();
84
+ else {
85
+ if (e.strokeStyle = c, e.lineWidth = f, e.lineJoin = "miter", i === "chevron") {
86
+ let t = s.length * Math.cos(s.spread), n = s.length * Math.sin(s.spread);
87
+ e.moveTo(...d(t, n)), e.lineTo(a, o), e.lineTo(...d(t, -n));
88
+ } else if (i === "bar") e.moveTo(...d(f / 2, z.barHalf)), e.lineTo(...d(f / 2, -z.barHalf));
89
+ else {
90
+ let t = z.diamondHalf;
91
+ e.moveTo(a, o), e.lineTo(...d(t, z.diamondAcross)), e.lineTo(...d(2 * t, 0)), e.lineTo(...d(t, -z.diamondAcross)), e.closePath();
92
+ }
93
+ e.stroke();
94
+ }
95
+ }
96
+ function De(e, t, n) {
97
+ let r = Math.hypot(t.x2 - t.x1, t.y2 - t.y1), [i, a] = r > 0 ? [(t.x2 - t.x1) / r, (t.y2 - t.y1) / r] : [1, 0], o = m(t, .5);
98
+ e.beginPath();
99
+ for (let n = 0; n < t.ticks; n++) {
100
+ let r = (n - (t.ticks - 1) / 2) * z.tickGap, s = o.x + i * r, c = o.y + a * r;
101
+ e.moveTo(s - a * z.tickHalf, c + i * z.tickHalf), e.lineTo(s + a * z.tickHalf, c - i * z.tickHalf);
102
+ }
103
+ e.strokeStyle = t.color, e.lineWidth = Math.max(z.tickWidth, 1.5 / n), e.setLineDash([]), e.stroke();
104
+ }
105
+ function Oe(e, t, n, r) {
106
+ let i = w(t, n), { packet: a } = t;
107
+ a.glow && a.glow * r >= be && (e.beginPath(), e.arc(i.x, i.y, a.radius + a.glow * .5, 0, ye), e.globalAlpha = t.alpha * .3, e.fillStyle = a.glowColor || a.color, e.fill(), e.globalAlpha = t.alpha), e.beginPath(), e.arc(i.x, i.y, a.radius, 0, ye), e.fillStyle = a.color, e.fill();
108
+ }
109
+ function ke(e, t, n, r) {
110
+ e.save(), e.globalAlpha = t.alpha, Oe(e, t, n, r), e.restore();
111
+ }
112
+ var Ae = 16, je = /* @__PURE__ */ new WeakMap();
113
+ function Me(e) {
114
+ let t = je.get(e);
115
+ return t || (t = new Float64Array(e.edges.length * 4), e.edges.forEach((e, n) => {
116
+ let r = e.curve ? e.curve.cx : e.x1, i = e.curve ? e.curve.cy : e.y1, a = (e.glow || 0) * .6 + (e.packet ? e.packet.radius + (e.packet.glow || 0) * .5 : 0), o = (e.width || 0) / 2 + a + Ae;
117
+ t[n * 4] = Math.min(e.x1, e.x2, r) - o, t[n * 4 + 1] = Math.min(e.y1, e.y2, i) - o, t[n * 4 + 2] = Math.max(e.x1, e.x2, r) + o, t[n * 4 + 3] = Math.max(e.y1, e.y2, i) + o;
118
+ }), je.set(e, t)), t;
119
+ }
120
+ function Ne(e, t, n, r) {
121
+ let i = Me(e), a = t.zoom || 1, o = 4 / a, s = -t.x / a - o, c = -t.y / a - o, l = (n - t.x) / a + o, u = (r - t.y) / a + o, d = [];
122
+ for (let t = 0; t < e.edges.length; t++) i[t * 4 + 2] < s || i[t * 4] > l || i[t * 4 + 3] < c || i[t * 4 + 1] > u || d.push(e.edges[t]);
123
+ return d;
124
+ }
125
+ function Pe(e, t, n, r, i) {
126
+ e.save(), e.globalAlpha = t.alpha;
127
+ let a = r.halo[t.halo];
128
+ a && (a.fill && (q(e, t.x, t.y, t.r + a.fillR), e.fillStyle = a.fill, e.fill()), q(e, t.x, t.y, t.r + a.ringR), e.strokeStyle = a.ring, e.lineWidth = a.ringWidth, e.stroke());
129
+ let s = r.mark[t.mark];
130
+ if (s) {
131
+ let r = t.r + Math.max(s.ringR, g.gap / n);
132
+ q(e, t.x, t.y, r), e.strokeStyle = s.color, e.lineWidth = Math.max(s.ringWidth, g.ring / n), e.setLineDash(s.ringDash || []), e.stroke(), e.setLineDash([]), t.mark === "removed" && (e.beginPath(), e.moveTo(t.x - r, t.y), e.lineTo(t.x + r, t.y), e.stroke());
133
+ }
134
+ xe(e, t.shape, t.x, t.y, t.r), t.glow && t.glow * n >= be && (e.save(), e.globalAlpha = t.alpha * .28, q(e, t.x, t.y, t.r + t.glow * .7), e.fillStyle = t.color, e.fill(), e.restore(), xe(e, t.shape, t.x, t.y, t.r)), e.fillStyle = t.color, e.fill();
135
+ let c = t.icon && i.icons ? i.icons.get(t.icon) : null, l = !c && ge(t, n), u = !c && !l && H(t, n) ? E(t.glyph, D(t, i)) : null;
136
+ if (u || (q(e, t.x, t.y, t.r * o), e.fillStyle = r.core, e.fill()), t.stroke && (xe(e, t.shape, t.x, t.y, Math.max(0, t.r - t.stroke.width / 2)), e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.stroke()), c) {
137
+ let n = t.r * le;
138
+ e.imageSmoothingEnabled = !i.pixelated, e.drawImage(c, t.x - n / 2, t.y - n / 2, n, n);
139
+ } else if (l) {
140
+ let n = ve(t.letters, i.values && i.values["--corn-map-glyph"]);
141
+ if (n) {
142
+ let r = t.r * 1;
143
+ e.imageSmoothingEnabled = !0, e.drawImage(n, t.x - r / 2, t.y - r / 2, r, r);
144
+ }
145
+ } else if (u) {
146
+ let n = t.r * G;
147
+ e.imageSmoothingEnabled = !0, e.drawImage(u, t.x - n / 2, t.y - n / 2, n, n);
148
+ }
149
+ e.restore();
150
+ }
151
+ function Fe(e, t = {}) {
152
+ let n = t.mapStyle || (() => x), r = e.getContext("2d"), o = 0, s = 0, c = 1, l = null, u = null, d = null, f = () => {
153
+ if (l) return l;
154
+ try {
155
+ l = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(e.width || 1, e.height || 1) : e.ownerDocument ? e.ownerDocument.createElement("canvas") : null, u = l && l.getContext ? l.getContext("2d") : null;
156
+ } catch {
157
+ u = null;
158
+ }
159
+ return u || (l = null), l;
160
+ }, p = t.layerMinEdges ?? 600, m = /* @__PURE__ */ new WeakMap(), h = (e) => (m.has(e) || m.set(e, e.edges.some((e) => e.packet)), m.get(e));
161
+ function g(e, t, n) {
162
+ e.save(), e.translate(n.x, n.y), e.scale(n.zoom, n.zoom);
163
+ let { decor: r } = t;
164
+ r.grid && Se(e, r.grid, n, o, s), r.lanes.length && we(e, r.lanes), r.rings.length && Ce(e, r.rings), Ne(t, n, o, s).forEach((t) => Te(e, t, 0, n.zoom, !1)), e.restore();
165
+ }
166
+ return {
167
+ kind: "canvas2d",
168
+ resize(t, n, i) {
169
+ o = t, s = n, c = i, e.width = t * i, e.height = n * i, r.setTransform(i, 0, 0, i, 0, 0), d = null, l && (l.width = e.width, l.height = e.height, u.setTransform(i, 0, 0, i, 0, 0));
170
+ },
171
+ draw(t, m, _) {
172
+ let v = n(), y = S(t, v);
173
+ r.clearRect(0, 0, o, s);
174
+ let b = a(i(y.theme), v), x = Ne(y, m, o, s);
175
+ if (h(y) && x.length > p && f()) {
176
+ d && d.scene === y && d.x === m.x && d.y === m.y && d.zoom === m.zoom && d.w === e.width && d.h === e.height || ((l.width !== e.width || l.height !== e.height) && (l.width = e.width, l.height = e.height), u.setTransform(c, 0, 0, c, 0, 0), u.clearRect(0, 0, o, s), g(u, y, m), d = {
177
+ scene: y,
178
+ x: m.x,
179
+ y: m.y,
180
+ zoom: m.zoom,
181
+ w: e.width,
182
+ h: e.height
183
+ }), r.save(), r.setTransform(1, 0, 0, 1, 0, 0), r.drawImage(l, 0, 0), r.restore(), r.save(), r.translate(m.x, m.y), r.scale(m.zoom, m.zoom), x.forEach((e) => {
184
+ e.packet && ke(r, e, _, m.zoom);
185
+ }), y.nodes.forEach((e) => Pe(r, e, m.zoom, b, v)), r.restore();
186
+ return;
187
+ }
188
+ r.save(), r.translate(m.x, m.y), r.scale(m.zoom, m.zoom);
189
+ let { decor: C } = y;
190
+ C.grid && Se(r, C.grid, m, o, s), C.lanes.length && we(r, C.lanes), C.rings.length && Ce(r, C.rings), x.forEach((e) => Te(r, e, _, m.zoom)), y.nodes.forEach((e) => Pe(r, e, m.zoom, b, v)), r.restore();
191
+ },
192
+ destroy() {
193
+ l = null, u = null, d = null;
194
+ }
195
+ };
196
+ }
197
+ var Ie = (e) => typeof e.hitR == "number" && e.hitR > e.r ? e.hitR : e.r;
198
+ function Le(e, { cellSize: t = 64 } = {}) {
199
+ let n = /* @__PURE__ */ new Map(), r = 0, i = (e, t) => e * 4194304 + t;
200
+ for (let a = 0; a < e.length; a++) {
201
+ let o = e[a];
202
+ Ie(o) > r && (r = Ie(o));
203
+ let s = i(Math.floor(o.x / t), Math.floor(o.y / t)), c = n.get(s);
204
+ c ? c.push(a) : n.set(s, [a]);
205
+ }
206
+ let a = (e) => typeof e == "number" ? e : e && e.pad || 0, o = (e) => typeof e == "number" ? 0 : e && e.min || 0;
207
+ return {
208
+ size: e.length,
209
+ cellSize: t,
210
+ nodeAt(s, c, l = 0) {
211
+ if (e.length === 0) return null;
212
+ let u = a(l), d = o(l), f = Math.max(r + u, d), p = Math.floor((s - f) / t), m = Math.floor((s + f) / t), h = Math.floor((c - f) / t), g = Math.floor((c + f) / t), _ = -1;
213
+ for (let t = p; t <= m; t++) for (let r = h; r <= g; r++) {
214
+ let a = n.get(i(t, r));
215
+ if (a) for (let t = 0; t < a.length; t++) {
216
+ let n = a[t];
217
+ if (n <= _) continue;
218
+ let r = e[n], i = Math.max(Ie(r) + u, d);
219
+ Math.hypot(r.x - s, r.y - c) <= i && (_ = n);
220
+ }
221
+ }
222
+ return _ < 0 ? null : e[_];
223
+ },
224
+ nodesIn(a) {
225
+ if (e.length === 0) return [];
226
+ let { minX: o, minY: s, maxX: c, maxY: l } = a, u = Math.floor((o - r) / t), d = Math.floor((c + r) / t), f = Math.floor((s - r) / t), p = Math.floor((l + r) / t), m = [];
227
+ for (let t = u; t <= d; t++) for (let r = f; r <= p; r++) {
228
+ let a = n.get(i(t, r));
229
+ if (a) for (let t = 0; t < a.length; t++) {
230
+ let n = a[t], r = e[n], i = r.x - Math.min(Math.max(r.x, o), c), u = r.y - Math.min(Math.max(r.y, s), l);
231
+ i * i + u * u <= Ie(r) ** 2 && m.push(n);
232
+ }
233
+ }
234
+ return m.sort((e, t) => e - t).map((t) => e[t]);
235
+ }
236
+ };
237
+ }
238
+ function Re(e, t, n, r, i = !1) {
239
+ let a = t.zoom;
240
+ return e.nodeAt((n - t.x) / a, (r - t.y) / a, {
241
+ pad: (i ? 16 : 6) / a,
242
+ min: (i ? 32 : 12) / a
243
+ });
244
+ }
245
+ function ze(e) {
246
+ let t = null, n = null, r = {
247
+ builds: 0,
248
+ get(i) {
249
+ return n && t === i || (n = Le(i.nodes, e), t = i, r.builds++), n;
250
+ }
251
+ };
252
+ return r;
253
+ }
254
+ // ../explorer/frame.js
255
+ var Be = 3e4;
256
+ function Ve({ dirty: e, packetsVisible: t, hidden: n, reduceMotion: r, idleMs: i, clientsWant: a = !1 }) {
257
+ if (n) return {
258
+ draw: !1,
259
+ again: !1
260
+ };
261
+ let o = t && !r && i < 3e4 || a;
262
+ return {
263
+ draw: e || o,
264
+ again: o
265
+ };
266
+ }
267
+ function He(e, t, n, r) {
268
+ let i = We(e);
269
+ if (i.length === 0) return !1;
270
+ if (!(n > 0) || !(r > 0)) return !0;
271
+ let a = -t.x / t.zoom, o = -t.y / t.zoom, s = (n - t.x) / t.zoom, c = (r - t.y) / t.zoom;
272
+ for (let e of i) {
273
+ let t = e.curve ? e.curve.cx : e.x1, n = e.curve ? e.curve.cy : e.y1, r = e.packet.radius + e.packet.glow;
274
+ if (!(Math.max(e.x1, e.x2, t) + r < a || Math.min(e.x1, e.x2, t) - r > s) && !(Math.max(e.y1, e.y2, n) + r < o || Math.min(e.y1, e.y2, n) - r > c)) return !0;
275
+ }
276
+ return !1;
277
+ }
278
+ var Ue = /* @__PURE__ */ new WeakMap();
279
+ function We(e) {
280
+ let t = Ue.get(e);
281
+ return t || (t = e.edges.filter((e) => e.packet), Ue.set(e, t)), t;
282
+ }
283
+ function Ge(e) {
284
+ let { draw: t, packetsVisible: n, isHidden: r, reduceMotion: i, extraDirty: a, tickClients: o, clientsWant: s, now: c, raf: l, caf: u } = e, d = !0, f = null, p = -Infinity, m = c(), h = !1, g = /* @__PURE__ */ new Set(), _ = () => {
285
+ if (g.size === 0) return;
286
+ let e = [...g];
287
+ g.clear(), e.forEach((e) => e());
288
+ }, v = () => {
289
+ !h && f === null && (f = l(y));
290
+ };
291
+ function y(e) {
292
+ f = null, _();
293
+ let n = o && !r() ? o(e) : !1, i = d || (a ? a() : !1), { draw: s, again: c } = b(i, n);
294
+ s && (i || e - p >= 31) && (d = !1, p = e, x.draws++, t()), x.frames++, c && v();
295
+ }
296
+ let b = (e, t) => Ve({
297
+ dirty: e,
298
+ packetsVisible: n(),
299
+ hidden: r(),
300
+ reduceMotion: i(),
301
+ idleMs: c() - m,
302
+ clientsWant: t
303
+ }), x = {
304
+ frames: 0,
305
+ draws: 0,
306
+ markDirty() {
307
+ d = !0, v();
308
+ },
309
+ queue(e, { draw: t = !0 } = {}) {
310
+ g.add(e), t ? x.markDirty() : v();
311
+ },
312
+ wake() {
313
+ v();
314
+ },
315
+ noteInput() {
316
+ let e = c(), t = e - m >= Be;
317
+ m = e, t && v();
318
+ },
319
+ shown() {
320
+ m = c();
321
+ let e = d || (a ? a() : !1), { draw: t, again: n } = b(e, s ? s() : !1);
322
+ (t || n) && v();
323
+ },
324
+ drawNow() {
325
+ _(), d = !1, p = c(), x.draws++, t();
326
+ },
327
+ hold(e) {
328
+ h = !!e, h ? x.cancel() : x.markDirty();
329
+ },
330
+ get pending() {
331
+ return f !== null;
332
+ },
333
+ cancel() {
334
+ f !== null && u(f), f = null;
335
+ }
336
+ };
337
+ return x;
338
+ }
339
+ var Ke = 1, qe = .3, Je = .58, Ye = 3, Xe = 100, J = 64, Y = {
340
+ selected: 0,
341
+ current: 1,
342
+ match: 2,
343
+ lit: 3,
344
+ marked: 4,
345
+ hub: 5,
346
+ rest: 6,
347
+ greyed: 7
348
+ }, Ze = 1.5, Qe = (e) => Number.isFinite(e) && e >= 9 ? Math.max(11, e) : 11, $e = (e) => Qe(e.labelMin), et = (e) => h.includes(e.type) && !e.greyed, tt = (e, t) => e.selected ? Y.selected : e.current ? Y.current : e.match ? Y.match : t && e.connected ? Y.lit : e.mark && e.mark !== "none" || e.labelKeep && !et(e) ? Y.marked : e.greyed ? Y.greyed : et(e) ? Y.hub : Y.rest;
349
+ function nt(e, t, n = {}) {
350
+ let { measure: r = null } = n, i = $e(e), a = e.nodes.some((e) => e.selected || !e.connected), o = [];
351
+ e.nodes.forEach((e, t) => {
352
+ e.label && e.labelAlpha >= .15 && o.push({
353
+ node: e,
354
+ index: t,
355
+ tier: tt(e, a)
356
+ });
357
+ }), o.sort((e, t) => e.tier - t.tier || t.node.r - e.node.r || (t.node.degree || 0) - (e.node.degree || 0) || e.index - t.index);
358
+ let s = /* @__PURE__ */ new Map(), c = (e, t) => (e + 8192) * 16384 + (t + 8192), l = [], u = Math.max(Ye, Ye * t);
359
+ for (let { node: e, index: n, tier: a } of o) {
360
+ let o = et(e), d = !e.greyed && (!!e.labelBold || o), f = Math.max(o ? i + 2 : i, e.labelSize * t), p = r ? r(e.label, Xe, d) * f / Xe : e.label.length * f * Je, m = e.x * t, h = e.y * t + e.r * t + u + f, g = m - p / 2, _ = m + p / 2, v = h - f * Ke, y = h + f * qe, b = a === Y.greyed ? 2 + f * Ze : 2, x = Math.floor((g - b) / J), S = Math.floor((_ + b) / J), C = Math.floor((v - b) / J), w = Math.floor((y + b) / J), T = !1;
361
+ for (let e = x; e <= S && !T; e++) for (let t = C; t <= w && !T; t++) {
362
+ let n = s.get(c(e, t));
363
+ if (n) for (let e = 0; e < n.length; e++) {
364
+ let t = n[e];
365
+ if (g - b < t.r && _ + b > t.l && v - b < t.b && y + b > t.t) {
366
+ T = !0;
367
+ break;
368
+ }
369
+ }
370
+ }
371
+ if (T) continue;
372
+ let E = {
373
+ index: n,
374
+ id: e.id,
375
+ rank: l.length,
376
+ tier: a,
377
+ px: f,
378
+ bold: d,
379
+ screen: e.labelSize * t <= (o ? i + 2 : i),
380
+ size: f / t,
381
+ x: e.x,
382
+ y: e.y + e.r + (u + f) / t,
383
+ node: e,
384
+ l: g,
385
+ t: v,
386
+ r: _,
387
+ b: y
388
+ };
389
+ l.push(E);
390
+ let D = Math.floor(g / J), O = Math.floor(_ / J), k = Math.floor(v / J), A = Math.floor(y / J);
391
+ for (let e = D; e <= O; e++) for (let t = k; t <= A; t++) {
392
+ let n = c(e, t), r = s.get(n);
393
+ r ? r.push(E) : s.set(n, [E]);
394
+ }
395
+ }
396
+ return l;
397
+ }
398
+ function rt(e, t, n, r = {}) {
399
+ let { max: a = 400, margin: o = 32, measure: s = null, hover: c = null } = r, l = [], u = e.labelOutline || i(e.theme).labelOutline;
400
+ for (let t of e.decor.lanes) for (let n of [
401
+ t.title,
402
+ t.note,
403
+ t.arrow
404
+ ]) n && l.push({
405
+ kind: "lane",
406
+ text: n.text,
407
+ x: n.x,
408
+ y: n.y,
409
+ size: n.size,
410
+ bold: n.bold,
411
+ italic: !1,
412
+ color: n.color,
413
+ alpha: 1,
414
+ outline: null,
415
+ align: "center",
416
+ family: e.labelFont || "\"Segoe UI\", -apple-system, BlinkMacSystemFont, Roboto, sans-serif"
417
+ });
418
+ let { zoom: d } = t, f = r.placed || nt(e, d, { measure: s }), p = -o - t.x, m = n.width + o - t.x, h = -o - t.y, g = n.height + o - t.y, _ = f.filter((e) => e.r >= p && e.l <= m && e.b >= h && e.t <= g);
419
+ _.length > a && (_ = _.slice(0, Math.max(0, a))), _.sort((e, t) => e.index - t.index);
420
+ let v = e.labelFont || "\"Segoe UI\", -apple-system, BlinkMacSystemFont, Roboto, sans-serif";
421
+ for (let e of _) {
422
+ let t = Math.max(1, 1 / d);
423
+ l.push({
424
+ kind: "node",
425
+ id: e.id,
426
+ text: e.node.label,
427
+ x: e.x,
428
+ y: e.y,
429
+ size: e.size,
430
+ bold: e.bold,
431
+ italic: !1,
432
+ color: e.node.labelColor,
433
+ alpha: e.node.labelAlpha,
434
+ outline: u.node ? {
435
+ color: u.node.color,
436
+ width: u.node.width * t
437
+ } : null,
438
+ align: "center",
439
+ family: v,
440
+ strike: !!e.node.labelStrike,
441
+ px: e.px,
442
+ screen: e.screen
443
+ });
444
+ }
445
+ let y = $e(e), b = _.map((e) => ({
446
+ l: t.x + e.l,
447
+ r: t.x + e.r,
448
+ t: t.y + e.t,
449
+ b: t.y + e.b
450
+ }));
451
+ for (let r of e.nodes) {
452
+ if (r.alpha < .5) continue;
453
+ let e = t.x + r.x * d, i = t.y + r.y * d, a = r.r * d;
454
+ e + a < 0 || e - a > n.width || i + a < 0 || i - a > n.height || b.push({
455
+ l: e - a,
456
+ r: e + a,
457
+ t: i - a,
458
+ b: i + a
459
+ });
460
+ }
461
+ let x = 0;
462
+ for (let r of e.edges) {
463
+ let i = r.label;
464
+ if (!i || x >= 120) continue;
465
+ let a = t.x + i.x * d, o = t.y + i.y * d;
466
+ if (a < 0 || a > n.width || o < 0 || o > n.height) continue;
467
+ let c = (s ? s(i.text, y, !1) : i.text.length * y * .55) / 2 + 2, f = {
468
+ l: a - c,
469
+ r: a + c,
470
+ t: o - y * .6 - 2,
471
+ b: o + y * .6 + 2
472
+ };
473
+ b.some((e) => f.l < e.r && f.r > e.l && f.t < e.b && f.b > e.t) || (b.push(f), x++, l.push({
474
+ kind: "edge",
475
+ text: i.text,
476
+ x: i.x,
477
+ y: i.y + y * .35 / d,
478
+ size: y / d,
479
+ px: y,
480
+ screen: !0,
481
+ bold: !1,
482
+ italic: !!i.italic,
483
+ color: i.color,
484
+ alpha: r.alpha,
485
+ outline: u.edge,
486
+ align: "center",
487
+ family: e.labelFont || "\"Segoe UI\", -apple-system, sans-serif"
488
+ }));
489
+ }
490
+ if (c) {
491
+ let n = e.nodes.find((e) => e.id === c);
492
+ if (n && n.label && !f.some((e) => e.id === c && _.includes(e))) {
493
+ let r = $e(e), i = t.y + n.y * d - n.r * d > 40 ? n.y - n.r - 5 / d : n.y + n.r + (5 + r) / d;
494
+ l.push({
495
+ kind: "chip",
496
+ id: n.id,
497
+ text: n.label,
498
+ x: n.x,
499
+ y: i,
500
+ size: r / d,
501
+ px: r,
502
+ screen: !0,
503
+ bold: !1,
504
+ italic: !1,
505
+ color: (e.nodes.find((e) => e.connected) || n).labelColor,
506
+ alpha: 1,
507
+ outline: u.node,
508
+ align: "center",
509
+ family: v,
510
+ strike: !1
511
+ });
512
+ }
513
+ }
514
+ return l;
515
+ }
516
+ var it = (e) => `${e.italic ? "italic " : ""}${e.bold ? "bold " : ""}${e.screen ? e.px : e.size}px ${e.family}`, at = {
517
+ ox: 0,
518
+ oy: 0,
519
+ k: 1
520
+ };
521
+ function ot(e, t, n) {
522
+ e.font = it(t);
523
+ let r = e.measureText(t.text).width + 8, i = t.px * 1.3 + 4, a = n.ox + t.x * n.k, o = n.oy + t.y * n.k, s = a - r / 2, c = o - t.px * Ke - 2;
524
+ e.globalAlpha = 1, e.beginPath(), e.roundRect ? e.roundRect(s, c, r, i, 4) : e.rect(s, c, r, i), e.fillStyle = t.outline ? t.outline.color : "rgba(9, 13, 22, 0.95)", e.fill(), e.lineWidth = 1, e.strokeStyle = t.color, e.stroke(), e.textAlign = t.align, e.fillStyle = t.color, e.fillText(t.text, a, o);
525
+ }
526
+ function st() {
527
+ return {
528
+ font: "",
529
+ alpha: -1,
530
+ fill: "",
531
+ stroke: "",
532
+ width: -1,
533
+ align: ""
534
+ };
535
+ }
536
+ function ct(e, t, n, r = at) {
537
+ if (t.kind === "chip") {
538
+ ot(e, t, r);
539
+ return;
540
+ }
541
+ n.alpha !== t.alpha && (e.globalAlpha = t.alpha, n.alpha = t.alpha);
542
+ let i = it(t);
543
+ n.font !== i && (e.font = i, n.font = i), n.align !== t.align && (e.textAlign = t.align, n.align = t.align);
544
+ let a = r.ox + t.x * r.k, o = r.oy + t.y * r.k;
545
+ if (t.outline) {
546
+ e.lineJoin = "round";
547
+ let i = t.outline.width * r.k;
548
+ n.stroke !== t.outline.color && (e.strokeStyle = t.outline.color, n.stroke = t.outline.color), n.width !== i && (e.lineWidth = i, n.width = i), e.strokeText(t.text, a, o);
549
+ }
550
+ if (n.fill !== t.color && (e.fillStyle = t.color, n.fill = t.color), e.fillText(t.text, a, o), t.strike) {
551
+ let i = e.measureText(t.text).width / 2, s = t.screen ? t.px : t.size * r.k;
552
+ e.beginPath(), e.moveTo(a - i, o - s * .32), e.lineTo(a + i, o - s * .32), e.strokeStyle = t.color, e.lineWidth = 1.4, e.stroke(), n.stroke = t.color, n.width = 1.4;
553
+ }
554
+ }
555
+ function lt(e, t, n, r) {
556
+ let i = null;
557
+ for (let a of e) n >= t.x + a.l && n <= t.x + a.r && r >= t.y + a.t && r <= t.y + a.b && (!i || a.index > i.index) && (i = a);
558
+ return i ? i.id : null;
559
+ }
560
+ function ut(e, t = {}) {
561
+ let n = t.mapStyle || (() => x), r = e.getContext("2d"), i = 0, a = 0, o = 1, s = null, c, l, u, d, f, p, m = null, h = !0, g = !1, _ = /* @__PURE__ */ new Map(), v = R, y = (e, t, n) => {
562
+ let i = `${n ? "b" : "n"}${t}|${v}|${e}`, a = _.get(i);
563
+ return a === void 0 && (_.size > 2e4 && _.clear(), r.font = it({
564
+ italic: !1,
565
+ bold: n,
566
+ size: t,
567
+ family: v
568
+ }), a = r.measureText(e).width, _.set(i, a)), a;
569
+ };
570
+ return {
571
+ hit(e, t) {
572
+ return m && s ? lt(m, {
573
+ x: l,
574
+ y: u,
575
+ zoom: d
576
+ }, e, t) : null;
577
+ },
578
+ resize(t, n, s) {
579
+ i = t, a = n, o = s, e.width = t * s, e.height = n * s, r.setTransform(s, 0, 0, s, 0, 0), h = !0;
580
+ },
581
+ draw(e, t, _ = {}) {
582
+ if (g) return !1;
583
+ let b = n(), x = b.plain ? 0 : b.version, C = _.hover || null;
584
+ if (!h && e === s && e.version === c && t.x === l && t.y === u && t.zoom === d && x === f && C === p) return !1;
585
+ let w = m && e === s && e.version === c && t.zoom === d && x === f && !h;
586
+ s = e, c = e.version, l = t.x, u = t.y, d = t.zoom, f = x, p = C, h = !1;
587
+ let T = S(e, b);
588
+ v = T.labelFont || "\"Segoe UI\", -apple-system, BlinkMacSystemFont, Roboto, sans-serif", r.setTransform(o, 0, 0, o, 0, 0), r.clearRect(0, 0, i, a), r.save(), r.translate(t.x, t.y), r.scale(t.zoom, t.zoom), w || (m = nt(T, t.zoom, { measure: y }));
589
+ let E = rt(T, t, {
590
+ width: i,
591
+ height: a
592
+ }, {
593
+ measure: y,
594
+ hover: C,
595
+ placed: m
596
+ }), D = st();
597
+ for (let e of E) e.kind === "lane" && ct(r, e, D);
598
+ for (let e of E) e.kind === "node" && !e.screen && ct(r, e, D);
599
+ r.restore();
600
+ let O = {
601
+ ox: t.x,
602
+ oy: t.y,
603
+ k: t.zoom
604
+ };
605
+ D = st();
606
+ for (let e of E) e.kind === "node" && e.screen && ct(r, e, D, O);
607
+ for (let e of E) e.kind === "edge" && ct(r, e, D, O);
608
+ for (let e of E) e.kind === "chip" && ct(r, e, D, O);
609
+ return !0;
610
+ },
611
+ destroy() {
612
+ g = !0, s = null, m = null, _.clear(), r.setTransform(1, 0, 0, 1, 0, 0), r.clearRect(0, 0, i, a);
613
+ }
614
+ };
615
+ }
616
+ // ../explorer/engine/render.js
617
+ var dt = [
618
+ "pointerdown",
619
+ "pointermove",
620
+ "mousedown",
621
+ "mousemove",
622
+ "wheel",
623
+ "touchstart",
624
+ "touchmove",
625
+ "keydown"
626
+ ];
627
+ function ft(e, t = {}) {
628
+ if (e.map) return e.map;
629
+ let { state: n } = e, r = t.measureCovered || (() => n.coveredBottom || 0), i = ce(e).get, a = !1, o = (e) => de(n, e), s = (e) => de(n, e, { viewer: !0 }), l = (t, r = e.viewEdges(), i = {
630
+ throughChildren: !!n.throughChildren,
631
+ kind: n.selectedKind || null
632
+ }) => b(t, r, i), f = d((t) => c(t, { reduceMotion: e.reducedMotion })), p = () => f.get(n), m = () => f.builds, h = ze(), g = () => h.get(p()), _ = () => h.builds, v = null, y = null;
633
+ function x() {
634
+ return v && y === n.canvas || (v && v.destroy(), v = Fe(n.canvas, { mapStyle: i }), y = n.canvas, n.width && v.resize(n.width, n.height, e.dpr())), v;
635
+ }
636
+ let S = null, w = null;
637
+ function T() {
638
+ return n.labelCanvas ? (S && w === n.labelCanvas || (S && S.destroy(), S = ut(n.labelCanvas, { mapStyle: i }), w = n.labelCanvas, n.width && S.resize(n.width, n.height, e.dpr())), S) : null;
639
+ }
640
+ function E(t) {
641
+ v && v !== t && v.destroy(), v = t, y = n.canvas, n.width && v.resize(n.width, n.height, e.dpr()), V();
642
+ }
643
+ function D() {
644
+ let { canvas: t } = n;
645
+ n.width = t.parentElement.clientWidth, n.height = t.parentElement.clientHeight, x().resize(n.width, n.height, e.dpr());
646
+ let r = T();
647
+ r && r.resize(n.width, n.height, e.dpr()), V();
648
+ }
649
+ function O() {
650
+ let t = n.canvas && n.canvas.parentElement, r = e.win && e.win.ResizeObserver;
651
+ if (!t || !r) return () => {};
652
+ let i = new r(() => {
653
+ n.canvas && (t.clientWidth !== n.width || t.clientHeight !== n.height) && D();
654
+ });
655
+ i.observe(t);
656
+ let a = () => i.disconnect();
657
+ return e.own(a), a;
658
+ }
659
+ function k(e, t = null) {
660
+ let { nodes: i, width: a, height: s } = n, c = i.filter(o);
661
+ if (t) {
662
+ let e = c.filter((e) => t.has(e.id));
663
+ e.length && (c = e);
664
+ }
665
+ if (c.length === 0) return null;
666
+ let l = Math.max(160, s - r()), u = Infinity, d = -Infinity, f = Infinity, p = -Infinity;
667
+ c.forEach((e) => {
668
+ let t = e.r || 18;
669
+ u = Math.min(u, e.x - t - 25), d = Math.max(d, e.x + t + 25), f = Math.min(f, e.y - t - 25), p = Math.max(p, e.y + t + 35);
670
+ }), n.view === "dataflow" && n.flow && (f = Math.min(f, n.flow.top - 10)), n.view === "house" && n.house && n.house.fit && !t && ({minX: u, maxX: d, minY: f, maxY: p} = n.house.fit);
671
+ let m = Math.max(160, a - e * 2), h = Math.max(160, l - e * 2), g = Math.min(m / (d - u), h / (p - f));
672
+ return {
673
+ minX: u,
674
+ maxX: d,
675
+ minY: f,
676
+ maxY: p,
677
+ mapHeight: l,
678
+ raw: g
679
+ };
680
+ }
681
+ let A = "", j = C;
682
+ function M() {
683
+ let e = `${n.sceneVersion}|${n.width}|${n.height}|${n.view}|${r()}`;
684
+ if (e !== A) {
685
+ A = e;
686
+ let t = k(P());
687
+ j = t && t.raw > 0 && Number.isFinite(t.raw) ? Math.max(u, Math.min(C, t.raw)) : C;
688
+ }
689
+ return j;
690
+ }
691
+ function N(e = 40, t = null) {
692
+ let { width: r, camera: i } = n, a = k(e, t);
693
+ if (!a) return;
694
+ let { minX: o, maxX: s, minY: c, maxY: l, mapHeight: d } = a, f = Math.min(1, Math.max(u, a.raw));
695
+ i.zoom = f, i.x = r / 2 - (o + s) / 2 * f, i.y = d / 2 - (c + l) / 2 * f, V();
696
+ }
697
+ let P = () => n.width < 640 ? 24 : 48, F = (e, t) => ({
698
+ x: (e - n.camera.x) / n.camera.zoom,
699
+ y: (t - n.camera.y) / n.camera.zoom
700
+ }), I = -1;
701
+ function ee() {
702
+ if (!n.canvas) return;
703
+ let e = p();
704
+ I = e.version, x().draw(e, n.camera, performance.now());
705
+ let t = T();
706
+ t && t.draw(e, n.camera, { hover: n.hoverNodeId }), L.forEach((t) => t(e, n.camera));
707
+ }
708
+ function te(e, t) {
709
+ let n = T();
710
+ return n ? n.hit(e, t) : null;
711
+ }
712
+ function ne(e) {
713
+ let t = e || null;
714
+ if (n.hoverNodeId === t) return;
715
+ n.hoverNodeId = t;
716
+ let r = T();
717
+ r && n.canvas && n.width && r.draw(p(), n.camera, { hover: t });
718
+ }
719
+ let L = /* @__PURE__ */ new Set(), R = (e) => (L.add(e), () => L.delete(e)), z = /* @__PURE__ */ new Set(), B = Ge({
720
+ draw: ee,
721
+ packetsVisible: () => !!n.canvas && He(p(), n.camera, n.width, n.height),
722
+ isHidden: () => e.hidden(),
723
+ tickClients: (e) => {
724
+ let t = !1;
725
+ return z.forEach((n) => {
726
+ n.tick(e), n.wants() && (t = !0);
727
+ }), t;
728
+ },
729
+ clientsWant: () => [...z].some((e) => e.wants()),
730
+ reduceMotion: () => e.reducedMotion,
731
+ extraDirty: () => n.sceneVersion !== I,
732
+ now: () => performance.now(),
733
+ raf: (e) => requestAnimationFrame(e),
734
+ caf: (e) => cancelAnimationFrame(e)
735
+ });
736
+ function V() {
737
+ !a && n.canvas && B.markDirty();
738
+ }
739
+ function H() {
740
+ !a && n.canvas && B.drawNow();
741
+ }
742
+ function U(e) {
743
+ return z.add(e), () => z.delete(e);
744
+ }
745
+ if (e.root) {
746
+ let t = () => B.noteInput();
747
+ for (let n of dt) e.listen(e.root, n, t, {
748
+ passive: !0,
749
+ capture: !0
750
+ });
751
+ }
752
+ e.onShown(() => B.shown());
753
+ function W() {
754
+ a = !0, e.map === G && (e.map = null), B.cancel(), v && (v.release ? v.release() : v.destroy(), v = null, y = null), S && (S.destroy(), S = null, w = null), L.clear(), z.clear();
755
+ }
756
+ let G = {
757
+ isNodeVisible: o,
758
+ isNodeVisibleToViewer: s,
759
+ getActiveSubgraph: l,
760
+ getScene: p,
761
+ sceneBuilds: m,
762
+ getSpatialIndex: g,
763
+ spatialBuilds: _,
764
+ getRenderer: x,
765
+ setRenderer: E,
766
+ resize: D,
767
+ watchSize: O,
768
+ getMinZoom: M,
769
+ fitGraphToViewport: N,
770
+ fitPadding: P,
771
+ screenToWorld: F,
772
+ labelNodeAt: te,
773
+ setHoverNode: ne,
774
+ onPaint: R,
775
+ render: V,
776
+ renderNow: H,
777
+ addFrameClient: U,
778
+ queueFrameWork: (e, t) => {
779
+ a || B.queue(e, t);
780
+ },
781
+ frameStats: () => ({
782
+ frames: B.frames,
783
+ draws: B.draws
784
+ }),
785
+ holdFrames: (e) => {
786
+ a || B.hold(e);
787
+ },
788
+ cancelFrame: () => B.cancel(),
789
+ ensureFlowLoop: () => {
790
+ a || B.wake();
791
+ },
792
+ destroy: W
793
+ };
794
+ return e.map = G, e.own(W), G;
795
+ }
796
+ // ../explorer/shaders.js
797
+ var X = "#version 300 es\nprecision highp float;\nuniform vec2 u_viewport;\nuniform vec3 u_cam;\nuniform float u_dpr;\n", Z = "\nvec4 toClip(vec2 pos) {\n return vec4(pos.x / u_viewport.x * 2.0 - 1.0, 1.0 - pos.y / u_viewport.y * 2.0, 0.0, 1.0);\n}\n", Q = "\nout vec4 outColor;\n\n// Coverage of one device pixel by the half plane d < 0 (d: signed distance in CSS px, pix: the pixel's size)\nfloat coverEdge(float d, float pix) {\n return clamp(0.5 - d / pix, 0.0, 1.0);\n}\n\n// Coverage of one pixel by a band of half width hw around dist = 0 (dist >= 0: distance from the centre line)\nfloat coverBand(float dist, float hw, float pix) {\n float hi = min(hw, dist + 0.5 * pix);\n float lo = max(-hw, dist - 0.5 * pix);\n return clamp((hi - lo) / pix, 0.0, 1.0);\n}\n\n// Coverage by a dash pattern along an arc (on / off in world units; on <= 0 or off <= 0 is solid)\nfloat coverDash(float arc, float on, float off, float pixWorld) {\n if (on <= 0.0 || off <= 0.0) return 1.0;\n float period = on + off;\n float u = mod(arc - on * 0.5 + period * 0.5, period) - period * 0.5;\n return clamp((on * 0.5 - abs(u)) / pixWorld + 0.5, 0.0, 1.0);\n}\n\n// Straight colour at alpha a, composited over acc (premultiplied)\nvoid over(inout vec4 acc, vec3 rgb, float a) {\n acc = vec4(rgb * a, a) + acc * (1.0 - a);\n}\n\n// What Canvas 2D's shadowBlur gives a disc of radius R at distance len from its centre: a blurred copy\n// of the disc. s is the blur's sigma in CSS px (shadowBlur is in DEVICE px and sigma = blur / 2). A big\n// disc has a straight-edge profile (a logistic stands in for the Gaussian's CDF); a small one is a\n// Gaussian bump whose height is what the blur leaves of it.\nfloat glowDisc(float len, float R, float s) {\n float wide = 1.0 / (1.0 + exp(clamp(1.702 * (len - R) / s, -30.0, 30.0)));\n float narrow = (1.0 - exp(-R * R / (2.0 * s * s))) * exp(-len * len / (2.0 * s * s));\n return mix(narrow, wide, smoothstep(0.5 * s, 2.5 * s, R));\n}\n\n// The normal distribution's CDF, as the same logistic (error under 0.01)\nfloat phi(float x) {\n return 1.0 / (1.0 + exp(clamp(-1.702 * x, -30.0, 30.0)));\n}\n", pt = `${X}
798
+ layout(location = 0) in vec2 a_corner;
799
+ layout(location = 1) in vec4 a_grid; // size, width
800
+ layout(location = 2) in vec4 a_color;
801
+ out vec2 v_pos;
802
+ flat out vec4 v_grid;
803
+ flat out vec4 v_color;
804
+ void main() {
805
+ v_pos = vec2((a_corner.x * 0.5 + 0.5) * u_viewport.x, (0.5 - a_corner.y * 0.5) * u_viewport.y);
806
+ v_grid = a_grid;
807
+ v_color = a_color;
808
+ gl_Position = vec4(a_corner, 0.0, 1.0);
809
+ }
810
+ `, mt = `${X}${Q}
811
+ in vec2 v_pos;
812
+ flat in vec4 v_grid;
813
+ flat in vec4 v_color;
814
+ void main() {
815
+ float zoom = u_cam.z;
816
+ float pix = 1.0 / u_dpr;
817
+ vec2 world = (v_pos - u_cam.xy) / zoom;
818
+ vec2 dist = abs(world - floor(world / v_grid.x + 0.5) * v_grid.x) * zoom;
819
+ float hw = v_grid.y * zoom * 0.5;
820
+ float cover = max(coverBand(dist.x, hw, pix), coverBand(dist.y, hw, pix));
821
+ outColor = vec4(v_color.rgb * v_color.a, v_color.a) * cover;
822
+ }
823
+ `, ht = `${X}${Z}
824
+ layout(location = 0) in vec2 a_corner;
825
+ layout(location = 1) in vec4 a_rect; // x, y, w, h (world)
826
+ layout(location = 2) in vec4 a_fill;
827
+ layout(location = 3) in vec4 a_stroke;
828
+ layout(location = 4) in vec2 a_style; // corner radius, stroke width (world)
829
+ out vec2 v_local;
830
+ flat out vec2 v_half;
831
+ flat out vec2 v_style;
832
+ flat out vec4 v_fill;
833
+ flat out vec4 v_stroke;
834
+ void main() {
835
+ float zoom = u_cam.z;
836
+ vec2 half_ = a_rect.zw * 0.5 * zoom;
837
+ vec2 centre = u_cam.xy + (a_rect.xy + a_rect.zw * 0.5) * zoom;
838
+ vec2 ext = half_ + a_style.y * zoom * 0.5 + 2.0;
839
+ vec2 pos = clamp(centre + a_corner * ext, vec2(0.0), u_viewport);
840
+ v_local = pos - centre;
841
+ v_half = half_;
842
+ v_style = a_style;
843
+ v_fill = a_fill;
844
+ v_stroke = a_stroke;
845
+ gl_Position = toClip(pos);
846
+ }
847
+ `, gt = `${X}${Q}
848
+ in vec2 v_local;
849
+ flat in vec2 v_half;
850
+ flat in vec2 v_style;
851
+ flat in vec4 v_fill;
852
+ flat in vec4 v_stroke;
853
+ void main() {
854
+ float zoom = u_cam.z;
855
+ float pix = 1.0 / u_dpr;
856
+ float rad = min(v_style.x * zoom, min(v_half.x, v_half.y));
857
+ vec2 q = abs(v_local) - v_half + rad;
858
+ float sd = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - rad;
859
+ vec4 acc = vec4(0.0);
860
+ over(acc, v_fill.rgb, v_fill.a * coverEdge(sd, pix));
861
+ over(acc, v_stroke.rgb, v_stroke.a * coverBand(abs(sd), v_style.y * zoom * 0.5, pix));
862
+ outColor = acc;
863
+ }
864
+ `, _t = `${X}${Z}
865
+ layout(location = 0) in vec2 a_corner;
866
+ layout(location = 1) in vec4 a_geom; // x, y, r, width (world)
867
+ layout(location = 2) in vec4 a_color;
868
+ layout(location = 3) in vec2 a_dash; // on, off (world)
869
+ out vec2 v_local;
870
+ flat out vec4 v_geom;
871
+ flat out vec4 v_color;
872
+ flat out vec2 v_dash;
873
+ void main() {
874
+ float zoom = u_cam.z;
875
+ vec2 centre = u_cam.xy + a_geom.xy * zoom;
876
+ float ext = (a_geom.z + a_geom.w * 0.5) * zoom + 2.0;
877
+ vec2 pos = clamp(centre + a_corner * ext, vec2(0.0), u_viewport);
878
+ v_local = pos - centre;
879
+ v_geom = a_geom;
880
+ v_color = a_color;
881
+ v_dash = a_dash;
882
+ gl_Position = toClip(pos);
883
+ }
884
+ `, vt = `${X}${Q}
885
+ in vec2 v_local;
886
+ flat in vec4 v_geom;
887
+ flat in vec4 v_color;
888
+ flat in vec2 v_dash;
889
+ void main() {
890
+ float zoom = u_cam.z;
891
+ float pix = 1.0 / u_dpr;
892
+ float len = length(v_local);
893
+ float cover = coverBand(abs(len - v_geom.z * zoom), v_geom.w * zoom * 0.5, pix);
894
+ // Dashes run clockwise from angle 0, as Canvas 2D's arc() does
895
+ float arc = mod(atan(v_local.y, v_local.x) + 6.2831853, 6.2831853) * v_geom.z;
896
+ cover *= coverDash(arc, v_dash.x, v_dash.y, pix / zoom);
897
+ outColor = vec4(v_color.rgb * v_color.a, v_color.a) * cover;
898
+ }
899
+ `, yt = `${X}${Z}
900
+ layout(location = 0) in vec2 a_corner;
901
+ layout(location = 1) in vec4 a_geom; // x, y, r (world), alpha
902
+ layout(location = 2) in vec4 a_color; // r, g, b (0..1), glow (px)
903
+ layout(location = 3) in vec4 a_kind; // halo code, mark code, colour alpha, shape code (0 circle, 1 rounded square, 2 hexagon, 3 square, 4 diamond; plus 8 when a glyph takes the core dot's place)
904
+ uniform vec4 u_haloGeom[4]; // fillR, ringR, ringWidth (world)
905
+ uniform vec4 u_markGeom[5]; // per mark code: ringR, ringWidth (world), dash on, dash off
906
+ uniform vec3 u_markMin; // MARK_MIN_PX, in screen px: ring thickness, edge thickness, gap from the node
907
+ out vec2 v_local;
908
+ flat out vec4 v_geom;
909
+ flat out vec4 v_color;
910
+ flat out vec4 v_kind;
911
+ void main() {
912
+ float zoom = u_cam.z;
913
+ int halo = int(a_kind.x + 0.5);
914
+ int mark = int(a_kind.y + 0.5);
915
+ // The quad reaches as far as the farthest thing drawn: the glow (3 sigma), the halo ring, the mark ring
916
+ float pad = a_color.w * 1.5 / u_dpr;
917
+ if (halo > 0) pad = max(pad, (u_haloGeom[halo].y + u_haloGeom[halo].z * 0.5) * zoom);
918
+ if (mark > 0) pad = max(pad, max(u_markGeom[mark].x * zoom, u_markMin.z) + max(u_markGeom[mark].y * zoom, u_markMin.x) + 1.5);
919
+ float ext = a_geom.z * zoom * 1.2 + pad + 2.0; // a diamond reaches 1.15 radii
920
+ vec2 centre = u_cam.xy + a_geom.xy * zoom;
921
+ v_local = a_corner * ext;
922
+ v_geom = a_geom;
923
+ v_color = a_color;
924
+ v_kind = a_kind;
925
+ gl_Position = toClip(centre + v_local);
926
+ }
927
+ `, bt = `${X}${Q}
928
+ in vec2 v_local;
929
+ flat in vec4 v_geom;
930
+ flat in vec4 v_color;
931
+ flat in vec4 v_kind;
932
+ uniform vec4 u_shape; // rounded square half side, its corner, hexagon inradius, square half side (x radius)
933
+ uniform vec2 u_shape2; // square corner, diamond half diagonal (x radius)
934
+ uniform float u_glyphMin; // GLYPH_MIN_PX: a node this wide on screen shows its glyph (the icon pass) instead of the core dot
935
+ uniform vec4 u_haloFill[4];
936
+ uniform vec4 u_haloRing[4];
937
+ uniform vec4 u_haloGeom[4];
938
+ uniform vec4 u_markColor[5];
939
+ uniform vec4 u_markGeom[5];
940
+ uniform vec3 u_markMin;
941
+ uniform vec4 u_core;
942
+ uniform float u_coreRatio;
943
+ // Signed distance (px) to a node's silhouette of radius R: the same shapes renderer-canvas2d.js draws (silhouette)
944
+ float sdRoundBox(vec2 p, float h, float c) {
945
+ vec2 q = abs(p) - vec2(h - c);
946
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - c;
947
+ }
948
+ float sdHex(vec2 p, float r) {
949
+ const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
950
+ p = abs(p);
951
+ p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy;
952
+ p -= vec2(clamp(p.x, -k.z * r, k.z * r), r);
953
+ return length(p) * sign(p.y);
954
+ }
955
+ float sdShape(vec2 p, float R, int shape, float len) {
956
+ if (shape == 1) return sdRoundBox(p, u_shape.x * R, u_shape.y * R);
957
+ if (shape == 2) return sdHex(p.yx, u_shape.z * R);
958
+ if (shape == 3) return sdRoundBox(p, u_shape.w * R, u_shape2.x * R);
959
+ if (shape == 4) return (abs(p.x) + abs(p.y) - u_shape2.y * R) * 0.70710678;
960
+ return len - R;
961
+ }
962
+ void main() {
963
+ float zoom = u_cam.z;
964
+ float pix = 1.0 / u_dpr;
965
+ float rw = v_geom.z;
966
+ float R = rw * zoom;
967
+ float al = v_geom.w;
968
+ float len = length(v_local);
969
+ vec4 acc = vec4(0.0);
970
+
971
+ // Halo: a translucent disc, then a ring
972
+ int halo = int(v_kind.x + 0.5);
973
+ if (halo > 0) {
974
+ vec4 fill = u_haloFill[halo];
975
+ if (fill.a > 0.0) over(acc, fill.rgb, fill.a * al * coverEdge(len - (rw + u_haloGeom[halo].x) * zoom, pix));
976
+ vec4 ring = u_haloRing[halo];
977
+ over(acc, ring.rgb, ring.a * al * coverBand(abs(len - (rw + u_haloGeom[halo].y) * zoom), u_haloGeom[halo].z * zoom * 0.5, pix));
978
+ }
979
+
980
+ // Glow: a blurred copy of the disc under it (see glowDisc)
981
+ float glow = v_color.w;
982
+ if (glow > 0.0) over(acc, v_color.rgb, v_kind.z * al * glowDisc(len, R, glow * 0.5 / u_dpr));
983
+
984
+ // The silhouette, and its white core unless the type's glyph is drawn there (glyphs.js: the icon pass draws it once the node is wide enough)
985
+ int shapeCode = int(v_kind.w + 0.5);
986
+ bool glyph = shapeCode >= 8;
987
+ if (glyph) shapeCode -= 8;
988
+ over(acc, v_color.rgb, v_kind.z * al * coverEdge(sdShape(v_local, R, shapeCode, len), pix));
989
+ if (!glyph || 2.0 * R < u_glyphMin) over(acc, u_core.rgb, u_core.a * al * coverEdge(len - R * u_coreRatio, pix));
990
+
991
+ // Mark: a ring with the look of its own mark (dashed when its dash is set: added), and for removed a
992
+ // strike through the node. However far out the camera is, the ring stays u_markMin.z px from the node
993
+ // and u_markMin.x px thick (scene.js MARK_MIN_PX; renderer-canvas2d.js drawNode does the same).
994
+ int mark = int(v_kind.y + 0.5);
995
+ if (mark > 0) {
996
+ vec4 mc = u_markColor[mark];
997
+ vec4 mg = u_markGeom[mark];
998
+ float ringW = rw + max(mg.x, u_markMin.z / zoom);
999
+ float rr = ringW * zoom;
1000
+ float wpx = max(mg.y * zoom, u_markMin.x);
1001
+ float cover = coverBand(abs(len - rr), wpx * 0.5, pix);
1002
+ if (mg.z > 0.0 && mg.w > 0.0 && len > 0.5) {
1003
+ // a whole number of dashes round the ring, so the pattern closes
1004
+ float circ = 6.2831853 * ringW;
1005
+ float n = max(floor(circ / (mg.z + mg.w) + 0.5), 1.0);
1006
+ float period = circ / n;
1007
+ float on = period * mg.z / (mg.z + mg.w);
1008
+ float arc = mod(atan(v_local.y, v_local.x) + 6.2831853, 6.2831853) * ringW;
1009
+ cover *= coverDash(arc, on, period - on, pix / zoom);
1010
+ }
1011
+ if (mark == 3) cover = max(cover, coverBand(abs(v_local.y), wpx * 0.5, pix) * coverEdge(abs(v_local.x) - rr, pix));
1012
+ over(acc, mc.rgb, mc.a * al * cover);
1013
+ }
1014
+
1015
+ outColor = acc;
1016
+ }
1017
+ `, xt = "\nvec2 bez(vec2 a, vec2 c, vec2 b, float t) {\n float u = 1.0 - t;\n return u * u * a + 2.0 * u * t * c + t * t * b;\n}\nvec2 bezD(vec2 a, vec2 c, vec2 b, float t) {\n return 2.0 * (1.0 - t) * (c - a) + 2.0 * t * (b - c);\n}\n// Arc length from 0 to t, in world units (midpoint rule, 8 steps: the speed is smooth)\nfloat bezArc(vec2 a, vec2 c, vec2 b, float t) {\n float sum = 0.0;\n for (int j = 0; j < 8; j++) sum += length(bezD(a, c, b, (float(j) + 0.5) * t / 8.0));\n return sum * t / 8.0;\n}\n", St = "\nvec2 packetPos(vec4 ends, vec4 mot, float timeSec) {\n float k = fract(timeSec * mot.z + mot.w);\n return bez(ends.xy, mot.xy, ends.zw, k);\n}\n", Ct = (e) => `${X}${xt}
1018
+ #define SEGS ${e}
1019
+ layout(location = 1) in vec4 a_ends; // x1, y1, x2, y2 (world)
1020
+ layout(location = 2) in vec4 a_geom; // control x, y (world), width (world), glow blur (px)
1021
+ layout(location = 3) in vec4 a_color; // straight rgb, alpha (the edge's alpha folded in)
1022
+ layout(location = 4) in vec4 a_glow; // glow rgb, glow strength (colour alpha x edge alpha)
1023
+ layout(location = 5) in vec2 a_dash; // on, off (world); 0 = solid
1024
+ layout(location = 6) in float a_marked; // 1 = a proposal's mark: never thinner than u_markMin.y px
1025
+ uniform vec3 u_markMin; // MARK_MIN_PX in screen px: ring thickness, edge thickness, gap
1026
+ out float v_across; // CSS px from the centre line, signed
1027
+ out float v_arc; // world units along the edge from its start; below 0 and past the length on the end caps
1028
+ flat out float v_len;
1029
+ flat out float v_halfWidth; // the stroke's half width in CSS px, minimum included
1030
+ flat out vec4 v_geom;
1031
+ flat out vec4 v_color;
1032
+ flat out vec4 v_glow;
1033
+ flat out vec2 v_dash;
1034
+ void main() {
1035
+ float zoom = u_cam.z;
1036
+ vec2 a = a_ends.xy;
1037
+ vec2 b = a_ends.zw;
1038
+ vec2 c = a_geom.xy;
1039
+ int pair = gl_VertexID / 2;
1040
+ float side = (gl_VertexID - pair * 2 == 0) ? -1.0 : 1.0;
1041
+ float t = float(clamp(pair - 1, 0, SEGS)) / float(SEGS);
1042
+ vec2 dir = bezD(a, c, b, t);
1043
+ dir = dot(dir, dir) < 1e-9 ? vec2(1.0, 0.0) : normalize(dir);
1044
+ vec2 normal = vec2(-dir.y, dir.x);
1045
+ float halfWidth = max(a_geom.z * zoom, a_marked * u_markMin.y) * 0.5;
1046
+ float pad = a_geom.w * 1.5 / u_dpr + 1.5; // the glow's 3 sigma, and room to anti-alias
1047
+ float ext = pair == 0 ? -pad : (pair == SEGS + 2 ? pad : 0.0);
1048
+ vec2 pos = u_cam.xy + bez(a, c, b, t) * zoom + dir * ext + normal * side * (halfWidth + pad);
1049
+ v_across = side * (halfWidth + pad);
1050
+ v_arc = bezArc(a, c, b, t) + ext / zoom;
1051
+ v_len = bezArc(a, c, b, 1.0);
1052
+ v_halfWidth = halfWidth;
1053
+ v_geom = a_geom;
1054
+ v_color = a_color;
1055
+ v_glow = a_glow;
1056
+ v_dash = a_dash;
1057
+ gl_Position = vec4(pos.x / u_viewport.x * 2.0 - 1.0, 1.0 - pos.y / u_viewport.y * 2.0, 0.0, 1.0);
1058
+ }
1059
+ `, wt = `${X}${Q}
1060
+ in float v_across;
1061
+ in float v_arc;
1062
+ flat in float v_len;
1063
+ flat in float v_halfWidth;
1064
+ flat in vec4 v_geom;
1065
+ flat in vec4 v_color;
1066
+ flat in vec4 v_glow;
1067
+ flat in vec2 v_dash;
1068
+
1069
+ // How much of a blurred copy of the stroke's dashes (sigma sw, world units) is under arc
1070
+ float blurredDashes(float arc, float on, float off, float len, float sw) {
1071
+ float whole = phi((arc - 0.0) / sw) - phi((arc - len) / sw);
1072
+ if (on <= 0.0 || off <= 0.0) return whole;
1073
+ float period = on + off;
1074
+ float n = floor(arc / period);
1075
+ float near = 0.0;
1076
+ for (int j = -2; j <= 2; j++) {
1077
+ float lo = (n + float(j)) * period;
1078
+ float hi = min(lo + on, len);
1079
+ lo = max(lo, 0.0);
1080
+ if (hi > lo) near += phi((arc - lo) / sw) - phi((arc - hi) / sw);
1081
+ }
1082
+ // blurred wider than a few periods, the dashes are an even tint
1083
+ return mix(min(near, 1.0), whole * on / period, smoothstep(0.5, 1.5, sw / period));
1084
+ }
1085
+
1086
+ void main() {
1087
+ float zoom = u_cam.z;
1088
+ float pix = 1.0 / u_dpr;
1089
+ float dist = abs(v_across);
1090
+ float halfWidth = v_halfWidth;
1091
+ vec4 acc = vec4(0.0);
1092
+
1093
+ // Glow: Canvas 2D's shadowBlur of the stroke, dashes and all, under it (sigma = blur / 2 device px)
1094
+ if (v_geom.w > 0.0 && v_glow.a > 0.0) {
1095
+ float s = v_geom.w * 0.5 / u_dpr;
1096
+ float across = phi((halfWidth - dist) / s) + phi((halfWidth + dist) / s) - 1.0;
1097
+ float along = blurredDashes(v_arc, v_dash.x, v_dash.y, v_len, s / zoom);
1098
+ over(acc, v_glow.rgb, v_glow.a * clamp(across, 0.0, 1.0) * clamp(along, 0.0, 1.0));
1099
+ }
1100
+
1101
+ // The stroke: a band, with square ends and the dash pattern in world units
1102
+ float cover = coverBand(dist, halfWidth, pix)
1103
+ * coverEdge(-v_arc * zoom, pix)
1104
+ * coverEdge((v_arc - v_len) * zoom, pix)
1105
+ * coverDash(v_arc, v_dash.x, v_dash.y, pix / zoom);
1106
+ over(acc, v_color.rgb, v_color.a * cover);
1107
+ outColor = acc;
1108
+ }
1109
+ `, Tt = `${X}${Z}
1110
+ layout(location = 0) in vec2 a_corner;
1111
+ layout(location = 1) in vec4 a_tip; // x, y (world), direction x, y (unit)
1112
+ layout(location = 2) in vec4 a_color;
1113
+ layout(location = 3) in float a_kind; // 1 = arrowhead (tip at x, y), 2 = strike (centred on x, y), 3 = chevron, 4 = bar, 5 = diamond (all with their tip at x, y), 6 = tick (centred on x, y)
1114
+ uniform vec4 u_tip; // arrow length, arrow spread (radians), strike half length, strike width (world)
1115
+ uniform vec4 u_end; // stroke width of the open marks, bar half length, diamond half length, diamond half width (world)
1116
+ out vec2 v_local;
1117
+ flat out vec4 v_color;
1118
+ flat out float v_kind;
1119
+ void main() {
1120
+ float zoom = u_cam.z;
1121
+ float ext = max(max(u_tip.x, 2.0 * u_end.z), max(u_tip.z, u_end.y)) * zoom + 3.0;
1122
+ vec2 dir = a_tip.zw;
1123
+ vec2 off = a_corner * ext;
1124
+ v_local = vec2(dot(off, dir), dot(off, vec2(-dir.y, dir.x)));
1125
+ v_color = a_color;
1126
+ v_kind = a_kind;
1127
+ gl_Position = toClip(u_cam.xy + a_tip.xy * zoom + off);
1128
+ }
1129
+ `, Et = `${X}${Q}
1130
+ in vec2 v_local;
1131
+ flat in vec4 v_color;
1132
+ flat in float v_kind;
1133
+ uniform vec4 u_tip;
1134
+ uniform vec4 u_end; // stroke width of the open marks, bar half length, diamond half length, diamond half width (world)
1135
+ uniform vec2 u_tick; // tick half length, tick width (world)
1136
+ // Distance to the segment a-b
1137
+ float sdSeg(vec2 p, vec2 a, vec2 b) {
1138
+ vec2 pa = p - a;
1139
+ vec2 ba = b - a;
1140
+ float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
1141
+ return length(pa - ba * h);
1142
+ }
1143
+ // Distance to a rhombus with half diagonals b (iq's sdRhombus)
1144
+ float ndot(vec2 a, vec2 b) { return a.x * b.x - a.y * b.y; }
1145
+ float sdRhombus(vec2 p, vec2 b) {
1146
+ p = abs(p);
1147
+ float h = clamp(ndot(b - 2.0 * p, b) / dot(b, b), -1.0, 1.0);
1148
+ float d = length(p - 0.5 * b * vec2(1.0 - h, 1.0 + h));
1149
+ return d * sign(p.x * b.y + p.y * b.x - b.x * b.y);
1150
+ }
1151
+ void main() {
1152
+ float zoom = u_cam.z;
1153
+ float pix = 1.0 / u_dpr;
1154
+ float sd;
1155
+ float L = u_tip.x * zoom;
1156
+ float sn = sin(u_tip.y);
1157
+ float cs = cos(u_tip.y);
1158
+ float w = max(u_end.x * zoom, 1.2) * 0.5; // half the stroke of an open mark: at least 1.2 px thick so it stays visible zoomed out
1159
+ if (v_kind < 1.5) {
1160
+ // The triangle with its tip at the origin and two barbs L back, spread radians either side of the line
1161
+ sd = max(max(sn * v_local.x + cs * v_local.y, sn * v_local.x - cs * v_local.y), -v_local.x - L * cs);
1162
+ } else if (v_kind < 2.5) {
1163
+ // A box across the edge, at least 1.5 px thick so it stays visible zoomed out
1164
+ vec2 q = abs(v_local) - vec2(max(u_tip.w * zoom, 1.5) * 0.5, u_tip.z * zoom);
1165
+ sd = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
1166
+ } else if (v_kind < 3.5) {
1167
+ // The chevron: the arrowhead's two barbs, open (a line each, from the tip back)
1168
+ vec2 barb = vec2(-L * cs, L * sn);
1169
+ sd = min(sdSeg(v_local, vec2(0.0), barb), sdSeg(v_local, vec2(0.0), vec2(barb.x, -barb.y))) - w;
1170
+ } else if (v_kind < 4.5) {
1171
+ // The bar: across the line at the target
1172
+ vec2 q = abs(v_local - vec2(-w, 0.0)) - vec2(w, u_end.y * zoom);
1173
+ sd = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
1174
+ } else if (v_kind < 5.5) {
1175
+ // The diamond: an outline, its front vertex at the tip
1176
+ vec2 h = vec2(u_end.z, u_end.w) * zoom;
1177
+ sd = abs(sdRhombus(v_local - vec2(-h.x, 0.0), h)) - w;
1178
+ } else {
1179
+ // The tick: a short box across the edge, centred, at least 1.5 px thick
1180
+ vec2 q = abs(v_local) - vec2(max(u_tick.y * zoom, 1.5) * 0.5, u_tick.x * zoom);
1181
+ sd = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
1182
+ }
1183
+ outColor = vec4(v_color.rgb * v_color.a, v_color.a) * coverEdge(sd, pix);
1184
+ }
1185
+ `, Dt = `${X}${Z}${xt}${St}
1186
+ layout(location = 0) in vec2 a_corner;
1187
+ layout(location = 1) in vec4 a_ends; // x1, y1, x2, y2 (world)
1188
+ layout(location = 2) in vec4 a_mot; // control x, y (world), speed (trips per second), phase
1189
+ layout(location = 3) in vec4 a_color; // the dot: straight rgb, alpha (edge alpha folded in)
1190
+ layout(location = 4) in vec4 a_glow; // its glow: rgb, strength
1191
+ layout(location = 5) in vec2 a_size; // radius (world), glow blur (px)
1192
+ uniform float u_time; // seconds
1193
+ out vec2 v_local;
1194
+ flat out vec4 v_size;
1195
+ flat out vec4 v_color;
1196
+ flat out vec4 v_glow;
1197
+ void main() {
1198
+ float zoom = u_cam.z;
1199
+ vec2 centre = u_cam.xy + packetPos(a_ends, a_mot, u_time) * zoom;
1200
+ v_local = a_corner * (a_size.x * zoom + a_size.y * 1.5 / u_dpr + 2.0);
1201
+ v_size = a_size.xyxy;
1202
+ v_color = a_color;
1203
+ v_glow = a_glow;
1204
+ gl_Position = toClip(centre + v_local);
1205
+ }
1206
+ `, Ot = `${X}${Q}
1207
+ in vec2 v_local;
1208
+ flat in vec4 v_size;
1209
+ flat in vec4 v_color;
1210
+ flat in vec4 v_glow;
1211
+ void main() {
1212
+ float zoom = u_cam.z;
1213
+ float pix = 1.0 / u_dpr;
1214
+ float len = length(v_local);
1215
+ float R = v_size.x * zoom;
1216
+ vec4 acc = vec4(0.0);
1217
+ if (v_size.y > 0.0) over(acc, v_glow.rgb, v_glow.a * glowDisc(len, R, v_size.y * 0.5 / u_dpr));
1218
+ over(acc, v_color.rgb, v_color.a * coverEdge(len - R, pix));
1219
+ outColor = acc;
1220
+ }
1221
+ `, kt = `${X}${Z}
1222
+ layout(location = 0) in vec2 a_corner;
1223
+ layout(location = 1) in vec4 a_geom; // x, y, side (world), alpha
1224
+ uniform float u_minR; // letters and glyphs: the least on-screen radius (px) of a node that shows them; 0 for a theme's icon
1225
+ uniform float u_sideRatio; // the image's side as a multiple of the node's radius (LETTER_RATIO, GLYPH_RATIO), to read the radius back
1226
+ out vec2 v_uv;
1227
+ flat out float v_alpha;
1228
+ void main() {
1229
+ if (u_minR > 0.0 && a_geom.z / u_sideRatio * u_cam.z < u_minR) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); v_uv = vec2(0.0); v_alpha = 0.0; return; } // too small on screen: outside the clip space, nothing drawn
1230
+ vec2 centre = u_cam.xy + a_geom.xy * u_cam.z;
1231
+ vec2 pos = centre + a_corner * (a_geom.z * 0.5 * u_cam.z);
1232
+ v_uv = vec2(a_corner.x * 0.5 + 0.5, a_corner.y * 0.5 + 0.5); // screen y runs down and an image's first row is its top, so the corner below the centre reads the last row
1233
+ v_alpha = a_geom.w;
1234
+ gl_Position = toClip(pos);
1235
+ }
1236
+ `, At = `${X}
1237
+ uniform sampler2D u_tex;
1238
+ in vec2 v_uv;
1239
+ flat in float v_alpha;
1240
+ out vec4 outColor;
1241
+ void main() {
1242
+ outColor = texture(u_tex, v_uv) * v_alpha; // the texture is uploaded premultiplied
1243
+ }
1244
+ `, jt = {
1245
+ none: 0,
1246
+ selected: 1,
1247
+ match: 2,
1248
+ child: 3
1249
+ }, Mt = {
1250
+ arrow: 1,
1251
+ strike: 2,
1252
+ chevron: 3,
1253
+ bar: 4,
1254
+ diamond: 5,
1255
+ tick: 6
1256
+ }, Nt = Object.freeze(Object.fromEntries(M.map((e, t) => [e, t]))), Pt = {
1257
+ none: 0,
1258
+ added: 1,
1259
+ changed: 2,
1260
+ removed: 3,
1261
+ edit: 4
1262
+ }, $ = (e) => {
1263
+ let [t, n, r, i] = L(e);
1264
+ return [
1265
+ t / 255,
1266
+ n / 255,
1267
+ r / 255,
1268
+ i
1269
+ ];
1270
+ }, Ft = (e, t) => Object.hasOwn(e, t) ? e[t] : 0;
1271
+ function It(e) {
1272
+ let { nodes: t } = e, n = new Float32Array(t.length * 12);
1273
+ return t.forEach((e, t) => {
1274
+ let [r, i, a, o] = $(e.color);
1275
+ n.set([
1276
+ e.x,
1277
+ e.y,
1278
+ e.r,
1279
+ e.alpha,
1280
+ r,
1281
+ i,
1282
+ a,
1283
+ e.glow || 0,
1284
+ Ft(jt, e.halo),
1285
+ Ft(Pt, e.mark),
1286
+ o,
1287
+ Ft(Nt, e.shape) + (e.glyph && !e.icon && !e.letters ? 8 : 0)
1288
+ ], t * 12);
1289
+ }), {
1290
+ data: n,
1291
+ count: t.length,
1292
+ stride: 12
1293
+ };
1294
+ }
1295
+ function Lt(e) {
1296
+ let { grid: t, rings: n, lanes: r } = e.decor, i = new Float32Array(t ? 8 : 0);
1297
+ t && i.set([
1298
+ t.size,
1299
+ t.width,
1300
+ 0,
1301
+ 0,
1302
+ ...$(t.color)
1303
+ ]);
1304
+ let a = new Float32Array(n.length * 10);
1305
+ n.forEach((e, t) => {
1306
+ let [n, r] = e.dash && e.dash.length >= 2 ? e.dash : [0, 0];
1307
+ a.set([
1308
+ e.x,
1309
+ e.y,
1310
+ e.r,
1311
+ e.width,
1312
+ ...$(e.color),
1313
+ n,
1314
+ r
1315
+ ], t * 10);
1316
+ });
1317
+ let o = new Float32Array(r.length * 14);
1318
+ return r.forEach((e, t) => {
1319
+ o.set([
1320
+ e.x,
1321
+ e.y,
1322
+ e.w,
1323
+ e.h,
1324
+ ...$(e.fill),
1325
+ ...$(e.stroke),
1326
+ e.radius,
1327
+ e.strokeWidth
1328
+ ], t * 14);
1329
+ }), {
1330
+ grid: {
1331
+ data: i,
1332
+ count: +!!t,
1333
+ stride: 8
1334
+ },
1335
+ rings: {
1336
+ data: a,
1337
+ count: n.length,
1338
+ stride: 10
1339
+ },
1340
+ lanes: {
1341
+ data: o,
1342
+ count: r.length,
1343
+ stride: 14
1344
+ }
1345
+ };
1346
+ }
1347
+ function Rt(e) {
1348
+ let t = {
1349
+ straight: [],
1350
+ curved: [],
1351
+ tips: [],
1352
+ packets: []
1353
+ };
1354
+ e.edges.forEach((e) => {
1355
+ let [n, r, i, a] = $(e.color), o = e.alpha, s = a * o, [c, l] = e.dash && e.dash.length >= 2 ? e.dash : [0, 0], u = e.glow > 0 && !!e.glowColor, [d, f, p, h] = u ? $(e.glowColor) : [
1356
+ 0,
1357
+ 0,
1358
+ 0,
1359
+ 0
1360
+ ], g = e.curve ? e.curve.cx : (e.x1 + e.x2) / 2, _ = e.curve ? e.curve.cy : (e.y1 + e.y2) / 2, v = e.mark && e.mark !== "none" ? 1 : 0;
1361
+ if (t[e.curve ? "curved" : "straight"].push([
1362
+ e.x1,
1363
+ e.y1,
1364
+ e.x2,
1365
+ e.y2,
1366
+ g,
1367
+ _,
1368
+ e.width,
1369
+ u ? e.glow : 0,
1370
+ n,
1371
+ r,
1372
+ i,
1373
+ s,
1374
+ d,
1375
+ f,
1376
+ p,
1377
+ h * s,
1378
+ c,
1379
+ l,
1380
+ v
1381
+ ]), e.arrow) {
1382
+ let a = Math.atan2(e.y2 - (e.curve ? e.curve.cy : e.y1), e.x2 - (e.curve ? e.curve.cx : e.x1)), o = e.end && e.end !== "triangle" && Ft(Mt, e.end) || Mt.arrow;
1383
+ t.tips.push([
1384
+ e.x2,
1385
+ e.y2,
1386
+ Math.cos(a),
1387
+ Math.sin(a),
1388
+ n,
1389
+ r,
1390
+ i,
1391
+ s,
1392
+ o
1393
+ ]);
1394
+ }
1395
+ if (e.ticks) {
1396
+ let a = m(e, .5), o = Math.hypot(e.x2 - e.x1, e.y2 - e.y1), [c, l] = o > 0 ? [(e.x2 - e.x1) / o, (e.y2 - e.y1) / o] : [1, 0];
1397
+ for (let o = 0; o < e.ticks; o++) {
1398
+ let u = (o - (e.ticks - 1) / 2) * z.tickGap;
1399
+ t.tips.push([
1400
+ a.x + c * u,
1401
+ a.y + l * u,
1402
+ c,
1403
+ l,
1404
+ n,
1405
+ r,
1406
+ i,
1407
+ s,
1408
+ Mt.tick
1409
+ ]);
1410
+ }
1411
+ }
1412
+ if (e.mark === "removed") {
1413
+ let a = m(e, .5), o = Math.hypot(e.x2 - e.x1, e.y2 - e.y1), [c, l] = o > 0 ? [(e.x2 - e.x1) / o, (e.y2 - e.y1) / o] : [1, 0];
1414
+ t.tips.push([
1415
+ a.x,
1416
+ a.y,
1417
+ c,
1418
+ l,
1419
+ n,
1420
+ r,
1421
+ i,
1422
+ s,
1423
+ Mt.strike
1424
+ ]);
1425
+ }
1426
+ if (e.packet) {
1427
+ let n = e.packet, [r, i, a, s] = $(n.color), [c, l, u, d] = $(n.glowColor);
1428
+ t.packets.push([
1429
+ e.x1,
1430
+ e.y1,
1431
+ e.x2,
1432
+ e.y2,
1433
+ g,
1434
+ _,
1435
+ n.speed,
1436
+ n.phase,
1437
+ r,
1438
+ i,
1439
+ a,
1440
+ s * o,
1441
+ c,
1442
+ l,
1443
+ u,
1444
+ d * s * o,
1445
+ n.radius,
1446
+ n.glow
1447
+ ]);
1448
+ }
1449
+ });
1450
+ let n = (e, t) => {
1451
+ let n = new Float32Array(e.length * t);
1452
+ return e.forEach((e, r) => n.set(e, r * t)), {
1453
+ data: n,
1454
+ count: e.length,
1455
+ stride: t
1456
+ };
1457
+ };
1458
+ return {
1459
+ straight: n(t.straight, 19),
1460
+ curved: n(t.curved, 19),
1461
+ tips: n(t.tips, 9),
1462
+ packets: n(t.packets, 18)
1463
+ };
1464
+ }
1465
+ var zt = (e) => ({
1466
+ ...Lt(e),
1467
+ nodes: It(e),
1468
+ ...Rt(e)
1469
+ });
1470
+ function Bt(e) {
1471
+ let t = [];
1472
+ e.nodes.forEach((e) => {
1473
+ if (!e.stroke) return;
1474
+ let [n, r, i, a] = $(e.stroke.color);
1475
+ t.push([
1476
+ e.x,
1477
+ e.y,
1478
+ Math.max(0, e.r - e.stroke.width / 2),
1479
+ e.stroke.width,
1480
+ n,
1481
+ r,
1482
+ i,
1483
+ a * e.alpha,
1484
+ 0,
1485
+ 0
1486
+ ]);
1487
+ });
1488
+ let n = new Float32Array(t.length * 10);
1489
+ return t.forEach((e, t) => n.set(e, t * 10)), {
1490
+ data: n,
1491
+ count: t.length,
1492
+ stride: 10
1493
+ };
1494
+ }
1495
+ function Vt(e, t, n = null) {
1496
+ let r = /* @__PURE__ */ new Map();
1497
+ e.nodes.forEach((e) => {
1498
+ let i = e.icon && t(e.icon) ? e.icon : null, a = e.r * le;
1499
+ if (!i && !e.icon && e.letters && t(pe(e.letters)) && (i = pe(e.letters), a = e.r * 1), !i && !e.icon && !e.letters && e.glyph) {
1500
+ let r = y(e.glyph, D(e, n));
1501
+ t(r) && (i = r, a = e.r * G);
1502
+ }
1503
+ if (!i) return;
1504
+ r.has(i) || r.set(i, {
1505
+ rows: [],
1506
+ minR: Infinity,
1507
+ maxR: 0
1508
+ });
1509
+ let o = r.get(i);
1510
+ o.maxR = Math.max(o.maxR, e.r), o.rows.push([
1511
+ e.x,
1512
+ e.y,
1513
+ a,
1514
+ e.alpha
1515
+ ]), o.minR = Math.min(o.minR, e.r);
1516
+ });
1517
+ let i = [], a = [];
1518
+ for (let [e, { rows: t, minR: n, maxR: o }] of r) i.push({
1519
+ kind: e,
1520
+ first: a.length,
1521
+ count: t.length,
1522
+ minR: n,
1523
+ maxR: o
1524
+ }), a.push(...t);
1525
+ let o = new Float32Array(a.length * 4);
1526
+ return a.forEach((e, t) => o.set(e, t * 4)), {
1527
+ data: o,
1528
+ count: a.length,
1529
+ stride: 4,
1530
+ groups: i
1531
+ };
1532
+ }
1533
+ function Ht(e = "dark", t = null) {
1534
+ let { halo: n, mark: r, core: s } = t ? a(i(e), t) : i(e), c = /* @__PURE__ */ new Float32Array(16), l = /* @__PURE__ */ new Float32Array(16), u = /* @__PURE__ */ new Float32Array(16);
1535
+ Object.entries(jt).forEach(([e, t]) => {
1536
+ let r = n[e];
1537
+ t && r && (c.set($(r.fill), t * 4), l.set($(r.ring), t * 4), u.set([
1538
+ r.fillR,
1539
+ r.ringR,
1540
+ r.ringWidth,
1541
+ 0
1542
+ ], t * 4));
1543
+ });
1544
+ let d = /* @__PURE__ */ new Float32Array(20), f = /* @__PURE__ */ new Float32Array(20);
1545
+ return Object.entries(Pt).forEach(([e, t]) => {
1546
+ if (!t) return;
1547
+ let n = r[e];
1548
+ d.set($(n.color), t * 4);
1549
+ let [i, a] = n.ringDash || [0, 0];
1550
+ f.set([
1551
+ n.ringR,
1552
+ n.ringWidth,
1553
+ i,
1554
+ a
1555
+ ], t * 4);
1556
+ }), {
1557
+ haloFill: c,
1558
+ haloRing: l,
1559
+ haloGeom: u,
1560
+ markColor: d,
1561
+ markGeom: f,
1562
+ markMin: new Float32Array([
1563
+ g.ring,
1564
+ g.edge,
1565
+ g.gap
1566
+ ]),
1567
+ core: new Float32Array($(s)),
1568
+ coreRatio: o
1569
+ };
1570
+ }
1571
+ var Ut = [
1572
+ {
1573
+ name: "grid",
1574
+ vert: pt,
1575
+ frag: mt,
1576
+ stride: 8,
1577
+ attribs: [[
1578
+ 1,
1579
+ 4,
1580
+ 0
1581
+ ], [
1582
+ 2,
1583
+ 4,
1584
+ 4
1585
+ ]]
1586
+ },
1587
+ {
1588
+ name: "lanes",
1589
+ vert: ht,
1590
+ frag: gt,
1591
+ stride: 14,
1592
+ attribs: [
1593
+ [
1594
+ 1,
1595
+ 4,
1596
+ 0
1597
+ ],
1598
+ [
1599
+ 2,
1600
+ 4,
1601
+ 4
1602
+ ],
1603
+ [
1604
+ 3,
1605
+ 4,
1606
+ 8
1607
+ ],
1608
+ [
1609
+ 4,
1610
+ 2,
1611
+ 12
1612
+ ]
1613
+ ]
1614
+ },
1615
+ {
1616
+ name: "rings",
1617
+ vert: _t,
1618
+ frag: vt,
1619
+ stride: 10,
1620
+ attribs: [
1621
+ [
1622
+ 1,
1623
+ 4,
1624
+ 0
1625
+ ],
1626
+ [
1627
+ 2,
1628
+ 4,
1629
+ 4
1630
+ ],
1631
+ [
1632
+ 3,
1633
+ 2,
1634
+ 8
1635
+ ]
1636
+ ]
1637
+ },
1638
+ {
1639
+ name: "straight",
1640
+ vert: Ct(1),
1641
+ frag: wt,
1642
+ stride: 19,
1643
+ verts: 8,
1644
+ attribs: [
1645
+ [
1646
+ 1,
1647
+ 4,
1648
+ 0
1649
+ ],
1650
+ [
1651
+ 2,
1652
+ 4,
1653
+ 4
1654
+ ],
1655
+ [
1656
+ 3,
1657
+ 4,
1658
+ 8
1659
+ ],
1660
+ [
1661
+ 4,
1662
+ 4,
1663
+ 12
1664
+ ],
1665
+ [
1666
+ 5,
1667
+ 2,
1668
+ 16
1669
+ ],
1670
+ [
1671
+ 6,
1672
+ 1,
1673
+ 18
1674
+ ]
1675
+ ],
1676
+ constants: "edges"
1677
+ },
1678
+ {
1679
+ name: "curved",
1680
+ vert: Ct(24),
1681
+ frag: wt,
1682
+ stride: 19,
1683
+ verts: 54,
1684
+ attribs: [
1685
+ [
1686
+ 1,
1687
+ 4,
1688
+ 0
1689
+ ],
1690
+ [
1691
+ 2,
1692
+ 4,
1693
+ 4
1694
+ ],
1695
+ [
1696
+ 3,
1697
+ 4,
1698
+ 8
1699
+ ],
1700
+ [
1701
+ 4,
1702
+ 4,
1703
+ 12
1704
+ ],
1705
+ [
1706
+ 5,
1707
+ 2,
1708
+ 16
1709
+ ],
1710
+ [
1711
+ 6,
1712
+ 1,
1713
+ 18
1714
+ ]
1715
+ ],
1716
+ constants: "edges"
1717
+ },
1718
+ {
1719
+ name: "tips",
1720
+ vert: Tt,
1721
+ frag: Et,
1722
+ stride: 9,
1723
+ attribs: [
1724
+ [
1725
+ 1,
1726
+ 4,
1727
+ 0
1728
+ ],
1729
+ [
1730
+ 2,
1731
+ 4,
1732
+ 4
1733
+ ],
1734
+ [
1735
+ 3,
1736
+ 1,
1737
+ 8
1738
+ ]
1739
+ ],
1740
+ constants: "tips"
1741
+ },
1742
+ {
1743
+ name: "packets",
1744
+ vert: Dt,
1745
+ frag: Ot,
1746
+ stride: 18,
1747
+ attribs: [
1748
+ [
1749
+ 1,
1750
+ 4,
1751
+ 0
1752
+ ],
1753
+ [
1754
+ 2,
1755
+ 4,
1756
+ 4
1757
+ ],
1758
+ [
1759
+ 3,
1760
+ 4,
1761
+ 8
1762
+ ],
1763
+ [
1764
+ 4,
1765
+ 4,
1766
+ 12
1767
+ ],
1768
+ [
1769
+ 5,
1770
+ 2,
1771
+ 16
1772
+ ]
1773
+ ],
1774
+ time: !0
1775
+ },
1776
+ {
1777
+ name: "nodes",
1778
+ vert: yt,
1779
+ frag: bt,
1780
+ stride: 12,
1781
+ attribs: [
1782
+ [
1783
+ 1,
1784
+ 4,
1785
+ 0
1786
+ ],
1787
+ [
1788
+ 2,
1789
+ 4,
1790
+ 4
1791
+ ],
1792
+ [
1793
+ 3,
1794
+ 4,
1795
+ 8
1796
+ ]
1797
+ ],
1798
+ constants: "nodes"
1799
+ }
1800
+ ], Wt = {
1801
+ nodes(e, t, n) {
1802
+ e.uniform4fv(t("u_haloFill"), n.haloFill), e.uniform4fv(t("u_haloRing"), n.haloRing), e.uniform4fv(t("u_haloGeom"), n.haloGeom), e.uniform4fv(t("u_markColor"), n.markColor), e.uniform4fv(t("u_markGeom"), n.markGeom), e.uniform3fv(t("u_markMin"), n.markMin), e.uniform4fv(t("u_core"), n.core), e.uniform1f(t("u_coreRatio"), n.coreRatio), e.uniform4f(t("u_shape"), v.roundedHalf, v.roundedCorner, v.hexInradius, v.squareHalf), e.uniform2f(t("u_shape2"), v.squareCorner, v.diamondHalf), e.uniform1f(t("u_glyphMin"), 14);
1803
+ },
1804
+ edges(e, t, n) {
1805
+ e.uniform3fv(t("u_markMin"), n.markMin);
1806
+ },
1807
+ tips(e, t) {
1808
+ e.uniform4f(t("u_tip"), s.length, s.spread, _.halfLength, _.width), e.uniform4f(t("u_end"), z.strokeWidth, z.barHalf, z.diamondHalf, z.diamondAcross), e.uniform2f(t("u_tick"), z.tickHalf, z.tickWidth);
1809
+ }
1810
+ }, Gt = {
1811
+ alpha: !0,
1812
+ premultipliedAlpha: !0,
1813
+ antialias: !1,
1814
+ depth: !1,
1815
+ stencil: !1,
1816
+ preserveDrawingBuffer: !1,
1817
+ powerPreference: "high-performance"
1818
+ };
1819
+ function Kt(e, t, n, r) {
1820
+ let i = e.createShader(t);
1821
+ if (e.shaderSource(i, n), e.compileShader(i), !e.getShaderParameter(i, e.COMPILE_STATUS)) {
1822
+ let t = e.getShaderInfoLog(i);
1823
+ throw e.deleteShader(i), Error(`${r} shader did not compile: ${t}`);
1824
+ }
1825
+ return i;
1826
+ }
1827
+ function qt(e, t, n, r) {
1828
+ let i = Kt(e, e.VERTEX_SHADER, t, `${r} vertex`), a = Kt(e, e.FRAGMENT_SHADER, n, `${r} fragment`), o = e.createProgram();
1829
+ if (e.attachShader(o, i), e.attachShader(o, a), e.linkProgram(o), e.deleteShader(i), e.deleteShader(a), !e.getProgramParameter(o, e.LINK_STATUS)) {
1830
+ let t = e.getProgramInfoLog(o);
1831
+ throw e.deleteProgram(o), Error(`${r} program did not link: ${t}`);
1832
+ }
1833
+ return o;
1834
+ }
1835
+ var Jt = (e) => !e || e.plain ? 0 : e.version;
1836
+ function Yt(e, t, n, r = null) {
1837
+ let i = Ht(n, r);
1838
+ t.passes.forEach((t) => {
1839
+ t.spec.constants && (e.useProgram(t.program), Wt[t.spec.constants](e, t.at, i));
1840
+ }), t.theme = n, t.styleKey = Jt(r);
1841
+ }
1842
+ function Xt(e, t, n) {
1843
+ let r = qt(e, t.vert, t.frag, t.name), i = e.createVertexArray(), a = e.createBuffer();
1844
+ e.bindVertexArray(i), t.verts || (e.bindBuffer(e.ARRAY_BUFFER, n), e.enableVertexAttribArray(0), e.vertexAttribPointer(0, 2, e.FLOAT, !1, 0, 0), e.vertexAttribDivisor(0, 0)), e.bindBuffer(e.ARRAY_BUFFER, a), t.attribs.forEach(([n, r, i]) => {
1845
+ e.enableVertexAttribArray(n), e.vertexAttribPointer(n, r, e.FLOAT, !1, t.stride * 4, i * 4), e.vertexAttribDivisor(n, 1);
1846
+ }), e.bindVertexArray(null);
1847
+ let o = (t) => e.getUniformLocation(r, t);
1848
+ return {
1849
+ spec: t,
1850
+ program: r,
1851
+ vao: i,
1852
+ buffer: a,
1853
+ at: o,
1854
+ count: 0,
1855
+ uniforms: {
1856
+ viewport: o("u_viewport"),
1857
+ cam: o("u_cam"),
1858
+ dpr: o("u_dpr"),
1859
+ time: t.time ? o("u_time") : null
1860
+ }
1861
+ };
1862
+ }
1863
+ var Zt = {
1864
+ strokes: {
1865
+ name: "strokes",
1866
+ vert: _t,
1867
+ frag: vt,
1868
+ stride: 10,
1869
+ attribs: [
1870
+ [
1871
+ 1,
1872
+ 4,
1873
+ 0
1874
+ ],
1875
+ [
1876
+ 2,
1877
+ 4,
1878
+ 4
1879
+ ],
1880
+ [
1881
+ 3,
1882
+ 2,
1883
+ 8
1884
+ ]
1885
+ ]
1886
+ },
1887
+ icons: {
1888
+ name: "icons",
1889
+ vert: kt,
1890
+ frag: At,
1891
+ stride: 4,
1892
+ attribs: [[
1893
+ 1,
1894
+ 4,
1895
+ 0
1896
+ ]]
1897
+ }
1898
+ };
1899
+ function Qt(e, t = "dark", n = null) {
1900
+ let r = e.createBuffer();
1901
+ e.bindBuffer(e.ARRAY_BUFFER, r), e.bufferData(e.ARRAY_BUFFER, new Float32Array([
1902
+ -1,
1903
+ -1,
1904
+ 1,
1905
+ -1,
1906
+ -1,
1907
+ 1,
1908
+ 1,
1909
+ 1
1910
+ ]), e.STATIC_DRAW);
1911
+ let i = {
1912
+ corners: r,
1913
+ passes: Ut.map((t) => Xt(e, t, r)),
1914
+ theme: t,
1915
+ styleKey: 0,
1916
+ extras: {
1917
+ strokes: null,
1918
+ icons: null
1919
+ },
1920
+ textures: /* @__PURE__ */ new Map(),
1921
+ iconStore: null
1922
+ };
1923
+ return Yt(e, i, t, n), i;
1924
+ }
1925
+ function $t(e, t) {
1926
+ e.deleteBuffer(t.corners), t.textures.forEach(({ texture: t }) => e.deleteTexture(t)), [...t.passes, ...Object.values(t.extras).filter(Boolean)].forEach((t) => {
1927
+ e.deleteProgram(t.program), e.deleteVertexArray(t.vao), e.deleteBuffer(t.buffer);
1928
+ });
1929
+ }
1930
+ function en(e, t = {}) {
1931
+ let n = t.gl || e.getContext("webgl2", Gt);
1932
+ if (!n) throw Error("WebGL2 is not available");
1933
+ let i = t.mapStyle || (() => x), a = {
1934
+ uploads: 0,
1935
+ draws: 0
1936
+ }, o = Qt(n), s = !1, c = 0, l = 0, u = null, d = null, f, p = null;
1937
+ function m(e) {
1938
+ return o.extras[e] || (o.extras[e] = Xt(n, Zt[e], o.corners)), o.extras[e];
1939
+ }
1940
+ function h() {
1941
+ o.passes.forEach((e) => {
1942
+ let t = u[e.spec.name];
1943
+ e.count = t.count, t.count && (n.bindBuffer(n.ARRAY_BUFFER, e.buffer), n.bufferData(n.ARRAY_BUFFER, t.data, n.DYNAMIC_DRAW));
1944
+ });
1945
+ for (let e of Object.keys(Zt)) {
1946
+ let t = u[e];
1947
+ if (!t.count && !o.extras[e]) continue;
1948
+ let r = m(e);
1949
+ r.count = t.count, t.count && (n.bindBuffer(n.ARRAY_BUFFER, r.buffer), n.bufferData(n.ARRAY_BUFFER, t.data, n.DYNAMIC_DRAW));
1950
+ }
1951
+ a.uploads++;
1952
+ }
1953
+ function g(e, t) {
1954
+ n.bindTexture(n.TEXTURE_2D, e), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, t ? n.NEAREST : n.LINEAR_MIPMAP_LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, t ? n.NEAREST : n.LINEAR);
1955
+ }
1956
+ function _(e, t, r) {
1957
+ let i = o.textures.get(e);
1958
+ if (!i || i.image !== t) {
1959
+ i && n.deleteTexture(i.texture);
1960
+ let r = n.createTexture();
1961
+ n.bindTexture(n.TEXTURE_2D, r), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), n.texImage2D(n.TEXTURE_2D, 0, n.RGBA, n.RGBA, n.UNSIGNED_BYTE, t), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), n.generateMipmap(n.TEXTURE_2D), i = {
1962
+ image: t,
1963
+ texture: r,
1964
+ pixelated: null
1965
+ }, o.textures.set(e, i);
1966
+ }
1967
+ return i.pixelated !== r && (g(i.texture, r), i.pixelated = r), i.texture;
1968
+ }
1969
+ function v(t, m, g) {
1970
+ if (p = [
1971
+ t,
1972
+ m,
1973
+ g
1974
+ ], s || !o || !c || !l) return;
1975
+ let v = i(), y = S(t, v), b = v.values ? v.values[A] : void 0;
1976
+ (o.iconStore !== v.icons || o.glyphInk !== b) && (o.textures.forEach(({ texture: e }) => n.deleteTexture(e)), o.textures.clear(), o.iconStore = v.icons, o.glyphInk = b, d = null), (y !== d || y.version !== f) && (u = {
1977
+ ...zt(y),
1978
+ strokes: Bt(y),
1979
+ icons: Vt(y, (e) => me(e) ? !!ve(he(e), b) : oe(e) ? !!E(r(e).type, r(e).ink) : !!(v.icons && v.icons.get(e)), v)
1980
+ }, d = y, f = y.version, h());
1981
+ let x = y.theme || "dark";
1982
+ (o.theme !== x || o.styleKey !== Jt(v)) && Yt(n, o, x, v), n.viewport(0, 0, e.width, e.height), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.enable(n.BLEND), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), o.passes.forEach((t) => {
1983
+ t.count && (n.useProgram(t.program), n.uniform2f(t.uniforms.viewport, c, l), n.uniform3f(t.uniforms.cam, m.x, m.y, m.zoom), n.uniform1f(t.uniforms.dpr, e.width / c), n.bindVertexArray(t.vao), t.uniforms.time && n.uniform1f(t.uniforms.time, (g || 0) / 1e3), n.drawArraysInstanced(n.TRIANGLE_STRIP, 0, t.spec.verts || 4, t.count), a.draws++);
1984
+ });
1985
+ let C = o.extras.strokes;
1986
+ C && C.count && (n.useProgram(C.program), n.uniform2f(C.uniforms.viewport, c, l), n.uniform3f(C.uniforms.cam, m.x, m.y, m.zoom), n.uniform1f(C.uniforms.dpr, e.width / c), n.bindVertexArray(C.vao), n.drawArraysInstanced(n.TRIANGLE_STRIP, 0, 4, C.count), a.draws++);
1987
+ let w = o.extras.icons;
1988
+ if (w && w.count) {
1989
+ n.useProgram(w.program), n.uniform2f(w.uniforms.viewport, c, l), n.uniform3f(w.uniforms.cam, m.x, m.y, m.zoom), n.uniform1f(w.uniforms.dpr, e.width / c), n.uniform1i(w.at("u_tex"), 0), n.activeTexture(n.TEXTURE0), n.bindVertexArray(w.vao), n.bindBuffer(n.ARRAY_BUFFER, w.buffer);
1990
+ for (let e of u.icons.groups) {
1991
+ let t = me(e.kind), i = oe(e.kind), o = t || i ? 14 : 0;
1992
+ if (o && e.maxR * 2 * m.zoom < o) continue;
1993
+ n.uniform1f(w.at("u_minR"), o / 2), n.uniform1f(w.at("u_sideRatio"), t ? 1 : i ? G : 1);
1994
+ let s = t ? ve(he(e.kind), v.values && v.values["--corn-map-glyph"]) : i ? E(r(e.kind).type, r(e.kind).ink) : v.icons && v.icons.get(e.kind);
1995
+ s && (n.bindTexture(n.TEXTURE_2D, _(e.kind, s, !!v.pixelated && !t && !i)), n.vertexAttribPointer(1, 4, n.FLOAT, !1, 16, e.first * 4 * 4), n.drawArraysInstanced(n.TRIANGLE_STRIP, 0, 4, e.count), a.draws++);
1996
+ }
1997
+ }
1998
+ n.bindVertexArray(null);
1999
+ }
2000
+ let y = (e) => {
2001
+ e.preventDefault(), s = !0, o = null;
2002
+ }, b = () => {
2003
+ try {
2004
+ o = Qt(n, p && p[0].theme || "dark", i()), s = !1, u && h(), p && v(...p);
2005
+ } catch (e) {
2006
+ console.warn("WebGL2 context restored but the renderer could not be rebuilt:", e.message);
2007
+ }
2008
+ };
2009
+ return e.addEventListener("webglcontextlost", y), e.addEventListener("webglcontextrestored", b), {
2010
+ kind: "webgl2",
2011
+ stats: a,
2012
+ resize(t, n, r) {
2013
+ c = t, l = n, e.width = Math.round(t * r), e.height = Math.round(n * r), p && v(...p);
2014
+ },
2015
+ draw: v,
2016
+ destroy: C,
2017
+ release() {
2018
+ let e = s;
2019
+ C();
2020
+ try {
2021
+ let t = !e && n.getExtension ? n.getExtension("WEBGL_lose_context") : null;
2022
+ t && t.loseContext();
2023
+ } catch {}
2024
+ }
2025
+ };
2026
+ function C() {
2027
+ e.removeEventListener("webglcontextlost", y), e.removeEventListener("webglcontextrestored", b), o && !s && $t(n, o), o = null, s = !0;
2028
+ }
2029
+ }
2030
+ // ../explorer/renderer.js
2031
+ function tn(e) {
2032
+ let t = e.ownerDocument.createElement("canvas");
2033
+ return t.className = "hx-overlay", t.setAttribute("data-corn", "map-overlay"), t.setAttribute("part", "map-overlay"), t.setAttribute("aria-hidden", "true"), e.after(t), t;
2034
+ }
2035
+ function nn(e, t = {}) {
2036
+ let n = t.prefer || null, r = t.mapStyle ? { mapStyle: t.mapStyle } : {};
2037
+ if (n === "canvas2d") return Fe(e, r);
2038
+ let i = null;
2039
+ try {
2040
+ i = e.getContext("webgl2", Gt);
2041
+ } catch {}
2042
+ if (!i) return Fe(e, r);
2043
+ try {
2044
+ return en(e, {
2045
+ gl: i,
2046
+ ...r
2047
+ });
2048
+ } catch (n) {
2049
+ console.warn(`WebGL2 renderer unavailable, drawing with Canvas 2D: ${n.message}`);
2050
+ let i = (t.makeStandIn || tn)(e), a = Fe(i, r);
2051
+ return {
2052
+ ...a,
2053
+ destroy() {
2054
+ a.destroy(), i.remove();
2055
+ }
2056
+ };
2057
+ }
2058
+ }
2059
+ // ../explorer/cluster.js
2060
+ function rn(e, t) {
2061
+ let n = /* @__PURE__ */ new Map();
2062
+ for (let e of t) !e.kind && !e.dashed && e.from && e.to && (n.get(e.from) || n.set(e.from, []).get(e.from)).push(e.to);
2063
+ let r = /* @__PURE__ */ new Set([e]), i = [e];
2064
+ for (; i.length;) for (let e of n.get(i.pop()) || []) r.has(e) || (r.add(e), i.push(e));
2065
+ return r;
2066
+ }
2067
+ // ../explorer/input.js
2068
+ function an(e) {
2069
+ let { state: t } = e, { render: n, getSpatialIndex: r, queueFrameWork: i, screenToWorld: a, getMinZoom: o, setHoverNode: s, labelNodeAt: c, fitGraphToViewport: u, fitPadding: d } = e.map, f = (t) => e.emit("select", t), m = () => e.emit("background"), g = () => e.emit("grab"), _ = !1, v = null, y = {
2070
+ x: 0,
2071
+ y: 0
2072
+ }, b = {
2073
+ x: 0,
2074
+ y: 0
2075
+ }, x = !1, S = null, C = null, w = 0, E = null, D = !1, O = null, k = null, A = null, j = !1, M = "", N = () => t.isFreeform && t.view === "orbit";
2076
+ function P(e) {
2077
+ let n = t.canvas.getBoundingClientRect(), r = e.touches ? e.touches[0] : e, i = n.width && t.width ? t.width / n.width : 1, a = n.height && t.height ? t.height / n.height : 1;
2078
+ return {
2079
+ x: (r.clientX - n.left) * i,
2080
+ y: (r.clientY - n.top) * a
2081
+ };
2082
+ }
2083
+ let F = {
2084
+ nodes: null,
2085
+ size: -1,
2086
+ map: null
2087
+ };
2088
+ function I(e) {
2089
+ return (F.nodes !== t.nodes || F.size !== t.nodes.length) && (F = {
2090
+ nodes: t.nodes,
2091
+ size: t.nodes.length,
2092
+ map: new Map(t.nodes.map((e) => [e.id, e]))
2093
+ }), F.map.get(e) || null;
2094
+ }
2095
+ function ee(e, n, i) {
2096
+ let a = Re(r(), t.camera, e, n, i);
2097
+ return a ? I(a.id) : null;
2098
+ }
2099
+ let te = (e) => Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY);
2100
+ function ne(e) {
2101
+ let n = t.canvas.getBoundingClientRect();
2102
+ return {
2103
+ x: (e.touches[0].clientX + e.touches[1].clientX) / 2 - n.left,
2104
+ y: (e.touches[0].clientY + e.touches[1].clientY) / 2 - n.top
2105
+ };
2106
+ }
2107
+ function L(e) {
2108
+ if (D = !0, g(), s(null), e.touches && e.touches.length === 2) {
2109
+ E = l(t.camera, te(e), ne(e)), O = null, _ = !1, v = null, S = null;
2110
+ return;
2111
+ }
2112
+ let n = !!(e.touches && e.touches.length > 0), r = P(e);
2113
+ b = {
2114
+ x: r.x,
2115
+ y: r.y
2116
+ }, x = !1, O = null, S = ee(r.x, r.y, n), N() && S ? (v = S, e.cancelable && e.preventDefault()) : (_ = !0, y = r);
2117
+ }
2118
+ function R() {
2119
+ k && E && Object.assign(t.camera, T(E, k.dist, k.mid, o())), k = null;
2120
+ let n = O;
2121
+ if (O = null, n) {
2122
+ if (v && N()) {
2123
+ let r = a(n.x, n.y);
2124
+ v.x = r.x, v.y = r.y, t.freeformPositions[v.id] = {
2125
+ x: r.x,
2126
+ y: r.y
2127
+ }, e.touchScene(), ue(e);
2128
+ } else _ && (t.camera.x += n.x - y.x, t.camera.y += n.y - y.y, y = n);
2129
+ }
2130
+ }
2131
+ function z() {
2132
+ let e = A;
2133
+ if (A = null, !e || _ || v) return;
2134
+ let t = ee(e.x, e.y, !1);
2135
+ B(!!t), s(t ? t.id : null);
2136
+ }
2137
+ function B(e) {
2138
+ e !== j && t.canvas && (e && (M = t.canvas.style.cursor), j = e, t.canvas.style.cursor = e ? "pointer" : M);
2139
+ }
2140
+ function V(e) {
2141
+ if (e.touches && e.touches.length === 2 && E) {
2142
+ e.cancelable && e.preventDefault(), k = {
2143
+ dist: te(e),
2144
+ mid: ne(e)
2145
+ }, i(R);
2146
+ return;
2147
+ }
2148
+ let t = P(e);
2149
+ Math.hypot(t.x - b.x, t.y - b.y) > 8 && (x = !0), v && N() || _ ? (e.cancelable && e.preventDefault(), O = t, i(R)) : e.touches || (A = t, i(z, { draw: !1 }));
2150
+ }
2151
+ function H(e) {
2152
+ R();
2153
+ let n = !!(e.changedTouches && e.changedTouches.length > 0), r = t.canvas.getBoundingClientRect(), i = n ? {
2154
+ x: e.changedTouches[0].clientX - r.left,
2155
+ y: e.changedTouches[0].clientY - r.top
2156
+ } : P(e);
2157
+ if (!x && D) {
2158
+ if (S) {
2159
+ let e = ee(i.x, i.y, n);
2160
+ if (e && e.id === S.id) {
2161
+ if (!N()) f(S);
2162
+ else {
2163
+ let e = Date.now();
2164
+ C && C.id === S.id && e - w < 380 ? (f(S), C = null, w = 0) : (C = S, w = e);
2165
+ }
2166
+ }
2167
+ } else {
2168
+ let e = I(c(i.x, i.y));
2169
+ e && h.includes(e.type) && e.id !== "root" ? u(d(), rn(e.id, t.edges)) : t.selectedNode && m();
2170
+ }
2171
+ }
2172
+ _ = !1, v = null, S = null, E = null, k = null, D = !1;
2173
+ }
2174
+ let { canvas: U } = t, W = !(e.root && e.root.nodeType === 9), G = (r) => {
2175
+ if (W && !r.ctrlKey && !r.metaKey && e.active() !== t.canvas) return;
2176
+ r.preventDefault(), g();
2177
+ let i = P(r);
2178
+ Object.assign(t.camera, p(t.camera, r.deltaY < 0 ? 1.12 : .88, i.x, i.y, o())), n();
2179
+ }, re = e.root || U, ie = [
2180
+ e.listen(U, "mousedown", L),
2181
+ e.listen(U, "mousemove", V),
2182
+ e.listen(U, "mouseleave", () => {
2183
+ A = null, B(!1), s(null);
2184
+ }),
2185
+ e.listen(re, "mouseup", H),
2186
+ e.listen(U, "touchstart", L, { passive: !1 }),
2187
+ e.listen(U, "touchmove", V, { passive: !1 }),
2188
+ e.listen(re, "touchend", H, { passive: !1 }),
2189
+ e.listen(re, "touchcancel", H, { passive: !1 }),
2190
+ e.listen(U, "wheel", G, { passive: !1 })
2191
+ ];
2192
+ return () => ie.forEach((e) => e());
2193
+ }
2194
+ // ../explorer/flow-build.js
2195
+ function on(e, t) {
2196
+ let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map();
2197
+ t.forEach((e) => {
2198
+ !e.kind && !e.dashed && n.get(e.from)?.type === "app" && n.get(e.to)?.type === "page" && r.set(e.to, e.from);
2199
+ });
2200
+ let i = e.filter((e) => e.type === "container" && e.selfHosted), a = /* @__PURE__ */ new Map();
2201
+ t.forEach((e) => {
2202
+ let t = n.get(e.from);
2203
+ if (e.kind !== "delivers" || t?.type !== "container" || t.selfHosted || n.get(e.to)?.type !== "page") return;
2204
+ let r = i.filter((e) => e.stack === t.stack);
2205
+ r.length === 1 && a.set(t.id, r[0].id);
2206
+ });
2207
+ let o = (e) => n.get(e)?.type === "page" ? r.get(e) || e : a.get(e) || e, s = new Set([...r].filter(([e]) => Array.isArray(n.get(e)?.methods) && n.get(e).methods.length).map(([, e]) => e)), c = (e) => e.type === "store" && (e.tier === "browser" || e.id === "store-idb"), l = /* @__PURE__ */ new Set();
2208
+ t.forEach((e) => {
2209
+ if (e.kind === "reads" || e.kind === "writes") {
2210
+ let t = e.kind === "reads" ? e.to : e.from;
2211
+ n.get(t)?.type === "page" && l.add(o(t));
2212
+ }
2213
+ }), t.forEach((e) => {
2214
+ e.kind === "flow" && e.flow === "api" && n.get(e.from)?.type === "app" && l.add(e.from);
2215
+ });
2216
+ let u = new Set(t.filter((e) => e.kind === "flow" && e.flow === "api").map((e) => `${o(e.from)}|${o(e.to)}`)), d = (t) => e.filter(t).sort((e, t) => String(e.label).localeCompare(String(t.label))), f = [
2217
+ {
2218
+ key: "browser",
2219
+ title: "Browser",
2220
+ note: "saved on the device first",
2221
+ nodes: d(c)
2222
+ },
2223
+ {
2224
+ key: "servers",
2225
+ title: "App servers",
2226
+ note: "pages, no-JS forms",
2227
+ nodes: d((e) => e.type === "app" && !s.has(e.id) && l.has(e.id))
2228
+ },
2229
+ {
2230
+ key: "api",
2231
+ title: "API",
2232
+ note: "where the endpoints are",
2233
+ nodes: d((e) => s.has(e.id))
2234
+ },
2235
+ {
2236
+ key: "tables",
2237
+ title: "Tables",
2238
+ note: "stores and tables",
2239
+ nodes: [...d((e) => e.type === "store" && !c(e)), ...d((e) => e.type === "table")]
2240
+ },
2241
+ {
2242
+ key: "services",
2243
+ title: "Services",
2244
+ note: "jobs, hooks, webhooks",
2245
+ nodes: d((e) => e.type === "service")
2246
+ },
2247
+ {
2248
+ key: "outside",
2249
+ title: "Outside",
2250
+ note: "systems the API reaches",
2251
+ nodes: [...d((e) => e.type === "external"), ...d((e) => e.type === "container" && e.selfHosted)]
2252
+ }
2253
+ ], p = new Set(f.flatMap((e) => e.nodes.map((e) => e.id))), m = [], h = /* @__PURE__ */ new Set(), g = (e, t, n) => {
2254
+ if (t === n || !p.has(t) || !p.has(n)) return;
2255
+ let r = `${t}|${n}|${e.kind}|${e.flow || ""}`;
2256
+ h.has(r) || (h.add(r), m.push({
2257
+ ...e,
2258
+ from: t,
2259
+ to: n,
2260
+ status: e.status || "live",
2261
+ phase: void 0
2262
+ }));
2263
+ };
2264
+ return t.forEach((e) => {
2265
+ if (!(e.kind === "calls" && u.has(`${o(e.from)}|${o(e.to)}`)) && (e.kind !== "calls" || n.get(e.from)?.type !== "container")) {
2266
+ if (e.kind === "flow" || [
2267
+ "calls",
2268
+ "triggers",
2269
+ "delivers"
2270
+ ].includes(e.kind)) return g(e, o(e.from), o(e.to));
2271
+ if (e.kind === "reads" || e.kind === "writes") {
2272
+ let t = e.kind === "reads" ? e.to : e.from;
2273
+ return n.get(t)?.type === "page" && !s.has(o(t)) ? void 0 : g(e, o(e.from), o(e.to));
2274
+ }
2275
+ }
2276
+ }), {
2277
+ tiers: f,
2278
+ ids: p,
2279
+ edges: m
2280
+ };
2281
+ }
2282
+ // ../explorer/pieces/map.js
2283
+ var sn = "Arrow keys pan, plus and minus zoom, 0 fits the map. N and P select the next and the previous node, Home and End the first and the last. F frames the selected node and what it lights. Escape clears the selection.", cn = "<canvas id=\"graph-canvas\" data-corn=\"map-canvas\" tabindex=\"0\" role=\"application\" aria-roledescription=\"map\" aria-label=\"Topology map\" aria-describedby=\"map-keys-help\"></canvas>", ln = ({ keysHelp: e = sn } = {}) => ({ stage: `${cn}
2284
+ <p id="map-keys-help" class="hx-sr-only">${P(e)}</p>
2285
+ <p id="map-announcer" class="hx-sr-only" role="status" aria-live="polite"></p>
2286
+ <canvas id="label-canvas" data-corn="label-canvas" aria-hidden="true"></canvas>` });
2287
+ function un(e, t, n) {
2288
+ let r = j(t, e, "<div data-corn=\"map-stage\"></div>", null, "stage"), i = n.mountStatus(r[0], t, { follow: !1 });
2289
+ i.refuse("second-map"), t.emit("piece:refused", {
2290
+ piece: "map",
2291
+ reason: "second-map",
2292
+ message: "A scope holds one map.",
2293
+ host: e.nodeType === 11 ? e.host : e
2294
+ });
2295
+ let a = () => {};
2296
+ return {
2297
+ inst: t,
2298
+ refused: !0,
2299
+ update: a,
2300
+ fit: a,
2301
+ refresh: a,
2302
+ focusNode: () => !1,
2303
+ applyTheme: a,
2304
+ destroy() {
2305
+ i.destroy();
2306
+ for (let e of r) e.remove();
2307
+ }
2308
+ };
2309
+ }
2310
+ function dn(e) {
2311
+ let t = e.nodeType === 11 ? e.host : e;
2312
+ return t && typeof t.getRootNode == "function" ? t.getRootNode() : null;
2313
+ }
2314
+ function fn(e, t, n = {}) {
2315
+ return !t && n.src !== void 0 && n.src !== null && n.src !== "" ? pn(e, n) : mn(e, t, n, null);
2316
+ }
2317
+ function pn(e, t) {
2318
+ let n = e.nodeType === 11 ? e.host : e, r = {}, i = null, a = !1;
2319
+ return import("./scope-vxRGj-2V.js").then((e) => e.n).then(({ mountScope: o }) => {
2320
+ if (a) return;
2321
+ let s = o(n, {
2322
+ src: t.src,
2323
+ theme: t.theme,
2324
+ useTheme: t.useTheme,
2325
+ tokens: t.tokens,
2326
+ version: t.version,
2327
+ pageUrl: t.pageUrl,
2328
+ onAuth: t.onAuth,
2329
+ onError: t.onError
2330
+ });
2331
+ i = mn(e, s.instance, {
2332
+ ...t,
2333
+ ...r
2334
+ }, s);
2335
+ }, (e) => {
2336
+ !a && t.onError && t.onError({
2337
+ kind: "offline",
2338
+ message: `the map's loader did not load: ${e && e.message ? e.message : e}`
2339
+ });
2340
+ }), {
2341
+ get inst() {
2342
+ return i ? i.inst : null;
2343
+ },
2344
+ get map() {
2345
+ return i ? i.map : null;
2346
+ },
2347
+ update(e = {}) {
2348
+ i ? i.update(e) : Object.assign(r, e);
2349
+ },
2350
+ fit() {
2351
+ i && i.fit();
2352
+ },
2353
+ focusNode(e) {
2354
+ return i ? i.focusNode(e) : !1;
2355
+ },
2356
+ refresh() {
2357
+ i && i.refresh();
2358
+ },
2359
+ applyTheme(e) {
2360
+ return i ? i.applyTheme(e) : null;
2361
+ },
2362
+ destroy() {
2363
+ a || (a = !0, i && i.destroy(), i = null);
2364
+ }
2365
+ };
2366
+ }
2367
+ function mn(e, t, n, r) {
2368
+ let i = !t;
2369
+ i && (t = ee({
2370
+ root: e,
2371
+ base: n.base || "",
2372
+ fetch: n.fetch,
2373
+ strings: n.strings
2374
+ }));
2375
+ let a = U(t), o = () => {};
2376
+ if (a) try {
2377
+ o = t.attach(e);
2378
+ } catch {
2379
+ return r && r.destroy(), un(e, t, a);
2380
+ }
2381
+ let { state: s } = t, c = a ? a.source : null;
2382
+ if (n.tokens) {
2383
+ let t = dn(e);
2384
+ t && ie(t.nodeType === 9 ? t : t.ownerDocument, n.tokens), t && t.nodeType === 11 && ie(t, n.tokens);
2385
+ }
2386
+ let l = B(t);
2387
+ l.own(o), r && l.own(() => r.destroy());
2388
+ let u = (e) => e === "canvas2d" ? "canvas2d" : "auto", d = (e) => e === "light" || e === "dark" ? e : "auto", f = {
2389
+ renderer: u(n.renderer),
2390
+ theme: d(n.theme),
2391
+ topology: void 0
2392
+ }, p = n.topology !== void 0 && n.topology !== null, m = !1, h = !1, g = ln({ keysHelp: n.keysHelp }).stage, _ = n.slots && n.slots.stage ? n.slots : null, v = j(t, e, _ ? g : `<div data-corn="map-stage">${g}</div>`, _, "stage"), y = (e) => v.map((t) => t.matches(e) ? t : t.querySelector(e)).find(Boolean);
2393
+ l.own(() => {
2394
+ for (let e of [...v, s.canvas]) e && e.remove();
2395
+ });
2396
+ let b = v.find((e) => e.matches("[data-corn=\"map-stage\"]")) || null;
2397
+ if (c && b) {
2398
+ let e = a.mountStatus(b, t, {
2399
+ onRetry: () => c.load(),
2400
+ focusMap: () => {
2401
+ s.canvas && s.canvas.focus();
2402
+ }
2403
+ });
2404
+ l.own(e.destroy);
2405
+ }
2406
+ s.canvas = y("[data-corn=\"map-canvas\"]"), s.labelCanvas = y("[data-corn=\"label-canvas\"]"), s.ctx = t.doc.createElement("canvas").getContext("2d");
2407
+ let x = ft(t, n.measureCovered ? { measureCovered: n.measureCovered } : {}), S = ce(t);
2408
+ l.own(S.watch()), l.own(S.onChange(() => x.render()));
2409
+ let C = () => f.renderer === "canvas2d" ? "canvas2d" : null, w = () => x.setRenderer(nn(s.canvas, {
2410
+ prefer: C(),
2411
+ mapStyle: S.get
2412
+ })), T = t.win && t.win.matchMedia ? t.win.matchMedia("(prefers-color-scheme: light)") : null;
2413
+ function E() {
2414
+ if (f.theme === "light" || f.theme === "dark") return f.theme;
2415
+ if (a && (a.theme === "light" || a.theme === "dark")) return a.theme;
2416
+ let e = t.doc && t.doc.documentElement, n = e ? e.getAttribute("data-theme") : null;
2417
+ return n === "light" || n === "dark" ? n : re("system", !!(T && T.matches));
2418
+ }
2419
+ function D() {
2420
+ if (m) return;
2421
+ let e = E();
2422
+ S.refresh(), s.theme !== e && (s.theme = e, t.touchScene()), x.render();
2423
+ }
2424
+ s.theme = E(), a && l.own(a.serverTheme.adopt(e)), a && (l.on("theme", () => D()), l.on("scope:theme", () => D())), T && T.addEventListener && (T.addEventListener("change", D), l.own(() => T.removeEventListener("change", D)));
2425
+ let k = t.win && t.win.MutationObserver;
2426
+ if (k && t.doc && t.doc.documentElement) {
2427
+ let e = new k(D);
2428
+ e.observe(t.doc.documentElement, {
2429
+ attributes: !0,
2430
+ attributeFilter: ["data-theme", "class"]
2431
+ }), l.own(() => e.disconnect());
2432
+ }
2433
+ w();
2434
+ function A() {
2435
+ te(t), s.view === "dataflow" && s.flow ? (s.flow.tiers.forEach((e) => e.nodes.forEach((e) => {
2436
+ e.r = Math.min(e.r, 13);
2437
+ })), O(t, s.flow)) : se(t);
2438
+ }
2439
+ let M = !1, P = () => {
2440
+ s.nodes.length && (M = !s.width || !s.height, M || x.fitGraphToViewport(x.fitPadding()));
2441
+ }, F = (e) => s.nodes.find((t) => t.id === e) || null, L = null;
2442
+ l.on("select", (e) => V(t, e, { source: "tap" })), l.on("background", () => W(t, { source: "tap" })), l.on("grab", () => ne(t)), l.on("selection", ({ node: e, edge: t, source: r }) => {
2443
+ m || ((e || t) && (L = null), n.onSelect && (e ? n.onSelect({
2444
+ id: e.id,
2445
+ kind: "node",
2446
+ source: r
2447
+ }) : t ? n.onSelect({
2448
+ id: `${t.from}->${t.to}`,
2449
+ kind: "edge",
2450
+ from: t.from,
2451
+ to: t.to,
2452
+ source: r
2453
+ }) : n.onSelect({
2454
+ id: null,
2455
+ kind: null,
2456
+ source: r
2457
+ })));
2458
+ });
2459
+ function R(e) {
2460
+ let n = F(String(e));
2461
+ return !n || m ? !1 : (V(t, n, {
2462
+ frame: !0,
2463
+ source: "api"
2464
+ }), !0);
2465
+ }
2466
+ let z = () => {}, H = !!t.root && t.root.nodeType === 9;
2467
+ function G() {
2468
+ let e = s.canvas, n = [an(t)];
2469
+ H || n.push(t.listen(e, "pointerdown", (t) => {
2470
+ if (t.pointerType === "mouse" && e.setPointerCapture) try {
2471
+ e.setPointerCapture(t.pointerId);
2472
+ } catch {}
2473
+ })), I(t), N(t), n.push(() => I(t)), z = () => n.forEach((e) => e());
2474
+ }
2475
+ l.own(x.onPaint(() => {
2476
+ M && s.width && s.height && P(), !h && s.nodes.length && (h = !0, n.onReady && n.onReady());
2477
+ })), G(), l.own(() => z());
2478
+ let ae = () => {
2479
+ !p && c && c.topology && c.topology !== f.topology && (f.topology = c.topology, oe(c.topology));
2480
+ };
2481
+ c && l.on("source", (e) => {
2482
+ e.state === "ready" && ae();
2483
+ }), l.own(x.watchSize()), x.resize();
2484
+ function oe(e) {
2485
+ let n = e && Array.isArray(e.nodes) ? e.nodes.filter((e) => e && typeof e.id == "string") : [], r = e && Array.isArray(e.edges) ? e.edges.filter((e) => e && typeof e.from == "string" && typeof e.to == "string") : [], i = s.selectedNode ? s.selectedNode.id : null;
2486
+ s.baseNodes = n, s.baseEdges = r, s.nodes = n.map((e) => ({ ...e })), s.edges = r.map((e) => ({ ...e })), s.mapNodes = s.nodes, s.mapEdges = s.edges, s.flow = on(s.nodes, s.edges);
2487
+ let a = i ? F(i) : null;
2488
+ a ? (s.selectedEdge = null, s.selectedNode = a) : (s.selectedNode || s.selectedEdge) && (s.selectedNode = null, s.selectedEdge = null), t.touchScene(), s.nodes.length && (A(), P());
2489
+ let o = !a && L ? F(L) : null;
2490
+ o && V(t, o, { source: "api" }), x.render(), x.ensureFlowLoop();
2491
+ }
2492
+ function le(e) {
2493
+ let n = e === "dataflow" ? "dataflow" : "orbit";
2494
+ s.view !== n && (s.view = n, t.touchScene(), s.nodes.length && (A(), P(), x.ensureFlowLoop()));
2495
+ }
2496
+ function ue() {
2497
+ let e = x.getRenderer();
2498
+ e.release ? e.release() : e.destroy(), z();
2499
+ let n = t.doc.createElement("template");
2500
+ n.innerHTML = cn;
2501
+ let r = n.content.firstElementChild;
2502
+ r.setAttribute("part", "map-canvas");
2503
+ let i = t.active() === s.canvas;
2504
+ s.canvas.replaceWith(r), s.canvas = r, G(), w(), x.resize(), i && r.focus();
2505
+ }
2506
+ function de(e = {}) {
2507
+ if (!m) {
2508
+ if ("renderer" in e) {
2509
+ let t = u(e.renderer);
2510
+ t !== f.renderer && (f.renderer = t, ue());
2511
+ }
2512
+ if ("theme" in e) {
2513
+ let t = d(e.theme);
2514
+ t !== f.theme && (f.theme = t, D());
2515
+ }
2516
+ if ("topology" in e && (p = e.topology !== void 0 && e.topology !== null, p && e.topology !== f.topology ? (f.topology = e.topology, oe(e.topology)) : !p && c && c.topology ? (f.topology = void 0, ae()) : !p && e.topology !== f.topology && (f.topology = e.topology, oe(e.topology))), "view" in e && le(e.view === "dataflow" ? "dataflow" : "orbit"), "node" in e) {
2517
+ let n = e.node == null || e.node === "" ? null : String(e.node);
2518
+ if (n === null) L = null, (s.selectedNode || s.selectedEdge) && W(t, { source: "api" });
2519
+ else {
2520
+ let e = F(n);
2521
+ e ? s.selectedNode && s.selectedNode.id === n || V(t, e, { source: "api" }) : L = n;
2522
+ }
2523
+ }
2524
+ }
2525
+ }
2526
+ function K() {
2527
+ m || (m = !0, l.destroy(), x.destroy(), i && t.destroy());
2528
+ }
2529
+ let fe = {};
2530
+ for (let e of [
2531
+ "topology",
2532
+ "view",
2533
+ "node"
2534
+ ]) n[e] !== void 0 && (fe[e] = n[e]);
2535
+ return de(fe), ae(), D(), {
2536
+ inst: t,
2537
+ map: x,
2538
+ update: de,
2539
+ destroy: K,
2540
+ fit: P,
2541
+ focusNode: R,
2542
+ refresh: D,
2543
+ applyTheme: (e) => S.applyTheme(e)
2544
+ };
2545
+ }
2546
+ // \0stencil-css:/home/runner/work/CornField/CornField/explorer/pieces/map-stage?tag=corn-map&encapsulation=shadow&__ext=css
2547
+ var hn = () => "[data-corn=map-stage]{background:var(--corn-ground-image), var(--corn-ground);width:100%;height:100%;min-height:16rem;display:block;position:relative;overflow:hidden}[data-corn=map-canvas]{cursor:grab;touch-action:none;width:100%;height:100%;display:block;position:absolute;inset:0}[data-corn=map-canvas]:active{cursor:grabbing}[data-corn=map-canvas]:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:calc(var(--corn-focus-width) * -1)}[data-corn=label-canvas]{pointer-events:none;width:100%;height:100%;position:absolute;inset:0}[data-corn=map-overlay]{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.hx-sr-only{clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;overflow:hidden;position:absolute!important}", gn = () => "[data-corn=source-status]{z-index:2;box-sizing:border-box;align-items:center;gap:var(--corn-space-3);width:min(26rem, calc(100% - var(--corn-space-6) * 2));padding:var(--corn-space-6);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius-lg);background:var(--corn-surface-1);color:var(--corn-text-2);box-shadow:var(--corn-shadow);text-align:center;font-family:var(--corn-font);font-size:var(--corn-text-md);flex-direction:column;line-height:1.5;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}[data-corn=source-status][hidden]{display:none}[data-corn=source-status]:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}[data-corn=source-status][data-corn-state=running]{box-shadow:none;color:var(--corn-text-3);background:0 0;border-color:#0000;padding:0}[data-corn=source-status][data-corn-state=running] [data-corn=source-title]{font-size:var(--corn-text-md);color:var(--corn-text-3);font-weight:400}[data-corn=source-status][data-corn-state=failure] [data-corn=source-title]{color:var(--corn-bad)}[data-corn=source-status][data-corn-state=waiting] [data-corn=source-title]{color:var(--corn-accent-text)}[data-corn=source-title],[data-corn=source-text]{margin:0}[data-corn=source-title]{font-size:var(--corn-text-lg);color:var(--corn-text);font-weight:600}[data-corn=source-text]{overflow-wrap:anywhere;user-select:text}[data-corn=source-origin]{font-family:var(--corn-mono);color:var(--corn-warn);overflow-wrap:anywhere;user-select:all}[data-corn=source-sign-in],[data-corn=source-retry]{box-sizing:border-box;min-height:max(var(--corn-control-height), 2.75rem);padding:0 var(--corn-space-6);border:var(--corn-border) solid var(--corn-line);border-radius:var(--corn-radius);background:var(--corn-surface-2);color:var(--corn-text);font-family:inherit;font-size:inherit;cursor:pointer;justify-content:center;align-items:center;text-decoration:none;display:inline-flex}[data-corn=source-sign-in]{border-color:var(--corn-accent);background:var(--corn-accent);color:var(--corn-text-on-accent);font-weight:600}[data-corn=source-sign-in]:hover{background:var(--corn-accent-hover)}[data-corn=source-retry]:hover{background:var(--corn-surface-3)}[data-corn=source-sign-in]:focus-visible,[data-corn=source-retry]:focus-visible{outline:var(--corn-focus-width) solid var(--corn-focus);outline-offset:var(--corn-focus-offset)}[data-corn=source-notice]{z-index:2;box-sizing:border-box;padding:var(--corn-space-3) var(--corn-space-6);background:var(--corn-surface-1);border-top:var(--corn-border) solid var(--corn-line-soft);color:var(--corn-text-2);font-family:var(--corn-font);font-size:var(--corn-text-sm);text-align:center;overflow-wrap:anywhere;margin:0;position:absolute;bottom:0;left:0;right:0}[data-corn=source-notice][hidden]{display:none}", _n = () => ":host{contain:layout;min-width:0;color:var(--corn-text);font-family:var(--corn-font);display:block;position:relative}:host([hidden]){display:none!important}", vn = class extends n {
2548
+ constructor(t) {
2549
+ super(), t !== !1 && this.__registerHost(), this.__attachShadow(), this.cornSelect = e(this, "cornSelect", 7), this.cornReady = e(this, "cornReady", 7), this.cornAuth = e(this, "cornAuth", 7), this.cornError = e(this, "cornError", 7);
2550
+ }
2551
+ get el() {
2552
+ return this;
2553
+ }
2554
+ topology;
2555
+ node;
2556
+ view = "map";
2557
+ theme;
2558
+ renderer = "auto";
2559
+ src;
2560
+ useTheme = !1;
2561
+ cornSelect;
2562
+ cornReady;
2563
+ cornAuth;
2564
+ cornError;
2565
+ piece = null;
2566
+ scope = null;
2567
+ loaded = !1;
2568
+ changes = {};
2569
+ connectedCallback() {
2570
+ this.loaded && this.mountPiece();
2571
+ }
2572
+ componentDidLoad() {
2573
+ this.loaded = !0, this.mountPiece();
2574
+ }
2575
+ disconnectedCallback() {
2576
+ this.unmountPiece();
2577
+ }
2578
+ unmountPiece() {
2579
+ this.piece && this.piece.destroy(), this.piece = null, this.scope && this.scope.leave(), this.scope = null;
2580
+ }
2581
+ remount() {
2582
+ this.unmountPiece(), this.loaded && this.el.isConnected && this.mountPiece();
2583
+ }
2584
+ mountPiece() {
2585
+ !this.piece && this.el.shadowRoot && (this.changes = {}, this.scope = k(this.el, () => this.remount()), this.piece = fn(this.el.shadowRoot, this.scope.inst, {
2586
+ topology: this.topology,
2587
+ view: this.view,
2588
+ node: this.node,
2589
+ theme: this.theme,
2590
+ renderer: this.renderer,
2591
+ tokens: ae,
2592
+ src: this.src,
2593
+ useTheme: this.useTheme,
2594
+ version: "0.49.0",
2595
+ pageUrl: () => typeof location > "u" ? "" : location.href,
2596
+ onAuth: (e) => this.cornAuth.emit(e),
2597
+ onError: (e) => this.cornError.emit(e),
2598
+ onSelect: (e) => {
2599
+ this.node = e.kind === "node" ? e.id : null, delete this.changes.node, this.cornSelect.emit(e);
2600
+ },
2601
+ onReady: () => this.cornReady.emit()
2602
+ }));
2603
+ }
2604
+ componentDidRender() {
2605
+ let e = this.changes;
2606
+ this.changes = {}, this.piece && Object.keys(e).length && this.piece.update(e);
2607
+ }
2608
+ changed(e, t, n) {
2609
+ this.changes[n] = e;
2610
+ }
2611
+ addressChanged() {
2612
+ this.piece && this.scope && !this.scope.inst && this.remount();
2613
+ }
2614
+ async fit() {
2615
+ this.piece && this.piece.fit();
2616
+ }
2617
+ async focusNode(e) {
2618
+ this.piece && this.piece.focusNode(e);
2619
+ }
2620
+ async refresh() {
2621
+ this.piece && this.piece.refresh();
2622
+ }
2623
+ static get watchers() {
2624
+ return {
2625
+ topology: [{ changed: 0 }],
2626
+ view: [{ changed: 0 }],
2627
+ node: [{ changed: 0 }],
2628
+ theme: [{ changed: 0 }],
2629
+ renderer: [{ changed: 0 }],
2630
+ src: [{ addressChanged: 0 }],
2631
+ useTheme: [{ addressChanged: 0 }]
2632
+ };
2633
+ }
2634
+ static get style() {
2635
+ return hn() + gn() + _n();
2636
+ }
2637
+ };
2638
+ t(vn, [
2639
+ 513,
2640
+ "corn-map",
2641
+ {
2642
+ topology: [16],
2643
+ node: [1537],
2644
+ view: [1],
2645
+ theme: [513],
2646
+ renderer: [1],
2647
+ src: [1],
2648
+ useTheme: [4, "use-theme"],
2649
+ fit: [64],
2650
+ focusNode: [64],
2651
+ refresh: [64]
2652
+ },
2653
+ void 0,
2654
+ {
2655
+ topology: [{ changed: 0 }],
2656
+ view: [{ changed: 0 }],
2657
+ node: [{ changed: 0 }],
2658
+ theme: [{ changed: 0 }],
2659
+ renderer: [{ changed: 0 }],
2660
+ src: [{ addressChanged: 0 }],
2661
+ useTheme: [{ addressChanged: 0 }]
2662
+ }
2663
+ ]);
2664
+ export { vn as t };