quixotic-gol 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,260 @@
1
+ import { ForwardRefExoticComponent } from 'react';
2
+ import { JSX } from 'react/jsx-runtime';
3
+ import { RefAttributes } from 'react';
4
+
5
+ /**
6
+ * Create a custom layout config by merging with defaults.
7
+ * @param overrides - Partial config to override defaults
8
+ * @returns Complete LayoutConfig with overrides applied
9
+ */
10
+ export declare function createLayoutConfig(overrides?: Partial<LayoutConfig>): LayoutConfig;
11
+
12
+ /**
13
+ * Default layout configuration with sensible values.
14
+ */
15
+ export declare const DEFAULT_LAYOUT_CONFIG: LayoutConfig;
16
+
17
+ declare interface DrawOp {
18
+ op: string;
19
+ grad?: string;
20
+ color?: string;
21
+ points?: number[][];
22
+ rect?: number[];
23
+ pt?: number[];
24
+ align?: string;
25
+ width?: number;
26
+ size?: number;
27
+ face?: string;
28
+ text?: string;
29
+ style?: string;
30
+ }
31
+
32
+ export declare interface Example {
33
+ title: string;
34
+ chain: string;
35
+ tx: string;
36
+ nodeMapping: Record<string, NodeMapping>;
37
+ dot: string;
38
+ }
39
+
40
+ export declare interface ExampleItem {
41
+ filename: string;
42
+ title: string;
43
+ chain: string;
44
+ tx: string;
45
+ edgeCount: number;
46
+ }
47
+
48
+ export declare interface GraphvizJson {
49
+ name: string;
50
+ directed: boolean;
51
+ strict: boolean;
52
+ bb?: string;
53
+ objects?: GraphvizObject[];
54
+ edges?: GraphvizObject[];
55
+ }
56
+
57
+ declare interface GraphvizObject {
58
+ _gvid: number;
59
+ name: string;
60
+ _draw_?: DrawOp[];
61
+ _ldraw_?: DrawOp[];
62
+ _hdraw_?: DrawOp[];
63
+ _tdraw_?: DrawOp[];
64
+ bb?: string;
65
+ pos?: string;
66
+ width?: string;
67
+ height?: string;
68
+ label?: string;
69
+ head?: number;
70
+ tail?: number;
71
+ }
72
+
73
+ /**
74
+ * GraphvizRenderer - Component that renders DOT strings using Web Worker
75
+ * and automatically renders them with custom layout.
76
+ *
77
+ * Supports both declarative (props) and imperative (ref) APIs for zoom control.
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * const rendererRef = useRef<GraphvizRendererRef>(null);
82
+ *
83
+ * <GraphvizRenderer
84
+ * ref={rendererRef}
85
+ * dotString={example.dot}
86
+ * nodeMapping={example.nodeMapping}
87
+ * maxDepth={2}
88
+ * className="w-full h-full"
89
+ * />
90
+ *
91
+ * // Use ref API
92
+ * rendererRef.current?.zoomIn();
93
+ * rendererRef.current?.zoomOut(15);
94
+ * rendererRef.current?.toggleZoom();
95
+ * ```
96
+ */
97
+ export declare const GraphvizRenderer: ForwardRefExoticComponent<GraphvizRendererProps & RefAttributes<GraphvizRendererRef>>;
98
+
99
+ export declare interface GraphvizRendererProps {
100
+ /** DOT string to render */
101
+ dotString: string;
102
+ /** Node mapping for custom rendering */
103
+ nodeMapping?: Record<string, NodeMapping>;
104
+ /** SVG font size */
105
+ svgFontSize?: number;
106
+ /** Optional custom loading indicator component */
107
+ loadingIndicator?: React.ReactNode;
108
+ /** Callback when rendering succeeds with JSON result */
109
+ onSuccess?: (json: GraphvizJson) => void;
110
+ /** Callback when rendering fails */
111
+ onError?: (error: Error) => void;
112
+ /** Callback on zoom with font size information */
113
+ onZoom?: (info: {
114
+ baseFontSize: number;
115
+ actualFontSize: number;
116
+ scale: number;
117
+ }) => void;
118
+ /** Callback for render progress with elapsed time in milliseconds */
119
+ onRenderProgress?: (elapsedMs: number) => void;
120
+ /** Additional class name for the container */
121
+ className?: string;
122
+ /** Show loading indicator (default: true) */
123
+ showLoading?: boolean;
124
+ /** Enable debug visual indicators (yellow border and center dot) */
125
+ debug?: boolean;
126
+ /** Currently selected edge ID (controlled component) */
127
+ selectedEdgeId?: number | null;
128
+ /** Callback when an edge is selected or deselected */
129
+ onEdgeSelect?: (edgeId: number | null) => void;
130
+ /** Use native Graphviz rendering instead of custom rendering (default: false) */
131
+ useNativeRendering?: boolean;
132
+ /** Custom node width in points (default: 240) */
133
+ nodeWidth?: number;
134
+ /** Custom node height in points (default: 64) */
135
+ nodeHeight?: number;
136
+ /** Custom spacing between node columns in points */
137
+ nodeColumnSpacing?: number;
138
+ }
139
+
140
+ /**
141
+ * Ref API for programmatic control of GraphvizRenderer
142
+ */
143
+ export declare interface GraphvizRendererRef {
144
+ /**
145
+ * Zoom in by increasing the effective font size
146
+ * @param percentage - Percentage to increase (default: 10)
147
+ */
148
+ zoomIn: (percentage?: number) => void;
149
+ /**
150
+ * Zoom out by decreasing the effective font size
151
+ * @param percentage - Percentage to decrease (default: 10)
152
+ */
153
+ zoomOut: (percentage?: number) => void;
154
+ /**
155
+ * Toggle between full overview and centered view with normal font size (16px)
156
+ */
157
+ toggleZoom: () => void;
158
+ /**
159
+ * Stop the current rendering operation and terminate the worker
160
+ */
161
+ stopRendering: () => void;
162
+ }
163
+
164
+ export declare const LARGE_GRAPH_THRESHOLD = 500;
165
+
166
+ /**
167
+ * Layout configuration for the Graphviz custom layout renderer.
168
+ * All layout-related constants are consolidated here for easy customization.
169
+ */
170
+ export declare interface LayoutConfig {
171
+ /** Horizontal extension at start/end of edges (in pixels) */
172
+ horizontalExtension: number;
173
+ /** Minimum distance between edge midY values (in pixels) */
174
+ minEdgeDistance: number;
175
+ /** Threshold for skipping vertical segments (in pixels) */
176
+ minVerticalSegment: number;
177
+ /** Radius for self-loop edges (in pixels) */
178
+ loopRadius: number;
179
+ /** Spacing between edges (in pixels) */
180
+ edgeSpacing: number;
181
+ /** Corner radius for edge paths (in pixels) */
182
+ cornerRadius: number;
183
+ /** Width of arrowhead (in pixels) */
184
+ arrowWidth: number;
185
+ /** Height of arrowhead (in pixels) */
186
+ arrowHeight: number;
187
+ /** Extra height for edge labels (in pixels) */
188
+ labelHeight: number;
189
+ /** Font size for edge labels (in pixels) */
190
+ labelFontSize: number;
191
+ /** Padding around label text (in pixels) */
192
+ labelPadding: number;
193
+ /** Corner radius for label background (in pixels) */
194
+ labelCornerRadius: number;
195
+ /** Spacing between nodes (in pixels) */
196
+ nodeSpacing: number;
197
+ /** Threshold for considering edges as nearly horizontal (in pixels) */
198
+ nearlyHorizontalThreshold: number;
199
+ /** Threshold for nearly aligned edges in 3seg path (in pixels) */
200
+ nearlyAlignedThreshold: number;
201
+ }
202
+
203
+ export declare interface NodeMapping {
204
+ sourceNodeId: string;
205
+ targetNodeId: string;
206
+ }
207
+
208
+ declare interface NodeMapping_2 {
209
+ sourceNodeId: string;
210
+ targetNodeId: string;
211
+ }
212
+
213
+ /**
214
+ * Render graph using custom SVG based on Graphviz JSON output
215
+ * @param maxDepth - Edge depth to filter by (null = show all)
216
+ * @param includeLesserDepths - If true, show depth <= maxDepth; if false, show only exact depth
217
+ * @param config - Layout configuration
218
+ * @returns Object containing zoom behavior and SVG references for imperative control
219
+ */
220
+ export declare function renderCustomGraph(container: HTMLDivElement, json: GraphvizJson, _nodeMapping?: Record<string, NodeMapping_2>, maxDepth?: number | null, includeLesserDepths?: boolean, config?: LayoutConfig, useOrthogonalRendering?: boolean, svgFontSize?: number, debug?: boolean, selectedEdgeId?: number | null, onEdgeSelect?: (edgeId: number | null) => void, nodeWidth?: number, nodeHeight?: number, nodeColumnSpacing?: number): {
221
+ zoomBehavior: any;
222
+ svgElement: SVGSVGElement;
223
+ gElement: SVGGElement;
224
+ baseFontSize: number;
225
+ viewBoxWidth: number;
226
+ };
227
+
228
+ /**
229
+ * Setup zoom and pan for graphviz native SVG rendering
230
+ */
231
+ export declare function setupZoomPan(container: HTMLDivElement): void;
232
+
233
+ export declare function useGraphvizWorker(): UseGraphvizWorkerResult;
234
+
235
+ declare interface UseGraphvizWorkerResult {
236
+ layout: (dot: string) => Promise<string>;
237
+ cancel: () => void;
238
+ isLoading: boolean;
239
+ error: string | null;
240
+ }
241
+
242
+ export declare function WorkerLoadingIndicator({ onCancel }: WorkerLoadingIndicatorProps): JSX.Element;
243
+
244
+ export declare interface WorkerLoadingIndicatorProps {
245
+ onCancel: () => void;
246
+ }
247
+
248
+ export declare interface WorkerRequest {
249
+ id: string;
250
+ dot: string;
251
+ }
252
+
253
+ export declare interface WorkerResponse {
254
+ id: string;
255
+ success: boolean;
256
+ json?: string;
257
+ error?: string;
258
+ }
259
+
260
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=require("react"),dt=require("react/jsx-runtime");var _e=typeof document<"u"?document.currentScript:null;const On=500;var Wn={value:()=>{}};function Ye(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ae(n)}function ae(t){this._=t}function Xn(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ae.prototype=Ye.prototype={constructor:ae,on:function(t,e){var n=this._,r=Xn(t+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((i=(t=r[s]).type)&&(i=Gn(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(t=r[s]).type)n[i]=We(n[i],t.name,e);else if(e==null)for(i in n)n[i]=We(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ae(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,i=s.length;r<i;++r)s[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,s=r.length;i<s;++i)r[i].value.apply(e,n)}};function Gn(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function We(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Wn,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var ke="http://www.w3.org/1999/xhtml";const Xe={svg:"http://www.w3.org/2000/svg",xhtml:ke,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ye(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Xe.hasOwnProperty(e)?{space:Xe[e],local:t}:t}function qn(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===ke&&e.documentElement.namespaceURI===ke?e.createElement(t):e.createElementNS(n,t)}}function Vn(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function ln(t){var e=ye(t);return(e.local?Vn:qn)(e)}function Un(){}function Re(t){return t==null?Un:function(){return this.querySelector(t)}}function Zn(t){typeof t!="function"&&(t=Re(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,c=r[i]=new Array(o),l,a,u=0;u<o;++u)(l=s[u])&&(a=t.call(l,l.__data__,u,s))&&("__data__"in l&&(a.__data__=l.__data__),c[u]=a);return new ft(r,this._parents)}function Kn(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Qn(){return[]}function un(t){return t==null?Qn:function(){return this.querySelectorAll(t)}}function Jn(t){return function(){return Kn(t.apply(this,arguments))}}function jn(t){typeof t=="function"?t=Jn(t):t=un(t);for(var e=this._groups,n=e.length,r=[],i=[],s=0;s<n;++s)for(var o=e[s],c=o.length,l,a=0;a<c;++a)(l=o[a])&&(r.push(t.call(l,l.__data__,a,o)),i.push(l));return new ft(r,i)}function fn(t){return function(){return this.matches(t)}}function hn(t){return function(e){return e.matches(t)}}var tr=Array.prototype.find;function er(t){return function(){return tr.call(this.children,t)}}function nr(){return this.firstElementChild}function rr(t){return this.select(t==null?nr:er(typeof t=="function"?t:hn(t)))}var ir=Array.prototype.filter;function or(){return Array.from(this.children)}function sr(t){return function(){return ir.call(this.children,t)}}function ar(t){return this.selectAll(t==null?or:sr(typeof t=="function"?t:hn(t)))}function cr(t){typeof t!="function"&&(t=fn(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,c=r[i]=[],l,a=0;a<o;++a)(l=s[a])&&t.call(l,l.__data__,a,s)&&c.push(l);return new ft(r,this._parents)}function dn(t){return new Array(t.length)}function lr(){return new ft(this._enter||this._groups.map(dn),this._parents)}function fe(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}fe.prototype={constructor:fe,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function ur(t){return function(){return t}}function fr(t,e,n,r,i,s){for(var o=0,c,l=e.length,a=s.length;o<a;++o)(c=e[o])?(c.__data__=s[o],r[o]=c):n[o]=new fe(t,s[o]);for(;o<l;++o)(c=e[o])&&(i[o]=c)}function hr(t,e,n,r,i,s,o){var c,l,a=new Map,u=e.length,d=s.length,g=new Array(u),x;for(c=0;c<u;++c)(l=e[c])&&(g[c]=x=o.call(l,l.__data__,c,e)+"",a.has(x)?i[c]=l:a.set(x,l));for(c=0;c<d;++c)x=o.call(t,s[c],c,s)+"",(l=a.get(x))?(r[c]=l,l.__data__=s[c],a.delete(x)):n[c]=new fe(t,s[c]);for(c=0;c<u;++c)(l=e[c])&&a.get(g[c])===l&&(i[c]=l)}function dr(t){return t.__data__}function pr(t,e){if(!arguments.length)return Array.from(this,dr);var n=e?hr:fr,r=this._parents,i=this._groups;typeof t!="function"&&(t=ur(t));for(var s=i.length,o=new Array(s),c=new Array(s),l=new Array(s),a=0;a<s;++a){var u=r[a],d=i[a],g=d.length,x=gr(t.call(u,u&&u.__data__,a,r)),N=x.length,S=c[a]=new Array(N),T=o[a]=new Array(N),$=l[a]=new Array(g);n(u,d,S,T,$,x,e);for(var K=0,W=0,Q,G;K<N;++K)if(Q=S[K]){for(K>=W&&(W=K+1);!(G=T[W])&&++W<N;);Q._next=G||null}}return o=new ft(o,r),o._enter=c,o._exit=l,o}function gr(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function mr(){return new ft(this._exit||this._groups.map(dn),this._parents)}function yr(t,e,n){var r=this.enter(),i=this,s=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function xr(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,s=r.length,o=Math.min(i,s),c=new Array(i),l=0;l<o;++l)for(var a=n[l],u=r[l],d=a.length,g=c[l]=new Array(d),x,N=0;N<d;++N)(x=a[N]||u[N])&&(g[N]=x);for(;l<i;++l)c[l]=n[l];return new ft(c,this._parents)}function wr(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,s=r[i],o;--i>=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function vr(t){t||(t=_r);function e(d,g){return d&&g?t(d.__data__,g.__data__):!d-!g}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o=n[s],c=o.length,l=i[s]=new Array(c),a,u=0;u<c;++u)(a=o[u])&&(l[u]=a);l.sort(e)}return new ft(i,this._parents).order()}function _r(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function br(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Er(){return Array.from(this)}function Nr(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length;i<s;++i){var o=r[i];if(o)return o}return null}function $r(){let t=0;for(const e of this)++t;return t}function kr(){return!this.node()}function Cr(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],s=0,o=i.length,c;s<o;++s)(c=i[s])&&t.call(c,c.__data__,s,i);return this}function Sr(t){return function(){this.removeAttribute(t)}}function Ar(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Mr(t,e){return function(){this.setAttribute(t,e)}}function zr(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Ir(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Pr(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Tr(t,e){var n=ye(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?Ar:Sr:typeof e=="function"?n.local?Pr:Ir:n.local?zr:Mr)(n,e))}function pn(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Yr(t){return function(){this.style.removeProperty(t)}}function Rr(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Br(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Dr(t,e,n){return arguments.length>1?this.each((e==null?Yr:typeof e=="function"?Br:Rr)(t,e,n??"")):Bt(this.node(),t)}function Bt(t,e){return t.style.getPropertyValue(e)||pn(t).getComputedStyle(t,null).getPropertyValue(e)}function Lr(t){return function(){delete this[t]}}function Fr(t,e){return function(){this[t]=e}}function Hr(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Or(t,e){return arguments.length>1?this.each((e==null?Lr:typeof e=="function"?Hr:Fr)(t,e)):this.node()[t]}function gn(t){return t.trim().split(/^|\s+/)}function Be(t){return t.classList||new mn(t)}function mn(t){this._node=t,this._names=gn(t.getAttribute("class")||"")}mn.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function yn(t,e){for(var n=Be(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function xn(t,e){for(var n=Be(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Wr(t){return function(){yn(this,t)}}function Xr(t){return function(){xn(this,t)}}function Gr(t,e){return function(){(e.apply(this,arguments)?yn:xn)(this,t)}}function qr(t,e){var n=gn(t+"");if(arguments.length<2){for(var r=Be(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?Gr:e?Wr:Xr)(n,e))}function Vr(){this.textContent=""}function Ur(t){return function(){this.textContent=t}}function Zr(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function Kr(t){return arguments.length?this.each(t==null?Vr:(typeof t=="function"?Zr:Ur)(t)):this.node().textContent}function Qr(){this.innerHTML=""}function Jr(t){return function(){this.innerHTML=t}}function jr(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function ti(t){return arguments.length?this.each(t==null?Qr:(typeof t=="function"?jr:Jr)(t)):this.node().innerHTML}function ei(){this.nextSibling&&this.parentNode.appendChild(this)}function ni(){return this.each(ei)}function ri(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ii(){return this.each(ri)}function oi(t){var e=typeof t=="function"?t:ln(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function si(){return null}function ai(t,e){var n=typeof t=="function"?t:ln(t),r=e==null?si:typeof e=="function"?e:Re(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ci(){var t=this.parentNode;t&&t.removeChild(this)}function li(){return this.each(ci)}function ui(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function fi(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function hi(t){return this.select(t?fi:ui)}function di(t){return arguments.length?this.property("__data__",t):this.node().__data__}function pi(t){return function(e){t.call(this,e,this.__data__)}}function gi(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function mi(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,s;n<i;++n)s=e[n],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++r]=s;++r?e.length=r:delete this.__on}}}function yi(t,e,n){return function(){var r=this.__on,i,s=pi(e);if(r){for(var o=0,c=r.length;o<c;++o)if((i=r[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=e;return}}this.addEventListener(t.type,s,n),i={type:t.type,name:t.name,value:e,listener:s,options:n},r?r.push(i):this.__on=[i]}}function xi(t,e,n){var r=gi(t+""),i,s=r.length,o;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,a=c.length,u;l<a;++l)for(i=0,u=c[l];i<s;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(c=e?yi:mi,i=0;i<s;++i)this.each(c(r[i],e,n));return this}function wn(t,e,n){var r=pn(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function wi(t,e){return function(){return wn(this,t,e)}}function vi(t,e){return function(){return wn(this,t,e.apply(this,arguments))}}function _i(t,e){return this.each((typeof e=="function"?vi:wi)(t,e))}function*bi(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,s=r.length,o;i<s;++i)(o=r[i])&&(yield o)}var vn=[null];function ft(t,e){this._groups=t,this._parents=e}function Qt(){return new ft([[document.documentElement]],vn)}function Ei(){return this}ft.prototype=Qt.prototype={constructor:ft,select:Zn,selectAll:jn,selectChild:rr,selectChildren:ar,filter:cr,data:pr,enter:lr,exit:mr,join:yr,merge:xr,selection:Ei,order:wr,sort:vr,call:br,nodes:Er,node:Nr,size:$r,empty:kr,each:Cr,attr:Tr,style:Dr,property:Or,classed:qr,text:Kr,html:ti,raise:ni,lower:ii,append:oi,insert:ai,remove:li,clone:hi,datum:di,on:xi,dispatch:_i,[Symbol.iterator]:bi};function st(t){return typeof t=="string"?new ft([[document.querySelector(t)]],[document.documentElement]):new ft([[t]],vn)}function Ni(t){let e;for(;e=t.sourceEvent;)t=e;return t}function At(t,e){if(t=Ni(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const Ce={capture:!0,passive:!1};function Se(t){t.preventDefault(),t.stopImmediatePropagation()}function $i(t){var e=t.document.documentElement,n=st(t).on("dragstart.drag",Se,Ce);"onselectstart"in e?n.on("selectstart.drag",Se,Ce):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function ki(t,e){var n=t.document.documentElement,r=st(t).on("dragstart.drag",null);e&&(r.on("click.drag",Se,Ce),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function De(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function _n(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Jt(){}var Vt=.7,he=1/Vt,Rt="\\s*([+-]?\\d+)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ci=/^#([0-9a-f]{3,8})$/,Si=new RegExp(`^rgb\\(${Rt},${Rt},${Rt}\\)$`),Ai=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),Mi=new RegExp(`^rgba\\(${Rt},${Rt},${Rt},${Ut}\\)$`),zi=new RegExp(`^rgba\\(${xt},${xt},${xt},${Ut}\\)$`),Ii=new RegExp(`^hsl\\(${Ut},${xt},${xt}\\)$`),Pi=new RegExp(`^hsla\\(${Ut},${xt},${xt},${Ut}\\)$`),Ge={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};De(Jt,Zt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:qe,formatHex:qe,formatHex8:Ti,formatHsl:Yi,formatRgb:Ve,toString:Ve});function qe(){return this.rgb().formatHex()}function Ti(){return this.rgb().formatHex8()}function Yi(){return bn(this).formatHsl()}function Ve(){return this.rgb().formatRgb()}function Zt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Ci.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Ue(e):n===3?new ut(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?ne(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?ne(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Si.exec(t))?new ut(e[1],e[2],e[3],1):(e=Ai.exec(t))?new ut(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Mi.exec(t))?ne(e[1],e[2],e[3],e[4]):(e=zi.exec(t))?ne(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Ii.exec(t))?Qe(e[1],e[2]/100,e[3]/100,1):(e=Pi.exec(t))?Qe(e[1],e[2]/100,e[3]/100,e[4]):Ge.hasOwnProperty(t)?Ue(Ge[t]):t==="transparent"?new ut(NaN,NaN,NaN,0):null}function Ue(t){return new ut(t>>16&255,t>>8&255,t&255,1)}function ne(t,e,n,r){return r<=0&&(t=e=n=NaN),new ut(t,e,n,r)}function Ri(t){return t instanceof Jt||(t=Zt(t)),t?(t=t.rgb(),new ut(t.r,t.g,t.b,t.opacity)):new ut}function Ae(t,e,n,r){return arguments.length===1?Ri(t):new ut(t,e,n,r??1)}function ut(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}De(ut,Ae,_n(Jt,{brighter(t){return t=t==null?he:Math.pow(he,t),new ut(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Vt:Math.pow(Vt,t),new ut(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ut(It(this.r),It(this.g),It(this.b),de(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ze,formatHex:Ze,formatHex8:Bi,formatRgb:Ke,toString:Ke}));function Ze(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}`}function Bi(){return`#${zt(this.r)}${zt(this.g)}${zt(this.b)}${zt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ke(){const t=de(this.opacity);return`${t===1?"rgb(":"rgba("}${It(this.r)}, ${It(this.g)}, ${It(this.b)}${t===1?")":`, ${t})`}`}function de(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function It(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function zt(t){return t=It(t),(t<16?"0":"")+t.toString(16)}function Qe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new pt(t,e,n,r)}function bn(t){if(t instanceof pt)return new pt(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=Zt(t)),!t)return new pt;if(t instanceof pt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,c=s-i,l=(s+i)/2;return c?(e===s?o=(n-r)/c+(n<r)*6:n===s?o=(r-e)/c+2:o=(e-n)/c+4,c/=l<.5?s+i:2-s-i,o*=60):c=l>0&&l<1?0:o,new pt(o,c,l,t.opacity)}function Di(t,e,n,r){return arguments.length===1?bn(t):new pt(t,e,n,r??1)}function pt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}De(pt,Di,_n(Jt,{brighter(t){return t=t==null?he:Math.pow(he,t),new pt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Vt:Math.pow(Vt,t),new pt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ut(be(t>=240?t-240:t+120,i,r),be(t,i,r),be(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new pt(Je(this.h),re(this.s),re(this.l),de(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=de(this.opacity);return`${t===1?"hsl(":"hsla("}${Je(this.h)}, ${re(this.s)*100}%, ${re(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Je(t){return t=(t||0)%360,t<0?t+360:t}function re(t){return Math.max(0,Math.min(1,t||0))}function be(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const En=t=>()=>t;function Li(t,e){return function(n){return t+n*e}}function Fi(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function Hi(t){return(t=+t)==1?Nn:function(e,n){return n-e?Fi(e,n,t):En(isNaN(e)?n:e)}}function Nn(t,e){var n=e-t;return n?Li(t,n):En(isNaN(t)?e:t)}const je=(function t(e){var n=Hi(e);function r(i,s){var o=n((i=Ae(i)).r,(s=Ae(s)).r),c=n(i.g,s.g),l=n(i.b,s.b),a=Nn(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=c(u),i.b=l(u),i.opacity=a(u),i+""}}return r.gamma=t,r})(1);function Et(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var Me=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ee=new RegExp(Me.source,"g");function Oi(t){return function(){return t}}function Wi(t){return function(e){return t(e)+""}}function Xi(t,e){var n=Me.lastIndex=Ee.lastIndex=0,r,i,s,o=-1,c=[],l=[];for(t=t+"",e=e+"";(r=Me.exec(t))&&(i=Ee.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),c[o]?c[o]+=s:c[++o]=s),(r=r[0])===(i=i[0])?c[o]?c[o]+=i:c[++o]=i:(c[++o]=null,l.push({i:o,x:Et(r,i)})),n=Ee.lastIndex;return n<e.length&&(s=e.slice(n),c[o]?c[o]+=s:c[++o]=s),c.length<2?l[0]?Wi(l[0].x):Oi(e):(e=l.length,function(a){for(var u=0,d;u<e;++u)c[(d=l[u]).i]=d.x(a);return c.join("")})}var tn=180/Math.PI,ze={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $n(t,e,n,r,i,s){var o,c,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(c=Math.sqrt(n*n+r*r))&&(n/=c,r/=c,l/=c),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(e,t)*tn,skewX:Math.atan(l)*tn,scaleX:o,scaleY:c}}var ie;function Gi(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?ze:$n(e.a,e.b,e.c,e.d,e.e,e.f)}function qi(t){return t==null||(ie||(ie=document.createElementNS("http://www.w3.org/2000/svg","g")),ie.setAttribute("transform",t),!(t=ie.transform.baseVal.consolidate()))?ze:(t=t.matrix,$n(t.a,t.b,t.c,t.d,t.e,t.f))}function kn(t,e,n,r){function i(a){return a.length?a.pop()+" ":""}function s(a,u,d,g,x,N){if(a!==d||u!==g){var S=x.push("translate(",null,e,null,n);N.push({i:S-4,x:Et(a,d)},{i:S-2,x:Et(u,g)})}else(d||g)&&x.push("translate("+d+e+g+n)}function o(a,u,d,g){a!==u?(a-u>180?u+=360:u-a>180&&(a+=360),g.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Et(a,u)})):u&&d.push(i(d)+"rotate("+u+r)}function c(a,u,d,g){a!==u?g.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Et(a,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(a,u,d,g,x,N){if(a!==d||u!==g){var S=x.push(i(x)+"scale(",null,",",null,")");N.push({i:S-4,x:Et(a,d)},{i:S-2,x:Et(u,g)})}else(d!==1||g!==1)&&x.push(i(x)+"scale("+d+","+g+")")}return function(a,u){var d=[],g=[];return a=t(a),u=t(u),s(a.translateX,a.translateY,u.translateX,u.translateY,d,g),o(a.rotate,u.rotate,d,g),c(a.skewX,u.skewX,d,g),l(a.scaleX,a.scaleY,u.scaleX,u.scaleY,d,g),a=u=null,function(x){for(var N=-1,S=g.length,T;++N<S;)d[(T=g[N]).i]=T.x(x);return d.join("")}}}var Vi=kn(Gi,"px, ","px)","deg)"),Ui=kn(qi,", ",")",")"),Zi=1e-12;function en(t){return((t=Math.exp(t))+1/t)/2}function Ki(t){return((t=Math.exp(t))-1/t)/2}function Qi(t){return((t=Math.exp(2*t))-1)/(t+1)}const Ji=(function t(e,n,r){function i(s,o){var c=s[0],l=s[1],a=s[2],u=o[0],d=o[1],g=o[2],x=u-c,N=d-l,S=x*x+N*N,T,$;if(S<Zi)$=Math.log(g/a)/e,T=function(et){return[c+et*x,l+et*N,a*Math.exp(e*et*$)]};else{var K=Math.sqrt(S),W=(g*g-a*a+r*S)/(2*a*n*K),Q=(g*g-a*a-r*S)/(2*g*n*K),G=Math.log(Math.sqrt(W*W+1)-W),F=Math.log(Math.sqrt(Q*Q+1)-Q);$=(F-G)/e,T=function(et){var z=et*$,R=en(G),H=a/(n*K)*(R*Qi(e*z+G)-Ki(G));return[c+H*x,l+H*N,a*R/en(e*z+G)]}}return T.duration=$*1e3*e/Math.SQRT2,T}return i.rho=function(s){var o=Math.max(.001,+s),c=o*o,l=c*c;return t(o,c,l)},i})(Math.SQRT2,2,4);var Dt=0,Xt=0,Ot=0,Cn=1e3,pe,Gt,ge=0,Pt=0,xe=0,Kt=typeof performance=="object"&&performance.now?performance:Date,Sn=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Le(){return Pt||(Sn(ji),Pt=Kt.now()+xe)}function ji(){Pt=0}function me(){this._call=this._time=this._next=null}me.prototype=An.prototype={constructor:me,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Le():+n)+(e==null?0:+e),!this._next&&Gt!==this&&(Gt?Gt._next=this:pe=this,Gt=this),this._call=t,this._time=n,Ie()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ie())}};function An(t,e,n){var r=new me;return r.restart(t,e,n),r}function to(){Le(),++Dt;for(var t=pe,e;t;)(e=Pt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Dt}function nn(){Pt=(ge=Kt.now())+xe,Dt=Xt=0;try{to()}finally{Dt=0,no(),Pt=0}}function eo(){var t=Kt.now(),e=t-ge;e>Cn&&(xe-=e,ge=t)}function no(){for(var t,e=pe,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:pe=n);Gt=t,Ie(r)}function Ie(t){if(!Dt){Xt&&(Xt=clearTimeout(Xt));var e=t-Pt;e>24?(t<1/0&&(Xt=setTimeout(nn,t-Kt.now()-xe)),Ot&&(Ot=clearInterval(Ot))):(Ot||(ge=Kt.now(),Ot=setInterval(eo,Cn)),Dt=1,Sn(nn))}}function rn(t,e,n){var r=new me;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var ro=Ye("start","end","cancel","interrupt"),io=[],Mn=0,on=1,Pe=2,ce=3,sn=4,Te=5,le=6;function we(t,e,n,r,i,s){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;oo(t,n,{name:e,index:r,group:i,on:ro,tween:io,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Mn})}function Fe(t,e){var n=gt(t,e);if(n.state>Mn)throw new Error("too late; already scheduled");return n}function wt(t,e){var n=gt(t,e);if(n.state>ce)throw new Error("too late; already running");return n}function gt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function oo(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=An(s,0,n.time);function s(a){n.state=on,n.timer.restart(o,n.delay,n.time),n.delay<=a&&o(a-n.delay)}function o(a){var u,d,g,x;if(n.state!==on)return l();for(u in r)if(x=r[u],x.name===n.name){if(x.state===ce)return rn(o);x.state===sn?(x.state=le,x.timer.stop(),x.on.call("interrupt",t,t.__data__,x.index,x.group),delete r[u]):+u<e&&(x.state=le,x.timer.stop(),x.on.call("cancel",t,t.__data__,x.index,x.group),delete r[u])}if(rn(function(){n.state===ce&&(n.state=sn,n.timer.restart(c,n.delay,n.time),c(a))}),n.state=Pe,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Pe){for(n.state=ce,i=new Array(g=n.tween.length),u=0,d=-1;u<g;++u)(x=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(i[++d]=x);i.length=d+1}}function c(a){for(var u=a<n.duration?n.ease.call(null,a/n.duration):(n.timer.restart(l),n.state=Te,1),d=-1,g=i.length;++d<g;)i[d].call(t,u);n.state===Te&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=le,n.timer.stop(),delete r[e];for(var a in r)return;delete t.__transition}}function ue(t,e){var n=t.__transition,r,i,s=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((r=n[o]).name!==e){s=!1;continue}i=r.state>Pe&&r.state<Te,r.state=le,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[o]}s&&delete t.__transition}}function so(t){return this.each(function(){ue(this,t)})}function ao(t,e){var n,r;return function(){var i=wt(this,t),s=i.tween;if(s!==n){r=n=s;for(var o=0,c=r.length;o<c;++o)if(r[o].name===e){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function co(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=wt(this,t),o=s.tween;if(o!==r){i=(r=o).slice();for(var c={name:e,value:n},l=0,a=i.length;l<a;++l)if(i[l].name===e){i[l]=c;break}l===a&&i.push(c)}s.tween=i}}function lo(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=gt(this.node(),n).tween,i=0,s=r.length,o;i<s;++i)if((o=r[i]).name===t)return o.value;return null}return this.each((e==null?ao:co)(n,t,e))}function He(t,e,n){var r=t._id;return t.each(function(){var i=wt(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return gt(i,r).value[e]}}function zn(t,e){var n;return(typeof e=="number"?Et:e instanceof Zt?je:(n=Zt(e))?(e=n,je):Xi)(t,e)}function uo(t){return function(){this.removeAttribute(t)}}function fo(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ho(t,e,n){var r,i=n+"",s;return function(){var o=this.getAttribute(t);return o===i?null:o===r?s:s=e(r=o,n)}}function po(t,e,n){var r,i=n+"",s;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===r?s:s=e(r=o,n)}}function go(t,e,n){var r,i,s;return function(){var o,c=n(this),l;return c==null?void this.removeAttribute(t):(o=this.getAttribute(t),l=c+"",o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,c)))}}function mo(t,e,n){var r,i,s;return function(){var o,c=n(this),l;return c==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),l=c+"",o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,c)))}}function yo(t,e){var n=ye(t),r=n==="transform"?Ui:zn;return this.attrTween(t,typeof e=="function"?(n.local?mo:go)(n,r,He(this,"attr."+t,e)):e==null?(n.local?fo:uo)(n):(n.local?po:ho)(n,r,e))}function xo(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function wo(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function vo(t,e){var n,r;function i(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&wo(t,s)),n}return i._value=e,i}function _o(t,e){var n,r;function i(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&xo(t,s)),n}return i._value=e,i}function bo(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=ye(t);return this.tween(n,(r.local?vo:_o)(r,e))}function Eo(t,e){return function(){Fe(this,t).delay=+e.apply(this,arguments)}}function No(t,e){return e=+e,function(){Fe(this,t).delay=e}}function $o(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Eo:No)(e,t)):gt(this.node(),e).delay}function ko(t,e){return function(){wt(this,t).duration=+e.apply(this,arguments)}}function Co(t,e){return e=+e,function(){wt(this,t).duration=e}}function So(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?ko:Co)(e,t)):gt(this.node(),e).duration}function Ao(t,e){if(typeof e!="function")throw new Error;return function(){wt(this,t).ease=e}}function Mo(t){var e=this._id;return arguments.length?this.each(Ao(e,t)):gt(this.node(),e).ease}function zo(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;wt(this,t).ease=n}}function Io(t){if(typeof t!="function")throw new Error;return this.each(zo(this._id,t))}function Po(t){typeof t!="function"&&(t=fn(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var s=e[i],o=s.length,c=r[i]=[],l,a=0;a<o;++a)(l=s[a])&&t.call(l,l.__data__,a,s)&&c.push(l);return new bt(r,this._parents,this._name,this._id)}function To(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,s=Math.min(r,i),o=new Array(r),c=0;c<s;++c)for(var l=e[c],a=n[c],u=l.length,d=o[c]=new Array(u),g,x=0;x<u;++x)(g=l[x]||a[x])&&(d[x]=g);for(;c<r;++c)o[c]=e[c];return new bt(o,this._parents,this._name,this._id)}function Yo(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function Ro(t,e,n){var r,i,s=Yo(e)?Fe:wt;return function(){var o=s(this,t),c=o.on;c!==r&&(i=(r=c).copy()).on(e,n),o.on=i}}function Bo(t,e){var n=this._id;return arguments.length<2?gt(this.node(),n).on.on(t):this.each(Ro(n,t,e))}function Do(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function Lo(){return this.on("end.remove",Do(this._id))}function Fo(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Re(t));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var c=r[o],l=c.length,a=s[o]=new Array(l),u,d,g=0;g<l;++g)(u=c[g])&&(d=t.call(u,u.__data__,g,c))&&("__data__"in u&&(d.__data__=u.__data__),a[g]=d,we(a[g],e,n,g,a,gt(u,n)));return new bt(s,this._parents,e,n)}function Ho(t){var e=this._name,n=this._id;typeof t!="function"&&(t=un(t));for(var r=this._groups,i=r.length,s=[],o=[],c=0;c<i;++c)for(var l=r[c],a=l.length,u,d=0;d<a;++d)if(u=l[d]){for(var g=t.call(u,u.__data__,d,l),x,N=gt(u,n),S=0,T=g.length;S<T;++S)(x=g[S])&&we(x,e,n,S,g,N);s.push(g),o.push(u)}return new bt(s,o,e,n)}var Oo=Qt.prototype.constructor;function Wo(){return new Oo(this._groups,this._parents)}function Xo(t,e){var n,r,i;return function(){var s=Bt(this,t),o=(this.style.removeProperty(t),Bt(this,t));return s===o?null:s===n&&o===r?i:i=e(n=s,r=o)}}function In(t){return function(){this.style.removeProperty(t)}}function Go(t,e,n){var r,i=n+"",s;return function(){var o=Bt(this,t);return o===i?null:o===r?s:s=e(r=o,n)}}function qo(t,e,n){var r,i,s;return function(){var o=Bt(this,t),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(t),Bt(this,t))),o===l?null:o===r&&l===i?s:(i=l,s=e(r=o,c))}}function Vo(t,e){var n,r,i,s="style."+e,o="end."+s,c;return function(){var l=wt(this,t),a=l.on,u=l.value[s]==null?c||(c=In(e)):void 0;(a!==n||i!==u)&&(r=(n=a).copy()).on(o,i=u),l.on=r}}function Uo(t,e,n){var r=(t+="")=="transform"?Vi:zn;return e==null?this.styleTween(t,Xo(t,r)).on("end.style."+t,In(t)):typeof e=="function"?this.styleTween(t,qo(t,r,He(this,"style."+t,e))).each(Vo(this._id,t)):this.styleTween(t,Go(t,r,e),n).on("end.style."+t,null)}function Zo(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Ko(t,e,n){var r,i;function s(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&Zo(t,o,n)),r}return s._value=e,s}function Qo(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,Ko(t,e,n??""))}function Jo(t){return function(){this.textContent=t}}function jo(t){return function(){var e=t(this);this.textContent=e??""}}function ts(t){return this.tween("text",typeof t=="function"?jo(He(this,"text",t)):Jo(t==null?"":t+""))}function es(t){return function(e){this.textContent=t.call(this,e)}}function ns(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&es(i)),e}return r._value=t,r}function rs(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,ns(t))}function is(){for(var t=this._name,e=this._id,n=Pn(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],c=o.length,l,a=0;a<c;++a)if(l=o[a]){var u=gt(l,e);we(l,t,n,a,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new bt(r,this._parents,t,n)}function os(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var c={value:o},l={value:function(){--i===0&&s()}};n.each(function(){var a=wt(this,r),u=a.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(c),e._.interrupt.push(c),e._.end.push(l)),a.on=e}),i===0&&s()})}var ss=0;function bt(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Pn(){return++ss}var vt=Qt.prototype;bt.prototype={constructor:bt,select:Fo,selectAll:Ho,selectChild:vt.selectChild,selectChildren:vt.selectChildren,filter:Po,merge:To,selection:Wo,transition:is,call:vt.call,nodes:vt.nodes,node:vt.node,size:vt.size,empty:vt.empty,each:vt.each,on:Bo,attr:yo,attrTween:bo,style:Uo,styleTween:Qo,text:ts,textTween:rs,remove:Lo,tween:lo,delay:$o,duration:So,ease:Mo,easeVarying:Io,end:os,[Symbol.iterator]:vt[Symbol.iterator]};function as(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var cs={time:null,delay:0,duration:250,ease:as};function ls(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function us(t){var e,n;t instanceof bt?(e=t._id,t=t._name):(e=Pn(),(n=cs).time=Le(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],c=o.length,l,a=0;a<c;++a)(l=o[a])&&we(l,t,e,a,o,n||ls(l,e));return new bt(r,this._parents,t,e)}Qt.prototype.interrupt=so;Qt.prototype.transition=us;const oe=t=>()=>t;function fs(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function _t(t,e,n){this.k=t,this.x=e,this.y=n}_t.prototype={constructor:_t,scale:function(t){return t===1?this:new _t(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new _t(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Nt=new _t(1,0,0);qt.prototype=_t.prototype;function qt(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Nt;return t.__zoom}function Ne(t){t.stopImmediatePropagation()}function Wt(t){t.preventDefault(),t.stopImmediatePropagation()}function hs(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function ds(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function an(){return this.__zoom||Nt}function ps(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function gs(){return navigator.maxTouchPoints||"ontouchstart"in this}function ms(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Oe(){var t=hs,e=ds,n=ms,r=ps,i=gs,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Ji,a=Ye("start","zoom","end"),u,d,g,x=500,N=150,S=0,T=10;function $(h){h.property("__zoom",an).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",H).filter(i).on("touchstart.zoom",I).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",tt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}$.transform=function(h,k,y,C){var Y=h.selection?h.selection():h;Y.property("__zoom",an),h!==Y?G(h,k,y,C):Y.interrupt().each(function(){F(this,arguments).event(C).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},$.scaleBy=function(h,k,y,C){$.scaleTo(h,function(){var Y=this.__zoom.k,B=typeof k=="function"?k.apply(this,arguments):k;return Y*B},y,C)},$.scaleTo=function(h,k,y,C){$.transform(h,function(){var Y=e.apply(this,arguments),B=this.__zoom,M=y==null?Q(Y):typeof y=="function"?y.apply(this,arguments):y,f=B.invert(M),p=typeof k=="function"?k.apply(this,arguments):k;return n(W(K(B,p),M,f),Y,o)},y,C)},$.translateBy=function(h,k,y,C){$.transform(h,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof y=="function"?y.apply(this,arguments):y),e.apply(this,arguments),o)},null,C)},$.translateTo=function(h,k,y,C,Y){$.transform(h,function(){var B=e.apply(this,arguments),M=this.__zoom,f=C==null?Q(B):typeof C=="function"?C.apply(this,arguments):C;return n(Nt.translate(f[0],f[1]).scale(M.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof y=="function"?-y.apply(this,arguments):-y),B,o)},C,Y)};function K(h,k){return k=Math.max(s[0],Math.min(s[1],k)),k===h.k?h:new _t(k,h.x,h.y)}function W(h,k,y){var C=k[0]-y[0]*h.k,Y=k[1]-y[1]*h.k;return C===h.x&&Y===h.y?h:new _t(h.k,C,Y)}function Q(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function G(h,k,y,C){h.on("start.zoom",function(){F(this,arguments).event(C).start()}).on("interrupt.zoom end.zoom",function(){F(this,arguments).event(C).end()}).tween("zoom",function(){var Y=this,B=arguments,M=F(Y,B).event(C),f=e.apply(Y,B),p=y==null?Q(f):typeof y=="function"?y.apply(Y,B):y,A=Math.max(f[1][0]-f[0][0],f[1][1]-f[0][1]),w=Y.__zoom,v=typeof k=="function"?k.apply(Y,B):k,b=l(w.invert(p).concat(A/w.k),v.invert(p).concat(A/v.k));return function(m){if(m===1)m=v;else{var _=b(m),E=A/_[2];m=new _t(E,p[0]-_[0]*E,p[1]-_[1]*E)}M.zoom(null,m)}})}function F(h,k,y){return!y&&h.__zooming||new et(h,k)}function et(h,k){this.that=h,this.args=k,this.active=0,this.sourceEvent=null,this.extent=e.apply(h,k),this.taps=0}et.prototype={event:function(h){return h&&(this.sourceEvent=h),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(h,k){return this.mouse&&h!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&h!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&h!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(h){var k=st(this.that).datum();a.call(h,this.that,new fs(h,{sourceEvent:this.sourceEvent,target:$,transform:this.that.__zoom,dispatch:a}),k)}};function z(h,...k){if(!t.apply(this,arguments))return;var y=F(this,k).event(h),C=this.__zoom,Y=Math.max(s[0],Math.min(s[1],C.k*Math.pow(2,r.apply(this,arguments)))),B=At(h);if(y.wheel)(y.mouse[0][0]!==B[0]||y.mouse[0][1]!==B[1])&&(y.mouse[1]=C.invert(y.mouse[0]=B)),clearTimeout(y.wheel);else{if(C.k===Y)return;y.mouse=[B,C.invert(B)],ue(this),y.start()}Wt(h),y.wheel=setTimeout(M,N),y.zoom("mouse",n(W(K(C,Y),y.mouse[0],y.mouse[1]),y.extent,o));function M(){y.wheel=null,y.end()}}function R(h,...k){if(g||!t.apply(this,arguments))return;var y=h.currentTarget,C=F(this,k,!0).event(h),Y=st(h.view).on("mousemove.zoom",p,!0).on("mouseup.zoom",A,!0),B=At(h,y),M=h.clientX,f=h.clientY;$i(h.view),Ne(h),C.mouse=[B,this.__zoom.invert(B)],ue(this),C.start();function p(w){if(Wt(w),!C.moved){var v=w.clientX-M,b=w.clientY-f;C.moved=v*v+b*b>S}C.event(w).zoom("mouse",n(W(C.that.__zoom,C.mouse[0]=At(w,y),C.mouse[1]),C.extent,o))}function A(w){Y.on("mousemove.zoom mouseup.zoom",null),ki(w.view,C.moved),Wt(w),C.event(w).end()}}function H(h,...k){if(t.apply(this,arguments)){var y=this.__zoom,C=At(h.changedTouches?h.changedTouches[0]:h,this),Y=y.invert(C),B=y.k*(h.shiftKey?.5:2),M=n(W(K(y,B),C,Y),e.apply(this,k),o);Wt(h),c>0?st(this).transition().duration(c).call(G,M,C,h):st(this).call($.transform,M,C,h)}}function I(h,...k){if(t.apply(this,arguments)){var y=h.touches,C=y.length,Y=F(this,k,h.changedTouches.length===C).event(h),B,M,f,p;for(Ne(h),M=0;M<C;++M)f=y[M],p=At(f,this),p=[p,this.__zoom.invert(p),f.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==p[2]&&(Y.touch1=p,Y.taps=0):(Y.touch0=p,B=!0,Y.taps=1+!!u);u&&(u=clearTimeout(u)),B&&(Y.taps<2&&(d=p[0],u=setTimeout(function(){u=null},x)),ue(this),Y.start())}}function Z(h,...k){if(this.__zooming){var y=F(this,k).event(h),C=h.changedTouches,Y=C.length,B,M,f,p;for(Wt(h),B=0;B<Y;++B)M=C[B],f=At(M,this),y.touch0&&y.touch0[2]===M.identifier?y.touch0[0]=f:y.touch1&&y.touch1[2]===M.identifier&&(y.touch1[0]=f);if(M=y.that.__zoom,y.touch1){var A=y.touch0[0],w=y.touch0[1],v=y.touch1[0],b=y.touch1[1],m=(m=v[0]-A[0])*m+(m=v[1]-A[1])*m,_=(_=b[0]-w[0])*_+(_=b[1]-w[1])*_;M=K(M,Math.sqrt(m/_)),f=[(A[0]+v[0])/2,(A[1]+v[1])/2],p=[(w[0]+b[0])/2,(w[1]+b[1])/2]}else if(y.touch0)f=y.touch0[0],p=y.touch0[1];else return;y.zoom("touch",n(W(M,f,p),y.extent,o))}}function tt(h,...k){if(this.__zooming){var y=F(this,k).event(h),C=h.changedTouches,Y=C.length,B,M;for(Ne(h),g&&clearTimeout(g),g=setTimeout(function(){g=null},x),B=0;B<Y;++B)M=C[B],y.touch0&&y.touch0[2]===M.identifier?delete y.touch0:y.touch1&&y.touch1[2]===M.identifier&&delete y.touch1;if(y.touch1&&!y.touch0&&(y.touch0=y.touch1,delete y.touch1),y.touch0)y.touch0[1]=this.__zoom.invert(y.touch0[0]);else if(y.end(),y.taps===2&&(M=At(M,this),Math.hypot(d[0]-M[0],d[1]-M[1])<T)){var f=st(this).on("dblclick.zoom");f&&f.apply(this,arguments)}}}return $.wheelDelta=function(h){return arguments.length?(r=typeof h=="function"?h:oe(+h),$):r},$.filter=function(h){return arguments.length?(t=typeof h=="function"?h:oe(!!h),$):t},$.touchable=function(h){return arguments.length?(i=typeof h=="function"?h:oe(!!h),$):i},$.extent=function(h){return arguments.length?(e=typeof h=="function"?h:oe([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),$):e},$.scaleExtent=function(h){return arguments.length?(s[0]=+h[0],s[1]=+h[1],$):[s[0],s[1]]},$.translateExtent=function(h){return arguments.length?(o[0][0]=+h[0][0],o[1][0]=+h[1][0],o[0][1]=+h[0][1],o[1][1]=+h[1][1],$):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},$.constrain=function(h){return arguments.length?(n=h,$):n},$.duration=function(h){return arguments.length?(c=+h,$):c},$.interpolate=function(h){return arguments.length?(l=h,$):l},$.on=function(){var h=a.on.apply(a,arguments);return h===a?$:h},$.clickDistance=function(h){return arguments.length?(S=(h=+h)*h,$):Math.sqrt(S)},$.tapDistance=function(h){return arguments.length?(T=+h,$):T},$}const jt={horizontalExtension:30,minEdgeDistance:50,minVerticalSegment:20,loopRadius:40,edgeSpacing:80,cornerRadius:15,arrowWidth:10,arrowHeight:6,labelHeight:15,labelFontSize:10,labelPadding:6,labelCornerRadius:4,nodeSpacing:50,nearlyHorizontalThreshold:5,nearlyAlignedThreshold:30};function Tn(t){return{...jt,...t}}function ys(t,e,n){const o=(t.clientWidth||800)/e,c=32/(n*o);return Math.max(3,c)}function $e(t,e,n){const r=t.node();if(!r)return;t.text(n);let i=r.getComputedTextLength();if(i<=e)return;const s="...";let o=0,c=n.length;for(;o<c;){const l=Math.floor((o+c+1)/2);t.text(n.slice(0,l)+s),i=r.getComputedTextLength(),i<=e?o=l:c=l-1}o>0?t.text(n.slice(0,o)+s):t.text(s)}class Yn{constructor(e,n,r,i,s){this.type=e,this._gvid=n,this.name=r,this._draw_=i,this._ldraw_=s}}class Rn extends Yn{constructor({_gvid:e,name:n,_draw_:r,_ldraw_:i,bb:s,pos:o,width:c,height:l,label:a}){super("node",e,n,r,i),this.virtualNode=!1,this.bb=s,this.pos=o,this.width=c,this.height=l,this.label=a}getPosition(){if(!this.pos)return null;const[e,n]=this.pos.split(",").map(Number);return[e,n]}getWidthPoints(){return parseFloat(this.width||"1")*72}getHeightPoints(){return parseFloat(this.height||"0.5")*72}getBounds(){const e=this.getPosition();if(!e)return null;const[n,r]=e,i=this.getWidthPoints(),s=this.getHeightPoints();return{x:n-i/2,y:r-s/2,width:i,height:s}}leftIn(){const e=this.getBounds();return e?{x:e.x,y:Math.trunc(e.y+e.height/4)}:null}leftOut(){const e=this.getBounds();return e?{x:e.x,y:Math.trunc(e.y+e.height/4*3)}:null}rightOut(){const e=this.getBounds();return e?{x:e.x+e.width,y:Math.trunc(e.y+e.height/4)}:null}rightIn(){const e=this.getBounds();return e?{x:e.x+e.width,y:Math.trunc(e.y+e.height/4*3)}:null}}class xs extends Yn{constructor({_gvid:e,name:n,_draw_:r,_ldraw_:i,_hdraw_:s,_tdraw_:o,head:c,tail:l,label:a}){if(super("edge",e,n,r,i),this.isBaseEdge=!1,this.depth=0,this.baseOffset=0,this.midY=0,this._hdraw_=s,this._tdraw_=o,this.head=c,this.tail=l,this.label=a,a){const u=a.match(/\[(\d+)\]/);u&&u[1]&&(this.edgeId=parseInt(u[1],10))}}setNodes(e,n){this.sourceNode=e,this.targetNode=n}getDirection(){if(!this.sourceNode||!this.targetNode)return null;const e=this.sourceNode.getPosition(),n=this.targetNode.getPosition();return!e||!n?null:this.sourceNode._gvid===this.targetNode._gvid?"self":e[0]<n[0]?"right":"left"}getStartPoint(){if(!this.sourceNode)return null;const e=this.getDirection();if(!e)return null;switch(e){case"right":return this.sourceNode.rightOut();case"left":return this.sourceNode.leftOut();case"self":return this.sourceNode.leftOut()}}getEndPoint(){if(!this.targetNode)return null;const e=this.getDirection();if(!e)return null;switch(e){case"right":return this.targetNode.leftIn();case"left":return this.targetNode.rightIn();case"self":return this.targetNode.rightIn()}}getLabelText(){if(this.label)return this.label.replace(/<[^>]*>/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&nbsp;/g," ").replace(/\s+/g," ").trim()||null;if(this._ldraw_){const e=[];if(this._ldraw_.forEach(n=>{n.op==="T"&&n.text&&e.push(n.text)}),e.length>0)return e.join(" ")}return null}getColor(){const e="#9AA4B2";if(this._draw_){for(const n of this._draw_)if(n.op==="c"&&n.color)return n.color}if(this._hdraw_){for(const n of this._hdraw_)if(n.op==="c"&&n.color)return n.color}return e}}class Bn{constructor(e,n=0){this.index=e,this.aboveY=n,this.belowY=n}allocateAbove(e){return this.aboveY-=e,this.aboveY}allocateBelow(e){const n=this.belowY;return this.belowY+=e,n}getRange(){return{above:this.aboveY,below:this.belowY}}}class ws extends Bn{constructor(e,n=0){super(e,n),this.nodes=[]}addNode(e,n=!0){if(this.nodes.push(e),!n)return;const r=e.getPosition();if(r){const i=e.height?parseFloat(e.height)*72:40,s=r[1]-i/2,o=r[1]+i/2;this.aboveY=Math.min(this.aboveY,s),this.belowY=Math.max(this.belowY,o)}}}class vs extends Bn{constructor(e,n,r=0){super(Math.min(e,n),r),this.edges=[],this.baseEdgeIndex=-1,this.sourceColIndex=e,this.targetColIndex=n}addEdge(e){this.edges.push(e)}setBaseEdge(e,n){this.baseEdge=e,this.baseEdgeIndex=n??this.edges.indexOf(e)}getKey(){const e=Math.min(this.sourceColIndex,this.targetColIndex),n=Math.max(this.sourceColIndex,this.targetColIndex);return`${e}-${n}`}}function Dn(t){if(!t)return[];const e=[],n=/<TD[^>]*>(.*?)<\/TD>/gi;let r;for(;(r=n.exec(t))!==null;){let i=r[1];i=i.replace(/<[^>]+>/g,"").trim(),i&&e.push(i)}if(e.length===0){const i=t.replace(/<[^>]+>/g,"").trim();i&&e.push(i)}return e}function _s(t){const e=st(t).select("svg"),n=e.select("g#graph0");if(e.empty()||n.empty()){console.warn("SVG or graph group not found");return}e.attr("width","100%").attr("height","100%");const r=Oe().scaleExtent([.1,2]).on("zoom",o=>{n.attr("transform",o.transform.toString())});e.call(r);const i=e.node(),s=n.node();if(i&&s){const o=s.getBBox(),c=i.parentElement;if(c){const l=c.clientWidth,a=c.clientHeight,u=o.width,d=o.height,g=o.x+u/2,x=o.y+d/2,N=.8/Math.max(u/l,d/a),S=[l/2-N*g,a/2-N*x];e.call(r.transform,Nt.translate(S[0],S[1]).scale(N))}}}function bs(t){if(!t.sourceNode)return null;const e=t.sourceNode.getPosition();if(!e)return null;const r=50/72,i=new Rn({_gvid:-1e3-t._gvid,name:`virtual_edge_${t._gvid}`,label:t.label,pos:`${e[0]},${e[1]}`,width:"0.5",height:r.toString()});return i.virtualNode=!0,i.edge=t,t.virtualNode=i,i}function Es(t,e,n){const r=e.nodes,i=r.findIndex(s=>s._gvid===n._gvid);if(i===-1){r.push(t);return}r.splice(i,0,t)}function Ns(t,e){const r=[],i=new Map;t.forEach(a=>{const u=a.getPosition();if(!u)return;const d=u[0];let g=r.findIndex(x=>Math.abs(d-x)<=20);g===-1&&(g=r.length,r.push(d)),i.set(a._gvid,g)});const s=r.map((a,u)=>({x:a,i:u})).sort((a,u)=>a.x-u.x).map((a,u)=>({oldIndex:a.i,newIndex:u})),o=new Map;s.forEach(({oldIndex:a,newIndex:u})=>{o.set(a,u)});for(const[a,u]of i)i.set(a,o.get(u)??u);const c=new Map;t.forEach(a=>{const u=i.get(a._gvid);u!==void 0&&(c.has(u)||c.set(u,new ws(u,0)),c.get(u).addNode(a,!1))}),e.forEach(a=>{if(!a.sourceNode||!a.targetNode||a.sourceNode._gvid!==a.targetNode._gvid)return;const u=i.get(a.sourceNode._gvid);if(u===void 0)return;const d=c.get(u);if(!d)return;const g=bs(a);g&&Es(g,d,a.sourceNode)});const l=new Map;return e.forEach(a=>{if(!a.sourceNode||!a.targetNode)return;const u=i.get(a.sourceNode._gvid),d=i.get(a.targetNode._gvid);if(u===void 0||d===void 0)return;a.depth=Math.abs(d-u)-1,a.depth<0&&(a.depth=0);const g=Math.min(u,d),x=Math.max(u,d),N=`${g}-${x}`;l.has(N)||l.set(N,new vs(u,d,0)),l.get(N).addEdge(a)}),l.forEach(a=>{a.edges.sort((u,d)=>{const g=u.getStartPoint(),x=u.getEndPoint(),N=g&&x?(g.y+x.y)/2:0,S=d.getStartPoint(),T=d.getEndPoint();return(S&&T?(S.y+T.y)/2:0)-N})}),{nodeColumnMap:i,nodeColumns:c,edgeColumns:l}}function $s(t,e){t.forEach(n=>{if(n.nodes.length===0)return;let r=!0;n.nodes.forEach(i=>{const s=i.getPosition();if(!s)return;const o=i.height?parseFloat(i.height)*72:40,c=e-s[1],l=c-o/2,a=c+o/2;r?(n.aboveY=l,n.belowY=a,r=!1):(n.aboveY=Math.min(n.aboveY,l),n.belowY=Math.max(n.belowY,a))})})}function ks(t,e){t.length!==0&&e.forEach(n=>{const r=n.edges;if(r.length===0)return;const i=r.filter(d=>d.depth===0);if(i.length===0)return;const s=Math.floor(i.length/2),o=i[s];o.isBaseEdge=!0,o.baseDirection=void 0;const c=r.indexOf(o);n.setBaseEdge(o,c);const l=o.getStartPoint(),a=o.getEndPoint(),u=l&&a?(l.y+a.y)/2:0;i.forEach((d,g)=>{if(d===o)return;const x=d.getStartPoint(),N=d.getEndPoint();(x&&N?(x.y+N.y)/2:0)>u?d.baseDirection="above":d.baseDirection="below"})})}function se(t,e,n,r=jt){const i=t.getStartPoint(),s=t.getEndPoint(),o=t.getDirection();if(!i||!s||!o||o==="self")return;const c={x:i.x,y:e-i.y},l={x:s.x,y:e-s.y};let a={x:l.x,y:l.y};o==="right"?a={x:l.x-r.arrowWidth,y:l.y}:o==="left"&&(a={x:l.x+r.arrowWidth,y:l.y});const u=r.horizontalExtension,d=r.minEdgeDistance,g=r.minVerticalSegment,x=G=>{if(G.length<2)return G;const F=[G[0]];for(let et=1;et<G.length;et++){const z=F[F.length-1];(Math.abs(G[et].x-z.x)>.1||Math.abs(G[et].y-z.y)>.1)&&F.push(G[et])}return F};let N;const S=t.baseDirection===void 0;t.baseDirection==="above"?N=Math.min(c.y,a.y):t.baseDirection==="below"?N=Math.max(c.y,a.y):N=(c.y+a.y)/2;let T=N;if(!S&&n&&n.midY!==void 0){if(t.baseDirection==="above"){const G=n.midY-d;T>G&&(T=G)}else if(t.baseDirection==="below"){const G=n.midY+d;T<G&&(T=G)}}const $=Math.abs(c.y-a.y)<5,K=(G,F)=>{const et=Math.abs(c.y-F),z=Math.abs(F-a.y),R=o==="right"?c.x+u:c.x-u,H=o==="right"?a.x-u:a.x+u;let I=[],Z=F;switch(G){case"straight":if($){const k=(c.y+a.y)/2;Math.abs(F-k)<g?(I=[c,a],Z=k):(I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},{x:H,y:a.y},a],Z=F)}else return null;break;case"2seg":et<z?Math.abs(F-c.y)<g?(I=[c,{x:a.x,y:c.y},a],Z=c.y):(I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},{x:H,y:a.y},a],Z=F):Math.abs(F-a.y)<g?(I=[c,{x:R,y:c.y},{x:R,y:a.y},a],Z=a.y):(I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},{x:H,y:a.y},a],Z=F);break;case"3seg":const h=F;I=[c,{x:R,y:c.y},{x:R,y:h},{x:H,y:h},{x:H,y:a.y},a],Z=h;break;case"4seg":I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},a],Z=F;break;case"5seg":if(et<g)I=[c,{x:R,y:c.y},{x:H,y:F},{x:H,y:a.y},a],Z=F;else if(z<g)I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},a],Z=F;else return null;break;case"6seg":I=[c,{x:R,y:c.y},{x:R,y:F},{x:H,y:F},{x:H,y:a.y},a],Z=F;break}const tt=x(I);return tt.length>0?{points:tt,actualMidY:Z}:null};let W;S?W=$?["straight","3seg"]:["3seg"]:W=$?["straight","3seg","4seg","5seg","6seg"]:["3seg","4seg","5seg","6seg"];for(const G of W){const F=K(G,T);if(F)return{midY:F.actualMidY,points:F.points}}const Q=K("6seg",T);return Q?{midY:Q.actualMidY,points:Q.points}:void 0}function cn(t,e){if(t.length<2)return"";if(e===0||t.length===2)return`M${t[0].x},${t[0].y} ${t.slice(1).map(i=>`L${i.x},${i.y}`).join(" ")}`;const n=[];n.push(`M${t[0].x},${t[0].y}`);for(let i=1;i<t.length-1;i++){const s=t[i-1],o=t[i],c=t[i+1],l=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2),a=Math.sqrt((c.x-o.x)**2+(c.y-o.y)**2),u=Math.min(l,a)/2,d=Math.min(e,u);if(d>0){const g=d/l,x=d/a,N={x:o.x-(o.x-s.x)*g,y:o.y-(o.y-s.y)*g},S={x:o.x+(c.x-o.x)*x,y:o.y+(c.y-o.y)*x};n.push(`L${N.x},${N.y}`),n.push(`Q${o.x},${o.y} ${S.x},${S.y}`)}else n.push(`L${o.x},${o.y}`)}const r=t[t.length-1];return n.push(`L${r.x},${r.y}`),n.join(" ")}function Cs(t,e,n,r=jt,i=!0,s=0,o=1/0,c,l,a,u,d,g,x,N=!1){var F,et;const S=g!=null&&t.edgeId===g,T=t.getColor(),$=e.append("g").attr("class",S?"edge selected":"edge").attr("id",`edge_${t._gvid}`).attr("data-edge-id",t.edgeId!==void 0?String(t.edgeId):"").attr("data-is-base",t.isBaseEdge?"true":"false").attr("data-color",T),K=t.getStartPoint(),W=t.getEndPoint(),Q=t.getDirection();console.log(`Edge ${t._gvid}: direction=${Q}, isBase=${t.isBaseEdge}, depth=${t.depth}`,{start:K,end:W,sourceNode:(F=t.sourceNode)==null?void 0:F.name,targetNode:(et=t.targetNode)==null?void 0:et.name});const G=r.arrowWidth;if(r.arrowHeight,K&&W&&Q){const z={x:K.x,y:n-K.y},R={x:W.x,y:n-W.y},H={x:R.x,y:R.y};let I={x:R.x,y:R.y};Q==="right"?I={x:R.x-G,y:R.y}:Q==="left"?I={x:R.x+G,y:R.y}:Q==="self"&&(I={x:R.x+G,y:R.y});let Z;const tt=r.loopRadius,h=r.horizontalExtension,k=r.cornerRadius;if(i)if(Q==="self")if(t.virtualNode){const f=t.virtualNode.getPosition();if(f){const p=n-f[1];t.midY=p;const A=[z,{x:z.x-h,y:z.y},{x:z.x-h,y:p},{x:I.x+h,y:p},{x:I.x+h,y:I.y},I];Z=cn(A,k)}else{const p=z.x-tt,A=z.y-tt,w=I.x+tt,v=I.y-tt;Z=`M${z.x},${z.y} C${p},${A} ${w},${v} ${I.x},${I.y}`}}else{const f=z.x-tt,p=z.y-tt,A=I.x+tt,w=I.y-tt;Z=`M${z.x},${z.y} C${f},${p} ${A},${w} ${I.x},${I.y}`}else{let f;if(t.orthogonalPathPoints&&t.orthogonalPathPoints.length>0)f=t.orthogonalPathPoints;else{const p=Math.abs(z.y-t.midY),A=Math.abs(t.midY-I.y),w=20,v=p>=w,b=A>=w,m=Q==="right"?z.x+h:z.x-h,_=Q==="right"?I.x-h:I.x+h;if(f=[],!v&&!b){const E=(z.y+I.y)/2;f.push(z,{x:m,y:E},{x:_,y:E},I)}else v?b?f.push(z,{x:m,y:z.y},{x:m,y:t.midY},{x:_,y:t.midY},{x:_,y:I.y},I):f.push(z,{x:m,y:z.y},{x:m,y:t.midY},{x:_,y:t.midY},I):f.push(z,{x:m,y:t.midY},{x:_,y:t.midY},{x:_,y:I.y},I)}Z=cn(f,k)}else if(Q==="self"){const f=z.x-tt,p=z.y-tt,A=I.x+tt,w=I.y-tt;Z=`M${z.x},${z.y} C${f},${p} ${A},${w} ${I.x},${I.y}`}else{const f=I.x-z.x;I.y-z.y;const p=.4,A=z.x+f*p,w=z.y,v=I.x-f*p,b=I.y;Z=`M${z.x},${z.y} C${A},${w} ${v},${b} ${I.x},${I.y}`}const y=N&&t.isBaseEdge?"#000000":t.getColor(),C=N&&t.isBaseEdge?4:1.5;$.append("path").attr("d",Z).attr("fill","none").attr("stroke","transparent").attr("stroke-width",10).attr("class","edge-hit-area").style("cursor","pointer"),$.append("path").attr("d",Z).attr("fill","none").attr("stroke",y).attr("stroke-width",C).attr("class","edge-path").style("pointer-events","none"),$.on("mouseenter",function(){st(this).raise()});const Y=12;let B="";Q==="right"?B=`translate(${H.x-Y}, ${H.y-Y/2})`:Q==="left"?B=`translate(${H.x+Y}, ${H.y+Y/2}) rotate(180)`:Q==="self"&&(B=`translate(${H.x+Y}, ${H.y+Y/2}) rotate(180)`),$.append("use").attr("class","edge-arrow").attr("href","#arrow-right").attr("width",Y).attr("height",Y).attr("transform",B).attr("fill",y).attr("stroke",y).style("stroke-width",0);const M={x:(z.x+I.x)/2,y:t.midY};if(t.label){const p=Dn(t.label).map(at=>at.length>20?at.slice(0,20)+"...":at).join(" "),A=p.length>60?p.slice(0,60)+"...":p,w=r.labelFontSize,v=w*.6,b=A.length*v,m=w,_=r.labelPadding,E=16,O=S?16:0,J=t.edgeId!==void 0,rt=J&&t.edgeId>s,U=J&&t.edgeId<o,D=(rt?E:0)+(U?E:0)+O,X=b+_*2+D,P=m+_*2,L=r.labelCornerRadius,q=M.y,it=M.x,ot=at=>st(`g.edge[data-edge-id="${at}"]`),V=12,j=$.append("g").attr("class","label-area");j.append("rect").attr("class","label-bg").attr("x",it-X/2).attr("y",q-P/2).attr("width",X).attr("height",P).attr("rx",L).attr("ry",L).attr("fill","white").attr("stroke",y).attr("stroke-width",1);const lt=it-X/2+E/2,mt=it+X/2-E/2-O,ct=it+X/2-O/2,te=it+(rt?E/2:0)-(U?E/2:0)-(S?O/2:0);if(J&&x&&$.style("cursor","pointer").on("click",function(at){at.stopPropagation(),!S&&x(t.edgeId)}),j.append("text").attr("class","label-text").attr("x",te).attr("y",q).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-family","Inter, Helvetica, Arial").attr("font-size","10px").attr("fill",y).style("pointer-events","none").text(A),N&&$.append("circle").attr("cx",te).attr("cy",q).attr("r",4).attr("fill","blue").attr("opacity",.8).style("pointer-events","none").attr("class","debug-label-center"),rt){const at=t.edgeId-1,ht=j.append("g").attr("class","nav-btn-group prev-btn-group");ht.append("rect").attr("class","nav-btn-area prev-btn-area").attr("x",it-X/2).attr("y",q-P/2).attr("width",E).attr("height",P).attr("fill","transparent").attr("rx",L).style("cursor","pointer").style("pointer-events","all"),ht.append("use").attr("class","nav-icon prev-icon").attr("href","#nav-left").attr("x",lt-V/2).attr("y",q-V/2).attr("width",V).attr("height",V).attr("fill","#888"),ht.on("click",function(yt){yt.stopPropagation();const $t=ot(at);if(!$t.empty()){if(c&&l&&a&&u&&d){const Tt=$t.node();if(Tt){const kt=st(Tt).select(".label-text").node();let Ct,St;if(kt)Ct=parseFloat(kt.getAttribute("x")||"0"),St=parseFloat(kt.getAttribute("y")||"0");else{const Yt=Tt.getBBox();Ct=Yt.x+Yt.width/2,St=Yt.y+Yt.height/2}const Lt=a.clientWidth,Ft=1.2*u/Lt,Ht=u/2-Ct*Ft,ve=d/2-St*Ft;l.transition().duration(500).call(c.transform,Nt.translate(Ht,ve).scale(Ft))}}x&&x(at)}})}if(U&&t.edgeId!==void 0){const at=t.edgeId+1,ht=S?mt:it+X/2-E/2,yt=j.append("g").attr("class","nav-btn-group next-btn-group");yt.append("rect").attr("class","nav-btn-area next-btn-area").attr("x",it+X/2-E-O).attr("y",q-P/2).attr("width",E).attr("height",P).attr("fill","transparent").attr("rx",L).style("cursor","pointer").style("pointer-events","all"),yt.append("use").attr("class","nav-icon next-icon").attr("href","#nav-right").attr("x",ht-V/2).attr("y",q-V/2).attr("width",V).attr("height",V).attr("fill","#888"),yt.on("click",function($t){$t.stopPropagation();const Tt=ot(at);if(!Tt.empty()){if(c&&l&&a&&u&&d){const kt=Tt.node();if(kt){const Ct=st(kt).select(".label-text").node();let St,Lt;if(Ct)St=parseFloat(Ct.getAttribute("x")||"0"),Lt=parseFloat(Ct.getAttribute("y")||"0");else{const ee=kt.getBBox();St=ee.x+ee.width/2,Lt=ee.y+ee.height/2}const Ft=a.clientWidth,Ht=1.2*u/Ft,ve=u/2-St*Ht,Yt=d/2-Lt*Ht;l.transition().duration(500).call(c.transform,Nt.translate(ve,Yt).scale(Ht))}}x&&x(at)}})}S&&J&&x&&$.append("text").attr("class","close-btn").attr("x",ct).attr("y",q).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-family","Arial").attr("font-size","12px").attr("font-weight","bold").attr("fill","#888").style("cursor","pointer").text("✕").on("mouseenter",function(){st(this).attr("fill","#EF4444")}).on("mouseleave",function(){st(this).attr("fill","#888")}).on("click",function(at){at.stopPropagation(),x(null)})}else t._ldraw_&&t._ldraw_.forEach(f=>{if(f.op==="T"&&f.text){const p=f.size||10,A=p*.6,w=f.text.length*A,v=p,b=6,m=w+b*2,_=v+b*2,E=4,O=M.y;$.append("rect").attr("x",M.x-m/2).attr("y",O-_/2).attr("width",m).attr("height",_).attr("rx",E).attr("ry",E).attr("fill","white").attr("stroke","#d0d0d0").attr("stroke-width",.5),$.append("text").attr("x",M.x).attr("y",O).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-family",f.face||"Inter, Helvetica, Arial").attr("font-size",`${p}px`).attr("fill",f.color||"#666").text(f.text)}});if(N){let f;t.depth===0?f=`d:0 dir:${t.baseDirection||"base"} off:${t.baseOffset} id:${t._gvid}`:f=`d:${t.depth} dir:${t.baseDirection||"?"} midY:${Math.round(t.midY)} id:${t._gvid}`,$.append("text").attr("x",M.x).attr("y",M.y+15).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-family","monospace").attr("font-size","9px").attr("fill","#999").text(f)}}else t._draw_&&t._draw_.forEach(z=>{if(z.op==="b"&&z.points){const R=z.points.map(([I,Z])=>[I,n-Z]),H=`M${R[0][0]},${R[0][1]} C${R.slice(1).map(I=>`${I[0]},${I[1]}`).join(" ")}`;$.append("path").attr("d",H).attr("fill","none").attr("stroke",z.color||"#9AA4B2").attr("stroke-width",2)}}),t._hdraw_&&t._hdraw_.forEach(z=>{if(z.op==="P"&&z.points){const R=z.points.map(([H,I])=>[H,n-I]);$.append("polygon").attr("points",R.map(H=>H.join(",")).join(" ")).attr("fill",z.color||"#9AA4B2")}}),t._ldraw_&&Mt($,t._ldraw_,n)}function Ln(t,e,n,r,i=!0,s=jt,o=!0,c=14,l=!1,a,u,d,g,x){var M;t.innerHTML="";const N=((M=e.bb)==null?void 0:M.split(",").map(Number))||[0,0,1e3,800];let[,,S,T]=N;const $=st(t).append("svg").attr("width","100%").attr("height","100%").attr("viewBox",`0 0 ${S} ${T}`).style("background","white");$.append("defs").html(`
2
+ <style>
3
+ @keyframes selected-pulse {
4
+ 0%, 100% {
5
+ stroke-opacity: 1;
6
+ }
7
+ 50% {
8
+ stroke-opacity: 0.7;
9
+ }
10
+ }
11
+ .edge {
12
+ cursor: pointer;
13
+ }
14
+ .edge path {
15
+ /* No transition on dash properties to avoid conflict with animation */
16
+ }
17
+ .edge use {
18
+ transition: transform 0.2s ease;
19
+ }
20
+ .edge text {
21
+ transition: font-weight 0.2s ease;
22
+ }
23
+ /* Marching ants animation keyframe */
24
+ @keyframes marching-ants {
25
+ 0% { stroke-dashoffset: 0; }
26
+ 100% { stroke-dashoffset: -12; }
27
+ }
28
+ /* Hover effect: marching ants dashed line */
29
+ .edge:hover:not(.selected) path.edge-path {
30
+ stroke-dasharray: 6 6;
31
+ animation: marching-ants 0.6s linear infinite;
32
+ }
33
+ /* Selected effect: marching ants dashed line */
34
+ .edge.selected path.edge-path {
35
+ stroke-dasharray: 6 6;
36
+ animation: marching-ants 0.6s linear infinite;
37
+ }
38
+ .close-btn {
39
+ cursor: pointer;
40
+ }
41
+ /* Nav icon visibility - controlled purely by CSS */
42
+ .nav-icon {
43
+ opacity: 0;
44
+ transition: opacity 0.15s ease, fill 0.15s ease;
45
+ pointer-events: none;
46
+ }
47
+ /* Show nav icons when hovering over the label area group */
48
+ .label-area:hover .nav-icon {
49
+ opacity: 1;
50
+ }
51
+ /* Also show nav icons when hovering on selected edge's nav button */
52
+ .nav-btn-group:hover .nav-icon {
53
+ fill: #3B82F6 !important;
54
+ opacity: 1;
55
+ }
56
+ .nav-btn-area {
57
+ transition: fill 0.15s ease;
58
+ }
59
+ .nav-btn-group:hover .nav-btn-area {
60
+ fill: rgba(59, 130, 246, 0.1);
61
+ }
62
+ </style>
63
+ <symbol id="arrow-right" viewBox="0 0 12 12">
64
+ <path d="M11.53 5.46967C11.8229 5.76256 11.8229 6.23744 11.53 6.53033L6.75736 11.303C6.46447 11.5959 5.98959 11.5959 5.6967 11.303C5.40381 11.0101 5.40381 10.5352 5.6967 10.2423L9.93934 6L5.6967 1.75736C5.40381 1.46447 5.40381 0.989593 5.6967 0.696699C5.98959 0.403806 6.46447 0.403806 6.75736 0.696699L11.53 5.46967ZM0 5.25H11V6.75H0V5.25Z"/>
65
+ </symbol>
66
+ <symbol id="nav-left" viewBox="0 0 32 32">
67
+ <path d="M20.7073 25.2921C20.8002 25.385 20.8739 25.4953 20.9242 25.6167C20.9745 25.7381 21.0004 25.8682 21.0004 25.9996C21.0004 26.131 20.9745 26.2611 20.9242 26.3825C20.8739 26.5039 20.8002 26.6142 20.7073 26.7071C20.6144 26.8 20.5041 26.8737 20.3827 26.924C20.2613 26.9743 20.1312 27.0001 19.9998 27.0001C19.8684 27.0001 19.7383 26.9743 19.6169 26.924C19.4955 26.8737 19.3852 26.8 19.2923 26.7071L9.29231 16.7071C9.19933 16.6142 9.12557 16.5039 9.07525 16.3825C9.02493 16.2611 8.99902 16.131 8.99902 15.9996C8.99902 15.8682 9.02493 15.738 9.07525 15.6166C9.12557 15.4952 9.19933 15.385 9.29231 15.2921L19.2923 5.29208C19.4799 5.10444 19.7344 4.99902 19.9998 4.99902C20.2652 4.99902 20.5197 5.10444 20.7073 5.29208C20.895 5.47972 21.0004 5.73422 21.0004 5.99958C21.0004 6.26494 20.895 6.51944 20.7073 6.70708L11.4136 15.9996L20.7073 25.2921Z"/>
68
+ </symbol>
69
+ <symbol id="nav-right" viewBox="0 0 32 32">
70
+ <path d="M22.7076 16.7071L12.7076 26.7071C12.6147 26.8 12.5044 26.8737 12.383 26.924C12.2616 26.9743 12.1315 27.0001 12.0001 27.0001C11.8687 27.0001 11.7386 26.9743 11.6172 26.924C11.4958 26.8737 11.3855 26.8 11.2926 26.7071C11.1997 26.6142 11.126 26.5039 11.0757 26.3825C11.0254 26.2611 10.9995 26.131 10.9995 25.9996C10.9995 25.8682 11.0254 25.7381 11.0757 25.6167C11.126 25.4953 11.1997 25.385 11.2926 25.2921L20.5863 15.9996L11.2926 6.70708C11.1049 6.51944 10.9995 6.26494 10.9995 5.99958C10.9995 5.73422 11.1049 5.47972 11.2926 5.29208C11.4802 5.10444 11.7347 4.99902 12.0001 4.99902C12.2654 4.99902 12.5199 5.10444 12.7076 5.29208L22.7076 15.2921C22.8005 15.385 22.8743 15.4952 22.9246 15.6166C22.975 15.738 23.0009 15.8682 23.0009 15.9996C23.0009 16.131 22.975 16.2611 22.9246 16.3825C22.8743 16.5039 22.8005 16.6142 22.7076 16.7071Z"/>
71
+ </symbol>
72
+ `);const K=$.append("g").attr("id","graph0");l&&$.append("circle").attr("cx",S/2).attr("cy",T/2).attr("r",8).attr("fill","red").attr("opacity",.9).style("pointer-events","none").attr("class","debug-center-marker");const Q=(e.objects||[]).map(f=>new Rn({_gvid:f._gvid,name:f.name,_draw_:f._draw_,_ldraw_:f._ldraw_,bb:f.bb,pos:f.pos,width:d!==void 0?String(d/72):f.width,height:g!==void 0?String(g/72):f.height,label:f.label})),G=new Map;Q.forEach(f=>{G.set(f._gvid,f)});const et=(e.edges||[]).map(f=>{const p=new xs({_gvid:f._gvid,name:f.name,_draw_:f._draw_,_ldraw_:f._ldraw_,_hdraw_:f._hdraw_,_tdraw_:f._tdraw_,head:f.head,tail:f.tail,label:f.label}),A=f.tail!==void 0?G.get(f.tail):void 0,w=f.head!==void 0?G.get(f.head):void 0;return A&&w&&p.setNodes(A,w),p}),{nodeColumnMap:z,nodeColumns:R,edgeColumns:H}=Ns(Q,et);console.log("debug:",{nodeColumnMap:z,nodeColumns:R,edgeColumns:H}),console.log("debug: edges sorted by midpoint Y:",Object.fromEntries(Array.from(H.entries()).map(([f,p])=>[f,p.edges.map(A=>{const w=A.getStartPoint(),v=A.getEndPoint(),b=w&&v?(w.y+v.y)/2:0;return{name:A.name,edgeId:A.edgeId,direction:A.getDirection(),startPoint:A.getStartPoint(),endPoint:A.getEndPoint(),midpointY:b.toFixed(2)}})])));const I=Array.from(R.keys()).sort((f,p)=>f-p),Z=I.length,tt=80;let h;if(x!==void 0)h=x,S=(Z>1?(Z-1)*h:0)+2*tt;else{const f=S-2*tt;h=Z>1?f/(Z-1):0}if(I.forEach((f,p)=>{const A=R.get(f);if(!A)return;const w=A.nodes;if(w.length===0)return;console.log(`Column ${f} before sort:`,w.map(D=>({name:D.name,isVirtual:D.virtualNode,pos:D.pos})));const v=Z>1?tt+p*h:S/2;w.sort((D,X)=>{const P=D.getPosition(),L=X.getPosition();return!P||!L?0:L[1]-P[1]}),console.log(`Column ${f} after sort:`,w.map(D=>({name:D.name,isVirtual:D.virtualNode,pos:D.pos})));const b=50,m=w.filter(D=>!D.virtualNode),_=m.length;if(_===0){let D=(T+w.reduce((X,P)=>X+P.getHeightPoints(),0))/2;w.forEach(X=>{const P=X.getHeightPoints();D-=P/2,X.pos=`${v},${D}`,D-=P/2});return}let E,O;if(_%2===1){const D=Math.floor(_/2),X=m[D];O=w.indexOf(X),E=T/2}else{const D=_/2-1,X=_/2,P=m[D];m[X],O=w.indexOf(P),E=T/2}const J=w[O],rt=J.getHeightPoints();J.pos=`${v},${E}`,console.log(`Positioned center ${J.name} (virtual: ${J.virtualNode}) at ${J.pos}`);let U=E+rt/2;for(let D=O-1;D>=0;D--){const X=w[D],P=w[D+1],L=X.getHeightPoints(),q=X.virtualNode||P.virtualNode?0:b;U+=q+L/2,X.pos=`${v},${U}`,console.log(`Positioned ${X.name} (virtual: ${X.virtualNode}) at ${X.pos}, spacing: ${q}`),U+=L/2}U=E-rt/2;for(let D=O+1;D<w.length;D++){const X=w[D],P=w[D-1],L=X.getHeightPoints(),q=X.virtualNode||P.virtualNode?0:b;U-=q+L/2,X.pos=`${v},${U}`,console.log(`Positioned ${X.name} (virtual: ${X.virtualNode}) at ${X.pos}, spacing: ${q}`),U-=L/2}}),x!==void 0&&$.attr("viewBox",`0 0 ${S} ${T}`),R.forEach(f=>{f.nodes.forEach(p=>{const A=p.getPosition();if(!A)return;const[w,v]=A,b=p.getWidthPoints(),m=p.getHeightPoints(),_=p.virtualNode;if(_&&!l)return;const E=K.append("g").attr("class",_?"node virtual-node":"node").attr("id",p.name),O=l&&_,J=p.label?Dn(p.label):[],rt=P=>/^\[[^\]]+\]$/.test(P.trim()),U=[],D=[];for(const P of J)if(rt(P.trim())&&D.length===0){const L=P.trim().slice(1,-1);U.push(L)}else D.push(P);if((U.length>0?D.length>=1:D.length>=2)&&!_){const P=m/2,L=m/2,q=T-v-m/2;E.append("rect").attr("x",w-b/2).attr("y",q).attr("width",b).attr("height",P).attr("rx",5).attr("ry",0).attr("fill","#EDF2F7").attr("stroke","#D5DFEA").attr("stroke-width",1),E.append("rect").attr("x",w-b/2).attr("y",q+P).attr("width",b).attr("height",L).attr("rx",0).attr("ry",5).attr("fill","white").attr("stroke","#D5DFEA").attr("stroke-width",1);const it=E.append("rect").attr("x",w-b/2).attr("y",q).attr("width",b).attr("height",m).attr("rx",5).attr("ry",5).attr("fill","none").attr("stroke","#D5DFEA").attr("stroke-width",1),ot=E.append("rect").attr("x",w-b/2-4).attr("y",q-4).attr("width",b+8).attr("height",m+8).attr("rx",5).attr("ry",5).attr("fill","none").attr("stroke","#000000").attr("stroke-width",2).attr("opacity",0).style("pointer-events","none");it.style("cursor","pointer").on("mouseenter",function(){ot.attr("opacity",1)}).on("mouseleave",function(){ot.attr("opacity",0)});let V=w-b/2+8;const j=q+P/2,lt=7.2,mt=6,ct=18,te=4;if(U.forEach(ht=>{const $t=ht.length*lt+mt*2;E.append("rect").attr("x",V).attr("y",j-ct/2).attr("width",$t).attr("height",ct).attr("rx",5).attr("ry",5).attr("fill","#4E1E03").attr("stroke","#AA4E09").attr("stroke-width",1),E.append("text").attr("x",V+mt).attr("y",j).attr("text-anchor","start").attr("dominant-baseline","middle").attr("font-family","var(--font-inter), Inter, Helvetica, Arial").attr("font-size","12px").attr("font-weight","500").attr("fill","white").text(ht),V+=$t+te}),D.length>0){const ht=w+b/2-8-V,yt=E.append("text").attr("x",V).attr("y",j).attr("text-anchor","start").attr("dominant-baseline","middle").attr("font-family","var(--font-inter), Inter, Helvetica, Arial").attr("font-size","12px").attr("font-weight","600").attr("fill","#334155");$e(yt,ht,D[0])}const at=(U.length>0,1);if(D.length>at){const ht=b-16,yt=E.append("text").attr("x",w-b/2+8).attr("y",q+P+L/2).attr("text-anchor","start").attr("dominant-baseline","middle").attr("font-family","var(--font-fira-code), Fira Code, monospace").attr("font-size","12px").attr("font-weight","400").attr("fill","#334155");$e(yt,ht,D[at])}}else{const P=E.append("rect").attr("x",w-b/2).attr("y",T-v-m/2).attr("width",b).attr("height",m).attr("rx",5).attr("ry",5).attr("fill",O?"#FEF2F2":"white").attr("stroke",O?"#EF4444":"#D5DFEA").attr("stroke-width",O?2:1);if(!_){const L=E.append("rect").attr("x",w-b/2-4).attr("y",T-v-m/2-4).attr("width",b+8).attr("height",m+8).attr("rx",5).attr("ry",5).attr("fill","none").attr("stroke","#000000").attr("stroke-width",2).attr("opacity",0).style("pointer-events","none");P.style("cursor","pointer").on("mouseenter",function(){L.attr("opacity",1)}).on("mouseleave",function(){L.attr("opacity",0)})}if(p.label){if(_)E.append("text").attr("x",w).attr("y",T-v).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-family","Inter, Helvetica, Arial").attr("font-size","10px").attr("fill","#991B1B").text(p.label.length>20?p.label.slice(0,20)+"...":p.label);else if(J.length===1){const L=b-16,q=E.append("text").attr("x",w-b/2+8).attr("y",T-v).attr("text-anchor","start").attr("dominant-baseline","middle").attr("font-family","var(--font-fira-code), Fira Code, monospace").attr("font-size","12px").attr("font-weight","400").attr("fill","#334155");$e(q,L,J[0])}}}!p.label&&p._ldraw_&&p._ldraw_.length>0&&!_&&p._ldraw_.forEach(P=>{P.op==="T"&&P.text&&E.append("text").attr("x",w-b/2+8).attr("y",T-v).attr("text-anchor","start").attr("dominant-baseline","middle").attr("font-family",P.face||"Inter, Helvetica, Arial").attr("font-size",`${P.size||11}px`).attr("fill",P.color||"#334155").text(P.text)})})}),o){$s(R,T),ks(et,H),console.log("debug: base edges selected:",Object.fromEntries(Array.from(H.entries()).map(([m,_])=>{var E,O;return[m,{baseEdge:(E=_.baseEdge)==null?void 0:E.name,baseEdgeId:(O=_.baseEdge)==null?void 0:O.edgeId,baseEdgeIndex:_.baseEdgeIndex,totalEdges:_.edges.length,depth0Edges:_.edges.filter(J=>J.depth===0).length}]})));const f=s.loopRadius,p=s.edgeSpacing,A=s.labelHeight;H.forEach(m=>{const _=m.edges;if(_.length===0)return;const E=m.baseEdge,O=m.baseEdgeIndex;if(!E||O<0)return;const J=E.getStartPoint(),rt=E.getEndPoint();if(!J||!rt)return;const U=T-J.y,D=T-rt.y;E.midY=(U+D)/2;const X=se(E,T,void 0,s);X&&(E.midY=X.midY,E.orthogonalPathPoints=X.points),m.aboveY=E.midY,m.belowY=E.midY;for(let P=O-1;P>=0;P--){const L=_[P];if(L.depth!==0)continue;if(L.getDirection()==="self"){const j=L.getStartPoint();j&&(L.midY=T-j.y-f);continue}const it=L.label?p+A:p;L.midY=m.aboveY-it,m.aboveY=L.midY,L.baseDirection="above",L.baseOffset=-(O-P);const ot=P<_.length-1?_[P+1]:void 0,V=se(L,T,ot,s);V&&(L.midY=V.midY,L.orthogonalPathPoints=V.points,m.aboveY=L.midY)}for(let P=O+1;P<_.length;P++){const L=_[P];if(L.depth!==0)continue;if(L.getDirection()==="self"){const j=L.getStartPoint();j&&(L.midY=T-j.y-f);continue}const it=L.label?p+A:p;L.midY=m.belowY+it,m.belowY=L.midY,L.baseDirection="below",L.baseOffset=P-O;const ot=P>0?_[P-1]:void 0,V=se(L,T,ot,s);V&&(L.midY=V.midY,L.orthogonalPathPoints=V.points,m.belowY=L.midY)}});const w=[];H.forEach(m=>{const _=m.edges;_.length===0||m.baseEdge||!_.every(O=>O.depth>0)||_.forEach(O=>{if(O.getDirection()!=="self")w.push(O);else{const J=O.getStartPoint();J&&(O.midY=T-J.y-f)}})}),w.sort((m,_)=>m.depth-_.depth),console.log("Processing deep edges by depth:",{totalEdges:w.length,depths:[...new Set(w.map(m=>m.depth))].sort((m,_)=>m-_)});let v=1/0,b=-1/0;H.forEach(m=>{m.aboveY!==0&&(v=Math.min(v,m.aboveY)),m.belowY!==0&&(b=Math.max(b,m.belowY))}),R.forEach(m=>{m.aboveY!==0&&(v=Math.min(v,m.aboveY)),m.belowY!==0&&(b=Math.max(b,m.belowY))}),console.log("Global bounds before deep edges:",{globalAboveY:v,globalBelowY:b}),w.forEach(m=>{if(!m.sourceNode||!m.targetNode)return;const _=z.get(m.sourceNode._gvid),E=z.get(m.targetNode._gvid);if(_===void 0||E===void 0)return;const O=Math.min(_,E),J=Math.max(_,E),rt=[];for(let j=O;j<=J;j++){const lt=R.get(j);lt&&rt.push(...lt.nodes)}const U=rt.map(j=>{const lt=j.getPosition();if(!lt)return null;const mt=T-lt[1],ct=j.height?parseFloat(j.height)*72:40;return{y:mt,height:ct,bottomY:mt+ct/2}}).filter(j=>j!==null).sort((j,lt)=>j.y-lt.y);let D;if(U.length===0)D=(v+b)/2;else if(U.length%2===1)D=U[Math.floor(U.length/2)].bottomY;else{const j=U.length/2;D=(U[j-1].bottomY+U[j].bottomY)/2}const X=m.getStartPoint(),P=m.getEndPoint(),q=(X&&P?T-(X.y+P.y)/2:D)<D?"above":"below";m.baseDirection=q;const it=m.label?p+A:p;let ot;q==="above"?(m.midY=v-it,ot=v,v=m.midY):(m.midY=b+it,ot=b,b=m.midY),console.log("Placed deep edge:",{edgeId:m.edgeId,depth:m.depth,direction:q,midY:m.midY,centerNodeBottomY:D,globalAboveY:v,globalBelowY:b});const V=se(m,T,{midY:ot},s);V&&(m.midY=V.midY,m.orthogonalPathPoints=V.points,q==="above"?v=Math.min(v,V.midY):b=Math.max(b,V.midY))})}const k=et.map(f=>f.edgeId).filter(f=>f!==void 0),y=k.length>0?Math.min(...k):0,C=k.length>0?Math.max(...k):0,Y=Oe().scaleExtent([.1,ys(t,S,c)]).on("zoom",f=>{const p=f.transform;console.log("zoom event:",{x:p.x,y:p.y,k:p.k,isNaN:isNaN(p.x)||isNaN(p.y)||isNaN(p.k)}),!isNaN(p.x)&&!isNaN(p.y)&&!isNaN(p.k)&&K.attr("transform",p.toString())});if($.call(Y),et.forEach(f=>{if(r!=null){if(i){if(f.depth>r)return}else if(f.depth!==r)return}Cs(f,K,T,s,o,y,C,Y,$,t,S,T,a,u,l)}),l){const f=K.node();if(f){const p=f.getBBox(),A=p.x+p.width/2,w=p.y+p.height/2;K.append("rect").attr("x",p.x).attr("y",p.y).attr("width",p.width).attr("height",p.height).attr("fill","none").attr("stroke","yellow").attr("stroke-width",3).attr("opacity",.8).style("pointer-events","none").attr("class","debug-root-border"),K.append("circle").attr("cx",A).attr("cy",w).attr("r",10).attr("fill","yellow").attr("stroke","orange").attr("stroke-width",2).attr("opacity",.9).style("pointer-events","none").attr("class","debug-geometric-center")}}const B=K.node();if(B){const f=B.getBBox(),p=.9*S/f.width,A=f.x+f.width/2,w=f.y+f.height/2,v=S/2-A*p,b=T/2-w*p;$.call(Y.transform,Nt.translate(v,b).scale(p))}return{zoomBehavior:Y,svgElement:$.node(),gElement:K.node(),baseFontSize:c,viewBoxWidth:S}}function Mt(t,e,n){let r="#000000",i="#000000",s="#000000";e.forEach(o=>{switch(o.op){case"c":o.color&&(r=o.color);break;case"C":o.color&&(i=o.color);break;case"F":o.color&&(s=o.color);break;case"T":o.pt&&o.text&&t.append("text").attr("x",o.pt[0]).attr("y",n-o.pt[1]).attr("text-anchor",o.align==="l"?"start":o.align==="r"?"end":"middle").attr("font-family",o.face||"Inter, Helvetica, Arial").attr("font-size",`${o.size||12}px`).attr("fill",o.color||s).text(o.text);break;case"p":if(o.points){const c=o.points.map(([l,a])=>[l,n-a]);t.append("polygon").attr("points",c.map(l=>l.join(",")).join(" ")).attr("fill",i).attr("stroke",r)}break;case"P":if(o.points){const c=o.points.map(([l,a])=>[l,n-a]);t.append("polygon").attr("points",c.map(l=>l.join(",")).join(" ")).attr("fill","none").attr("stroke",r)}break;case"e":if(o.rect){const[c,l,a,u]=o.rect;t.append("ellipse").attr("cx",c).attr("cy",n-l).attr("rx",a).attr("ry",u).attr("fill",i).attr("stroke",r)}break;case"E":if(o.rect){const[c,l,a,u]=o.rect;t.append("ellipse").attr("cx",c).attr("cy",n-l).attr("rx",a).attr("ry",u).attr("fill","none").attr("stroke",r)}break;case"b":if(o.points){const c=o.points.map(([a,u])=>[a,n-u]),l=`M${c[0][0]},${c[0][1]} C${c.slice(1).map(a=>`${a[0]},${a[1]}`).join(" ")}`;t.append("path").attr("d",l).attr("fill","none").attr("stroke",r).attr("stroke-width",1)}break;case"B":if(o.points){const c=o.points.map(([a,u])=>[a,n-u]),l=`M${c[0][0]},${c[0][1]} C${c.slice(1).map(a=>`${a[0]},${a[1]}`).join(" ")}`;t.append("path").attr("d",l).attr("fill",i).attr("stroke",r).attr("stroke-width",1)}break;case"L":if(o.points){const l=`M${o.points.map(([a,u])=>[a,n-u]).map(a=>`${a[0]},${a[1]}`).join(" L")}`;t.append("path").attr("d",l).attr("fill","none").attr("stroke",r).attr("stroke-width",1)}break}})}function Ss(t,e,n=14){var x;t.innerHTML="";const r=((x=e.bb)==null?void 0:x.split(",").map(Number))||[0,0,1e3,800],[,,i,s]=r,o=st(t).append("svg").attr("width","100%").attr("height","100%").attr("viewBox",`0 0 ${i} ${s}`).style("background","white");o.append("defs").html(`
73
+ <style>
74
+ .node rect, .node ellipse, .node polygon {
75
+ cursor: pointer;
76
+ }
77
+ .edge {
78
+ cursor: pointer;
79
+ }
80
+ </style>
81
+ `);const c=o.append("g").attr("id","graph0");(e.objects||[]).forEach(N=>{const S=c.append("g").attr("class","node").attr("id",N.name);N._draw_&&Mt(S,N._draw_,s),N._ldraw_&&Mt(S,N._ldraw_,s)}),(e.edges||[]).forEach(N=>{const S=c.append("g").attr("class","edge").attr("id",`edge_${N._gvid}`);N._draw_&&Mt(S,N._draw_,s),N._hdraw_&&Mt(S,N._hdraw_,s),N._tdraw_&&Mt(S,N._tdraw_,s),N._ldraw_&&Mt(S,N._ldraw_,s)});const u=Oe().scaleExtent([.1,10]).on("zoom",N=>{c.attr("transform",N.transform.toString())});o.call(u);const d=t.clientWidth||800,g=n*(d/i);return{zoomBehavior:u,svgElement:o.node(),gElement:c.node(),baseFontSize:g,viewBoxWidth:i}}function Fn(){const t=nt.useRef(null),e=nt.useRef(null),[n,r]=nt.useState(!1),[i,s]=nt.useState(null),o=nt.useCallback(()=>{const a=new Worker(new URL("/assets/graphvizWorker-Bbv8iQW7.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:_e&&_e.tagName.toUpperCase()==="SCRIPT"&&_e.src||new URL("index.js",document.baseURI).href),{type:"module"});return a.onmessage=u=>{const{id:d,success:g,json:x,error:N}=u.data;if(e.current&&e.current.id===d){if(r(!1),g&&x)e.current.resolve(x);else{const S=new Error(N||"Unknown worker error");s(S.message),e.current.reject(S)}e.current=null}},a.onerror=u=>{r(!1);const d=new Error(`Worker error: ${u.message}`);s(d.message),e.current&&(e.current.reject(d),e.current=null)},a},[]);nt.useEffect(()=>(t.current=o(),()=>{var a;(a=t.current)==null||a.terminate(),t.current=null}),[o]);const c=nt.useCallback(a=>new Promise((u,d)=>{if(!t.current){d(new Error("Worker not initialized"));return}e.current&&e.current.reject(new Error("Request cancelled"));const g=Math.random().toString(36).slice(2);e.current={id:g,resolve:u,reject:d},r(!0),s(null);const x={id:g,dot:a};t.current.postMessage(x)}),[]),l=nt.useCallback(()=>{e.current&&(console.warn("Graphviz worker: Request cancelled by user"),e.current.reject(new Error("Cancelled by user")),e.current=null,r(!1)),t.current&&(t.current.terminate(),t.current=o())},[o]);return{layout:c,cancel:l,isLoading:n,error:i}}function Hn({onCancel:t}){return dt.jsx("div",{className:"absolute inset-0 bg-gray-900/80 flex flex-col items-center justify-center z-40",children:dt.jsxs("div",{className:"flex flex-col items-center gap-4",children:[dt.jsx("div",{className:"w-12 h-12 border-4 border-blue-500/30 border-t-blue-500 rounded-full animate-spin"}),dt.jsxs("div",{className:"text-center",children:[dt.jsx("p",{className:"text-white font-medium mb-1",children:"Processing layout..."}),dt.jsx("p",{className:"text-gray-400 text-sm",children:"This may take a while for large graphs"})]}),dt.jsx("button",{onClick:t,className:"mt-2 px-4 py-2 rounded-lg bg-red-600/80 text-white hover:bg-red-600 transition-colors text-sm",children:"Cancel"})]})})}const As=nt.forwardRef(function({dotString:e,nodeMapping:n={},svgFontSize:r=14,loadingIndicator:i,onSuccess:s,onError:o,onZoom:c,onRenderProgress:l,className:a="",showLoading:u=!0,debug:d=!1,selectedEdgeId:g=null,onEdgeSelect:x,useNativeRendering:N=!1,nodeWidth:S=240,nodeHeight:T=64,nodeColumnSpacing:$=800},K){const W=nt.useRef(null),{layout:Q,cancel:G,isLoading:F,error:et}=Fn(),z=nt.useRef(null),R=nt.useRef(null),H=nt.useRef(null),I=nt.useRef(14),Z=nt.useRef(1e3),tt=nt.useRef(!1),h=nt.useRef(null),k=nt.useRef(null),y=nt.useRef(null),C=nt.useRef(null),Y=nt.useRef(x);return Y.current=x,nt.useImperativeHandle(K,()=>({zoomIn:(B=10)=>{var b,m;if(!z.current||!R.current||!H.current)return;const M=qt(H.current),f=1+B/100,p=M.k*f,A=st(R.current),w=((b=W.current)==null?void 0:b.clientWidth)||1,v=((m=W.current)==null?void 0:m.clientHeight)||1;A.transition().duration(300).call(z.current.scaleTo,p,[w/2,v/2])},zoomOut:(B=10)=>{var b,m;if(!z.current||!R.current||!H.current)return;const M=qt(H.current),f=1-B/100,p=Math.max(.1,M.k*f),A=st(R.current),w=((b=W.current)==null?void 0:b.clientWidth)||1,v=((m=W.current)==null?void 0:m.clientHeight)||1;A.transition().duration(300).call(z.current.scaleTo,p,[w/2,v/2])},toggleZoom:()=>{var lt,mt;if(!z.current||!R.current||!H.current)return;const B=st(R.current),M=((lt=W.current)==null?void 0:lt.clientWidth)||1;(mt=W.current)!=null&&mt.clientHeight;const f=I.current,p=R.current.getAttribute("viewBox");if(!p)return;const[,,A,w]=p.split(" ").map(Number);if(isNaN(A)||isNaN(w))return;if(!k.current){const ct=H.current.getBBox();k.current={x:ct.x,y:ct.y,width:ct.width,height:ct.height}}const v=k.current;if(console.log("rootBBox:",v),isNaN(v.x)||isNaN(v.y)||isNaN(v.width)||isNaN(v.height)){console.error("rootBBox contains NaN values, recalculating...");const ct=H.current.getBBox();k.current={x:ct.x,y:ct.y,width:ct.width,height:ct.height}}const b=v.x+v.width/2,m=v.y+v.height/2,_=M/A,E=.9*A/v.width,O=f*_*E,rt=16/(f*_),U=f*_*rt,D=Math.min(E,rt),X=Math.max(E,rt),P=qt(R.current),L=f*_*P.k;console.log("toggleZoom debug:",{currentState:tt.current?"zoomedIn":"zoomedOut",currentScale:P.k,currentFontSize:L,overviewScale:E,overviewFontSize:O,detailScale:rt,detailFontSize:U,zoomOutScale:D,zoomInScale:X});let q;tt.current?(q=D,tt.current=!1):(q=X,h.current=qt(R.current),tt.current=!0),console.log("toggleZoom target:",{targetScale:q,targetFontSize:f*_*q,newState:tt.current?"zoomedIn":"zoomedOut"});const it=A/2-b*q,ot=w/2-m*q,V=Nt.translate(it,ot).scale(q);console.log("newTransform:",{x:V.x,y:V.y,k:V.k}),st(H.current).transition().duration(500).attr("transform",V.toString()).on("end",()=>{B.call(z.current.transform,V)})},stopRendering:()=>{C.current&&(clearInterval(C.current),C.current=null),y.current=null,G(),W.current&&(W.current.innerHTML=""),tt.current=!1,h.current=null}}),[G]),nt.useEffect(()=>{if(!e||!W.current)return;let B=!1;return y.current=Date.now(),l&&(C.current=setInterval(()=>{if(y.current){const M=Date.now()-y.current;l(M)}},100)),Q(e).then(M=>{var p;if(B)return;const f=JSON.parse(M);if(W.current){let A=r;if(f.objects){for(const v of f.objects)if(v._ldraw_)for(const b of v._ldraw_)b.size&&b.size>A&&(A=b.size)}let w;if(N?w=Ss(W.current,f,A):w=Ln(W.current,f,n,null,!0,Tn(),!0,A,d,null,v=>{var b;return(b=Y.current)==null?void 0:b.call(Y,v)},S,T,$),z.current=w.zoomBehavior,R.current=w.svgElement,H.current=w.gElement,I.current=w.baseFontSize,Z.current=w.viewBoxWidth,H.current){const v=H.current.getBBox();k.current={x:v.x,y:v.y,width:v.width,height:v.height};const b=Z.current,m=((p=W.current)==null?void 0:p.clientWidth)||1,_=I.current,E=m/b,O=.9*b/v.width,J=16/(_*E);tt.current=O>=J}if(h.current=null,C.current&&(clearInterval(C.current),C.current=null),y.current=null,c){const v=W.current.querySelector("svg"),b=v==null?void 0:v.querySelector("#graph0");if(v&&b){const m=A,_=v.getAttribute("viewBox");let E=1e3;if(_){const[,,U]=_.split(" ").map(Number);U&&(E=U)}const O=()=>{var q;const U=b.getAttribute("transform");let D=1;if(U){const it=U.match(/scale\(([^,)]+)/);if(it){const ot=parseFloat(it[1]);isNaN(ot)||(D=ot)}else{const ot=U.match(/matrix\(([^,)]+)/);if(ot){const V=parseFloat(ot[1]);isNaN(V)||(D=V)}}}const P=(((q=W.current)==null?void 0:q.clientWidth)||1)/E,L=m*P*D;!isNaN(L)&&!isNaN(D)&&c({baseFontSize:m,actualFontSize:L,scale:D})};O();const J=new MutationObserver(O);J.observe(b,{attributes:!0,attributeFilter:["transform"]});const rt=()=>O();return window.addEventListener("resize",rt),()=>{J.disconnect(),window.removeEventListener("resize",rt)}}}}s==null||s(f)}).catch(M=>{B||(C.current&&(clearInterval(C.current),C.current=null),y.current=null,M.message!=="Cancelled by user"&&M.message!=="Request cancelled"&&(console.error("GraphvizRenderer error:",M),W.current&&(W.current.innerHTML=`<div style="padding: 1rem; color: #ef4444"><strong>Error rendering graph:</strong> ${M.message}</div>`),o==null||o(M instanceof Error?M:new Error(String(M)))))}),()=>{B=!0,C.current&&(clearInterval(C.current),C.current=null),y.current=null,G()}},[e,n,r,l,d,N,S,T,$]),nt.useEffect(()=>{var M;if(N||!W.current)return;const B=W.current.querySelector("svg");if(B&&(B.querySelectorAll("g.edge.selected").forEach(f=>{f.classList.remove("selected"),f.querySelectorAll(".close-btn, .close-btn-bg").forEach(p=>p.remove())}),g!=null)){const f=B.querySelector(`g.edge[data-edge-id="${g}"]`);if(f){f.classList.add("selected"),(M=f.parentNode)==null||M.appendChild(f);const p=f.querySelector(".label-bg");if(p&&x){p.getBoundingClientRect();const A=f.querySelector(".label-text");if(A){const w=A.getAttribute("y"),v=parseFloat(p.getAttribute("x")||"0"),b=parseFloat(p.getAttribute("width")||"0"),m=v+b+16;if(!f.querySelector(".close-btn")){const _=document.createElementNS("http://www.w3.org/2000/svg","circle");_.setAttribute("class","close-btn-bg"),_.setAttribute("cx",String(m)),_.setAttribute("cy",w||"0"),_.setAttribute("r","8"),_.setAttribute("fill","white"),_.setAttribute("stroke","#d0d0d0"),_.setAttribute("stroke-width","1"),_.style.cursor="pointer";const E=document.createElementNS("http://www.w3.org/2000/svg","text");E.setAttribute("class","close-btn"),E.setAttribute("x",String(m)),E.setAttribute("y",w||"0"),E.setAttribute("text-anchor","middle"),E.setAttribute("dominant-baseline","central"),E.setAttribute("font-family","Arial"),E.setAttribute("font-size","12px"),E.setAttribute("font-weight","bold"),E.setAttribute("fill","#888"),E.style.cursor="pointer",E.textContent="✕";const O=J=>{J.stopPropagation(),x(null)};_.addEventListener("click",O),E.addEventListener("click",O),f.appendChild(_),f.appendChild(E)}}}}}},[g,x,N]),dt.jsxs("div",{className:`graphviz-renderer ${a}`.trim(),style:{position:"relative",width:"100%",height:"100%"},children:[dt.jsx("div",{ref:W,style:{width:"100%",height:"100%"}}),F&&u&&(i??dt.jsx(Hn,{onCancel:G})),et&&!F&&dt.jsxs("div",{style:{padding:"1rem",color:"#ef4444"},children:[dt.jsx("strong",{children:"Error:"})," ",et]})]})});exports.DEFAULT_LAYOUT_CONFIG=jt;exports.GraphvizRenderer=As;exports.LARGE_GRAPH_THRESHOLD=On;exports.WorkerLoadingIndicator=Hn;exports.createLayoutConfig=Tn;exports.renderCustomGraph=Ln;exports.setupZoomPan=_s;exports.useGraphvizWorker=Fn;