@avodado/render 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ html{scroll-behavior:smooth;}
14
14
  --positive:#3f7d4e; --positive-soft:#e3efe2; --negative:#a13b2e; --negative-soft:#f4e0db;
15
15
  --purple:#5b4a8a; --purple-soft:#ebe6f3; --teal:#2f6f6a; --teal-soft:#e0eeec; --white:#fcfbf7;
16
16
  --radius:4px;
17
- --font-display:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,"Times New Roman",serif;
18
- --font-body:Georgia,"Iowan Old Style",Palatino,"Times New Roman",serif;
17
+ --font-display:"Inter","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
18
+ --font-body:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
19
19
  --font-mono:"SF Mono",ui-monospace,Menlo,Consolas,"Courier New",monospace;
20
20
  }
21
21
  body{background:var(--white);color:var(--charcoal);font-family:var(--font-body);font-size:15px;line-height:1.6;}
@@ -414,67 +414,1734 @@ function renderCallout(data) {
414
414
  return `<div class="callout ${tone}"><div class="callout-title">${escapeHtml(title)}</div><div class="callout-body">${escapeHtml(body)}</div></div>`;
415
415
  }
416
416
 
417
+ // ../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/dist/dagre.esm.js
418
+ var ge = Object.defineProperty;
419
+ var hn = (e, n, t) => n in e ? ge(e, n, { enumerable: true, configurable: true, writable: true, value: t }) : e[n] = t;
420
+ var fn = (e, n) => {
421
+ for (var t in n) ge(e, t, { get: n[t], enumerable: true });
422
+ };
423
+ var pe = (e, n, t) => hn(e, n + "" , t);
424
+ var z = {};
425
+ fn(z, { Graph: () => p, alg: () => R, json: () => ye, version: () => pn });
426
+ var bn = Object.defineProperty;
427
+ var Le = (e, n) => {
428
+ for (var t in n) bn(e, t, { get: n[t], enumerable: true });
429
+ };
430
+ var p = class {
431
+ constructor(e) {
432
+ this._isDirected = true, this._isMultigraph = false, this._isCompound = false, this._nodes = {}, this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {}, this._nodeCount = 0, this._edgeCount = 0, this._defaultNodeLabelFn = () => {
433
+ }, this._defaultEdgeLabelFn = () => {
434
+ }, e && (this._isDirected = "directed" in e ? e.directed : true, this._isMultigraph = "multigraph" in e ? e.multigraph : false, this._isCompound = "compound" in e ? e.compound : false), this._isCompound && (this._parent = {}, this._children = {}, this._children["\0"] = {});
435
+ }
436
+ isDirected() {
437
+ return this._isDirected;
438
+ }
439
+ isMultigraph() {
440
+ return this._isMultigraph;
441
+ }
442
+ isCompound() {
443
+ return this._isCompound;
444
+ }
445
+ setGraph(e) {
446
+ return this._label = e, this;
447
+ }
448
+ graph() {
449
+ return this._label;
450
+ }
451
+ setDefaultNodeLabel(e) {
452
+ return typeof e != "function" ? this._defaultNodeLabelFn = () => e : this._defaultNodeLabelFn = e, this;
453
+ }
454
+ nodeCount() {
455
+ return this._nodeCount;
456
+ }
457
+ nodes() {
458
+ return Object.keys(this._nodes);
459
+ }
460
+ sources() {
461
+ return this.nodes().filter((e) => Object.keys(this._in[e]).length === 0);
462
+ }
463
+ sinks() {
464
+ return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
465
+ }
466
+ setNodes(e, n) {
467
+ return e.forEach((t) => {
468
+ n !== void 0 ? this.setNode(t, n) : this.setNode(t);
469
+ }), this;
470
+ }
471
+ setNode(e, n) {
472
+ return e in this._nodes ? (arguments.length > 1 && (this._nodes[e] = n), this) : (this._nodes[e] = arguments.length > 1 ? n : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = "\0", this._children[e] = {}, this._children["\0"][e] = true), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
473
+ }
474
+ node(e) {
475
+ return this._nodes[e];
476
+ }
477
+ hasNode(e) {
478
+ return e in this._nodes;
479
+ }
480
+ removeNode(e) {
481
+ if (e in this._nodes) {
482
+ let n = (t) => this.removeEdge(this._edgeObjs[t]);
483
+ delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((t) => {
484
+ this.setParent(t);
485
+ }), delete this._children[e]), Object.keys(this._in[e]).forEach(n), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(n), delete this._out[e], delete this._sucs[e], --this._nodeCount;
486
+ }
487
+ return this;
488
+ }
489
+ setParent(e, n) {
490
+ if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
491
+ if (n === void 0) n = "\0";
492
+ else {
493
+ n += "";
494
+ for (let t = n; t !== void 0; t = this.parent(t)) if (t === e) throw new Error("Setting " + n + " as parent of " + e + " would create a cycle");
495
+ this.setNode(n);
496
+ }
497
+ return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = n, this._children[n][e] = true, this;
498
+ }
499
+ parent(e) {
500
+ if (this._isCompound) {
501
+ let n = this._parent[e];
502
+ if (n !== "\0") return n;
503
+ }
504
+ }
505
+ children(e = "\0") {
506
+ if (this._isCompound) {
507
+ let n = this._children[e];
508
+ if (n) return Object.keys(n);
509
+ } else {
510
+ if (e === "\0") return this.nodes();
511
+ if (this.hasNode(e)) return [];
512
+ }
513
+ return [];
514
+ }
515
+ predecessors(e) {
516
+ let n = this._preds[e];
517
+ if (n) return Object.keys(n);
518
+ }
519
+ successors(e) {
520
+ let n = this._sucs[e];
521
+ if (n) return Object.keys(n);
522
+ }
523
+ neighbors(e) {
524
+ let n = this.predecessors(e);
525
+ if (n) {
526
+ let t = new Set(n);
527
+ for (let r of this.successors(e)) t.add(r);
528
+ return Array.from(t.values());
529
+ }
530
+ }
531
+ isLeaf(e) {
532
+ let n;
533
+ return this.isDirected() ? n = this.successors(e) : n = this.neighbors(e), n.length === 0;
534
+ }
535
+ filterNodes(e) {
536
+ let n = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
537
+ n.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
538
+ e(o) && n.setNode(o, i);
539
+ }), Object.values(this._edgeObjs).forEach((o) => {
540
+ n.hasNode(o.v) && n.hasNode(o.w) && n.setEdge(o, this.edge(o));
541
+ });
542
+ let t = {}, r = (o) => {
543
+ let i = this.parent(o);
544
+ return !i || n.hasNode(i) ? (t[o] = i != null ? i : void 0, i != null ? i : void 0) : i in t ? t[i] : r(i);
545
+ };
546
+ return this._isCompound && n.nodes().forEach((o) => n.setParent(o, r(o))), n;
547
+ }
548
+ setDefaultEdgeLabel(e) {
549
+ return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
550
+ }
551
+ edgeCount() {
552
+ return this._edgeCount;
553
+ }
554
+ edges() {
555
+ return Object.values(this._edgeObjs);
556
+ }
557
+ setPath(e, n) {
558
+ return e.reduce((t, r) => (n !== void 0 ? this.setEdge(t, r, n) : this.setEdge(t, r), r)), this;
559
+ }
560
+ setEdge(e, n, t, r) {
561
+ let o, i, s, a, d = false;
562
+ typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (a = n, d = true)) : (o = e, i = n, s = r, arguments.length > 2 && (a = t, d = true)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
563
+ let l = C(this._isDirected, o, i, s);
564
+ if (l in this._edgeLabels) return d && (this._edgeLabels[l] = a), this;
565
+ if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
566
+ this.setNode(o), this.setNode(i), this._edgeLabels[l] = d ? a : this._defaultEdgeLabelFn(o, i, s);
567
+ let u = gn(this._isDirected, o, i, s);
568
+ return o = u.v, i = u.w, Object.freeze(u), this._edgeObjs[l] = u, me(this._preds[i], o), me(this._sucs[o], i), this._in[i][l] = u, this._out[o][l] = u, this._edgeCount++, this;
569
+ }
570
+ edge(e, n, t) {
571
+ let r = arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t);
572
+ return this._edgeLabels[r];
573
+ }
574
+ edgeAsObj(e, n, t) {
575
+ let r = arguments.length === 1 ? this.edge(e) : this.edge(e, n, t);
576
+ return typeof r != "object" ? { label: r } : r;
577
+ }
578
+ hasEdge(e, n, t) {
579
+ return (arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t)) in this._edgeLabels;
580
+ }
581
+ removeEdge(e, n, t) {
582
+ let r = arguments.length === 1 ? Y(this._isDirected, e) : C(this._isDirected, e, n, t), o = this._edgeObjs[r];
583
+ if (o) {
584
+ let i = o.v, s = o.w;
585
+ delete this._edgeLabels[r], delete this._edgeObjs[r], Ee(this._preds[s], i), Ee(this._sucs[i], s), delete this._in[s][r], delete this._out[i][r], this._edgeCount--;
586
+ }
587
+ return this;
588
+ }
589
+ inEdges(e, n) {
590
+ return this.isDirected() ? this.filterEdges(this._in[e], e, n) : this.nodeEdges(e, n);
591
+ }
592
+ outEdges(e, n) {
593
+ return this.isDirected() ? this.filterEdges(this._out[e], e, n) : this.nodeEdges(e, n);
594
+ }
595
+ nodeEdges(e, n) {
596
+ if (e in this._nodes) return this.filterEdges({ ...this._in[e], ...this._out[e] }, e, n);
597
+ }
598
+ _removeFromParentsChildList(e) {
599
+ delete this._children[this._parent[e]][e];
600
+ }
601
+ filterEdges(e, n, t) {
602
+ if (!e) return;
603
+ let r = Object.values(e);
604
+ return t ? r.filter((o) => o.v === n && o.w === t || o.v === t && o.w === n) : r;
605
+ }
606
+ };
607
+ function me(e, n) {
608
+ e[n] ? e[n]++ : e[n] = 1;
609
+ }
610
+ function Ee(e, n) {
611
+ e[n] !== void 0 && !--e[n] && delete e[n];
612
+ }
613
+ function C(e, n, t, r) {
614
+ let o = "" + n, i = "" + t;
615
+ if (!e && o > i) {
616
+ let s = o;
617
+ o = i, i = s;
618
+ }
619
+ return o + "" + i + "" + (r === void 0 ? "\0" : r);
620
+ }
621
+ function gn(e, n, t, r) {
622
+ let o = "" + n, i = "" + t;
623
+ if (!e && o > i) {
624
+ let a = o;
625
+ o = i, i = a;
626
+ }
627
+ let s = { v: o, w: i };
628
+ return r && (s.name = r), s;
629
+ }
630
+ function Y(e, n) {
631
+ return C(e, n.v, n.w, n.name);
632
+ }
633
+ var pn = "4.0.1";
634
+ var ye = {};
635
+ Le(ye, { read: () => yn, write: () => mn });
636
+ function mn(e) {
637
+ let n = { options: { directed: e.isDirected(), multigraph: e.isMultigraph(), compound: e.isCompound() }, nodes: En(e), edges: Ln(e) }, t = e.graph();
638
+ return t !== void 0 && (n.value = structuredClone(t)), n;
639
+ }
640
+ function En(e) {
641
+ return e.nodes().map((n) => {
642
+ let t = e.node(n), r = e.parent(n), o = { v: n };
643
+ return t !== void 0 && (o.value = t), r !== void 0 && (o.parent = r), o;
644
+ });
645
+ }
646
+ function Ln(e) {
647
+ return e.edges().map((n) => {
648
+ let t = e.edge(n), r = { v: n.v, w: n.w };
649
+ return n.name !== void 0 && (r.name = n.name), t !== void 0 && (r.value = t), r;
650
+ });
651
+ }
652
+ function yn(e) {
653
+ let n = new p(e.options);
654
+ return e.value !== void 0 && n.setGraph(e.value), e.nodes.forEach((t) => {
655
+ n.setNode(t.v, t.value), t.parent && n.setParent(t.v, t.parent);
656
+ }), e.edges.forEach((t) => {
657
+ n.setEdge({ v: t.v, w: t.w, name: t.name }, t.value);
658
+ }), n;
659
+ }
660
+ var R = {};
661
+ Le(R, { CycleException: () => D, bellmanFord: () => we, components: () => Gn, dijkstra: () => F, dijkstraAll: () => _n, findCycles: () => xn, floydWarshall: () => On, isAcyclic: () => Cn, postorder: () => Pn, preorder: () => Mn, prim: () => jn, shortestPaths: () => Sn, tarjan: () => Ge, topsort: () => ke });
662
+ var wn = () => 1;
663
+ function we(e, n, t, r) {
664
+ return Nn(e, String(n), t || wn, r || function(o) {
665
+ return e.outEdges(o);
666
+ });
667
+ }
668
+ function Nn(e, n, t, r) {
669
+ let o = {}, i, s = 0, a = e.nodes(), d = function(c) {
670
+ let h = t(c);
671
+ o[c.v].distance + h < o[c.w].distance && (o[c.w] = { distance: o[c.v].distance + h, predecessor: c.v }, i = true);
672
+ }, l = function() {
673
+ a.forEach(function(c) {
674
+ r(c).forEach(function(h) {
675
+ let f = h.v === c ? h.v : h.w, g = f === h.v ? h.w : h.v;
676
+ d({ v: f, w: g });
677
+ });
678
+ });
679
+ };
680
+ a.forEach(function(c) {
681
+ let h = c === n ? 0 : Number.POSITIVE_INFINITY;
682
+ o[c] = { distance: h, predecessor: "" };
683
+ });
684
+ let u = a.length;
685
+ for (let c = 1; c < u && (i = false, s++, l(), !!i); c++) ;
686
+ if (s === u - 1 && (i = false, l(), i)) throw new Error("The graph contains a negative weight cycle");
687
+ return o;
688
+ }
689
+ function Gn(e) {
690
+ let n = {}, t = [], r;
691
+ function o(i) {
692
+ i in n || (n[i] = true, r.push(i), e.successors(i).forEach(o), e.predecessors(i).forEach(o));
693
+ }
694
+ return e.nodes().forEach(function(i) {
695
+ r = [], o(i), r.length && t.push(r);
696
+ }), t;
697
+ }
698
+ var Ne = class {
699
+ constructor() {
700
+ this._arr = [], this._keyIndices = {};
701
+ }
702
+ size() {
703
+ return this._arr.length;
704
+ }
705
+ keys() {
706
+ return this._arr.map((e) => e.key);
707
+ }
708
+ has(e) {
709
+ return e in this._keyIndices;
710
+ }
711
+ priority(e) {
712
+ let n = this._keyIndices[e];
713
+ if (n !== void 0) return this._arr[n].priority;
714
+ }
715
+ min() {
716
+ if (this.size() === 0) throw new Error("Queue underflow");
717
+ return this._arr[0].key;
718
+ }
719
+ add(e, n) {
720
+ let t = this._keyIndices, r = String(e);
721
+ if (!(r in t)) {
722
+ let o = this._arr, i = o.length;
723
+ return t[r] = i, o.push({ key: r, priority: n }), this._decrease(i), true;
724
+ }
725
+ return false;
726
+ }
727
+ removeMin() {
728
+ this._swap(0, this._arr.length - 1);
729
+ let e = this._arr.pop();
730
+ return delete this._keyIndices[e.key], this._heapify(0), e.key;
731
+ }
732
+ decrease(e, n) {
733
+ let t = this._keyIndices[e];
734
+ if (t === void 0) throw new Error(`Key not found: ${e}`);
735
+ let r = this._arr[t].priority;
736
+ if (n > r) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${n}`);
737
+ this._arr[t].priority = n, this._decrease(t);
738
+ }
739
+ _heapify(e) {
740
+ let n = this._arr, t = 2 * e, r = t + 1, o = e;
741
+ t < n.length && (o = n[t].priority < n[o].priority ? t : o, r < n.length && (o = n[r].priority < n[o].priority ? r : o), o !== e && (this._swap(e, o), this._heapify(o)));
742
+ }
743
+ _decrease(e) {
744
+ let n = this._arr, t = n[e].priority, r;
745
+ for (; e !== 0 && (r = e >> 1, !(n[r].priority < t)); ) this._swap(e, r), e = r;
746
+ }
747
+ _swap(e, n) {
748
+ let t = this._arr, r = this._keyIndices, o = t[e], i = t[n];
749
+ t[e] = i, t[n] = o, r[i.key] = e, r[o.key] = n;
750
+ }
751
+ };
752
+ var kn = () => 1;
753
+ function F(e, n, t, r) {
754
+ let o = function(i) {
755
+ return e.outEdges(i);
756
+ };
757
+ return vn(e, String(n), t || kn, r || o);
758
+ }
759
+ function vn(e, n, t, r) {
760
+ let o = {}, i = new Ne(), s, a, d = function(l) {
761
+ let u = l.v !== s ? l.v : l.w, c = o[u], h = t(l), f = a.distance + h;
762
+ if (h < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + l + " Weight: " + h);
763
+ f < c.distance && (c.distance = f, c.predecessor = s, i.decrease(u, f));
764
+ };
765
+ for (e.nodes().forEach(function(l) {
766
+ let u = l === n ? 0 : Number.POSITIVE_INFINITY;
767
+ o[l] = { distance: u, predecessor: "" }, i.add(l, u);
768
+ }); i.size() > 0 && (s = i.removeMin(), a = o[s], a.distance !== Number.POSITIVE_INFINITY); ) r(s).forEach(d);
769
+ return o;
770
+ }
771
+ function _n(e, n, t) {
772
+ return e.nodes().reduce(function(r, o) {
773
+ return r[o] = F(e, o, n, t), r;
774
+ }, {});
775
+ }
776
+ function Ge(e) {
777
+ let n = 0, t = [], r = {}, o = [];
778
+ function i(s) {
779
+ let a = r[s] = { onStack: true, lowlink: n, index: n++ };
780
+ if (t.push(s), e.successors(s).forEach(function(d) {
781
+ d in r ? r[d].onStack && (a.lowlink = Math.min(a.lowlink, r[d].index)) : (i(d), a.lowlink = Math.min(a.lowlink, r[d].lowlink));
782
+ }), a.lowlink === a.index) {
783
+ let d = [], l;
784
+ do
785
+ l = t.pop(), r[l].onStack = false, d.push(l);
786
+ while (s !== l);
787
+ o.push(d);
788
+ }
789
+ }
790
+ return e.nodes().forEach(function(s) {
791
+ s in r || i(s);
792
+ }), o;
793
+ }
794
+ function xn(e) {
795
+ return Ge(e).filter(function(n) {
796
+ return n.length > 1 || n.length === 1 && e.hasEdge(n[0], n[0]);
797
+ });
798
+ }
799
+ var Tn = () => 1;
800
+ function On(e, n, t) {
801
+ return In(e, n || Tn, t || function(r) {
802
+ return e.outEdges(r);
803
+ });
804
+ }
805
+ function In(e, n, t) {
806
+ let r = {}, o = e.nodes();
807
+ return o.forEach(function(i) {
808
+ r[i] = {}, r[i][i] = { distance: 0, predecessor: "" }, o.forEach(function(s) {
809
+ i !== s && (r[i][s] = { distance: Number.POSITIVE_INFINITY, predecessor: "" });
810
+ }), t(i).forEach(function(s) {
811
+ let a = s.v === i ? s.w : s.v, d = n(s);
812
+ r[i][a] = { distance: d, predecessor: i };
813
+ });
814
+ }), o.forEach(function(i) {
815
+ let s = r[i];
816
+ o.forEach(function(a) {
817
+ let d = r[a];
818
+ o.forEach(function(l) {
819
+ let u = d[i], c = s[l], h = d[l], f = u.distance + c.distance;
820
+ f < h.distance && (h.distance = f, h.predecessor = c.predecessor);
821
+ });
822
+ });
823
+ }), r;
824
+ }
825
+ var D = class extends Error {
826
+ constructor(...e) {
827
+ super(...e);
828
+ }
829
+ };
830
+ function ke(e) {
831
+ let n = {}, t = {}, r = [];
832
+ function o(i) {
833
+ if (i in t) throw new D();
834
+ i in n || (t[i] = true, n[i] = true, e.predecessors(i).forEach(o), delete t[i], r.push(i));
835
+ }
836
+ if (e.sinks().forEach(o), Object.keys(n).length !== e.nodeCount()) throw new D();
837
+ return r;
838
+ }
839
+ function Cn(e) {
840
+ try {
841
+ ke(e);
842
+ } catch (n) {
843
+ if (n instanceof D) return false;
844
+ throw n;
845
+ }
846
+ return true;
847
+ }
848
+ function Rn(e, n, t, r, o) {
849
+ Array.isArray(n) || (n = [n]);
850
+ let i = ((a) => {
851
+ var d;
852
+ return (d = e.isDirected() ? e.successors(a) : e.neighbors(a)) != null ? d : [];
853
+ }), s = {};
854
+ return n.forEach(function(a) {
855
+ if (!e.hasNode(a)) throw new Error("Graph does not have node: " + a);
856
+ o = ve(e, a, t === "post", s, i, r, o);
857
+ }), o;
858
+ }
859
+ function ve(e, n, t, r, o, i, s) {
860
+ return n in r || (r[n] = true, t || (s = i(s, n)), o(n).forEach(function(a) {
861
+ s = ve(e, a, t, r, o, i, s);
862
+ }), t && (s = i(s, n))), s;
863
+ }
864
+ function _e(e, n, t) {
865
+ return Rn(e, n, t, function(r, o) {
866
+ return r.push(o), r;
867
+ }, []);
868
+ }
869
+ function Pn(e, n) {
870
+ return _e(e, n, "post");
871
+ }
872
+ function Mn(e, n) {
873
+ return _e(e, n, "pre");
874
+ }
875
+ function jn(e, n) {
876
+ let t = new p(), r = {}, o = new Ne(), i;
877
+ function s(d) {
878
+ let l = d.v === i ? d.w : d.v, u = o.priority(l);
879
+ if (u !== void 0) {
880
+ let c = n(d);
881
+ c < u && (r[l] = i, o.decrease(l, c));
882
+ }
883
+ }
884
+ if (e.nodeCount() === 0) return t;
885
+ e.nodes().forEach(function(d) {
886
+ o.add(d, Number.POSITIVE_INFINITY), t.setNode(d);
887
+ }), o.decrease(e.nodes()[0], 0);
888
+ let a = false;
889
+ for (; o.size() > 0; ) {
890
+ if (i = o.removeMin(), i in r) t.setEdge(i, r[i]);
891
+ else {
892
+ if (a) throw new Error("Input graph is not connected: " + e);
893
+ a = true;
894
+ }
895
+ e.nodeEdges(i).forEach(s);
896
+ }
897
+ return t;
898
+ }
899
+ function Sn(e, n, t, r) {
900
+ return Fn(e, n, t, r != null ? r : ((o) => {
901
+ let i = e.outEdges(o);
902
+ return i != null ? i : [];
903
+ }));
904
+ }
905
+ function Fn(e, n, t, r) {
906
+ if (t === void 0) return F(e, n, t, r);
907
+ let o = false, i = e.nodes();
908
+ for (let s = 0; s < i.length; s++) {
909
+ let a = r(i[s]);
910
+ for (let d = 0; d < a.length; d++) {
911
+ let l = a[d], u = l.v === i[s] ? l.v : l.w, c = u === l.v ? l.w : l.v;
912
+ t({ v: u, w: c }) < 0 && (o = true);
913
+ }
914
+ if (o) return we(e, n, t, r);
915
+ }
916
+ return F(e, n, t, r);
917
+ }
918
+ function w(e, n, t, r) {
919
+ let o = r;
920
+ for (; e.hasNode(o); ) o = j(r);
921
+ return t.dummy = n, e.setNode(o, t), o;
922
+ }
923
+ function xe(e) {
924
+ let n = new p().setGraph(e.graph());
925
+ return e.nodes().forEach((t) => n.setNode(t, e.node(t))), e.edges().forEach((t) => {
926
+ let r = n.edge(t.v, t.w) || { weight: 0, minlen: 1 }, o = e.edge(t);
927
+ n.setEdge(t.v, t.w, { weight: r.weight + o.weight, minlen: Math.max(r.minlen, o.minlen) });
928
+ }), n;
929
+ }
930
+ function A(e) {
931
+ let n = new p({ multigraph: e.isMultigraph() }).setGraph(e.graph());
932
+ return e.nodes().forEach((t) => {
933
+ e.children(t).length || n.setNode(t, e.node(t));
934
+ }), e.edges().forEach((t) => {
935
+ n.setEdge(t, e.edge(t));
936
+ }), n;
937
+ }
938
+ function H(e, n) {
939
+ let t = e.x, r = e.y, o = n.x - t, i = n.y - r, s = e.width / 2, a = e.height / 2;
940
+ if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
941
+ let d, l;
942
+ return Math.abs(i) * s > Math.abs(o) * a ? (i < 0 && (a = -a), d = a * o / i, l = a) : (o < 0 && (s = -s), d = s, l = s * i / o), { x: t + d, y: r + l };
943
+ }
944
+ function N(e) {
945
+ let n = k(X(e) + 1).map(() => []);
946
+ return e.nodes().forEach((t) => {
947
+ let r = e.node(t), o = r.rank;
948
+ o !== void 0 && (n[o] || (n[o] = []), n[o][r.order] = t);
949
+ }), n;
950
+ }
951
+ function Te(e) {
952
+ let n = e.nodes().map((r) => {
953
+ let o = e.node(r).rank;
954
+ return o === void 0 ? Number.MAX_VALUE : o;
955
+ }), t = L(Math.min, n);
956
+ e.nodes().forEach((r) => {
957
+ let o = e.node(r);
958
+ Object.hasOwn(o, "rank") && (o.rank -= t);
959
+ });
960
+ }
961
+ function Oe(e) {
962
+ let n = e.nodes().map((s) => e.node(s).rank).filter((s) => s !== void 0), t = L(Math.min, n), r = [];
963
+ e.nodes().forEach((s) => {
964
+ let a = e.node(s).rank - t;
965
+ r[a] || (r[a] = []), r[a].push(s);
966
+ });
967
+ let o = 0, i = e.graph().nodeRankFactor;
968
+ Array.from(r).forEach((s, a) => {
969
+ s === void 0 && a % i !== 0 ? --o : s !== void 0 && o && s.forEach((d) => e.node(d).rank += o);
970
+ });
971
+ }
972
+ function q(e, n, t, r) {
973
+ let o = { width: 0, height: 0 };
974
+ return arguments.length >= 4 && (o.rank = t, o.order = r), w(e, "border", o, n);
975
+ }
976
+ function Dn(e, n = Ie) {
977
+ let t = [];
978
+ for (let r = 0; r < e.length; r += n) {
979
+ let o = e.slice(r, r + n);
980
+ t.push(o);
981
+ }
982
+ return t;
983
+ }
984
+ var Ie = 65535;
985
+ function L(e, n) {
986
+ if (n.length > Ie) {
987
+ let t = Dn(n);
988
+ return e(...t.map((r) => e(...r)));
989
+ } else return e(...n);
990
+ }
991
+ function X(e) {
992
+ let t = e.nodes().map((r) => {
993
+ let o = e.node(r).rank;
994
+ return o === void 0 ? Number.MIN_VALUE : o;
995
+ });
996
+ return L(Math.max, t);
997
+ }
998
+ function Ce(e, n) {
999
+ let t = { lhs: [], rhs: [] };
1000
+ return e.forEach((r) => {
1001
+ n(r) ? t.lhs.push(r) : t.rhs.push(r);
1002
+ }), t;
1003
+ }
1004
+ function P(e, n) {
1005
+ let t = Date.now();
1006
+ try {
1007
+ return n();
1008
+ } finally {
1009
+ console.log(e + " time: " + (Date.now() - t) + "ms");
1010
+ }
1011
+ }
1012
+ function M(e, n) {
1013
+ return n();
1014
+ }
1015
+ var An = 0;
1016
+ function j(e) {
1017
+ let n = ++An;
1018
+ return e + ("" + n);
1019
+ }
1020
+ function k(e, n, t = 1) {
1021
+ n == null && (n = e, e = 0);
1022
+ let r = (i) => i < n;
1023
+ t < 0 && (r = (i) => n < i);
1024
+ let o = [];
1025
+ for (let i = e; r(i); i += t) o.push(i);
1026
+ return o;
1027
+ }
1028
+ function T(e, n) {
1029
+ let t = {};
1030
+ for (let r of n) e[r] !== void 0 && (t[r] = e[r]);
1031
+ return t;
1032
+ }
1033
+ function O(e, n) {
1034
+ let t;
1035
+ return typeof n == "string" ? t = (r) => r[n] : t = n, Object.entries(e).reduce((r, [o, i]) => (r[o] = t(i, o), r), {});
1036
+ }
1037
+ function Re(e, n) {
1038
+ return e.reduce((t, r, o) => (t[r] = n[o], t), {});
1039
+ }
1040
+ var _ = "\0";
1041
+ var U = "3.0.0";
1042
+ var K = class {
1043
+ constructor() {
1044
+ pe(this, "_sentinel");
1045
+ let n = {};
1046
+ n._next = n._prev = n, this._sentinel = n;
1047
+ }
1048
+ dequeue() {
1049
+ let n = this._sentinel, t = n._prev;
1050
+ if (t !== n) return Pe(t), t;
1051
+ }
1052
+ enqueue(n) {
1053
+ let t = this._sentinel;
1054
+ n._prev && n._next && Pe(n), n._next = t._next, t._next._prev = n, t._next = n, n._prev = t;
1055
+ }
1056
+ toString() {
1057
+ let n = [], t = this._sentinel, r = t._prev;
1058
+ for (; r !== t; ) n.push(JSON.stringify(r, Vn)), r = r._prev;
1059
+ return "[" + n.join(", ") + "]";
1060
+ }
1061
+ };
1062
+ function Pe(e) {
1063
+ e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
1064
+ }
1065
+ function Vn(e, n) {
1066
+ if (e !== "_next" && e !== "_prev") return n;
1067
+ }
1068
+ var Me = K;
1069
+ var Wn = () => 1;
1070
+ function Q(e, n) {
1071
+ if (e.nodeCount() <= 1) return [];
1072
+ let t = Yn(e, n || Wn);
1073
+ return Bn(t.graph, t.buckets, t.zeroIdx).flatMap((o) => e.outEdges(o.v, o.w) || []);
1074
+ }
1075
+ function Bn(e, n, t) {
1076
+ var a;
1077
+ let r = [], o = n[n.length - 1], i = n[0], s;
1078
+ for (; e.nodeCount(); ) {
1079
+ for (; s = i.dequeue(); ) $(e, n, t, s);
1080
+ for (; s = o.dequeue(); ) $(e, n, t, s);
1081
+ if (e.nodeCount()) {
1082
+ for (let d = n.length - 2; d > 0; --d) if (s = (a = n[d]) == null ? void 0 : a.dequeue(), s) {
1083
+ r = r.concat($(e, n, t, s, true) || []);
1084
+ break;
1085
+ }
1086
+ }
1087
+ }
1088
+ return r;
1089
+ }
1090
+ function $(e, n, t, r, o) {
1091
+ let i = [], s = o ? i : void 0;
1092
+ return (e.inEdges(r.v) || []).forEach((a) => {
1093
+ let d = e.edge(a), l = e.node(a.v);
1094
+ o && i.push({ v: a.v, w: a.w }), l.out -= d, J(n, t, l);
1095
+ }), (e.outEdges(r.v) || []).forEach((a) => {
1096
+ let d = e.edge(a), l = a.w, u = e.node(l);
1097
+ u.in -= d, J(n, t, u);
1098
+ }), e.removeNode(r.v), s;
1099
+ }
1100
+ function Yn(e, n) {
1101
+ let t = new p(), r = 0, o = 0;
1102
+ e.nodes().forEach((a) => {
1103
+ t.setNode(a, { v: a, in: 0, out: 0 });
1104
+ }), e.edges().forEach((a) => {
1105
+ let d = t.edge(a.v, a.w) || 0, l = n(a), u = d + l;
1106
+ t.setEdge(a.v, a.w, u);
1107
+ let c = t.node(a.v), h = t.node(a.w);
1108
+ o = Math.max(o, c.out += l), r = Math.max(r, h.in += l);
1109
+ });
1110
+ let i = zn(o + r + 3).map(() => new Me()), s = r + 1;
1111
+ return t.nodes().forEach((a) => {
1112
+ J(i, s, t.node(a));
1113
+ }), { graph: t, buckets: i, zeroIdx: s };
1114
+ }
1115
+ function J(e, n, t) {
1116
+ var r, o, i;
1117
+ t.out ? t.in ? (i = e[t.out - t.in + n]) == null || i.enqueue(t) : (o = e[e.length - 1]) == null || o.enqueue(t) : (r = e[0]) == null || r.enqueue(t);
1118
+ }
1119
+ function zn(e) {
1120
+ let n = [];
1121
+ for (let t = 0; t < e; t++) n.push(t);
1122
+ return n;
1123
+ }
1124
+ function je(e) {
1125
+ (e.graph().acyclicer === "greedy" ? Q(e, t(e)) : Hn(e)).forEach((r) => {
1126
+ let o = e.edge(r);
1127
+ e.removeEdge(r), o.forwardName = r.name, o.reversed = true, e.setEdge(r.w, r.v, o, j("rev"));
1128
+ });
1129
+ function t(r) {
1130
+ return (o) => r.edge(o).weight;
1131
+ }
1132
+ }
1133
+ function Hn(e) {
1134
+ let n = [], t = {}, r = {};
1135
+ function o(i) {
1136
+ Object.hasOwn(r, i) || (r[i] = true, t[i] = true, e.outEdges(i).forEach((s) => {
1137
+ Object.hasOwn(t, s.w) ? n.push(s) : o(s.w);
1138
+ }), delete t[i]);
1139
+ }
1140
+ return e.nodes().forEach(o), n;
1141
+ }
1142
+ function Se(e) {
1143
+ e.edges().forEach((n) => {
1144
+ let t = e.edge(n);
1145
+ if (t.reversed) {
1146
+ e.removeEdge(n);
1147
+ let r = t.forwardName;
1148
+ delete t.reversed, delete t.forwardName, e.setEdge(n.w, n.v, t, r);
1149
+ }
1150
+ });
1151
+ }
1152
+ function Fe(e) {
1153
+ e.graph().dummyChains = [], e.edges().forEach((n) => Xn(e, n));
1154
+ }
1155
+ function Xn(e, n) {
1156
+ let t = n.v, r = e.node(t).rank, o = n.w, i = e.node(o).rank, s = n.name, a = e.edge(n), d = a.labelRank;
1157
+ if (i === r + 1) return;
1158
+ e.removeEdge(n);
1159
+ let l, u, c;
1160
+ for (c = 0, ++r; r < i; ++c, ++r) a.points = [], u = { width: 0, height: 0, edgeLabel: a, edgeObj: n, rank: r }, l = w(e, "edge", u, "_d"), r === d && (u.width = a.width, u.height = a.height, u.dummy = "edge-label", u.labelpos = a.labelpos), e.setEdge(t, l, { weight: a.weight }, s), c === 0 && e.graph().dummyChains.push(l), t = l;
1161
+ e.setEdge(t, o, { weight: a.weight }, s);
1162
+ }
1163
+ function De(e) {
1164
+ e.graph().dummyChains.forEach((n) => {
1165
+ let t = e.node(n), r = t.edgeLabel, o;
1166
+ for (e.setEdge(t.edgeObj, r); t.dummy; ) o = e.successors(n)[0], e.removeNode(n), r.points.push({ x: t.x, y: t.y }), t.dummy === "edge-label" && (r.x = t.x, r.y = t.y, r.width = t.width, r.height = t.height), n = o, t = e.node(n);
1167
+ });
1168
+ }
1169
+ function S(e) {
1170
+ let n = {};
1171
+ function t(r) {
1172
+ let o = e.node(r);
1173
+ if (Object.hasOwn(n, r)) return o.rank;
1174
+ n[r] = true;
1175
+ let i = e.outEdges(r), s = i ? i.map((d) => d == null ? Number.POSITIVE_INFINITY : t(d.w) - e.edge(d).minlen) : [], a = L(Math.min, s);
1176
+ return a === Number.POSITIVE_INFINITY && (a = 0), o.rank = a;
1177
+ }
1178
+ e.sources().forEach(t);
1179
+ }
1180
+ function v(e, n) {
1181
+ return e.node(n.w).rank - e.node(n.v).rank - e.edge(n).minlen;
1182
+ }
1183
+ var V = Kn;
1184
+ function Kn(e) {
1185
+ let n = new p({ directed: false }), t = e.nodes();
1186
+ if (t.length === 0) throw new Error("Graph must have at least one node");
1187
+ let r = t[0], o = e.nodeCount();
1188
+ n.setNode(r, {});
1189
+ let i, s;
1190
+ for (; $n(n, e) < o && (i = Jn(n, e), !!i); ) s = n.hasNode(i.v) ? v(e, i) : -v(e, i), Qn(n, e, s);
1191
+ return n;
1192
+ }
1193
+ function $n(e, n) {
1194
+ function t(r) {
1195
+ let o = n.nodeEdges(r);
1196
+ o && o.forEach((i) => {
1197
+ let s = i.v, a = r === s ? i.w : s;
1198
+ !e.hasNode(a) && !v(n, i) && (e.setNode(a, {}), e.setEdge(r, a, {}), t(a));
1199
+ });
1200
+ }
1201
+ return e.nodes().forEach(t), e.nodeCount();
1202
+ }
1203
+ function Jn(e, n) {
1204
+ return n.edges().reduce((r, o) => {
1205
+ let i = Number.POSITIVE_INFINITY;
1206
+ return e.hasNode(o.v) !== e.hasNode(o.w) && (i = v(n, o)), i < r[0] ? [i, o] : r;
1207
+ }, [Number.POSITIVE_INFINITY, null])[1];
1208
+ }
1209
+ function Qn(e, n, t) {
1210
+ e.nodes().forEach((r) => n.node(r).rank += t);
1211
+ }
1212
+ var { preorder: Zn, postorder: et } = R;
1213
+ var Ve = x;
1214
+ x.initLowLimValues = ee;
1215
+ x.initCutValues = Z;
1216
+ x.calcCutValue = We;
1217
+ x.leaveEdge = Ye;
1218
+ x.enterEdge = ze;
1219
+ x.exchangeEdges = He;
1220
+ function x(e) {
1221
+ e = xe(e), S(e);
1222
+ let n = V(e);
1223
+ ee(n), Z(n, e);
1224
+ let t, r;
1225
+ for (; t = Ye(n); ) r = ze(n, e, t), He(n, e, t, r);
1226
+ }
1227
+ function Z(e, n) {
1228
+ let t = et(e, e.nodes());
1229
+ t = t.slice(0, t.length - 1), t.forEach((r) => nt(e, n, r));
1230
+ }
1231
+ function nt(e, n, t) {
1232
+ let o = e.node(t).parent, i = e.edge(t, o);
1233
+ i.cutvalue = We(e, n, t);
1234
+ }
1235
+ function We(e, n, t) {
1236
+ let o = e.node(t).parent, i = true, s = n.edge(t, o), a = 0;
1237
+ s || (i = false, s = n.edge(o, t)), a = s.weight;
1238
+ let d = n.nodeEdges(t);
1239
+ return d && d.forEach((l) => {
1240
+ let u = l.v === t, c = u ? l.w : l.v;
1241
+ if (c !== o) {
1242
+ let h = u === i, f = n.edge(l).weight;
1243
+ if (a += h ? f : -f, rt(e, t, c)) {
1244
+ let b = e.edge(t, c).cutvalue;
1245
+ a += h ? -b : b;
1246
+ }
1247
+ }
1248
+ }), a;
1249
+ }
1250
+ function ee(e, n) {
1251
+ arguments.length < 2 && (n = e.nodes()[0]), Be(e, {}, 1, n);
1252
+ }
1253
+ function Be(e, n, t, r, o) {
1254
+ let i = t, s = e.node(r);
1255
+ n[r] = true;
1256
+ let a = e.neighbors(r);
1257
+ return a && a.forEach((d) => {
1258
+ Object.hasOwn(n, d) || (t = Be(e, n, t, d, r));
1259
+ }), s.low = i, s.lim = t++, o ? s.parent = o : delete s.parent, t;
1260
+ }
1261
+ function Ye(e) {
1262
+ return e.edges().find((n) => e.edge(n).cutvalue < 0);
1263
+ }
1264
+ function ze(e, n, t) {
1265
+ let r = t.v, o = t.w;
1266
+ n.hasEdge(r, o) || (r = t.w, o = t.v);
1267
+ let i = e.node(r), s = e.node(o), a = i, d = false;
1268
+ return i.lim > s.lim && (a = s, d = true), n.edges().filter((u) => d === Ae(e, e.node(u.v), a) && d !== Ae(e, e.node(u.w), a)).reduce((u, c) => v(n, c) < v(n, u) ? c : u);
1269
+ }
1270
+ function He(e, n, t, r) {
1271
+ let o = t.v, i = t.w;
1272
+ e.removeEdge(o, i), e.setEdge(r.v, r.w, {}), ee(e), Z(e, n), tt(e, n);
1273
+ }
1274
+ function tt(e, n) {
1275
+ let t = e.nodes().find((o) => !e.node(o).parent);
1276
+ if (!t) return;
1277
+ let r = Zn(e, [t]);
1278
+ r = r.slice(1), r.forEach((o) => {
1279
+ let s = e.node(o).parent, a = n.edge(o, s), d = false;
1280
+ a || (a = n.edge(s, o), d = true), n.node(o).rank = n.node(s).rank + (d ? a.minlen : -a.minlen);
1281
+ });
1282
+ }
1283
+ function rt(e, n, t) {
1284
+ return e.hasEdge(n, t);
1285
+ }
1286
+ function Ae(e, n, t) {
1287
+ return t.low <= n.lim && n.lim <= t.lim;
1288
+ }
1289
+ var Xe = ot;
1290
+ function ot(e) {
1291
+ let n = e.graph().ranker;
1292
+ if (typeof n == "function") return n(e);
1293
+ switch (n) {
1294
+ case "network-simplex":
1295
+ qe(e);
1296
+ break;
1297
+ case "tight-tree":
1298
+ st(e);
1299
+ break;
1300
+ case "longest-path":
1301
+ it(e);
1302
+ break;
1303
+ case "none":
1304
+ break;
1305
+ default:
1306
+ qe(e);
1307
+ }
1308
+ }
1309
+ var it = S;
1310
+ function st(e) {
1311
+ S(e), V(e);
1312
+ }
1313
+ function qe(e) {
1314
+ Ve(e);
1315
+ }
1316
+ var Ue = at;
1317
+ function at(e) {
1318
+ let n = lt(e);
1319
+ e.graph().dummyChains.forEach((t) => {
1320
+ let r = e.node(t), o = r.edgeObj, i = dt(e, n, o.v, o.w), s = i.path, a = i.lca, d = 0, l = s[d], u = true;
1321
+ for (; t !== o.w; ) {
1322
+ if (r = e.node(t), u) {
1323
+ for (; (l = s[d]) !== a && e.node(l).maxRank < r.rank; ) d++;
1324
+ l === a && (u = false);
1325
+ }
1326
+ if (!u) {
1327
+ for (; d < s.length - 1 && e.node(s[d + 1]).minRank <= r.rank; ) d++;
1328
+ l = s[d];
1329
+ }
1330
+ l !== void 0 && e.setParent(t, l), t = e.successors(t)[0];
1331
+ }
1332
+ });
1333
+ }
1334
+ function dt(e, n, t, r) {
1335
+ let o = [], i = [], s = Math.min(n[t].low, n[r].low), a = Math.max(n[t].lim, n[r].lim), d;
1336
+ d = t;
1337
+ do
1338
+ d = e.parent(d), o.push(d);
1339
+ while (d && (n[d].low > s || a > n[d].lim));
1340
+ let l = d, u = r;
1341
+ for (; (u = e.parent(u)) !== l; ) i.push(u);
1342
+ return { path: o.concat(i.reverse()), lca: l };
1343
+ }
1344
+ function lt(e) {
1345
+ let n = {}, t = 0;
1346
+ function r(o) {
1347
+ let i = t;
1348
+ e.children(o).forEach(r), n[o] = { low: i, lim: t++ };
1349
+ }
1350
+ return e.children(_).forEach(r), n;
1351
+ }
1352
+ function Ke(e) {
1353
+ let n = w(e, "root", {}, "_root"), t = ut(e), r = Object.values(t), o = L(Math.max, r) - 1, i = 2 * o + 1;
1354
+ e.graph().nestingRoot = n, e.edges().forEach((a) => e.edge(a).minlen *= i);
1355
+ let s = ct(e) + 1;
1356
+ e.children(_).forEach((a) => $e(e, n, i, s, o, t, a)), e.graph().nodeRankFactor = i;
1357
+ }
1358
+ function $e(e, n, t, r, o, i, s) {
1359
+ var c;
1360
+ let a = e.children(s);
1361
+ if (!a.length) {
1362
+ s !== n && e.setEdge(n, s, { weight: 0, minlen: t });
1363
+ return;
1364
+ }
1365
+ let d = q(e, "_bt"), l = q(e, "_bb"), u = e.node(s);
1366
+ e.setParent(d, s), u.borderTop = d, e.setParent(l, s), u.borderBottom = l, a.forEach((h) => {
1367
+ var y;
1368
+ $e(e, n, t, r, o, i, h);
1369
+ let f = e.node(h), g = f.borderTop ? f.borderTop : h, b = f.borderBottom ? f.borderBottom : h, m = f.borderTop ? r : 2 * r, E = g !== b ? 1 : o - ((y = i[s]) != null ? y : 0) + 1;
1370
+ e.setEdge(d, g, { weight: m, minlen: E, nestingEdge: true }), e.setEdge(b, l, { weight: m, minlen: E, nestingEdge: true });
1371
+ }), e.parent(s) || e.setEdge(n, d, { weight: 0, minlen: o + ((c = i[s]) != null ? c : 0) });
1372
+ }
1373
+ function ut(e) {
1374
+ let n = {};
1375
+ function t(r, o) {
1376
+ let i = e.children(r);
1377
+ i && i.length && i.forEach((s) => t(s, o + 1)), n[r] = o;
1378
+ }
1379
+ return e.children(_).forEach((r) => t(r, 1)), n;
1380
+ }
1381
+ function ct(e) {
1382
+ return e.edges().reduce((n, t) => n + e.edge(t).weight, 0);
1383
+ }
1384
+ function Je(e) {
1385
+ let n = e.graph();
1386
+ e.removeNode(n.nestingRoot), delete n.nestingRoot, e.edges().forEach((t) => {
1387
+ e.edge(t).nestingEdge && e.removeEdge(t);
1388
+ });
1389
+ }
1390
+ var Ze = ft;
1391
+ function ft(e) {
1392
+ function n(t) {
1393
+ let r = e.children(t), o = e.node(t);
1394
+ if (r.length && r.forEach(n), Object.hasOwn(o, "minRank")) {
1395
+ o.borderLeft = [], o.borderRight = [];
1396
+ for (let i = o.minRank, s = o.maxRank + 1; i < s; ++i) Qe(e, "borderLeft", "_bl", t, o, i), Qe(e, "borderRight", "_br", t, o, i);
1397
+ }
1398
+ }
1399
+ e.children(_).forEach(n);
1400
+ }
1401
+ function Qe(e, n, t, r, o, i) {
1402
+ let s = { width: 0, height: 0, rank: i, borderType: n }, a = o[n][i - 1], d = w(e, "border", s, t);
1403
+ o[n][i] = d, e.setParent(d, r), a && e.setEdge(a, d, { weight: 1 });
1404
+ }
1405
+ function nn(e) {
1406
+ var t;
1407
+ let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
1408
+ (n === "lr" || n === "rl") && rn(e);
1409
+ }
1410
+ function tn(e) {
1411
+ var t;
1412
+ let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
1413
+ (n === "bt" || n === "rl") && bt(e), (n === "lr" || n === "rl") && (gt(e), rn(e));
1414
+ }
1415
+ function rn(e) {
1416
+ e.nodes().forEach((n) => en(e.node(n))), e.edges().forEach((n) => en(e.edge(n)));
1417
+ }
1418
+ function en(e) {
1419
+ let n = e.width;
1420
+ e.width = e.height, e.height = n;
1421
+ }
1422
+ function bt(e) {
1423
+ e.nodes().forEach((n) => ne(e.node(n))), e.edges().forEach((n) => {
1424
+ var r;
1425
+ let t = e.edge(n);
1426
+ (r = t.points) == null || r.forEach(ne), Object.hasOwn(t, "y") && ne(t);
1427
+ });
1428
+ }
1429
+ function ne(e) {
1430
+ e.y = -e.y;
1431
+ }
1432
+ function gt(e) {
1433
+ e.nodes().forEach((n) => te(e.node(n))), e.edges().forEach((n) => {
1434
+ var r;
1435
+ let t = e.edge(n);
1436
+ (r = t.points) == null || r.forEach(te), Object.hasOwn(t, "x") && te(t);
1437
+ });
1438
+ }
1439
+ function te(e) {
1440
+ let n = e.x;
1441
+ e.x = e.y, e.y = n;
1442
+ }
1443
+ function re(e) {
1444
+ let n = {}, t = e.nodes().filter((d) => !e.children(d).length), r = t.map((d) => e.node(d).rank), o = L(Math.max, r), i = k(o + 1).map(() => []);
1445
+ function s(d) {
1446
+ if (n[d]) return;
1447
+ n[d] = true;
1448
+ let l = e.node(d);
1449
+ i[l.rank].push(d);
1450
+ let u = e.successors(d);
1451
+ u && u.forEach(s);
1452
+ }
1453
+ return t.sort((d, l) => e.node(d).rank - e.node(l).rank).forEach(s), i;
1454
+ }
1455
+ function oe(e, n) {
1456
+ let t = 0;
1457
+ for (let r = 1; r < n.length; ++r) t += mt(e, n[r - 1], n[r]);
1458
+ return t;
1459
+ }
1460
+ function mt(e, n, t) {
1461
+ let r = Re(t, t.map((l, u) => u)), o = n.flatMap((l) => {
1462
+ let u = e.outEdges(l);
1463
+ return u ? u.map((c) => ({ pos: r[c.w], weight: e.edge(c).weight })).sort((c, h) => c.pos - h.pos) : [];
1464
+ }), i = 1;
1465
+ for (; i < t.length; ) i <<= 1;
1466
+ let s = 2 * i - 1;
1467
+ i -= 1;
1468
+ let a = new Array(s).fill(0), d = 0;
1469
+ return o.forEach((l) => {
1470
+ let u = l.pos + i;
1471
+ a[u] += l.weight;
1472
+ let c = 0;
1473
+ for (; u > 0; ) u % 2 && (c += a[u + 1]), u = u - 1 >> 1, a[u] += l.weight;
1474
+ d += l.weight * c;
1475
+ }), d;
1476
+ }
1477
+ function ie(e, n = []) {
1478
+ return n.map((t) => {
1479
+ let r = e.inEdges(t);
1480
+ if (!r || !r.length) return { v: t };
1481
+ {
1482
+ let o = r.reduce((i, s) => {
1483
+ let a = e.edge(s), d = e.node(s.v);
1484
+ return { sum: i.sum + a.weight * d.order, weight: i.weight + a.weight };
1485
+ }, { sum: 0, weight: 0 });
1486
+ return { v: t, barycenter: o.sum / o.weight, weight: o.weight };
1487
+ }
1488
+ });
1489
+ }
1490
+ function se(e, n) {
1491
+ let t = {};
1492
+ e.forEach((o, i) => {
1493
+ let s = { indegree: 0, in: [], out: [], vs: [o.v], i };
1494
+ o.barycenter !== void 0 && (s.barycenter = o.barycenter, s.weight = o.weight), t[o.v] = s;
1495
+ }), n.edges().forEach((o) => {
1496
+ let i = t[o.v], s = t[o.w];
1497
+ i !== void 0 && s !== void 0 && (s.indegree++, i.out.push(s));
1498
+ });
1499
+ let r = Object.values(t).filter((o) => !o.indegree);
1500
+ return Et(r);
1501
+ }
1502
+ function Et(e) {
1503
+ let n = [];
1504
+ function t(o) {
1505
+ return (i) => {
1506
+ i.merged || (i.barycenter === void 0 || o.barycenter === void 0 || i.barycenter >= o.barycenter) && Lt(o, i);
1507
+ };
1508
+ }
1509
+ function r(o) {
1510
+ return (i) => {
1511
+ i.in.push(o), --i.indegree === 0 && e.push(i);
1512
+ };
1513
+ }
1514
+ for (; e.length; ) {
1515
+ let o = e.pop();
1516
+ n.push(o), o.in.reverse().forEach(t(o)), o.out.forEach(r(o));
1517
+ }
1518
+ return n.filter((o) => !o.merged).map((o) => T(o, ["vs", "i", "barycenter", "weight"]));
1519
+ }
1520
+ function Lt(e, n) {
1521
+ let t = 0, r = 0;
1522
+ e.weight && (t += e.barycenter * e.weight, r += e.weight), n.weight && (t += n.barycenter * n.weight, r += n.weight), e.vs = n.vs.concat(e.vs), e.barycenter = t / r, e.weight = r, e.i = Math.min(n.i, e.i), n.merged = true;
1523
+ }
1524
+ function ae(e, n) {
1525
+ let t = Ce(e, (u) => Object.hasOwn(u, "barycenter")), r = t.lhs, o = t.rhs.sort((u, c) => c.i - u.i), i = [], s = 0, a = 0, d = 0;
1526
+ r.sort(yt(!!n)), d = on(i, o, d), r.forEach((u) => {
1527
+ d += u.vs.length, i.push(u.vs), s += u.barycenter * u.weight, a += u.weight, d = on(i, o, d);
1528
+ });
1529
+ let l = { vs: i.flat(1) };
1530
+ return a && (l.barycenter = s / a, l.weight = a), l;
1531
+ }
1532
+ function on(e, n, t) {
1533
+ let r;
1534
+ for (; n.length && (r = n[n.length - 1]).i <= t; ) n.pop(), e.push(r.vs), t++;
1535
+ return t;
1536
+ }
1537
+ function yt(e) {
1538
+ return (n, t) => n.barycenter < t.barycenter ? -1 : n.barycenter > t.barycenter ? 1 : e ? t.i - n.i : n.i - t.i;
1539
+ }
1540
+ function W(e, n, t, r) {
1541
+ let o = e.children(n), i = e.node(n), s = i ? i.borderLeft : void 0, a = i ? i.borderRight : void 0, d = {};
1542
+ s && (o = o.filter((h) => h !== s && h !== a));
1543
+ let l = ie(e, o);
1544
+ l.forEach((h) => {
1545
+ if (e.children(h.v).length) {
1546
+ let f = W(e, h.v, t, r);
1547
+ d[h.v] = f, Object.hasOwn(f, "barycenter") && Nt(h, f);
1548
+ }
1549
+ });
1550
+ let u = se(l, t);
1551
+ wt(u, d);
1552
+ let c = ae(u, r);
1553
+ if (s && a) {
1554
+ c.vs = [s, c.vs, a].flat(1);
1555
+ let h = e.predecessors(s);
1556
+ if (h && h.length) {
1557
+ let f = e.node(h[0]), g = e.predecessors(a), b = e.node(g[0]);
1558
+ Object.hasOwn(c, "barycenter") || (c.barycenter = 0, c.weight = 0), c.barycenter = (c.barycenter * c.weight + f.order + b.order) / (c.weight + 2), c.weight += 2;
1559
+ }
1560
+ }
1561
+ return c;
1562
+ }
1563
+ function wt(e, n) {
1564
+ e.forEach((t) => {
1565
+ t.vs = t.vs.flatMap((r) => n[r] ? n[r].vs : r);
1566
+ });
1567
+ }
1568
+ function Nt(e, n) {
1569
+ e.barycenter !== void 0 ? (e.barycenter = (e.barycenter * e.weight + n.barycenter * n.weight) / (e.weight + n.weight), e.weight += n.weight) : (e.barycenter = n.barycenter, e.weight = n.weight);
1570
+ }
1571
+ function de(e, n, t, r) {
1572
+ r || (r = e.nodes());
1573
+ let o = Gt(e), i = new p({ compound: true }).setGraph({ root: o }).setDefaultNodeLabel((s) => e.node(s));
1574
+ return r.forEach((s) => {
1575
+ let a = e.node(s), d = e.parent(s);
1576
+ if (a.rank === n || a.minRank <= n && n <= a.maxRank) {
1577
+ i.setNode(s), i.setParent(s, d || o);
1578
+ let l = e[t](s);
1579
+ l && l.forEach((u) => {
1580
+ let c = u.v === s ? u.w : u.v, h = i.edge(c, s), f = h !== void 0 ? h.weight : 0;
1581
+ i.setEdge(c, s, { weight: e.edge(u).weight + f });
1582
+ }), Object.hasOwn(a, "minRank") && i.setNode(s, { borderLeft: a.borderLeft[n], borderRight: a.borderRight[n] });
1583
+ }
1584
+ }), i;
1585
+ }
1586
+ function Gt(e) {
1587
+ let n;
1588
+ for (; e.hasNode(n = j("_root")); ) ;
1589
+ return n;
1590
+ }
1591
+ function le(e, n, t) {
1592
+ let r = {}, o;
1593
+ t.forEach((i) => {
1594
+ let s = e.parent(i), a, d;
1595
+ for (; s; ) {
1596
+ if (a = e.parent(s), a ? (d = r[a], r[a] = s) : (d = o, o = s), d && d !== s) {
1597
+ n.setEdge(d, s);
1598
+ return;
1599
+ }
1600
+ s = a;
1601
+ }
1602
+ });
1603
+ }
1604
+ function B(e, n = {}) {
1605
+ if (typeof n.customOrder == "function") {
1606
+ n.customOrder(e, B);
1607
+ return;
1608
+ }
1609
+ let t = X(e), r = sn(e, k(1, t + 1), "inEdges"), o = sn(e, k(t - 1, -1, -1), "outEdges"), i = re(e);
1610
+ if (an(e, i), n.disableOptimalOrderHeuristic) return;
1611
+ let s = Number.POSITIVE_INFINITY, a, d = n.constraints || [];
1612
+ for (let l = 0, u = 0; u < 4; ++l, ++u) {
1613
+ kt(l % 2 ? r : o, l % 4 >= 2, d), i = N(e);
1614
+ let c = oe(e, i);
1615
+ c < s ? (u = 0, a = Object.assign({}, i), s = c) : c === s && (a = structuredClone(i));
1616
+ }
1617
+ an(e, a);
1618
+ }
1619
+ function sn(e, n, t) {
1620
+ let r = /* @__PURE__ */ new Map(), o = (i, s) => {
1621
+ r.has(i) || r.set(i, []), r.get(i).push(s);
1622
+ };
1623
+ for (let i of e.nodes()) {
1624
+ let s = e.node(i);
1625
+ if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let a = s.minRank; a <= s.maxRank; a++) a !== s.rank && o(a, i);
1626
+ }
1627
+ return n.map(function(i) {
1628
+ return de(e, i, t, r.get(i) || []);
1629
+ });
1630
+ }
1631
+ function kt(e, n, t) {
1632
+ let r = new p();
1633
+ e.forEach(function(o) {
1634
+ t.forEach((a) => r.setEdge(a.left, a.right));
1635
+ let i = o.graph().root, s = W(o, i, r, n);
1636
+ s.vs.forEach((a, d) => o.node(a).order = d), le(o, r, s.vs);
1637
+ });
1638
+ }
1639
+ function an(e, n) {
1640
+ Object.values(n).forEach((t) => t.forEach((r, o) => e.node(r).order = o));
1641
+ }
1642
+ function vt(e, n) {
1643
+ let t = {};
1644
+ function r(o, i) {
1645
+ let s = 0, a = 0, d = o.length, l = i[i.length - 1];
1646
+ return i.forEach((u, c) => {
1647
+ let h = xt(e, u), f = h ? e.node(h).order : d;
1648
+ (h || u === l) && (i.slice(a, c + 1).forEach((g) => {
1649
+ let b = e.predecessors(g);
1650
+ b && b.forEach((m) => {
1651
+ let E = e.node(m), y = E.order;
1652
+ (y < s || f < y) && !(E.dummy && e.node(g).dummy) && dn(t, m, g);
1653
+ });
1654
+ }), a = c + 1, s = f);
1655
+ }), i;
1656
+ }
1657
+ return n.length && n.reduce(r), t;
1658
+ }
1659
+ function _t(e, n) {
1660
+ let t = {};
1661
+ function r(i, s, a, d, l) {
1662
+ k(s, a).forEach((u) => {
1663
+ let c = i[u];
1664
+ if (c !== void 0 && e.node(c).dummy) {
1665
+ let h = e.predecessors(c);
1666
+ h && h.forEach((f) => {
1667
+ if (f === void 0) return;
1668
+ let g = e.node(f);
1669
+ g.dummy && (g.order < d || g.order > l) && dn(t, f, c);
1670
+ });
1671
+ }
1672
+ });
1673
+ }
1674
+ function o(i, s) {
1675
+ let a = -1, d = -1, l = 0;
1676
+ return s.forEach((u, c) => {
1677
+ if (e.node(u).dummy === "border") {
1678
+ let h = e.predecessors(u);
1679
+ if (h && h.length) {
1680
+ let f = h[0];
1681
+ if (f === void 0) return;
1682
+ d = e.node(f).order, r(s, l, c, a, d), l = c, a = d;
1683
+ }
1684
+ }
1685
+ r(s, l, s.length, d, i.length);
1686
+ }), s;
1687
+ }
1688
+ return n.length && n.reduce(o), t;
1689
+ }
1690
+ function xt(e, n) {
1691
+ if (e.node(n).dummy) {
1692
+ let t = e.predecessors(n);
1693
+ if (t) return t.find((r) => e.node(r).dummy);
1694
+ }
1695
+ }
1696
+ function dn(e, n, t) {
1697
+ if (n > t) {
1698
+ let o = n;
1699
+ n = t, t = o;
1700
+ }
1701
+ let r = e[n];
1702
+ r || (e[n] = r = {}), r[t] = true;
1703
+ }
1704
+ function Tt(e, n, t) {
1705
+ if (n > t) {
1706
+ let o = n;
1707
+ n = t, t = o;
1708
+ }
1709
+ let r = e[n];
1710
+ return r !== void 0 && Object.hasOwn(r, t);
1711
+ }
1712
+ function Ot(e, n, t, r) {
1713
+ let o = {}, i = {}, s = {};
1714
+ return n.forEach((a) => {
1715
+ a.forEach((d, l) => {
1716
+ o[d] = d, i[d] = d, s[d] = l;
1717
+ });
1718
+ }), n.forEach((a) => {
1719
+ let d = -1;
1720
+ a.forEach((l) => {
1721
+ let u = r(l);
1722
+ if (u && u.length) {
1723
+ let c = u.sort((f, g) => {
1724
+ let b = s[f], m = s[g];
1725
+ return (b !== void 0 ? b : 0) - (m !== void 0 ? m : 0);
1726
+ }), h = (c.length - 1) / 2;
1727
+ for (let f = Math.floor(h), g = Math.ceil(h); f <= g; ++f) {
1728
+ let b = c[f];
1729
+ if (b === void 0) continue;
1730
+ let m = s[b];
1731
+ if (m !== void 0 && i[l] === l && d < m && !Tt(t, l, b)) {
1732
+ let E = o[b];
1733
+ E !== void 0 && (i[b] = l, i[l] = o[l] = E, d = m);
1734
+ }
1735
+ }
1736
+ }
1737
+ });
1738
+ }), { root: o, align: i };
1739
+ }
1740
+ function It(e, n, t, r, o = false) {
1741
+ let i = {}, s = Ct(e, n, t, o), a = o ? "borderLeft" : "borderRight";
1742
+ function d(f, g) {
1743
+ let b = s.nodes().slice(), m = {}, E = b.pop();
1744
+ for (; E; ) {
1745
+ if (m[E]) f(E);
1746
+ else {
1747
+ m[E] = true, b.push(E);
1748
+ for (let y of g(E)) b.push(y);
1749
+ }
1750
+ E = b.pop();
1751
+ }
1752
+ }
1753
+ function l(f) {
1754
+ let g = s.inEdges(f);
1755
+ g ? i[f] = g.reduce((b, m) => {
1756
+ var I;
1757
+ let E = (I = i[m.v]) != null ? I : 0, y = s.edge(m);
1758
+ return Math.max(b, E + (y !== void 0 ? y : 0));
1759
+ }, 0) : i[f] = 0;
1760
+ }
1761
+ function u(f) {
1762
+ let g = s.outEdges(f), b = Number.POSITIVE_INFINITY;
1763
+ g && (b = g.reduce((E, y) => {
1764
+ let I = i[y.w], be = s.edge(y);
1765
+ return Math.min(E, (I !== void 0 ? I : 0) - (be !== void 0 ? be : 0));
1766
+ }, Number.POSITIVE_INFINITY));
1767
+ let m = e.node(f);
1768
+ b !== Number.POSITIVE_INFINITY && m.borderType !== a && (i[f] = Math.max(i[f] !== void 0 ? i[f] : 0, b));
1769
+ }
1770
+ function c(f) {
1771
+ return s.predecessors(f) || [];
1772
+ }
1773
+ function h(f) {
1774
+ return s.successors(f) || [];
1775
+ }
1776
+ return d(l, c), d(u, h), Object.keys(r).forEach((f) => {
1777
+ var b;
1778
+ let g = t[f];
1779
+ g !== void 0 && (i[f] = (b = i[g]) != null ? b : 0);
1780
+ }), i;
1781
+ }
1782
+ function Ct(e, n, t, r) {
1783
+ let o = new p(), i = e.graph(), s = jt(i.nodesep, i.edgesep, r);
1784
+ return n.forEach((a) => {
1785
+ let d;
1786
+ a.forEach((l) => {
1787
+ let u = t[l];
1788
+ if (u !== void 0) {
1789
+ if (o.setNode(u), d !== void 0) {
1790
+ let c = t[d];
1791
+ if (c !== void 0) {
1792
+ let h = o.edge(c, u);
1793
+ o.setEdge(c, u, Math.max(s(e, l, d), h || 0));
1794
+ }
1795
+ }
1796
+ d = l;
1797
+ }
1798
+ });
1799
+ }), o;
1800
+ }
1801
+ function Rt(e, n) {
1802
+ return Object.values(n).reduce((t, r) => {
1803
+ let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
1804
+ Object.entries(r).forEach(([a, d]) => {
1805
+ let l = St(e, a) / 2;
1806
+ o = Math.max(d + l, o), i = Math.min(d - l, i);
1807
+ });
1808
+ let s = o - i;
1809
+ return s < t[0] && (t = [s, r]), t;
1810
+ }, [Number.POSITIVE_INFINITY, null])[1];
1811
+ }
1812
+ function Pt(e, n) {
1813
+ let t = Object.values(n), r = L(Math.min, t), o = L(Math.max, t);
1814
+ ["u", "d"].forEach((i) => {
1815
+ ["l", "r"].forEach((s) => {
1816
+ let a = i + s, d = e[a];
1817
+ if (!d || d === n) return;
1818
+ let l = Object.values(d), u = r - L(Math.min, l);
1819
+ s !== "l" && (u = o - L(Math.max, l)), u && (e[a] = O(d, (c) => c + u));
1820
+ });
1821
+ });
1822
+ }
1823
+ function Mt(e, n = void 0) {
1824
+ let t = e.ul;
1825
+ return t ? O(t, (r, o) => {
1826
+ var s, a;
1827
+ if (n) {
1828
+ let d = n.toLowerCase(), l = e[d];
1829
+ if (l && l[o] !== void 0) return l[o];
1830
+ }
1831
+ let i = Object.values(e).map((d) => {
1832
+ let l = d[o];
1833
+ return l !== void 0 ? l : 0;
1834
+ }).sort((d, l) => d - l);
1835
+ return (((s = i[1]) != null ? s : 0) + ((a = i[2]) != null ? a : 0)) / 2;
1836
+ }) : {};
1837
+ }
1838
+ function ln(e) {
1839
+ let n = N(e), t = Object.assign(vt(e, n), _t(e, n)), r = {}, o;
1840
+ ["u", "d"].forEach((s) => {
1841
+ o = s === "u" ? n : Object.values(n).reverse(), ["l", "r"].forEach((a) => {
1842
+ a === "r" && (o = o.map((c) => Object.values(c).reverse()));
1843
+ let l = Ot(e, o, t, (c) => (s === "u" ? e.predecessors(c) : e.successors(c)) || []), u = It(e, o, l.root, l.align, a === "r");
1844
+ a === "r" && (u = O(u, (c) => -c)), r[s + a] = u;
1845
+ });
1846
+ });
1847
+ let i = Rt(e, r);
1848
+ return Pt(r, i), Mt(r, e.graph().align);
1849
+ }
1850
+ function jt(e, n, t) {
1851
+ return (r, o, i) => {
1852
+ let s = r.node(o), a = r.node(i), d = 0, l;
1853
+ if (d += s.width / 2, Object.hasOwn(s, "labelpos")) switch (s.labelpos.toLowerCase()) {
1854
+ case "l":
1855
+ l = -s.width / 2;
1856
+ break;
1857
+ case "r":
1858
+ l = s.width / 2;
1859
+ break;
1860
+ }
1861
+ if (l && (d += t ? l : -l), l = void 0, d += (s.dummy ? n : e) / 2, d += (a.dummy ? n : e) / 2, d += a.width / 2, Object.hasOwn(a, "labelpos")) switch (a.labelpos.toLowerCase()) {
1862
+ case "l":
1863
+ l = a.width / 2;
1864
+ break;
1865
+ case "r":
1866
+ l = -a.width / 2;
1867
+ break;
1868
+ }
1869
+ return l && (d += t ? l : -l), d;
1870
+ };
1871
+ }
1872
+ function St(e, n) {
1873
+ return e.node(n).width;
1874
+ }
1875
+ function un(e) {
1876
+ e = A(e), Ft(e), Object.entries(ln(e)).forEach(([n, t]) => e.node(n).x = t);
1877
+ }
1878
+ function Ft(e) {
1879
+ let n = N(e), t = e.graph(), r = t.ranksep, o = t.rankalign, i = 0;
1880
+ n.forEach((s) => {
1881
+ let a = s.reduce((d, l) => {
1882
+ var c;
1883
+ let u = (c = e.node(l).height) != null ? c : 0;
1884
+ return d > u ? d : u;
1885
+ }, 0);
1886
+ s.forEach((d) => {
1887
+ let l = e.node(d);
1888
+ o === "top" ? l.y = i + l.height / 2 : o === "bottom" ? l.y = i + a - l.height / 2 : l.y = i + a / 2;
1889
+ }), i += a + r;
1890
+ });
1891
+ }
1892
+ function he(e, n = {}) {
1893
+ let t = n.debugTiming ? P : M;
1894
+ return t("layout", () => {
1895
+ let r = t(" buildLayoutGraph", () => Xt(e));
1896
+ return t(" runLayout", () => Dt(r, t, n)), t(" updateInputGraph", () => At(e, r)), r;
1897
+ });
1898
+ }
1899
+ function Dt(e, n, t) {
1900
+ n(" makeSpaceForEdgeLabels", () => Ut(e)), n(" removeSelfEdges", () => rr(e)), n(" acyclic", () => je(e)), n(" nestingGraph.run", () => Ke(e)), n(" rank", () => Xe(A(e))), n(" injectEdgeLabelProxies", () => Kt(e)), n(" removeEmptyRanks", () => Oe(e)), n(" nestingGraph.cleanup", () => Je(e)), n(" normalizeRanks", () => Te(e)), n(" assignRankMinMax", () => $t(e)), n(" removeEdgeLabelProxies", () => Jt(e)), n(" normalize.run", () => Fe(e)), n(" parentDummyChains", () => Ue(e)), n(" addBorderSegments", () => Ze(e)), n(" order", () => B(e, t)), n(" insertSelfEdges", () => or(e)), n(" adjustCoordinateSystem", () => nn(e)), n(" position", () => un(e)), n(" positionSelfEdges", () => ir(e)), n(" removeBorderNodes", () => tr(e)), n(" normalize.undo", () => De(e)), n(" fixupEdgeLabelCoords", () => er(e)), n(" undoCoordinateSystem", () => tn(e)), n(" translateGraph", () => Qt(e)), n(" assignNodeIntersects", () => Zt(e)), n(" reversePoints", () => nr(e)), n(" acyclic.undo", () => Se(e));
1901
+ }
1902
+ function At(e, n) {
1903
+ e.nodes().forEach((t) => {
1904
+ let r = e.node(t), o = n.node(t);
1905
+ r && (r.x = o.x, r.y = o.y, r.order = o.order, r.rank = o.rank, n.children(t).length && (r.width = o.width, r.height = o.height));
1906
+ }), e.edges().forEach((t) => {
1907
+ let r = e.edge(t), o = n.edge(t);
1908
+ r.points = o.points, Object.hasOwn(o, "x") && (r.x = o.x, r.y = o.y);
1909
+ }), e.graph().width = n.graph().width, e.graph().height = n.graph().height;
1910
+ }
1911
+ var Vt = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
1912
+ var Wt = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "TB", rankalign: "center" };
1913
+ var Bt = ["acyclicer", "ranker", "rankdir", "align", "rankalign"];
1914
+ var Yt = ["width", "height", "rank"];
1915
+ var cn = { width: 0, height: 0 };
1916
+ var zt = ["minlen", "weight", "width", "height", "labeloffset"];
1917
+ var Ht = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" };
1918
+ var qt = ["labelpos"];
1919
+ function Xt(e) {
1920
+ let n = new p({ multigraph: true, compound: true }), t = ce(e.graph());
1921
+ return n.setGraph(Object.assign({}, Wt, ue(t, Vt), T(t, Bt))), e.nodes().forEach((r) => {
1922
+ let o = ce(e.node(r)), i = ue(o, Yt);
1923
+ Object.keys(cn).forEach((a) => {
1924
+ i[a] === void 0 && (i[a] = cn[a]);
1925
+ }), n.setNode(r, i);
1926
+ let s = e.parent(r);
1927
+ s !== void 0 && n.setParent(r, s);
1928
+ }), e.edges().forEach((r) => {
1929
+ let o = ce(e.edge(r));
1930
+ n.setEdge(r, Object.assign({}, Ht, ue(o, zt), T(o, qt)));
1931
+ }), n;
1932
+ }
1933
+ function Ut(e) {
1934
+ let n = e.graph();
1935
+ n.ranksep /= 2, e.edges().forEach((t) => {
1936
+ let r = e.edge(t);
1937
+ r.minlen *= 2, r.labelpos.toLowerCase() !== "c" && (n.rankdir === "TB" || n.rankdir === "BT" ? r.width += r.labeloffset : r.height += r.labeloffset);
1938
+ });
1939
+ }
1940
+ function Kt(e) {
1941
+ e.edges().forEach((n) => {
1942
+ let t = e.edge(n);
1943
+ if (t.width && t.height) {
1944
+ let r = e.node(n.v), i = { rank: (e.node(n.w).rank - r.rank) / 2 + r.rank, e: n };
1945
+ w(e, "edge-proxy", i, "_ep");
1946
+ }
1947
+ });
1948
+ }
1949
+ function $t(e) {
1950
+ let n = 0;
1951
+ e.nodes().forEach((t) => {
1952
+ let r = e.node(t);
1953
+ r.borderTop && (r.minRank = e.node(r.borderTop).rank, r.maxRank = e.node(r.borderBottom).rank, n = Math.max(n, r.maxRank));
1954
+ }), e.graph().maxRank = n;
1955
+ }
1956
+ function Jt(e) {
1957
+ e.nodes().forEach((n) => {
1958
+ let t = e.node(n);
1959
+ if (t.dummy === "edge-proxy") {
1960
+ let r = t;
1961
+ e.edge(r.e).labelRank = t.rank, e.removeNode(n);
1962
+ }
1963
+ });
1964
+ }
1965
+ function Qt(e) {
1966
+ let n = Number.POSITIVE_INFINITY, t = 0, r = Number.POSITIVE_INFINITY, o = 0, i = e.graph(), s = i.marginx || 0, a = i.marginy || 0;
1967
+ function d(l) {
1968
+ let u = l.x, c = l.y, h = l.width, f = l.height;
1969
+ n = Math.min(n, u - h / 2), t = Math.max(t, u + h / 2), r = Math.min(r, c - f / 2), o = Math.max(o, c + f / 2);
1970
+ }
1971
+ e.nodes().forEach((l) => d(e.node(l))), e.edges().forEach((l) => {
1972
+ let u = e.edge(l);
1973
+ Object.hasOwn(u, "x") && d(u);
1974
+ }), n -= s, r -= a, e.nodes().forEach((l) => {
1975
+ let u = e.node(l);
1976
+ u.x -= n, u.y -= r;
1977
+ }), e.edges().forEach((l) => {
1978
+ let u = e.edge(l);
1979
+ u.points.forEach((c) => {
1980
+ c.x -= n, c.y -= r;
1981
+ }), Object.hasOwn(u, "x") && (u.x -= n), Object.hasOwn(u, "y") && (u.y -= r);
1982
+ }), i.width = t - n + s, i.height = o - r + a;
1983
+ }
1984
+ function Zt(e) {
1985
+ e.edges().forEach((n) => {
1986
+ let t = e.edge(n), r = e.node(n.v), o = e.node(n.w), i, s;
1987
+ t.points ? (i = t.points[0], s = t.points[t.points.length - 1]) : (t.points = [], i = o, s = r), t.points.unshift(H(r, i)), t.points.push(H(o, s));
1988
+ });
1989
+ }
1990
+ function er(e) {
1991
+ e.edges().forEach((n) => {
1992
+ let t = e.edge(n);
1993
+ if (Object.hasOwn(t, "x")) switch ((t.labelpos === "l" || t.labelpos === "r") && (t.width -= t.labeloffset), t.labelpos) {
1994
+ case "l":
1995
+ t.x -= t.width / 2 + t.labeloffset;
1996
+ break;
1997
+ case "r":
1998
+ t.x += t.width / 2 + t.labeloffset;
1999
+ break;
2000
+ }
2001
+ });
2002
+ }
2003
+ function nr(e) {
2004
+ e.edges().forEach((n) => {
2005
+ let t = e.edge(n);
2006
+ t.reversed && t.points.reverse();
2007
+ });
2008
+ }
2009
+ function tr(e) {
2010
+ e.nodes().forEach((n) => {
2011
+ if (e.children(n).length) {
2012
+ let t = e.node(n), r = e.node(t.borderTop), o = e.node(t.borderBottom), i = e.node(t.borderLeft[t.borderLeft.length - 1]), s = e.node(t.borderRight[t.borderRight.length - 1]);
2013
+ t.width = Math.abs(s.x - i.x), t.height = Math.abs(o.y - r.y), t.x = i.x + t.width / 2, t.y = r.y + t.height / 2;
2014
+ }
2015
+ }), e.nodes().forEach((n) => {
2016
+ e.node(n).dummy === "border" && e.removeNode(n);
2017
+ });
2018
+ }
2019
+ function rr(e) {
2020
+ e.edges().forEach((n) => {
2021
+ if (n.v === n.w) {
2022
+ let t = e.node(n.v);
2023
+ t.selfEdges || (t.selfEdges = []), t.selfEdges.push({ e: n, label: e.edge(n) }), e.removeEdge(n);
2024
+ }
2025
+ });
2026
+ }
2027
+ function or(e) {
2028
+ N(e).forEach((t) => {
2029
+ let r = 0;
2030
+ t.forEach((o, i) => {
2031
+ let s = e.node(o);
2032
+ s.order = i + r, (s.selfEdges || []).forEach((a) => {
2033
+ w(e, "selfedge", { width: a.label.width, height: a.label.height, rank: s.rank, order: i + ++r, e: a.e, label: a.label }, "_se");
2034
+ }), delete s.selfEdges;
2035
+ });
2036
+ });
2037
+ }
2038
+ function ir(e) {
2039
+ e.nodes().forEach((n) => {
2040
+ let t = e.node(n);
2041
+ if (t.dummy === "selfedge") {
2042
+ let r = t, o = e.node(r.e.v), i = o.x + o.width / 2, s = o.y, a = t.x - i, d = o.height / 2;
2043
+ e.setEdge(r.e, r.label), e.removeNode(n), r.label.points = [{ x: i + 2 * a / 3, y: s - d }, { x: i + 5 * a / 6, y: s - d }, { x: i + a, y: s }, { x: i + 5 * a / 6, y: s + d }, { x: i + 2 * a / 3, y: s + d }], r.label.x = t.x, r.label.y = t.y;
2044
+ }
2045
+ });
2046
+ }
2047
+ function ue(e, n) {
2048
+ return O(T(e, n), Number);
2049
+ }
2050
+ function ce(e) {
2051
+ let n = {};
2052
+ return e && Object.entries(e).forEach(([t, r]) => {
2053
+ typeof t == "string" && (t = t.toLowerCase()), n[t] = r;
2054
+ }), n;
2055
+ }
2056
+ function fe(e) {
2057
+ let n = N(e), t = new p({ compound: true, multigraph: true }).setGraph({});
2058
+ return e.nodes().forEach((r) => {
2059
+ t.setNode(r, { label: r }), t.setParent(r, "layer" + e.node(r).rank);
2060
+ }), e.edges().forEach((r) => t.setEdge(r.v, r.w, {}, r.name)), n.forEach((r, o) => {
2061
+ let i = "layer" + o;
2062
+ t.setNode(i, { rank: "same" }), r.reduce((s, a) => (t.setEdge(s, a, { style: "invis" }), a));
2063
+ }), t;
2064
+ }
2065
+ var sr = { graphlib: z, version: U, layout: he, debug: fe, util: { time: P, notime: M } };
2066
+ var To = sr;
2067
+
417
2068
  // src/blocks/erd.ts
2069
+ var MAX_ROWS = 10;
2070
+ var COL_W = 216;
2071
+ var ROW_H = 24;
2072
+ var HEAD_H = 32;
2073
+ var BOT_PAD = 8;
418
2074
  function renderErd(data) {
419
2075
  const ents = data.entities ?? [];
420
2076
  const rels = data.relations ?? [];
421
- const colW = 200;
422
- const rowH = 22;
423
- const headH = 30;
424
- const gapX = 80;
425
- const top = 14;
426
- const pad = 16;
427
- let x = pad;
428
- let maxH = 0;
429
2077
  const boxes = ents.map((e) => {
430
2078
  const cols = e.columns ?? [];
431
- const h = headH + cols.length * rowH + 10;
432
- const box = { name: e.name, columns: cols, x, y: top, w: colW, h };
433
- x += colW + gapX;
434
- if (h > maxH) maxH = h;
435
- return box;
436
- });
437
- const W = pad * 2 + ents.length * colW + Math.max(0, ents.length - 1) * gapX;
438
- const H = top + maxH + 24;
439
- const byName = /* @__PURE__ */ new Map();
440
- for (const b of boxes) byName.set(b.name, b);
441
- let s = `<svg viewBox="0 0 ${W} ${H}" role="img"><title>Entity-relationship diagram</title>`;
442
- const rowCenterY = (box, idx) => idx < 0 ? box.y + 24 : box.y + headH + 16 + idx * rowH - 4;
443
- for (const r of rels) {
444
- const a = byName.get(r.from);
445
- const b = byName.get(r.to);
446
- if (!a || !b) continue;
447
- const fkIdx = pickFkIndex(a.columns, r.to);
448
- const pkIdx = b.columns.findIndex((c) => c.pk === true);
449
- const y1 = rowCenterY(a, fkIdx);
450
- const y2 = rowCenterY(b, pkIdx);
451
- const aLeftOfB = a.x + a.w / 2 <= b.x + b.w / 2;
452
- const x1 = aLeftOfB ? a.x + a.w : a.x;
453
- const x2 = aLeftOfB ? b.x : b.x + b.w;
454
- const mx = (x1 + x2) / 2;
455
- const dir = aLeftOfB ? 1 : -1;
456
- s += `<path d="M${x1},${y1} H${mx} V${y2} H${x2}" fill="none" stroke="var(--gray)" stroke-width="1.5"/><circle cx="${x1}" cy="${y1}" r="2.6" fill="var(--gray)"/><path d="M${x2 - 9 * dir},${y2 - 6} L${x2},${y2} L${x2 - 9 * dir},${y2 + 6}" fill="none" stroke="var(--navy)" stroke-width="1.6" stroke-linejoin="round"/>`;
457
- if (r.card !== void 0) {
458
- const w = 30;
459
- const cy = (y1 + y2) / 2;
460
- s += `<rect x="${mx - w / 2}" y="${cy - 9}" width="${w}" height="18" rx="9" fill="var(--white)" stroke="var(--rule)"/><text x="${mx}" y="${cy + 3}" class="edge-label">${escapeHtml(r.card)}</text>`;
2079
+ let rows = cols;
2080
+ let hidden = 0;
2081
+ if (cols.length > MAX_ROWS) {
2082
+ rows = cols.slice(0, MAX_ROWS - 1);
2083
+ hidden = cols.length - rows.length;
461
2084
  }
2085
+ const bodyRows = rows.length + (hidden > 0 ? 1 : 0);
2086
+ const h = HEAD_H + bodyRows * ROW_H + BOT_PAD;
2087
+ return { name: e.name, rows, hidden, w: COL_W, h };
2088
+ });
2089
+ const byName = new Map(boxes.map((b) => [b.name, b]));
2090
+ const validRels = rels.filter((r) => byName.has(r.from) && byName.has(r.to));
2091
+ const g = new To.graphlib.Graph({ multigraph: true });
2092
+ g.setGraph({ rankdir: "LR", nodesep: 34, ranksep: 86, marginx: 18, marginy: 18 });
2093
+ g.setDefaultEdgeLabel(() => ({}));
2094
+ for (const b of boxes) g.setNode(b.name, { width: b.w, height: b.h });
2095
+ validRels.forEach((r, i) => g.setEdge(r.from, r.to, {}, `e${i}`));
2096
+ To.layout(g);
2097
+ const graph = g.graph();
2098
+ const W2 = Math.ceil(graph.width ?? 0);
2099
+ const H2 = Math.ceil(graph.height ?? 0);
2100
+ const topLeft = /* @__PURE__ */ new Map();
2101
+ for (const b of boxes) {
2102
+ const n = g.node(b.name);
2103
+ topLeft.set(b.name, { x: n.x - b.w / 2, y: n.y - b.h / 2 });
462
2104
  }
2105
+ let s = `<svg viewBox="0 0 ${W2} ${H2}" role="img"><title>Entity-relationship diagram</title>`;
2106
+ validRels.forEach((r, i) => {
2107
+ const e = g.edge(r.from, r.to, `e${i}`);
2108
+ const pts = e?.points;
2109
+ if (!pts || pts.length < 2) return;
2110
+ const first = pts[0];
2111
+ const last = pts[pts.length - 1];
2112
+ const prev = pts[pts.length - 2];
2113
+ if (first === void 0 || last === void 0 || prev === void 0) return;
2114
+ const line = pts.map((p2) => `${round(p2.x)},${round(p2.y)}`).join(" ");
2115
+ s += `<polyline points="${line}" fill="none" stroke="var(--gray)" stroke-width="1.5"/><circle cx="${round(first.x)}" cy="${round(first.y)}" r="2.6" fill="var(--gray)"/>` + arrowHead(prev, last);
2116
+ const mid = r.card !== void 0 ? pts[Math.floor(pts.length / 2)] : void 0;
2117
+ if (r.card !== void 0 && mid !== void 0) {
2118
+ const w2 = 30;
2119
+ s += `<rect x="${round(mid.x - w2 / 2)}" y="${round(mid.y - 9)}" width="${w2}" height="18" rx="9" fill="var(--white)" stroke="var(--rule)"/><text x="${round(mid.x)}" y="${round(mid.y + 3)}" class="edge-label">${escapeHtml(r.card)}</text>`;
2120
+ }
2121
+ });
463
2122
  for (const b of boxes) {
464
- s += `<rect x="${b.x}" y="${b.y}" width="${b.w}" height="${b.h}" rx="4" fill="var(--white)" stroke="var(--navy)"/><rect x="${b.x}" y="${b.y}" width="${b.w}" height="${headH}" rx="4" fill="var(--navy)"/><rect x="${b.x}" y="${b.y + headH - 4}" width="${b.w}" height="4" fill="var(--navy)"/><text x="${b.x + b.w / 2}" y="${b.y + 20}" class="er-head-text">${escapeHtml(b.name)}</text>`;
465
- b.columns.forEach((f, j) => {
466
- const fy = b.y + headH + 16 + j * rowH;
467
- const nameX = f.pk === true || f.fk === true ? b.x + 38 : b.x + 12;
468
- if (j > 0) {
469
- s += `<line x1="${b.x}" y1="${fy - 14}" x2="${b.x + b.w}" y2="${fy - 14}" class="er-rowline"/>`;
2123
+ const p2 = topLeft.get(b.name);
2124
+ if (!p2) continue;
2125
+ const { x: x2, y } = p2;
2126
+ s += `<rect x="${round(x2)}" y="${round(y)}" width="${b.w}" height="${b.h}" rx="5" fill="var(--white)" stroke="var(--navy)"/><path d="M${round(x2)},${round(y + HEAD_H)} v${ -27} a5,5 0 0 1 5,-5 h${b.w - 10} a5,5 0 0 1 5,5 v${HEAD_H - 5} z" fill="var(--navy)"/><text x="${round(x2 + b.w / 2)}" y="${round(y + 21)}" class="er-head-text">${escapeHtml(b.name)}</text>`;
2127
+ b.rows.forEach((f, j2) => {
2128
+ const rowTop = y + HEAD_H + j2 * ROW_H;
2129
+ const ty = rowTop + 16;
2130
+ if (j2 > 0) {
2131
+ s += `<line x1="${round(x2)}" y1="${round(rowTop)}" x2="${round(x2 + b.w)}" y2="${round(rowTop)}" class="er-rowline"/>`;
470
2132
  }
2133
+ const nameX = f.pk === true || f.fk === true ? x2 + 40 : x2 + 13;
471
2134
  if (f.pk === true) {
472
- s += `<text x="${b.x + 12}" y="${fy}" class="er-key">PK</text>`;
2135
+ s += `<text x="${round(x2 + 13)}" y="${round(ty)}" class="er-key">PK</text>`;
473
2136
  } else if (f.fk === true) {
474
- s += `<text x="${b.x + 12}" y="${fy}" class="er-key fk">FK</text>`;
2137
+ s += `<text x="${round(x2 + 13)}" y="${round(ty)}" class="er-key fk">FK</text>`;
475
2138
  }
476
- s += `<text x="${nameX}" y="${fy}" class="er-col">${escapeHtml(f.name)}</text><text x="${b.x + b.w - 12}" y="${fy}" class="er-col dim" text-anchor="end">${escapeHtml(f.type ?? "")}</text>`;
2139
+ s += `<text x="${round(nameX)}" y="${round(ty)}" class="er-col">${escapeHtml(f.name)}</text><text x="${round(x2 + b.w - 13)}" y="${round(ty)}" class="er-col dim" text-anchor="end">${escapeHtml(f.type ?? "")}</text>`;
477
2140
  });
2141
+ if (b.hidden > 0) {
2142
+ const rowTop = y + HEAD_H + b.rows.length * ROW_H;
2143
+ s += `<line x1="${round(x2)}" y1="${round(rowTop)}" x2="${round(x2 + b.w)}" y2="${round(rowTop)}" class="er-rowline"/><text x="${round(x2 + b.w / 2)}" y="${round(rowTop + 16)}" class="er-col dim" text-anchor="middle">\u2026 +${b.hidden} more</text>`;
2144
+ }
478
2145
  }
479
2146
  s += `</svg>`;
480
2147
  const opts = {
@@ -485,18 +2152,17 @@ function renderErd(data) {
485
2152
  };
486
2153
  return diagramFrame(opts, s);
487
2154
  }
488
- function pickFkIndex(columns, toName) {
489
- const fks = columns.map((c, i) => ({ c, i })).filter((x) => x.c.fk === true);
490
- const first = fks[0];
491
- if (first === void 0) return -1;
492
- const t = toName.toLowerCase();
493
- const singular = t.replace(/s$/, "");
494
- const match = fks.find((x) => {
495
- const n = x.c.name.toLowerCase();
496
- return n.includes(t) || n.includes(singular);
497
- });
498
- return (match ?? first).i;
2155
+ function arrowHead(from, to) {
2156
+ const ang = Math.atan2(to.y - from.y, to.x - from.x);
2157
+ const len = 10;
2158
+ const spread = 0.42;
2159
+ const b1x = to.x - len * Math.cos(ang - spread);
2160
+ const b1y = to.y - len * Math.sin(ang - spread);
2161
+ const b2x = to.x - len * Math.cos(ang + spread);
2162
+ const b2y = to.y - len * Math.sin(ang + spread);
2163
+ return `<path d="M${round(b1x)},${round(b1y)} L${round(to.x)},${round(to.y)} L${round(b2x)},${round(b2y)}" fill="none" stroke="var(--navy)" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round"/>`;
499
2164
  }
2165
+ var round = (n) => Math.round(n * 10) / 10;
500
2166
 
501
2167
  // src/blocks/kanban.ts
502
2168
  function renderKanban(data) {
@@ -544,21 +2210,21 @@ function renderFoot(foot) {
544
2210
  function renderSequence(data) {
545
2211
  const actors = data.actors ?? [];
546
2212
  const messages = data.messages ?? [];
547
- const N = Math.max(actors.length, 1);
2213
+ const N2 = Math.max(actors.length, 1);
548
2214
  const leftPad = 24;
549
2215
  const laneW = 168;
550
2216
  const gap = 58;
551
2217
  const headY = 16;
552
2218
  const headH = 42;
553
2219
  const cx = (i) => leftPad + laneW / 2 + i * (laneW + gap);
554
- const width = leftPad * 2 + N * laneW + (N - 1) * gap;
2220
+ const width = leftPad * 2 + N2 * laneW + (N2 - 1) * gap;
555
2221
  const idx = (id) => actors.findIndex((a) => a.id === id);
556
2222
  const msgStartY = 92;
557
2223
  const step = 42;
558
- const rows = messages.map((m, k) => {
2224
+ const rows = messages.map((m, k2) => {
559
2225
  const base = {
560
- n: k + 1,
561
- y: msgStartY + k * step,
2226
+ n: k2 + 1,
2227
+ y: msgStartY + k2 * step,
562
2228
  fromI: idx(m.from),
563
2229
  toI: idx(m.to),
564
2230
  kind: m.kind ?? "sync",
@@ -582,8 +2248,8 @@ function renderSequence(data) {
582
2248
  });
583
2249
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Sequence diagram</title><defs><marker id="sqArrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#1a1a2e"/></marker><marker id="sqOpen" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10" fill="none" stroke="#1a1a2e" stroke-width="1.2"/></marker><marker id="sqErr" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#991b1b"/></marker></defs>`;
584
2250
  for (let i = 0; i < actors.length; i++) {
585
- const x = cx(i);
586
- s += `<line x1="${x}" y1="${headY + headH}" x2="${x}" y2="${bottom}" class="lifeline"/>`;
2251
+ const x2 = cx(i);
2252
+ s += `<line x1="${x2}" y1="${headY + headH}" x2="${x2}" y2="${bottom}" class="lifeline"/>`;
587
2253
  }
588
2254
  for (const ac of activations) {
589
2255
  if (!ac) continue;
@@ -595,17 +2261,17 @@ function renderSequence(data) {
595
2261
  s += `<g><rect x="${cx(i) - laneW / 2}" y="${headY}" width="${laneW}" height="${headH}" class="lane-head${extCls}"/><text x="${cx(i)}" y="${headY + 22}" class="lane-head-text">${escapeHtml(a.name)}</text>` + sub + `</g>`;
596
2262
  });
597
2263
  for (const r of rows) {
598
- const k = KIND[r.kind];
2264
+ const k2 = KIND[r.kind];
599
2265
  if (r.kind === "note" || r.toI < 0) {
600
2266
  if (r.fromI < 0) continue;
601
- const x = cx(r.fromI);
602
- s += `<g><circle cx="${x + 18}" cy="${r.y - 10}" r="10" class="step-badge"/><text x="${x + 18}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${x + 34}" y="${r.y - 6}" class="msg-text note">${escapeHtml(r.label)}</text></g>`;
2267
+ const x3 = cx(r.fromI);
2268
+ s += `<g><circle cx="${x3 + 18}" cy="${r.y - 10}" r="10" class="step-badge"/><text x="${x3 + 18}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${x3 + 34}" y="${r.y - 6}" class="msg-text note">${escapeHtml(r.label)}</text></g>`;
603
2269
  continue;
604
2270
  }
605
2271
  if (r.fromI === r.toI) {
606
- const x = cx(r.fromI);
2272
+ const x3 = cx(r.fromI);
607
2273
  const errCls = r.kind === "error" ? " err" : "";
608
- s += `<g><circle cx="${x + 18}" cy="${r.y - 10}" r="10" class="step-badge${errCls}"/><text x="${x + 18}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${x + 34}" y="${r.y - 6}" class="msg-text note">${escapeHtml(r.label)}</text></g>`;
2274
+ s += `<g><circle cx="${x3 + 18}" cy="${r.y - 10}" r="10" class="step-badge${errCls}"/><text x="${x3 + 18}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${x3 + 34}" y="${r.y - 6}" class="msg-text note">${escapeHtml(r.label)}</text></g>`;
609
2275
  continue;
610
2276
  }
611
2277
  const x1 = cx(r.fromI);
@@ -616,8 +2282,8 @@ function renderSequence(data) {
616
2282
  const badgeX = ltr ? x1 + 18 : x1 - 18;
617
2283
  const labelX = ltr ? badgeX + 16 : badgeX - 16;
618
2284
  const labelAnchor = ltr ? "start" : "end";
619
- const markerAttr = k.marker !== null ? ` marker-end="url(#${k.marker})"` : "";
620
- s += `<line x1="${x1}" y1="${r.y}" x2="${end}" y2="${r.y}" class="${k.cls}"${markerAttr}/><circle cx="${badgeX}" cy="${r.y - 10}" r="10" class="step-badge${errBadge}"/><text x="${badgeX}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${labelX}" y="${r.y - 6}" class="${k.txt}" text-anchor="${labelAnchor}">${escapeHtml(r.label)}</text>`;
2285
+ const markerAttr = k2.marker !== null ? ` marker-end="url(#${k2.marker})"` : "";
2286
+ s += `<line x1="${x1}" y1="${r.y}" x2="${end}" y2="${r.y}" class="${k2.cls}"${markerAttr}/><circle cx="${badgeX}" cy="${r.y - 10}" r="10" class="step-badge${errBadge}"/><text x="${badgeX}" y="${r.y - 6.5}" class="step-badge-text">${r.n}</text><text x="${labelX}" y="${r.y - 6}" class="${k2.txt}" text-anchor="${labelAnchor}">${escapeHtml(r.label)}</text>`;
621
2287
  }
622
2288
  s += `</svg>`;
623
2289
  const actorById = /* @__PURE__ */ new Map();
@@ -690,11 +2356,11 @@ function renderTable(data) {
690
2356
  function renderTimeline(data) {
691
2357
  const items = data.items ?? [];
692
2358
  let h = `<div class="tl">`;
693
- for (const it of items) {
694
- const st = it.status ?? "future";
695
- const date = it.date !== void 0 ? `<div class="tl-date">${escapeHtml(it.date)}</div>` : "";
696
- const desc = it.desc !== void 0 ? `<div class="tl-desc">${escapeHtml(it.desc)}</div>` : "";
697
- h += `<div class="tl-item"><span class="tl-dot ${st}"></span>` + date + `<div class="tl-label">${escapeHtml(it.label)}</div>` + desc + `</div>`;
2359
+ for (const it2 of items) {
2360
+ const st2 = it2.status ?? "future";
2361
+ const date = it2.date !== void 0 ? `<div class="tl-date">${escapeHtml(it2.date)}</div>` : "";
2362
+ const desc = it2.desc !== void 0 ? `<div class="tl-desc">${escapeHtml(it2.desc)}</div>` : "";
2363
+ h += `<div class="tl-item"><span class="tl-dot ${st2}"></span>` + date + `<div class="tl-label">${escapeHtml(it2.label)}</div>` + desc + `</div>`;
698
2364
  }
699
2365
  return h + `</div>`;
700
2366
  }
@@ -708,18 +2374,18 @@ function renderTracker(data) {
708
2374
  if (hasOwner) headCells.push("<th>Owner</th>");
709
2375
  if (hasDue) headCells.push("<th>Due</th>");
710
2376
  let h = `<table class="trk"><thead><tr>${headCells.join("")}</tr></thead><tbody>`;
711
- for (const it of items) {
712
- const st = it.status ?? "todo";
713
- const pr = it.priority;
2377
+ for (const it2 of items) {
2378
+ const st2 = it2.status ?? "todo";
2379
+ const pr = it2.priority;
714
2380
  const prCell = pr !== void 0 ? `<span class="pri ${pr}">${escapeHtml(pr)}</span>` : "";
715
- const rowCls = st === "done" ? ' class="done"' : "";
2381
+ const rowCls = st2 === "done" ? ' class="done"' : "";
716
2382
  const cells = [
717
- `<td class="trk-task">${escapeHtml(it.task)}</td>`,
718
- `<td><span class="st ${st}">${escapeHtml(st)}</span></td>`,
2383
+ `<td class="trk-task">${escapeHtml(it2.task)}</td>`,
2384
+ `<td><span class="st ${st2}">${escapeHtml(st2)}</span></td>`,
719
2385
  `<td>${prCell}</td>`
720
2386
  ];
721
- if (hasOwner) cells.push(`<td>${escapeHtml(it.owner ?? "")}</td>`);
722
- if (hasDue) cells.push(`<td>${escapeHtml(it.due ?? "")}</td>`);
2387
+ if (hasOwner) cells.push(`<td>${escapeHtml(it2.owner ?? "")}</td>`);
2388
+ if (hasDue) cells.push(`<td>${escapeHtml(it2.due ?? "")}</td>`);
723
2389
  h += `<tr${rowCls}>${cells.join("")}</tr>`;
724
2390
  }
725
2391
  return h + `</tbody></table>`;
@@ -767,11 +2433,11 @@ function renderProseBlock(data) {
767
2433
  if (t === "h") return `<h3>${escapeHtml(text)}</h3>`;
768
2434
  if (t === "quote") return `<blockquote>${escapeHtml(text)}</blockquote>`;
769
2435
  if (t === "ul") {
770
- const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join("");
2436
+ const items = (b.items ?? []).map((x2) => `<li>${escapeHtml(x2)}</li>`).join("");
771
2437
  return `<ul>${items}</ul>`;
772
2438
  }
773
2439
  if (t === "ol") {
774
- const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join("");
2440
+ const items = (b.items ?? []).map((x2) => `<li>${escapeHtml(x2)}</li>`).join("");
775
2441
  return `<ol>${items}</ol>`;
776
2442
  }
777
2443
  return `<p>${escapeHtml(text)}</p>`;
@@ -792,7 +2458,7 @@ function renderGlossary(data) {
792
2458
  function renderProsCons(data) {
793
2459
  const prosLabel = data.prosLabel ?? "Pros";
794
2460
  const consLabel = data.consLabel ?? "Cons";
795
- const pros = (data.pros ?? []).map((p) => `<div class="pc-item">${escapeHtml(p)}</div>`).join("");
2461
+ const pros = (data.pros ?? []).map((p2) => `<div class="pc-item">${escapeHtml(p2)}</div>`).join("");
796
2462
  const cons = (data.cons ?? []).map((c) => `<div class="pc-item">${escapeHtml(c)}</div>`).join("");
797
2463
  return `<div class="pc"><div class="pc-col pro"><div class="pc-head">${escapeHtml(prosLabel)}</div>` + pros + `</div><div class="pc-col con"><div class="pc-head">${escapeHtml(consLabel)}</div>` + cons + `</div></div>`;
798
2464
  }
@@ -801,8 +2467,8 @@ function renderProsCons(data) {
801
2467
  function renderCvt(data) {
802
2468
  const cur = data.current ?? {};
803
2469
  const tgt = data.target ?? {};
804
- const curItems = (cur.items ?? []).map((x) => `<div class="ct-item">${escapeHtml(x)}</div>`).join("");
805
- const tgtItems = (tgt.items ?? []).map((x) => `<div class="ct-item">${escapeHtml(x)}</div>`).join("");
2470
+ const curItems = (cur.items ?? []).map((x2) => `<div class="ct-item">${escapeHtml(x2)}</div>`).join("");
2471
+ const tgtItems = (tgt.items ?? []).map((x2) => `<div class="ct-item">${escapeHtml(x2)}</div>`).join("");
806
2472
  const curLabel = cur.label ?? "Current";
807
2473
  const tgtLabel = tgt.label ?? "Target";
808
2474
  const note = data.note !== void 0 ? `<div class="tbl-note">${escapeHtml(data.note)}</div>` : "";
@@ -846,9 +2512,9 @@ function highlightCode(code) {
846
2512
  } else if (m[3] !== void 0) {
847
2513
  out += `<span class="num">${escapeHtml(t)}</span>`;
848
2514
  } else {
849
- const lt = t.toLowerCase();
850
- if (KW.has(lt)) out += `<span class="kw">${escapeHtml(t)}</span>`;
851
- else if (TY.has(lt)) out += `<span class="ty">${escapeHtml(t)}</span>`;
2515
+ const lt2 = t.toLowerCase();
2516
+ if (KW.has(lt2)) out += `<span class="kw">${escapeHtml(t)}</span>`;
2517
+ else if (TY.has(lt2)) out += `<span class="ty">${escapeHtml(t)}</span>`;
852
2518
  else if (src[TOKEN_RE.lastIndex] === "(")
853
2519
  out += `<span class="fn">${escapeHtml(t)}</span>`;
854
2520
  else out += escapeHtml(t);
@@ -870,12 +2536,12 @@ function renderCode(data) {
870
2536
  // src/blocks/agenda.ts
871
2537
  function renderAgenda(data) {
872
2538
  const items = data.items ?? [];
873
- const rows = items.map((it) => {
874
- const dur = it.duration !== void 0 ? `<div class="agenda-dur">${escapeHtml(it.duration)}</div>` : "";
875
- const owner = it.owner !== void 0 ? `<span class="agenda-owner">${escapeHtml(it.owner)}</span>` : "";
876
- const desc = it.desc !== void 0 ? `<div class="agenda-desc">${escapeHtml(it.desc)}</div>` : "";
877
- const time = it.time !== void 0 ? `<div class="agenda-time">${escapeHtml(it.time)}</div>` : "";
878
- return `<div class="agenda-row"><div>${time}${dur}</div><div><div class="agenda-title">${escapeHtml(it.title)}${owner}</div>` + desc + `</div></div>`;
2539
+ const rows = items.map((it2) => {
2540
+ const dur = it2.duration !== void 0 ? `<div class="agenda-dur">${escapeHtml(it2.duration)}</div>` : "";
2541
+ const owner = it2.owner !== void 0 ? `<span class="agenda-owner">${escapeHtml(it2.owner)}</span>` : "";
2542
+ const desc = it2.desc !== void 0 ? `<div class="agenda-desc">${escapeHtml(it2.desc)}</div>` : "";
2543
+ const time = it2.time !== void 0 ? `<div class="agenda-time">${escapeHtml(it2.time)}</div>` : "";
2544
+ return `<div class="agenda-row"><div>${time}${dur}</div><div><div class="agenda-title">${escapeHtml(it2.title)}${owner}</div>` + desc + `</div></div>`;
879
2545
  }).join("");
880
2546
  return `<div class="agenda">${rows}</div>`;
881
2547
  }
@@ -923,78 +2589,78 @@ var CHART_COLORS = ["#0e54a1", "#1a6dbe", "#0f766e", "#1f9747", "#6b21a8", "#f79
923
2589
  function renderPyramid(data) {
924
2590
  const levels = data.levels ?? [];
925
2591
  const n = Math.max(levels.length, 1);
926
- const W = 520;
2592
+ const W2 = 520;
927
2593
  const top = 16;
928
2594
  const rowH = Math.min(72, Math.floor(280 / n));
929
2595
  const gap = 4;
930
- const apex = W / 2;
2596
+ const apex = W2 / 2;
931
2597
  const pad = 16;
932
2598
  const maxW = 430;
933
- const H = top + n * (rowH + gap) + pad;
934
- const polygons = levels.map((L, i) => {
2599
+ const H2 = top + n * (rowH + gap) + pad;
2600
+ const polygons = levels.map((L2, i) => {
935
2601
  const y = top + i * (rowH + gap);
936
2602
  const wTop = maxW * (i / n);
937
2603
  const wBot = maxW * ((i + 1) / n);
938
2604
  const fill = CHART_COLORS[i % CHART_COLORS.length] ?? "#0e54a1";
939
- const desc = L.desc !== void 0 ? `<text x="${apex}" y="${y + rowH / 2 + 14}" class="pyr-desc">${escapeHtml(L.desc)}</text>` : "";
940
- return `<g><polygon points="${apex - wTop / 2},${y} ${apex + wTop / 2},${y} ${apex + wBot / 2},${y + rowH} ${apex - wBot / 2},${y + rowH}" fill="${fill}"/><text x="${apex}" y="${y + rowH / 2 - 1}" class="pyr-label">${escapeHtml(L.label)}</text>` + desc + `</g>`;
2605
+ const desc = L2.desc !== void 0 ? `<text x="${apex}" y="${y + rowH / 2 + 14}" class="pyr-desc">${escapeHtml(L2.desc)}</text>` : "";
2606
+ return `<g><polygon points="${apex - wTop / 2},${y} ${apex + wTop / 2},${y} ${apex + wBot / 2},${y + rowH} ${apex - wBot / 2},${y + rowH}" fill="${fill}"/><text x="${apex}" y="${y + rowH / 2 - 1}" class="pyr-label">${escapeHtml(L2.label)}</text>` + desc + `</g>`;
941
2607
  }).join("");
942
- return `<svg viewBox="0 0 ${W} ${H}" role="img"><title>Pyramid</title>${polygons}</svg>`;
2608
+ return `<svg viewBox="0 0 ${W2} ${H2}" role="img"><title>Pyramid</title>${polygons}</svg>`;
943
2609
  }
944
2610
 
945
2611
  // src/blocks/funnel.ts
946
2612
  var CHART_COLORS2 = ["#0e54a1", "#1a6dbe", "#0f766e", "#1f9747", "#6b21a8", "#f7952c"];
947
- function toNum(v) {
948
- if (typeof v === "number") return v;
949
- const n = parseFloat(v.replace(/[, _]/g, ""));
2613
+ function toNum(v2) {
2614
+ if (typeof v2 === "number") return v2;
2615
+ const n = parseFloat(v2.replace(/[, _]/g, ""));
950
2616
  return Number.isFinite(n) ? n : 0;
951
2617
  }
952
- function fmt(v) {
953
- return typeof v === "number" ? v.toLocaleString() : v;
2618
+ function fmt(v2) {
2619
+ return typeof v2 === "number" ? v2.toLocaleString() : v2;
954
2620
  }
955
2621
  function renderFunnel(data) {
956
2622
  const stages = (data.stages ?? []).filter(Boolean);
957
- const W = 560;
2623
+ const W2 = 560;
958
2624
  const top = 14;
959
2625
  const rowH = 62;
960
2626
  const maxW = 420;
961
2627
  const pad = 14;
962
- const cx = W / 2;
963
- const H = top + stages.length * rowH + pad;
2628
+ const cx = W2 / 2;
2629
+ const H2 = top + stages.length * rowH + pad;
964
2630
  const vals = stages.map((s) => toNum(s.value));
965
2631
  const first = vals[0] ?? 0;
966
2632
  const max = Math.max(1, ...vals);
967
- const wOf = (v) => Math.max(78, maxW * (v / max));
2633
+ const wOf = (v2) => Math.max(78, maxW * (v2 / max));
968
2634
  const groups = stages.map((s, i) => {
969
- const v = vals[i] ?? 0;
970
- const vNext = i < stages.length - 1 ? vals[i + 1] ?? 0 : v * 0.82;
971
- const wTop = wOf(v);
2635
+ const v2 = vals[i] ?? 0;
2636
+ const vNext = i < stages.length - 1 ? vals[i + 1] ?? 0 : v2 * 0.82;
2637
+ const wTop = wOf(v2);
972
2638
  const wBot = wOf(vNext);
973
2639
  const y = top + i * rowH;
974
2640
  const fill = CHART_COLORS2[i % CHART_COLORS2.length] ?? "#0e54a1";
975
- const pct = first > 0 ? Math.round(v / first * 100) : 0;
2641
+ const pct = first > 0 ? Math.round(v2 / first * 100) : 0;
976
2642
  const sub = i > 0 && first > 0 ? ` \xB7 ${pct}%` : "";
977
2643
  return `<g><polygon points="${cx - wTop / 2},${y} ${cx + wTop / 2},${y} ${cx + wBot / 2},${y + rowH} ${cx - wBot / 2},${y + rowH}" fill="${fill}" stroke="#fff" stroke-width="2"/><text x="${cx}" y="${y + rowH / 2 - 3}" class="funnel-label">${escapeHtml(s.label)}</text><text x="${cx}" y="${y + rowH / 2 + 15}" class="funnel-val">${escapeHtml(fmt(s.value))}${sub}</text></g>`;
978
2644
  }).join("");
979
- return `<svg viewBox="0 0 ${W} ${H}" role="img"><title>Funnel</title>${groups}</svg>`;
2645
+ return `<svg viewBox="0 0 ${W2} ${H2}" role="img"><title>Funnel</title>${groups}</svg>`;
980
2646
  }
981
2647
 
982
2648
  // src/svg/ortho.ts
983
- function ortho(A, B) {
984
- const a = { x: A.x + A.w / 2, y: A.y + A.h / 2 };
985
- const b = { x: B.x + B.w / 2, y: B.y + B.h / 2 };
2649
+ function ortho(A2, B2) {
2650
+ const a = { x: A2.x + A2.w / 2, y: A2.y + A2.h / 2 };
2651
+ const b = { x: B2.x + B2.w / 2, y: B2.y + B2.h / 2 };
986
2652
  const dx = b.x - a.x;
987
2653
  const dy = b.y - a.y;
988
2654
  if (Math.abs(dx) >= Math.abs(dy)) {
989
- const sx2 = dx >= 0 ? A.x + A.w : A.x;
990
- const ex2 = dx >= 0 ? B.x : B.x + B.w;
2655
+ const sx2 = dx >= 0 ? A2.x + A2.w : A2.x;
2656
+ const ex2 = dx >= 0 ? B2.x : B2.x + B2.w;
991
2657
  const sy2 = a.y;
992
2658
  const ey2 = b.y;
993
2659
  const mx = (sx2 + ex2) / 2;
994
2660
  return { d: `M ${sx2} ${sy2} H ${mx} V ${ey2} H ${ex2}`, lx: mx, ly: (sy2 + ey2) / 2 };
995
2661
  }
996
- const sy = dy >= 0 ? A.y + A.h : A.y;
997
- const ey = dy >= 0 ? B.y : B.y + B.h;
2662
+ const sy = dy >= 0 ? A2.y + A2.h : A2.y;
2663
+ const ey = dy >= 0 ? B2.y : B2.y + B2.h;
998
2664
  const sx = a.x;
999
2665
  const ex = b.x;
1000
2666
  const my = (sy + ey) / 2;
@@ -1007,16 +2673,16 @@ function wrapText(text, max, maxLines) {
1007
2673
  const words = String(text).split(/\s+/);
1008
2674
  const lines = [];
1009
2675
  let cur = "";
1010
- for (const w of words) {
2676
+ for (const w2 of words) {
1011
2677
  if (!cur) {
1012
- cur = w;
2678
+ cur = w2;
1013
2679
  continue;
1014
2680
  }
1015
- if ((cur + " " + w).length <= max) {
1016
- cur += " " + w;
2681
+ if ((cur + " " + w2).length <= max) {
2682
+ cur += " " + w2;
1017
2683
  } else {
1018
2684
  lines.push(cur);
1019
- cur = w;
2685
+ cur = w2;
1020
2686
  if (lines.length === maxLines) break;
1021
2687
  }
1022
2688
  }
@@ -1025,11 +2691,11 @@ function wrapText(text, max, maxLines) {
1025
2691
  }
1026
2692
 
1027
2693
  // src/svg/edgePill.ts
1028
- function edgePill(p, label, err = false) {
2694
+ function edgePill(p2, label, err = false) {
1029
2695
  if (label === void 0 || label === "") return "";
1030
- const w = Math.max(26, label.length * 5.4);
2696
+ const w2 = Math.max(26, label.length * 5.4);
1031
2697
  const errClass = err ? " err" : "";
1032
- return `<g><rect x="${p.lx - w / 2}" y="${p.ly - 9}" width="${w}" height="18" rx="9" fill="#fff" stroke="#d1d5db"/><text x="${p.lx}" y="${p.ly + 3}" class="edge-label${errClass}">${escapeHtml(label)}</text></g>`;
2698
+ return `<g><rect x="${p2.lx - w2 / 2}" y="${p2.ly - 9}" width="${w2}" height="18" rx="9" fill="#fff" stroke="#d1d5db"/><text x="${p2.lx}" y="${p2.ly + 3}" class="edge-label${errClass}">${escapeHtml(label)}</text></g>`;
1033
2699
  }
1034
2700
 
1035
2701
  // src/blocks/flow.ts
@@ -1071,32 +2737,32 @@ function renderFlowSvg(data) {
1071
2737
  const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;
1072
2738
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Flowchart</title>`;
1073
2739
  for (const e of edges) {
1074
- const A = byId.get(e.from);
1075
- const B = byId.get(e.to);
1076
- if (!A || !B) continue;
1077
- const p = ortho(rectFor2(A), rectFor2(B));
2740
+ const A2 = byId.get(e.from);
2741
+ const B2 = byId.get(e.to);
2742
+ if (!A2 || !B2) continue;
2743
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
1078
2744
  const isErr = e.kind === "error" || ERR_LABEL_RE.test(e.label ?? "");
1079
2745
  const stroke = isErr ? "#991b1b" : "#1a1a2e";
1080
2746
  const marker = isErr ? "gErr" : "gArrow";
1081
2747
  const sw = isErr ? 1.6 : 1.4;
1082
- s += `<g><path d="${p.d}" fill="none" stroke="${stroke}" stroke-width="${sw}" marker-end="url(#${marker})"/>` + edgePill(p, e.label, isErr) + `</g>`;
2748
+ s += `<g><path d="${p2.d}" fill="none" stroke="${stroke}" stroke-width="${sw}" marker-end="url(#${marker})"/>` + edgePill(p2, e.label, isErr) + `</g>`;
1083
2749
  }
1084
2750
  for (const n of nodes) {
1085
2751
  const r = rectFor2(n);
1086
- const st = flowStyle(n.kind);
2752
+ const st2 = flowStyle(n.kind);
1087
2753
  const cx = r.x + r.w / 2;
1088
2754
  const cy = r.y + r.h / 2;
1089
2755
  let shape;
1090
- if (st.shape === "diamond") {
1091
- shape = `<polygon points="${cx},${r.y} ${r.x + r.w},${cy} ${cx},${r.y + r.h} ${r.x},${cy}" fill="${st.fill}" stroke="${st.stroke}" stroke-width="1.5"/>`;
1092
- } else if (st.shape === "stadium") {
1093
- shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="${r.h / 2}" fill="${st.fill}" stroke="${st.stroke}" stroke-width="1.5"/>`;
2756
+ if (st2.shape === "diamond") {
2757
+ shape = `<polygon points="${cx},${r.y} ${r.x + r.w},${cy} ${cx},${r.y + r.h} ${r.x},${cy}" fill="${st2.fill}" stroke="${st2.stroke}" stroke-width="1.5"/>`;
2758
+ } else if (st2.shape === "stadium") {
2759
+ shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="${r.h / 2}" fill="${st2.fill}" stroke="${st2.stroke}" stroke-width="1.5"/>`;
1094
2760
  } else {
1095
- shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="7" fill="${st.fill}" stroke="${st.stroke}" stroke-width="1.4"/>`;
2761
+ shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="7" fill="${st2.fill}" stroke="${st2.stroke}" stroke-width="1.4"/>`;
1096
2762
  }
1097
2763
  const lines = wrapText(n.label, 22, 2);
1098
2764
  const texts = lines.map(
1099
- (ln, j) => `<text x="${cx}" y="${cy + 4 - (lines.length - 1) * 7 + j * 14}" class="fc-label" fill="${st.text}">${escapeHtml(ln)}</text>`
2765
+ (ln2, j2) => `<text x="${cx}" y="${cy + 4 - (lines.length - 1) * 7 + j2 * 14}" class="fc-label" fill="${st2.text}">${escapeHtml(ln2)}</text>`
1100
2766
  ).join("");
1101
2767
  s += `<g filter="url(#gshadow)">${shape}${texts}</g>`;
1102
2768
  }
@@ -1155,31 +2821,31 @@ function renderState(data) {
1155
2821
  const byId = new Map(states.map((s2) => [s2.id, s2]));
1156
2822
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>State machine</title>`;
1157
2823
  for (const t of trans) {
1158
- const A = byId.get(t.from);
1159
- const B = byId.get(t.to);
1160
- if (!A || !B) continue;
2824
+ const A2 = byId.get(t.from);
2825
+ const B2 = byId.get(t.to);
2826
+ if (!A2 || !B2) continue;
1161
2827
  const label = t.event + (t.guard !== void 0 ? ` ${t.guard}` : "");
1162
2828
  if (t.from === t.to) {
1163
- const r = rectFor(A, cellW, cellH, gapX, gapY, padX, padTop);
2829
+ const r = rectFor(A2, cellW, cellH, gapX, gapY, padX, padTop);
1164
2830
  s += `<g><path d="M ${r.cx - 12} ${r.y} C ${r.cx - 30} ${r.y - 32}, ${r.cx + 30} ${r.y - 32}, ${r.cx + 12} ${r.y}" fill="none" stroke="#1a1a2e" stroke-width="1.3" marker-end="url(#gArrow)"/>` + edgePill({ lx: r.cx, ly: r.y - 28 }, label) + `</g>`;
1165
2831
  continue;
1166
2832
  }
1167
- const p = ortho(
1168
- rectFor(A, cellW, cellH, gapX, gapY, padX, padTop),
1169
- rectFor(B, cellW, cellH, gapX, gapY, padX, padTop)
2833
+ const p2 = ortho(
2834
+ rectFor(A2, cellW, cellH, gapX, gapY, padX, padTop),
2835
+ rectFor(B2, cellW, cellH, gapX, gapY, padX, padTop)
1170
2836
  );
1171
- s += `<g><path d="${p.d}" fill="none" stroke="#1a1a2e" stroke-width="1.3" marker-end="url(#gArrow)"/>` + edgePill(p, label) + `</g>`;
2837
+ s += `<g><path d="${p2.d}" fill="none" stroke="#1a1a2e" stroke-width="1.3" marker-end="url(#gArrow)"/>` + edgePill(p2, label) + `</g>`;
1172
2838
  }
1173
- for (const st of states) {
1174
- const r = rectFor(st, cellW, cellH, gapX, gapY, padX, padTop);
1175
- if (st.kind === "start") {
2839
+ for (const st2 of states) {
2840
+ const r = rectFor(st2, cellW, cellH, gapX, gapY, padX, padTop);
2841
+ if (st2.kind === "start") {
1176
2842
  s += `<circle cx="${r.cx}" cy="${r.cy}" r="10" fill="#1a1a2e"/>`;
1177
- } else if (st.kind === "terminal") {
2843
+ } else if (st2.kind === "terminal") {
1178
2844
  s += `<g><circle cx="${r.cx}" cy="${r.cy}" r="12" fill="#fff" stroke="#1a1a2e" stroke-width="1.5"/><circle cx="${r.cx}" cy="${r.cy}" r="6" fill="#1a1a2e"/></g>`;
1179
2845
  } else {
1180
- const fill = st.kind === "wait" ? "#fde7cd" : "#dcf1e2";
1181
- const stroke = st.kind === "wait" ? "#f7952c" : "#1f9747";
1182
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="23" fill="${fill}" stroke="${stroke}" stroke-width="1.5"/><text x="${r.cx}" y="${r.cy + 4.5}" class="sm-name" fill="#1a1a2e">${escapeHtml(st.name ?? "")}</text></g>`;
2846
+ const fill = st2.kind === "wait" ? "#fde7cd" : "#dcf1e2";
2847
+ const stroke = st2.kind === "wait" ? "#f7952c" : "#1f9747";
2848
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="23" fill="${fill}" stroke="${stroke}" stroke-width="1.5"/><text x="${r.cx}" y="${r.cy + 4.5}" class="sm-name" fill="#1a1a2e">${escapeHtml(st2.name ?? "")}</text></g>`;
1183
2849
  }
1184
2850
  }
1185
2851
  s += `</svg>`;
@@ -1231,26 +2897,26 @@ function renderDfd(data) {
1231
2897
  const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;
1232
2898
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Data-flow diagram</title>`;
1233
2899
  for (const e of edges) {
1234
- const A = byId.get(e.from);
1235
- const B = byId.get(e.to);
1236
- if (!A || !B) continue;
1237
- const p = ortho(rectFor2(A), rectFor2(B));
1238
- s += `<g><path d="${p.d}" fill="none" stroke="#1a1a2e" stroke-width="1.4" marker-end="url(#gArrow)"/>` + edgePill(p, e.label) + `</g>`;
2900
+ const A2 = byId.get(e.from);
2901
+ const B2 = byId.get(e.to);
2902
+ if (!A2 || !B2) continue;
2903
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
2904
+ s += `<g><path d="${p2.d}" fill="none" stroke="#1a1a2e" stroke-width="1.4" marker-end="url(#gArrow)"/>` + edgePill(p2, e.label) + `</g>`;
1239
2905
  }
1240
2906
  for (const n of nodes) {
1241
2907
  const r = rectFor2(n);
1242
- const st = dfdStyle(n.kind);
1243
- const k = (n.kind ?? "process").toLowerCase();
2908
+ const st2 = dfdStyle(n.kind);
2909
+ const k2 = (n.kind ?? "process").toLowerCase();
1244
2910
  let shape;
1245
- if (k === "process") {
1246
- shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="16" fill="${st.fill}" stroke="${st.stroke}" stroke-width="1.4"/>`;
1247
- } else if (k === "store" || k === "datastore") {
1248
- shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${st.fill}" stroke="none"/><line x1="${r.x}" y1="${r.y}" x2="${r.x + r.w}" y2="${r.y}" stroke="${st.stroke}" stroke-width="1.6"/><line x1="${r.x}" y1="${r.y + r.h}" x2="${r.x + r.w}" y2="${r.y + r.h}" stroke="${st.stroke}" stroke-width="1.6"/><line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.h}" stroke="${st.stroke}" stroke-width="1.6"/>`;
2911
+ if (k2 === "process") {
2912
+ shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="16" fill="${st2.fill}" stroke="${st2.stroke}" stroke-width="1.4"/>`;
2913
+ } else if (k2 === "store" || k2 === "datastore") {
2914
+ shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${st2.fill}" stroke="none"/><line x1="${r.x}" y1="${r.y}" x2="${r.x + r.w}" y2="${r.y}" stroke="${st2.stroke}" stroke-width="1.6"/><line x1="${r.x}" y1="${r.y + r.h}" x2="${r.x + r.w}" y2="${r.y + r.h}" stroke="${st2.stroke}" stroke-width="1.6"/><line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.h}" stroke="${st2.stroke}" stroke-width="1.6"/>`;
1249
2915
  } else {
1250
- shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${st.fill}" stroke="${st.stroke}" stroke-width="1.4"/>`;
2916
+ shape = `<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" fill="${st2.fill}" stroke="${st2.stroke}" stroke-width="1.4"/>`;
1251
2917
  }
1252
- const num = n.num !== void 0 && k === "process" ? `<text x="${r.x + 12}" y="${r.y + 18}" class="dfd-num" fill="${st.text}">${escapeHtml(n.num)}</text>` : "";
1253
- s += `<g filter="url(#gshadow)">${shape}${num}<text x="${r.x + r.w / 2}" y="${r.y + r.h / 2 + 4}" class="dfd-name" fill="${st.text}">${escapeHtml(n.name)}</text></g>`;
2918
+ const num = n.num !== void 0 && k2 === "process" ? `<text x="${r.x + 12}" y="${r.y + 18}" class="dfd-num" fill="${st2.text}">${escapeHtml(n.num)}</text>` : "";
2919
+ s += `<g filter="url(#gshadow)">${shape}${num}<text x="${r.x + r.w / 2}" y="${r.y + r.h / 2 + 4}" class="dfd-name" fill="${st2.text}">${escapeHtml(n.name)}</text></g>`;
1254
2920
  }
1255
2921
  s += `</svg>`;
1256
2922
  return diagramFrame(
@@ -1265,34 +2931,34 @@ function renderDfd(data) {
1265
2931
  }
1266
2932
 
1267
2933
  // src/blocks/journey.ts
1268
- function clamp01(v) {
1269
- if (v < 0) return 0;
1270
- if (v > 1) return 1;
1271
- return v;
2934
+ function clamp01(v2) {
2935
+ if (v2 < 0) return 0;
2936
+ if (v2 > 1) return 1;
2937
+ return v2;
1272
2938
  }
1273
2939
  function renderJourney(data) {
1274
2940
  const stages = data.stages ?? [];
1275
2941
  const rows = data.rows ?? [];
1276
2942
  const emotion = data.emotion ?? [];
1277
2943
  const n = Math.max(stages.length, 1);
1278
- const W = Math.max(380, n * 150);
1279
- const H = 92;
2944
+ const W2 = Math.max(380, n * 150);
2945
+ const H2 = 92;
1280
2946
  const pad = 20;
1281
- const colW = (W - pad * 2) / n;
2947
+ const colW = (W2 - pad * 2) / n;
1282
2948
  const ex = (i) => pad + colW * (i + 0.5);
1283
- const ey = (v) => H - 14 - (H - 30) * clamp01(v);
2949
+ const ey = (v2) => H2 - 14 - (H2 - 30) * clamp01(v2);
1284
2950
  const head = `<tr><th></th>` + stages.map((s) => `<th class="c">${escapeHtml(s.label)}</th>`).join("") + `</tr>`;
1285
2951
  const body = rows.map(
1286
2952
  (r) => `<tr><td class="lead">${escapeHtml(r.label)}</td>` + (r.cells ?? []).map((c) => `<td class="c">${escapeHtml(c)}</td>`).join("") + `</tr>`
1287
2953
  ).join("");
1288
2954
  let svg = "";
1289
2955
  if (emotion.length > 0) {
1290
- const points = emotion.map((v, i) => `${ex(i)},${ey(v)}`).join(" ");
1291
- const dots = emotion.map((v, i) => {
1292
- const fill = v >= 0.6 ? "#1f9747" : v <= 0.35 ? "#991b1b" : "#f7952c";
1293
- return `<circle cx="${ex(i)}" cy="${ey(v)}" r="5" fill="${fill}" stroke="#fff" stroke-width="1.5"/>`;
2956
+ const points = emotion.map((v2, i) => `${ex(i)},${ey(v2)}`).join(" ");
2957
+ const dots = emotion.map((v2, i) => {
2958
+ const fill = v2 >= 0.6 ? "#1f9747" : v2 <= 0.35 ? "#991b1b" : "#f7952c";
2959
+ return `<circle cx="${ex(i)}" cy="${ey(v2)}" r="5" fill="${fill}" stroke="#fff" stroke-width="1.5"/>`;
1294
2960
  }).join("");
1295
- svg = `<div style="margin-top:10px"><div style="font-size:10px;color:#6b7280;font-weight:700;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px">Emotion</div><svg viewBox="0 0 ${W} ${H}" style="width:100%" role="img"><title>Emotion curve</title><polyline points="${points}" fill="none" stroke="#0e54a1" stroke-width="2"/>` + dots + `</svg></div>`;
2961
+ svg = `<div style="margin-top:10px"><div style="font-size:10px;color:#6b7280;font-weight:700;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px">Emotion</div><svg viewBox="0 0 ${W2} ${H2}" style="width:100%" role="img"><title>Emotion curve</title><polyline points="${points}" fill="none" stroke="#0e54a1" stroke-width="2"/>` + dots + `</svg></div>`;
1296
2962
  }
1297
2963
  return `<div><table class="pres-table"><thead>${head}</thead><tbody>${body}</tbody></table>` + svg + `</div>`;
1298
2964
  }
@@ -1314,7 +2980,7 @@ function ganttColor(kind) {
1314
2980
  function renderGantt(data) {
1315
2981
  const periods = data.periods ?? [];
1316
2982
  const tasks = data.tasks ?? [];
1317
- const P = Math.max(periods.length, 1);
2983
+ const P2 = Math.max(periods.length, 1);
1318
2984
  const labelW = 156;
1319
2985
  const padX = 20;
1320
2986
  const padTop = 34;
@@ -1322,14 +2988,14 @@ function renderGantt(data) {
1322
2988
  const barH = 18;
1323
2989
  const colW = 64;
1324
2990
  const padBot = 14;
1325
- const width = labelW + padX * 2 + P * colW;
2991
+ const width = labelW + padX * 2 + P2 * colW;
1326
2992
  const height = padTop + tasks.length * rowH + padBot;
1327
2993
  const xCol = (i) => labelW + padX + i * colW;
1328
2994
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Schedule</title>`;
1329
2995
  for (let i = 0; i < periods.length; i++) {
1330
2996
  s += `<g><line x1="${xCol(i)}" y1="${padTop - 6}" x2="${xCol(i)}" y2="${height - padBot}" stroke="#eef0f3" stroke-width="1"/><text x="${xCol(i) + colW / 2}" y="${padTop - 12}" class="gantt-head">${escapeHtml(periods[i] ?? "")}</text></g>`;
1331
2997
  }
1332
- s += `<line x1="${xCol(P)}" y1="${padTop - 6}" x2="${xCol(P)}" y2="${height - padBot}" stroke="#eef0f3" stroke-width="1"/>`;
2998
+ s += `<line x1="${xCol(P2)}" y1="${padTop - 6}" x2="${xCol(P2)}" y2="${height - padBot}" stroke="#eef0f3" stroke-width="1"/>`;
1333
2999
  for (let i = 0; i < tasks.length; i++) {
1334
3000
  const t = tasks[i];
1335
3001
  if (t === void 0) continue;
@@ -1362,21 +3028,21 @@ function renderGraph(data) {
1362
3028
  const rectFor2 = (n) => {
1363
3029
  const cx = cxOf(n.col);
1364
3030
  const cy = cyOf(n.row);
1365
- const w = Math.max(98, n.label.length * 8 + 26);
1366
- return { x: cx - w / 2, y: cy - 20, w, h: 40, cx, cy };
3031
+ const w2 = Math.max(98, n.label.length * 8 + 26);
3032
+ return { x: cx - w2 / 2, y: cy - 20, w: w2, h: 40, cx, cy };
1367
3033
  };
1368
3034
  const byId = new Map(nodes.map((n) => [n.id, n]));
1369
3035
  const width = padX * 2 + cols * cellW + (cols - 1) * gapX;
1370
3036
  const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;
1371
3037
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Graph</title>`;
1372
3038
  for (const e of edges) {
1373
- const A = byId.get(e.from);
1374
- const B = byId.get(e.to);
1375
- if (!A || !B) continue;
1376
- const p = ortho(rectFor2(A), rectFor2(B));
3039
+ const A2 = byId.get(e.from);
3040
+ const B2 = byId.get(e.to);
3041
+ if (!A2 || !B2) continue;
3042
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
1377
3043
  const directed = (e.dir ?? "directed") !== "undirected";
1378
3044
  const markerAttr = directed ? ` marker-end="url(#gArrow)"` : "";
1379
- s += `<g><path d="${p.d}" fill="none" stroke="#6b7280" stroke-width="1.4"${markerAttr}/>` + edgePill(p, e.label) + `</g>`;
3045
+ s += `<g><path d="${p2.d}" fill="none" stroke="#6b7280" stroke-width="1.4"${markerAttr}/>` + edgePill(p2, e.label) + `</g>`;
1380
3046
  }
1381
3047
  for (const n of nodes) {
1382
3048
  const r = rectFor2(n);
@@ -1396,28 +3062,28 @@ function renderGraph(data) {
1396
3062
  }
1397
3063
 
1398
3064
  // src/blocks/quadrant.ts
1399
- function clamp012(v) {
1400
- if (v === void 0 || Number.isNaN(v)) return 0.5;
1401
- if (v < 0) return 0;
1402
- if (v > 1) return 1;
1403
- return v;
3065
+ function clamp012(v2) {
3066
+ if (v2 === void 0 || Number.isNaN(v2)) return 0.5;
3067
+ if (v2 < 0) return 0;
3068
+ if (v2 > 1) return 1;
3069
+ return v2;
1404
3070
  }
1405
3071
  function renderQuadrant(data) {
1406
- const W = 580;
1407
- const H = 440;
3072
+ const W2 = 580;
3073
+ const H2 = 440;
1408
3074
  const pad = 56;
1409
3075
  const x0 = pad;
1410
- const x1 = W - pad;
3076
+ const x1 = W2 - pad;
1411
3077
  const y0 = pad - 16;
1412
- const y1 = H - pad;
3078
+ const y1 = H2 - pad;
1413
3079
  const mx = (x0 + x1) / 2;
1414
3080
  const my = (y0 + y1) / 2;
1415
- const px = (v) => x0 + (x1 - x0) * clamp012(v);
1416
- const py = (v) => y1 - (y1 - y0) * clamp012(v);
3081
+ const px = (v2) => x0 + (x1 - x0) * clamp012(v2);
3082
+ const py = (v2) => y1 - (y1 - y0) * clamp012(v2);
1417
3083
  const items = data.items ?? [];
1418
3084
  const xA = data.xAxis ?? {};
1419
3085
  const yA = data.yAxis ?? {};
1420
- let s = `<svg viewBox="0 0 ${W} ${H}" role="img"><title>Quadrant</title>`;
3086
+ let s = `<svg viewBox="0 0 ${W2} ${H2}" role="img"><title>Quadrant</title>`;
1421
3087
  s += `<rect x="${x0}" y="${y0}" width="${x1 - x0}" height="${y1 - y0}" fill="#fafbfc" stroke="#e5e7eb"/>`;
1422
3088
  s += `<rect x="${mx}" y="${y0}" width="${x1 - mx}" height="${my - y0}" fill="#0e54a1" fill-opacity="0.04"/>`;
1423
3089
  s += `<line x1="${x0}" y1="${my}" x2="${x1}" y2="${my}" class="quad-axis" marker-end="url(#gArrow)"/>`;
@@ -1434,13 +3100,13 @@ function renderQuadrant(data) {
1434
3100
  s += `<text x="${x0 - 10}" y="${y0 + 6}" class="quad-end" text-anchor="end">${escapeHtml(yA.high)}</text>`;
1435
3101
  if (yA.low !== void 0)
1436
3102
  s += `<text x="${x0 - 10}" y="${y1}" class="quad-end" text-anchor="end">${escapeHtml(yA.low)}</text>`;
1437
- for (const it of items) {
1438
- const cx = px(it.x);
1439
- const cy = py(it.y);
3103
+ for (const it2 of items) {
3104
+ const cx = px(it2.x);
3105
+ const cy = py(it2.y);
1440
3106
  const left = cx > mx;
1441
3107
  const tx = cx + (left ? -12 : 12);
1442
3108
  const anchor = left ? "end" : "start";
1443
- s += `<g filter="url(#gshadow)"><circle cx="${cx}" cy="${cy}" r="7" fill="#f7952c" stroke="#fff" stroke-width="1.5"/><text x="${tx}" y="${cy + 4}" class="quad-pt-label" text-anchor="${anchor}">${escapeHtml(it.label)}</text></g>`;
3109
+ s += `<g filter="url(#gshadow)"><circle cx="${cx}" cy="${cy}" r="7" fill="#f7952c" stroke="#fff" stroke-width="1.5"/><text x="${tx}" y="${cy + 4}" class="quad-pt-label" text-anchor="${anchor}">${escapeHtml(it2.label)}</text></g>`;
1444
3110
  }
1445
3111
  s += `</svg>`;
1446
3112
  return diagramFrame(
@@ -1495,23 +3161,23 @@ function renderSwimlane(data) {
1495
3161
  const height = padTop + lanes.length * laneH + padBot;
1496
3162
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>Swimlane</title>`;
1497
3163
  for (let i = 0; i < lanes.length; i++) {
1498
- const L = lanes[i];
1499
- if (L === void 0) continue;
1500
- s += `<g><rect x="${padX}" y="${yLane(i)}" width="${width - padX * 2}" height="${laneH}" fill="${i % 2 ? "#fafafa" : "#fff"}" stroke="#e5e7eb"/><rect x="${padX}" y="${yLane(i)}" width="${labelW}" height="${laneH}" fill="#0e54a1"/><text x="${padX + 14}" y="${yLane(i) + laneH / 2 + 4}" class="sl-lane-label">${escapeHtml(L.label)}</text></g>`;
3164
+ const L2 = lanes[i];
3165
+ if (L2 === void 0) continue;
3166
+ s += `<g><rect x="${padX}" y="${yLane(i)}" width="${width - padX * 2}" height="${laneH}" fill="${i % 2 ? "#fafafa" : "#fff"}" stroke="#e5e7eb"/><rect x="${padX}" y="${yLane(i)}" width="${labelW}" height="${laneH}" fill="#0e54a1"/><text x="${padX + 14}" y="${yLane(i) + laneH / 2 + 4}" class="sl-lane-label">${escapeHtml(L2.label)}</text></g>`;
1501
3167
  }
1502
3168
  for (const lk of links) {
1503
- const A = byId.get(lk.from);
1504
- const B = byId.get(lk.to);
1505
- if (!A || !B) continue;
1506
- const p = ortho(rectFor2(A), rectFor2(B));
1507
- s += `<g><path d="${p.d}" fill="none" stroke="#1a1a2e" stroke-width="1.4" marker-end="url(#gArrow)"/>` + edgePill(p, lk.label) + `</g>`;
1508
- }
1509
- for (const st of steps) {
1510
- const r = rectFor2(st);
1511
- const c = laneColor(st.kind);
1512
- const lines = wrapText(st.label, 20, 2);
3169
+ const A2 = byId.get(lk.from);
3170
+ const B2 = byId.get(lk.to);
3171
+ if (!A2 || !B2) continue;
3172
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
3173
+ s += `<g><path d="${p2.d}" fill="none" stroke="#1a1a2e" stroke-width="1.4" marker-end="url(#gArrow)"/>` + edgePill(p2, lk.label) + `</g>`;
3174
+ }
3175
+ for (const st2 of steps) {
3176
+ const r = rectFor2(st2);
3177
+ const c = laneColor(st2.kind);
3178
+ const lines = wrapText(st2.label, 20, 2);
1513
3179
  const texts = lines.map(
1514
- (ln, j) => `<text x="${r.x + r.w / 2}" y="${r.y + r.h / 2 + 4 - (lines.length - 1) * 7 + j * 14}" class="sl-step" fill="${c.text}">${escapeHtml(ln)}</text>`
3180
+ (ln2, j2) => `<text x="${r.x + r.w / 2}" y="${r.y + r.h / 2 + 4 - (lines.length - 1) * 7 + j2 * 14}" class="sl-step" fill="${c.text}">${escapeHtml(ln2)}</text>`
1515
3181
  ).join("");
1516
3182
  s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="7" fill="${c.fill}" stroke="${c.stroke}" stroke-width="1.3"/>` + texts + `</g>`;
1517
3183
  }
@@ -1575,35 +3241,35 @@ function blockStyle(kind) {
1575
3241
  return { accent: "#374151", fill: "#fff", text: "#1a1a2e" };
1576
3242
  }
1577
3243
  }
1578
- function nodeGlyph(kind, x, y, c) {
1579
- const k = (kind ?? "").toLowerCase();
1580
- if (k === "store" || k === "db" || k === "database") {
1581
- return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x + 8}" cy="${y + 3}" rx="7" ry="3"/><path d="M${x + 1} ${y + 3} V ${y + 13}"/><path d="M${x + 15} ${y + 3} V ${y + 13}"/><path d="M${x + 1} ${y + 13} a 7 3 0 0 0 14 0"/></g>`;
3244
+ function nodeGlyph(kind, x2, y, c) {
3245
+ const k2 = (kind ?? "").toLowerCase();
3246
+ if (k2 === "store" || k2 === "db" || k2 === "database") {
3247
+ return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="3"/><path d="M${x2 + 1} ${y + 3} V ${y + 13}"/><path d="M${x2 + 15} ${y + 3} V ${y + 13}"/><path d="M${x2 + 1} ${y + 13} a 7 3 0 0 0 14 0"/></g>`;
1582
3248
  }
1583
- if (k === "bucket" || k === "blob" || k === "object") {
1584
- return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x + 8}" cy="${y + 3}" rx="7" ry="2.5"/><path d="M${x + 1.5} ${y + 3} L ${x + 3.5} ${y + 14} L ${x + 12.5} ${y + 14} L ${x + 14.5} ${y + 3}"/></g>`;
3249
+ if (k2 === "bucket" || k2 === "blob" || k2 === "object") {
3250
+ return `<g stroke="${c}" stroke-width="1.3" fill="none"><ellipse cx="${x2 + 8}" cy="${y + 3}" rx="7" ry="2.5"/><path d="M${x2 + 1.5} ${y + 3} L ${x2 + 3.5} ${y + 14} L ${x2 + 12.5} ${y + 14} L ${x2 + 14.5} ${y + 3}"/></g>`;
1585
3251
  }
1586
- if (k === "queue" || k === "topic") {
1587
- return `<g stroke="${c}" stroke-width="1.6"><path d="M${x + 2} ${y + 1} V ${y + 14}"/><path d="M${x + 8} ${y + 1} V ${y + 14}"/><path d="M${x + 14} ${y + 1} V ${y + 14}"/></g>`;
3252
+ if (k2 === "queue" || k2 === "topic") {
3253
+ return `<g stroke="${c}" stroke-width="1.6"><path d="M${x2 + 2} ${y + 1} V ${y + 14}"/><path d="M${x2 + 8} ${y + 1} V ${y + 14}"/><path d="M${x2 + 14} ${y + 1} V ${y + 14}"/></g>`;
1588
3254
  }
1589
- if (k === "firewall") {
1590
- return `<path d="M${x + 8} ${y} L ${x + 15} ${y + 3} V ${y + 9} Q ${x + 15} ${y + 14} ${x + 8} ${y + 16} Q ${x + 1} ${y + 14} ${x + 1} ${y + 9} V ${y + 3} Z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
3255
+ if (k2 === "firewall") {
3256
+ return `<path d="M${x2 + 8} ${y} L ${x2 + 15} ${y + 3} V ${y + 9} Q ${x2 + 15} ${y + 14} ${x2 + 8} ${y + 16} Q ${x2 + 1} ${y + 14} ${x2 + 1} ${y + 9} V ${y + 3} Z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
1591
3257
  }
1592
- if (k === "cache") {
1593
- const slab = (dy) => `<path d="M${x + 1} ${y + 5 + dy} L${x + 8} ${y + 2 + dy} L${x + 15} ${y + 5 + dy} L${x + 8} ${y + 8 + dy} Z" fill="none" stroke="${c}" stroke-width="1.2"/>`;
3258
+ if (k2 === "cache") {
3259
+ const slab = (dy) => `<path d="M${x2 + 1} ${y + 5 + dy} L${x2 + 8} ${y + 2 + dy} L${x2 + 15} ${y + 5 + dy} L${x2 + 8} ${y + 8 + dy} Z" fill="none" stroke="${c}" stroke-width="1.2"/>`;
1594
3260
  return `<g>${slab(0)}${slab(3.5)}${slab(7)}</g>`;
1595
3261
  }
1596
- if (k === "function" || k === "lambda") {
1597
- return `<text x="${x + 7}" y="${y + 14}" font-family="Georgia, serif" font-size="17" font-style="italic" font-weight="700" fill="${c}" text-anchor="middle">\u0192</text>`;
3262
+ if (k2 === "function" || k2 === "lambda") {
3263
+ return `<text x="${x2 + 7}" y="${y + 14}" font-family="Georgia, serif" font-size="17" font-style="italic" font-weight="700" fill="${c}" text-anchor="middle">\u0192</text>`;
1598
3264
  }
1599
- if (k === "cdn" || k === "external") {
1600
- return `<path d="M${x + 3} ${y + 13} a 4 4 0 0 1 0.5 -8 a 5 5 0 0 1 9.5 1.2 a 3 3 0 0 1 1 6.8 z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
3265
+ if (k2 === "cdn" || k2 === "external") {
3266
+ return `<path d="M${x2 + 3} ${y + 13} a 4 4 0 0 1 0.5 -8 a 5 5 0 0 1 9.5 1.2 a 3 3 0 0 1 1 6.8 z" fill="none" stroke="${c}" stroke-width="1.3"/>`;
1601
3267
  }
1602
- if (k === "gateway" || k === "lb") {
1603
- return `<g stroke="${c}" stroke-width="1.5" fill="none"><path d="M${x + 2} ${y + 1} L ${x + 8} ${y + 7} L ${x + 2} ${y + 13}"/><path d="M${x + 8} ${y + 1} L ${x + 14} ${y + 7} L ${x + 8} ${y + 13}"/></g>`;
3268
+ if (k2 === "gateway" || k2 === "lb") {
3269
+ return `<g stroke="${c}" stroke-width="1.5" fill="none"><path d="M${x2 + 2} ${y + 1} L ${x2 + 8} ${y + 7} L ${x2 + 2} ${y + 13}"/><path d="M${x2 + 8} ${y + 1} L ${x2 + 14} ${y + 7} L ${x2 + 8} ${y + 13}"/></g>`;
1604
3270
  }
1605
- if (k === "service" || k === "microservice" || k === "compute" || k === "container") {
1606
- return `<g stroke="${c}" stroke-width="1.3"><rect x="${x + 4}" y="${y + 1}" width="11" height="11" rx="1.5" fill="none"/><rect x="${x + 1}" y="${y + 4}" width="11" height="11" rx="1.5" fill="#fff"/></g>`;
3271
+ if (k2 === "service" || k2 === "microservice" || k2 === "compute" || k2 === "container") {
3272
+ return `<g stroke="${c}" stroke-width="1.3"><rect x="${x2 + 4}" y="${y + 1}" width="11" height="11" rx="1.5" fill="none"/><rect x="${x2 + 1}" y="${y + 4}" width="11" height="11" rx="1.5" fill="#fff"/></g>`;
1607
3273
  }
1608
3274
  return "";
1609
3275
  }
@@ -1763,42 +3429,42 @@ function renderC4(data) {
1763
3429
  const minY = Math.min(...internals.map((r) => r.y)) - 26;
1764
3430
  const maxX = Math.max(...internals.map((r) => r.x + r.w)) + 16;
1765
3431
  const maxY = Math.max(...internals.map((r) => r.y + r.h)) + 16;
1766
- const w = Math.max(120, data.boundary.label.length * 6.2);
1767
- boundarySvg = `<g><rect x="${minX}" y="${minY}" width="${maxX - minX}" height="${maxY - minY}" rx="12" class="c4-boundary"/><rect x="${minX + 12}" y="${minY - 8}" width="${w}" height="16" fill="#fff"/><text x="${minX + 16}" y="${minY + 4}" class="c4-boundary-label">${escapeHtml(data.boundary.label)}</text></g>`;
3432
+ const w2 = Math.max(120, data.boundary.label.length * 6.2);
3433
+ boundarySvg = `<g><rect x="${minX}" y="${minY}" width="${maxX - minX}" height="${maxY - minY}" rx="12" class="c4-boundary"/><rect x="${minX + 12}" y="${minY - 8}" width="${w2}" height="16" fill="#fff"/><text x="${minX + 16}" y="${minY + 4}" class="c4-boundary-label">${escapeHtml(data.boundary.label)}</text></g>`;
1768
3434
  }
1769
3435
  }
1770
3436
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>C4 diagram</title>${boundarySvg}`;
1771
3437
  for (const e of edges) {
1772
- const A = byId.get(e.from);
1773
- const B = byId.get(e.to);
1774
- if (!A || !B) continue;
1775
- const p = ortho(rectFor2(A), rectFor2(B));
1776
- const st = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? {
3438
+ const A2 = byId.get(e.from);
3439
+ const B2 = byId.get(e.to);
3440
+ if (!A2 || !B2) continue;
3441
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
3442
+ const st2 = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? {
1777
3443
  stroke: "#1a1a2e",
1778
3444
  sw: 1.4,
1779
3445
  dash: "",
1780
3446
  marker: "gArrow",
1781
3447
  err: false
1782
3448
  };
1783
- s += `<g><path d="${p.d}" fill="none" stroke="${st.stroke}" stroke-width="${st.sw}" stroke-dasharray="${st.dash}" marker-end="url(#${st.marker})"/>` + edgePill(p, e.label, st.err) + `</g>`;
3449
+ s += `<g><path d="${p2.d}" fill="none" stroke="${st2.stroke}" stroke-width="${st2.sw}" stroke-dasharray="${st2.dash}" marker-end="url(#${st2.marker})"/>` + edgePill(p2, e.label, st2.err) + `</g>`;
1784
3450
  }
1785
3451
  for (const n of nodes) {
1786
3452
  const r = rectFor2(n);
1787
- const st = c4Style(n);
3453
+ const st2 = c4Style(n);
1788
3454
  const px = r.x + 16;
1789
3455
  const desc = wrapText(n.desc, 30, 2);
1790
- const strokeWidth = st.solid === true ? 0 : 1.2;
1791
- const strokeAttr = st.solid === true ? "none" : st.accent;
1792
- const dashAttr = st.dash !== void 0 ? ` stroke-dasharray="${st.dash}"` : "";
1793
- const stripe = st.solid === true ? "" : `<rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st.accent}"/>`;
1794
- const personGlyph = n.kind === "person" ? `<g fill="${st.text}"><circle cx="${px + 6}" cy="${r.y + 19}" r="6"/><path d="M ${px} ${r.y + 34} a 6 7 0 0 1 12 0 z"/></g>` : "";
3456
+ const strokeWidth = st2.solid === true ? 0 : 1.2;
3457
+ const strokeAttr = st2.solid === true ? "none" : st2.accent;
3458
+ const dashAttr = st2.dash !== void 0 ? ` stroke-dasharray="${st2.dash}"` : "";
3459
+ const stripe = st2.solid === true ? "" : `<rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st2.accent}"/>`;
3460
+ const personGlyph = n.kind === "person" ? `<g fill="${st2.text}"><circle cx="${px + 6}" cy="${r.y + 19}" r="6"/><path d="M ${px} ${r.y + 34} a 6 7 0 0 1 12 0 z"/></g>` : "";
1795
3461
  const chipX = n.kind === "person" ? px + 22 : px;
1796
- const chipFill = st.solid === true ? st.sub : st.accent;
1797
- const techLine = n.tech !== void 0 ? `<text x="${px}" y="${r.y + 60}" class="c4-tech" fill="${st.sub}">${escapeHtml(n.tech)}</text>` : "";
3462
+ const chipFill = st2.solid === true ? st2.sub : st2.accent;
3463
+ const techLine = n.tech !== void 0 ? `<text x="${px}" y="${r.y + 60}" class="c4-tech" fill="${st2.sub}">${escapeHtml(n.tech)}</text>` : "";
1798
3464
  const descLines = desc.map(
1799
- (ln, j) => `<text x="${px}" y="${r.y + 77 + j * 13}" class="c4-desc" fill="${st.sub}">${escapeHtml(ln)}</text>`
3465
+ (ln2, j2) => `<text x="${px}" y="${r.y + 77 + j2 * 13}" class="c4-desc" fill="${st2.sub}">${escapeHtml(ln2)}</text>`
1800
3466
  ).join("");
1801
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="10" fill="${st.fill}" stroke="${strokeAttr}" stroke-width="${strokeWidth}"${dashAttr}/>` + stripe + personGlyph + `<text x="${chipX}" y="${r.y + 22}" class="c4-chip" fill="${chipFill}">${escapeHtml(st.chip)}</text><text x="${px}" y="${r.y + 44}" class="c4-name" fill="${st.text}">${escapeHtml(n.name)}</text>` + techLine + descLines + `</g>`;
3467
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="10" fill="${st2.fill}" stroke="${strokeAttr}" stroke-width="${strokeWidth}"${dashAttr}/>` + stripe + personGlyph + `<text x="${chipX}" y="${r.y + 22}" class="c4-chip" fill="${chipFill}">${escapeHtml(st2.chip)}</text><text x="${px}" y="${r.y + 44}" class="c4-name" fill="${st2.text}">${escapeHtml(n.name)}</text>` + techLine + descLines + `</g>`;
1802
3468
  }
1803
3469
  s += `</svg>`;
1804
3470
  const legend = `<div class="legend">` + LEGEND.map(
@@ -1871,14 +3537,14 @@ function renderUml(data) {
1871
3537
  const height = acc - gapY + padBot;
1872
3538
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>UML class diagram</title><defs><marker id="umlTri" viewBox="0 0 14 14" refX="13" refY="7" markerWidth="15" markerHeight="15" orient="auto-start-reverse"><path d="M1,1 L13,7 L1,13 z" fill="#fff" stroke="#1a1a2e" stroke-width="1.2"/></marker><marker id="umlDiaF" viewBox="0 0 20 12" refX="19" refY="6" markerWidth="20" markerHeight="12" orient="auto-start-reverse"><path d="M1,6 L10,1 L19,6 L10,11 z" fill="#1a1a2e"/></marker><marker id="umlDiaH" viewBox="0 0 20 12" refX="19" refY="6" markerWidth="20" markerHeight="12" orient="auto-start-reverse"><path d="M1,6 L10,1 L19,6 L10,11 z" fill="#fff" stroke="#1a1a2e" stroke-width="1.2"/></marker><marker id="umlOpen" viewBox="0 0 12 12" refX="10" refY="6" markerWidth="12" markerHeight="12" orient="auto-start-reverse"><path d="M1,1 L11,6 L1,11" fill="none" stroke="#1a1a2e" stroke-width="1.3"/></marker></defs>`;
1873
3539
  for (const rl of rels) {
1874
- const A = byId.get(rl.from);
1875
- const B = byId.get(rl.to);
1876
- if (!A || !B) continue;
1877
- const p = ortho(rectFor2(A), rectFor2(B));
1878
- const st = umlRel(rl.kind);
1879
- const start = st.start !== void 0 ? ` marker-start="url(#${st.start})"` : "";
1880
- const end = st.end !== void 0 ? ` marker-end="url(#${st.end})"` : "";
1881
- s += `<g><path d="${p.d}" fill="none" stroke="#1a1a2e" stroke-width="1.3" stroke-dasharray="${st.dash}"${start}${end}/>` + edgePill(p, rl.label) + `</g>`;
3540
+ const A2 = byId.get(rl.from);
3541
+ const B2 = byId.get(rl.to);
3542
+ if (!A2 || !B2) continue;
3543
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
3544
+ const st2 = umlRel(rl.kind);
3545
+ const start = st2.start !== void 0 ? ` marker-start="url(#${st2.start})"` : "";
3546
+ const end = st2.end !== void 0 ? ` marker-end="url(#${st2.end})"` : "";
3547
+ s += `<g><path d="${p2.d}" fill="none" stroke="#1a1a2e" stroke-width="1.3" stroke-dasharray="${st2.dash}"${start}${end}/>` + edgePill(p2, rl.label) + `</g>`;
1882
3548
  }
1883
3549
  for (const c of classes) {
1884
3550
  const r = rectFor2(c);
@@ -1887,10 +3553,10 @@ function renderUml(data) {
1887
3553
  const nameY = r.y + (c.stereotype !== void 0 ? 24 : 19);
1888
3554
  const stereo = c.stereotype !== void 0 ? `<text x="${r.x + r.w / 2}" y="${r.y + 13}" class="uml-stereo">\xAB${escapeHtml(c.stereotype)}\xBB</text>` : "";
1889
3555
  const attrs = (c.attrs ?? []).map(
1890
- (a, j) => `<text x="${r.x + 10}" y="${r.y + hh + 14 + j * rowH}" class="uml-row">${escapeHtml(a)}</text>`
3556
+ (a, j2) => `<text x="${r.x + 10}" y="${r.y + hh + 14 + j2 * rowH}" class="uml-row">${escapeHtml(a)}</text>`
1891
3557
  ).join("");
1892
3558
  const methods = (c.methods ?? []).map(
1893
- (m, j) => `<text x="${r.x + 10}" y="${r.y + hh + aH + 14 + j * rowH}" class="uml-row">${escapeHtml(m)}</text>`
3559
+ (m, j2) => `<text x="${r.x + 10}" y="${r.y + hh + aH + 14 + j2 * rowH}" class="uml-row">${escapeHtml(m)}</text>`
1894
3560
  ).join("");
1895
3561
  s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="3" fill="#fff" stroke="#0e54a1" stroke-width="1.3"/>` + stereo + `<text x="${r.x + r.w / 2}" y="${nameY}" class="uml-name">${escapeHtml(c.name)}</text><line x1="${r.x}" y1="${r.y + hh}" x2="${r.x + r.w}" y2="${r.y + hh}" class="uml-sep"/>` + attrs + `<line x1="${r.x}" y1="${r.y + hh + aH}" x2="${r.x + r.w}" y2="${r.y + hh + aH}" class="uml-sep"/>` + methods + `</g>`;
1896
3562
  }
@@ -1971,20 +3637,20 @@ function renderMece(data) {
1971
3637
  }
1972
3638
  for (const n of nodes) {
1973
3639
  if (!pos.has(n.id)) continue;
1974
- const x = xOf(n.id);
3640
+ const x2 = xOf(n.id);
1975
3641
  const y = yOf(n.id);
1976
- const st = meceStyle(depth.get(n.id) ?? 0);
1977
- const stroke = st.solid === true ? "none" : st.accent;
1978
- const stripe = st.solid === true ? "" : `<rect x="${x}" y="${y}" width="5" height="${nodeH}" rx="2" fill="${st.accent}"/>`;
1979
- const labelX = x + (st.solid === true ? nodeW / 2 : 14);
1980
- const anchor = st.solid === true ? "middle" : "start";
1981
- const lines = wrapText(n.label, st.solid === true ? 22 : 20, n.note !== void 0 ? 1 : 2);
3642
+ const st2 = meceStyle(depth.get(n.id) ?? 0);
3643
+ const stroke = st2.solid === true ? "none" : st2.accent;
3644
+ const stripe = st2.solid === true ? "" : `<rect x="${x2}" y="${y}" width="5" height="${nodeH}" rx="2" fill="${st2.accent}"/>`;
3645
+ const labelX = x2 + (st2.solid === true ? nodeW / 2 : 14);
3646
+ const anchor = st2.solid === true ? "middle" : "start";
3647
+ const lines = wrapText(n.label, st2.solid === true ? 22 : 20, n.note !== void 0 ? 1 : 2);
1982
3648
  const startY = lines.length === 2 ? y + 22 : y + (n.note !== void 0 ? 22 : 30);
1983
3649
  const labelTexts = lines.map(
1984
- (ln, j) => `<text x="${labelX}" y="${startY + j * 14}" class="blk-name" fill="${st.text}" text-anchor="${anchor}">${escapeHtml(ln)}</text>`
3650
+ (ln2, j2) => `<text x="${labelX}" y="${startY + j2 * 14}" class="blk-name" fill="${st2.text}" text-anchor="${anchor}">${escapeHtml(ln2)}</text>`
1985
3651
  ).join("");
1986
- const note = n.note !== void 0 ? `<text x="${labelX}" y="${y + 38}" class="ft-note" fill="${st.solid === true ? "#cfe0f3" : st.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
1987
- s += `<g filter="url(#gshadow)"><rect x="${x}" y="${y}" width="${nodeW}" height="${nodeH}" rx="6" fill="${st.fill}" stroke="${stroke}" stroke-width="1.3"/>` + stripe + labelTexts + note + `</g>`;
3652
+ const note = n.note !== void 0 ? `<text x="${labelX}" y="${y + 38}" class="ft-note" fill="${st2.solid === true ? "#cfe0f3" : st2.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
3653
+ s += `<g filter="url(#gshadow)"><rect x="${x2}" y="${y}" width="${nodeW}" height="${nodeH}" rx="6" fill="${st2.fill}" stroke="${stroke}" stroke-width="1.3"/>` + stripe + labelTexts + note + `</g>`;
1988
3654
  }
1989
3655
  s += `</svg>`;
1990
3656
  return diagramFrame(
@@ -2082,20 +3748,20 @@ function renderFrontend(data) {
2082
3748
  }
2083
3749
  for (const n of nodes) {
2084
3750
  if (!pos.has(n.id)) continue;
2085
- const x = xOf(n.id);
3751
+ const x2 = xOf(n.id);
2086
3752
  const y = yOf(n.id);
2087
- const st = ftStyle(n.kind);
2088
- const stroke = st.solid === true ? "none" : st.accent;
2089
- const stripe = st.solid === true ? "" : `<rect x="${x}" y="${y}" width="5" height="${nodeH}" rx="2" fill="${st.accent}"/>`;
2090
- const labelX = x + (st.solid === true ? nodeW / 2 : 14);
2091
- const anchor = st.solid === true ? "middle" : "start";
2092
- const lines = wrapText(n.name, st.solid === true ? 20 : 18, n.note !== void 0 ? 1 : 2);
3753
+ const st2 = ftStyle(n.kind);
3754
+ const stroke = st2.solid === true ? "none" : st2.accent;
3755
+ const stripe = st2.solid === true ? "" : `<rect x="${x2}" y="${y}" width="5" height="${nodeH}" rx="2" fill="${st2.accent}"/>`;
3756
+ const labelX = x2 + (st2.solid === true ? nodeW / 2 : 14);
3757
+ const anchor = st2.solid === true ? "middle" : "start";
3758
+ const lines = wrapText(n.name, st2.solid === true ? 20 : 18, n.note !== void 0 ? 1 : 2);
2093
3759
  const startY = lines.length === 2 ? y + 25 : y + (n.note !== void 0 ? 25 : 33);
2094
3760
  const labelTexts = lines.map(
2095
- (ln, j) => `<text x="${labelX}" y="${startY + j * 14}" class="blk-name" fill="${st.text}" text-anchor="${anchor}">${escapeHtml(ln)}</text>`
3761
+ (ln2, j2) => `<text x="${labelX}" y="${startY + j2 * 14}" class="blk-name" fill="${st2.text}" text-anchor="${anchor}">${escapeHtml(ln2)}</text>`
2096
3762
  ).join("");
2097
- const note = n.note !== void 0 ? `<text x="${labelX}" y="${y + 41}" class="ft-note" fill="${st.solid === true ? "#cfe0f3" : st.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
2098
- s += `<g filter="url(#gshadow)"><rect x="${x}" y="${y}" width="${nodeW}" height="${nodeH}" rx="8" fill="${st.fill}" stroke="${stroke}" stroke-width="1.2"/>` + stripe + labelTexts + note + `</g>`;
3763
+ const note = n.note !== void 0 ? `<text x="${labelX}" y="${y + 41}" class="ft-note" fill="${st2.solid === true ? "#cfe0f3" : st2.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
3764
+ s += `<g filter="url(#gshadow)"><rect x="${x2}" y="${y}" width="${nodeW}" height="${nodeH}" rx="8" fill="${st2.fill}" stroke="${stroke}" stroke-width="1.2"/>` + stripe + labelTexts + note + `</g>`;
2099
3765
  }
2100
3766
  s += `</svg>`;
2101
3767
  return diagramFrame(
@@ -2164,36 +3830,36 @@ function renderCluster(data) {
2164
3830
  s += `<g><rect x="${cb.x}" y="${cb.y}" width="${cb.w}" height="${cb.h}" rx="12" fill="#0e54a1" fill-opacity="0.035" stroke="#0e54a1" stroke-width="1.4" stroke-dasharray="8 5"/><rect x="${cb.x}" y="${cb.y}" width="${cb.w}" height="${cHeader}" rx="12" fill="#0e54a1"/><rect x="${cb.x}" y="${cb.y + cHeader - 12}" width="${cb.w}" height="12" fill="#0e54a1"/><text x="${cb.x + 16}" y="${cb.y + 21}" class="cl-head">${escapeHtml(cb.c.label)}</text>` + kindLabel + `</g>`;
2165
3831
  }
2166
3832
  for (const e of edges) {
2167
- const A = rects.get(e.from);
2168
- const B = rects.get(e.to);
2169
- if (!A || !B) continue;
2170
- const p = ortho(A, B);
2171
- const st = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? {
3833
+ const A2 = rects.get(e.from);
3834
+ const B2 = rects.get(e.to);
3835
+ if (!A2 || !B2) continue;
3836
+ const p2 = ortho(A2, B2);
3837
+ const st2 = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? {
2172
3838
  stroke: "#1a1a2e",
2173
3839
  sw: 1.4,
2174
3840
  dash: "",
2175
3841
  marker: "gArrow",
2176
3842
  err: false
2177
3843
  };
2178
- s += `<g><path d="${p.d}" fill="none" stroke="${st.stroke}" stroke-width="${st.sw}" stroke-dasharray="${st.dash}" marker-end="url(#${st.marker})"/>` + edgePill(p, e.label, st.err) + `</g>`;
3844
+ s += `<g><path d="${p2.d}" fill="none" stroke="${st2.stroke}" stroke-width="${st2.sw}" stroke-dasharray="${st2.dash}" marker-end="url(#${st2.marker})"/>` + edgePill(p2, e.label, st2.err) + `</g>`;
2179
3845
  }
2180
3846
  for (const sv of services) {
2181
3847
  const r = rects.get(sv.id);
2182
3848
  if (r === void 0) continue;
2183
- const st = blockStyle(sv.kind);
2184
- const gl = nodeGlyph(sv.kind, r.x + 14, r.y + 14, st.accent);
3849
+ const st2 = blockStyle(sv.kind);
3850
+ const gl = nodeGlyph(sv.kind, r.x + 14, r.y + 14, st2.accent);
2185
3851
  const nx = gl.length > 0 ? r.x + 38 : r.x + 14;
2186
3852
  const reps = sv.replicas ?? 0;
2187
- const techLine = sv.tech !== void 0 ? `<text x="${nx}" y="${r.y + 42}" class="blk-tech" fill="${st.accent}">${escapeHtml(sv.tech)}</text>` : "";
3853
+ const techLine = sv.tech !== void 0 ? `<text x="${nx}" y="${r.y + 42}" class="blk-tech" fill="${st2.accent}">${escapeHtml(sv.tech)}</text>` : "";
2188
3854
  const repIndicator = reps > 0 ? (() => {
2189
3855
  const shown = Math.min(reps, 5);
2190
3856
  let bars = "";
2191
- for (let j = 0; j < shown; j++) {
2192
- bars += `<rect x="${r.x + 12 + j * 8}" y="${r.y + r.h - 14}" width="5" height="8" rx="1" fill="${st.accent}" opacity="0.7"/>`;
3857
+ for (let j2 = 0; j2 < shown; j2++) {
3858
+ bars += `<rect x="${r.x + 12 + j2 * 8}" y="${r.y + r.h - 14}" width="5" height="8" rx="1" fill="${st2.accent}" opacity="0.7"/>`;
2193
3859
  }
2194
- return `<g>` + bars + `<text x="${r.x + 12 + shown * 8 + 4}" y="${r.y + r.h - 7}" class="blk-tech" fill="${st.accent}">\xD7${reps}</text></g>`;
3860
+ return `<g>` + bars + `<text x="${r.x + 12 + shown * 8 + 4}" y="${r.y + r.h - 7}" class="blk-tech" fill="${st2.accent}">\xD7${reps}</text></g>`;
2195
3861
  })() : "";
2196
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="8" fill="${st.fill}" stroke="${st.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st.accent}"/>` + gl + `<text x="${nx}" y="${r.y + (sv.tech !== void 0 ? 26 : 30)}" class="blk-name" fill="${st.text}" style="font-size:12px">${escapeHtml(sv.label)}</text>` + techLine + repIndicator + `</g>`;
3862
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="8" fill="${st2.fill}" stroke="${st2.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st2.accent}"/>` + gl + `<text x="${nx}" y="${r.y + (sv.tech !== void 0 ? 26 : 30)}" class="blk-name" fill="${st2.text}" style="font-size:12px">${escapeHtml(sv.label)}</text>` + techLine + repIndicator + `</g>`;
2197
3863
  }
2198
3864
  s += `</svg>`;
2199
3865
  return diagramFrame(
@@ -2267,21 +3933,21 @@ function renderGrid(data) {
2267
3933
  s += `<g>${zone}${label}</g>`;
2268
3934
  }
2269
3935
  for (const e of edges) {
2270
- const A = byId.get(e.from);
2271
- const B = byId.get(e.to);
2272
- if (!A || !B) continue;
2273
- const p = ortho(rectFor2(A), rectFor2(B));
2274
- const st = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? FALLBACK_EDGE;
2275
- s += `<g><path d="${p.d}" fill="none" stroke="${st.stroke}" stroke-width="${st.sw}" stroke-dasharray="${st.dash}" marker-end="url(#${st.marker})"/>` + edgePill(p, e.label, st.err) + `</g>`;
3936
+ const A2 = byId.get(e.from);
3937
+ const B2 = byId.get(e.to);
3938
+ if (!A2 || !B2) continue;
3939
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
3940
+ const st2 = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? FALLBACK_EDGE;
3941
+ s += `<g><path d="${p2.d}" fill="none" stroke="${st2.stroke}" stroke-width="${st2.sw}" stroke-dasharray="${st2.dash}" marker-end="url(#${st2.marker})"/>` + edgePill(p2, e.label, st2.err) + `</g>`;
2276
3942
  }
2277
3943
  for (const n of nodes) {
2278
3944
  const r = rectFor2(n);
2279
- const st = blockStyle(n.kind);
2280
- const gl = nodeGlyph(n.kind, r.x + 16, r.y + 16, st.accent);
3945
+ const st2 = blockStyle(n.kind);
3946
+ const gl = nodeGlyph(n.kind, r.x + 16, r.y + 16, st2.accent);
2281
3947
  const nx = gl.length > 0 ? r.x + 42 : r.x + 16;
2282
- const chip = gl.length === 0 && n.kind !== void 0 ? `<text x="${r.x + 16}" y="${r.y + 22}" class="blk-chip" fill="${st.accent}">${escapeHtml(n.kind)}</text>` : "";
2283
- const tech = n.tech !== void 0 ? `<text x="${nx}" y="${r.y + (gl.length > 0 ? 50 : 60)}" class="blk-tech" fill="${st.accent}">${escapeHtml(n.tech)}</text>` : "";
2284
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="9" fill="${st.fill}" stroke="${st.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st.accent}"/>` + gl + chip + `<text x="${nx}" y="${r.y + (gl.length > 0 ? 34 : 44)}" class="blk-name" fill="${st.text}">${escapeHtml(n.name)}</text>` + tech + `</g>`;
3948
+ const chip = gl.length === 0 && n.kind !== void 0 ? `<text x="${r.x + 16}" y="${r.y + 22}" class="blk-chip" fill="${st2.accent}">${escapeHtml(n.kind)}</text>` : "";
3949
+ const tech = n.tech !== void 0 ? `<text x="${nx}" y="${r.y + (gl.length > 0 ? 50 : 60)}" class="blk-tech" fill="${st2.accent}">${escapeHtml(n.tech)}</text>` : "";
3950
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="9" fill="${st2.fill}" stroke="${st2.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st2.accent}"/>` + gl + chip + `<text x="${nx}" y="${r.y + (gl.length > 0 ? 34 : 44)}" class="blk-name" fill="${st2.text}">${escapeHtml(n.name)}</text>` + tech + `</g>`;
2285
3951
  }
2286
3952
  s += `</svg>`;
2287
3953
  return s;
@@ -2291,7 +3957,7 @@ function renderLayered(data) {
2291
3957
  const nodes = data.nodes ?? [];
2292
3958
  const edges = data.edges ?? [];
2293
3959
  const byLayer = layers.map(
2294
- (_, i) => nodes.filter((n) => (n.layer ?? 0) === i)
3960
+ (_2, i) => nodes.filter((n) => (n.layer ?? 0) === i)
2295
3961
  );
2296
3962
  const outerPad = 28;
2297
3963
  const titleH = data.systemLabel !== void 0 ? 32 : 16;
@@ -2315,9 +3981,9 @@ function renderLayered(data) {
2315
3981
  const rects = /* @__PURE__ */ new Map();
2316
3982
  byLayer.forEach((arr, i) => {
2317
3983
  const startX = contentX + (bandInnerW - rowW(arr.length)) / 2;
2318
- arr.forEach((n, j) => {
3984
+ arr.forEach((n, j2) => {
2319
3985
  rects.set(n.id, {
2320
- x: startX + j * (nodeW + nodeGap),
3986
+ x: startX + j2 * (nodeW + nodeGap),
2321
3987
  y: bandY(i) + bandPadY,
2322
3988
  w: nodeW,
2323
3989
  h: nodeH
@@ -2329,26 +3995,26 @@ function renderLayered(data) {
2329
3995
  s += `<text x="${outerPad + 14}" y="${outerPad + 18}" class="grp-label" fill="#0e54a1">${escapeHtml(data.systemLabel)}</text>`;
2330
3996
  }
2331
3997
  for (let i = 0; i < layers.length; i++) {
2332
- const L = layers[i];
2333
- if (L === void 0) continue;
2334
- s += `<g><rect x="${innerX}" y="${bandY(i)}" width="${labelW + bandInnerW}" height="${bandH}" rx="6" fill="#f3f4f6" stroke="#d1d5db"/><rect x="${innerX}" y="${bandY(i)}" width="${labelW}" height="${bandH}" rx="6" fill="#0e54a1"/><rect x="${innerX + labelW - 8}" y="${bandY(i)}" width="8" height="${bandH}" fill="#0e54a1"/><text x="${innerX + 14}" y="${bandY(i) + bandH / 2 + 4}" class="layer-label">${escapeHtml(L.label)}</text></g>`;
3998
+ const L2 = layers[i];
3999
+ if (L2 === void 0) continue;
4000
+ s += `<g><rect x="${innerX}" y="${bandY(i)}" width="${labelW + bandInnerW}" height="${bandH}" rx="6" fill="#f3f4f6" stroke="#d1d5db"/><rect x="${innerX}" y="${bandY(i)}" width="${labelW}" height="${bandH}" rx="6" fill="#0e54a1"/><rect x="${innerX + labelW - 8}" y="${bandY(i)}" width="8" height="${bandH}" fill="#0e54a1"/><text x="${innerX + 14}" y="${bandY(i) + bandH / 2 + 4}" class="layer-label">${escapeHtml(L2.label)}</text></g>`;
2335
4001
  }
2336
4002
  for (const e of edges) {
2337
- const A = rects.get(e.from);
2338
- const B = rects.get(e.to);
2339
- if (!A || !B) continue;
2340
- const p = ortho(A, B);
2341
- const st = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? FALLBACK_EDGE;
2342
- s += `<g><path d="${p.d}" fill="none" stroke="${st.stroke}" stroke-width="${st.sw}" stroke-dasharray="${st.dash}" marker-end="url(#${st.marker})"/>` + edgePill(p, e.label, st.err) + `</g>`;
4003
+ const A2 = rects.get(e.from);
4004
+ const B2 = rects.get(e.to);
4005
+ if (!A2 || !B2) continue;
4006
+ const p2 = ortho(A2, B2);
4007
+ const st2 = GEDGE[e.kind ?? "solid"] ?? GEDGE["solid"] ?? FALLBACK_EDGE;
4008
+ s += `<g><path d="${p2.d}" fill="none" stroke="${st2.stroke}" stroke-width="${st2.sw}" stroke-dasharray="${st2.dash}" marker-end="url(#${st2.marker})"/>` + edgePill(p2, e.label, st2.err) + `</g>`;
2343
4009
  }
2344
4010
  for (const n of nodes) {
2345
4011
  const r = rects.get(n.id);
2346
4012
  if (r === void 0) continue;
2347
- const st = blockStyle(n.kind);
2348
- const gl = nodeGlyph(n.kind, r.x + 12, r.y + 12, st.accent);
4013
+ const st2 = blockStyle(n.kind);
4014
+ const gl = nodeGlyph(n.kind, r.x + 12, r.y + 12, st2.accent);
2349
4015
  const nx = gl.length > 0 ? r.x + 34 : r.x + 14;
2350
- const tech = n.tech !== void 0 ? `<text x="${nx}" y="${r.y + 42}" class="blk-tech" fill="${st.accent}">${escapeHtml(n.tech)}</text>` : "";
2351
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="8" fill="${st.fill}" stroke="${st.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st.accent}"/>` + gl + `<text x="${nx}" y="${r.y + (n.tech !== void 0 ? 26 : 33)}" class="blk-name" fill="${st.text}">${escapeHtml(n.name)}</text>` + tech + `</g>`;
4016
+ const tech = n.tech !== void 0 ? `<text x="${nx}" y="${r.y + 42}" class="blk-tech" fill="${st2.accent}">${escapeHtml(n.tech)}</text>` : "";
4017
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="8" fill="${st2.fill}" stroke="${st2.accent}" stroke-width="1.2"/><rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st2.accent}"/>` + gl + `<text x="${nx}" y="${r.y + (n.tech !== void 0 ? 26 : 33)}" class="blk-name" fill="${st2.text}">${escapeHtml(n.name)}</text>` + tech + `</g>`;
2352
4018
  }
2353
4019
  s += `</svg>`;
2354
4020
  return s;
@@ -2528,28 +4194,28 @@ function renderFelogicGraph(data, frame) {
2528
4194
  s += `<g><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="10" fill="${col}" fill-opacity="0.05" stroke="${col}" stroke-opacity="0.5" stroke-width="1.2" stroke-dasharray="7 5"/><text x="${r.x + 14}" y="${r.y + 15}" class="grp-label" fill="${col}">${escapeHtml(g.label)}</text></g>`;
2529
4195
  }
2530
4196
  for (const e of edges) {
2531
- const A = byId.get(e.from);
2532
- const B = byId.get(e.to);
2533
- if (!A || !B) continue;
2534
- const p = ortho(rectFor2(A), rectFor2(B));
2535
- const st = feEdge(e.kind);
2536
- s += `<g><path d="${p.d}" fill="none" stroke="${st.stroke}" stroke-width="${st.sw}" stroke-dasharray="${st.dash}" marker-end="url(#${st.marker})"/>` + edgePill(p, e.label) + `</g>`;
4197
+ const A2 = byId.get(e.from);
4198
+ const B2 = byId.get(e.to);
4199
+ if (!A2 || !B2) continue;
4200
+ const p2 = ortho(rectFor2(A2), rectFor2(B2));
4201
+ const st2 = feEdge(e.kind);
4202
+ s += `<g><path d="${p2.d}" fill="none" stroke="${st2.stroke}" stroke-width="${st2.sw}" stroke-dasharray="${st2.dash}" marker-end="url(#${st2.marker})"/>` + edgePill(p2, e.label) + `</g>`;
2537
4203
  }
2538
4204
  for (const n of nodes) {
2539
4205
  const r = rectFor2(n);
2540
- const st = feStyle(n.kind);
2541
- const k = (n.kind ?? "").toLowerCase();
2542
- const gl = GLYPH_KINDS.has(k) ? nodeGlyph(GLYPH_REMAP[k] ?? k, r.x + 16, r.y + 16, st.accent) : "";
2543
- const nx = st.solid === true ? r.x + r.w / 2 : gl.length > 0 ? r.x + 42 : r.x + 16;
2544
- const anchor = st.solid === true ? "middle" : "start";
2545
- const nameY = r.y + (st.stereo !== void 0 ? 38 : n.note !== void 0 ? 36 : 44);
2546
- const noteY = r.y + (st.stereo !== void 0 ? 56 : 52);
2547
- const stroke = st.solid === true ? "none" : st.accent;
2548
- const dashAttr = st.dash !== void 0 ? ` stroke-dasharray="${st.dash}"` : "";
2549
- const stripe = st.solid === true ? "" : `<rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st.accent}"/>`;
2550
- const stereo = st.stereo !== void 0 ? `<text x="${r.x + r.w / 2}" y="${r.y + 20}" class="uml-stereo">\xAB${escapeHtml(st.stereo)}\xBB</text>` : "";
2551
- const note = n.note !== void 0 ? `<text x="${nx}" y="${noteY}" class="blk-tech" fill="${st.solid === true ? "#cfe0f3" : st.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
2552
- s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="9" fill="${st.fill}" stroke="${stroke}" stroke-width="1.2"${dashAttr}/>` + stripe + gl + stereo + `<text x="${nx}" y="${nameY}" class="blk-name" fill="${st.text}" text-anchor="${anchor}">${escapeHtml(n.name)}</text>` + note + `</g>`;
4206
+ const st2 = feStyle(n.kind);
4207
+ const k2 = (n.kind ?? "").toLowerCase();
4208
+ const gl = GLYPH_KINDS.has(k2) ? nodeGlyph(GLYPH_REMAP[k2] ?? k2, r.x + 16, r.y + 16, st2.accent) : "";
4209
+ const nx = st2.solid === true ? r.x + r.w / 2 : gl.length > 0 ? r.x + 42 : r.x + 16;
4210
+ const anchor = st2.solid === true ? "middle" : "start";
4211
+ const nameY = r.y + (st2.stereo !== void 0 ? 38 : n.note !== void 0 ? 36 : 44);
4212
+ const noteY = r.y + (st2.stereo !== void 0 ? 56 : 52);
4213
+ const stroke = st2.solid === true ? "none" : st2.accent;
4214
+ const dashAttr = st2.dash !== void 0 ? ` stroke-dasharray="${st2.dash}"` : "";
4215
+ const stripe = st2.solid === true ? "" : `<rect x="${r.x}" y="${r.y}" width="5" height="${r.h}" rx="2" fill="${st2.accent}"/>`;
4216
+ const stereo = st2.stereo !== void 0 ? `<text x="${r.x + r.w / 2}" y="${r.y + 20}" class="uml-stereo">\xAB${escapeHtml(st2.stereo)}\xBB</text>` : "";
4217
+ const note = n.note !== void 0 ? `<text x="${nx}" y="${noteY}" class="blk-tech" fill="${st2.solid === true ? "#cfe0f3" : st2.accent}" text-anchor="${anchor}">${escapeHtml(n.note)}</text>` : "";
4218
+ s += `<g filter="url(#gshadow)"><rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="9" fill="${st2.fill}" stroke="${stroke}" stroke-width="1.2"${dashAttr}/>` + stripe + gl + stereo + `<text x="${nx}" y="${nameY}" class="blk-name" fill="${st2.text}" text-anchor="${anchor}">${escapeHtml(n.name)}</text>` + note + `</g>`;
2553
4219
  }
2554
4220
  s += `</svg>`;
2555
4221
  return diagramFrame(
@@ -2613,11 +4279,11 @@ function elementHeight(el) {
2613
4279
  }
2614
4280
  }
2615
4281
  var PH = 'fill="var(--light-gray)" stroke="var(--rule)" stroke-width="1"';
2616
- function drawElement(el, x, y, w) {
4282
+ function drawElement(el, x2, y, w2) {
2617
4283
  const rows = Math.max(1, el.rows ?? 1);
2618
4284
  const label = el.label ?? "";
2619
4285
  const accent = el.tone === "danger" ? "var(--negative)" : el.tone === "muted" ? "var(--gray)" : "var(--navy)";
2620
- const anchorX = el.align === "c" ? x + w / 2 : el.align === "r" ? x + w : x;
4286
+ const anchorX = el.align === "c" ? x2 + w2 / 2 : el.align === "r" ? x2 + w2 : x2;
2621
4287
  const anchor = el.align === "c" ? "middle" : el.align === "r" ? "end" : "start";
2622
4288
  switch (el.type) {
2623
4289
  case "header":
@@ -2627,69 +4293,69 @@ function drawElement(el, x, y, w) {
2627
4293
  case "text": {
2628
4294
  let s = "";
2629
4295
  for (let i = 0; i < rows; i++) {
2630
- const lw = i === rows - 1 ? w * 0.66 : w;
2631
- s += `<rect x="${x}" y="${y + i * 12}" width="${lw}" height="6" rx="3" fill="var(--rule)"/>`;
4296
+ const lw = i === rows - 1 ? w2 * 0.66 : w2;
4297
+ s += `<rect x="${x2}" y="${y + i * 12}" width="${lw}" height="6" rx="3" fill="var(--rule)"/>`;
2632
4298
  }
2633
4299
  return s;
2634
4300
  }
2635
4301
  case "button":
2636
- return `<rect x="${x}" y="${y}" width="${w}" height="34" rx="8" fill="${accent}"/><text x="${x + w / 2}" y="${y + 22}" class="wf-btn" text-anchor="middle">${escapeHtml(label || "Button")}</text>`;
4302
+ return `<rect x="${x2}" y="${y}" width="${w2}" height="34" rx="8" fill="${accent}"/><text x="${x2 + w2 / 2}" y="${y + 22}" class="wf-btn" text-anchor="middle">${escapeHtml(label || "Button")}</text>`;
2637
4303
  case "input":
2638
4304
  case "search": {
2639
- const icon = el.type === "search" ? `<circle cx="${x + 16}" cy="${y + 17}" r="5" fill="none" stroke="var(--gray)" stroke-width="1.4"/><path d="M${x + 20} ${y + 21} l4 4" stroke="var(--gray)" stroke-width="1.4"/>` : "";
2640
- const tx = el.type === "search" ? x + 30 : x + 12;
2641
- return `<rect x="${x}" y="${y}" width="${w}" height="34" rx="8" fill="var(--white)" stroke="var(--rule)" stroke-width="1.2"/>` + icon + `<text x="${tx}" y="${y + 21}" class="wf-ph-text">${escapeHtml(label || "Type here\u2026")}</text>`;
4305
+ const icon = el.type === "search" ? `<circle cx="${x2 + 16}" cy="${y + 17}" r="5" fill="none" stroke="var(--gray)" stroke-width="1.4"/><path d="M${x2 + 20} ${y + 21} l4 4" stroke="var(--gray)" stroke-width="1.4"/>` : "";
4306
+ const tx = el.type === "search" ? x2 + 30 : x2 + 12;
4307
+ return `<rect x="${x2}" y="${y}" width="${w2}" height="34" rx="8" fill="var(--white)" stroke="var(--rule)" stroke-width="1.2"/>` + icon + `<text x="${tx}" y="${y + 21}" class="wf-ph-text">${escapeHtml(label || "Type here\u2026")}</text>`;
2642
4308
  }
2643
4309
  case "image":
2644
- return `<rect x="${x}" y="${y}" width="${w}" height="88" rx="8" ${PH}/><path d="M${x} ${y + 88} L${x + w * 0.4} ${y + 40} L${x + w * 0.62} ${y + 66} L${x + w * 0.78} ${y + 50} L${x + w} ${y + 88}" fill="none" stroke="var(--gray)" stroke-width="1.3"/><circle cx="${x + w * 0.74} " cy="${y + 26}" r="7" fill="none" stroke="var(--gray)" stroke-width="1.3"/>`;
4310
+ return `<rect x="${x2}" y="${y}" width="${w2}" height="88" rx="8" ${PH}/><path d="M${x2} ${y + 88} L${x2 + w2 * 0.4} ${y + 40} L${x2 + w2 * 0.62} ${y + 66} L${x2 + w2 * 0.78} ${y + 50} L${x2 + w2} ${y + 88}" fill="none" stroke="var(--gray)" stroke-width="1.3"/><circle cx="${x2 + w2 * 0.74} " cy="${y + 26}" r="7" fill="none" stroke="var(--gray)" stroke-width="1.3"/>`;
2645
4311
  case "avatar":
2646
- return `<circle cx="${x + 22}" cy="${y + 22}" r="20" ${PH}/><circle cx="${x + 22}" cy="${y + 17}" r="7" fill="var(--gray)"/><path d="M${x + 9} ${y + 40} a13 11 0 0 1 26 0" fill="var(--gray)"/>` + (label ? `<text x="${x + 52}" y="${y + 27}" class="wf-sub" fill="var(--charcoal)">${escapeHtml(label)}</text>` : "");
4312
+ return `<circle cx="${x2 + 22}" cy="${y + 22}" r="20" ${PH}/><circle cx="${x2 + 22}" cy="${y + 17}" r="7" fill="var(--gray)"/><path d="M${x2 + 9} ${y + 40} a13 11 0 0 1 26 0" fill="var(--gray)"/>` + (label ? `<text x="${x2 + 52}" y="${y + 27}" class="wf-sub" fill="var(--charcoal)">${escapeHtml(label)}</text>` : "");
2647
4313
  case "card": {
2648
4314
  let s = "";
2649
4315
  for (let i = 0; i < rows; i++) {
2650
4316
  const cy = y + i * 74;
2651
- s += `<rect x="${x}" y="${cy}" width="${w}" height="64" rx="10" fill="var(--white)" stroke="var(--rule)" stroke-width="1.2"/><rect x="${x + 12}" y="${cy + 12}" width="40" height="40" rx="8" ${PH}/><rect x="${x + 64}" y="${cy + 16}" width="${w - 92}" height="7" rx="3.5" fill="var(--rule)"/><rect x="${x + 64}" y="${cy + 34}" width="${(w - 92) * 0.6}" height="6" rx="3" fill="var(--rule)"/>`;
4317
+ s += `<rect x="${x2}" y="${cy}" width="${w2}" height="64" rx="10" fill="var(--white)" stroke="var(--rule)" stroke-width="1.2"/><rect x="${x2 + 12}" y="${cy + 12}" width="40" height="40" rx="8" ${PH}/><rect x="${x2 + 64}" y="${cy + 16}" width="${w2 - 92}" height="7" rx="3.5" fill="var(--rule)"/><rect x="${x2 + 64}" y="${cy + 34}" width="${(w2 - 92) * 0.6}" height="6" rx="3" fill="var(--rule)"/>`;
2652
4318
  }
2653
- const cap = label ? `<text x="${x + 64}" y="${y + 30}" class="wf-ph-text"></text>` : "";
4319
+ const cap = label ? `<text x="${x2 + 64}" y="${y + 30}" class="wf-ph-text"></text>` : "";
2654
4320
  return s + cap;
2655
4321
  }
2656
4322
  case "list": {
2657
4323
  let s = "";
2658
4324
  for (let i = 0; i < rows; i++) {
2659
4325
  const ly = y + i * 40;
2660
- s += `<circle cx="${x + 16}" cy="${ly + 20}" r="12" ${PH}/><rect x="${x + 38}" y="${ly + 12}" width="${w - 76}" height="6" rx="3" fill="var(--rule)"/><rect x="${x + 38}" y="${ly + 24}" width="${(w - 76) * 0.55}" height="5" rx="2.5" fill="var(--rule)"/><path d="M${x + w - 14} ${ly + 15} l5 5 l-5 5" fill="none" stroke="var(--gray)" stroke-width="1.4"/>` + (i < rows - 1 ? `<line x1="${x + 38}" y1="${ly + 40}" x2="${x + w}" y2="${ly + 40}" stroke="var(--light-gray)" stroke-width="1"/>` : "");
4326
+ s += `<circle cx="${x2 + 16}" cy="${ly + 20}" r="12" ${PH}/><rect x="${x2 + 38}" y="${ly + 12}" width="${w2 - 76}" height="6" rx="3" fill="var(--rule)"/><rect x="${x2 + 38}" y="${ly + 24}" width="${(w2 - 76) * 0.55}" height="5" rx="2.5" fill="var(--rule)"/><path d="M${x2 + w2 - 14} ${ly + 15} l5 5 l-5 5" fill="none" stroke="var(--gray)" stroke-width="1.4"/>` + (i < rows - 1 ? `<line x1="${x2 + 38}" y1="${ly + 40}" x2="${x2 + w2}" y2="${ly + 40}" stroke="var(--light-gray)" stroke-width="1"/>` : "");
2661
4327
  }
2662
4328
  return s;
2663
4329
  }
2664
4330
  case "nav": {
2665
4331
  const items = (label || "Home, Docs, Pricing, About").split(",").map((t) => t.trim());
2666
4332
  let s = "";
2667
- let nx = x;
2668
- for (const it of items) {
2669
- const pw = 16 + it.length * 6.2;
2670
- s += `<rect x="${nx}" y="${y + 4}" width="${pw}" height="22" rx="11" fill="var(--light-gray)"/><text x="${nx + pw / 2}" y="${y + 19}" class="wf-ph-text" text-anchor="middle">${escapeHtml(it)}</text>`;
4333
+ let nx = x2;
4334
+ for (const it2 of items) {
4335
+ const pw = 16 + it2.length * 6.2;
4336
+ s += `<rect x="${nx}" y="${y + 4}" width="${pw}" height="22" rx="11" fill="var(--light-gray)"/><text x="${nx + pw / 2}" y="${y + 19}" class="wf-ph-text" text-anchor="middle">${escapeHtml(it2)}</text>`;
2671
4337
  nx += pw + 8;
2672
4338
  }
2673
4339
  return s;
2674
4340
  }
2675
4341
  case "tabs": {
2676
4342
  const items = (label || "Home, Search, Bell, Profile").split(",").map((t) => t.trim());
2677
- const seg = w / items.length;
2678
- let s = `<line x1="${x}" y1="${y}" x2="${x + w}" y2="${y}" stroke="var(--rule)" stroke-width="1"/>`;
2679
- items.forEach((it, i) => {
2680
- const cx = x + seg * i + seg / 2;
2681
- s += `<circle cx="${cx}" cy="${y + 18}" r="8" fill="none" stroke="${i === 0 ? accent : "var(--gray)"}" stroke-width="1.6"/><text x="${cx}" y="${y + 42}" class="wf-tab" text-anchor="middle" fill="${i === 0 ? accent : "var(--gray)"}">${escapeHtml(it)}</text>`;
4343
+ const seg = w2 / items.length;
4344
+ let s = `<line x1="${x2}" y1="${y}" x2="${x2 + w2}" y2="${y}" stroke="var(--rule)" stroke-width="1"/>`;
4345
+ items.forEach((it2, i) => {
4346
+ const cx = x2 + seg * i + seg / 2;
4347
+ s += `<circle cx="${cx}" cy="${y + 18}" r="8" fill="none" stroke="${i === 0 ? accent : "var(--gray)"}" stroke-width="1.6"/><text x="${cx}" y="${y + 42}" class="wf-tab" text-anchor="middle" fill="${i === 0 ? accent : "var(--gray)"}">${escapeHtml(it2)}</text>`;
2682
4348
  });
2683
4349
  return s;
2684
4350
  }
2685
4351
  case "divider":
2686
- return `<line x1="${x}" y1="${y + 7}" x2="${x + w}" y2="${y + 7}" stroke="var(--rule)" stroke-width="1"/>`;
4352
+ return `<line x1="${x2}" y1="${y + 7}" x2="${x2 + w2}" y2="${y + 7}" stroke="var(--rule)" stroke-width="1"/>`;
2687
4353
  case "badge": {
2688
4354
  const pw = 22 + label.length * 6.4;
2689
4355
  return `<rect x="${anchorX - (anchor === "middle" ? pw / 2 : anchor === "end" ? pw : 0)}" y="${y}" width="${pw}" height="22" rx="11" fill="${accent}"/><text x="${anchorX - (anchor === "middle" ? 0 : anchor === "end" ? pw / 2 : -pw / 2)}" y="${y + 15}" class="wf-btn" text-anchor="middle">${escapeHtml(label || "New")}</text>`;
2690
4356
  }
2691
4357
  case "toggle":
2692
- return (label ? `<text x="${x}" y="${y + 19}" class="wf-sub" fill="var(--charcoal)">${escapeHtml(label)}</text>` : "") + `<rect x="${x + w - 44}" y="${y + 6}" width="44" height="22" rx="11" fill="${accent}"/><circle cx="${x + w - 16}" cy="${y + 17}" r="8" fill="#fff"/>`;
4358
+ return (label ? `<text x="${x2}" y="${y + 19}" class="wf-sub" fill="var(--charcoal)">${escapeHtml(label)}</text>` : "") + `<rect x="${x2 + w2 - 44}" y="${y + 6}" width="44" height="22" rx="11" fill="${accent}"/><circle cx="${x2 + w2 - 16}" cy="${y + 17}" r="8" fill="#fff"/>`;
2693
4359
  case "spacer":
2694
4360
  return "";
2695
4361
  default:
@@ -2758,18 +4424,18 @@ function renderWireframe(data) {
2758
4424
  const width = totalW + padX * 2;
2759
4425
  const height = maxH + capH + padY * 2;
2760
4426
  let s = `<svg viewBox="0 0 ${width} ${height}" role="img"><title>${escapeHtml(data.title ?? "UI mockup")}</title>`;
2761
- let x = padX;
4427
+ let x2 = padX;
2762
4428
  drawn.forEach((d, i) => {
2763
4429
  const screen = screens[i];
2764
- s += `<g transform="translate(${x}, ${padY})">${d.svg}</g>`;
4430
+ s += `<g transform="translate(${x2}, ${padY})">${d.svg}</g>`;
2765
4431
  const cap = screen?.label;
2766
4432
  if (cap !== void 0 && cap.length > 0) {
2767
4433
  const lines = wrapText(cap, Math.floor(d.width / 6), 2);
2768
- lines.forEach((ln, j) => {
2769
- s += `<text x="${x + d.width / 2}" y="${padY + maxH + 16 + j * 12}" class="wf-caption" text-anchor="middle">${escapeHtml(ln)}</text>`;
4434
+ lines.forEach((ln2, j2) => {
4435
+ s += `<text x="${x2 + d.width / 2}" y="${padY + maxH + 16 + j2 * 12}" class="wf-caption" text-anchor="middle">${escapeHtml(ln2)}</text>`;
2770
4436
  });
2771
4437
  }
2772
- x += d.width + gap;
4438
+ x2 += d.width + gap;
2773
4439
  });
2774
4440
  s += `</svg>`;
2775
4441
  return diagramFrame(
@@ -2946,7 +4612,7 @@ var themes = {
2946
4612
  function themeStyle(name) {
2947
4613
  const vars = themes[name].vars;
2948
4614
  const parts = [];
2949
- for (const k of Object.keys(vars)) parts.push(`${k}:${vars[k]};`);
4615
+ for (const k2 of Object.keys(vars)) parts.push(`${k2}:${vars[k2]};`);
2950
4616
  return parts.join("");
2951
4617
  }
2952
4618
 
@@ -2969,8 +4635,8 @@ function renderSectionHead(num, kind, title, lede) {
2969
4635
  return `<div class="section-head"><div class="section-num">SECTION ${pad2(num)} \xB7 ${escapeHtml(label)}</div>` + titleHtml + ledeHtml + `</div>`;
2970
4636
  }
2971
4637
  function dispatchBlock(kind, data) {
2972
- const fn = htmlRenderers[kind];
2973
- return fn(data);
4638
+ const fn2 = htmlRenderers[kind];
4639
+ return fn2(data);
2974
4640
  }
2975
4641
  function renderTypedSegment(seg, ctx) {
2976
4642
  if (seg.kind === "meta") return "";
@@ -3000,7 +4666,7 @@ function renderSegment(seg, ctx) {
3000
4666
  function buildThemeVars(theme, vars) {
3001
4667
  let css = themeStyle(theme);
3002
4668
  if (vars !== void 0) {
3003
- for (const k of Object.keys(vars)) css += `${k}:${vars[k]};`;
4669
+ for (const k2 of Object.keys(vars)) css += `${k2}:${vars[k2]};`;
3004
4670
  }
3005
4671
  return css;
3006
4672
  }
@@ -3033,6 +4699,11 @@ function renderDocument(doc, opts = {}) {
3033
4699
  </html>
3034
4700
  `;
3035
4701
  }
4702
+ /*! Bundled license information:
4703
+
4704
+ @dagrejs/dagre/dist/dagre.esm.js:
4705
+ (*! For license information please see dagre.esm.js.LEGAL.txt *)
4706
+ */
3036
4707
 
3037
4708
  export { DEFAULT_THEME, buildThemeVars, edgePill, escapeHtml, globalDefsSvg, houseCss, htmlRenderers, ortho, renderDocument, renderDocumentParts, renderProse, safeColor, safeUrl, themeStyle, themes, wrapText };
3038
4709
  //# sourceMappingURL=index.js.map