quixotic-gol 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,3680 @@
1
+ import { useRef as lt, useState as Ge, useCallback as be, useEffect as Ce, forwardRef as Hn, useImperativeHandle as Wn } from "react";
2
+ import { jsx as Et, jsxs as ue } from "react/jsx-runtime";
3
+ const Ys = 500;
4
+ var On = { value: () => {
5
+ } };
6
+ function Re() {
7
+ for (var t = 0, e = arguments.length, n = {}, r; t < e; ++t) {
8
+ if (!(r = arguments[t] + "") || r in n || /[\s.]/.test(r)) throw new Error("illegal type: " + r);
9
+ n[r] = [];
10
+ }
11
+ return new se(n);
12
+ }
13
+ function se(t) {
14
+ this._ = t;
15
+ }
16
+ function Xn(t, e) {
17
+ return t.trim().split(/^|\s+/).map(function(n) {
18
+ var r = "", i = n.indexOf(".");
19
+ if (i >= 0 && (r = n.slice(i + 1), n = n.slice(0, i)), n && !e.hasOwnProperty(n)) throw new Error("unknown type: " + n);
20
+ return { type: n, name: r };
21
+ });
22
+ }
23
+ se.prototype = Re.prototype = {
24
+ constructor: se,
25
+ on: function(t, e) {
26
+ var n = this._, r = Xn(t + "", n), i, s = -1, o = r.length;
27
+ if (arguments.length < 2) {
28
+ for (; ++s < o; ) if ((i = (t = r[s]).type) && (i = Gn(n[i], t.name))) return i;
29
+ return;
30
+ }
31
+ if (e != null && typeof e != "function") throw new Error("invalid callback: " + e);
32
+ for (; ++s < o; )
33
+ if (i = (t = r[s]).type) n[i] = Ve(n[i], t.name, e);
34
+ else if (e == null) for (i in n) n[i] = Ve(n[i], t.name, null);
35
+ return this;
36
+ },
37
+ copy: function() {
38
+ var t = {}, e = this._;
39
+ for (var n in e) t[n] = e[n].slice();
40
+ return new se(t);
41
+ },
42
+ call: function(t, e) {
43
+ if ((i = arguments.length - 2) > 0) for (var n = new Array(i), r = 0, i, s; r < i; ++r) n[r] = arguments[r + 2];
44
+ if (!this._.hasOwnProperty(t)) throw new Error("unknown type: " + t);
45
+ for (s = this._[t], r = 0, i = s.length; r < i; ++r) s[r].value.apply(e, n);
46
+ },
47
+ apply: function(t, e, n) {
48
+ if (!this._.hasOwnProperty(t)) throw new Error("unknown type: " + t);
49
+ for (var r = this._[t], i = 0, s = r.length; i < s; ++i) r[i].value.apply(e, n);
50
+ }
51
+ };
52
+ function Gn(t, e) {
53
+ for (var n = 0, r = t.length, i; n < r; ++n)
54
+ if ((i = t[n]).name === e)
55
+ return i.value;
56
+ }
57
+ function Ve(t, e, n) {
58
+ for (var r = 0, i = t.length; r < i; ++r)
59
+ if (t[r].name === e) {
60
+ t[r] = On, t = t.slice(0, r).concat(t.slice(r + 1));
61
+ break;
62
+ }
63
+ return n != null && t.push({ name: e, value: n }), t;
64
+ }
65
+ var Se = "http://www.w3.org/1999/xhtml";
66
+ const qe = {
67
+ svg: "http://www.w3.org/2000/svg",
68
+ xhtml: Se,
69
+ xlink: "http://www.w3.org/1999/xlink",
70
+ xml: "http://www.w3.org/XML/1998/namespace",
71
+ xmlns: "http://www.w3.org/2000/xmlns/"
72
+ };
73
+ function ye(t) {
74
+ var e = t += "", n = e.indexOf(":");
75
+ return n >= 0 && (e = t.slice(0, n)) !== "xmlns" && (t = t.slice(n + 1)), qe.hasOwnProperty(e) ? { space: qe[e], local: t } : t;
76
+ }
77
+ function Vn(t) {
78
+ return function() {
79
+ var e = this.ownerDocument, n = this.namespaceURI;
80
+ return n === Se && e.documentElement.namespaceURI === Se ? e.createElement(t) : e.createElementNS(n, t);
81
+ };
82
+ }
83
+ function qn(t) {
84
+ return function() {
85
+ return this.ownerDocument.createElementNS(t.space, t.local);
86
+ };
87
+ }
88
+ function hn(t) {
89
+ var e = ye(t);
90
+ return (e.local ? qn : Vn)(e);
91
+ }
92
+ function Un() {
93
+ }
94
+ function De(t) {
95
+ return t == null ? Un : function() {
96
+ return this.querySelector(t);
97
+ };
98
+ }
99
+ function Zn(t) {
100
+ typeof t != "function" && (t = De(t));
101
+ for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i)
102
+ for (var s = e[i], o = s.length, c = r[i] = new Array(o), l, a, u = 0; u < o; ++u)
103
+ (l = s[u]) && (a = t.call(l, l.__data__, u, s)) && ("__data__" in l && (a.__data__ = l.__data__), c[u] = a);
104
+ return new ft(r, this._parents);
105
+ }
106
+ function Kn(t) {
107
+ return t == null ? [] : Array.isArray(t) ? t : Array.from(t);
108
+ }
109
+ function Qn() {
110
+ return [];
111
+ }
112
+ function dn(t) {
113
+ return t == null ? Qn : function() {
114
+ return this.querySelectorAll(t);
115
+ };
116
+ }
117
+ function Jn(t) {
118
+ return function() {
119
+ return Kn(t.apply(this, arguments));
120
+ };
121
+ }
122
+ function jn(t) {
123
+ typeof t == "function" ? t = Jn(t) : t = dn(t);
124
+ for (var e = this._groups, n = e.length, r = [], i = [], s = 0; s < n; ++s)
125
+ for (var o = e[s], c = o.length, l, a = 0; a < c; ++a)
126
+ (l = o[a]) && (r.push(t.call(l, l.__data__, a, o)), i.push(l));
127
+ return new ft(r, i);
128
+ }
129
+ function pn(t) {
130
+ return function() {
131
+ return this.matches(t);
132
+ };
133
+ }
134
+ function gn(t) {
135
+ return function(e) {
136
+ return e.matches(t);
137
+ };
138
+ }
139
+ var tr = Array.prototype.find;
140
+ function er(t) {
141
+ return function() {
142
+ return tr.call(this.children, t);
143
+ };
144
+ }
145
+ function nr() {
146
+ return this.firstElementChild;
147
+ }
148
+ function rr(t) {
149
+ return this.select(t == null ? nr : er(typeof t == "function" ? t : gn(t)));
150
+ }
151
+ var ir = Array.prototype.filter;
152
+ function or() {
153
+ return Array.from(this.children);
154
+ }
155
+ function sr(t) {
156
+ return function() {
157
+ return ir.call(this.children, t);
158
+ };
159
+ }
160
+ function ar(t) {
161
+ return this.selectAll(t == null ? or : sr(typeof t == "function" ? t : gn(t)));
162
+ }
163
+ function cr(t) {
164
+ typeof t != "function" && (t = pn(t));
165
+ for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i)
166
+ for (var s = e[i], o = s.length, c = r[i] = [], l, a = 0; a < o; ++a)
167
+ (l = s[a]) && t.call(l, l.__data__, a, s) && c.push(l);
168
+ return new ft(r, this._parents);
169
+ }
170
+ function mn(t) {
171
+ return new Array(t.length);
172
+ }
173
+ function lr() {
174
+ return new ft(this._enter || this._groups.map(mn), this._parents);
175
+ }
176
+ function fe(t, e) {
177
+ this.ownerDocument = t.ownerDocument, this.namespaceURI = t.namespaceURI, this._next = null, this._parent = t, this.__data__ = e;
178
+ }
179
+ fe.prototype = {
180
+ constructor: fe,
181
+ appendChild: function(t) {
182
+ return this._parent.insertBefore(t, this._next);
183
+ },
184
+ insertBefore: function(t, e) {
185
+ return this._parent.insertBefore(t, e);
186
+ },
187
+ querySelector: function(t) {
188
+ return this._parent.querySelector(t);
189
+ },
190
+ querySelectorAll: function(t) {
191
+ return this._parent.querySelectorAll(t);
192
+ }
193
+ };
194
+ function ur(t) {
195
+ return function() {
196
+ return t;
197
+ };
198
+ }
199
+ function fr(t, e, n, r, i, s) {
200
+ for (var o = 0, c, l = e.length, a = s.length; o < a; ++o)
201
+ (c = e[o]) ? (c.__data__ = s[o], r[o] = c) : n[o] = new fe(t, s[o]);
202
+ for (; o < l; ++o)
203
+ (c = e[o]) && (i[o] = c);
204
+ }
205
+ function hr(t, e, n, r, i, s, o) {
206
+ var c, l, a = /* @__PURE__ */ new Map(), u = e.length, d = s.length, g = new Array(u), x;
207
+ for (c = 0; c < u; ++c)
208
+ (l = e[c]) && (g[c] = x = o.call(l, l.__data__, c, e) + "", a.has(x) ? i[c] = l : a.set(x, l));
209
+ for (c = 0; c < d; ++c)
210
+ x = o.call(t, s[c], c, s) + "", (l = a.get(x)) ? (r[c] = l, l.__data__ = s[c], a.delete(x)) : n[c] = new fe(t, s[c]);
211
+ for (c = 0; c < u; ++c)
212
+ (l = e[c]) && a.get(g[c]) === l && (i[c] = l);
213
+ }
214
+ function dr(t) {
215
+ return t.__data__;
216
+ }
217
+ function pr(t, e) {
218
+ if (!arguments.length) return Array.from(this, dr);
219
+ var n = e ? hr : fr, r = this._parents, i = this._groups;
220
+ typeof t != "function" && (t = ur(t));
221
+ for (var s = i.length, o = new Array(s), c = new Array(s), l = new Array(s), a = 0; a < s; ++a) {
222
+ var u = r[a], d = i[a], g = d.length, x = gr(t.call(u, u && u.__data__, a, r)), N = x.length, S = c[a] = new Array(N), Y = o[a] = new Array(N), $ = l[a] = new Array(g);
223
+ n(u, d, S, Y, $, x, e);
224
+ for (var K = 0, O = 0, Q, G; K < N; ++K)
225
+ if (Q = S[K]) {
226
+ for (K >= O && (O = K + 1); !(G = Y[O]) && ++O < N; ) ;
227
+ Q._next = G || null;
228
+ }
229
+ }
230
+ return o = new ft(o, r), o._enter = c, o._exit = l, o;
231
+ }
232
+ function gr(t) {
233
+ return typeof t == "object" && "length" in t ? t : Array.from(t);
234
+ }
235
+ function mr() {
236
+ return new ft(this._exit || this._groups.map(mn), this._parents);
237
+ }
238
+ function yr(t, e, n) {
239
+ var r = this.enter(), i = this, s = this.exit();
240
+ return typeof t == "function" ? (r = t(r), r && (r = r.selection())) : r = r.append(t + ""), e != null && (i = e(i), i && (i = i.selection())), n == null ? s.remove() : n(s), r && i ? r.merge(i).order() : i;
241
+ }
242
+ function xr(t) {
243
+ for (var e = t.selection ? t.selection() : t, n = this._groups, r = e._groups, i = n.length, s = r.length, o = Math.min(i, s), c = new Array(i), l = 0; l < o; ++l)
244
+ for (var a = n[l], u = r[l], d = a.length, g = c[l] = new Array(d), x, N = 0; N < d; ++N)
245
+ (x = a[N] || u[N]) && (g[N] = x);
246
+ for (; l < i; ++l)
247
+ c[l] = n[l];
248
+ return new ft(c, this._parents);
249
+ }
250
+ function wr() {
251
+ for (var t = this._groups, e = -1, n = t.length; ++e < n; )
252
+ for (var r = t[e], i = r.length - 1, s = r[i], o; --i >= 0; )
253
+ (o = r[i]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
254
+ return this;
255
+ }
256
+ function vr(t) {
257
+ t || (t = _r);
258
+ function e(d, g) {
259
+ return d && g ? t(d.__data__, g.__data__) : !d - !g;
260
+ }
261
+ for (var n = this._groups, r = n.length, i = new Array(r), s = 0; s < r; ++s) {
262
+ for (var o = n[s], c = o.length, l = i[s] = new Array(c), a, u = 0; u < c; ++u)
263
+ (a = o[u]) && (l[u] = a);
264
+ l.sort(e);
265
+ }
266
+ return new ft(i, this._parents).order();
267
+ }
268
+ function _r(t, e) {
269
+ return t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
270
+ }
271
+ function br() {
272
+ var t = arguments[0];
273
+ return arguments[0] = this, t.apply(null, arguments), this;
274
+ }
275
+ function Er() {
276
+ return Array.from(this);
277
+ }
278
+ function Nr() {
279
+ for (var t = this._groups, e = 0, n = t.length; e < n; ++e)
280
+ for (var r = t[e], i = 0, s = r.length; i < s; ++i) {
281
+ var o = r[i];
282
+ if (o) return o;
283
+ }
284
+ return null;
285
+ }
286
+ function $r() {
287
+ let t = 0;
288
+ for (const e of this) ++t;
289
+ return t;
290
+ }
291
+ function kr() {
292
+ return !this.node();
293
+ }
294
+ function Cr(t) {
295
+ for (var e = this._groups, n = 0, r = e.length; n < r; ++n)
296
+ for (var i = e[n], s = 0, o = i.length, c; s < o; ++s)
297
+ (c = i[s]) && t.call(c, c.__data__, s, i);
298
+ return this;
299
+ }
300
+ function Sr(t) {
301
+ return function() {
302
+ this.removeAttribute(t);
303
+ };
304
+ }
305
+ function Ar(t) {
306
+ return function() {
307
+ this.removeAttributeNS(t.space, t.local);
308
+ };
309
+ }
310
+ function Mr(t, e) {
311
+ return function() {
312
+ this.setAttribute(t, e);
313
+ };
314
+ }
315
+ function zr(t, e) {
316
+ return function() {
317
+ this.setAttributeNS(t.space, t.local, e);
318
+ };
319
+ }
320
+ function Ir(t, e) {
321
+ return function() {
322
+ var n = e.apply(this, arguments);
323
+ n == null ? this.removeAttribute(t) : this.setAttribute(t, n);
324
+ };
325
+ }
326
+ function Pr(t, e) {
327
+ return function() {
328
+ var n = e.apply(this, arguments);
329
+ n == null ? this.removeAttributeNS(t.space, t.local) : this.setAttributeNS(t.space, t.local, n);
330
+ };
331
+ }
332
+ function Yr(t, e) {
333
+ var n = ye(t);
334
+ if (arguments.length < 2) {
335
+ var r = this.node();
336
+ return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n);
337
+ }
338
+ return this.each((e == null ? n.local ? Ar : Sr : typeof e == "function" ? n.local ? Pr : Ir : n.local ? zr : Mr)(n, e));
339
+ }
340
+ function yn(t) {
341
+ return t.ownerDocument && t.ownerDocument.defaultView || t.document && t || t.defaultView;
342
+ }
343
+ function Tr(t) {
344
+ return function() {
345
+ this.style.removeProperty(t);
346
+ };
347
+ }
348
+ function Br(t, e, n) {
349
+ return function() {
350
+ this.style.setProperty(t, e, n);
351
+ };
352
+ }
353
+ function Rr(t, e, n) {
354
+ return function() {
355
+ var r = e.apply(this, arguments);
356
+ r == null ? this.style.removeProperty(t) : this.style.setProperty(t, r, n);
357
+ };
358
+ }
359
+ function Dr(t, e, n) {
360
+ return arguments.length > 1 ? this.each((e == null ? Tr : typeof e == "function" ? Rr : Br)(t, e, n ?? "")) : Rt(this.node(), t);
361
+ }
362
+ function Rt(t, e) {
363
+ return t.style.getPropertyValue(e) || yn(t).getComputedStyle(t, null).getPropertyValue(e);
364
+ }
365
+ function Lr(t) {
366
+ return function() {
367
+ delete this[t];
368
+ };
369
+ }
370
+ function Fr(t, e) {
371
+ return function() {
372
+ this[t] = e;
373
+ };
374
+ }
375
+ function Hr(t, e) {
376
+ return function() {
377
+ var n = e.apply(this, arguments);
378
+ n == null ? delete this[t] : this[t] = n;
379
+ };
380
+ }
381
+ function Wr(t, e) {
382
+ return arguments.length > 1 ? this.each((e == null ? Lr : typeof e == "function" ? Hr : Fr)(t, e)) : this.node()[t];
383
+ }
384
+ function xn(t) {
385
+ return t.trim().split(/^|\s+/);
386
+ }
387
+ function Le(t) {
388
+ return t.classList || new wn(t);
389
+ }
390
+ function wn(t) {
391
+ this._node = t, this._names = xn(t.getAttribute("class") || "");
392
+ }
393
+ wn.prototype = {
394
+ add: function(t) {
395
+ var e = this._names.indexOf(t);
396
+ e < 0 && (this._names.push(t), this._node.setAttribute("class", this._names.join(" ")));
397
+ },
398
+ remove: function(t) {
399
+ var e = this._names.indexOf(t);
400
+ e >= 0 && (this._names.splice(e, 1), this._node.setAttribute("class", this._names.join(" ")));
401
+ },
402
+ contains: function(t) {
403
+ return this._names.indexOf(t) >= 0;
404
+ }
405
+ };
406
+ function vn(t, e) {
407
+ for (var n = Le(t), r = -1, i = e.length; ++r < i; ) n.add(e[r]);
408
+ }
409
+ function _n(t, e) {
410
+ for (var n = Le(t), r = -1, i = e.length; ++r < i; ) n.remove(e[r]);
411
+ }
412
+ function Or(t) {
413
+ return function() {
414
+ vn(this, t);
415
+ };
416
+ }
417
+ function Xr(t) {
418
+ return function() {
419
+ _n(this, t);
420
+ };
421
+ }
422
+ function Gr(t, e) {
423
+ return function() {
424
+ (e.apply(this, arguments) ? vn : _n)(this, t);
425
+ };
426
+ }
427
+ function Vr(t, e) {
428
+ var n = xn(t + "");
429
+ if (arguments.length < 2) {
430
+ for (var r = Le(this.node()), i = -1, s = n.length; ++i < s; ) if (!r.contains(n[i])) return !1;
431
+ return !0;
432
+ }
433
+ return this.each((typeof e == "function" ? Gr : e ? Or : Xr)(n, e));
434
+ }
435
+ function qr() {
436
+ this.textContent = "";
437
+ }
438
+ function Ur(t) {
439
+ return function() {
440
+ this.textContent = t;
441
+ };
442
+ }
443
+ function Zr(t) {
444
+ return function() {
445
+ var e = t.apply(this, arguments);
446
+ this.textContent = e ?? "";
447
+ };
448
+ }
449
+ function Kr(t) {
450
+ return arguments.length ? this.each(t == null ? qr : (typeof t == "function" ? Zr : Ur)(t)) : this.node().textContent;
451
+ }
452
+ function Qr() {
453
+ this.innerHTML = "";
454
+ }
455
+ function Jr(t) {
456
+ return function() {
457
+ this.innerHTML = t;
458
+ };
459
+ }
460
+ function jr(t) {
461
+ return function() {
462
+ var e = t.apply(this, arguments);
463
+ this.innerHTML = e ?? "";
464
+ };
465
+ }
466
+ function ti(t) {
467
+ return arguments.length ? this.each(t == null ? Qr : (typeof t == "function" ? jr : Jr)(t)) : this.node().innerHTML;
468
+ }
469
+ function ei() {
470
+ this.nextSibling && this.parentNode.appendChild(this);
471
+ }
472
+ function ni() {
473
+ return this.each(ei);
474
+ }
475
+ function ri() {
476
+ this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
477
+ }
478
+ function ii() {
479
+ return this.each(ri);
480
+ }
481
+ function oi(t) {
482
+ var e = typeof t == "function" ? t : hn(t);
483
+ return this.select(function() {
484
+ return this.appendChild(e.apply(this, arguments));
485
+ });
486
+ }
487
+ function si() {
488
+ return null;
489
+ }
490
+ function ai(t, e) {
491
+ var n = typeof t == "function" ? t : hn(t), r = e == null ? si : typeof e == "function" ? e : De(e);
492
+ return this.select(function() {
493
+ return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
494
+ });
495
+ }
496
+ function ci() {
497
+ var t = this.parentNode;
498
+ t && t.removeChild(this);
499
+ }
500
+ function li() {
501
+ return this.each(ci);
502
+ }
503
+ function ui() {
504
+ var t = this.cloneNode(!1), e = this.parentNode;
505
+ return e ? e.insertBefore(t, this.nextSibling) : t;
506
+ }
507
+ function fi() {
508
+ var t = this.cloneNode(!0), e = this.parentNode;
509
+ return e ? e.insertBefore(t, this.nextSibling) : t;
510
+ }
511
+ function hi(t) {
512
+ return this.select(t ? fi : ui);
513
+ }
514
+ function di(t) {
515
+ return arguments.length ? this.property("__data__", t) : this.node().__data__;
516
+ }
517
+ function pi(t) {
518
+ return function(e) {
519
+ t.call(this, e, this.__data__);
520
+ };
521
+ }
522
+ function gi(t) {
523
+ return t.trim().split(/^|\s+/).map(function(e) {
524
+ var n = "", r = e.indexOf(".");
525
+ return r >= 0 && (n = e.slice(r + 1), e = e.slice(0, r)), { type: e, name: n };
526
+ });
527
+ }
528
+ function mi(t) {
529
+ return function() {
530
+ var e = this.__on;
531
+ if (e) {
532
+ for (var n = 0, r = -1, i = e.length, s; n < i; ++n)
533
+ s = e[n], (!t.type || s.type === t.type) && s.name === t.name ? this.removeEventListener(s.type, s.listener, s.options) : e[++r] = s;
534
+ ++r ? e.length = r : delete this.__on;
535
+ }
536
+ };
537
+ }
538
+ function yi(t, e, n) {
539
+ return function() {
540
+ var r = this.__on, i, s = pi(e);
541
+ if (r) {
542
+ for (var o = 0, c = r.length; o < c; ++o)
543
+ if ((i = r[o]).type === t.type && i.name === t.name) {
544
+ this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = s, i.options = n), i.value = e;
545
+ return;
546
+ }
547
+ }
548
+ this.addEventListener(t.type, s, n), i = { type: t.type, name: t.name, value: e, listener: s, options: n }, r ? r.push(i) : this.__on = [i];
549
+ };
550
+ }
551
+ function xi(t, e, n) {
552
+ var r = gi(t + ""), i, s = r.length, o;
553
+ if (arguments.length < 2) {
554
+ var c = this.node().__on;
555
+ if (c) {
556
+ for (var l = 0, a = c.length, u; l < a; ++l)
557
+ for (i = 0, u = c[l]; i < s; ++i)
558
+ if ((o = r[i]).type === u.type && o.name === u.name)
559
+ return u.value;
560
+ }
561
+ return;
562
+ }
563
+ for (c = e ? yi : mi, i = 0; i < s; ++i) this.each(c(r[i], e, n));
564
+ return this;
565
+ }
566
+ function bn(t, e, n) {
567
+ var r = yn(t), i = r.CustomEvent;
568
+ typeof i == "function" ? i = new i(e, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(e, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(e, !1, !1)), t.dispatchEvent(i);
569
+ }
570
+ function wi(t, e) {
571
+ return function() {
572
+ return bn(this, t, e);
573
+ };
574
+ }
575
+ function vi(t, e) {
576
+ return function() {
577
+ return bn(this, t, e.apply(this, arguments));
578
+ };
579
+ }
580
+ function _i(t, e) {
581
+ return this.each((typeof e == "function" ? vi : wi)(t, e));
582
+ }
583
+ function* bi() {
584
+ for (var t = this._groups, e = 0, n = t.length; e < n; ++e)
585
+ for (var r = t[e], i = 0, s = r.length, o; i < s; ++i)
586
+ (o = r[i]) && (yield o);
587
+ }
588
+ var En = [null];
589
+ function ft(t, e) {
590
+ this._groups = t, this._parents = e;
591
+ }
592
+ function Qt() {
593
+ return new ft([[document.documentElement]], En);
594
+ }
595
+ function Ei() {
596
+ return this;
597
+ }
598
+ ft.prototype = Qt.prototype = {
599
+ constructor: ft,
600
+ select: Zn,
601
+ selectAll: jn,
602
+ selectChild: rr,
603
+ selectChildren: ar,
604
+ filter: cr,
605
+ data: pr,
606
+ enter: lr,
607
+ exit: mr,
608
+ join: yr,
609
+ merge: xr,
610
+ selection: Ei,
611
+ order: wr,
612
+ sort: vr,
613
+ call: br,
614
+ nodes: Er,
615
+ node: Nr,
616
+ size: $r,
617
+ empty: kr,
618
+ each: Cr,
619
+ attr: Yr,
620
+ style: Dr,
621
+ property: Wr,
622
+ classed: Vr,
623
+ text: Kr,
624
+ html: ti,
625
+ raise: ni,
626
+ lower: ii,
627
+ append: oi,
628
+ insert: ai,
629
+ remove: li,
630
+ clone: hi,
631
+ datum: di,
632
+ on: xi,
633
+ dispatch: _i,
634
+ [Symbol.iterator]: bi
635
+ };
636
+ function ot(t) {
637
+ return typeof t == "string" ? new ft([[document.querySelector(t)]], [document.documentElement]) : new ft([[t]], En);
638
+ }
639
+ function Ni(t) {
640
+ let e;
641
+ for (; e = t.sourceEvent; ) t = e;
642
+ return t;
643
+ }
644
+ function At(t, e) {
645
+ if (t = Ni(t), e === void 0 && (e = t.currentTarget), e) {
646
+ var n = e.ownerSVGElement || e;
647
+ if (n.createSVGPoint) {
648
+ var r = n.createSVGPoint();
649
+ return r.x = t.clientX, r.y = t.clientY, r = r.matrixTransform(e.getScreenCTM().inverse()), [r.x, r.y];
650
+ }
651
+ if (e.getBoundingClientRect) {
652
+ var i = e.getBoundingClientRect();
653
+ return [t.clientX - i.left - e.clientLeft, t.clientY - i.top - e.clientTop];
654
+ }
655
+ }
656
+ return [t.pageX, t.pageY];
657
+ }
658
+ const Ae = { capture: !0, passive: !1 };
659
+ function Me(t) {
660
+ t.preventDefault(), t.stopImmediatePropagation();
661
+ }
662
+ function $i(t) {
663
+ var e = t.document.documentElement, n = ot(t).on("dragstart.drag", Me, Ae);
664
+ "onselectstart" in e ? n.on("selectstart.drag", Me, Ae) : (e.__noselect = e.style.MozUserSelect, e.style.MozUserSelect = "none");
665
+ }
666
+ function ki(t, e) {
667
+ var n = t.document.documentElement, r = ot(t).on("dragstart.drag", null);
668
+ e && (r.on("click.drag", Me, Ae), setTimeout(function() {
669
+ r.on("click.drag", null);
670
+ }, 0)), "onselectstart" in n ? r.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
671
+ }
672
+ function Fe(t, e, n) {
673
+ t.prototype = e.prototype = n, n.constructor = t;
674
+ }
675
+ function Nn(t, e) {
676
+ var n = Object.create(t.prototype);
677
+ for (var r in e) n[r] = e[r];
678
+ return n;
679
+ }
680
+ function Jt() {
681
+ }
682
+ var qt = 0.7, he = 1 / qt, Bt = "\\s*([+-]?\\d+)\\s*", Ut = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", yt = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Ci = /^#([0-9a-f]{3,8})$/, Si = new RegExp(`^rgb\\(${Bt},${Bt},${Bt}\\)$`), Ai = new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`), Mi = new RegExp(`^rgba\\(${Bt},${Bt},${Bt},${Ut}\\)$`), zi = new RegExp(`^rgba\\(${yt},${yt},${yt},${Ut}\\)$`), Ii = new RegExp(`^hsl\\(${Ut},${yt},${yt}\\)$`), Pi = new RegExp(`^hsla\\(${Ut},${yt},${yt},${Ut}\\)$`), Ue = {
683
+ aliceblue: 15792383,
684
+ antiquewhite: 16444375,
685
+ aqua: 65535,
686
+ aquamarine: 8388564,
687
+ azure: 15794175,
688
+ beige: 16119260,
689
+ bisque: 16770244,
690
+ black: 0,
691
+ blanchedalmond: 16772045,
692
+ blue: 255,
693
+ blueviolet: 9055202,
694
+ brown: 10824234,
695
+ burlywood: 14596231,
696
+ cadetblue: 6266528,
697
+ chartreuse: 8388352,
698
+ chocolate: 13789470,
699
+ coral: 16744272,
700
+ cornflowerblue: 6591981,
701
+ cornsilk: 16775388,
702
+ crimson: 14423100,
703
+ cyan: 65535,
704
+ darkblue: 139,
705
+ darkcyan: 35723,
706
+ darkgoldenrod: 12092939,
707
+ darkgray: 11119017,
708
+ darkgreen: 25600,
709
+ darkgrey: 11119017,
710
+ darkkhaki: 12433259,
711
+ darkmagenta: 9109643,
712
+ darkolivegreen: 5597999,
713
+ darkorange: 16747520,
714
+ darkorchid: 10040012,
715
+ darkred: 9109504,
716
+ darksalmon: 15308410,
717
+ darkseagreen: 9419919,
718
+ darkslateblue: 4734347,
719
+ darkslategray: 3100495,
720
+ darkslategrey: 3100495,
721
+ darkturquoise: 52945,
722
+ darkviolet: 9699539,
723
+ deeppink: 16716947,
724
+ deepskyblue: 49151,
725
+ dimgray: 6908265,
726
+ dimgrey: 6908265,
727
+ dodgerblue: 2003199,
728
+ firebrick: 11674146,
729
+ floralwhite: 16775920,
730
+ forestgreen: 2263842,
731
+ fuchsia: 16711935,
732
+ gainsboro: 14474460,
733
+ ghostwhite: 16316671,
734
+ gold: 16766720,
735
+ goldenrod: 14329120,
736
+ gray: 8421504,
737
+ green: 32768,
738
+ greenyellow: 11403055,
739
+ grey: 8421504,
740
+ honeydew: 15794160,
741
+ hotpink: 16738740,
742
+ indianred: 13458524,
743
+ indigo: 4915330,
744
+ ivory: 16777200,
745
+ khaki: 15787660,
746
+ lavender: 15132410,
747
+ lavenderblush: 16773365,
748
+ lawngreen: 8190976,
749
+ lemonchiffon: 16775885,
750
+ lightblue: 11393254,
751
+ lightcoral: 15761536,
752
+ lightcyan: 14745599,
753
+ lightgoldenrodyellow: 16448210,
754
+ lightgray: 13882323,
755
+ lightgreen: 9498256,
756
+ lightgrey: 13882323,
757
+ lightpink: 16758465,
758
+ lightsalmon: 16752762,
759
+ lightseagreen: 2142890,
760
+ lightskyblue: 8900346,
761
+ lightslategray: 7833753,
762
+ lightslategrey: 7833753,
763
+ lightsteelblue: 11584734,
764
+ lightyellow: 16777184,
765
+ lime: 65280,
766
+ limegreen: 3329330,
767
+ linen: 16445670,
768
+ magenta: 16711935,
769
+ maroon: 8388608,
770
+ mediumaquamarine: 6737322,
771
+ mediumblue: 205,
772
+ mediumorchid: 12211667,
773
+ mediumpurple: 9662683,
774
+ mediumseagreen: 3978097,
775
+ mediumslateblue: 8087790,
776
+ mediumspringgreen: 64154,
777
+ mediumturquoise: 4772300,
778
+ mediumvioletred: 13047173,
779
+ midnightblue: 1644912,
780
+ mintcream: 16121850,
781
+ mistyrose: 16770273,
782
+ moccasin: 16770229,
783
+ navajowhite: 16768685,
784
+ navy: 128,
785
+ oldlace: 16643558,
786
+ olive: 8421376,
787
+ olivedrab: 7048739,
788
+ orange: 16753920,
789
+ orangered: 16729344,
790
+ orchid: 14315734,
791
+ palegoldenrod: 15657130,
792
+ palegreen: 10025880,
793
+ paleturquoise: 11529966,
794
+ palevioletred: 14381203,
795
+ papayawhip: 16773077,
796
+ peachpuff: 16767673,
797
+ peru: 13468991,
798
+ pink: 16761035,
799
+ plum: 14524637,
800
+ powderblue: 11591910,
801
+ purple: 8388736,
802
+ rebeccapurple: 6697881,
803
+ red: 16711680,
804
+ rosybrown: 12357519,
805
+ royalblue: 4286945,
806
+ saddlebrown: 9127187,
807
+ salmon: 16416882,
808
+ sandybrown: 16032864,
809
+ seagreen: 3050327,
810
+ seashell: 16774638,
811
+ sienna: 10506797,
812
+ silver: 12632256,
813
+ skyblue: 8900331,
814
+ slateblue: 6970061,
815
+ slategray: 7372944,
816
+ slategrey: 7372944,
817
+ snow: 16775930,
818
+ springgreen: 65407,
819
+ steelblue: 4620980,
820
+ tan: 13808780,
821
+ teal: 32896,
822
+ thistle: 14204888,
823
+ tomato: 16737095,
824
+ turquoise: 4251856,
825
+ violet: 15631086,
826
+ wheat: 16113331,
827
+ white: 16777215,
828
+ whitesmoke: 16119285,
829
+ yellow: 16776960,
830
+ yellowgreen: 10145074
831
+ };
832
+ Fe(Jt, Zt, {
833
+ copy(t) {
834
+ return Object.assign(new this.constructor(), this, t);
835
+ },
836
+ displayable() {
837
+ return this.rgb().displayable();
838
+ },
839
+ hex: Ze,
840
+ // Deprecated! Use color.formatHex.
841
+ formatHex: Ze,
842
+ formatHex8: Yi,
843
+ formatHsl: Ti,
844
+ formatRgb: Ke,
845
+ toString: Ke
846
+ });
847
+ function Ze() {
848
+ return this.rgb().formatHex();
849
+ }
850
+ function Yi() {
851
+ return this.rgb().formatHex8();
852
+ }
853
+ function Ti() {
854
+ return $n(this).formatHsl();
855
+ }
856
+ function Ke() {
857
+ return this.rgb().formatRgb();
858
+ }
859
+ function Zt(t) {
860
+ var e, n;
861
+ return t = (t + "").trim().toLowerCase(), (e = Ci.exec(t)) ? (n = e[1].length, e = parseInt(e[1], 16), n === 6 ? Qe(e) : n === 3 ? new ut(e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, (e & 15) << 4 | e & 15, 1) : n === 8 ? ee(e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, (e & 255) / 255) : n === 4 ? ee(e >> 12 & 15 | e >> 8 & 240, e >> 8 & 15 | e >> 4 & 240, e >> 4 & 15 | e & 240, ((e & 15) << 4 | e & 15) / 255) : null) : (e = Si.exec(t)) ? new ut(e[1], e[2], e[3], 1) : (e = Ai.exec(t)) ? new ut(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, 1) : (e = Mi.exec(t)) ? ee(e[1], e[2], e[3], e[4]) : (e = zi.exec(t)) ? ee(e[1] * 255 / 100, e[2] * 255 / 100, e[3] * 255 / 100, e[4]) : (e = Ii.exec(t)) ? tn(e[1], e[2] / 100, e[3] / 100, 1) : (e = Pi.exec(t)) ? tn(e[1], e[2] / 100, e[3] / 100, e[4]) : Ue.hasOwnProperty(t) ? Qe(Ue[t]) : t === "transparent" ? new ut(NaN, NaN, NaN, 0) : null;
862
+ }
863
+ function Qe(t) {
864
+ return new ut(t >> 16 & 255, t >> 8 & 255, t & 255, 1);
865
+ }
866
+ function ee(t, e, n, r) {
867
+ return r <= 0 && (t = e = n = NaN), new ut(t, e, n, r);
868
+ }
869
+ function Bi(t) {
870
+ return t instanceof Jt || (t = Zt(t)), t ? (t = t.rgb(), new ut(t.r, t.g, t.b, t.opacity)) : new ut();
871
+ }
872
+ function ze(t, e, n, r) {
873
+ return arguments.length === 1 ? Bi(t) : new ut(t, e, n, r ?? 1);
874
+ }
875
+ function ut(t, e, n, r) {
876
+ this.r = +t, this.g = +e, this.b = +n, this.opacity = +r;
877
+ }
878
+ Fe(ut, ze, Nn(Jt, {
879
+ brighter(t) {
880
+ return t = t == null ? he : Math.pow(he, t), new ut(this.r * t, this.g * t, this.b * t, this.opacity);
881
+ },
882
+ darker(t) {
883
+ return t = t == null ? qt : Math.pow(qt, t), new ut(this.r * t, this.g * t, this.b * t, this.opacity);
884
+ },
885
+ rgb() {
886
+ return this;
887
+ },
888
+ clamp() {
889
+ return new ut(It(this.r), It(this.g), It(this.b), de(this.opacity));
890
+ },
891
+ displayable() {
892
+ return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
893
+ },
894
+ hex: Je,
895
+ // Deprecated! Use color.formatHex.
896
+ formatHex: Je,
897
+ formatHex8: Ri,
898
+ formatRgb: je,
899
+ toString: je
900
+ }));
901
+ function Je() {
902
+ return `#${zt(this.r)}${zt(this.g)}${zt(this.b)}`;
903
+ }
904
+ function Ri() {
905
+ return `#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
906
+ }
907
+ function je() {
908
+ const t = de(this.opacity);
909
+ return `${t === 1 ? "rgb(" : "rgba("}${It(this.r)}, ${It(this.g)}, ${It(this.b)}${t === 1 ? ")" : `, ${t})`}`;
910
+ }
911
+ function de(t) {
912
+ return isNaN(t) ? 1 : Math.max(0, Math.min(1, t));
913
+ }
914
+ function It(t) {
915
+ return Math.max(0, Math.min(255, Math.round(t) || 0));
916
+ }
917
+ function zt(t) {
918
+ return t = It(t), (t < 16 ? "0" : "") + t.toString(16);
919
+ }
920
+ function tn(t, e, n, r) {
921
+ return r <= 0 ? t = e = n = NaN : n <= 0 || n >= 1 ? t = e = NaN : e <= 0 && (t = NaN), new dt(t, e, n, r);
922
+ }
923
+ function $n(t) {
924
+ if (t instanceof dt) return new dt(t.h, t.s, t.l, t.opacity);
925
+ if (t instanceof Jt || (t = Zt(t)), !t) return new dt();
926
+ if (t instanceof dt) return t;
927
+ t = t.rgb();
928
+ var e = t.r / 255, n = t.g / 255, r = t.b / 255, i = Math.min(e, n, r), s = Math.max(e, n, r), o = NaN, c = s - i, l = (s + i) / 2;
929
+ return c ? (e === s ? o = (n - r) / c + (n < r) * 6 : n === s ? o = (r - e) / c + 2 : o = (e - n) / c + 4, c /= l < 0.5 ? s + i : 2 - s - i, o *= 60) : c = l > 0 && l < 1 ? 0 : o, new dt(o, c, l, t.opacity);
930
+ }
931
+ function Di(t, e, n, r) {
932
+ return arguments.length === 1 ? $n(t) : new dt(t, e, n, r ?? 1);
933
+ }
934
+ function dt(t, e, n, r) {
935
+ this.h = +t, this.s = +e, this.l = +n, this.opacity = +r;
936
+ }
937
+ Fe(dt, Di, Nn(Jt, {
938
+ brighter(t) {
939
+ return t = t == null ? he : Math.pow(he, t), new dt(this.h, this.s, this.l * t, this.opacity);
940
+ },
941
+ darker(t) {
942
+ return t = t == null ? qt : Math.pow(qt, t), new dt(this.h, this.s, this.l * t, this.opacity);
943
+ },
944
+ rgb() {
945
+ var t = this.h % 360 + (this.h < 0) * 360, e = isNaN(t) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * e, i = 2 * n - r;
946
+ return new ut(
947
+ Ee(t >= 240 ? t - 240 : t + 120, i, r),
948
+ Ee(t, i, r),
949
+ Ee(t < 120 ? t + 240 : t - 120, i, r),
950
+ this.opacity
951
+ );
952
+ },
953
+ clamp() {
954
+ return new dt(en(this.h), ne(this.s), ne(this.l), de(this.opacity));
955
+ },
956
+ displayable() {
957
+ return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
958
+ },
959
+ formatHsl() {
960
+ const t = de(this.opacity);
961
+ return `${t === 1 ? "hsl(" : "hsla("}${en(this.h)}, ${ne(this.s) * 100}%, ${ne(this.l) * 100}%${t === 1 ? ")" : `, ${t})`}`;
962
+ }
963
+ }));
964
+ function en(t) {
965
+ return t = (t || 0) % 360, t < 0 ? t + 360 : t;
966
+ }
967
+ function ne(t) {
968
+ return Math.max(0, Math.min(1, t || 0));
969
+ }
970
+ function Ee(t, e, n) {
971
+ return (t < 60 ? e + (n - e) * t / 60 : t < 180 ? n : t < 240 ? e + (n - e) * (240 - t) / 60 : e) * 255;
972
+ }
973
+ const kn = (t) => () => t;
974
+ function Li(t, e) {
975
+ return function(n) {
976
+ return t + n * e;
977
+ };
978
+ }
979
+ function Fi(t, e, n) {
980
+ return t = Math.pow(t, n), e = Math.pow(e, n) - t, n = 1 / n, function(r) {
981
+ return Math.pow(t + r * e, n);
982
+ };
983
+ }
984
+ function Hi(t) {
985
+ return (t = +t) == 1 ? Cn : function(e, n) {
986
+ return n - e ? Fi(e, n, t) : kn(isNaN(e) ? n : e);
987
+ };
988
+ }
989
+ function Cn(t, e) {
990
+ var n = e - t;
991
+ return n ? Li(t, n) : kn(isNaN(t) ? e : t);
992
+ }
993
+ const nn = (function t(e) {
994
+ var n = Hi(e);
995
+ function r(i, s) {
996
+ var o = n((i = ze(i)).r, (s = ze(s)).r), c = n(i.g, s.g), l = n(i.b, s.b), a = Cn(i.opacity, s.opacity);
997
+ return function(u) {
998
+ return i.r = o(u), i.g = c(u), i.b = l(u), i.opacity = a(u), i + "";
999
+ };
1000
+ }
1001
+ return r.gamma = t, r;
1002
+ })(1);
1003
+ function bt(t, e) {
1004
+ return t = +t, e = +e, function(n) {
1005
+ return t * (1 - n) + e * n;
1006
+ };
1007
+ }
1008
+ var Ie = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Ne = new RegExp(Ie.source, "g");
1009
+ function Wi(t) {
1010
+ return function() {
1011
+ return t;
1012
+ };
1013
+ }
1014
+ function Oi(t) {
1015
+ return function(e) {
1016
+ return t(e) + "";
1017
+ };
1018
+ }
1019
+ function Xi(t, e) {
1020
+ var n = Ie.lastIndex = Ne.lastIndex = 0, r, i, s, o = -1, c = [], l = [];
1021
+ for (t = t + "", e = e + ""; (r = Ie.exec(t)) && (i = Ne.exec(e)); )
1022
+ (s = i.index) > n && (s = e.slice(n, s), c[o] ? c[o] += s : c[++o] = s), (r = r[0]) === (i = i[0]) ? c[o] ? c[o] += i : c[++o] = i : (c[++o] = null, l.push({ i: o, x: bt(r, i) })), n = Ne.lastIndex;
1023
+ return n < e.length && (s = e.slice(n), c[o] ? c[o] += s : c[++o] = s), c.length < 2 ? l[0] ? Oi(l[0].x) : Wi(e) : (e = l.length, function(a) {
1024
+ for (var u = 0, d; u < e; ++u) c[(d = l[u]).i] = d.x(a);
1025
+ return c.join("");
1026
+ });
1027
+ }
1028
+ var rn = 180 / Math.PI, Pe = {
1029
+ translateX: 0,
1030
+ translateY: 0,
1031
+ rotate: 0,
1032
+ skewX: 0,
1033
+ scaleX: 1,
1034
+ scaleY: 1
1035
+ };
1036
+ function Sn(t, e, n, r, i, s) {
1037
+ var o, c, l;
1038
+ return (o = Math.sqrt(t * t + e * e)) && (t /= o, e /= o), (l = t * n + e * r) && (n -= t * l, r -= e * l), (c = Math.sqrt(n * n + r * r)) && (n /= c, r /= c, l /= c), t * r < e * n && (t = -t, e = -e, l = -l, o = -o), {
1039
+ translateX: i,
1040
+ translateY: s,
1041
+ rotate: Math.atan2(e, t) * rn,
1042
+ skewX: Math.atan(l) * rn,
1043
+ scaleX: o,
1044
+ scaleY: c
1045
+ };
1046
+ }
1047
+ var re;
1048
+ function Gi(t) {
1049
+ const e = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(t + "");
1050
+ return e.isIdentity ? Pe : Sn(e.a, e.b, e.c, e.d, e.e, e.f);
1051
+ }
1052
+ function Vi(t) {
1053
+ return t == null || (re || (re = document.createElementNS("http://www.w3.org/2000/svg", "g")), re.setAttribute("transform", t), !(t = re.transform.baseVal.consolidate())) ? Pe : (t = t.matrix, Sn(t.a, t.b, t.c, t.d, t.e, t.f));
1054
+ }
1055
+ function An(t, e, n, r) {
1056
+ function i(a) {
1057
+ return a.length ? a.pop() + " " : "";
1058
+ }
1059
+ function s(a, u, d, g, x, N) {
1060
+ if (a !== d || u !== g) {
1061
+ var S = x.push("translate(", null, e, null, n);
1062
+ N.push({ i: S - 4, x: bt(a, d) }, { i: S - 2, x: bt(u, g) });
1063
+ } else (d || g) && x.push("translate(" + d + e + g + n);
1064
+ }
1065
+ function o(a, u, d, g) {
1066
+ a !== u ? (a - u > 180 ? u += 360 : u - a > 180 && (a += 360), g.push({ i: d.push(i(d) + "rotate(", null, r) - 2, x: bt(a, u) })) : u && d.push(i(d) + "rotate(" + u + r);
1067
+ }
1068
+ function c(a, u, d, g) {
1069
+ a !== u ? g.push({ i: d.push(i(d) + "skewX(", null, r) - 2, x: bt(a, u) }) : u && d.push(i(d) + "skewX(" + u + r);
1070
+ }
1071
+ function l(a, u, d, g, x, N) {
1072
+ if (a !== d || u !== g) {
1073
+ var S = x.push(i(x) + "scale(", null, ",", null, ")");
1074
+ N.push({ i: S - 4, x: bt(a, d) }, { i: S - 2, x: bt(u, g) });
1075
+ } else (d !== 1 || g !== 1) && x.push(i(x) + "scale(" + d + "," + g + ")");
1076
+ }
1077
+ return function(a, u) {
1078
+ var d = [], g = [];
1079
+ return a = t(a), u = t(u), s(a.translateX, a.translateY, u.translateX, u.translateY, d, g), o(a.rotate, u.rotate, d, g), c(a.skewX, u.skewX, d, g), l(a.scaleX, a.scaleY, u.scaleX, u.scaleY, d, g), a = u = null, function(x) {
1080
+ for (var N = -1, S = g.length, Y; ++N < S; ) d[(Y = g[N]).i] = Y.x(x);
1081
+ return d.join("");
1082
+ };
1083
+ };
1084
+ }
1085
+ var qi = An(Gi, "px, ", "px)", "deg)"), Ui = An(Vi, ", ", ")", ")"), Zi = 1e-12;
1086
+ function on(t) {
1087
+ return ((t = Math.exp(t)) + 1 / t) / 2;
1088
+ }
1089
+ function Ki(t) {
1090
+ return ((t = Math.exp(t)) - 1 / t) / 2;
1091
+ }
1092
+ function Qi(t) {
1093
+ return ((t = Math.exp(2 * t)) - 1) / (t + 1);
1094
+ }
1095
+ const Ji = (function t(e, n, r) {
1096
+ function i(s, o) {
1097
+ var c = s[0], l = s[1], a = s[2], u = o[0], d = o[1], g = o[2], x = u - c, N = d - l, S = x * x + N * N, Y, $;
1098
+ if (S < Zi)
1099
+ $ = Math.log(g / a) / e, Y = function(et) {
1100
+ return [
1101
+ c + et * x,
1102
+ l + et * N,
1103
+ a * Math.exp(e * et * $)
1104
+ ];
1105
+ };
1106
+ else {
1107
+ var K = Math.sqrt(S), O = (g * g - a * a + r * S) / (2 * a * n * K), Q = (g * g - a * a - r * S) / (2 * g * n * K), G = Math.log(Math.sqrt(O * O + 1) - O), F = Math.log(Math.sqrt(Q * Q + 1) - Q);
1108
+ $ = (F - G) / e, Y = function(et) {
1109
+ var z = et * $, B = on(G), H = a / (n * K) * (B * Qi(e * z + G) - Ki(G));
1110
+ return [
1111
+ c + H * x,
1112
+ l + H * N,
1113
+ a * B / on(e * z + G)
1114
+ ];
1115
+ };
1116
+ }
1117
+ return Y.duration = $ * 1e3 * e / Math.SQRT2, Y;
1118
+ }
1119
+ return i.rho = function(s) {
1120
+ var o = Math.max(1e-3, +s), c = o * o, l = c * c;
1121
+ return t(o, c, l);
1122
+ }, i;
1123
+ })(Math.SQRT2, 2, 4);
1124
+ var Dt = 0, Xt = 0, Wt = 0, Mn = 1e3, pe, Gt, ge = 0, Pt = 0, xe = 0, Kt = typeof performance == "object" && performance.now ? performance : Date, zn = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(t) {
1125
+ setTimeout(t, 17);
1126
+ };
1127
+ function He() {
1128
+ return Pt || (zn(ji), Pt = Kt.now() + xe);
1129
+ }
1130
+ function ji() {
1131
+ Pt = 0;
1132
+ }
1133
+ function me() {
1134
+ this._call = this._time = this._next = null;
1135
+ }
1136
+ me.prototype = In.prototype = {
1137
+ constructor: me,
1138
+ restart: function(t, e, n) {
1139
+ if (typeof t != "function") throw new TypeError("callback is not a function");
1140
+ n = (n == null ? He() : +n) + (e == null ? 0 : +e), !this._next && Gt !== this && (Gt ? Gt._next = this : pe = this, Gt = this), this._call = t, this._time = n, Ye();
1141
+ },
1142
+ stop: function() {
1143
+ this._call && (this._call = null, this._time = 1 / 0, Ye());
1144
+ }
1145
+ };
1146
+ function In(t, e, n) {
1147
+ var r = new me();
1148
+ return r.restart(t, e, n), r;
1149
+ }
1150
+ function to() {
1151
+ He(), ++Dt;
1152
+ for (var t = pe, e; t; )
1153
+ (e = Pt - t._time) >= 0 && t._call.call(void 0, e), t = t._next;
1154
+ --Dt;
1155
+ }
1156
+ function sn() {
1157
+ Pt = (ge = Kt.now()) + xe, Dt = Xt = 0;
1158
+ try {
1159
+ to();
1160
+ } finally {
1161
+ Dt = 0, no(), Pt = 0;
1162
+ }
1163
+ }
1164
+ function eo() {
1165
+ var t = Kt.now(), e = t - ge;
1166
+ e > Mn && (xe -= e, ge = t);
1167
+ }
1168
+ function no() {
1169
+ for (var t, e = pe, n, r = 1 / 0; e; )
1170
+ e._call ? (r > e._time && (r = e._time), t = e, e = e._next) : (n = e._next, e._next = null, e = t ? t._next = n : pe = n);
1171
+ Gt = t, Ye(r);
1172
+ }
1173
+ function Ye(t) {
1174
+ if (!Dt) {
1175
+ Xt && (Xt = clearTimeout(Xt));
1176
+ var e = t - Pt;
1177
+ e > 24 ? (t < 1 / 0 && (Xt = setTimeout(sn, t - Kt.now() - xe)), Wt && (Wt = clearInterval(Wt))) : (Wt || (ge = Kt.now(), Wt = setInterval(eo, Mn)), Dt = 1, zn(sn));
1178
+ }
1179
+ }
1180
+ function an(t, e, n) {
1181
+ var r = new me();
1182
+ return e = e == null ? 0 : +e, r.restart((i) => {
1183
+ r.stop(), t(i + e);
1184
+ }, e, n), r;
1185
+ }
1186
+ var ro = Re("start", "end", "cancel", "interrupt"), io = [], Pn = 0, cn = 1, Te = 2, ae = 3, ln = 4, Be = 5, ce = 6;
1187
+ function we(t, e, n, r, i, s) {
1188
+ var o = t.__transition;
1189
+ if (!o) t.__transition = {};
1190
+ else if (n in o) return;
1191
+ oo(t, n, {
1192
+ name: e,
1193
+ index: r,
1194
+ // For context during callback.
1195
+ group: i,
1196
+ // For context during callback.
1197
+ on: ro,
1198
+ tween: io,
1199
+ time: s.time,
1200
+ delay: s.delay,
1201
+ duration: s.duration,
1202
+ ease: s.ease,
1203
+ timer: null,
1204
+ state: Pn
1205
+ });
1206
+ }
1207
+ function We(t, e) {
1208
+ var n = pt(t, e);
1209
+ if (n.state > Pn) throw new Error("too late; already scheduled");
1210
+ return n;
1211
+ }
1212
+ function xt(t, e) {
1213
+ var n = pt(t, e);
1214
+ if (n.state > ae) throw new Error("too late; already running");
1215
+ return n;
1216
+ }
1217
+ function pt(t, e) {
1218
+ var n = t.__transition;
1219
+ if (!n || !(n = n[e])) throw new Error("transition not found");
1220
+ return n;
1221
+ }
1222
+ function oo(t, e, n) {
1223
+ var r = t.__transition, i;
1224
+ r[e] = n, n.timer = In(s, 0, n.time);
1225
+ function s(a) {
1226
+ n.state = cn, n.timer.restart(o, n.delay, n.time), n.delay <= a && o(a - n.delay);
1227
+ }
1228
+ function o(a) {
1229
+ var u, d, g, x;
1230
+ if (n.state !== cn) return l();
1231
+ for (u in r)
1232
+ if (x = r[u], x.name === n.name) {
1233
+ if (x.state === ae) return an(o);
1234
+ x.state === ln ? (x.state = ce, x.timer.stop(), x.on.call("interrupt", t, t.__data__, x.index, x.group), delete r[u]) : +u < e && (x.state = ce, x.timer.stop(), x.on.call("cancel", t, t.__data__, x.index, x.group), delete r[u]);
1235
+ }
1236
+ if (an(function() {
1237
+ n.state === ae && (n.state = ln, n.timer.restart(c, n.delay, n.time), c(a));
1238
+ }), n.state = Te, n.on.call("start", t, t.__data__, n.index, n.group), n.state === Te) {
1239
+ for (n.state = ae, i = new Array(g = n.tween.length), u = 0, d = -1; u < g; ++u)
1240
+ (x = n.tween[u].value.call(t, t.__data__, n.index, n.group)) && (i[++d] = x);
1241
+ i.length = d + 1;
1242
+ }
1243
+ }
1244
+ function c(a) {
1245
+ for (var u = a < n.duration ? n.ease.call(null, a / n.duration) : (n.timer.restart(l), n.state = Be, 1), d = -1, g = i.length; ++d < g; )
1246
+ i[d].call(t, u);
1247
+ n.state === Be && (n.on.call("end", t, t.__data__, n.index, n.group), l());
1248
+ }
1249
+ function l() {
1250
+ n.state = ce, n.timer.stop(), delete r[e];
1251
+ for (var a in r) return;
1252
+ delete t.__transition;
1253
+ }
1254
+ }
1255
+ function le(t, e) {
1256
+ var n = t.__transition, r, i, s = !0, o;
1257
+ if (n) {
1258
+ e = e == null ? null : e + "";
1259
+ for (o in n) {
1260
+ if ((r = n[o]).name !== e) {
1261
+ s = !1;
1262
+ continue;
1263
+ }
1264
+ i = r.state > Te && r.state < Be, r.state = ce, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", t, t.__data__, r.index, r.group), delete n[o];
1265
+ }
1266
+ s && delete t.__transition;
1267
+ }
1268
+ }
1269
+ function so(t) {
1270
+ return this.each(function() {
1271
+ le(this, t);
1272
+ });
1273
+ }
1274
+ function ao(t, e) {
1275
+ var n, r;
1276
+ return function() {
1277
+ var i = xt(this, t), s = i.tween;
1278
+ if (s !== n) {
1279
+ r = n = s;
1280
+ for (var o = 0, c = r.length; o < c; ++o)
1281
+ if (r[o].name === e) {
1282
+ r = r.slice(), r.splice(o, 1);
1283
+ break;
1284
+ }
1285
+ }
1286
+ i.tween = r;
1287
+ };
1288
+ }
1289
+ function co(t, e, n) {
1290
+ var r, i;
1291
+ if (typeof n != "function") throw new Error();
1292
+ return function() {
1293
+ var s = xt(this, t), o = s.tween;
1294
+ if (o !== r) {
1295
+ i = (r = o).slice();
1296
+ for (var c = { name: e, value: n }, l = 0, a = i.length; l < a; ++l)
1297
+ if (i[l].name === e) {
1298
+ i[l] = c;
1299
+ break;
1300
+ }
1301
+ l === a && i.push(c);
1302
+ }
1303
+ s.tween = i;
1304
+ };
1305
+ }
1306
+ function lo(t, e) {
1307
+ var n = this._id;
1308
+ if (t += "", arguments.length < 2) {
1309
+ for (var r = pt(this.node(), n).tween, i = 0, s = r.length, o; i < s; ++i)
1310
+ if ((o = r[i]).name === t)
1311
+ return o.value;
1312
+ return null;
1313
+ }
1314
+ return this.each((e == null ? ao : co)(n, t, e));
1315
+ }
1316
+ function Oe(t, e, n) {
1317
+ var r = t._id;
1318
+ return t.each(function() {
1319
+ var i = xt(this, r);
1320
+ (i.value || (i.value = {}))[e] = n.apply(this, arguments);
1321
+ }), function(i) {
1322
+ return pt(i, r).value[e];
1323
+ };
1324
+ }
1325
+ function Yn(t, e) {
1326
+ var n;
1327
+ return (typeof e == "number" ? bt : e instanceof Zt ? nn : (n = Zt(e)) ? (e = n, nn) : Xi)(t, e);
1328
+ }
1329
+ function uo(t) {
1330
+ return function() {
1331
+ this.removeAttribute(t);
1332
+ };
1333
+ }
1334
+ function fo(t) {
1335
+ return function() {
1336
+ this.removeAttributeNS(t.space, t.local);
1337
+ };
1338
+ }
1339
+ function ho(t, e, n) {
1340
+ var r, i = n + "", s;
1341
+ return function() {
1342
+ var o = this.getAttribute(t);
1343
+ return o === i ? null : o === r ? s : s = e(r = o, n);
1344
+ };
1345
+ }
1346
+ function po(t, e, n) {
1347
+ var r, i = n + "", s;
1348
+ return function() {
1349
+ var o = this.getAttributeNS(t.space, t.local);
1350
+ return o === i ? null : o === r ? s : s = e(r = o, n);
1351
+ };
1352
+ }
1353
+ function go(t, e, n) {
1354
+ var r, i, s;
1355
+ return function() {
1356
+ var o, c = n(this), l;
1357
+ return c == null ? void this.removeAttribute(t) : (o = this.getAttribute(t), l = c + "", o === l ? null : o === r && l === i ? s : (i = l, s = e(r = o, c)));
1358
+ };
1359
+ }
1360
+ function mo(t, e, n) {
1361
+ var r, i, s;
1362
+ return function() {
1363
+ var o, c = n(this), l;
1364
+ return c == null ? void this.removeAttributeNS(t.space, t.local) : (o = this.getAttributeNS(t.space, t.local), l = c + "", o === l ? null : o === r && l === i ? s : (i = l, s = e(r = o, c)));
1365
+ };
1366
+ }
1367
+ function yo(t, e) {
1368
+ var n = ye(t), r = n === "transform" ? Ui : Yn;
1369
+ return this.attrTween(t, typeof e == "function" ? (n.local ? mo : go)(n, r, Oe(this, "attr." + t, e)) : e == null ? (n.local ? fo : uo)(n) : (n.local ? po : ho)(n, r, e));
1370
+ }
1371
+ function xo(t, e) {
1372
+ return function(n) {
1373
+ this.setAttribute(t, e.call(this, n));
1374
+ };
1375
+ }
1376
+ function wo(t, e) {
1377
+ return function(n) {
1378
+ this.setAttributeNS(t.space, t.local, e.call(this, n));
1379
+ };
1380
+ }
1381
+ function vo(t, e) {
1382
+ var n, r;
1383
+ function i() {
1384
+ var s = e.apply(this, arguments);
1385
+ return s !== r && (n = (r = s) && wo(t, s)), n;
1386
+ }
1387
+ return i._value = e, i;
1388
+ }
1389
+ function _o(t, e) {
1390
+ var n, r;
1391
+ function i() {
1392
+ var s = e.apply(this, arguments);
1393
+ return s !== r && (n = (r = s) && xo(t, s)), n;
1394
+ }
1395
+ return i._value = e, i;
1396
+ }
1397
+ function bo(t, e) {
1398
+ var n = "attr." + t;
1399
+ if (arguments.length < 2) return (n = this.tween(n)) && n._value;
1400
+ if (e == null) return this.tween(n, null);
1401
+ if (typeof e != "function") throw new Error();
1402
+ var r = ye(t);
1403
+ return this.tween(n, (r.local ? vo : _o)(r, e));
1404
+ }
1405
+ function Eo(t, e) {
1406
+ return function() {
1407
+ We(this, t).delay = +e.apply(this, arguments);
1408
+ };
1409
+ }
1410
+ function No(t, e) {
1411
+ return e = +e, function() {
1412
+ We(this, t).delay = e;
1413
+ };
1414
+ }
1415
+ function $o(t) {
1416
+ var e = this._id;
1417
+ return arguments.length ? this.each((typeof t == "function" ? Eo : No)(e, t)) : pt(this.node(), e).delay;
1418
+ }
1419
+ function ko(t, e) {
1420
+ return function() {
1421
+ xt(this, t).duration = +e.apply(this, arguments);
1422
+ };
1423
+ }
1424
+ function Co(t, e) {
1425
+ return e = +e, function() {
1426
+ xt(this, t).duration = e;
1427
+ };
1428
+ }
1429
+ function So(t) {
1430
+ var e = this._id;
1431
+ return arguments.length ? this.each((typeof t == "function" ? ko : Co)(e, t)) : pt(this.node(), e).duration;
1432
+ }
1433
+ function Ao(t, e) {
1434
+ if (typeof e != "function") throw new Error();
1435
+ return function() {
1436
+ xt(this, t).ease = e;
1437
+ };
1438
+ }
1439
+ function Mo(t) {
1440
+ var e = this._id;
1441
+ return arguments.length ? this.each(Ao(e, t)) : pt(this.node(), e).ease;
1442
+ }
1443
+ function zo(t, e) {
1444
+ return function() {
1445
+ var n = e.apply(this, arguments);
1446
+ if (typeof n != "function") throw new Error();
1447
+ xt(this, t).ease = n;
1448
+ };
1449
+ }
1450
+ function Io(t) {
1451
+ if (typeof t != "function") throw new Error();
1452
+ return this.each(zo(this._id, t));
1453
+ }
1454
+ function Po(t) {
1455
+ typeof t != "function" && (t = pn(t));
1456
+ for (var e = this._groups, n = e.length, r = new Array(n), i = 0; i < n; ++i)
1457
+ for (var s = e[i], o = s.length, c = r[i] = [], l, a = 0; a < o; ++a)
1458
+ (l = s[a]) && t.call(l, l.__data__, a, s) && c.push(l);
1459
+ return new _t(r, this._parents, this._name, this._id);
1460
+ }
1461
+ function Yo(t) {
1462
+ if (t._id !== this._id) throw new Error();
1463
+ for (var e = this._groups, n = t._groups, r = e.length, i = n.length, s = Math.min(r, i), o = new Array(r), c = 0; c < s; ++c)
1464
+ for (var l = e[c], a = n[c], u = l.length, d = o[c] = new Array(u), g, x = 0; x < u; ++x)
1465
+ (g = l[x] || a[x]) && (d[x] = g);
1466
+ for (; c < r; ++c)
1467
+ o[c] = e[c];
1468
+ return new _t(o, this._parents, this._name, this._id);
1469
+ }
1470
+ function To(t) {
1471
+ return (t + "").trim().split(/^|\s+/).every(function(e) {
1472
+ var n = e.indexOf(".");
1473
+ return n >= 0 && (e = e.slice(0, n)), !e || e === "start";
1474
+ });
1475
+ }
1476
+ function Bo(t, e, n) {
1477
+ var r, i, s = To(e) ? We : xt;
1478
+ return function() {
1479
+ var o = s(this, t), c = o.on;
1480
+ c !== r && (i = (r = c).copy()).on(e, n), o.on = i;
1481
+ };
1482
+ }
1483
+ function Ro(t, e) {
1484
+ var n = this._id;
1485
+ return arguments.length < 2 ? pt(this.node(), n).on.on(t) : this.each(Bo(n, t, e));
1486
+ }
1487
+ function Do(t) {
1488
+ return function() {
1489
+ var e = this.parentNode;
1490
+ for (var n in this.__transition) if (+n !== t) return;
1491
+ e && e.removeChild(this);
1492
+ };
1493
+ }
1494
+ function Lo() {
1495
+ return this.on("end.remove", Do(this._id));
1496
+ }
1497
+ function Fo(t) {
1498
+ var e = this._name, n = this._id;
1499
+ typeof t != "function" && (t = De(t));
1500
+ for (var r = this._groups, i = r.length, s = new Array(i), o = 0; o < i; ++o)
1501
+ for (var c = r[o], l = c.length, a = s[o] = new Array(l), u, d, g = 0; g < l; ++g)
1502
+ (u = c[g]) && (d = t.call(u, u.__data__, g, c)) && ("__data__" in u && (d.__data__ = u.__data__), a[g] = d, we(a[g], e, n, g, a, pt(u, n)));
1503
+ return new _t(s, this._parents, e, n);
1504
+ }
1505
+ function Ho(t) {
1506
+ var e = this._name, n = this._id;
1507
+ typeof t != "function" && (t = dn(t));
1508
+ for (var r = this._groups, i = r.length, s = [], o = [], c = 0; c < i; ++c)
1509
+ for (var l = r[c], a = l.length, u, d = 0; d < a; ++d)
1510
+ if (u = l[d]) {
1511
+ for (var g = t.call(u, u.__data__, d, l), x, N = pt(u, n), S = 0, Y = g.length; S < Y; ++S)
1512
+ (x = g[S]) && we(x, e, n, S, g, N);
1513
+ s.push(g), o.push(u);
1514
+ }
1515
+ return new _t(s, o, e, n);
1516
+ }
1517
+ var Wo = Qt.prototype.constructor;
1518
+ function Oo() {
1519
+ return new Wo(this._groups, this._parents);
1520
+ }
1521
+ function Xo(t, e) {
1522
+ var n, r, i;
1523
+ return function() {
1524
+ var s = Rt(this, t), o = (this.style.removeProperty(t), Rt(this, t));
1525
+ return s === o ? null : s === n && o === r ? i : i = e(n = s, r = o);
1526
+ };
1527
+ }
1528
+ function Tn(t) {
1529
+ return function() {
1530
+ this.style.removeProperty(t);
1531
+ };
1532
+ }
1533
+ function Go(t, e, n) {
1534
+ var r, i = n + "", s;
1535
+ return function() {
1536
+ var o = Rt(this, t);
1537
+ return o === i ? null : o === r ? s : s = e(r = o, n);
1538
+ };
1539
+ }
1540
+ function Vo(t, e, n) {
1541
+ var r, i, s;
1542
+ return function() {
1543
+ var o = Rt(this, t), c = n(this), l = c + "";
1544
+ return c == null && (l = c = (this.style.removeProperty(t), Rt(this, t))), o === l ? null : o === r && l === i ? s : (i = l, s = e(r = o, c));
1545
+ };
1546
+ }
1547
+ function qo(t, e) {
1548
+ var n, r, i, s = "style." + e, o = "end." + s, c;
1549
+ return function() {
1550
+ var l = xt(this, t), a = l.on, u = l.value[s] == null ? c || (c = Tn(e)) : void 0;
1551
+ (a !== n || i !== u) && (r = (n = a).copy()).on(o, i = u), l.on = r;
1552
+ };
1553
+ }
1554
+ function Uo(t, e, n) {
1555
+ var r = (t += "") == "transform" ? qi : Yn;
1556
+ return e == null ? this.styleTween(t, Xo(t, r)).on("end.style." + t, Tn(t)) : typeof e == "function" ? this.styleTween(t, Vo(t, r, Oe(this, "style." + t, e))).each(qo(this._id, t)) : this.styleTween(t, Go(t, r, e), n).on("end.style." + t, null);
1557
+ }
1558
+ function Zo(t, e, n) {
1559
+ return function(r) {
1560
+ this.style.setProperty(t, e.call(this, r), n);
1561
+ };
1562
+ }
1563
+ function Ko(t, e, n) {
1564
+ var r, i;
1565
+ function s() {
1566
+ var o = e.apply(this, arguments);
1567
+ return o !== i && (r = (i = o) && Zo(t, o, n)), r;
1568
+ }
1569
+ return s._value = e, s;
1570
+ }
1571
+ function Qo(t, e, n) {
1572
+ var r = "style." + (t += "");
1573
+ if (arguments.length < 2) return (r = this.tween(r)) && r._value;
1574
+ if (e == null) return this.tween(r, null);
1575
+ if (typeof e != "function") throw new Error();
1576
+ return this.tween(r, Ko(t, e, n ?? ""));
1577
+ }
1578
+ function Jo(t) {
1579
+ return function() {
1580
+ this.textContent = t;
1581
+ };
1582
+ }
1583
+ function jo(t) {
1584
+ return function() {
1585
+ var e = t(this);
1586
+ this.textContent = e ?? "";
1587
+ };
1588
+ }
1589
+ function ts(t) {
1590
+ return this.tween("text", typeof t == "function" ? jo(Oe(this, "text", t)) : Jo(t == null ? "" : t + ""));
1591
+ }
1592
+ function es(t) {
1593
+ return function(e) {
1594
+ this.textContent = t.call(this, e);
1595
+ };
1596
+ }
1597
+ function ns(t) {
1598
+ var e, n;
1599
+ function r() {
1600
+ var i = t.apply(this, arguments);
1601
+ return i !== n && (e = (n = i) && es(i)), e;
1602
+ }
1603
+ return r._value = t, r;
1604
+ }
1605
+ function rs(t) {
1606
+ var e = "text";
1607
+ if (arguments.length < 1) return (e = this.tween(e)) && e._value;
1608
+ if (t == null) return this.tween(e, null);
1609
+ if (typeof t != "function") throw new Error();
1610
+ return this.tween(e, ns(t));
1611
+ }
1612
+ function is() {
1613
+ for (var t = this._name, e = this._id, n = Bn(), r = this._groups, i = r.length, s = 0; s < i; ++s)
1614
+ for (var o = r[s], c = o.length, l, a = 0; a < c; ++a)
1615
+ if (l = o[a]) {
1616
+ var u = pt(l, e);
1617
+ we(l, t, n, a, o, {
1618
+ time: u.time + u.delay + u.duration,
1619
+ delay: 0,
1620
+ duration: u.duration,
1621
+ ease: u.ease
1622
+ });
1623
+ }
1624
+ return new _t(r, this._parents, t, n);
1625
+ }
1626
+ function os() {
1627
+ var t, e, n = this, r = n._id, i = n.size();
1628
+ return new Promise(function(s, o) {
1629
+ var c = { value: o }, l = { value: function() {
1630
+ --i === 0 && s();
1631
+ } };
1632
+ n.each(function() {
1633
+ var a = xt(this, r), u = a.on;
1634
+ u !== t && (e = (t = u).copy(), e._.cancel.push(c), e._.interrupt.push(c), e._.end.push(l)), a.on = e;
1635
+ }), i === 0 && s();
1636
+ });
1637
+ }
1638
+ var ss = 0;
1639
+ function _t(t, e, n, r) {
1640
+ this._groups = t, this._parents = e, this._name = n, this._id = r;
1641
+ }
1642
+ function Bn() {
1643
+ return ++ss;
1644
+ }
1645
+ var wt = Qt.prototype;
1646
+ _t.prototype = {
1647
+ constructor: _t,
1648
+ select: Fo,
1649
+ selectAll: Ho,
1650
+ selectChild: wt.selectChild,
1651
+ selectChildren: wt.selectChildren,
1652
+ filter: Po,
1653
+ merge: Yo,
1654
+ selection: Oo,
1655
+ transition: is,
1656
+ call: wt.call,
1657
+ nodes: wt.nodes,
1658
+ node: wt.node,
1659
+ size: wt.size,
1660
+ empty: wt.empty,
1661
+ each: wt.each,
1662
+ on: Ro,
1663
+ attr: yo,
1664
+ attrTween: bo,
1665
+ style: Uo,
1666
+ styleTween: Qo,
1667
+ text: ts,
1668
+ textTween: rs,
1669
+ remove: Lo,
1670
+ tween: lo,
1671
+ delay: $o,
1672
+ duration: So,
1673
+ ease: Mo,
1674
+ easeVarying: Io,
1675
+ end: os,
1676
+ [Symbol.iterator]: wt[Symbol.iterator]
1677
+ };
1678
+ function as(t) {
1679
+ return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
1680
+ }
1681
+ var cs = {
1682
+ time: null,
1683
+ // Set on use.
1684
+ delay: 0,
1685
+ duration: 250,
1686
+ ease: as
1687
+ };
1688
+ function ls(t, e) {
1689
+ for (var n; !(n = t.__transition) || !(n = n[e]); )
1690
+ if (!(t = t.parentNode))
1691
+ throw new Error(`transition ${e} not found`);
1692
+ return n;
1693
+ }
1694
+ function us(t) {
1695
+ var e, n;
1696
+ t instanceof _t ? (e = t._id, t = t._name) : (e = Bn(), (n = cs).time = He(), t = t == null ? null : t + "");
1697
+ for (var r = this._groups, i = r.length, s = 0; s < i; ++s)
1698
+ for (var o = r[s], c = o.length, l, a = 0; a < c; ++a)
1699
+ (l = o[a]) && we(l, t, e, a, o, n || ls(l, e));
1700
+ return new _t(r, this._parents, t, e);
1701
+ }
1702
+ Qt.prototype.interrupt = so;
1703
+ Qt.prototype.transition = us;
1704
+ const ie = (t) => () => t;
1705
+ function fs(t, {
1706
+ sourceEvent: e,
1707
+ target: n,
1708
+ transform: r,
1709
+ dispatch: i
1710
+ }) {
1711
+ Object.defineProperties(this, {
1712
+ type: { value: t, enumerable: !0, configurable: !0 },
1713
+ sourceEvent: { value: e, enumerable: !0, configurable: !0 },
1714
+ target: { value: n, enumerable: !0, configurable: !0 },
1715
+ transform: { value: r, enumerable: !0, configurable: !0 },
1716
+ _: { value: i }
1717
+ });
1718
+ }
1719
+ function vt(t, e, n) {
1720
+ this.k = t, this.x = e, this.y = n;
1721
+ }
1722
+ vt.prototype = {
1723
+ constructor: vt,
1724
+ scale: function(t) {
1725
+ return t === 1 ? this : new vt(this.k * t, this.x, this.y);
1726
+ },
1727
+ translate: function(t, e) {
1728
+ return t === 0 & e === 0 ? this : new vt(this.k, this.x + this.k * t, this.y + this.k * e);
1729
+ },
1730
+ apply: function(t) {
1731
+ return [t[0] * this.k + this.x, t[1] * this.k + this.y];
1732
+ },
1733
+ applyX: function(t) {
1734
+ return t * this.k + this.x;
1735
+ },
1736
+ applyY: function(t) {
1737
+ return t * this.k + this.y;
1738
+ },
1739
+ invert: function(t) {
1740
+ return [(t[0] - this.x) / this.k, (t[1] - this.y) / this.k];
1741
+ },
1742
+ invertX: function(t) {
1743
+ return (t - this.x) / this.k;
1744
+ },
1745
+ invertY: function(t) {
1746
+ return (t - this.y) / this.k;
1747
+ },
1748
+ rescaleX: function(t) {
1749
+ return t.copy().domain(t.range().map(this.invertX, this).map(t.invert, t));
1750
+ },
1751
+ rescaleY: function(t) {
1752
+ return t.copy().domain(t.range().map(this.invertY, this).map(t.invert, t));
1753
+ },
1754
+ toString: function() {
1755
+ return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
1756
+ }
1757
+ };
1758
+ var Nt = new vt(1, 0, 0);
1759
+ Vt.prototype = vt.prototype;
1760
+ function Vt(t) {
1761
+ for (; !t.__zoom; ) if (!(t = t.parentNode)) return Nt;
1762
+ return t.__zoom;
1763
+ }
1764
+ function $e(t) {
1765
+ t.stopImmediatePropagation();
1766
+ }
1767
+ function Ot(t) {
1768
+ t.preventDefault(), t.stopImmediatePropagation();
1769
+ }
1770
+ function hs(t) {
1771
+ return (!t.ctrlKey || t.type === "wheel") && !t.button;
1772
+ }
1773
+ function ds() {
1774
+ var t = this;
1775
+ return t instanceof SVGElement ? (t = t.ownerSVGElement || t, t.hasAttribute("viewBox") ? (t = t.viewBox.baseVal, [[t.x, t.y], [t.x + t.width, t.y + t.height]]) : [[0, 0], [t.width.baseVal.value, t.height.baseVal.value]]) : [[0, 0], [t.clientWidth, t.clientHeight]];
1776
+ }
1777
+ function un() {
1778
+ return this.__zoom || Nt;
1779
+ }
1780
+ function ps(t) {
1781
+ return -t.deltaY * (t.deltaMode === 1 ? 0.05 : t.deltaMode ? 1 : 2e-3) * (t.ctrlKey ? 10 : 1);
1782
+ }
1783
+ function gs() {
1784
+ return navigator.maxTouchPoints || "ontouchstart" in this;
1785
+ }
1786
+ function ms(t, e, n) {
1787
+ var r = t.invertX(e[0][0]) - n[0][0], i = t.invertX(e[1][0]) - n[1][0], s = t.invertY(e[0][1]) - n[0][1], o = t.invertY(e[1][1]) - n[1][1];
1788
+ return t.translate(
1789
+ i > r ? (r + i) / 2 : Math.min(0, r) || Math.max(0, i),
1790
+ o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
1791
+ );
1792
+ }
1793
+ function Xe() {
1794
+ var t = hs, e = ds, n = ms, r = ps, i = gs, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], c = 250, l = Ji, a = Re("start", "zoom", "end"), u, d, g, x = 500, N = 150, S = 0, Y = 10;
1795
+ function $(h) {
1796
+ h.property("__zoom", un).on("wheel.zoom", z, { passive: !1 }).on("mousedown.zoom", B).on("dblclick.zoom", H).filter(i).on("touchstart.zoom", I).on("touchmove.zoom", Z).on("touchend.zoom touchcancel.zoom", tt).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
1797
+ }
1798
+ $.transform = function(h, k, y, C) {
1799
+ var T = h.selection ? h.selection() : h;
1800
+ T.property("__zoom", un), h !== T ? G(h, k, y, C) : T.interrupt().each(function() {
1801
+ F(this, arguments).event(C).start().zoom(null, typeof k == "function" ? k.apply(this, arguments) : k).end();
1802
+ });
1803
+ }, $.scaleBy = function(h, k, y, C) {
1804
+ $.scaleTo(h, function() {
1805
+ var T = this.__zoom.k, R = typeof k == "function" ? k.apply(this, arguments) : k;
1806
+ return T * R;
1807
+ }, y, C);
1808
+ }, $.scaleTo = function(h, k, y, C) {
1809
+ $.transform(h, function() {
1810
+ var T = e.apply(this, arguments), R = this.__zoom, M = y == null ? Q(T) : typeof y == "function" ? y.apply(this, arguments) : y, f = R.invert(M), p = typeof k == "function" ? k.apply(this, arguments) : k;
1811
+ return n(O(K(R, p), M, f), T, o);
1812
+ }, y, C);
1813
+ }, $.translateBy = function(h, k, y, C) {
1814
+ $.transform(h, function() {
1815
+ return n(this.__zoom.translate(
1816
+ typeof k == "function" ? k.apply(this, arguments) : k,
1817
+ typeof y == "function" ? y.apply(this, arguments) : y
1818
+ ), e.apply(this, arguments), o);
1819
+ }, null, C);
1820
+ }, $.translateTo = function(h, k, y, C, T) {
1821
+ $.transform(h, function() {
1822
+ var R = e.apply(this, arguments), M = this.__zoom, f = C == null ? Q(R) : typeof C == "function" ? C.apply(this, arguments) : C;
1823
+ return n(Nt.translate(f[0], f[1]).scale(M.k).translate(
1824
+ typeof k == "function" ? -k.apply(this, arguments) : -k,
1825
+ typeof y == "function" ? -y.apply(this, arguments) : -y
1826
+ ), R, o);
1827
+ }, C, T);
1828
+ };
1829
+ function K(h, k) {
1830
+ return k = Math.max(s[0], Math.min(s[1], k)), k === h.k ? h : new vt(k, h.x, h.y);
1831
+ }
1832
+ function O(h, k, y) {
1833
+ var C = k[0] - y[0] * h.k, T = k[1] - y[1] * h.k;
1834
+ return C === h.x && T === h.y ? h : new vt(h.k, C, T);
1835
+ }
1836
+ function Q(h) {
1837
+ return [(+h[0][0] + +h[1][0]) / 2, (+h[0][1] + +h[1][1]) / 2];
1838
+ }
1839
+ function G(h, k, y, C) {
1840
+ h.on("start.zoom", function() {
1841
+ F(this, arguments).event(C).start();
1842
+ }).on("interrupt.zoom end.zoom", function() {
1843
+ F(this, arguments).event(C).end();
1844
+ }).tween("zoom", function() {
1845
+ var T = this, R = arguments, M = F(T, R).event(C), f = e.apply(T, R), p = y == null ? Q(f) : typeof y == "function" ? y.apply(T, R) : y, A = Math.max(f[1][0] - f[0][0], f[1][1] - f[0][1]), w = T.__zoom, v = typeof k == "function" ? k.apply(T, R) : k, b = l(w.invert(p).concat(A / w.k), v.invert(p).concat(A / v.k));
1846
+ return function(m) {
1847
+ if (m === 1) m = v;
1848
+ else {
1849
+ var _ = b(m), E = A / _[2];
1850
+ m = new vt(E, p[0] - _[0] * E, p[1] - _[1] * E);
1851
+ }
1852
+ M.zoom(null, m);
1853
+ };
1854
+ });
1855
+ }
1856
+ function F(h, k, y) {
1857
+ return !y && h.__zooming || new et(h, k);
1858
+ }
1859
+ function et(h, k) {
1860
+ this.that = h, this.args = k, this.active = 0, this.sourceEvent = null, this.extent = e.apply(h, k), this.taps = 0;
1861
+ }
1862
+ et.prototype = {
1863
+ event: function(h) {
1864
+ return h && (this.sourceEvent = h), this;
1865
+ },
1866
+ start: function() {
1867
+ return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
1868
+ },
1869
+ zoom: function(h, k) {
1870
+ return this.mouse && h !== "mouse" && (this.mouse[1] = k.invert(this.mouse[0])), this.touch0 && h !== "touch" && (this.touch0[1] = k.invert(this.touch0[0])), this.touch1 && h !== "touch" && (this.touch1[1] = k.invert(this.touch1[0])), this.that.__zoom = k, this.emit("zoom"), this;
1871
+ },
1872
+ end: function() {
1873
+ return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
1874
+ },
1875
+ emit: function(h) {
1876
+ var k = ot(this.that).datum();
1877
+ a.call(
1878
+ h,
1879
+ this.that,
1880
+ new fs(h, {
1881
+ sourceEvent: this.sourceEvent,
1882
+ target: $,
1883
+ transform: this.that.__zoom,
1884
+ dispatch: a
1885
+ }),
1886
+ k
1887
+ );
1888
+ }
1889
+ };
1890
+ function z(h, ...k) {
1891
+ if (!t.apply(this, arguments)) return;
1892
+ var y = F(this, k).event(h), C = this.__zoom, T = Math.max(s[0], Math.min(s[1], C.k * Math.pow(2, r.apply(this, arguments)))), R = At(h);
1893
+ if (y.wheel)
1894
+ (y.mouse[0][0] !== R[0] || y.mouse[0][1] !== R[1]) && (y.mouse[1] = C.invert(y.mouse[0] = R)), clearTimeout(y.wheel);
1895
+ else {
1896
+ if (C.k === T) return;
1897
+ y.mouse = [R, C.invert(R)], le(this), y.start();
1898
+ }
1899
+ Ot(h), y.wheel = setTimeout(M, N), y.zoom("mouse", n(O(K(C, T), y.mouse[0], y.mouse[1]), y.extent, o));
1900
+ function M() {
1901
+ y.wheel = null, y.end();
1902
+ }
1903
+ }
1904
+ function B(h, ...k) {
1905
+ if (g || !t.apply(this, arguments)) return;
1906
+ var y = h.currentTarget, C = F(this, k, !0).event(h), T = ot(h.view).on("mousemove.zoom", p, !0).on("mouseup.zoom", A, !0), R = At(h, y), M = h.clientX, f = h.clientY;
1907
+ $i(h.view), $e(h), C.mouse = [R, this.__zoom.invert(R)], le(this), C.start();
1908
+ function p(w) {
1909
+ if (Ot(w), !C.moved) {
1910
+ var v = w.clientX - M, b = w.clientY - f;
1911
+ C.moved = v * v + b * b > S;
1912
+ }
1913
+ C.event(w).zoom("mouse", n(O(C.that.__zoom, C.mouse[0] = At(w, y), C.mouse[1]), C.extent, o));
1914
+ }
1915
+ function A(w) {
1916
+ T.on("mousemove.zoom mouseup.zoom", null), ki(w.view, C.moved), Ot(w), C.event(w).end();
1917
+ }
1918
+ }
1919
+ function H(h, ...k) {
1920
+ if (t.apply(this, arguments)) {
1921
+ var y = this.__zoom, C = At(h.changedTouches ? h.changedTouches[0] : h, this), T = y.invert(C), R = y.k * (h.shiftKey ? 0.5 : 2), M = n(O(K(y, R), C, T), e.apply(this, k), o);
1922
+ Ot(h), c > 0 ? ot(this).transition().duration(c).call(G, M, C, h) : ot(this).call($.transform, M, C, h);
1923
+ }
1924
+ }
1925
+ function I(h, ...k) {
1926
+ if (t.apply(this, arguments)) {
1927
+ var y = h.touches, C = y.length, T = F(this, k, h.changedTouches.length === C).event(h), R, M, f, p;
1928
+ for ($e(h), M = 0; M < C; ++M)
1929
+ f = y[M], p = At(f, this), p = [p, this.__zoom.invert(p), f.identifier], T.touch0 ? !T.touch1 && T.touch0[2] !== p[2] && (T.touch1 = p, T.taps = 0) : (T.touch0 = p, R = !0, T.taps = 1 + !!u);
1930
+ u && (u = clearTimeout(u)), R && (T.taps < 2 && (d = p[0], u = setTimeout(function() {
1931
+ u = null;
1932
+ }, x)), le(this), T.start());
1933
+ }
1934
+ }
1935
+ function Z(h, ...k) {
1936
+ if (this.__zooming) {
1937
+ var y = F(this, k).event(h), C = h.changedTouches, T = C.length, R, M, f, p;
1938
+ for (Ot(h), R = 0; R < T; ++R)
1939
+ M = C[R], f = At(M, this), y.touch0 && y.touch0[2] === M.identifier ? y.touch0[0] = f : y.touch1 && y.touch1[2] === M.identifier && (y.touch1[0] = f);
1940
+ if (M = y.that.__zoom, y.touch1) {
1941
+ var A = y.touch0[0], w = y.touch0[1], v = y.touch1[0], b = y.touch1[1], m = (m = v[0] - A[0]) * m + (m = v[1] - A[1]) * m, _ = (_ = b[0] - w[0]) * _ + (_ = b[1] - w[1]) * _;
1942
+ M = K(M, Math.sqrt(m / _)), f = [(A[0] + v[0]) / 2, (A[1] + v[1]) / 2], p = [(w[0] + b[0]) / 2, (w[1] + b[1]) / 2];
1943
+ } else if (y.touch0) f = y.touch0[0], p = y.touch0[1];
1944
+ else return;
1945
+ y.zoom("touch", n(O(M, f, p), y.extent, o));
1946
+ }
1947
+ }
1948
+ function tt(h, ...k) {
1949
+ if (this.__zooming) {
1950
+ var y = F(this, k).event(h), C = h.changedTouches, T = C.length, R, M;
1951
+ for ($e(h), g && clearTimeout(g), g = setTimeout(function() {
1952
+ g = null;
1953
+ }, x), R = 0; R < T; ++R)
1954
+ M = C[R], y.touch0 && y.touch0[2] === M.identifier ? delete y.touch0 : y.touch1 && y.touch1[2] === M.identifier && delete y.touch1;
1955
+ if (y.touch1 && !y.touch0 && (y.touch0 = y.touch1, delete y.touch1), y.touch0) y.touch0[1] = this.__zoom.invert(y.touch0[0]);
1956
+ else if (y.end(), y.taps === 2 && (M = At(M, this), Math.hypot(d[0] - M[0], d[1] - M[1]) < Y)) {
1957
+ var f = ot(this).on("dblclick.zoom");
1958
+ f && f.apply(this, arguments);
1959
+ }
1960
+ }
1961
+ }
1962
+ return $.wheelDelta = function(h) {
1963
+ return arguments.length ? (r = typeof h == "function" ? h : ie(+h), $) : r;
1964
+ }, $.filter = function(h) {
1965
+ return arguments.length ? (t = typeof h == "function" ? h : ie(!!h), $) : t;
1966
+ }, $.touchable = function(h) {
1967
+ return arguments.length ? (i = typeof h == "function" ? h : ie(!!h), $) : i;
1968
+ }, $.extent = function(h) {
1969
+ return arguments.length ? (e = typeof h == "function" ? h : ie([[+h[0][0], +h[0][1]], [+h[1][0], +h[1][1]]]), $) : e;
1970
+ }, $.scaleExtent = function(h) {
1971
+ return arguments.length ? (s[0] = +h[0], s[1] = +h[1], $) : [s[0], s[1]];
1972
+ }, $.translateExtent = function(h) {
1973
+ return arguments.length ? (o[0][0] = +h[0][0], o[1][0] = +h[1][0], o[0][1] = +h[0][1], o[1][1] = +h[1][1], $) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
1974
+ }, $.constrain = function(h) {
1975
+ return arguments.length ? (n = h, $) : n;
1976
+ }, $.duration = function(h) {
1977
+ return arguments.length ? (c = +h, $) : c;
1978
+ }, $.interpolate = function(h) {
1979
+ return arguments.length ? (l = h, $) : l;
1980
+ }, $.on = function() {
1981
+ var h = a.on.apply(a, arguments);
1982
+ return h === a ? $ : h;
1983
+ }, $.clickDistance = function(h) {
1984
+ return arguments.length ? (S = (h = +h) * h, $) : Math.sqrt(S);
1985
+ }, $.tapDistance = function(h) {
1986
+ return arguments.length ? (Y = +h, $) : Y;
1987
+ }, $;
1988
+ }
1989
+ const ve = {
1990
+ // Edge Routing
1991
+ horizontalExtension: 30,
1992
+ minEdgeDistance: 50,
1993
+ minVerticalSegment: 20,
1994
+ loopRadius: 40,
1995
+ edgeSpacing: 80,
1996
+ cornerRadius: 15,
1997
+ // Arrow
1998
+ arrowWidth: 10,
1999
+ arrowHeight: 6,
2000
+ // Label
2001
+ labelHeight: 15,
2002
+ labelFontSize: 10,
2003
+ labelPadding: 6,
2004
+ labelCornerRadius: 4,
2005
+ // Node
2006
+ nodeSpacing: 50,
2007
+ // Path Selection
2008
+ nearlyHorizontalThreshold: 5,
2009
+ nearlyAlignedThreshold: 30
2010
+ };
2011
+ function ys(t) {
2012
+ return {
2013
+ ...ve,
2014
+ ...t
2015
+ };
2016
+ }
2017
+ function xs(t, e, n) {
2018
+ const o = (t.clientWidth || 800) / e, c = 32 / (n * o);
2019
+ return Math.max(3, c);
2020
+ }
2021
+ function ke(t, e, n) {
2022
+ const r = t.node();
2023
+ if (!r) return;
2024
+ t.text(n);
2025
+ let i = r.getComputedTextLength();
2026
+ if (i <= e) return;
2027
+ const s = "...";
2028
+ let o = 0, c = n.length;
2029
+ for (; o < c; ) {
2030
+ const l = Math.floor((o + c + 1) / 2);
2031
+ t.text(n.slice(0, l) + s), i = r.getComputedTextLength(), i <= e ? o = l : c = l - 1;
2032
+ }
2033
+ o > 0 ? t.text(n.slice(0, o) + s) : t.text(s);
2034
+ }
2035
+ class Rn {
2036
+ constructor(e, n, r, i, s) {
2037
+ this.type = e, this._gvid = n, this.name = r, this._draw_ = i, this._ldraw_ = s;
2038
+ }
2039
+ }
2040
+ class Dn extends Rn {
2041
+ // Reference to the edge this virtual node represents
2042
+ constructor({
2043
+ _gvid: e,
2044
+ name: n,
2045
+ _draw_: r,
2046
+ _ldraw_: i,
2047
+ bb: s,
2048
+ pos: o,
2049
+ width: c,
2050
+ height: l,
2051
+ label: a
2052
+ }) {
2053
+ super("node", e, n, r, i), this.virtualNode = !1, this.bb = s, this.pos = o, this.width = c, this.height = l, this.label = a;
2054
+ }
2055
+ /**
2056
+ * Get parsed position as [x, y] coordinates
2057
+ */
2058
+ getPosition() {
2059
+ if (!this.pos) return null;
2060
+ const [e, n] = this.pos.split(",").map(Number);
2061
+ return [e, n];
2062
+ }
2063
+ /**
2064
+ * Get width in points (1 inch = 72 points)
2065
+ */
2066
+ getWidthPoints() {
2067
+ return parseFloat(this.width || "1") * 72;
2068
+ }
2069
+ /**
2070
+ * Get height in points (1 inch = 72 points)
2071
+ */
2072
+ getHeightPoints() {
2073
+ return parseFloat(this.height || "0.5") * 72;
2074
+ }
2075
+ /**
2076
+ * Get bounding box coordinates (x, y is top-left corner)
2077
+ * Note: Graphviz pos is center, so we calculate top-left
2078
+ */
2079
+ getBounds() {
2080
+ const e = this.getPosition();
2081
+ if (!e) return null;
2082
+ const [n, r] = e, i = this.getWidthPoints(), s = this.getHeightPoints();
2083
+ return {
2084
+ x: n - i / 2,
2085
+ y: r - s / 2,
2086
+ width: i,
2087
+ height: s
2088
+ };
2089
+ }
2090
+ /**
2091
+ * Left side input point (1/4 from top)
2092
+ */
2093
+ leftIn() {
2094
+ const e = this.getBounds();
2095
+ return e ? {
2096
+ x: e.x,
2097
+ y: Math.trunc(e.y + e.height / 4)
2098
+ } : null;
2099
+ }
2100
+ /**
2101
+ * Left side output point (3/4 from top)
2102
+ */
2103
+ leftOut() {
2104
+ const e = this.getBounds();
2105
+ return e ? {
2106
+ x: e.x,
2107
+ y: Math.trunc(e.y + e.height / 4 * 3)
2108
+ } : null;
2109
+ }
2110
+ /**
2111
+ * Right side output point (1/4 from top)
2112
+ */
2113
+ rightOut() {
2114
+ const e = this.getBounds();
2115
+ return e ? {
2116
+ x: e.x + e.width,
2117
+ y: Math.trunc(e.y + e.height / 4)
2118
+ } : null;
2119
+ }
2120
+ /**
2121
+ * Right side input point (3/4 from top)
2122
+ */
2123
+ rightIn() {
2124
+ const e = this.getBounds();
2125
+ return e ? {
2126
+ x: e.x + e.width,
2127
+ y: Math.trunc(e.y + e.height / 4 * 3)
2128
+ } : null;
2129
+ }
2130
+ }
2131
+ class ws extends Rn {
2132
+ constructor({
2133
+ _gvid: e,
2134
+ name: n,
2135
+ _draw_: r,
2136
+ _ldraw_: i,
2137
+ _hdraw_: s,
2138
+ _tdraw_: o,
2139
+ head: c,
2140
+ tail: l,
2141
+ label: a
2142
+ }) {
2143
+ if (super("edge", e, n, r, i), this.isBaseEdge = !1, this.depth = 0, this.baseOffset = 0, this.midY = 0, this._hdraw_ = s, this._tdraw_ = o, this.head = c, this.tail = l, this.label = a, a) {
2144
+ const u = a.match(/\[(\d+)\]/);
2145
+ u && u[1] && (this.edgeId = parseInt(u[1], 10));
2146
+ }
2147
+ }
2148
+ /**
2149
+ * Set the source and target node references
2150
+ */
2151
+ setNodes(e, n) {
2152
+ this.sourceNode = e, this.targetNode = n;
2153
+ }
2154
+ /**
2155
+ * Determine edge direction based on source/target node positions
2156
+ * - "right": source is left of target (edge goes left → right)
2157
+ * - "left": source is right of target (edge goes right → left)
2158
+ * - "self": source and target are the same node
2159
+ */
2160
+ getDirection() {
2161
+ if (!this.sourceNode || !this.targetNode) return null;
2162
+ const e = this.sourceNode.getPosition(), n = this.targetNode.getPosition();
2163
+ return !e || !n ? null : this.sourceNode._gvid === this.targetNode._gvid ? "self" : e[0] < n[0] ? "right" : "left";
2164
+ }
2165
+ /**
2166
+ * Get the start point (source port) based on edge direction
2167
+ * - Right edge: source node's rightOut
2168
+ * - Left edge: source node's leftOut
2169
+ * - Self-loop: source node's leftOut
2170
+ */
2171
+ getStartPoint() {
2172
+ if (!this.sourceNode) return null;
2173
+ const e = this.getDirection();
2174
+ if (!e) return null;
2175
+ switch (e) {
2176
+ case "right":
2177
+ return this.sourceNode.rightOut();
2178
+ case "left":
2179
+ return this.sourceNode.leftOut();
2180
+ case "self":
2181
+ return this.sourceNode.leftOut();
2182
+ }
2183
+ }
2184
+ /**
2185
+ * Get the end point (target port) based on edge direction
2186
+ * - Right edge: target node's leftIn
2187
+ * - Left edge: target node's rightIn
2188
+ * - Self-loop: target node's rightIn
2189
+ */
2190
+ getEndPoint() {
2191
+ if (!this.targetNode) return null;
2192
+ const e = this.getDirection();
2193
+ if (!e) return null;
2194
+ switch (e) {
2195
+ case "right":
2196
+ return this.targetNode.leftIn();
2197
+ case "left":
2198
+ return this.targetNode.rightIn();
2199
+ case "self":
2200
+ return this.targetNode.rightIn();
2201
+ }
2202
+ }
2203
+ /**
2204
+ * Get the label text for this edge
2205
+ * Extracts from HTML label or _ldraw_ operations
2206
+ * @returns The label text or null if no label
2207
+ */
2208
+ getLabelText() {
2209
+ if (this.label)
2210
+ return this.label.replace(/<[^>]*>/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim() || null;
2211
+ if (this._ldraw_) {
2212
+ const e = [];
2213
+ if (this._ldraw_.forEach((n) => {
2214
+ n.op === "T" && n.text && e.push(n.text);
2215
+ }), e.length > 0)
2216
+ return e.join(" ");
2217
+ }
2218
+ return null;
2219
+ }
2220
+ /**
2221
+ * Get the stroke color for this edge
2222
+ * Extracts from _draw_ operations (looks for 'c' color-setting operation)
2223
+ * @returns The color string or default gray if not found
2224
+ */
2225
+ getColor() {
2226
+ const e = "#9AA4B2";
2227
+ if (this._draw_) {
2228
+ for (const n of this._draw_)
2229
+ if (n.op === "c" && n.color)
2230
+ return n.color;
2231
+ }
2232
+ if (this._hdraw_) {
2233
+ for (const n of this._hdraw_)
2234
+ if (n.op === "c" && n.color)
2235
+ return n.color;
2236
+ }
2237
+ return e;
2238
+ }
2239
+ }
2240
+ class Ln {
2241
+ constructor(e, n = 0) {
2242
+ this.index = e, this.aboveY = n, this.belowY = n;
2243
+ }
2244
+ /** Allocate space above current aboveY, returns the new Y position */
2245
+ allocateAbove(e) {
2246
+ return this.aboveY -= e, this.aboveY;
2247
+ }
2248
+ /** Allocate space below current belowY, returns the new Y position */
2249
+ allocateBelow(e) {
2250
+ const n = this.belowY;
2251
+ return this.belowY += e, n;
2252
+ }
2253
+ /** Get the current range of allocated Y coordinates */
2254
+ getRange() {
2255
+ return { above: this.aboveY, below: this.belowY };
2256
+ }
2257
+ }
2258
+ class vs extends Ln {
2259
+ constructor(e, n = 0) {
2260
+ super(e, n), this.nodes = [];
2261
+ }
2262
+ addNode(e, n = !0) {
2263
+ if (this.nodes.push(e), !n) return;
2264
+ const r = e.getPosition();
2265
+ if (r) {
2266
+ const i = e.height ? parseFloat(e.height) * 72 : 40, s = r[1] - i / 2, o = r[1] + i / 2;
2267
+ this.aboveY = Math.min(this.aboveY, s), this.belowY = Math.max(this.belowY, o);
2268
+ }
2269
+ }
2270
+ }
2271
+ class _s extends Ln {
2272
+ constructor(e, n, r = 0) {
2273
+ super(Math.min(e, n), r), this.edges = [], this.baseEdgeIndex = -1, this.sourceColIndex = e, this.targetColIndex = n;
2274
+ }
2275
+ addEdge(e) {
2276
+ this.edges.push(e);
2277
+ }
2278
+ /** Set the base edge for this column */
2279
+ setBaseEdge(e, n) {
2280
+ this.baseEdge = e, this.baseEdgeIndex = n ?? this.edges.indexOf(e);
2281
+ }
2282
+ /** Get the key for this edge column */
2283
+ getKey() {
2284
+ const e = Math.min(this.sourceColIndex, this.targetColIndex), n = Math.max(this.sourceColIndex, this.targetColIndex);
2285
+ return `${e}-${n}`;
2286
+ }
2287
+ }
2288
+ function Fn(t) {
2289
+ if (!t) return [];
2290
+ const e = [], n = /<TD[^>]*>(.*?)<\/TD>/gi;
2291
+ let r;
2292
+ for (; (r = n.exec(t)) !== null; ) {
2293
+ let i = r[1];
2294
+ i = i.replace(/<[^>]+>/g, "").trim(), i && e.push(i);
2295
+ }
2296
+ if (e.length === 0) {
2297
+ const i = t.replace(/<[^>]+>/g, "").trim();
2298
+ i && e.push(i);
2299
+ }
2300
+ return e;
2301
+ }
2302
+ function Ts(t) {
2303
+ const e = ot(t).select("svg"), n = e.select("g#graph0");
2304
+ if (e.empty() || n.empty()) {
2305
+ console.warn("SVG or graph group not found");
2306
+ return;
2307
+ }
2308
+ e.attr("width", "100%").attr("height", "100%");
2309
+ const r = Xe().scaleExtent([0.1, 2]).on("zoom", (o) => {
2310
+ n.attr("transform", o.transform.toString());
2311
+ });
2312
+ e.call(r);
2313
+ const i = e.node(), s = n.node();
2314
+ if (i && s) {
2315
+ const o = s.getBBox(), c = i.parentElement;
2316
+ if (c) {
2317
+ const l = c.clientWidth, a = c.clientHeight, u = o.width, d = o.height, g = o.x + u / 2, x = o.y + d / 2, N = 0.8 / Math.max(u / l, d / a), S = [
2318
+ l / 2 - N * g,
2319
+ a / 2 - N * x
2320
+ ];
2321
+ e.call(
2322
+ r.transform,
2323
+ Nt.translate(S[0], S[1]).scale(N)
2324
+ );
2325
+ }
2326
+ }
2327
+ }
2328
+ function bs(t) {
2329
+ if (!t.sourceNode) return null;
2330
+ const e = t.sourceNode.getPosition();
2331
+ if (!e) return null;
2332
+ const r = 50 / 72, i = new Dn({
2333
+ _gvid: -1e3 - t._gvid,
2334
+ // Negative ID to distinguish from real nodes
2335
+ name: `virtual_edge_${t._gvid}`,
2336
+ label: t.label,
2337
+ pos: `${e[0]},${e[1]}`,
2338
+ // Same position as source node
2339
+ width: "0.5",
2340
+ // Small width
2341
+ height: r.toString()
2342
+ // Height matches node spacing
2343
+ });
2344
+ return i.virtualNode = !0, i.edge = t, t.virtualNode = i, i;
2345
+ }
2346
+ function Es(t, e, n) {
2347
+ const r = e.nodes, i = r.findIndex((s) => s._gvid === n._gvid);
2348
+ if (i === -1) {
2349
+ r.push(t);
2350
+ return;
2351
+ }
2352
+ r.splice(i, 0, t);
2353
+ }
2354
+ function Ns(t, e) {
2355
+ const r = [], i = /* @__PURE__ */ new Map();
2356
+ t.forEach((a) => {
2357
+ const u = a.getPosition();
2358
+ if (!u) return;
2359
+ const d = u[0];
2360
+ let g = r.findIndex(
2361
+ (x) => Math.abs(d - x) <= 20
2362
+ );
2363
+ g === -1 && (g = r.length, r.push(d)), i.set(a._gvid, g);
2364
+ });
2365
+ const s = r.map((a, u) => ({ x: a, i: u })).sort((a, u) => a.x - u.x).map((a, u) => ({ oldIndex: a.i, newIndex: u })), o = /* @__PURE__ */ new Map();
2366
+ s.forEach(({ oldIndex: a, newIndex: u }) => {
2367
+ o.set(a, u);
2368
+ });
2369
+ for (const [a, u] of i)
2370
+ i.set(a, o.get(u) ?? u);
2371
+ const c = /* @__PURE__ */ new Map();
2372
+ t.forEach((a) => {
2373
+ const u = i.get(a._gvid);
2374
+ u !== void 0 && (c.has(u) || c.set(u, new vs(u, 0)), c.get(u).addNode(a, !1));
2375
+ }), e.forEach((a) => {
2376
+ if (!a.sourceNode || !a.targetNode || a.sourceNode._gvid !== a.targetNode._gvid) return;
2377
+ const u = i.get(a.sourceNode._gvid);
2378
+ if (u === void 0) return;
2379
+ const d = c.get(u);
2380
+ if (!d) return;
2381
+ const g = bs(a);
2382
+ g && Es(g, d, a.sourceNode);
2383
+ });
2384
+ const l = /* @__PURE__ */ new Map();
2385
+ return e.forEach((a) => {
2386
+ if (!a.sourceNode || !a.targetNode) return;
2387
+ const u = i.get(a.sourceNode._gvid), d = i.get(a.targetNode._gvid);
2388
+ if (u === void 0 || d === void 0) return;
2389
+ a.depth = Math.abs(d - u) - 1, a.depth < 0 && (a.depth = 0);
2390
+ const g = Math.min(u, d), x = Math.max(u, d), N = `${g}-${x}`;
2391
+ l.has(N) || l.set(N, new _s(u, d, 0)), l.get(N).addEdge(a);
2392
+ }), l.forEach((a) => {
2393
+ a.edges.sort((u, d) => {
2394
+ const g = u.getStartPoint(), x = u.getEndPoint(), N = g && x ? (g.y + x.y) / 2 : 0, S = d.getStartPoint(), Y = d.getEndPoint();
2395
+ return (S && Y ? (S.y + Y.y) / 2 : 0) - N;
2396
+ });
2397
+ }), { nodeColumnMap: i, nodeColumns: c, edgeColumns: l };
2398
+ }
2399
+ function $s(t, e) {
2400
+ t.forEach((n) => {
2401
+ if (n.nodes.length === 0) return;
2402
+ let r = !0;
2403
+ n.nodes.forEach((i) => {
2404
+ const s = i.getPosition();
2405
+ if (!s) return;
2406
+ const o = i.height ? parseFloat(i.height) * 72 : 40, c = e - s[1], l = c - o / 2, a = c + o / 2;
2407
+ r ? (n.aboveY = l, n.belowY = a, r = !1) : (n.aboveY = Math.min(n.aboveY, l), n.belowY = Math.max(n.belowY, a));
2408
+ });
2409
+ });
2410
+ }
2411
+ function ks(t, e) {
2412
+ t.length !== 0 && e.forEach((n) => {
2413
+ const r = n.edges;
2414
+ if (r.length === 0) return;
2415
+ const i = r.filter((d) => d.depth === 0);
2416
+ if (i.length === 0) return;
2417
+ const s = Math.floor(i.length / 2), o = i[s];
2418
+ o.isBaseEdge = !0, o.baseDirection = void 0;
2419
+ const c = r.indexOf(o);
2420
+ n.setBaseEdge(o, c);
2421
+ const l = o.getStartPoint(), a = o.getEndPoint(), u = l && a ? (l.y + a.y) / 2 : 0;
2422
+ i.forEach((d, g) => {
2423
+ if (d === o) return;
2424
+ const x = d.getStartPoint(), N = d.getEndPoint();
2425
+ (x && N ? (x.y + N.y) / 2 : 0) > u ? d.baseDirection = "above" : d.baseDirection = "below";
2426
+ });
2427
+ });
2428
+ }
2429
+ function oe(t, e, n, r = ve) {
2430
+ const i = t.getStartPoint(), s = t.getEndPoint(), o = t.getDirection();
2431
+ if (!i || !s || !o || o === "self")
2432
+ return;
2433
+ const c = { x: i.x, y: e - i.y }, l = { x: s.x, y: e - s.y };
2434
+ let a = { x: l.x, y: l.y };
2435
+ o === "right" ? a = { x: l.x - r.arrowWidth, y: l.y } : o === "left" && (a = { x: l.x + r.arrowWidth, y: l.y });
2436
+ const u = r.horizontalExtension, d = r.minEdgeDistance, g = r.minVerticalSegment, x = (G) => {
2437
+ if (G.length < 2) return G;
2438
+ const F = [G[0]];
2439
+ for (let et = 1; et < G.length; et++) {
2440
+ const z = F[F.length - 1];
2441
+ (Math.abs(G[et].x - z.x) > 0.1 || Math.abs(G[et].y - z.y) > 0.1) && F.push(G[et]);
2442
+ }
2443
+ return F;
2444
+ };
2445
+ let N;
2446
+ const S = t.baseDirection === void 0;
2447
+ t.baseDirection === "above" ? N = Math.min(c.y, a.y) : t.baseDirection === "below" ? N = Math.max(c.y, a.y) : N = (c.y + a.y) / 2;
2448
+ let Y = N;
2449
+ if (!S && n && n.midY !== void 0) {
2450
+ if (t.baseDirection === "above") {
2451
+ const G = n.midY - d;
2452
+ Y > G && (Y = G);
2453
+ } else if (t.baseDirection === "below") {
2454
+ const G = n.midY + d;
2455
+ Y < G && (Y = G);
2456
+ }
2457
+ }
2458
+ const $ = Math.abs(c.y - a.y) < 5, K = (G, F) => {
2459
+ const et = Math.abs(c.y - F), z = Math.abs(F - a.y), B = o === "right" ? c.x + u : c.x - u, H = o === "right" ? a.x - u : a.x + u;
2460
+ let I = [], Z = F;
2461
+ switch (G) {
2462
+ case "straight":
2463
+ if ($) {
2464
+ const k = (c.y + a.y) / 2;
2465
+ Math.abs(F - k) < g ? (I = [c, a], Z = k) : (I = [
2466
+ c,
2467
+ { x: B, y: c.y },
2468
+ // H: horizontal extension
2469
+ { x: B, y: F },
2470
+ // V: vertical to midY
2471
+ { x: H, y: F },
2472
+ // H: horizontal at midY
2473
+ { x: H, y: a.y },
2474
+ // V: vertical to end
2475
+ a
2476
+ // H: horizontal to end
2477
+ ], Z = F);
2478
+ } else
2479
+ return null;
2480
+ break;
2481
+ case "2seg":
2482
+ et < z ? Math.abs(F - c.y) < g ? (I = [c, { x: a.x, y: c.y }, a], Z = c.y) : (I = [
2483
+ c,
2484
+ { x: B, y: c.y },
2485
+ // H: horizontal extension
2486
+ { x: B, y: F },
2487
+ // V: vertical to midY
2488
+ { x: H, y: F },
2489
+ // H: horizontal at midY
2490
+ { x: H, y: a.y },
2491
+ // V: vertical to end
2492
+ a
2493
+ // H: horizontal to end
2494
+ ], Z = F) : Math.abs(F - a.y) < g ? (I = [
2495
+ c,
2496
+ { x: B, y: c.y },
2497
+ // H: horizontal extension
2498
+ { x: B, y: a.y },
2499
+ // V: vertical to end.y
2500
+ a
2501
+ // H: horizontal to end
2502
+ ], Z = a.y) : (I = [
2503
+ c,
2504
+ { x: B, y: c.y },
2505
+ // H: horizontal extension
2506
+ { x: B, y: F },
2507
+ // V: vertical to midY
2508
+ { x: H, y: F },
2509
+ // H: horizontal at midY
2510
+ { x: H, y: a.y },
2511
+ // V: vertical to end
2512
+ a
2513
+ // H: horizontal to end
2514
+ ], Z = F);
2515
+ break;
2516
+ case "3seg":
2517
+ const h = F;
2518
+ I = [
2519
+ c,
2520
+ { x: B, y: c.y },
2521
+ { x: B, y: h },
2522
+ { x: H, y: h },
2523
+ { x: H, y: a.y },
2524
+ a
2525
+ ], Z = h;
2526
+ break;
2527
+ case "4seg":
2528
+ I = [
2529
+ c,
2530
+ { x: B, y: c.y },
2531
+ // H: horizontal extension from start
2532
+ { x: B, y: F },
2533
+ // V: vertical to midY
2534
+ { x: H, y: F },
2535
+ // H: horizontal at midY to end extension
2536
+ a
2537
+ // Final segment (may be H or V depending on pathEnd.y vs testMidY)
2538
+ ], Z = F;
2539
+ break;
2540
+ case "5seg":
2541
+ if (et < g)
2542
+ I = [
2543
+ c,
2544
+ { x: B, y: c.y },
2545
+ // H: horizontal extension
2546
+ { x: H, y: F },
2547
+ // H: horizontal at midY (skip V since start.y ≈ testMidY)
2548
+ { x: H, y: a.y },
2549
+ // V: vertical to end Y
2550
+ a
2551
+ // H: horizontal to end
2552
+ ], Z = F;
2553
+ else if (z < g)
2554
+ I = [
2555
+ c,
2556
+ { x: B, y: c.y },
2557
+ // H: horizontal extension
2558
+ { x: B, y: F },
2559
+ // V: vertical to midY
2560
+ { x: H, y: F },
2561
+ // H: horizontal at midY
2562
+ a
2563
+ // H: horizontal to end (skip V since testMidY ≈ pathEnd.y)
2564
+ ], Z = F;
2565
+ else
2566
+ return null;
2567
+ break;
2568
+ case "6seg":
2569
+ I = [
2570
+ c,
2571
+ { x: B, y: c.y },
2572
+ { x: B, y: F },
2573
+ { x: H, y: F },
2574
+ { x: H, y: a.y },
2575
+ a
2576
+ ], Z = F;
2577
+ break;
2578
+ }
2579
+ const tt = x(I);
2580
+ return tt.length > 0 ? { points: tt, actualMidY: Z } : null;
2581
+ };
2582
+ let O;
2583
+ S ? O = $ ? ["straight", "3seg"] : ["3seg"] : O = $ ? ["straight", "3seg", "4seg", "5seg", "6seg"] : ["3seg", "4seg", "5seg", "6seg"];
2584
+ for (const G of O) {
2585
+ const F = K(G, Y);
2586
+ if (F)
2587
+ return { midY: F.actualMidY, points: F.points };
2588
+ }
2589
+ const Q = K("6seg", Y);
2590
+ return Q ? { midY: Q.actualMidY, points: Q.points } : void 0;
2591
+ }
2592
+ function fn(t, e) {
2593
+ if (t.length < 2) return "";
2594
+ if (e === 0 || t.length === 2)
2595
+ return `M${t[0].x},${t[0].y} ${t.slice(1).map((i) => `L${i.x},${i.y}`).join(" ")}`;
2596
+ const n = [];
2597
+ n.push(`M${t[0].x},${t[0].y}`);
2598
+ for (let i = 1; i < t.length - 1; i++) {
2599
+ const s = t[i - 1], o = t[i], c = t[i + 1], l = Math.sqrt((o.x - s.x) ** 2 + (o.y - s.y) ** 2), a = Math.sqrt((c.x - o.x) ** 2 + (c.y - o.y) ** 2), u = Math.min(l, a) / 2, d = Math.min(e, u);
2600
+ if (d > 0) {
2601
+ const g = d / l, x = d / a, N = {
2602
+ x: o.x - (o.x - s.x) * g,
2603
+ y: o.y - (o.y - s.y) * g
2604
+ }, S = {
2605
+ x: o.x + (c.x - o.x) * x,
2606
+ y: o.y + (c.y - o.y) * x
2607
+ };
2608
+ n.push(`L${N.x},${N.y}`), n.push(`Q${o.x},${o.y} ${S.x},${S.y}`);
2609
+ } else
2610
+ n.push(`L${o.x},${o.y}`);
2611
+ }
2612
+ const r = t[t.length - 1];
2613
+ return n.push(`L${r.x},${r.y}`), n.join(" ");
2614
+ }
2615
+ function Cs(t, e, n, r = ve, i = !0, s = 0, o = 1 / 0, c, l, a, u, d, g, x, N = !1) {
2616
+ var F, et;
2617
+ const S = g != null && t.edgeId === g, Y = t.getColor(), $ = e.append("g").attr("class", S ? "edge selected" : "edge").attr("id", `edge_${t._gvid}`).attr("data-edge-id", t.edgeId !== void 0 ? String(t.edgeId) : "").attr("data-is-base", t.isBaseEdge ? "true" : "false").attr("data-color", Y), K = t.getStartPoint(), O = t.getEndPoint(), Q = t.getDirection();
2618
+ console.log(
2619
+ `Edge ${t._gvid}: direction=${Q}, isBase=${t.isBaseEdge}, depth=${t.depth}`,
2620
+ {
2621
+ start: K,
2622
+ end: O,
2623
+ sourceNode: (F = t.sourceNode) == null ? void 0 : F.name,
2624
+ targetNode: (et = t.targetNode) == null ? void 0 : et.name
2625
+ }
2626
+ );
2627
+ const G = r.arrowWidth;
2628
+ if (r.arrowHeight, K && O && Q) {
2629
+ const z = { x: K.x, y: n - K.y }, B = { x: O.x, y: n - O.y }, H = { x: B.x, y: B.y };
2630
+ let I = { x: B.x, y: B.y };
2631
+ Q === "right" ? I = { x: B.x - G, y: B.y } : Q === "left" ? I = { x: B.x + G, y: B.y } : Q === "self" && (I = { x: B.x + G, y: B.y });
2632
+ let Z;
2633
+ const tt = r.loopRadius, h = r.horizontalExtension, k = r.cornerRadius;
2634
+ if (i)
2635
+ if (Q === "self")
2636
+ if (t.virtualNode) {
2637
+ const f = t.virtualNode.getPosition();
2638
+ if (f) {
2639
+ const p = n - f[1];
2640
+ t.midY = p;
2641
+ const A = [
2642
+ z,
2643
+ // leftOut of source node
2644
+ { x: z.x - h, y: z.y },
2645
+ // Extend left
2646
+ { x: z.x - h, y: p },
2647
+ // Go to virtual node height
2648
+ { x: I.x + h, y: p },
2649
+ // Horizontal segment through virtual node
2650
+ { x: I.x + h, y: I.y },
2651
+ // Go down to rightIn
2652
+ I
2653
+ // rightIn of source node
2654
+ ];
2655
+ Z = fn(A, k);
2656
+ } else {
2657
+ const p = z.x - tt, A = z.y - tt, w = I.x + tt, v = I.y - tt;
2658
+ Z = `M${z.x},${z.y} C${p},${A} ${w},${v} ${I.x},${I.y}`;
2659
+ }
2660
+ } else {
2661
+ const f = z.x - tt, p = z.y - tt, A = I.x + tt, w = I.y - tt;
2662
+ Z = `M${z.x},${z.y} C${f},${p} ${A},${w} ${I.x},${I.y}`;
2663
+ }
2664
+ else {
2665
+ let f;
2666
+ if (t.orthogonalPathPoints && t.orthogonalPathPoints.length > 0)
2667
+ f = t.orthogonalPathPoints;
2668
+ else {
2669
+ const p = Math.abs(z.y - t.midY), A = Math.abs(t.midY - I.y), w = 20, v = p >= w, b = A >= w, m = Q === "right" ? z.x + h : z.x - h, _ = Q === "right" ? I.x - h : I.x + h;
2670
+ if (f = [], !v && !b) {
2671
+ const E = (z.y + I.y) / 2;
2672
+ f.push(
2673
+ z,
2674
+ { x: m, y: E },
2675
+ { x: _, y: E },
2676
+ I
2677
+ );
2678
+ } else v ? b ? f.push(
2679
+ z,
2680
+ { x: m, y: z.y },
2681
+ { x: m, y: t.midY },
2682
+ { x: _, y: t.midY },
2683
+ { x: _, y: I.y },
2684
+ I
2685
+ ) : f.push(
2686
+ z,
2687
+ { x: m, y: z.y },
2688
+ { x: m, y: t.midY },
2689
+ { x: _, y: t.midY },
2690
+ I
2691
+ ) : f.push(
2692
+ z,
2693
+ { x: m, y: t.midY },
2694
+ { x: _, y: t.midY },
2695
+ { x: _, y: I.y },
2696
+ I
2697
+ );
2698
+ }
2699
+ Z = fn(f, k);
2700
+ }
2701
+ else if (Q === "self") {
2702
+ const f = z.x - tt, p = z.y - tt, A = I.x + tt, w = I.y - tt;
2703
+ Z = `M${z.x},${z.y} C${f},${p} ${A},${w} ${I.x},${I.y}`;
2704
+ } else {
2705
+ const f = I.x - z.x;
2706
+ I.y - z.y;
2707
+ const p = 0.4, A = z.x + f * p, w = z.y, v = I.x - f * p, b = I.y;
2708
+ Z = `M${z.x},${z.y} C${A},${w} ${v},${b} ${I.x},${I.y}`;
2709
+ }
2710
+ const y = N && t.isBaseEdge ? "#000000" : t.getColor(), C = N && t.isBaseEdge ? 4 : 1.5;
2711
+ $.append("path").attr("d", Z).attr("fill", "none").attr("stroke", "transparent").attr("stroke-width", 10).attr("class", "edge-hit-area").style("cursor", "pointer"), $.append("path").attr("d", Z).attr("fill", "none").attr("stroke", y).attr("stroke-width", C).attr("class", "edge-path").style("pointer-events", "none"), $.on("mouseenter", function() {
2712
+ ot(this).raise();
2713
+ });
2714
+ const T = 12;
2715
+ let R = "";
2716
+ Q === "right" ? R = `translate(${H.x - T}, ${H.y - T / 2})` : Q === "left" ? R = `translate(${H.x + T}, ${H.y + T / 2}) rotate(180)` : Q === "self" && (R = `translate(${H.x + T}, ${H.y + T / 2}) rotate(180)`), $.append("use").attr("class", "edge-arrow").attr("href", "#arrow-right").attr("width", T).attr("height", T).attr("transform", R).attr("fill", y).attr("stroke", y).style("stroke-width", 0);
2717
+ const M = {
2718
+ x: (z.x + I.x) / 2,
2719
+ y: t.midY
2720
+ };
2721
+ if (t.label) {
2722
+ const p = Fn(t.label).map((st) => st.length > 20 ? st.slice(0, 20) + "..." : st).join(" "), A = p.length > 60 ? p.slice(0, 60) + "..." : p, w = r.labelFontSize, v = w * 0.6, b = A.length * v, m = w, _ = r.labelPadding, E = 16, W = S ? 16 : 0, J = t.edgeId !== void 0, nt = J && t.edgeId > s, U = J && t.edgeId < o, D = (nt ? E : 0) + (U ? E : 0) + W, X = b + _ * 2 + D, P = m + _ * 2, L = r.labelCornerRadius, V = M.y, rt = M.x, it = (st) => ot(`g.edge[data-edge-id="${st}"]`), q = 12, j = $.append("g").attr("class", "label-area");
2723
+ j.append("rect").attr("class", "label-bg").attr("x", rt - X / 2).attr("y", V - P / 2).attr("width", X).attr("height", P).attr("rx", L).attr("ry", L).attr("fill", "white").attr("stroke", y).attr("stroke-width", 1);
2724
+ const ct = rt - X / 2 + E / 2, gt = rt + X / 2 - E / 2 - W, at = rt + X / 2 - W / 2, jt = rt + (nt ? E / 2 : 0) - (U ? E / 2 : 0) - (S ? W / 2 : 0);
2725
+ if (J && x && $.style("cursor", "pointer").on("click", function(st) {
2726
+ st.stopPropagation(), !S && x(t.edgeId);
2727
+ }), j.append("text").attr("class", "label-text").attr("x", jt).attr("y", V).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-family", "Inter, Helvetica, Arial").attr("font-size", "10px").attr("fill", y).style("pointer-events", "none").text(A), N && $.append("circle").attr("cx", jt).attr("cy", V).attr("r", 4).attr("fill", "blue").attr("opacity", 0.8).style("pointer-events", "none").attr("class", "debug-label-center"), nt) {
2728
+ const st = t.edgeId - 1, ht = j.append("g").attr("class", "nav-btn-group prev-btn-group");
2729
+ ht.append("rect").attr("class", "nav-btn-area prev-btn-area").attr("x", rt - X / 2).attr("y", V - P / 2).attr("width", E).attr("height", P).attr("fill", "transparent").attr("rx", L).style("cursor", "pointer").style("pointer-events", "all"), ht.append("use").attr("class", "nav-icon prev-icon").attr("href", "#nav-left").attr("x", ct - q / 2).attr("y", V - q / 2).attr("width", q).attr("height", q).attr("fill", "#888"), ht.on("click", function(mt) {
2730
+ mt.stopPropagation();
2731
+ const $t = it(st);
2732
+ if (!$t.empty()) {
2733
+ if (c && l && a && u && d) {
2734
+ const Yt = $t.node();
2735
+ if (Yt) {
2736
+ const kt = ot(Yt).select(".label-text").node();
2737
+ let Ct, St;
2738
+ if (kt)
2739
+ Ct = parseFloat(kt.getAttribute("x") || "0"), St = parseFloat(kt.getAttribute("y") || "0");
2740
+ else {
2741
+ const Tt = Yt.getBBox();
2742
+ Ct = Tt.x + Tt.width / 2, St = Tt.y + Tt.height / 2;
2743
+ }
2744
+ const Lt = a.clientWidth, Ft = 1.2 * u / Lt, Ht = u / 2 - Ct * Ft, _e = d / 2 - St * Ft;
2745
+ l.transition().duration(500).call(
2746
+ c.transform,
2747
+ Nt.translate(Ht, _e).scale(Ft)
2748
+ );
2749
+ }
2750
+ }
2751
+ x && x(st);
2752
+ }
2753
+ });
2754
+ }
2755
+ if (U && t.edgeId !== void 0) {
2756
+ const st = t.edgeId + 1, ht = S ? gt : rt + X / 2 - E / 2, mt = j.append("g").attr("class", "nav-btn-group next-btn-group");
2757
+ mt.append("rect").attr("class", "nav-btn-area next-btn-area").attr("x", rt + X / 2 - E - W).attr("y", V - P / 2).attr("width", E).attr("height", P).attr("fill", "transparent").attr("rx", L).style("cursor", "pointer").style("pointer-events", "all"), mt.append("use").attr("class", "nav-icon next-icon").attr("href", "#nav-right").attr("x", ht - q / 2).attr("y", V - q / 2).attr("width", q).attr("height", q).attr("fill", "#888"), mt.on("click", function($t) {
2758
+ $t.stopPropagation();
2759
+ const Yt = it(st);
2760
+ if (!Yt.empty()) {
2761
+ if (c && l && a && u && d) {
2762
+ const kt = Yt.node();
2763
+ if (kt) {
2764
+ const Ct = ot(kt).select(".label-text").node();
2765
+ let St, Lt;
2766
+ if (Ct)
2767
+ St = parseFloat(Ct.getAttribute("x") || "0"), Lt = parseFloat(Ct.getAttribute("y") || "0");
2768
+ else {
2769
+ const te = kt.getBBox();
2770
+ St = te.x + te.width / 2, Lt = te.y + te.height / 2;
2771
+ }
2772
+ const Ft = a.clientWidth, Ht = 1.2 * u / Ft, _e = u / 2 - St * Ht, Tt = d / 2 - Lt * Ht;
2773
+ l.transition().duration(500).call(
2774
+ c.transform,
2775
+ Nt.translate(_e, Tt).scale(Ht)
2776
+ );
2777
+ }
2778
+ }
2779
+ x && x(st);
2780
+ }
2781
+ });
2782
+ }
2783
+ S && J && x && $.append("text").attr("class", "close-btn").attr("x", at).attr("y", V).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-family", "Arial").attr("font-size", "12px").attr("font-weight", "bold").attr("fill", "#888").style("cursor", "pointer").text("✕").on("mouseenter", function() {
2784
+ ot(this).attr("fill", "#EF4444");
2785
+ }).on("mouseleave", function() {
2786
+ ot(this).attr("fill", "#888");
2787
+ }).on("click", function(st) {
2788
+ st.stopPropagation(), x(null);
2789
+ });
2790
+ } else t._ldraw_ && t._ldraw_.forEach((f) => {
2791
+ if (f.op === "T" && f.text) {
2792
+ const p = f.size || 10, A = p * 0.6, w = f.text.length * A, v = p, b = 6, m = w + b * 2, _ = v + b * 2, E = 4, W = M.y;
2793
+ $.append("rect").attr("x", M.x - m / 2).attr("y", W - _ / 2).attr("width", m).attr("height", _).attr("rx", E).attr("ry", E).attr("fill", "white").attr("stroke", "#d0d0d0").attr("stroke-width", 0.5), $.append("text").attr("x", M.x).attr("y", W).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-family", f.face || "Inter, Helvetica, Arial").attr("font-size", `${p}px`).attr("fill", f.color || "#666").text(f.text);
2794
+ }
2795
+ });
2796
+ if (N) {
2797
+ let f;
2798
+ t.depth === 0 ? f = `d:0 dir:${t.baseDirection || "base"} off:${t.baseOffset} id:${t._gvid}` : f = `d:${t.depth} dir:${t.baseDirection || "?"} midY:${Math.round(t.midY)} id:${t._gvid}`, $.append("text").attr("x", M.x).attr("y", M.y + 15).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-family", "monospace").attr("font-size", "9px").attr("fill", "#999").text(f);
2799
+ }
2800
+ } else
2801
+ t._draw_ && t._draw_.forEach((z) => {
2802
+ if (z.op === "b" && z.points) {
2803
+ const B = z.points.map(([I, Z]) => [I, n - Z]), H = `M${B[0][0]},${B[0][1]} C${B.slice(1).map((I) => `${I[0]},${I[1]}`).join(" ")}`;
2804
+ $.append("path").attr("d", H).attr("fill", "none").attr("stroke", z.color || "#9AA4B2").attr("stroke-width", 2);
2805
+ }
2806
+ }), t._hdraw_ && t._hdraw_.forEach((z) => {
2807
+ if (z.op === "P" && z.points) {
2808
+ const B = z.points.map(([H, I]) => [H, n - I]);
2809
+ $.append("polygon").attr("points", B.map((H) => H.join(",")).join(" ")).attr("fill", z.color || "#9AA4B2");
2810
+ }
2811
+ }), t._ldraw_ && Mt($, t._ldraw_, n);
2812
+ }
2813
+ function Ss(t, e, n, r, i = !0, s = ve, o = !0, c = 14, l = !1, a, u, d, g, x) {
2814
+ var M;
2815
+ t.innerHTML = "";
2816
+ const N = ((M = e.bb) == null ? void 0 : M.split(",").map(Number)) || [0, 0, 1e3, 800];
2817
+ let [, , S, Y] = N;
2818
+ const $ = ot(t).append("svg").attr("width", "100%").attr("height", "100%").attr("viewBox", `0 0 ${S} ${Y}`).style("background", "white");
2819
+ $.append("defs").html(`
2820
+ <style>
2821
+ @keyframes selected-pulse {
2822
+ 0%, 100% {
2823
+ stroke-opacity: 1;
2824
+ }
2825
+ 50% {
2826
+ stroke-opacity: 0.7;
2827
+ }
2828
+ }
2829
+ .edge {
2830
+ cursor: pointer;
2831
+ }
2832
+ .edge path {
2833
+ /* No transition on dash properties to avoid conflict with animation */
2834
+ }
2835
+ .edge use {
2836
+ transition: transform 0.2s ease;
2837
+ }
2838
+ .edge text {
2839
+ transition: font-weight 0.2s ease;
2840
+ }
2841
+ /* Marching ants animation keyframe */
2842
+ @keyframes marching-ants {
2843
+ 0% { stroke-dashoffset: 0; }
2844
+ 100% { stroke-dashoffset: -12; }
2845
+ }
2846
+ /* Hover effect: marching ants dashed line */
2847
+ .edge:hover:not(.selected) path.edge-path {
2848
+ stroke-dasharray: 6 6;
2849
+ animation: marching-ants 0.6s linear infinite;
2850
+ }
2851
+ /* Selected effect: marching ants dashed line */
2852
+ .edge.selected path.edge-path {
2853
+ stroke-dasharray: 6 6;
2854
+ animation: marching-ants 0.6s linear infinite;
2855
+ }
2856
+ .close-btn {
2857
+ cursor: pointer;
2858
+ }
2859
+ /* Nav icon visibility - controlled purely by CSS */
2860
+ .nav-icon {
2861
+ opacity: 0;
2862
+ transition: opacity 0.15s ease, fill 0.15s ease;
2863
+ pointer-events: none;
2864
+ }
2865
+ /* Show nav icons when hovering over the label area group */
2866
+ .label-area:hover .nav-icon {
2867
+ opacity: 1;
2868
+ }
2869
+ /* Also show nav icons when hovering on selected edge's nav button */
2870
+ .nav-btn-group:hover .nav-icon {
2871
+ fill: #3B82F6 !important;
2872
+ opacity: 1;
2873
+ }
2874
+ .nav-btn-area {
2875
+ transition: fill 0.15s ease;
2876
+ }
2877
+ .nav-btn-group:hover .nav-btn-area {
2878
+ fill: rgba(59, 130, 246, 0.1);
2879
+ }
2880
+ </style>
2881
+ <symbol id="arrow-right" viewBox="0 0 12 12">
2882
+ <path d="M11.53 5.46967C11.8229 5.76256 11.8229 6.23744 11.53 6.53033L6.75736 11.303C6.46447 11.5959 5.98959 11.5959 5.6967 11.303C5.40381 11.0101 5.40381 10.5352 5.6967 10.2423L9.93934 6L5.6967 1.75736C5.40381 1.46447 5.40381 0.989593 5.6967 0.696699C5.98959 0.403806 6.46447 0.403806 6.75736 0.696699L11.53 5.46967ZM0 5.25H11V6.75H0V5.25Z"/>
2883
+ </symbol>
2884
+ <symbol id="nav-left" viewBox="0 0 32 32">
2885
+ <path d="M20.7073 25.2921C20.8002 25.385 20.8739 25.4953 20.9242 25.6167C20.9745 25.7381 21.0004 25.8682 21.0004 25.9996C21.0004 26.131 20.9745 26.2611 20.9242 26.3825C20.8739 26.5039 20.8002 26.6142 20.7073 26.7071C20.6144 26.8 20.5041 26.8737 20.3827 26.924C20.2613 26.9743 20.1312 27.0001 19.9998 27.0001C19.8684 27.0001 19.7383 26.9743 19.6169 26.924C19.4955 26.8737 19.3852 26.8 19.2923 26.7071L9.29231 16.7071C9.19933 16.6142 9.12557 16.5039 9.07525 16.3825C9.02493 16.2611 8.99902 16.131 8.99902 15.9996C8.99902 15.8682 9.02493 15.738 9.07525 15.6166C9.12557 15.4952 9.19933 15.385 9.29231 15.2921L19.2923 5.29208C19.4799 5.10444 19.7344 4.99902 19.9998 4.99902C20.2652 4.99902 20.5197 5.10444 20.7073 5.29208C20.895 5.47972 21.0004 5.73422 21.0004 5.99958C21.0004 6.26494 20.895 6.51944 20.7073 6.70708L11.4136 15.9996L20.7073 25.2921Z"/>
2886
+ </symbol>
2887
+ <symbol id="nav-right" viewBox="0 0 32 32">
2888
+ <path d="M22.7076 16.7071L12.7076 26.7071C12.6147 26.8 12.5044 26.8737 12.383 26.924C12.2616 26.9743 12.1315 27.0001 12.0001 27.0001C11.8687 27.0001 11.7386 26.9743 11.6172 26.924C11.4958 26.8737 11.3855 26.8 11.2926 26.7071C11.1997 26.6142 11.126 26.5039 11.0757 26.3825C11.0254 26.2611 10.9995 26.131 10.9995 25.9996C10.9995 25.8682 11.0254 25.7381 11.0757 25.6167C11.126 25.4953 11.1997 25.385 11.2926 25.2921L20.5863 15.9996L11.2926 6.70708C11.1049 6.51944 10.9995 6.26494 10.9995 5.99958C10.9995 5.73422 11.1049 5.47972 11.2926 5.29208C11.4802 5.10444 11.7347 4.99902 12.0001 4.99902C12.2654 4.99902 12.5199 5.10444 12.7076 5.29208L22.7076 15.2921C22.8005 15.385 22.8743 15.4952 22.9246 15.6166C22.975 15.738 23.0009 15.8682 23.0009 15.9996C23.0009 16.131 22.975 16.2611 22.9246 16.3825C22.8743 16.5039 22.8005 16.6142 22.7076 16.7071Z"/>
2889
+ </symbol>
2890
+ `);
2891
+ const K = $.append("g").attr("id", "graph0");
2892
+ l && $.append("circle").attr("cx", S / 2).attr("cy", Y / 2).attr("r", 8).attr("fill", "red").attr("opacity", 0.9).style("pointer-events", "none").attr("class", "debug-center-marker");
2893
+ const Q = (e.objects || []).map(
2894
+ (f) => new Dn({
2895
+ _gvid: f._gvid,
2896
+ name: f.name,
2897
+ _draw_: f._draw_,
2898
+ _ldraw_: f._ldraw_,
2899
+ bb: f.bb,
2900
+ pos: f.pos,
2901
+ // Apply custom node dimensions if provided (convert points to inches)
2902
+ width: d !== void 0 ? String(d / 72) : f.width,
2903
+ height: g !== void 0 ? String(g / 72) : f.height,
2904
+ label: f.label
2905
+ })
2906
+ ), G = /* @__PURE__ */ new Map();
2907
+ Q.forEach((f) => {
2908
+ G.set(f._gvid, f);
2909
+ });
2910
+ const et = (e.edges || []).map((f) => {
2911
+ const p = new ws({
2912
+ _gvid: f._gvid,
2913
+ name: f.name,
2914
+ _draw_: f._draw_,
2915
+ _ldraw_: f._ldraw_,
2916
+ _hdraw_: f._hdraw_,
2917
+ _tdraw_: f._tdraw_,
2918
+ head: f.head,
2919
+ tail: f.tail,
2920
+ label: f.label
2921
+ }), A = f.tail !== void 0 ? G.get(f.tail) : void 0, w = f.head !== void 0 ? G.get(f.head) : void 0;
2922
+ return A && w && p.setNodes(A, w), p;
2923
+ }), { nodeColumnMap: z, nodeColumns: B, edgeColumns: H } = Ns(
2924
+ Q,
2925
+ et
2926
+ );
2927
+ console.log("debug:", { nodeColumnMap: z, nodeColumns: B, edgeColumns: H }), console.log(
2928
+ "debug: edges sorted by midpoint Y:",
2929
+ Object.fromEntries(
2930
+ Array.from(H.entries()).map(([f, p]) => [
2931
+ f,
2932
+ p.edges.map((A) => {
2933
+ const w = A.getStartPoint(), v = A.getEndPoint(), b = w && v ? (w.y + v.y) / 2 : 0;
2934
+ return {
2935
+ name: A.name,
2936
+ edgeId: A.edgeId,
2937
+ direction: A.getDirection(),
2938
+ startPoint: A.getStartPoint(),
2939
+ endPoint: A.getEndPoint(),
2940
+ midpointY: b.toFixed(2)
2941
+ };
2942
+ })
2943
+ ])
2944
+ )
2945
+ );
2946
+ const I = Array.from(B.keys()).sort((f, p) => f - p), Z = I.length, tt = 80;
2947
+ let h;
2948
+ if (x !== void 0)
2949
+ h = x, S = (Z > 1 ? (Z - 1) * h : 0) + 2 * tt;
2950
+ else {
2951
+ const f = S - 2 * tt;
2952
+ h = Z > 1 ? f / (Z - 1) : 0;
2953
+ }
2954
+ if (I.forEach((f, p) => {
2955
+ const A = B.get(f);
2956
+ if (!A) return;
2957
+ const w = A.nodes;
2958
+ if (w.length === 0) return;
2959
+ console.log(
2960
+ `Column ${f} before sort:`,
2961
+ w.map((D) => ({
2962
+ name: D.name,
2963
+ isVirtual: D.virtualNode,
2964
+ pos: D.pos
2965
+ }))
2966
+ );
2967
+ const v = Z > 1 ? tt + p * h : S / 2;
2968
+ w.sort((D, X) => {
2969
+ const P = D.getPosition(), L = X.getPosition();
2970
+ return !P || !L ? 0 : L[1] - P[1];
2971
+ }), console.log(
2972
+ `Column ${f} after sort:`,
2973
+ w.map((D) => ({
2974
+ name: D.name,
2975
+ isVirtual: D.virtualNode,
2976
+ pos: D.pos
2977
+ }))
2978
+ );
2979
+ const b = 50, m = w.filter((D) => !D.virtualNode), _ = m.length;
2980
+ if (_ === 0) {
2981
+ let D = (Y + w.reduce((X, P) => X + P.getHeightPoints(), 0)) / 2;
2982
+ w.forEach((X) => {
2983
+ const P = X.getHeightPoints();
2984
+ D -= P / 2, X.pos = `${v},${D}`, D -= P / 2;
2985
+ });
2986
+ return;
2987
+ }
2988
+ let E, W;
2989
+ if (_ % 2 === 1) {
2990
+ const D = Math.floor(_ / 2), X = m[D];
2991
+ W = w.indexOf(X), E = Y / 2;
2992
+ } else {
2993
+ const D = _ / 2 - 1, X = _ / 2, P = m[D];
2994
+ m[X], W = w.indexOf(P), E = Y / 2;
2995
+ }
2996
+ const J = w[W], nt = J.getHeightPoints();
2997
+ J.pos = `${v},${E}`, console.log(
2998
+ `Positioned center ${J.name} (virtual: ${J.virtualNode}) at ${J.pos}`
2999
+ );
3000
+ let U = E + nt / 2;
3001
+ for (let D = W - 1; D >= 0; D--) {
3002
+ const X = w[D], P = w[D + 1], L = X.getHeightPoints(), V = X.virtualNode || P.virtualNode ? 0 : b;
3003
+ U += V + L / 2, X.pos = `${v},${U}`, console.log(
3004
+ `Positioned ${X.name} (virtual: ${X.virtualNode}) at ${X.pos}, spacing: ${V}`
3005
+ ), U += L / 2;
3006
+ }
3007
+ U = E - nt / 2;
3008
+ for (let D = W + 1; D < w.length; D++) {
3009
+ const X = w[D], P = w[D - 1], L = X.getHeightPoints(), V = X.virtualNode || P.virtualNode ? 0 : b;
3010
+ U -= V + L / 2, X.pos = `${v},${U}`, console.log(
3011
+ `Positioned ${X.name} (virtual: ${X.virtualNode}) at ${X.pos}, spacing: ${V}`
3012
+ ), U -= L / 2;
3013
+ }
3014
+ }), x !== void 0 && $.attr("viewBox", `0 0 ${S} ${Y}`), B.forEach((f) => {
3015
+ f.nodes.forEach((p) => {
3016
+ const A = p.getPosition();
3017
+ if (!A) return;
3018
+ const [w, v] = A, b = p.getWidthPoints(), m = p.getHeightPoints(), _ = p.virtualNode;
3019
+ if (_ && !l) return;
3020
+ const E = K.append("g").attr("class", _ ? "node virtual-node" : "node").attr("id", p.name), W = l && _, J = p.label ? Fn(p.label) : [], nt = (P) => /^\[[^\]]+\]$/.test(P.trim()), U = [], D = [];
3021
+ for (const P of J)
3022
+ if (nt(P.trim()) && D.length === 0) {
3023
+ const L = P.trim().slice(1, -1);
3024
+ U.push(L);
3025
+ } else
3026
+ D.push(P);
3027
+ if ((U.length > 0 ? D.length >= 1 : D.length >= 2) && !_) {
3028
+ const P = m / 2, L = m / 2, V = Y - v - m / 2;
3029
+ E.append("rect").attr("x", w - b / 2).attr("y", V).attr("width", b).attr("height", P).attr("rx", 5).attr("ry", 0).attr("fill", "#EDF2F7").attr("stroke", "#D5DFEA").attr("stroke-width", 1), E.append("rect").attr("x", w - b / 2).attr("y", V + P).attr("width", b).attr("height", L).attr("rx", 0).attr("ry", 5).attr("fill", "white").attr("stroke", "#D5DFEA").attr("stroke-width", 1);
3030
+ const rt = E.append("rect").attr("x", w - b / 2).attr("y", V).attr("width", b).attr("height", m).attr("rx", 5).attr("ry", 5).attr("fill", "none").attr("stroke", "#D5DFEA").attr("stroke-width", 1), it = E.append("rect").attr("x", w - b / 2 - 4).attr("y", V - 4).attr("width", b + 8).attr("height", m + 8).attr("rx", 5).attr("ry", 5).attr("fill", "none").attr("stroke", "#000000").attr("stroke-width", 2).attr("opacity", 0).style("pointer-events", "none");
3031
+ rt.style("cursor", "pointer").on("mouseenter", function() {
3032
+ it.attr("opacity", 1);
3033
+ }).on("mouseleave", function() {
3034
+ it.attr("opacity", 0);
3035
+ });
3036
+ let q = w - b / 2 + 8;
3037
+ const j = V + P / 2, ct = 7.2, gt = 6, at = 18, jt = 4;
3038
+ if (U.forEach((ht) => {
3039
+ const $t = ht.length * ct + gt * 2;
3040
+ E.append("rect").attr("x", q).attr("y", j - at / 2).attr("width", $t).attr("height", at).attr("rx", 5).attr("ry", 5).attr("fill", "#4E1E03").attr("stroke", "#AA4E09").attr("stroke-width", 1), E.append("text").attr("x", q + gt).attr("y", j).attr("text-anchor", "start").attr("dominant-baseline", "middle").attr("font-family", "var(--font-inter), Inter, Helvetica, Arial").attr("font-size", "12px").attr("font-weight", "500").attr("fill", "white").text(ht), q += $t + jt;
3041
+ }), D.length > 0) {
3042
+ const ht = w + b / 2 - 8 - q, mt = E.append("text").attr("x", q).attr("y", j).attr("text-anchor", "start").attr("dominant-baseline", "middle").attr("font-family", "var(--font-inter), Inter, Helvetica, Arial").attr("font-size", "12px").attr("font-weight", "600").attr("fill", "#334155");
3043
+ ke(mt, ht, D[0]);
3044
+ }
3045
+ const st = (U.length > 0, 1);
3046
+ if (D.length > st) {
3047
+ const ht = b - 16, mt = E.append("text").attr("x", w - b / 2 + 8).attr("y", V + P + L / 2).attr("text-anchor", "start").attr("dominant-baseline", "middle").attr("font-family", "var(--font-fira-code), Fira Code, monospace").attr("font-size", "12px").attr("font-weight", "400").attr("fill", "#334155");
3048
+ ke(mt, ht, D[st]);
3049
+ }
3050
+ } else {
3051
+ const P = E.append("rect").attr("x", w - b / 2).attr("y", Y - v - m / 2).attr("width", b).attr("height", m).attr("rx", 5).attr("ry", 5).attr("fill", W ? "#FEF2F2" : "white").attr("stroke", W ? "#EF4444" : "#D5DFEA").attr("stroke-width", W ? 2 : 1);
3052
+ if (!_) {
3053
+ const L = E.append("rect").attr("x", w - b / 2 - 4).attr("y", Y - v - m / 2 - 4).attr("width", b + 8).attr("height", m + 8).attr("rx", 5).attr("ry", 5).attr("fill", "none").attr("stroke", "#000000").attr("stroke-width", 2).attr("opacity", 0).style("pointer-events", "none");
3054
+ P.style("cursor", "pointer").on("mouseenter", function() {
3055
+ L.attr("opacity", 1);
3056
+ }).on("mouseleave", function() {
3057
+ L.attr("opacity", 0);
3058
+ });
3059
+ }
3060
+ if (p.label) {
3061
+ if (_)
3062
+ E.append("text").attr("x", w).attr("y", Y - v).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-family", "Inter, Helvetica, Arial").attr("font-size", "10px").attr("fill", "#991B1B").text(
3063
+ p.label.length > 20 ? p.label.slice(0, 20) + "..." : p.label
3064
+ );
3065
+ else if (J.length === 1) {
3066
+ const L = b - 16, V = E.append("text").attr("x", w - b / 2 + 8).attr("y", Y - v).attr("text-anchor", "start").attr("dominant-baseline", "middle").attr("font-family", "var(--font-fira-code), Fira Code, monospace").attr("font-size", "12px").attr("font-weight", "400").attr("fill", "#334155");
3067
+ ke(V, L, J[0]);
3068
+ }
3069
+ }
3070
+ }
3071
+ !p.label && p._ldraw_ && p._ldraw_.length > 0 && !_ && p._ldraw_.forEach((P) => {
3072
+ P.op === "T" && P.text && E.append("text").attr("x", w - b / 2 + 8).attr("y", Y - v).attr("text-anchor", "start").attr("dominant-baseline", "middle").attr("font-family", P.face || "Inter, Helvetica, Arial").attr("font-size", `${P.size || 11}px`).attr("fill", P.color || "#334155").text(P.text);
3073
+ });
3074
+ });
3075
+ }), o) {
3076
+ $s(B, Y), ks(et, H), console.log(
3077
+ "debug: base edges selected:",
3078
+ Object.fromEntries(
3079
+ Array.from(H.entries()).map(([m, _]) => {
3080
+ var E, W;
3081
+ return [
3082
+ m,
3083
+ {
3084
+ baseEdge: (E = _.baseEdge) == null ? void 0 : E.name,
3085
+ baseEdgeId: (W = _.baseEdge) == null ? void 0 : W.edgeId,
3086
+ baseEdgeIndex: _.baseEdgeIndex,
3087
+ totalEdges: _.edges.length,
3088
+ depth0Edges: _.edges.filter((J) => J.depth === 0).length
3089
+ }
3090
+ ];
3091
+ })
3092
+ )
3093
+ );
3094
+ const f = s.loopRadius, p = s.edgeSpacing, A = s.labelHeight;
3095
+ H.forEach((m) => {
3096
+ const _ = m.edges;
3097
+ if (_.length === 0) return;
3098
+ const E = m.baseEdge, W = m.baseEdgeIndex;
3099
+ if (!E || W < 0) return;
3100
+ const J = E.getStartPoint(), nt = E.getEndPoint();
3101
+ if (!J || !nt) return;
3102
+ const U = Y - J.y, D = Y - nt.y;
3103
+ E.midY = (U + D) / 2;
3104
+ const X = oe(
3105
+ E,
3106
+ Y,
3107
+ void 0,
3108
+ s
3109
+ );
3110
+ X && (E.midY = X.midY, E.orthogonalPathPoints = X.points), m.aboveY = E.midY, m.belowY = E.midY;
3111
+ for (let P = W - 1; P >= 0; P--) {
3112
+ const L = _[P];
3113
+ if (L.depth !== 0) continue;
3114
+ if (L.getDirection() === "self") {
3115
+ const j = L.getStartPoint();
3116
+ j && (L.midY = Y - j.y - f);
3117
+ continue;
3118
+ }
3119
+ const rt = L.label ? p + A : p;
3120
+ L.midY = m.aboveY - rt, m.aboveY = L.midY, L.baseDirection = "above", L.baseOffset = -(W - P);
3121
+ const it = P < _.length - 1 ? _[P + 1] : void 0, q = oe(
3122
+ L,
3123
+ Y,
3124
+ it,
3125
+ s
3126
+ );
3127
+ q && (L.midY = q.midY, L.orthogonalPathPoints = q.points, m.aboveY = L.midY);
3128
+ }
3129
+ for (let P = W + 1; P < _.length; P++) {
3130
+ const L = _[P];
3131
+ if (L.depth !== 0) continue;
3132
+ if (L.getDirection() === "self") {
3133
+ const j = L.getStartPoint();
3134
+ j && (L.midY = Y - j.y - f);
3135
+ continue;
3136
+ }
3137
+ const rt = L.label ? p + A : p;
3138
+ L.midY = m.belowY + rt, m.belowY = L.midY, L.baseDirection = "below", L.baseOffset = P - W;
3139
+ const it = P > 0 ? _[P - 1] : void 0, q = oe(
3140
+ L,
3141
+ Y,
3142
+ it,
3143
+ s
3144
+ );
3145
+ q && (L.midY = q.midY, L.orthogonalPathPoints = q.points, m.belowY = L.midY);
3146
+ }
3147
+ });
3148
+ const w = [];
3149
+ H.forEach((m) => {
3150
+ const _ = m.edges;
3151
+ _.length === 0 || m.baseEdge || !_.every((W) => W.depth > 0) || _.forEach((W) => {
3152
+ if (W.getDirection() !== "self")
3153
+ w.push(W);
3154
+ else {
3155
+ const J = W.getStartPoint();
3156
+ J && (W.midY = Y - J.y - f);
3157
+ }
3158
+ });
3159
+ }), w.sort((m, _) => m.depth - _.depth), console.log("Processing deep edges by depth:", {
3160
+ totalEdges: w.length,
3161
+ depths: [...new Set(w.map((m) => m.depth))].sort((m, _) => m - _)
3162
+ });
3163
+ let v = 1 / 0, b = -1 / 0;
3164
+ H.forEach((m) => {
3165
+ m.aboveY !== 0 && (v = Math.min(v, m.aboveY)), m.belowY !== 0 && (b = Math.max(b, m.belowY));
3166
+ }), B.forEach((m) => {
3167
+ m.aboveY !== 0 && (v = Math.min(v, m.aboveY)), m.belowY !== 0 && (b = Math.max(b, m.belowY));
3168
+ }), console.log("Global bounds before deep edges:", {
3169
+ globalAboveY: v,
3170
+ globalBelowY: b
3171
+ }), w.forEach((m) => {
3172
+ if (!m.sourceNode || !m.targetNode) return;
3173
+ const _ = z.get(m.sourceNode._gvid), E = z.get(m.targetNode._gvid);
3174
+ if (_ === void 0 || E === void 0) return;
3175
+ const W = Math.min(_, E), J = Math.max(_, E), nt = [];
3176
+ for (let j = W; j <= J; j++) {
3177
+ const ct = B.get(j);
3178
+ ct && nt.push(...ct.nodes);
3179
+ }
3180
+ const U = nt.map((j) => {
3181
+ const ct = j.getPosition();
3182
+ if (!ct) return null;
3183
+ const gt = Y - ct[1], at = j.height ? parseFloat(j.height) * 72 : 40;
3184
+ return { y: gt, height: at, bottomY: gt + at / 2 };
3185
+ }).filter(
3186
+ (j) => j !== null
3187
+ ).sort((j, ct) => j.y - ct.y);
3188
+ let D;
3189
+ if (U.length === 0)
3190
+ D = (v + b) / 2;
3191
+ else if (U.length % 2 === 1)
3192
+ D = U[Math.floor(U.length / 2)].bottomY;
3193
+ else {
3194
+ const j = U.length / 2;
3195
+ D = (U[j - 1].bottomY + U[j].bottomY) / 2;
3196
+ }
3197
+ const X = m.getStartPoint(), P = m.getEndPoint(), V = (X && P ? Y - (X.y + P.y) / 2 : D) < D ? "above" : "below";
3198
+ m.baseDirection = V;
3199
+ const rt = m.label ? p + A : p;
3200
+ let it;
3201
+ V === "above" ? (m.midY = v - rt, it = v, v = m.midY) : (m.midY = b + rt, it = b, b = m.midY), console.log("Placed deep edge:", {
3202
+ edgeId: m.edgeId,
3203
+ depth: m.depth,
3204
+ direction: V,
3205
+ midY: m.midY,
3206
+ centerNodeBottomY: D,
3207
+ globalAboveY: v,
3208
+ globalBelowY: b
3209
+ });
3210
+ const q = oe(
3211
+ m,
3212
+ Y,
3213
+ { midY: it },
3214
+ s
3215
+ );
3216
+ q && (m.midY = q.midY, m.orthogonalPathPoints = q.points, V === "above" ? v = Math.min(v, q.midY) : b = Math.max(b, q.midY));
3217
+ });
3218
+ }
3219
+ const k = et.map((f) => f.edgeId).filter((f) => f !== void 0), y = k.length > 0 ? Math.min(...k) : 0, C = k.length > 0 ? Math.max(...k) : 0, T = Xe().scaleExtent([0.1, xs(t, S, c)]).on("zoom", (f) => {
3220
+ const p = f.transform;
3221
+ console.log("zoom event:", { x: p.x, y: p.y, k: p.k, isNaN: isNaN(p.x) || isNaN(p.y) || isNaN(p.k) }), !isNaN(p.x) && !isNaN(p.y) && !isNaN(p.k) && K.attr("transform", p.toString());
3222
+ });
3223
+ if ($.call(T), et.forEach((f) => {
3224
+ if (r != null) {
3225
+ if (i) {
3226
+ if (f.depth > r) return;
3227
+ } else if (f.depth !== r) return;
3228
+ }
3229
+ Cs(
3230
+ f,
3231
+ K,
3232
+ Y,
3233
+ s,
3234
+ o,
3235
+ y,
3236
+ C,
3237
+ T,
3238
+ $,
3239
+ t,
3240
+ S,
3241
+ Y,
3242
+ a,
3243
+ u,
3244
+ l
3245
+ );
3246
+ }), l) {
3247
+ const f = K.node();
3248
+ if (f) {
3249
+ const p = f.getBBox(), A = p.x + p.width / 2, w = p.y + p.height / 2;
3250
+ K.append("rect").attr("x", p.x).attr("y", p.y).attr("width", p.width).attr("height", p.height).attr("fill", "none").attr("stroke", "yellow").attr("stroke-width", 3).attr("opacity", 0.8).style("pointer-events", "none").attr("class", "debug-root-border"), K.append("circle").attr("cx", A).attr("cy", w).attr("r", 10).attr("fill", "yellow").attr("stroke", "orange").attr("stroke-width", 2).attr("opacity", 0.9).style("pointer-events", "none").attr("class", "debug-geometric-center");
3251
+ }
3252
+ }
3253
+ const R = K.node();
3254
+ if (R) {
3255
+ const f = R.getBBox(), p = 0.9 * S / f.width, A = f.x + f.width / 2, w = f.y + f.height / 2, v = S / 2 - A * p, b = Y / 2 - w * p;
3256
+ $.call(
3257
+ T.transform,
3258
+ Nt.translate(v, b).scale(p)
3259
+ );
3260
+ }
3261
+ return {
3262
+ zoomBehavior: T,
3263
+ svgElement: $.node(),
3264
+ gElement: K.node(),
3265
+ baseFontSize: c,
3266
+ viewBoxWidth: S
3267
+ };
3268
+ }
3269
+ function Mt(t, e, n) {
3270
+ let r = "#000000", i = "#000000", s = "#000000";
3271
+ e.forEach((o) => {
3272
+ switch (o.op) {
3273
+ case "c":
3274
+ o.color && (r = o.color);
3275
+ break;
3276
+ case "C":
3277
+ o.color && (i = o.color);
3278
+ break;
3279
+ case "F":
3280
+ o.color && (s = o.color);
3281
+ break;
3282
+ case "T":
3283
+ o.pt && o.text && t.append("text").attr("x", o.pt[0]).attr("y", n - o.pt[1]).attr(
3284
+ "text-anchor",
3285
+ o.align === "l" ? "start" : o.align === "r" ? "end" : "middle"
3286
+ ).attr("font-family", o.face || "Inter, Helvetica, Arial").attr("font-size", `${o.size || 12}px`).attr("fill", o.color || s).text(o.text);
3287
+ break;
3288
+ case "p":
3289
+ if (o.points) {
3290
+ const c = o.points.map(([l, a]) => [l, n - a]);
3291
+ t.append("polygon").attr("points", c.map((l) => l.join(",")).join(" ")).attr("fill", i).attr("stroke", r);
3292
+ }
3293
+ break;
3294
+ case "P":
3295
+ if (o.points) {
3296
+ const c = o.points.map(([l, a]) => [l, n - a]);
3297
+ t.append("polygon").attr("points", c.map((l) => l.join(",")).join(" ")).attr("fill", "none").attr("stroke", r);
3298
+ }
3299
+ break;
3300
+ case "e":
3301
+ if (o.rect) {
3302
+ const [c, l, a, u] = o.rect;
3303
+ t.append("ellipse").attr("cx", c).attr("cy", n - l).attr("rx", a).attr("ry", u).attr("fill", i).attr("stroke", r);
3304
+ }
3305
+ break;
3306
+ case "E":
3307
+ if (o.rect) {
3308
+ const [c, l, a, u] = o.rect;
3309
+ t.append("ellipse").attr("cx", c).attr("cy", n - l).attr("rx", a).attr("ry", u).attr("fill", "none").attr("stroke", r);
3310
+ }
3311
+ break;
3312
+ case "b":
3313
+ if (o.points) {
3314
+ const c = o.points.map(([a, u]) => [a, n - u]), l = `M${c[0][0]},${c[0][1]} C${c.slice(1).map((a) => `${a[0]},${a[1]}`).join(" ")}`;
3315
+ t.append("path").attr("d", l).attr("fill", "none").attr("stroke", r).attr("stroke-width", 1);
3316
+ }
3317
+ break;
3318
+ case "B":
3319
+ if (o.points) {
3320
+ const c = o.points.map(([a, u]) => [a, n - u]), l = `M${c[0][0]},${c[0][1]} C${c.slice(1).map((a) => `${a[0]},${a[1]}`).join(" ")}`;
3321
+ t.append("path").attr("d", l).attr("fill", i).attr("stroke", r).attr("stroke-width", 1);
3322
+ }
3323
+ break;
3324
+ case "L":
3325
+ if (o.points) {
3326
+ const l = `M${o.points.map(([a, u]) => [a, n - u]).map((a) => `${a[0]},${a[1]}`).join(" L")}`;
3327
+ t.append("path").attr("d", l).attr("fill", "none").attr("stroke", r).attr("stroke-width", 1);
3328
+ }
3329
+ break;
3330
+ }
3331
+ });
3332
+ }
3333
+ function As(t, e, n = 14) {
3334
+ var x;
3335
+ t.innerHTML = "";
3336
+ const r = ((x = e.bb) == null ? void 0 : x.split(",").map(Number)) || [0, 0, 1e3, 800], [, , i, s] = r, o = ot(t).append("svg").attr("width", "100%").attr("height", "100%").attr("viewBox", `0 0 ${i} ${s}`).style("background", "white");
3337
+ o.append("defs").html(`
3338
+ <style>
3339
+ .node rect, .node ellipse, .node polygon {
3340
+ cursor: pointer;
3341
+ }
3342
+ .edge {
3343
+ cursor: pointer;
3344
+ }
3345
+ </style>
3346
+ `);
3347
+ const c = o.append("g").attr("id", "graph0");
3348
+ (e.objects || []).forEach((N) => {
3349
+ const S = c.append("g").attr("class", "node").attr("id", N.name);
3350
+ N._draw_ && Mt(S, N._draw_, s), N._ldraw_ && Mt(S, N._ldraw_, s);
3351
+ }), (e.edges || []).forEach((N) => {
3352
+ const S = c.append("g").attr("class", "edge").attr("id", `edge_${N._gvid}`);
3353
+ N._draw_ && Mt(S, N._draw_, s), N._hdraw_ && Mt(S, N._hdraw_, s), N._tdraw_ && Mt(S, N._tdraw_, s), N._ldraw_ && Mt(S, N._ldraw_, s);
3354
+ });
3355
+ const u = Xe().scaleExtent([0.1, 10]).on("zoom", (N) => {
3356
+ c.attr("transform", N.transform.toString());
3357
+ });
3358
+ o.call(u);
3359
+ const d = t.clientWidth || 800, g = n * (d / i);
3360
+ return {
3361
+ zoomBehavior: u,
3362
+ svgElement: o.node(),
3363
+ gElement: c.node(),
3364
+ baseFontSize: g,
3365
+ viewBoxWidth: i
3366
+ };
3367
+ }
3368
+ function Ms() {
3369
+ const t = lt(null), e = lt(null), [n, r] = Ge(!1), [i, s] = Ge(null), o = be(() => {
3370
+ const a = new Worker(
3371
+ new URL(
3372
+ /* @vite-ignore */
3373
+ "/assets/graphvizWorker-Bbv8iQW7.js",
3374
+ import.meta.url
3375
+ ),
3376
+ { type: "module" }
3377
+ );
3378
+ return a.onmessage = (u) => {
3379
+ const { id: d, success: g, json: x, error: N } = u.data;
3380
+ if (e.current && e.current.id === d) {
3381
+ if (r(!1), g && x)
3382
+ e.current.resolve(x);
3383
+ else {
3384
+ const S = new Error(N || "Unknown worker error");
3385
+ s(S.message), e.current.reject(S);
3386
+ }
3387
+ e.current = null;
3388
+ }
3389
+ }, a.onerror = (u) => {
3390
+ r(!1);
3391
+ const d = new Error(`Worker error: ${u.message}`);
3392
+ s(d.message), e.current && (e.current.reject(d), e.current = null);
3393
+ }, a;
3394
+ }, []);
3395
+ Ce(() => (t.current = o(), () => {
3396
+ var a;
3397
+ (a = t.current) == null || a.terminate(), t.current = null;
3398
+ }), [o]);
3399
+ const c = be((a) => new Promise((u, d) => {
3400
+ if (!t.current) {
3401
+ d(new Error("Worker not initialized"));
3402
+ return;
3403
+ }
3404
+ e.current && e.current.reject(new Error("Request cancelled"));
3405
+ const g = Math.random().toString(36).slice(2);
3406
+ e.current = { id: g, resolve: u, reject: d }, r(!0), s(null);
3407
+ const x = { id: g, dot: a };
3408
+ t.current.postMessage(x);
3409
+ }), []), l = be(() => {
3410
+ e.current && (console.warn("Graphviz worker: Request cancelled by user"), e.current.reject(new Error("Cancelled by user")), e.current = null, r(!1)), t.current && (t.current.terminate(), t.current = o());
3411
+ }, [o]);
3412
+ return { layout: c, cancel: l, isLoading: n, error: i };
3413
+ }
3414
+ function zs({ onCancel: t }) {
3415
+ return /* @__PURE__ */ Et("div", { className: "absolute inset-0 bg-gray-900/80 flex flex-col items-center justify-center z-40", children: /* @__PURE__ */ ue("div", { className: "flex flex-col items-center gap-4", children: [
3416
+ /* @__PURE__ */ Et("div", { className: "w-12 h-12 border-4 border-blue-500/30 border-t-blue-500 rounded-full animate-spin" }),
3417
+ /* @__PURE__ */ ue("div", { className: "text-center", children: [
3418
+ /* @__PURE__ */ Et("p", { className: "text-white font-medium mb-1", children: "Processing layout..." }),
3419
+ /* @__PURE__ */ Et("p", { className: "text-gray-400 text-sm", children: "This may take a while for large graphs" })
3420
+ ] }),
3421
+ /* @__PURE__ */ Et(
3422
+ "button",
3423
+ {
3424
+ onClick: t,
3425
+ className: "mt-2 px-4 py-2 rounded-lg bg-red-600/80 text-white hover:bg-red-600 transition-colors text-sm",
3426
+ children: "Cancel"
3427
+ }
3428
+ )
3429
+ ] }) });
3430
+ }
3431
+ const Bs = Hn(function({
3432
+ dotString: e,
3433
+ nodeMapping: n = {},
3434
+ svgFontSize: r = 14,
3435
+ loadingIndicator: i,
3436
+ onSuccess: s,
3437
+ onError: o,
3438
+ onZoom: c,
3439
+ onRenderProgress: l,
3440
+ className: a = "",
3441
+ showLoading: u = !0,
3442
+ debug: d = !1,
3443
+ selectedEdgeId: g = null,
3444
+ onEdgeSelect: x,
3445
+ useNativeRendering: N = !1,
3446
+ nodeWidth: S = 240,
3447
+ nodeHeight: Y = 64,
3448
+ nodeColumnSpacing: $ = 800
3449
+ }, K) {
3450
+ const O = lt(null), { layout: Q, cancel: G, isLoading: F, error: et } = Ms(), z = lt(null), B = lt(null), H = lt(null), I = lt(14), Z = lt(1e3), tt = lt(!1), h = lt(null), k = lt(null), y = lt(null), C = lt(null), T = lt(x);
3451
+ return T.current = x, Wn(K, () => ({
3452
+ zoomIn: (R = 10) => {
3453
+ var b, m;
3454
+ if (!z.current || !B.current || !H.current) return;
3455
+ const M = Vt(H.current), f = 1 + R / 100, p = M.k * f, A = ot(B.current), w = ((b = O.current) == null ? void 0 : b.clientWidth) || 1, v = ((m = O.current) == null ? void 0 : m.clientHeight) || 1;
3456
+ A.transition().duration(300).call(
3457
+ z.current.scaleTo,
3458
+ p,
3459
+ [w / 2, v / 2]
3460
+ );
3461
+ },
3462
+ zoomOut: (R = 10) => {
3463
+ var b, m;
3464
+ if (!z.current || !B.current || !H.current) return;
3465
+ const M = Vt(H.current), f = 1 - R / 100, p = Math.max(0.1, M.k * f), A = ot(B.current), w = ((b = O.current) == null ? void 0 : b.clientWidth) || 1, v = ((m = O.current) == null ? void 0 : m.clientHeight) || 1;
3466
+ A.transition().duration(300).call(
3467
+ z.current.scaleTo,
3468
+ p,
3469
+ [w / 2, v / 2]
3470
+ );
3471
+ },
3472
+ toggleZoom: () => {
3473
+ var ct, gt;
3474
+ if (!z.current || !B.current || !H.current) return;
3475
+ const R = ot(B.current), M = ((ct = O.current) == null ? void 0 : ct.clientWidth) || 1;
3476
+ (gt = O.current) != null && gt.clientHeight;
3477
+ const f = I.current, p = B.current.getAttribute("viewBox");
3478
+ if (!p) return;
3479
+ const [, , A, w] = p.split(" ").map(Number);
3480
+ if (isNaN(A) || isNaN(w))
3481
+ return;
3482
+ if (!k.current) {
3483
+ const at = H.current.getBBox();
3484
+ k.current = { x: at.x, y: at.y, width: at.width, height: at.height };
3485
+ }
3486
+ const v = k.current;
3487
+ if (console.log("rootBBox:", v), isNaN(v.x) || isNaN(v.y) || isNaN(v.width) || isNaN(v.height)) {
3488
+ console.error("rootBBox contains NaN values, recalculating...");
3489
+ const at = H.current.getBBox();
3490
+ k.current = { x: at.x, y: at.y, width: at.width, height: at.height };
3491
+ }
3492
+ const b = v.x + v.width / 2, m = v.y + v.height / 2, _ = M / A, E = 0.9 * A / v.width, W = f * _ * E, nt = 16 / (f * _), U = f * _ * nt, D = Math.min(E, nt), X = Math.max(E, nt), P = Vt(B.current), L = f * _ * P.k;
3493
+ console.log("toggleZoom debug:", {
3494
+ currentState: tt.current ? "zoomedIn" : "zoomedOut",
3495
+ currentScale: P.k,
3496
+ currentFontSize: L,
3497
+ overviewScale: E,
3498
+ overviewFontSize: W,
3499
+ detailScale: nt,
3500
+ detailFontSize: U,
3501
+ zoomOutScale: D,
3502
+ zoomInScale: X
3503
+ });
3504
+ let V;
3505
+ tt.current ? (V = D, tt.current = !1) : (V = X, h.current = Vt(B.current), tt.current = !0), console.log("toggleZoom target:", {
3506
+ targetScale: V,
3507
+ targetFontSize: f * _ * V,
3508
+ newState: tt.current ? "zoomedIn" : "zoomedOut"
3509
+ });
3510
+ const rt = A / 2 - b * V, it = w / 2 - m * V, q = Nt.translate(rt, it).scale(V);
3511
+ console.log("newTransform:", { x: q.x, y: q.y, k: q.k }), ot(H.current).transition().duration(500).attr("transform", q.toString()).on("end", () => {
3512
+ R.call(z.current.transform, q);
3513
+ });
3514
+ },
3515
+ stopRendering: () => {
3516
+ C.current && (clearInterval(C.current), C.current = null), y.current = null, G(), O.current && (O.current.innerHTML = ""), tt.current = !1, h.current = null;
3517
+ }
3518
+ }), [G]), Ce(() => {
3519
+ if (!e || !O.current) return;
3520
+ let R = !1;
3521
+ return y.current = Date.now(), l && (C.current = setInterval(() => {
3522
+ if (y.current) {
3523
+ const M = Date.now() - y.current;
3524
+ l(M);
3525
+ }
3526
+ }, 100)), Q(e).then((M) => {
3527
+ var p;
3528
+ if (R) return;
3529
+ const f = JSON.parse(M);
3530
+ if (O.current) {
3531
+ let A = r;
3532
+ if (f.objects) {
3533
+ for (const v of f.objects)
3534
+ if (v._ldraw_)
3535
+ for (const b of v._ldraw_)
3536
+ b.size && b.size > A && (A = b.size);
3537
+ }
3538
+ let w;
3539
+ if (N ? w = As(
3540
+ O.current,
3541
+ f,
3542
+ A
3543
+ ) : w = Ss(
3544
+ O.current,
3545
+ f,
3546
+ n,
3547
+ null,
3548
+ // maxDepth - always show all
3549
+ !0,
3550
+ // includeLesserDepths - always true
3551
+ ys(),
3552
+ // Use default layout config
3553
+ !0,
3554
+ // useOrthogonalRendering - always true
3555
+ A,
3556
+ d,
3557
+ null,
3558
+ // selectedEdgeId - handle selection separately via useEffect
3559
+ (v) => {
3560
+ var b;
3561
+ return (b = T.current) == null ? void 0 : b.call(T, v);
3562
+ },
3563
+ // Use ref for callback
3564
+ S,
3565
+ Y,
3566
+ $
3567
+ ), z.current = w.zoomBehavior, B.current = w.svgElement, H.current = w.gElement, I.current = w.baseFontSize, Z.current = w.viewBoxWidth, H.current) {
3568
+ const v = H.current.getBBox();
3569
+ k.current = { x: v.x, y: v.y, width: v.width, height: v.height };
3570
+ const b = Z.current, m = ((p = O.current) == null ? void 0 : p.clientWidth) || 1, _ = I.current, E = m / b, W = 0.9 * b / v.width, J = 16 / (_ * E);
3571
+ tt.current = W >= J;
3572
+ }
3573
+ if (h.current = null, C.current && (clearInterval(C.current), C.current = null), y.current = null, c) {
3574
+ const v = O.current.querySelector("svg"), b = v == null ? void 0 : v.querySelector("#graph0");
3575
+ if (v && b) {
3576
+ const m = A, _ = v.getAttribute("viewBox");
3577
+ let E = 1e3;
3578
+ if (_) {
3579
+ const [, , U] = _.split(" ").map(Number);
3580
+ U && (E = U);
3581
+ }
3582
+ const W = () => {
3583
+ var V;
3584
+ const U = b.getAttribute("transform");
3585
+ let D = 1;
3586
+ if (U) {
3587
+ const rt = U.match(/scale\(([^,)]+)/);
3588
+ if (rt) {
3589
+ const it = parseFloat(rt[1]);
3590
+ isNaN(it) || (D = it);
3591
+ } else {
3592
+ const it = U.match(/matrix\(([^,)]+)/);
3593
+ if (it) {
3594
+ const q = parseFloat(it[1]);
3595
+ isNaN(q) || (D = q);
3596
+ }
3597
+ }
3598
+ }
3599
+ const P = (((V = O.current) == null ? void 0 : V.clientWidth) || 1) / E, L = m * P * D;
3600
+ !isNaN(L) && !isNaN(D) && c({ baseFontSize: m, actualFontSize: L, scale: D });
3601
+ };
3602
+ W();
3603
+ const J = new MutationObserver(W);
3604
+ J.observe(b, {
3605
+ attributes: !0,
3606
+ attributeFilter: ["transform"]
3607
+ });
3608
+ const nt = () => W();
3609
+ return window.addEventListener("resize", nt), () => {
3610
+ J.disconnect(), window.removeEventListener("resize", nt);
3611
+ };
3612
+ }
3613
+ }
3614
+ }
3615
+ s == null || s(f);
3616
+ }).catch((M) => {
3617
+ R || (C.current && (clearInterval(C.current), C.current = null), y.current = null, M.message !== "Cancelled by user" && M.message !== "Request cancelled" && (console.error("GraphvizRenderer error:", M), O.current && (O.current.innerHTML = `<div style="padding: 1rem; color: #ef4444"><strong>Error rendering graph:</strong> ${M.message}</div>`), o == null || o(M instanceof Error ? M : new Error(String(M)))));
3618
+ }), () => {
3619
+ R = !0, C.current && (clearInterval(C.current), C.current = null), y.current = null, G();
3620
+ };
3621
+ }, [
3622
+ e,
3623
+ n,
3624
+ r,
3625
+ l,
3626
+ d,
3627
+ N,
3628
+ S,
3629
+ Y,
3630
+ $
3631
+ ]), Ce(() => {
3632
+ var M;
3633
+ if (N || !O.current) return;
3634
+ const R = O.current.querySelector("svg");
3635
+ if (R && (R.querySelectorAll("g.edge.selected").forEach((f) => {
3636
+ f.classList.remove("selected"), f.querySelectorAll(".close-btn, .close-btn-bg").forEach((p) => p.remove());
3637
+ }), g != null)) {
3638
+ const f = R.querySelector(`g.edge[data-edge-id="${g}"]`);
3639
+ if (f) {
3640
+ f.classList.add("selected"), (M = f.parentNode) == null || M.appendChild(f);
3641
+ const p = f.querySelector(".label-bg");
3642
+ if (p && x) {
3643
+ p.getBoundingClientRect();
3644
+ const A = f.querySelector(".label-text");
3645
+ if (A) {
3646
+ const w = A.getAttribute("y"), v = parseFloat(p.getAttribute("x") || "0"), b = parseFloat(p.getAttribute("width") || "0"), m = v + b + 16;
3647
+ if (!f.querySelector(".close-btn")) {
3648
+ const _ = document.createElementNS("http://www.w3.org/2000/svg", "circle");
3649
+ _.setAttribute("class", "close-btn-bg"), _.setAttribute("cx", String(m)), _.setAttribute("cy", w || "0"), _.setAttribute("r", "8"), _.setAttribute("fill", "white"), _.setAttribute("stroke", "#d0d0d0"), _.setAttribute("stroke-width", "1"), _.style.cursor = "pointer";
3650
+ const E = document.createElementNS("http://www.w3.org/2000/svg", "text");
3651
+ E.setAttribute("class", "close-btn"), E.setAttribute("x", String(m)), E.setAttribute("y", w || "0"), E.setAttribute("text-anchor", "middle"), E.setAttribute("dominant-baseline", "central"), E.setAttribute("font-family", "Arial"), E.setAttribute("font-size", "12px"), E.setAttribute("font-weight", "bold"), E.setAttribute("fill", "#888"), E.style.cursor = "pointer", E.textContent = "✕";
3652
+ const W = (J) => {
3653
+ J.stopPropagation(), x(null);
3654
+ };
3655
+ _.addEventListener("click", W), E.addEventListener("click", W), f.appendChild(_), f.appendChild(E);
3656
+ }
3657
+ }
3658
+ }
3659
+ }
3660
+ }
3661
+ }, [g, x, N]), /* @__PURE__ */ ue("div", { className: `graphviz-renderer ${a}`.trim(), style: { position: "relative", width: "100%", height: "100%" }, children: [
3662
+ /* @__PURE__ */ Et("div", { ref: O, style: { width: "100%", height: "100%" } }),
3663
+ F && u && (i ?? /* @__PURE__ */ Et(zs, { onCancel: G })),
3664
+ et && !F && /* @__PURE__ */ ue("div", { style: { padding: "1rem", color: "#ef4444" }, children: [
3665
+ /* @__PURE__ */ Et("strong", { children: "Error:" }),
3666
+ " ",
3667
+ et
3668
+ ] })
3669
+ ] });
3670
+ });
3671
+ export {
3672
+ ve as DEFAULT_LAYOUT_CONFIG,
3673
+ Bs as GraphvizRenderer,
3674
+ Ys as LARGE_GRAPH_THRESHOLD,
3675
+ zs as WorkerLoadingIndicator,
3676
+ ys as createLayoutConfig,
3677
+ Ss as renderCustomGraph,
3678
+ Ts as setupZoomPan,
3679
+ Ms as useGraphvizWorker
3680
+ };