apexsankey 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -98,6 +98,27 @@ The layout can be configured by passing a second argument to `ApexSankey` with t
98
98
  | `fontSize` | `string` | `'14px'` | CSS font-size for node labels. |
99
99
  | `fontWeight` | `string` | `'400'` | CSS font-weight for node labels. |
100
100
  | `a11y` | `{ enabled?: boolean, diagramLabel?: string, description?: string }` | `{ enabled: true }` | WCAG 2.1 AA accessibility options. |
101
+ | `locale` | `{ direction?: 'ltr' \| 'rtl' \| 'auto', messages?: Partial<SankeyMessages> }` | `{ direction: 'ltr' }` | Localization and text-direction. `direction: 'rtl'` mirrors the diagram horizontally (flows read right-to-left) and sets `dir="rtl"` on the container (`'auto'` defers to the document). `messages` overrides the screen-reader strings the diagram generates. |
102
+
103
+ ### Localization & RTL
104
+
105
+ The diagram's screen-reader strings live in `SankeyMessages`; pass a `Partial<SankeyMessages>` via `locale.messages` to translate any subset (unset keys keep their English defaults, exported as `DEFAULT_SANKEY_MESSAGES`). Visible tooltips are localized separately via `tooltipTemplate` / `nodeTooltipTemplate`.
106
+
107
+ | `SankeyMessages` key | Type | Description |
108
+ | --- | --- | --- |
109
+ | `diagramLabel` | `(ctx: SankeyDiagramLabelContext) => string` | SVG root aria-label summary (node/flow counts + largest flow). |
110
+ | `nodeAriaLabel` | `(ctx: SankeyNodeLabelContext) => string` | Per-node aria-label (incoming/outgoing flow summary). |
111
+ | `edgeAriaLabel` | `(ctx: SankeyEdgeLabelContext) => string` | Per-edge aria-label. Default: `Flow from {source} to {target}: {value} units`. |
112
+ | `nodesGroupLabel` | `string` | aria-label for the `<g>` wrapping all nodes. Default: `'Sankey nodes'`. |
113
+
114
+ ```ts
115
+ const sankey = new ApexSankey(el, {
116
+ locale: {
117
+ direction: 'rtl',
118
+ messages: {nodesGroupLabel: 'العقد'},
119
+ },
120
+ });
121
+ ```
101
122
 
102
123
  Default tooltip template
103
124
 
package/apexsankey.d.ts CHANGED
@@ -23,6 +23,8 @@ declare class WrappedEl {}
23
23
 
24
24
 
25
25
 
26
+ declare type TextDirection = 'ltr' | 'rtl' | 'auto';
27
+
26
28
 
27
29
 
28
30
  /** Options for WCAG 2.1 AA accessibility support */
@@ -136,6 +138,8 @@ export declare interface CommonOptions {
136
138
  readonly enableToolbar: boolean;
137
139
  /** Height of the canvas. Use `'auto'` to derive height from width at a 1.6:1 ratio. @default 'auto' */
138
140
  readonly height: number | string;
141
+ /** Localization and text-direction (RTL) options. See {@link LocaleOptions}. @default { direction: 'ltr' } */
142
+ readonly locale?: LocaleOptions;
139
143
  /** Horizontal spacing between node columns in pixels. @default 20 */
140
144
  readonly spacing: number;
141
145
  /** Internal SVG viewport height in pixels. @default 500 */
@@ -146,6 +150,12 @@ export declare interface CommonOptions {
146
150
  readonly width: number | string;
147
151
  }
148
152
 
153
+ /**
154
+ * English defaults for every {@link SankeyMessages} string. These reproduce the
155
+ * exact screen-reader text the diagram generated before localization support.
156
+ */
157
+ export declare const DEFAULT_SANKEY_MESSAGES: SankeyMessages;
158
+
149
159
  /** Label attached to a graph edge during the layout pipeline */
150
160
  declare interface EdgeLabel {
151
161
  value?: number;
@@ -271,6 +281,24 @@ export declare interface LayoutOptions {
271
281
  readonly whitespace: number;
272
282
  }
273
283
 
284
+ /**
285
+ * Localization and text-direction options.
286
+ *
287
+ * With the defaults (`direction: 'ltr'`, no message overrides) the output is
288
+ * byte-for-byte identical to builds that predate i18n support.
289
+ */
290
+ export declare interface LocaleOptions {
291
+ /**
292
+ * Text and layout direction. `'rtl'` mirrors the diagram horizontally (flows
293
+ * read right-to-left) and sets `dir="rtl"` on the container; `'auto'` defers
294
+ * to the document/element direction.
295
+ * @default 'ltr'
296
+ */
297
+ readonly direction?: TextDirection;
298
+ /** Overrides for screen-reader strings. See {@link SankeyMessages}. */
299
+ readonly messages?: Partial<SankeyMessages>;
300
+ }
301
+
274
302
  /** Shape of node user data attached to a graph node */
275
303
  export declare interface NodeData {
276
304
  id?: string;
@@ -342,6 +370,30 @@ declare class Paper {
342
370
  get width(): number;
343
371
  }
344
372
 
373
+ /** Context passed to {@link SankeyMessages.diagramLabel}. */
374
+ export declare interface SankeyDiagramLabelContext {
375
+ /** Number of (non-dummy) nodes in the diagram. */
376
+ readonly nodeCount: number;
377
+ /** Number of flows (edges). */
378
+ readonly flowCount: number;
379
+ /** The single largest flow, omitted when no value-bearing flow exists. */
380
+ readonly largestFlow?: {
381
+ readonly source: string;
382
+ readonly target: string;
383
+ readonly value: number;
384
+ };
385
+ }
386
+
387
+ /** Context passed to {@link SankeyMessages.edgeAriaLabel}. */
388
+ export declare interface SankeyEdgeLabelContext {
389
+ /** Source node name. */
390
+ readonly source: string;
391
+ /** Target node name. */
392
+ readonly target: string;
393
+ /** Flow value. */
394
+ readonly value: number;
395
+ }
396
+
345
397
  /** Generic graph interface for layout algorithms that only need basic traversal. */
346
398
  declare interface SankeyGraph {
347
399
  nodes(): string[];
@@ -406,14 +458,46 @@ declare class SankeyGraphRenderer extends Paper {
406
458
  private pathHighlighter;
407
459
  /** Guard: entrance animation plays only on the first render. */
408
460
  private _hasAnimated;
461
+ /** Resolved, localized screen-reader strings. */
462
+ private messages;
409
463
  constructor(element: HTMLElement, options: SankeyOptions, chartContext: ChartContext);
464
+ /** Resolved, localized screen-reader strings (English defaults + `locale.messages`). */
465
+ getMessages(): SankeyMessages;
466
+ /** Whether the current `locale.direction` resolves to right-to-left. */
467
+ private get isRtl();
410
468
  construct(data: GraphData): void;
469
+ /**
470
+ * Mirror the laid-out diagram horizontally so flows read right-to-left.
471
+ * Node centers and edge endpoints are reflected around a common axis (the
472
+ * midpoint of all node centers), which keeps every edge attached to the
473
+ * correct node face. Runs once per `construct`, so re-renders redraw the
474
+ * already-mirrored positions without compounding.
475
+ */
476
+ private mirrorLayoutForRtl;
411
477
  render({ keepOldPosition }?: {
412
478
  keepOldPosition?: boolean | undefined;
413
479
  }): void;
414
480
  renderEdge(edgeObj: GraphEdge, group: G): void;
415
481
  }
416
482
 
483
+ /**
484
+ * Every user-facing string the Sankey diagram generates internally (the
485
+ * screen-reader summaries and group labels). Override any subset via
486
+ * {@link LocaleOptions.messages}; unset keys keep their English defaults
487
+ * ({@link DEFAULT_SANKEY_MESSAGES}). Visible tooltips are localized separately
488
+ * through `tooltipTemplate` / `nodeTooltipTemplate`.
489
+ */
490
+ export declare interface SankeyMessages {
491
+ /** Builds the SVG root aria-label summary. */
492
+ readonly diagramLabel: (ctx: SankeyDiagramLabelContext) => string;
493
+ /** Builds an edge path's aria-label. */
494
+ readonly edgeAriaLabel: (ctx: SankeyEdgeLabelContext) => string;
495
+ /** Builds a node group's aria-label. */
496
+ readonly nodeAriaLabel: (ctx: SankeyNodeLabelContext) => string;
497
+ /** aria-label for the `<g>` wrapping all nodes. @default 'Sankey nodes' */
498
+ readonly nodesGroupLabel: string;
499
+ }
500
+
417
501
  /** Data passed to the onNodeClick callback */
418
502
  export declare interface SankeyNode {
419
503
  value?: number;
@@ -427,6 +511,22 @@ export declare interface SankeyNode {
427
511
  data?: NodeData | null;
428
512
  }
429
513
 
514
+ /** Context passed to {@link SankeyMessages.nodeAriaLabel}. */
515
+ export declare interface SankeyNodeLabelContext {
516
+ /** Resolved node display name. */
517
+ readonly name: string;
518
+ /** Incoming flow summary, omitted when the node has no incoming flows. */
519
+ readonly incoming?: {
520
+ readonly total: number;
521
+ readonly sources: readonly string[];
522
+ };
523
+ /** Outgoing flow summary, omitted when the node has no outgoing flows. */
524
+ readonly outgoing?: {
525
+ readonly total: number;
526
+ readonly targets: readonly string[];
527
+ };
528
+ }
529
+
430
530
  /**
431
531
  * Full configuration type for `ApexSankey`. An intersection of all sub-option
432
532
  * interfaces: `CommonOptions & EdgeOptions & FontOptions & InteractionOptions &
@@ -436,6 +536,8 @@ export declare interface SankeyNode {
436
536
  */
437
537
  export declare type SankeyOptions = CommonOptions & EdgeOptions & FontOptions & InteractionOptions & AnimationOptions & LayoutOptions & NodeOptions & TooltipOptions & A11yOptions;
438
538
 
539
+ export { TextDirection }
540
+
439
541
  /** Data passed to the tooltipTemplate callback */
440
542
  export declare interface TooltipContent {
441
543
  source?: NodeData | null;
@@ -1 +1 @@
1
- const t=()=>{};class e{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),o=Array.from(e);return{item:t=>o[t]||null,get length(){return o.length},[Symbol.iterator]:()=>o[Symbol.iterator](),...Object.fromEntries(o.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,o):this.context.addEventListener(t,e,o)}removeEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,o):this.context.removeEventListener(t,e,o)}injectStyles(t,e,o={}){const{force:n=!1,priority:i="normal"}=o;if(!n&&this.injectedStyles.has(e))return;if(n){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!n)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:o})=>{this.injectStyles(t,e,o)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class o{constructor(t,o){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new e(t,o)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,o){this.chartContext.addEventListener(t,e,o)}removeEventListener(t,e,o){this.chartContext.removeEventListener(t,e,o)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class n{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const i="http://www.w3.org/2000/svg";let r=0;class s{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:o}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==o&&this.node.setAttribute("stroke-dasharray",String(o)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof s?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new s(e):null}first(){const t=this.node.firstElementChild;return t?new s(t):null}}class a extends s{constructor(t){super(document.createElementNS(i,"g")),t&&this.attr(t)}}class d extends s{constructor(){super(document.createElementNS(i,"rect"))}}class l extends s{constructor(t){super(document.createElementNS(i,"path")),t&&this.attr(t)}}class h extends s{constructor(){super(document.createElementNS(i,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(i,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class c{constructor(t){this.gradient=t}stop(t,e){const o=document.createElementNS(i,"stop");o.setAttribute("offset",String(t)),o.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(o)}}function u(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class p{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}add(t){return this.node.appendChild(t instanceof s?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(i,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const o=document.createElementNS(i,"linearGradient"),n="apx-grad-"+ ++r;return o.setAttribute("id",n),o.setAttribute("x1","0%"),o.setAttribute("y1","0%"),o.setAttribute("x2","100%"),o.setAttribute("y2","0%"),e(new c(o)),this._defs.appendChild(o),o}panZoom(t={}){return this._panZoomState=function(t,e){const o=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),n={zoomFactor:e.zoomFactor??.2,zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...o},vb:{...o}};t.addEventListener("wheel",(e=>{let o;if(e.preventDefault(),e.ctrlKey){const t=.005;o=1+Math.max(-.15,Math.min(.15,e.deltaY*t))}else o=e.deltaY<0?1-n.zoomFactor:1+n.zoomFactor;const i=n.currentZoom/o;if(i<n.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=n,l=d.w*o,h=d.h*o,c=d.x+s*(d.w-l),p=d.y+a*(d.h-h);n.vb={x:c,y:p,w:l,h:h},n.currentZoom=i,u(t,n.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const o=e.clientX-a,n=e.clientY-d;if(Math.abs(o)<4&&Math.abs(n)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const o=t.getBoundingClientRect(),l=n.vb.w/o.width,h=n.vb.h/o.height,c=(e.clientX-a)*l,p=(e.clientY-d)*h;n.vb={x:n.vb.x-c,y:n.vb.y-p,w:n.vb.w,h:n.vb.h},u(t,n.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),n}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const o=this._panZoomState;if(t<o.zoomMin)return this;const n=o.currentZoom/t,{vb:i}=o,r=i.w*n,s=i.h*n,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return o.vb={x:a,y:d,w:r,h:s},o.currentZoom=t,u(this.node,o.vb),this}}function g(t,e,o,n){const i=new a;return i.attr({"data-parent":n,"data-self":o,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const f={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class m{constructor(t,o){this.element=t,t&&(this.chartContext=o||new e(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n right: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n right: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,o){const n=this.chartContext.createElement("div");return n.id=t,n.className="toolbar-item",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.innerHTML=e,o&&(n.setAttribute("data-tooltip",o),n.setAttribute("aria-label",o)),n.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())})),n}render({enableExport:e=!1,enableFitscreen:o=!1,enableZoom:n=!1,onExport:i=t,onFitscreen:r=t,onZoom:s=t}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),e){const t=this.createToolbarItem("export",f.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(n){const t=this.createToolbarItem("zoom-in",f["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",f["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(o){const t=this.createToolbarItem("fit-screen",f["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const v="aria-hidden",y=(t,e="apex-tooltip-container")=>{let o=t.getElementById(e);if(!o){o=t.createElement("div"),o.id=e,o.setAttribute("role","tooltip"),o.setAttribute(v,"true");t.getAppendContainer().appendChild(o),t.trackTooltip(o)}return o},b=(t,e="",o,n="",i=!1)=>{const r=t.getElementById(e);if(!r)return y(t,e),b(t,e,o,n,i);if(o&&n){const e=n.includes("tooltip-content"),s=o.match(/background-color:\s*([^;]+);?/),a=o.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=n;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${n}</div>`}const d=o+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(r.setAttribute("style",d),r.classList.add("visible"),r.setAttribute(v,"false"),i&&"undefined"!=typeof window){const e=r.offsetWidth,o=parseFloat(r.style.left),n=t.getChartBounds();if(e>0&&!Number.isNaN(o)&&n.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=n.left+t,s=((t,e,o,n,i=8)=>{if(t+e<=o-i)return t;const r=t-e;return r<n+i?Math.max(n+i,o-e-i):r})(o,e,n.right+t,i);s!==o&&(r.style.left=`${s}px`)}}}else r.removeAttribute("style"),r.classList.remove("visible"),r.setAttribute(v,"true"),r.innerHTML=""},x=({bgColor:t,borderColor:e,fontColor:o,fontFamily:n,fontSize:i,fontWeight:r,maxWidth:s,padding:a,placement:d="top",x:l,y:h})=>{const c=["position: absolute;","z-index: 1000;","pointer-events: none;"];return c.push("box-sizing: border-box;"),c.push("word-wrap: break-word;"),c.push("overflow-wrap: break-word;"),c.push(`left: ${l}px;`),c.push(`top: ${h}px;`),c.push(`data-placement: ${d};`),s&&(c.push(`width: ${s}px;`),c.push(`max-width: ${s}px;`)),e&&c.push(`border: 1px solid ${e};`),o&&c.push(`color: ${o};`),n&&c.push(`font-family: ${n};`),r&&c.push(`font-weight: ${r};`),i&&c.push(`font-size: ${i};`),t&&(c.push(`background-color: ${t};`),c.push("border-radius: 6px;"),c.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&c.push(`padding: ${a}px;`),c.join(" ")},w=globalThis.console;const E=class{static decodeLicenseData(t){try{const e=window.atob(t),o=JSON.parse(e);return o.issueDate&&o.expiryDate&&o.plan?{domains:Array.isArray(o.domains)?o.domains:void 0,expiryDate:o.expiryDate,issueDate:o.issueDate,plan:o.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,o="standard",n){const i={expiryDate:e,issueDate:t,plan:o};n&&n.length>0&&(i.domains=n);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,w.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.indexOf("-"),o=-1!==e?t.slice(e+1):"";if(!o)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=this.decodeLicenseData(o);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(n.expiryDate)<i)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,valid:!1};if(n.domains&&n.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!n.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:n,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${n.domains.join(", ")}.`,valid:!1}}return{data:n,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};E.licenseKey=null,E.validationResult=null;let A=E;const S=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};S.WATERMARK_ATTR="data-apexcharts-watermark",S.WATERMARK_TEXT="APEXCHARTS";let C=S;function k(t,e){let o=null;for(let n=0;n<t.length;++n)if(e(t[n])){o=n;break}return o}function $(t,e){if(0===t.length)return;let o,n=0;for(let i=t.length-1;i>=0;--i)o=(t[i].dy??0)/2,(t[i][e]??0)-o<n&&(t[i][e]=Math.min(t[i].Rmax??0,n+o)),n=(t[i][e]??0)+o;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let n=0;n<t.length;++n)o=(t[n].dy??0)/2,(t[n][e]??0)+o>i&&(t[n][e]=Math.max(o,i-o)),i=(t[n][e]??0)-o}function M(t){const e=t.edgeGap||0;return function(o){!function(t,e,o){t.nodes().forEach((n=>{const i=t.node(n),r=L(t,i.outgoing||[],"outgoing"),s=L(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),h=s.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),c=l+Math.max(0,a-1)*o,u=h+Math.max(0,d-1)*o;let p=((i.dy??0)-c)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),r.forEach(((n,r)=>{const s=t.edge(n);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=o)})),s.forEach(((n,r)=>{const s=t.edge(n);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<d-1&&(g+=o)}))}))}(o,t,e),function(t){t.nodes().forEach((e=>{const o=t.node(e),n=(o.outgoing||[]).map((e=>t.edge(e))),i=(o.incoming||[]).map((e=>t.edge(e)));n.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),T(n,"r0"),T(i,"r1")}))}(o);const n=[];return o.edges().forEach((t=>{const e=o.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,n.push(e)})),n}}function L(t,e,o){return e.slice().sort(((e,n)=>{let i,r;if("outgoing"===o){const o=t.node(e.w),s=t.node(n.w);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}else{const o=t.node(e.v),s=t.node(n.v);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==n.name){if("number"==typeof e.name&&"number"==typeof n.name)return e.name-n.name;if("string"==typeof e.name&&"string"==typeof n.name)return e.name.localeCompare(n.name)}return 0}))}function T(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),o=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(o)/2.1:0!==o?(e*e+o*o)/Math.abs(4*o):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let o=k(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===o&&(o=t.length),$(t.slice(o),e),o>0){const n=[];for(let e=o-1;e>=0;e--)n.push(t[e]);$(n,e)}}function _(t,e,o,n,i){if(0===n.length)return;const r=n.map((o=>{const n=`__${e.v}_${e.w}_${o}`;return t.setNode(n,{data:null,direction:i,dummy:!0,rank:o}),n})),s=[e.v,...r,e.w];s.forEach(((n,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:o,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function B(t,e,o){return function(t,e,o){let n,i;e.length>o.length?(n=e,i=o):(n=o,i=e);const r=i.length,s=[];n.forEach((e=>{i.forEach(((o,n)=>{(t.hasEdge(e,o)||t.hasEdge(o,e))&&s.push(n)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let h=0;return s.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(h+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),h}(t,e,o)}function N(t){const e=[];let o=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===o.length&&(o=t.nodes().slice(0,1)),function(t,e){const o=new Set,n=[];function i(e){if(!o.has(e)){o.add(e),n.push(e);for(const o of t.successors(e))i(o)}}for(const t of e)i(t);return n}(t,o).forEach((o=>{const n=t.node(o).rank;if(void 0!==n){for(;n>=e.length;)e.push([]);e[n].push(o)}})),e}function R(t,e){let o=!0;for(;o;){o=!1;for(let n=0;n<e.length;++n)for(let i=0;i<e[n].length-1;++i){const r=F(t,e,n);I(e[n],i,i+1);F(t,e,n)<r?o=!0:I(e[n],i,i+1)}}}function F(t,e,o){let n=0;return o>0&&(n+=B(t,e[o-1],e[o])),o+1<e.length&&(n+=B(t,e[o],e[o+1])),n}function I(t,e,o){const n=t[e];t[e]=t[o],t[o]=n}function z(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const o=t[e-1]-t[0],n=t[t.length-1]-t[e];return(t[e-1]*n+t[e]*o)/(o+n)}function O(t,e,o=1,n=!1){if(o>0)for(let o=1;o<e.length;++o){const i=new Map;e[o].forEach((r=>{const s=z(W(t,e,o,o-1,r,n));i.set(r,s)})),j(e[o],i)}else for(let o=e.length-2;o>=0;--o){const i=new Map;e[o].forEach((r=>{const s=z(W(t,e,o,o+1,r,n));i.set(r,s)})),j(e[o],i)}}function W(t,e,o,n,i,r=!1){const s=e[o],a=e[n],d=[];return a.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o)})),0===d.length&&r&&s.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o+.5)})),d.sort(((t,e)=>t-e)),d}function j(t,e){const o=new Map(t.map(((t,e)=>[t,e])));for(let n=1;n<t.length;++n)for(let i=n;i>0;--i){let n=i-1,r=e.get(t[n]),s=e.get(t[i]);for(;-1===(r=e.get(t[n]))&&n>0;)n--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=o.get(t[n])??r,s=o.get(t[i])??s),s>=r)break;[t[i],t[n]]=[t[n],t[i]]}}function q(t,e){let o=0;for(let n=0;n<e.length-1;++n)o+=B(t,e[n],e[n+1]);return o}function D(t){const e=[];for(const o of t){const t=[];e.push(t);for(const e of o)t.push(e)}return e}const H=(t,e)=>(t||[]).reduce(((t,o)=>t+(e?e(o):o)),0);function G(){let t=[100,100],e=null,o=.18,n=function(t,e,o){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),Y(a,i,r),function(t,e,o,n=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);i.dy=i.value*o+l*n})),t.edges().forEach((n=>{const i=t.edge(n);i.value=e(i),i.dy=i.value*o}))}(a,i,e,l);const h=Z(a,d,l,e),c=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;c[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=h[d]/H(h)*t[1],p=0===s?0:o*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?n(l[e],l[e+1],a):0)),m=H(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=H(f)?v/H(f):0;let b=s+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),c[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o];for(let t=0;t<n.length;t++){const i=n[t];for(let n=0;n<i.length;n++)e.push({rankIndex:o,bandIndex:t,nodeIndex:n,nodeId:i[n]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:o,nodeId:n})=>{var i;t===g&&e===f||(g=t,f=e,u=c[t][e],p=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(n);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[o]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),o===p.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const o=[];return e.forEach(((n,i)=>{if(i===e.length-1)return;let r=0;n.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const o=t.edge(e).dy,n=t.node(e.w).y-t.node(e.v).y,i=Math.abs(n)-o,s=o*o-i*i,a=s>=0?Math.sqrt(s):o;a>r&&(r=a)}))}))})),o.push(r)})),o}(a,d);!function(t,e,o,n){const i=n.reduce(((t,e)=>t+e),0);let r;if(i>o)r=n.map((t=>o*t/i));else{const t=o-i;r=n.map((o=>o+t/(e.length-1)))}let s=0;e.forEach(((e,o)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[o]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return s.scaleToFit=function(n,s,a=0){Y(n,i,r);let d=0;a>0&&n.nodes().forEach((t=>{d=Math.max(d,function(t,e,o){if(o<=0)return 0;const n=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,n.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*o}(n,t,a))}));const l=H(Z(n,s,0,1));if(l<=0)return void(e=1);const h=t[1]-d;e=h/l,1!==o&&(e*=1-o)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(n="function"==typeof t?t:()=>t,s):n},s.whitespace=function(t){return arguments.length?(o=t,s):o},s.scale=function(t){return arguments.length?(e=t,s):e},s}function Y(t,e,o){t.nodes().forEach((n=>{const i=H(t.inEdges(n),(o=>e(t.edge(o)))),r=H(t.outEdges(n),(o=>e(t.edge(o))));let s=t.node(n);s||t.setNode(n,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=o(s)||"r")}))}function Z(t,e,o=0,n=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=H(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*o/n}));r[i]=Math.max(r[i],s)}))})),r}function P(t,e,o){return void 0!==o?`${t}${e}${o}`:`${t}${e}`}class X{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,o;if(!this._nodes.has(t))return this;this._nodes.delete(t);const n=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of n){const o=this._edges.get(t);o&&(null==(e=this._in.get(o.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(o=this._out.get(e.v))||o.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,o,n){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,n=t.name,o=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?P(s,a,n):P(s,a),l=this._edges.get(d);if(l)void 0!==o&&(l.label=o);else{const t={v:s,w:a,name:n,label:void 0!==o?o:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,o){var n;let i;return i="string"==typeof t?this._isMultigraph?P(t,e,o):P(t,e):this._isMultigraph?P(t.v,t.w,t.name):P(t.v,t.w),null==(n=this._edges.get(i))?void 0:n.label}hasEdge(t,e,o){const n=this._isMultigraph?P(t,e,o):P(t,e);return this._edges.has(n)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:o})=>({v:t,w:e,name:o})))}removeEdge(t){var e,o;const n=this._isMultigraph?P(t.v,t.w,t.name):P(t.v,t.w),i=this._edges.get(n);return i?(null==(e=this._out.get(i.v))||e.delete(n),null==(o=this._in.get(i.w))||o.delete(n),this._edges.delete(n),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const o=[],n=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=P(i.v,i.w,i.name);n.has(t)||(n.add(t),o.push(i))}return o}}function V(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function K(t,e){const o=function(t,e){const o=new Set,n=new X({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return U(t,e,o,n,i),t.nodes().forEach((e=>{o.has(e)||U(t,e,o,n,i)})),i.forEach(((t,e)=>{n.node(t).thread=e+1<i.length?i[e+1]:i[0]})),n}(t,e);return t.edges().forEach((e=>{const n=function(t,e,o){const n=t.node(e),i=t.node(o);if((n.depth??0)<(i.depth??0)){let e=n.thread;for(;void 0!==e&&(t.node(e).depth??0)>(n.depth??0);){if(e===o)return 1;e=t.node(e).thread}}else if((i.depth??0)<(n.depth??0)){let o=i.thread;for(;void 0!==o&&(t.node(o).depth??0)>(i.depth??0);){if(o===e)return-1;o=t.node(o).thread}}return 0}(o,e.v,e.w);if(n<0){const o=t.edge(e)||{};o.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,o)}})),t}function U(t,e,o,n,i,r=0){if(!o.has(e)){o.add(e),i.push(e),n.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{o.has(s)||n.setEdge(e,s,{delta:1}),U(t,s,o,n,i,r+1)}))}}function Q(t,e){if(0===t.nodes().length)return;const o=function(t,e){const o=new X({directed:!0});let n=!1;for(const t of e)if("min"===t.type){n=!0;break}if(!n){const o=t.sources();e=o.length>0?[{nodes:[o[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;t.nodes.forEach((t=>{i.set(t,e)})),o.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,n={nodes:[t],type:"same"};i.set(t,e),o.setNode(e,n)}})),t.edges().forEach((e=>{const n=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=o.edge(n,r)||{delta:0};n===r?(d.delta=0,o.setEdge(n,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),o.setEdge(r,n,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),o.setEdge(n,r,d))})),o}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(o),K(o,"0"),function(t){var e;const o=t.sources(),n=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(V(t))}));o.length>0;){const r=o.shift();if(void 0===r)break;n.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const o of t.inEdges(r)){const n=(null==(e=t.edge(o)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(o.v).rank??0)+n)}for(const e of t.outEdges(r))i.add(V(e));for(const e of t.nodes())o.indexOf(e)<0&&!n.has(e)&&!t.inEdges(e).some((t=>!i.has(V(t))))&&o.push(e)}}(o),function(t){function e(e){const o=t.node(e),n=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==n&&(o.rank=n)}t.edges().forEach((o=>{t.edge(o).temp&&e(o.w)}))}(o),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),o.nodes().forEach((e=>{var n;const i=o.node(e);null==(n=i.nodes)||n.forEach((e=>{t.node(e).rank=i.rank}))}))}function J(t){const e=G(),o=M(t);let n=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const o=new X({directed:!0,multigraph:!0});return e.forEach((t=>{o.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),o.nodes().forEach((t=>o.setNode(t,{data:{}}))),t.forEach((t=>{o.hasNode(t.id)&&(o.node(t.id).data=t,void 0!==t.direction&&(o.node(t.id).direction=t.direction))})),o.edges().forEach((t=>{o.edge(t).source=o.node(t.v),o.edge(t).target=o.node(t.w)})),o}(a,s);var h;return d.order?(Q(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(Q(l,d.rankSets||[]),(h=l).edges().forEach((t=>{const e=h.node(t.v),o=h.node(t.w),n=h.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==o.rank&&i+1<=o.rank){for("l"===e.direction&&r.push(i);++i<o.rank;)r.push(i);"l"===o.direction&&r.push(i),_(h,t,n,r,"r")}else if(void 0!==i&&void 0!==o.rank&&i>o.rank){for("l"!==e.direction&&r.push(i);i-- >o.rank+1;)r.push(i);"l"!==o.direction&&r.push(i),_(h,t,n,r,"l")}})),r=function(t,e=25){const o=N(t);let n=o,i=q(t,o),r=0;for(;r++<e;){O(t,o,r%2==0?1:0),R(t,o);const e=q(t,o);if(e<i&&(n=D(o),i=e),0===i)break}return n.map((t=>[t]))}(l)),n=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const o=t.node(e);o.incoming=t.inEdges(e),o.outgoing=t.outEdges(e)}))}(l),i=o(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var o;let n=t.node(e);if(!n)return;let i=(null==(o=t.inEdges(e))?void 0:o.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let r,s=i.map((t=>t.r1));for(;n.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:s[e],x:n.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),n=t.node(e=r);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(l),function(t){t.edges().forEach((e=>{const o=t.edge(e);o.points||(o.points=[]),o.points.unshift({d:o.d0,ro:o.r0,x:o.x0,y:o.y0}),o.points.push({d:o.d1,ri:o.r1,x:o.x1,y:o.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return n},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const tt=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],et=t=>0===t.dy?0:2;function ot(t){const e=Math.max(et(t),t.dy)/2;let{x0:o}=t,{x1:n}=t,{y0:i}=t,{y1:r}=t;n<o&&([o,n]=[n,o],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,o=t.y1-t.y0;return[t.dy/2,(e*e+o*o)/Math.abs(4*o)]}(t),d=Math.max(a[0],Math.min(a[1],(n-o)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),h=Math.max(a[0],Math.min(a[1],t.r1||d));const c=n-o,u=r-i-s*(l+h),p=Math.sqrt(c*c+u*u),g=-s*Math.acos(Math.min(1,(l+h)/p)),f=Math.atan2(u,c);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=o+1*l*Math.sin(Math.abs(m)),x=n-1*h*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-h*s*(1-Math.cos(m));function A(t,o){const n=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?o+e:o-e;return 0===m&&(s=o),`A${s} ${s} ${Math.abs(m)} 0 ${n} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,h=0,b=o,x=n,w=i,E=r,v=0,y=e),`M${[o,i-e]} ${A(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${A(-1,h)}${[n,r-e]} L${[n,r+e]} ${A(1,h)}${[x-v,E+y]} L${[b-v,w+y]} ${A(-1,l)}${[o,i+e]} Z`}function nt(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],o=Math.max(et(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-o]} L${[e.x??0,(e.y??0)-o]} L${[e.x??0,(e.y??0)+o]} L${[(e.x??0)-20,(e.y??0)+o]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)+o]} L${[e.x??0,(e.y??0)+o]} Z`:null}(t);if(!t.points)return null;let o,n="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];o={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},n+=ot(o)}return n}const it=(t,e)=>{const o=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&o.length>e?`${o.substr(0,15)}...`:o};function rt(t,{fontColor:e,maxRank:o,nodeWidth:n}){const{data:i}=t;if(!i)return null;const r=function(t,e){let o=!1,n=!1;return(t.rank??0)<e/2&&(n=!0,o=!1),{right:n,top:o}}(t,o),{x:s,y:a}=function(t,e,o){const n=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+o/2:-o/2-10,{x:(t.x??0)+i,y:(t.y??0)+n}}(t,r,n);return function(t="",{fontColor:e="#666767",pointerEvents:o="all",textAnchor:n="start",x:i,y:r}={}){const s=new h;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":o,"text-anchor":n}),s}(it(i,r.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:r.top?"middle":r.right?"start":"end",x:s,y:a})}function st(t,e,o){var n,i;const{dy:r,x:s,y:l}=t,{fontColor:h="#212121",fontSize:c="14px",fontFamily:u,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m=0,onNodeClick:v,nodeTooltip:w}=o,E=new a({class:"node"}),A=function({borderColor:t="#caced0",color:e="#97cbe6",height:o=0,opacity:n=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const l=new d;return l.attr({height:o,opacity:n,rx:i,ry:i,width:r,x:s,y:a}),l.fill(e),l.stroke({color:t,width:1}),l}({height:r,width:m,x:(s??0)-m/2,y:l});if(A.fill(null==(n=t.data)?void 0:n.color),A.stroke({color:g??(null==(i=t.data)?void 0:i.color),width:f}),A.on("click",(()=>{"function"==typeof v&&v(t)})),w){const{chartContext:e,isCustomTooltip:o,nodeValue:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=w,l=d({node:t.data,value:n});A.on("mouseover",(t=>{const{pageX:n,pageY:d}=t,g=x({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});b(e,a,g,l,!0)})),A.on("mousemove",(t=>{const{pageX:n,pageY:d}=t,g=x({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});b(e,a,g,l,!0)})),A.on("mouseout",(()=>{y(e,a).style.display="none"}))}if(E.add(A),t.data&&(r??0)>Number.parseInt(c,10)){const o=rt(t,{fontColor:h,maxRank:e,nodeWidth:m});o&&E.add(o)}return E}const at={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:o})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${o}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}};class dt{constructor(t,e,o){this.element=t,this.options=e,this.chartContext=o,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(i,"svg");return new p(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new n(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,o,n){this.canvas.viewbox(`${t} ${e} ${o} ${n}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class lt{constructor(t,e,o){this.svgRoot=t,this.graph=e,this.dimOpacity=o}highlightNode(t){const e=this.prefersReducedMotion(),o=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],n=new Set([t]);o.forEach((t=>{var e,o,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(o=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:o.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&n.add(a),d&&n.add(d)})),this.dimAll(e),o.forEach((t=>{const o=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);o&&this.setOpacity(o,1,e)})),n.forEach((t=>{const o=this.svgRoot.querySelector(`[data-node-id="${t}"]`);o&&this.setOpacity(o,1,e)}))}highlightEdge(t,e){var o,n,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(n=null==(o=null==a?void 0:a.source)?void 0:o.data)?void 0:n.id)??t,l=(null==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const h=this.svgRoot.querySelector(`[data-node-id="${d}"]`),c=this.svgRoot.querySelector(`[data-node-id="${l}"]`);h&&this.setOpacity(h,1,s),c&&this.setOpacity(c,1,s)}reset(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,o){t.style.transition=o?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function ht(t,e){const o=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),n=o("--apex-sankey-edge-opacity"),i=""!==n?Number(n):e.edgeOpacity,r=o("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=o("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=o("--apex-sankey-edge-gradient"),h=""!==l?"true"===l:e.edgeGradientFill,c=o("--apex-sankey-node-border-color")||e.nodeBorderColor,u=o("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=o("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=o("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=o("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:h,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:o("--apex-sankey-label-color")||e.fontColor,fontSize:o("--apex-sankey-label-font-size")||e.fontSize,fontFamily:o("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:c,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const ct="#005FCC",ut="role",pt="aria-label",gt="data-node-id",ft="data-orig-stroke",mt="data-orig-stroke-width",vt="stroke",yt="stroke-width",bt="forced-colors",xt="apexsankey-desc",wt="data-edge-target";const Et="apexsankey-a11y-styles";class At{constructor(t,e,o={},n,i){this.svgEl=t,this.graph=e,this.options=o,this.tooltipId=n,this.pathHighlighter=i,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(Et))return;const t=document.createElement("style");t.id=Et,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${ct};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,options:o}=this,n=e.nodes().filter((t=>!e.node(t).dummy)),i=e.edges(),r=function(t,e,o,n){var i,r,s,a;if(n)return n;let d=0,l="",h="";for(const e of o)try{const o=t.edge(e.v,e.w,e.name).value??0;if(o>d){const n=t.node(e.v),c=t.node(e.w);n.dummy||c.dummy||(d=o,l=(null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??e.v,h=(null==(s=c.data)?void 0:s.title)??(null==(a=c.data)?void 0:a.id)??e.w)}}catch{}let c=`Sankey flow diagram: ${e.length} nodes, ${o.length} flows.`;return l&&h&&(c+=` Largest flow: ${l} (${d} units) to ${h}.`),c}(e,n,i,o.diagramLabel);t.setAttribute(ut,"img"),t.setAttribute(pt,r),t.removeAttribute("aria-labelledby");const s=t.querySelector("title");if(s&&s.remove(),o.description){let e=t.querySelector("desc");if(!e){const o=document.createElementNS("http://www.w3.org/2000/svg","desc");o.id=xt,t.insertBefore(o,t.firstChild),e=o}e.textContent=o.description,t.setAttribute("aria-describedby",xt)}const a=Array.from(t.querySelectorAll(`[${gt}]`));a.forEach((t=>{const o=t.getAttribute(gt);o&&(t.setAttribute(ut,"listitem"),t.setAttribute(pt,function(t,e){var o,n,i,r,s,a;const d=e.node(t),l=(null==(o=d.data)?void 0:o.title)??(null==(n=d.data)?void 0:n.id)??t,h=[];let c=0;for(const o of e.inEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.v);n.dummy||(h.push((null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??o.v),c+=t.value??0)}catch{}const u=[];let p=0;for(const o of e.outEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.w);n.dummy||(u.push((null==(s=n.data)?void 0:s.title)??(null==(a=n.data)?void 0:a.id)??o.w),p+=t.value??0)}catch{}let g=l;h.length>0&&(g+=`: receives ${c} units from ${h.join(", ")}`),u.length>0&&(g+=`${h.length>0?"; ":": "}flows ${p} units to ${u.join(", ")}`);return g}(o,e)),t.setAttribute("tabindex","0"))})),this.nodeGroups=a;const d=[],l=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,n,i,r;const s=t.getAttribute("data-edge-source"),a=t.getAttribute("data-edge-target"),c=t.getAttribute("data-edge-name")??void 0;if(s&&a)try{const u=e.edge(s,a,c),p=u.source,g=u.target;if(!p||!g)return;const f=(null==(o=p.data)?void 0:o.title)??(null==(n=p.data)?void 0:n.id)??s,m=(null==(i=g.data)?void 0:i.title)??(null==(r=g.data)?void 0:r.id)??a,v=u.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",`Flow from ${f} to ${m}: ${v} units`),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),d.push(t),h.set(t,s),l.has(s)||l.set(s,[]);const y=l.get(s);y&&y.push(t)}catch{}})),this.edgePaths=d,this.nodeOutEdges=l,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(o=>{const n=o.key;if("Enter"===n||" "===n){o.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===n)o.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===n||"ArrowDown"===n){o.preventDefault();const n=t.getAttribute(gt),i=n?this.nodeOutEdges.get(n)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===n||"ArrowUp"===n){o.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const o=t.getAttribute(gt);o&&(null==(e=this.pathHighlighter)||e.highlightNode(o))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},o=()=>{const e=this.edgeSourceNode.get(t),o=e?this.nodeGroups.find((t=>t.getAttribute(gt)===e)):void 0;o&&o.focus()};t.addEventListener("keydown",(n=>{const i=n.key;if("Enter"===i||" "===i)n.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)n.preventDefault(),o();else if("ArrowDown"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i+1)%o.length].focus()}else if("ArrowUp"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i-1+o.length)%o.length].focus()}else if("ArrowRight"===i){n.preventDefault();const e=t.getAttribute(wt),o=e?this.nodeGroups.find((t=>t.getAttribute(gt)===e)):void 0;o&&o.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),o=this.nodeGroups.findIndex((t=>t.getAttribute(gt)===e));if(-1!==o){const t=n.shiftKey?(o-1+this.nodeGroups.length)%this.nodeGroups.length:(o+1)%this.nodeGroups.length;n.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const o=t.getAttribute("data-edge-source"),n=t.getAttribute(wt);o&&n&&(null==(e=this.pathHighlighter)||e.highlightEdge(o,n))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const o=t.relatedTarget;o&&this.edgePaths.includes(o)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(ft,e.getAttribute(vt)??""),e.setAttribute(mt,e.getAttribute(yt)??""),e.setAttribute(vt,ct),e.setAttribute(yt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const o=e.getAttribute(ft),n=e.getAttribute(mt);null!==o&&(e.setAttribute(vt,o),e.removeAttribute(ft)),null!==n&&(e.setAttribute(yt,n),e.removeAttribute(mt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(bt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(bt):this.svgEl.classList.remove(bt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const St="http://www.w3.org/2000/svg";class Ct extends dt{constructor(t,e,o){super(t,e,o),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e}construct(t){const{edgeGap:e,nodeWidth:o,spacing:n,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=J({edgeGap:e,nodeWidth:o,whitespace:s});a.size([r-o,i-n]);const d=t.nodes.map(((t,e)=>{const o=e%tt.length;return{...t,color:t.color??tt[o],colorIndex:o}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l}render({keepOldPosition:t=!1}={}){var e,o;this.renderOptions=ht(this.element,this.options);const{tooltipTheme:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===n?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===n&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v,nodeTooltipTemplate:b,onNodeClick:x,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}=this.renderOptions,C=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new lt(this.canvas.node,this.graph,p):null;const k=((t={})=>{const e=[];for(const n in t){const i=`${o=n,o.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[n]};`;e.push(i)}var o;return e.join(" ")})({color:d,fontFamily:l,fontSize:h,fontWeight:c}),$=g(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(o=this.graph)?void 0:o.edges())||[],T=g();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const _=g();_.node.setAttribute("role","list"),_.node.setAttribute("aria-label","Sankey nodes"),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let o;if(a&&b){const e=this.graph.inEdges(t)??[],n=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),r=n.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),s=Math.max(i,r);o={chartContext:this.chartContext,isCustomTooltip:b!==at.nodeTooltipTemplate,nodeTooltipTemplate:b,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}}const n=st(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:o,onNodeClick:x});if(n.node.setAttribute("data-node-id",t),n.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;n.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),n.node.addEventListener("mouseleave",(()=>e.reset()))}_.add(n)})),$.add(_),this.add($);const{animation:B}=this.renderOptions;if((null==B?void 0:B.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,o,n,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(St,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,h=document.createElementNS(St,"clipPath");h.setAttribute("id",l);const c=document.createElementNS(St,"rect");c.setAttribute("x",String(a)),c.setAttribute("y","-9999"),c.setAttribute("height","99999"),c.setAttribute("width","0"),h.appendChild(c),d.appendChild(h),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(o){null===u&&(u=o);const n=o-u,r=Math.min(n/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;c.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),h.remove())}));const p=o.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),o=g+(n>0?e/n:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:o,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,_.node,this.maxRank,B.duration)),t&&this.updateViewBox(C.x,C.y,C.width,C.height),a){const t=y(this.chartContext,S);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const N=this.renderOptions.a11y;!1!==(null==N?void 0:N.enabled)&&(this.a11yHelper=new At(this.canvas.node,this.graph,N,S,this.pathHighlighter),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:o,edgeOpacity:n,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:h,tooltipBorderColor:c,tooltipFontColor:u,tooltipId:p,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),w=f.source,E=f.target;if(!w||!E)return;m.dummy&&(f.x0=(f.x0??0)-d/2),v.dummy&&(f.x1=(f.x1??0)+d/2);const A=nt(f);if(!A)return;const S=function(t,{edgeColor:e,id:o="",opacity:n=1}={}){const i=new l({d:t});return i.id(o),i.fill(e).opacity(n),i}(A,{edgeColor:this.canvas.gradient("linear",(t=>{var e,n,i;t.stop(0,(null==(e=w.data)?void 0:e.color)??""),t.stop(1,o?(null==(n=E.data)?void 0:n.color)??"":(null==(i=w.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:n});if(S.node.setAttribute("data-edge-source",t.v),S.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&S.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,o=t.v,n=t.w;S.on("mouseenter",(()=>e.highlightEdge(o,n))),S.on("mouseleave",(()=>e.reset()))}if(i&&w.data&&E.data){const t=g?g({source:w.data,target:E.data,value:f.value}):`${w.data.title} → ${E.data.title}: ${f.value}`,e=g!==at.tooltipTemplate;S.on("mouseover",(o=>{const{pageX:n,pageY:i}=o,d=x({bgColor:e?void 0:h,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});b(this.chartContext,p,d,t,!0)})),S.on("mousemove",(o=>{const{pageX:n,pageY:i}=o,d=x({bgColor:e?void 0:h,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});b(this.chartContext,p,d,t,!0)})),S.on("mouseout",(()=>{y(this.chartContext,p).style.display="none"}))}e.add(S)}}class kt extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...at,...e};const{height:o,width:n}=this.options;this.graph=new Ct(this.element,this.options,this.chartContext),this.setupElementDimensions(n,o),this.handleWatermark()}static setLicense(t){A.setLicense(t)}setupElementDimensions(t,e){let o=!1,n=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(n=Number(t.substring(0,t.length-1)),o=!0):n=Number(t);const i="auto"===e?n/1.6:e;this.element.style.width=`${n}${o?"%":"px"}`,this.element.style.height=`${i}${o?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(A.isLicenseValid()?C.remove(this.element):C.add(this.element))}render(t){if(!this.element)throw new Error("Element not found");if(this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new m(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}}"undefined"!=typeof window&&(window.ApexSankey=kt);export{kt as ApexSankey,kt as default};
1
+ const t=()=>{};class e{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),o=Array.from(e);return{item:t=>o[t]||null,get length(){return o.length},[Symbol.iterator]:()=>o[Symbol.iterator](),...Object.fromEntries(o.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,o):this.context.addEventListener(t,e,o)}removeEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,o):this.context.removeEventListener(t,e,o)}injectStyles(t,e,o={}){const{force:n=!1,priority:i="normal"}=o;if(!n&&this.injectedStyles.has(e))return;if(n){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!n)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:o})=>{this.injectStyles(t,e,o)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class o{constructor(t,o){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new e(t,o)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,o){this.chartContext.addEventListener(t,e,o)}removeEventListener(t,e,o){this.chartContext.removeEventListener(t,e,o)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class n{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const i="http://www.w3.org/2000/svg";let r=0;class s{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:o}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==o&&this.node.setAttribute("stroke-dasharray",String(o)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof s?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new s(e):null}first(){const t=this.node.firstElementChild;return t?new s(t):null}}class a extends s{constructor(t){super(document.createElementNS(i,"g")),t&&this.attr(t)}}class d extends s{constructor(){super(document.createElementNS(i,"rect"))}}class l extends s{constructor(t){super(document.createElementNS(i,"path")),t&&this.attr(t)}}class c extends s{constructor(){super(document.createElementNS(i,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(i,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class h{constructor(t){this.gradient=t}stop(t,e){const o=document.createElementNS(i,"stop");o.setAttribute("offset",String(t)),o.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(o)}}function u(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class p{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}add(t){return this.node.appendChild(t instanceof s?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(i,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const o=document.createElementNS(i,"linearGradient"),n="apx-grad-"+ ++r;return o.setAttribute("id",n),o.setAttribute("x1","0%"),o.setAttribute("y1","0%"),o.setAttribute("x2","100%"),o.setAttribute("y2","0%"),e(new h(o)),this._defs.appendChild(o),o}panZoom(t={}){return this._panZoomState=function(t,e){const o=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),n={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...o},vb:{...o}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const o=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=n.currentZoom/o;if(i<n.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=n,l=d.w*o,c=d.h*o,h=d.x+s*(d.w-l),p=d.y+a*(d.h-c);n.vb={x:h,y:p,w:l,h:c},n.currentZoom=i,u(t,n.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const o=e.clientX-a,n=e.clientY-d;if(Math.abs(o)<4&&Math.abs(n)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const o=t.getBoundingClientRect(),l=n.vb.w/o.width,c=n.vb.h/o.height,h=(e.clientX-a)*l,p=(e.clientY-d)*c;n.vb={x:n.vb.x-h,y:n.vb.y-p,w:n.vb.w,h:n.vb.h},u(t,n.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),n}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const o=this._panZoomState;if(t<o.zoomMin)return this;const n=o.currentZoom/t,{vb:i}=o,r=i.w*n,s=i.h*n,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return o.vb={x:a,y:d,w:r,h:s},o.currentZoom=t,u(this.node,o.vb),this}}function g(t,e,o,n){const i=new a;return i.attr({"data-parent":n,"data-self":o,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const f={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class m{constructor(t,o){this.element=t,t&&(this.chartContext=o||new e(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n /* Logical inset: stays on the right in LTR, mirrors to the left in RTL\n (so it never collides with RTL-flipped chrome such as the search box). */\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,o){const n=this.chartContext.createElement("div");return n.id=t,n.className="toolbar-item",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.innerHTML=e,o&&(n.setAttribute("data-tooltip",o),n.setAttribute("aria-label",o)),n.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())})),n}render({enableExport:e=!1,enableFitscreen:o=!1,enableZoom:n=!1,onExport:i=t,onFitscreen:r=t,onZoom:s=t}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),e){const t=this.createToolbarItem("export",f.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(n){const t=this.createToolbarItem("zoom-in",f["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",f["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(o){const t=this.createToolbarItem("fit-screen",f["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const v="aria-hidden",y=(t,e="apex-tooltip-container")=>{let o=t.getElementById(e);if(!o){o=t.createElement("div"),o.id=e,o.setAttribute("role","tooltip"),o.setAttribute(v,"true");t.getAppendContainer().appendChild(o),t.trackTooltip(o)}return o},b=(t,e="",o,n="",i=!1)=>{const r=t.getElementById(e);if(!r)return y(t,e),b(t,e,o,n,i);if(o&&n){const e=n.includes("tooltip-content"),s=o.match(/background-color:\s*([^;]+);?/),a=o.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=n;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${n}</div>`}const d=o+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(r.setAttribute("style",d),r.classList.add("visible"),r.setAttribute(v,"false"),i&&"undefined"!=typeof window){const e=r.offsetWidth,o=parseFloat(r.style.left),n=t.getChartBounds();if(e>0&&!Number.isNaN(o)&&n.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=n.left+t,s=((t,e,o,n,i=8)=>{if(t+e<=o-i)return t;const r=t-e;return r<n+i?Math.max(n+i,o-e-i):r})(o,e,n.right+t,i);s!==o&&(r.style.left=`${s}px`)}}}else r.removeAttribute("style"),r.classList.remove("visible"),r.setAttribute(v,"true"),r.innerHTML=""},x=({bgColor:t,borderColor:e,fontColor:o,fontFamily:n,fontSize:i,fontWeight:r,maxWidth:s,padding:a,placement:d="top",x:l,y:c})=>{const h=["position: absolute;","z-index: 1000;","pointer-events: none;"];return h.push("box-sizing: border-box;"),h.push("word-wrap: break-word;"),h.push("overflow-wrap: break-word;"),h.push(`left: ${l}px;`),h.push(`top: ${c}px;`),h.push(`data-placement: ${d};`),s&&(h.push(`width: ${s}px;`),h.push(`max-width: ${s}px;`)),e&&h.push(`border: 1px solid ${e};`),o&&h.push(`color: ${o};`),n&&h.push(`font-family: ${n};`),r&&h.push(`font-weight: ${r};`),i&&h.push(`font-size: ${i};`),t&&(h.push(`background-color: ${t};`),h.push("border-radius: 6px;"),h.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&h.push(`padding: ${a}px;`),h.join(" ")},w=globalThis.console;const E=class{static decodeLicenseData(t){try{const e=window.atob(t),o=JSON.parse(e);return o.issueDate&&o.expiryDate&&o.plan?{domains:Array.isArray(o.domains)?o.domains:void 0,expiryDate:o.expiryDate,issueDate:o.issueDate,plan:o.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,o="standard",n){const i={expiryDate:e,issueDate:t,plan:o};n&&n.length>0&&(i.domains=n);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,w.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.indexOf("-"),o=-1!==e?t.slice(e+1):"";if(!o)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=this.decodeLicenseData(o);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(n.expiryDate)<i)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,valid:!1};if(n.domains&&n.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!n.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:n,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${n.domains.join(", ")}.`,valid:!1}}return{data:n,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};E.licenseKey=null,E.validationResult=null;let A=E;const C=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};C.WATERMARK_ATTR="data-apexcharts-watermark",C.WATERMARK_TEXT="APEXCHARTS";let S=C;function k(t,e){let o=null;for(let n=0;n<t.length;++n)if(e(t[n])){o=n;break}return o}function $(t,e){if(0===t.length)return;let o,n=0;for(let i=t.length-1;i>=0;--i)o=(t[i].dy??0)/2,(t[i][e]??0)-o<n&&(t[i][e]=Math.min(t[i].Rmax??0,n+o)),n=(t[i][e]??0)+o;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let n=0;n<t.length;++n)o=(t[n].dy??0)/2,(t[n][e]??0)+o>i&&(t[n][e]=Math.max(o,i-o)),i=(t[n][e]??0)-o}function M(t){const e=t.edgeGap||0;return function(o){!function(t,e,o){t.nodes().forEach((n=>{const i=t.node(n),r=L(t,i.outgoing||[],"outgoing"),s=L(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),c=s.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),h=l+Math.max(0,a-1)*o,u=c+Math.max(0,d-1)*o;let p=((i.dy??0)-h)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),r.forEach(((n,r)=>{const s=t.edge(n);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=o)})),s.forEach(((n,r)=>{const s=t.edge(n);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<d-1&&(g+=o)}))}))}(o,t,e),function(t){t.nodes().forEach((e=>{const o=t.node(e),n=(o.outgoing||[]).map((e=>t.edge(e))),i=(o.incoming||[]).map((e=>t.edge(e)));n.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),T(n,"r0"),T(i,"r1")}))}(o);const n=[];return o.edges().forEach((t=>{const e=o.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,n.push(e)})),n}}function L(t,e,o){return e.slice().sort(((e,n)=>{let i,r;if("outgoing"===o){const o=t.node(e.w),s=t.node(n.w);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}else{const o=t.node(e.v),s=t.node(n.v);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==n.name){if("number"==typeof e.name&&"number"==typeof n.name)return e.name-n.name;if("string"==typeof e.name&&"string"==typeof n.name)return e.name.localeCompare(n.name)}return 0}))}function T(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),o=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(o)/2.1:0!==o?(e*e+o*o)/Math.abs(4*o):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let o=k(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===o&&(o=t.length),$(t.slice(o),e),o>0){const n=[];for(let e=o-1;e>=0;e--)n.push(t[e]);$(n,e)}}function R(t,e,o,n,i){if(0===n.length)return;const r=n.map((o=>{const n=`__${e.v}_${e.w}_${o}`;return t.setNode(n,{data:null,direction:i,dummy:!0,rank:o}),n})),s=[e.v,...r,e.w];s.forEach(((n,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:o,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function _(t,e,o){return function(t,e,o){let n,i;e.length>o.length?(n=e,i=o):(n=o,i=e);const r=i.length,s=[];n.forEach((e=>{i.forEach(((o,n)=>{(t.hasEdge(e,o)||t.hasEdge(o,e))&&s.push(n)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let c=0;return s.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(c+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),c}(t,e,o)}function B(t){const e=[];let o=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===o.length&&(o=t.nodes().slice(0,1)),function(t,e){const o=new Set,n=[];function i(e){if(!o.has(e)){o.add(e),n.push(e);for(const o of t.successors(e))i(o)}}for(const t of e)i(t);return n}(t,o).forEach((o=>{const n=t.node(o).rank;if(void 0!==n){for(;n>=e.length;)e.push([]);e[n].push(o)}})),e}function N(t,e){let o=!0;for(;o;){o=!1;for(let n=0;n<e.length;++n)for(let i=0;i<e[n].length-1;++i){const r=F(t,e,n);I(e[n],i,i+1);F(t,e,n)<r?o=!0:I(e[n],i,i+1)}}}function F(t,e,o){let n=0;return o>0&&(n+=_(t,e[o-1],e[o])),o+1<e.length&&(n+=_(t,e[o],e[o+1])),n}function I(t,e,o){const n=t[e];t[e]=t[o],t[o]=n}function O(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const o=t[e-1]-t[0],n=t[t.length-1]-t[e];return(t[e-1]*n+t[e]*o)/(o+n)}function W(t,e,o=1,n=!1){if(o>0)for(let o=1;o<e.length;++o){const i=new Map;e[o].forEach((r=>{const s=O(z(t,e,o,o-1,r,n));i.set(r,s)})),j(e[o],i)}else for(let o=e.length-2;o>=0;--o){const i=new Map;e[o].forEach((r=>{const s=O(z(t,e,o,o+1,r,n));i.set(r,s)})),j(e[o],i)}}function z(t,e,o,n,i,r=!1){const s=e[o],a=e[n],d=[];return a.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o)})),0===d.length&&r&&s.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o+.5)})),d.sort(((t,e)=>t-e)),d}function j(t,e){const o=new Map(t.map(((t,e)=>[t,e])));for(let n=1;n<t.length;++n)for(let i=n;i>0;--i){let n=i-1,r=e.get(t[n]),s=e.get(t[i]);for(;-1===(r=e.get(t[n]))&&n>0;)n--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=o.get(t[n])??r,s=o.get(t[i])??s),s>=r)break;[t[i],t[n]]=[t[n],t[i]]}}function q(t,e){let o=0;for(let n=0;n<e.length-1;++n)o+=_(t,e[n],e[n+1]);return o}function G(t){const e=[];for(const o of t){const t=[];e.push(t);for(const e of o)t.push(e)}return e}const D=(t,e)=>(t||[]).reduce(((t,o)=>t+(e?e(o):o)),0);function H(){let t=[100,100],e=null,o=.18,n=function(t,e,o){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),Y(a,i,r),function(t,e,o,n=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);i.dy=i.value*o+l*n})),t.edges().forEach((n=>{const i=t.edge(n);i.value=e(i),i.dy=i.value*o}))}(a,i,e,l);const c=Z(a,d,l,e),h=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;h[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=c[d]/D(c)*t[1],p=0===s?0:o*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?n(l[e],l[e+1],a):0)),m=D(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=D(f)?v/D(f):0;let b=s+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),h[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o];for(let t=0;t<n.length;t++){const i=n[t];for(let n=0;n<i.length;n++)e.push({rankIndex:o,bandIndex:t,nodeIndex:n,nodeId:i[n]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:o,nodeId:n})=>{var i;t===g&&e===f||(g=t,f=e,u=h[t][e],p=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(n);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[o]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),o===p.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const o=[];return e.forEach(((n,i)=>{if(i===e.length-1)return;let r=0;n.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const o=t.edge(e).dy,n=t.node(e.w).y-t.node(e.v).y,i=Math.abs(n)-o,s=o*o-i*i,a=s>=0?Math.sqrt(s):o;a>r&&(r=a)}))}))})),o.push(r)})),o}(a,d);!function(t,e,o,n){const i=n.reduce(((t,e)=>t+e),0);let r;if(i>o)r=n.map((t=>o*t/i));else{const t=o-i;r=n.map((o=>o+t/(e.length-1)))}let s=0;e.forEach(((e,o)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[o]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return s.scaleToFit=function(n,s,a=0){Y(n,i,r);let d=0;a>0&&n.nodes().forEach((t=>{d=Math.max(d,function(t,e,o){if(o<=0)return 0;const n=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,n.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*o}(n,t,a))}));const l=D(Z(n,s,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==o&&(e*=1-o)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(n="function"==typeof t?t:()=>t,s):n},s.whitespace=function(t){return arguments.length?(o=t,s):o},s.scale=function(t){return arguments.length?(e=t,s):e},s}function Y(t,e,o){t.nodes().forEach((n=>{const i=D(t.inEdges(n),(o=>e(t.edge(o)))),r=D(t.outEdges(n),(o=>e(t.edge(o))));let s=t.node(n);s||t.setNode(n,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=o(s)||"r")}))}function Z(t,e,o=0,n=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=D(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*o/n}));r[i]=Math.max(r[i],s)}))})),r}function P(t,e,o){return void 0!==o?`${t}${e}${o}`:`${t}${e}`}class X{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,o;if(!this._nodes.has(t))return this;this._nodes.delete(t);const n=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of n){const o=this._edges.get(t);o&&(null==(e=this._in.get(o.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(o=this._out.get(e.v))||o.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,o,n){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,n=t.name,o=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?P(s,a,n):P(s,a),l=this._edges.get(d);if(l)void 0!==o&&(l.label=o);else{const t={v:s,w:a,name:n,label:void 0!==o?o:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,o){var n;let i;return i="string"==typeof t?this._isMultigraph?P(t,e,o):P(t,e):this._isMultigraph?P(t.v,t.w,t.name):P(t.v,t.w),null==(n=this._edges.get(i))?void 0:n.label}hasEdge(t,e,o){const n=this._isMultigraph?P(t,e,o):P(t,e);return this._edges.has(n)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:o})=>({v:t,w:e,name:o})))}removeEdge(t){var e,o;const n=this._isMultigraph?P(t.v,t.w,t.name):P(t.v,t.w),i=this._edges.get(n);return i?(null==(e=this._out.get(i.v))||e.delete(n),null==(o=this._in.get(i.w))||o.delete(n),this._edges.delete(n),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const o=[],n=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=P(i.v,i.w,i.name);n.has(t)||(n.add(t),o.push(i))}return o}}function K(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function V(t,e){const o=function(t,e){const o=new Set,n=new X({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return U(t,e,o,n,i),t.nodes().forEach((e=>{o.has(e)||U(t,e,o,n,i)})),i.forEach(((t,e)=>{n.node(t).thread=e+1<i.length?i[e+1]:i[0]})),n}(t,e);return t.edges().forEach((e=>{const n=function(t,e,o){const n=t.node(e),i=t.node(o);if((n.depth??0)<(i.depth??0)){let e=n.thread;for(;void 0!==e&&(t.node(e).depth??0)>(n.depth??0);){if(e===o)return 1;e=t.node(e).thread}}else if((i.depth??0)<(n.depth??0)){let o=i.thread;for(;void 0!==o&&(t.node(o).depth??0)>(i.depth??0);){if(o===e)return-1;o=t.node(o).thread}}return 0}(o,e.v,e.w);if(n<0){const o=t.edge(e)||{};o.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,o)}})),t}function U(t,e,o,n,i,r=0){if(!o.has(e)){o.add(e),i.push(e),n.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{o.has(s)||n.setEdge(e,s,{delta:1}),U(t,s,o,n,i,r+1)}))}}function Q(t,e){if(0===t.nodes().length)return;const o=function(t,e){const o=new X({directed:!0});let n=!1;for(const t of e)if("min"===t.type){n=!0;break}if(!n){const o=t.sources();e=o.length>0?[{nodes:[o[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;t.nodes.forEach((t=>{i.set(t,e)})),o.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,n={nodes:[t],type:"same"};i.set(t,e),o.setNode(e,n)}})),t.edges().forEach((e=>{const n=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=o.edge(n,r)||{delta:0};n===r?(d.delta=0,o.setEdge(n,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),o.setEdge(r,n,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),o.setEdge(n,r,d))})),o}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(o),V(o,"0"),function(t){var e;const o=t.sources(),n=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(K(t))}));o.length>0;){const r=o.shift();if(void 0===r)break;n.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const o of t.inEdges(r)){const n=(null==(e=t.edge(o)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(o.v).rank??0)+n)}for(const e of t.outEdges(r))i.add(K(e));for(const e of t.nodes())o.indexOf(e)<0&&!n.has(e)&&!t.inEdges(e).some((t=>!i.has(K(t))))&&o.push(e)}}(o),function(t){function e(e){const o=t.node(e),n=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==n&&(o.rank=n)}t.edges().forEach((o=>{t.edge(o).temp&&e(o.w)}))}(o),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),o.nodes().forEach((e=>{var n;const i=o.node(e);null==(n=i.nodes)||n.forEach((e=>{t.node(e).rank=i.rank}))}))}function J(t){const e=H(),o=M(t);let n=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const o=new X({directed:!0,multigraph:!0});return e.forEach((t=>{o.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),o.nodes().forEach((t=>o.setNode(t,{data:{}}))),t.forEach((t=>{o.hasNode(t.id)&&(o.node(t.id).data=t,void 0!==t.direction&&(o.node(t.id).direction=t.direction))})),o.edges().forEach((t=>{o.edge(t).source=o.node(t.v),o.edge(t).target=o.node(t.w)})),o}(a,s);var c;return d.order?(Q(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(Q(l,d.rankSets||[]),(c=l).edges().forEach((t=>{const e=c.node(t.v),o=c.node(t.w),n=c.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==o.rank&&i+1<=o.rank){for("l"===e.direction&&r.push(i);++i<o.rank;)r.push(i);"l"===o.direction&&r.push(i),R(c,t,n,r,"r")}else if(void 0!==i&&void 0!==o.rank&&i>o.rank){for("l"!==e.direction&&r.push(i);i-- >o.rank+1;)r.push(i);"l"!==o.direction&&r.push(i),R(c,t,n,r,"l")}})),r=function(t,e=25){const o=B(t);let n=o,i=q(t,o),r=0;for(;r++<e;){W(t,o,r%2==0?1:0),N(t,o);const e=q(t,o);if(e<i&&(n=G(o),i=e),0===i)break}return n.map((t=>[t]))}(l)),n=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const o=t.node(e);o.incoming=t.inEdges(e),o.outgoing=t.outEdges(e)}))}(l),i=o(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var o;let n=t.node(e);if(!n)return;let i=(null==(o=t.inEdges(e))?void 0:o.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let r,s=i.map((t=>t.r1));for(;n.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:s[e],x:n.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),n=t.node(e=r);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(l),function(t){t.edges().forEach((e=>{const o=t.edge(e);o.points||(o.points=[]),o.points.unshift({d:o.d0,ro:o.r0,x:o.x0,y:o.y0}),o.points.push({d:o.d1,ri:o.r1,x:o.x1,y:o.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return n},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const tt=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],et=t=>0===t.dy?0:2;function ot(t){const e=Math.max(et(t),t.dy)/2;let{x0:o}=t,{x1:n}=t,{y0:i}=t,{y1:r}=t;n<o&&([o,n]=[n,o],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,o=t.y1-t.y0;return[t.dy/2,(e*e+o*o)/Math.abs(4*o)]}(t),d=Math.max(a[0],Math.min(a[1],(n-o)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),c=Math.max(a[0],Math.min(a[1],t.r1||d));const h=n-o,u=r-i-s*(l+c),p=Math.sqrt(h*h+u*u),g=-s*Math.acos(Math.min(1,(l+c)/p)),f=Math.atan2(u,h);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=o+1*l*Math.sin(Math.abs(m)),x=n-1*c*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-c*s*(1-Math.cos(m));function A(t,o){const n=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?o+e:o-e;return 0===m&&(s=o),`A${s} ${s} ${Math.abs(m)} 0 ${n} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,c=0,b=o,x=n,w=i,E=r,v=0,y=e),`M${[o,i-e]} ${A(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${A(-1,c)}${[n,r-e]} L${[n,r+e]} ${A(1,c)}${[x-v,E+y]} L${[b-v,w+y]} ${A(-1,l)}${[o,i+e]} Z`}function nt(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],o=Math.max(et(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-o]} L${[e.x??0,(e.y??0)-o]} L${[e.x??0,(e.y??0)+o]} L${[(e.x??0)-20,(e.y??0)+o]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)+o]} L${[e.x??0,(e.y??0)+o]} Z`:null}(t);if(!t.points)return null;let o,n="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];o={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},n+=ot(o)}return n}const it=(t,e)=>{const o=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&o.length>e?`${o.substr(0,15)}...`:o};function rt(t,{fontColor:e,isRtl:o,maxRank:n,nodeWidth:i}){const{data:r}=t;if(!r)return null;const s=function(t,e,o){let n=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,n=!1),o&&(i=!i),{right:i,top:n}}(t,n,o),{x:a,y:d}=function(t,e,o){const n=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+o/2:-o/2-10,{x:(t.x??0)+i,y:(t.y??0)+n}}(t,s,i);return function(t="",{fontColor:e="#666767",pointerEvents:o="all",textAnchor:n="start",x:i,y:r}={}){const s=new c;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":o,"text-anchor":n}),s}(it(r,s.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:s.top?"middle":s.right?"start":"end",x:a,y:d})}function st(t,e,o){var n,i;const{dy:r,x:s,y:l}=t,{fontColor:c="#212121",fontSize:h="14px",fontFamily:u,fontWeight:p,isRtl:g=!1,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v=0,onNodeClick:w,nodeTooltip:E}=o,A=new a({class:"node"}),C=function({borderColor:t="#caced0",color:e="#97cbe6",height:o=0,opacity:n=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const l=new d;return l.attr({height:o,opacity:n,rx:i,ry:i,width:r,x:s,y:a}),l.fill(e),l.stroke({color:t,width:1}),l}({height:r,width:v,x:(s??0)-v/2,y:l});if(C.fill(null==(n=t.data)?void 0:n.color),C.stroke({color:f??(null==(i=t.data)?void 0:i.color),width:m}),C.on("click",(()=>{"function"==typeof w&&w(t)})),E){const{chartContext:e,isCustomTooltip:o,nodeValue:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=E,l=d({node:t.data,value:n});C.on("mouseover",(t=>{const{pageX:n,pageY:d}=t,g=x({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||c,fontFamily:o?void 0:u??"",fontSize:o?void 0:h??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});b(e,a,g,l,!0)})),C.on("mousemove",(t=>{const{pageX:n,pageY:d}=t,g=x({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||c,fontFamily:o?void 0:u??"",fontSize:o?void 0:h??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});b(e,a,g,l,!0)})),C.on("mouseout",(()=>{y(e,a).style.display="none"}))}if(A.add(C),t.data&&(r??0)>Number.parseInt(h,10)){const o=rt(t,{fontColor:c,isRtl:g,maxRank:e,nodeWidth:v});o&&A.add(o)}return A}const at={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",locale:{direction:"ltr"},nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:o})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${o}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}},dt={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:o})=>{let n=`Sankey flow diagram: ${o} nodes, ${t} flows.`;return e&&(n+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),n},edgeAriaLabel:({source:t,target:e,value:o})=>`Flow from ${t} to ${e}: ${o} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:o})=>{let n=e;if(t&&(n+=`: receives ${t.total} units from ${t.sources.join(", ")}`),o){n+=`${t?"; ":": "}flows ${o.total} units to ${o.targets.join(", ")}`}return n},nodesGroupLabel:"Sankey nodes"};function lt(t){var e;return function(t,e){if(!e)return{...t};const o={...t};for(const t of Object.keys(e)){const n=e[t];void 0!==n&&(o[t]=n)}return o}(dt,null==(e=t.locale)?void 0:e.messages)}class ct{constructor(t,e,o){this.element=t,this.options=e,this.chartContext=o,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(i,"svg");return new p(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new n(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,o,n){this.canvas.viewbox(`${t} ${e} ${o} ${n}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class ht{constructor(t,e,o){this.svgRoot=t,this.graph=e,this.dimOpacity=o}highlightNode(t){const e=this.prefersReducedMotion(),o=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],n=new Set([t]);o.forEach((t=>{var e,o,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(o=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:o.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&n.add(a),d&&n.add(d)})),this.dimAll(e),o.forEach((t=>{const o=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);o&&this.setOpacity(o,1,e)})),n.forEach((t=>{const o=this.svgRoot.querySelector(`[data-node-id="${t}"]`);o&&this.setOpacity(o,1,e)}))}highlightEdge(t,e){var o,n,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(n=null==(o=null==a?void 0:a.source)?void 0:o.data)?void 0:n.id)??t,l=(null==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const c=this.svgRoot.querySelector(`[data-node-id="${d}"]`),h=this.svgRoot.querySelector(`[data-node-id="${l}"]`);c&&this.setOpacity(c,1,s),h&&this.setOpacity(h,1,s)}reset(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,o){t.style.transition=o?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function ut(t,e){const o=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),n=o("--apex-sankey-edge-opacity"),i=""!==n?Number(n):e.edgeOpacity,r=o("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=o("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=o("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=o("--apex-sankey-node-border-color")||e.nodeBorderColor,u=o("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=o("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=o("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=o("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:o("--apex-sankey-label-color")||e.fontColor,fontSize:o("--apex-sankey-label-font-size")||e.fontSize,fontFamily:o("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:h,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const pt="#005FCC",gt="role",ft="aria-label",mt="data-node-id",vt="data-orig-stroke",yt="data-orig-stroke-width",bt="stroke",xt="stroke-width",wt="forced-colors",Et="apexsankey-desc",At="data-edge-target";const Ct="apexsankey-a11y-styles";class St{constructor(t,e,o={},n,i,r=dt){this.svgEl=t,this.graph=e,this.options=o,this.tooltipId=n,this.pathHighlighter=i,this.messages=r,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(Ct))return;const t=document.createElement("style");t.id=Ct,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${pt};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,messages:o,options:n}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),r=e.edges(),s=function(t,e,o,n,i){var r,s,a,d;if(i)return i;let l=0,c="",h="";for(const e of o)try{const o=t.edge(e.v,e.w,e.name).value??0;if(o>l){const n=t.node(e.v),i=t.node(e.w);n.dummy||i.dummy||(l=o,c=(null==(r=n.data)?void 0:r.title)??(null==(s=n.data)?void 0:s.id)??e.v,h=(null==(a=i.data)?void 0:a.title)??(null==(d=i.data)?void 0:d.id)??e.w)}}catch{}const u=c&&h?{source:c,target:h,value:l}:void 0;return n.diagramLabel({flowCount:o.length,largestFlow:u,nodeCount:e.length})}(e,i,r,o,n.diagramLabel);t.setAttribute(gt,"img"),t.setAttribute(ft,s),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),n.description){let e=t.querySelector("desc");if(!e){const o=document.createElementNS("http://www.w3.org/2000/svg","desc");o.id=Et,t.insertBefore(o,t.firstChild),e=o}e.textContent=n.description,t.setAttribute("aria-describedby",Et)}const d=Array.from(t.querySelectorAll(`[${mt}]`));d.forEach((t=>{const n=t.getAttribute(mt);n&&(t.setAttribute(gt,"listitem"),t.setAttribute(ft,function(t,e,o){var n,i,r,s,a,d;const l=e.node(t),c=(null==(n=l.data)?void 0:n.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const o of e.inEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.v);n.dummy||(h.push((null==(r=n.data)?void 0:r.title)??(null==(s=n.data)?void 0:s.id)??o.v),u+=t.value??0)}catch{}const p=[];let g=0;for(const o of e.outEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.w);n.dummy||(p.push((null==(a=n.data)?void 0:a.title)??(null==(d=n.data)?void 0:d.id)??o.w),g+=t.value??0)}catch{}return o.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:p.length>0?{targets:p,total:g}:void 0})}(n,e,o)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var n,i,r,s;const a=t.getAttribute("data-edge-source"),d=t.getAttribute("data-edge-target"),u=t.getAttribute("data-edge-name")??void 0;if(a&&d)try{const p=e.edge(a,d,u),g=p.source,f=p.target;if(!g||!f)return;const m=(null==(n=g.data)?void 0:n.title)??(null==(i=g.data)?void 0:i.id)??a,v=(null==(r=f.data)?void 0:r.title)??(null==(s=f.data)?void 0:s.id)??d,y=p.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",o.edgeAriaLabel({source:m,target:v,value:y})),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),l.push(t),h.set(t,a),c.has(a)||c.set(a,[]);const b=c.get(a);b&&b.push(t)}catch{}})),this.edgePaths=l,this.nodeOutEdges=c,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(o=>{const n=o.key;if("Enter"===n||" "===n){o.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===n)o.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===n||"ArrowDown"===n){o.preventDefault();const n=t.getAttribute(mt),i=n?this.nodeOutEdges.get(n)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===n||"ArrowUp"===n){o.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const o=t.getAttribute(mt);o&&(null==(e=this.pathHighlighter)||e.highlightNode(o))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},o=()=>{const e=this.edgeSourceNode.get(t),o=e?this.nodeGroups.find((t=>t.getAttribute(mt)===e)):void 0;o&&o.focus()};t.addEventListener("keydown",(n=>{const i=n.key;if("Enter"===i||" "===i)n.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)n.preventDefault(),o();else if("ArrowDown"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i+1)%o.length].focus()}else if("ArrowUp"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i-1+o.length)%o.length].focus()}else if("ArrowRight"===i){n.preventDefault();const e=t.getAttribute(At),o=e?this.nodeGroups.find((t=>t.getAttribute(mt)===e)):void 0;o&&o.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),o=this.nodeGroups.findIndex((t=>t.getAttribute(mt)===e));if(-1!==o){const t=n.shiftKey?(o-1+this.nodeGroups.length)%this.nodeGroups.length:(o+1)%this.nodeGroups.length;n.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const o=t.getAttribute("data-edge-source"),n=t.getAttribute(At);o&&n&&(null==(e=this.pathHighlighter)||e.highlightEdge(o,n))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const o=t.relatedTarget;o&&this.edgePaths.includes(o)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(vt,e.getAttribute(bt)??""),e.setAttribute(yt,e.getAttribute(xt)??""),e.setAttribute(bt,pt),e.setAttribute(xt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const o=e.getAttribute(vt),n=e.getAttribute(yt);null!==o&&(e.setAttribute(bt,o),e.removeAttribute(vt)),null!==n&&(e.setAttribute(xt,n),e.removeAttribute(yt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(wt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(wt):this.svgEl.classList.remove(wt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const kt="http://www.w3.org/2000/svg";class $t extends ct{constructor(t,e,o){super(t,e,o),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e,this.messages=lt(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var o;if("rtl"===t)return!0;if("ltr"===t)return!1;if("undefined"==typeof window||"undefined"==typeof document)return!1;if(e){const t=e.closest('[dir="rtl"], [dir="ltr"]');return t?"rtl"===t.getAttribute("dir"):"rtl"===window.getComputedStyle(e).direction}return"rtl"===((null==(o=document.documentElement)?void 0:o.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){const{edgeGap:e,nodeWidth:o,spacing:n,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=J({edgeGap:e,nodeWidth:o,whitespace:s});a.size([r-o,i-n]);const d=t.nodes.map(((t,e)=>{const o=e%tt.length;return{...t,color:t.color??tt[o],colorIndex:o}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l,this.isRtl&&this.mirrorLayoutForRtl()}mirrorLayoutForRtl(){const t=this.graph.nodes();let e=1/0,o=-1/0;for(const n of t){const t=this.graph.node(n).x;void 0!==t&&(e=Math.min(e,t),o=Math.max(o,t))}if(!Number.isFinite(e))return;const n=e+o;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=n-t.x)}for(const t of this.graph.edges()){const e=this.graph.edge(t.v,t.w,t.name);if(void 0!==e.x0&&(e.x0=n-e.x0),void 0!==e.x1&&(e.x1=n-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=n-t.x)}}render({keepOldPosition:t=!1}={}){var e,o;this.renderOptions=ut(this.element,this.options);const{tooltipTheme:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===n?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===n&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v,nodeTooltipTemplate:b,onNodeClick:x,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:C}=this.renderOptions,S=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new ht(this.canvas.node,this.graph,p):null;const k=((t={})=>{const e=[];for(const n in t){const i=`${o=n,o.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[n]};`;e.push(i)}var o;return e.join(" ")})({color:d,fontFamily:l,fontSize:c,fontWeight:h}),$=g(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(o=this.graph)?void 0:o.edges())||[],T=g();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const R=g();R.node.setAttribute("role","list"),R.node.setAttribute("aria-label",this.messages.nodesGroupLabel),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let o;if(a&&b){const e=this.graph.inEdges(t)??[],n=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),r=n.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),s=Math.max(i,r);o={chartContext:this.chartContext,isCustomTooltip:b!==at.nodeTooltipTemplate,nodeTooltipTemplate:b,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:C}}const n=st(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,isRtl:this.isRtl,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:o,onNodeClick:x});if(n.node.setAttribute("data-node-id",t),n.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;n.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),n.node.addEventListener("mouseleave",(()=>e.reset()))}R.add(n)})),$.add(R),this.add($);const{animation:_}=this.renderOptions;if((null==_?void 0:_.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,o,n,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(kt,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(kt,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(kt,"rect");h.setAttribute("x",String(a)),h.setAttribute("y","-9999"),h.setAttribute("height","99999"),h.setAttribute("width","0"),c.appendChild(h),d.appendChild(c),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(o){null===u&&(u=o);const n=o-u,r=Math.min(n/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;h.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),c.remove())}));const p=o.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),o=g+(n>0?e/n:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:o,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,R.node,this.maxRank,_.duration)),t&&this.updateViewBox(S.x,S.y,S.width,S.height),a){const t=y(this.chartContext,C);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const B=this.renderOptions.a11y;!1!==(null==B?void 0:B.enabled)&&(this.a11yHelper=new St(this.canvas.node,this.graph,B,C,this.pathHighlighter,this.messages),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:o,edgeOpacity:n,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:c,tooltipBorderColor:h,tooltipFontColor:u,tooltipId:p,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),w=f.source,E=f.target;if(!w||!E)return;const A=this.isRtl?-1:1;m.dummy&&(f.x0=(f.x0??0)-d/2*A),v.dummy&&(f.x1=(f.x1??0)+d/2*A);const C=nt(f);if(!C)return;const S=function(t,{edgeColor:e,id:o="",opacity:n=1}={}){const i=new l({d:t});return i.id(o),i.fill(e).opacity(n),i}(C,{edgeColor:this.canvas.gradient("linear",(t=>{var e,n,i;t.stop(0,(null==(e=w.data)?void 0:e.color)??""),t.stop(1,o?(null==(n=E.data)?void 0:n.color)??"":(null==(i=w.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:n});if(S.node.setAttribute("data-edge-source",t.v),S.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&S.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,o=t.v,n=t.w;S.on("mouseenter",(()=>e.highlightEdge(o,n))),S.on("mouseleave",(()=>e.reset()))}if(i&&w.data&&E.data){const t=g?g({source:w.data,target:E.data,value:f.value}):`${w.data.title} → ${E.data.title}: ${f.value}`,e=g!==at.tooltipTemplate;S.on("mouseover",(o=>{const{pageX:n,pageY:i}=o,d=x({bgColor:e?void 0:c,borderColor:e?void 0:h,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});b(this.chartContext,p,d,t,!0)})),S.on("mousemove",(o=>{const{pageX:n,pageY:i}=o,d=x({bgColor:e?void 0:c,borderColor:e?void 0:h,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});b(this.chartContext,p,d,t,!0)})),S.on("mouseout",(()=>{y(this.chartContext,p).style.display="none"}))}e.add(S)}}class Mt extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...at,...e};const{height:o,width:n}=this.options;this.graph=new $t(this.element,this.options,this.chartContext),this.setupElementDimensions(n,o),this.handleWatermark()}static setLicense(t){A.setLicense(t)}setupElementDimensions(t,e){let o=!1,n=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(n=Number(t.substring(0,t.length-1)),o=!0):n=Number(t);const i="auto"===e?n/1.6:e;this.element.style.width=`${n}${o?"%":"px"}`,this.element.style.height=`${i}${o?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(A.isLicenseValid()?S.remove(this.element):S.add(this.element))}render(t){var e,o,n;if(!this.element)throw new Error("Element not found");if(o=this.element,n=(null==(e=this.options.locale)?void 0:e.direction)??"ltr",o&&("ltr"===n?o.removeAttribute("dir"):o.setAttribute("dir",n)),this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new m(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}}"undefined"!=typeof window&&(window.ApexSankey=Mt);export{Mt as ApexSankey,dt as DEFAULT_SANKEY_MESSAGES,Mt as default};
package/apexsankey.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSankey={})}(this,(function(t){"use strict";const e=()=>{};class o{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),o=Array.from(e);return{item:t=>o[t]||null,get length(){return o.length},[Symbol.iterator]:()=>o[Symbol.iterator](),...Object.fromEntries(o.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,o):this.context.addEventListener(t,e,o)}removeEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,o):this.context.removeEventListener(t,e,o)}injectStyles(t,e,o={}){const{force:n=!1,priority:i="normal"}=o;if(!n&&this.injectedStyles.has(e))return;if(n){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!n)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:o})=>{this.injectStyles(t,e,o)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class n{constructor(t,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new o(t,e)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,o){this.chartContext.addEventListener(t,e,o)}removeEventListener(t,e,o){this.chartContext.removeEventListener(t,e,o)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class i{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const r="http://www.w3.org/2000/svg";let s=0;class a{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:o}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==o&&this.node.setAttribute("stroke-dasharray",String(o)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof a?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new a(e):null}first(){const t=this.node.firstElementChild;return t?new a(t):null}}class d extends a{constructor(t){super(document.createElementNS(r,"g")),t&&this.attr(t)}}class l extends a{constructor(){super(document.createElementNS(r,"rect"))}}class h extends a{constructor(t){super(document.createElementNS(r,"path")),t&&this.attr(t)}}class c extends a{constructor(){super(document.createElementNS(r,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(r,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class u{constructor(t){this.gradient=t}stop(t,e){const o=document.createElementNS(r,"stop");o.setAttribute("offset",String(t)),o.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(o)}}function p(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class g{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}add(t){return this.node.appendChild(t instanceof a?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(r,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const o=document.createElementNS(r,"linearGradient"),n="apx-grad-"+ ++s;return o.setAttribute("id",n),o.setAttribute("x1","0%"),o.setAttribute("y1","0%"),o.setAttribute("x2","100%"),o.setAttribute("y2","0%"),e(new u(o)),this._defs.appendChild(o),o}panZoom(t={}){return this._panZoomState=function(t,e){const o=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),n={zoomFactor:e.zoomFactor??.2,zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...o},vb:{...o}};t.addEventListener("wheel",(e=>{let o;if(e.preventDefault(),e.ctrlKey){const t=.005;o=1+Math.max(-.15,Math.min(.15,e.deltaY*t))}else o=e.deltaY<0?1-n.zoomFactor:1+n.zoomFactor;const i=n.currentZoom/o;if(i<n.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=n,l=d.w*o,h=d.h*o,c=d.x+s*(d.w-l),u=d.y+a*(d.h-h);n.vb={x:c,y:u,w:l,h:h},n.currentZoom=i,p(t,n.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const o=e.clientX-a,n=e.clientY-d;if(Math.abs(o)<4&&Math.abs(n)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const o=t.getBoundingClientRect(),l=n.vb.w/o.width,h=n.vb.h/o.height,c=(e.clientX-a)*l,u=(e.clientY-d)*h;n.vb={x:n.vb.x-c,y:n.vb.y-u,w:n.vb.w,h:n.vb.h},p(t,n.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),n}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const o=this._panZoomState;if(t<o.zoomMin)return this;const n=o.currentZoom/t,{vb:i}=o,r=i.w*n,s=i.h*n,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return o.vb={x:a,y:d,w:r,h:s},o.currentZoom=t,p(this.node,o.vb),this}}function f(t,e,o,n){const i=new d;return i.attr({"data-parent":n,"data-self":o,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const m={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class v{constructor(t,e){this.element=t,t&&(this.chartContext=e||new o(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n right: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n right: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,o){const n=this.chartContext.createElement("div");return n.id=t,n.className="toolbar-item",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.innerHTML=e,o&&(n.setAttribute("data-tooltip",o),n.setAttribute("aria-label",o)),n.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())})),n}render({enableExport:t=!1,enableFitscreen:o=!1,enableZoom:n=!1,onExport:i=e,onFitscreen:r=e,onZoom:s=e}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),t){const t=this.createToolbarItem("export",m.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(n){const t=this.createToolbarItem("zoom-in",m["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",m["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(o){const t=this.createToolbarItem("fit-screen",m["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const y="aria-hidden",b=(t,e="apex-tooltip-container")=>{let o=t.getElementById(e);if(!o){o=t.createElement("div"),o.id=e,o.setAttribute("role","tooltip"),o.setAttribute(y,"true");t.getAppendContainer().appendChild(o),t.trackTooltip(o)}return o},x=(t,e="",o,n="",i=!1)=>{const r=t.getElementById(e);if(!r)return b(t,e),x(t,e,o,n,i);if(o&&n){const e=n.includes("tooltip-content"),s=o.match(/background-color:\s*([^;]+);?/),a=o.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=n;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${n}</div>`}const d=o+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(r.setAttribute("style",d),r.classList.add("visible"),r.setAttribute(y,"false"),i&&"undefined"!=typeof window){const e=r.offsetWidth,o=parseFloat(r.style.left),n=t.getChartBounds();if(e>0&&!Number.isNaN(o)&&n.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=n.left+t,s=((t,e,o,n,i=8)=>{if(t+e<=o-i)return t;const r=t-e;return r<n+i?Math.max(n+i,o-e-i):r})(o,e,n.right+t,i);s!==o&&(r.style.left=`${s}px`)}}}else r.removeAttribute("style"),r.classList.remove("visible"),r.setAttribute(y,"true"),r.innerHTML=""},w=({bgColor:t,borderColor:e,fontColor:o,fontFamily:n,fontSize:i,fontWeight:r,maxWidth:s,padding:a,placement:d="top",x:l,y:h})=>{const c=["position: absolute;","z-index: 1000;","pointer-events: none;"];return c.push("box-sizing: border-box;"),c.push("word-wrap: break-word;"),c.push("overflow-wrap: break-word;"),c.push(`left: ${l}px;`),c.push(`top: ${h}px;`),c.push(`data-placement: ${d};`),s&&(c.push(`width: ${s}px;`),c.push(`max-width: ${s}px;`)),e&&c.push(`border: 1px solid ${e};`),o&&c.push(`color: ${o};`),n&&c.push(`font-family: ${n};`),r&&c.push(`font-weight: ${r};`),i&&c.push(`font-size: ${i};`),t&&(c.push(`background-color: ${t};`),c.push("border-radius: 6px;"),c.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&c.push(`padding: ${a}px;`),c.join(" ")},E=globalThis.console;const S=class{static decodeLicenseData(t){try{const e=window.atob(t),o=JSON.parse(e);return o.issueDate&&o.expiryDate&&o.plan?{domains:Array.isArray(o.domains)?o.domains:void 0,expiryDate:o.expiryDate,issueDate:o.issueDate,plan:o.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,o="standard",n){const i={expiryDate:e,issueDate:t,plan:o};n&&n.length>0&&(i.domains=n);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,E.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.indexOf("-"),o=-1!==e?t.slice(e+1):"";if(!o)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=this.decodeLicenseData(o);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(n.expiryDate)<i)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,valid:!1};if(n.domains&&n.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!n.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:n,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${n.domains.join(", ")}.`,valid:!1}}return{data:n,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};S.licenseKey=null,S.validationResult=null;let A=S;const C=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};C.WATERMARK_ATTR="data-apexcharts-watermark",C.WATERMARK_TEXT="APEXCHARTS";let k=C;function $(t,e){let o=null;for(let n=0;n<t.length;++n)if(e(t[n])){o=n;break}return o}function M(t,e){if(0===t.length)return;let o,n=0;for(let i=t.length-1;i>=0;--i)o=(t[i].dy??0)/2,(t[i][e]??0)-o<n&&(t[i][e]=Math.min(t[i].Rmax??0,n+o)),n=(t[i][e]??0)+o;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let n=0;n<t.length;++n)o=(t[n].dy??0)/2,(t[n][e]??0)+o>i&&(t[n][e]=Math.max(o,i-o)),i=(t[n][e]??0)-o}function L(t){const e=t.edgeGap||0;return function(o){!function(t,e,o){t.nodes().forEach((n=>{const i=t.node(n),r=T(t,i.outgoing||[],"outgoing"),s=T(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),h=s.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),c=l+Math.max(0,a-1)*o,u=h+Math.max(0,d-1)*o;let p=((i.dy??0)-c)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),r.forEach(((n,r)=>{const s=t.edge(n);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=o)})),s.forEach(((n,r)=>{const s=t.edge(n);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<d-1&&(g+=o)}))}))}(o,t,e),function(t){t.nodes().forEach((e=>{const o=t.node(e),n=(o.outgoing||[]).map((e=>t.edge(e))),i=(o.incoming||[]).map((e=>t.edge(e)));n.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),_(n,"r0"),_(i,"r1")}))}(o);const n=[];return o.edges().forEach((t=>{const e=o.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,n.push(e)})),n}}function T(t,e,o){return e.slice().sort(((e,n)=>{let i,r;if("outgoing"===o){const o=t.node(e.w),s=t.node(n.w);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}else{const o=t.node(e.v),s=t.node(n.v);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==n.name){if("number"==typeof e.name&&"number"==typeof n.name)return e.name-n.name;if("string"==typeof e.name&&"string"==typeof n.name)return e.name.localeCompare(n.name)}return 0}))}function _(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),o=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(o)/2.1:0!==o?(e*e+o*o)/Math.abs(4*o):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let o=$(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===o&&(o=t.length),M(t.slice(o),e),o>0){const n=[];for(let e=o-1;e>=0;e--)n.push(t[e]);M(n,e)}}function B(t,e,o,n,i){if(0===n.length)return;const r=n.map((o=>{const n=`__${e.v}_${e.w}_${o}`;return t.setNode(n,{data:null,direction:i,dummy:!0,rank:o}),n})),s=[e.v,...r,e.w];s.forEach(((n,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:o,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function N(t,e,o){return function(t,e,o){let n,i;e.length>o.length?(n=e,i=o):(n=o,i=e);const r=i.length,s=[];n.forEach((e=>{i.forEach(((o,n)=>{(t.hasEdge(e,o)||t.hasEdge(o,e))&&s.push(n)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let h=0;return s.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(h+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),h}(t,e,o)}function R(t){const e=[];let o=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===o.length&&(o=t.nodes().slice(0,1)),function(t,e){const o=new Set,n=[];function i(e){if(!o.has(e)){o.add(e),n.push(e);for(const o of t.successors(e))i(o)}}for(const t of e)i(t);return n}(t,o).forEach((o=>{const n=t.node(o).rank;if(void 0!==n){for(;n>=e.length;)e.push([]);e[n].push(o)}})),e}function F(t,e){let o=!0;for(;o;){o=!1;for(let n=0;n<e.length;++n)for(let i=0;i<e[n].length-1;++i){const r=I(t,e,n);z(e[n],i,i+1);I(t,e,n)<r?o=!0:z(e[n],i,i+1)}}}function I(t,e,o){let n=0;return o>0&&(n+=N(t,e[o-1],e[o])),o+1<e.length&&(n+=N(t,e[o],e[o+1])),n}function z(t,e,o){const n=t[e];t[e]=t[o],t[o]=n}function O(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const o=t[e-1]-t[0],n=t[t.length-1]-t[e];return(t[e-1]*n+t[e]*o)/(o+n)}function W(t,e,o=1,n=!1){if(o>0)for(let o=1;o<e.length;++o){const i=new Map;e[o].forEach((r=>{const s=O(j(t,e,o,o-1,r,n));i.set(r,s)})),q(e[o],i)}else for(let o=e.length-2;o>=0;--o){const i=new Map;e[o].forEach((r=>{const s=O(j(t,e,o,o+1,r,n));i.set(r,s)})),q(e[o],i)}}function j(t,e,o,n,i,r=!1){const s=e[o],a=e[n],d=[];return a.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o)})),0===d.length&&r&&s.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o+.5)})),d.sort(((t,e)=>t-e)),d}function q(t,e){const o=new Map(t.map(((t,e)=>[t,e])));for(let n=1;n<t.length;++n)for(let i=n;i>0;--i){let n=i-1,r=e.get(t[n]),s=e.get(t[i]);for(;-1===(r=e.get(t[n]))&&n>0;)n--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=o.get(t[n])??r,s=o.get(t[i])??s),s>=r)break;[t[i],t[n]]=[t[n],t[i]]}}function D(t,e){let o=0;for(let n=0;n<e.length-1;++n)o+=N(t,e[n],e[n+1]);return o}function H(t){const e=[];for(const o of t){const t=[];e.push(t);for(const e of o)t.push(e)}return e}const G=(t,e)=>(t||[]).reduce(((t,o)=>t+(e?e(o):o)),0);function Y(){let t=[100,100],e=null,o=.18,n=function(t,e,o){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),P(a,i,r),function(t,e,o,n=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);i.dy=i.value*o+l*n})),t.edges().forEach((n=>{const i=t.edge(n);i.value=e(i),i.dy=i.value*o}))}(a,i,e,l);const h=Z(a,d,l,e),c=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;c[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=h[d]/G(h)*t[1],p=0===s?0:o*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?n(l[e],l[e+1],a):0)),m=G(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=G(f)?v/G(f):0;let b=s+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),c[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o];for(let t=0;t<n.length;t++){const i=n[t];for(let n=0;n<i.length;n++)e.push({rankIndex:o,bandIndex:t,nodeIndex:n,nodeId:i[n]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:o,nodeId:n})=>{var i;t===g&&e===f||(g=t,f=e,u=c[t][e],p=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(n);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[o]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),o===p.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const o=[];return e.forEach(((n,i)=>{if(i===e.length-1)return;let r=0;n.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const o=t.edge(e).dy,n=t.node(e.w).y-t.node(e.v).y,i=Math.abs(n)-o,s=o*o-i*i,a=s>=0?Math.sqrt(s):o;a>r&&(r=a)}))}))})),o.push(r)})),o}(a,d);!function(t,e,o,n){const i=n.reduce(((t,e)=>t+e),0);let r;if(i>o)r=n.map((t=>o*t/i));else{const t=o-i;r=n.map((o=>o+t/(e.length-1)))}let s=0;e.forEach(((e,o)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[o]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return s.scaleToFit=function(n,s,a=0){P(n,i,r);let d=0;a>0&&n.nodes().forEach((t=>{d=Math.max(d,function(t,e,o){if(o<=0)return 0;const n=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,n.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*o}(n,t,a))}));const l=G(Z(n,s,0,1));if(l<=0)return void(e=1);const h=t[1]-d;e=h/l,1!==o&&(e*=1-o)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(n="function"==typeof t?t:()=>t,s):n},s.whitespace=function(t){return arguments.length?(o=t,s):o},s.scale=function(t){return arguments.length?(e=t,s):e},s}function P(t,e,o){t.nodes().forEach((n=>{const i=G(t.inEdges(n),(o=>e(t.edge(o)))),r=G(t.outEdges(n),(o=>e(t.edge(o))));let s=t.node(n);s||t.setNode(n,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=o(s)||"r")}))}function Z(t,e,o=0,n=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=G(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*o/n}));r[i]=Math.max(r[i],s)}))})),r}function X(t,e,o){return void 0!==o?`${t}${e}${o}`:`${t}${e}`}class V{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,o;if(!this._nodes.has(t))return this;this._nodes.delete(t);const n=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of n){const o=this._edges.get(t);o&&(null==(e=this._in.get(o.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(o=this._out.get(e.v))||o.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,o,n){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,n=t.name,o=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?X(s,a,n):X(s,a),l=this._edges.get(d);if(l)void 0!==o&&(l.label=o);else{const t={v:s,w:a,name:n,label:void 0!==o?o:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,o){var n;let i;return i="string"==typeof t?this._isMultigraph?X(t,e,o):X(t,e):this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),null==(n=this._edges.get(i))?void 0:n.label}hasEdge(t,e,o){const n=this._isMultigraph?X(t,e,o):X(t,e);return this._edges.has(n)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:o})=>({v:t,w:e,name:o})))}removeEdge(t){var e,o;const n=this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),i=this._edges.get(n);return i?(null==(e=this._out.get(i.v))||e.delete(n),null==(o=this._in.get(i.w))||o.delete(n),this._edges.delete(n),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const o=[],n=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=X(i.v,i.w,i.name);n.has(t)||(n.add(t),o.push(i))}return o}}function K(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function U(t,e){const o=function(t,e){const o=new Set,n=new V({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Q(t,e,o,n,i),t.nodes().forEach((e=>{o.has(e)||Q(t,e,o,n,i)})),i.forEach(((t,e)=>{n.node(t).thread=e+1<i.length?i[e+1]:i[0]})),n}(t,e);return t.edges().forEach((e=>{const n=function(t,e,o){const n=t.node(e),i=t.node(o);if((n.depth??0)<(i.depth??0)){let e=n.thread;for(;void 0!==e&&(t.node(e).depth??0)>(n.depth??0);){if(e===o)return 1;e=t.node(e).thread}}else if((i.depth??0)<(n.depth??0)){let o=i.thread;for(;void 0!==o&&(t.node(o).depth??0)>(i.depth??0);){if(o===e)return-1;o=t.node(o).thread}}return 0}(o,e.v,e.w);if(n<0){const o=t.edge(e)||{};o.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,o)}})),t}function Q(t,e,o,n,i,r=0){if(!o.has(e)){o.add(e),i.push(e),n.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{o.has(s)||n.setEdge(e,s,{delta:1}),Q(t,s,o,n,i,r+1)}))}}function J(t,e){if(0===t.nodes().length)return;const o=function(t,e){const o=new V({directed:!0});let n=!1;for(const t of e)if("min"===t.type){n=!0;break}if(!n){const o=t.sources();e=o.length>0?[{nodes:[o[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;t.nodes.forEach((t=>{i.set(t,e)})),o.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,n={nodes:[t],type:"same"};i.set(t,e),o.setNode(e,n)}})),t.edges().forEach((e=>{const n=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=o.edge(n,r)||{delta:0};n===r?(d.delta=0,o.setEdge(n,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),o.setEdge(r,n,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),o.setEdge(n,r,d))})),o}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(o),U(o,"0"),function(t){var e;const o=t.sources(),n=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(K(t))}));o.length>0;){const r=o.shift();if(void 0===r)break;n.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const o of t.inEdges(r)){const n=(null==(e=t.edge(o)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(o.v).rank??0)+n)}for(const e of t.outEdges(r))i.add(K(e));for(const e of t.nodes())o.indexOf(e)<0&&!n.has(e)&&!t.inEdges(e).some((t=>!i.has(K(t))))&&o.push(e)}}(o),function(t){function e(e){const o=t.node(e),n=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==n&&(o.rank=n)}t.edges().forEach((o=>{t.edge(o).temp&&e(o.w)}))}(o),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),o.nodes().forEach((e=>{var n;const i=o.node(e);null==(n=i.nodes)||n.forEach((e=>{t.node(e).rank=i.rank}))}))}function tt(t){const e=Y(),o=L(t);let n=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const o=new V({directed:!0,multigraph:!0});return e.forEach((t=>{o.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),o.nodes().forEach((t=>o.setNode(t,{data:{}}))),t.forEach((t=>{o.hasNode(t.id)&&(o.node(t.id).data=t,void 0!==t.direction&&(o.node(t.id).direction=t.direction))})),o.edges().forEach((t=>{o.edge(t).source=o.node(t.v),o.edge(t).target=o.node(t.w)})),o}(a,s);var h;return d.order?(J(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(J(l,d.rankSets||[]),(h=l).edges().forEach((t=>{const e=h.node(t.v),o=h.node(t.w),n=h.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==o.rank&&i+1<=o.rank){for("l"===e.direction&&r.push(i);++i<o.rank;)r.push(i);"l"===o.direction&&r.push(i),B(h,t,n,r,"r")}else if(void 0!==i&&void 0!==o.rank&&i>o.rank){for("l"!==e.direction&&r.push(i);i-- >o.rank+1;)r.push(i);"l"!==o.direction&&r.push(i),B(h,t,n,r,"l")}})),r=function(t,e=25){const o=R(t);let n=o,i=D(t,o),r=0;for(;r++<e;){W(t,o,r%2==0?1:0),F(t,o);const e=D(t,o);if(e<i&&(n=H(o),i=e),0===i)break}return n.map((t=>[t]))}(l)),n=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const o=t.node(e);o.incoming=t.inEdges(e),o.outgoing=t.outEdges(e)}))}(l),i=o(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var o;let n=t.node(e);if(!n)return;let i=(null==(o=t.inEdges(e))?void 0:o.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let r,s=i.map((t=>t.r1));for(;n.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:s[e],x:n.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),n=t.node(e=r);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(l),function(t){t.edges().forEach((e=>{const o=t.edge(e);o.points||(o.points=[]),o.points.unshift({d:o.d0,ro:o.r0,x:o.x0,y:o.y0}),o.points.push({d:o.d1,ri:o.r1,x:o.x1,y:o.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return n},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const et=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],ot=t=>0===t.dy?0:2;function nt(t){const e=Math.max(ot(t),t.dy)/2;let{x0:o}=t,{x1:n}=t,{y0:i}=t,{y1:r}=t;n<o&&([o,n]=[n,o],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,o=t.y1-t.y0;return[t.dy/2,(e*e+o*o)/Math.abs(4*o)]}(t),d=Math.max(a[0],Math.min(a[1],(n-o)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),h=Math.max(a[0],Math.min(a[1],t.r1||d));const c=n-o,u=r-i-s*(l+h),p=Math.sqrt(c*c+u*u),g=-s*Math.acos(Math.min(1,(l+h)/p)),f=Math.atan2(u,c);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=o+1*l*Math.sin(Math.abs(m)),x=n-1*h*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-h*s*(1-Math.cos(m));function S(t,o){const n=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?o+e:o-e;return 0===m&&(s=o),`A${s} ${s} ${Math.abs(m)} 0 ${n} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,h=0,b=o,x=n,w=i,E=r,v=0,y=e),`M${[o,i-e]} ${S(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${S(-1,h)}${[n,r-e]} L${[n,r+e]} ${S(1,h)}${[x-v,E+y]} L${[b-v,w+y]} ${S(-1,l)}${[o,i+e]} Z`}function it(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],o=Math.max(ot(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-o]} L${[e.x??0,(e.y??0)-o]} L${[e.x??0,(e.y??0)+o]} L${[(e.x??0)-20,(e.y??0)+o]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)+o]} L${[e.x??0,(e.y??0)+o]} Z`:null}(t);if(!t.points)return null;let o,n="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];o={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},n+=nt(o)}return n}const rt=(t,e)=>{const o=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&o.length>e?`${o.substr(0,15)}...`:o};function st(t,{fontColor:e,maxRank:o,nodeWidth:n}){const{data:i}=t;if(!i)return null;const r=function(t,e){let o=!1,n=!1;return(t.rank??0)<e/2&&(n=!0,o=!1),{right:n,top:o}}(t,o),{x:s,y:a}=function(t,e,o){const n=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+o/2:-o/2-10,{x:(t.x??0)+i,y:(t.y??0)+n}}(t,r,n);return function(t="",{fontColor:e="#666767",pointerEvents:o="all",textAnchor:n="start",x:i,y:r}={}){const s=new c;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":o,"text-anchor":n}),s}(rt(i,r.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:r.top?"middle":r.right?"start":"end",x:s,y:a})}function at(t,e,o){var n,i;const{dy:r,x:s,y:a}=t,{fontColor:h="#212121",fontSize:c="14px",fontFamily:u,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m=0,onNodeClick:v,nodeTooltip:y}=o,E=new d({class:"node"}),S=function({borderColor:t="#caced0",color:e="#97cbe6",height:o=0,opacity:n=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const d=new l;return d.attr({height:o,opacity:n,rx:i,ry:i,width:r,x:s,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}({height:r,width:m,x:(s??0)-m/2,y:a});if(S.fill(null==(n=t.data)?void 0:n.color),S.stroke({color:g??(null==(i=t.data)?void 0:i.color),width:f}),S.on("click",(()=>{"function"==typeof v&&v(t)})),y){const{chartContext:e,isCustomTooltip:o,nodeValue:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=y,l=d({node:t.data,value:n});S.on("mouseover",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mousemove",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mouseout",(()=>{b(e,a).style.display="none"}))}if(E.add(S),t.data&&(r??0)>Number.parseInt(c,10)){const o=st(t,{fontColor:h,maxRank:e,nodeWidth:m});o&&E.add(o)}return E}const dt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:o})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${o}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}};class lt{constructor(t,e,o){this.element=t,this.options=e,this.chartContext=o,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(r,"svg");return new g(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new i(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,o,n){this.canvas.viewbox(`${t} ${e} ${o} ${n}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class ht{constructor(t,e,o){this.svgRoot=t,this.graph=e,this.dimOpacity=o}highlightNode(t){const e=this.prefersReducedMotion(),o=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],n=new Set([t]);o.forEach((t=>{var e,o,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(o=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:o.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&n.add(a),d&&n.add(d)})),this.dimAll(e),o.forEach((t=>{const o=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);o&&this.setOpacity(o,1,e)})),n.forEach((t=>{const o=this.svgRoot.querySelector(`[data-node-id="${t}"]`);o&&this.setOpacity(o,1,e)}))}highlightEdge(t,e){var o,n,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(n=null==(o=null==a?void 0:a.source)?void 0:o.data)?void 0:n.id)??t,l=(null==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const h=this.svgRoot.querySelector(`[data-node-id="${d}"]`),c=this.svgRoot.querySelector(`[data-node-id="${l}"]`);h&&this.setOpacity(h,1,s),c&&this.setOpacity(c,1,s)}reset(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,o){t.style.transition=o?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function ct(t,e){const o=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),n=o("--apex-sankey-edge-opacity"),i=""!==n?Number(n):e.edgeOpacity,r=o("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=o("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=o("--apex-sankey-edge-gradient"),h=""!==l?"true"===l:e.edgeGradientFill,c=o("--apex-sankey-node-border-color")||e.nodeBorderColor,u=o("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=o("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=o("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=o("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:h,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:o("--apex-sankey-label-color")||e.fontColor,fontSize:o("--apex-sankey-label-font-size")||e.fontSize,fontFamily:o("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:c,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const ut="#005FCC",pt="role",gt="aria-label",ft="data-node-id",mt="data-orig-stroke",vt="data-orig-stroke-width",yt="stroke",bt="stroke-width",xt="forced-colors",wt="apexsankey-desc",Et="data-edge-target";const St="apexsankey-a11y-styles";class At{constructor(t,e,o={},n,i){this.svgEl=t,this.graph=e,this.options=o,this.tooltipId=n,this.pathHighlighter=i,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(St))return;const t=document.createElement("style");t.id=St,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${ut};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,options:o}=this,n=e.nodes().filter((t=>!e.node(t).dummy)),i=e.edges(),r=function(t,e,o,n){var i,r,s,a;if(n)return n;let d=0,l="",h="";for(const e of o)try{const o=t.edge(e.v,e.w,e.name).value??0;if(o>d){const n=t.node(e.v),c=t.node(e.w);n.dummy||c.dummy||(d=o,l=(null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??e.v,h=(null==(s=c.data)?void 0:s.title)??(null==(a=c.data)?void 0:a.id)??e.w)}}catch{}let c=`Sankey flow diagram: ${e.length} nodes, ${o.length} flows.`;return l&&h&&(c+=` Largest flow: ${l} (${d} units) to ${h}.`),c}(e,n,i,o.diagramLabel);t.setAttribute(pt,"img"),t.setAttribute(gt,r),t.removeAttribute("aria-labelledby");const s=t.querySelector("title");if(s&&s.remove(),o.description){let e=t.querySelector("desc");if(!e){const o=document.createElementNS("http://www.w3.org/2000/svg","desc");o.id=wt,t.insertBefore(o,t.firstChild),e=o}e.textContent=o.description,t.setAttribute("aria-describedby",wt)}const a=Array.from(t.querySelectorAll(`[${ft}]`));a.forEach((t=>{const o=t.getAttribute(ft);o&&(t.setAttribute(pt,"listitem"),t.setAttribute(gt,function(t,e){var o,n,i,r,s,a;const d=e.node(t),l=(null==(o=d.data)?void 0:o.title)??(null==(n=d.data)?void 0:n.id)??t,h=[];let c=0;for(const o of e.inEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.v);n.dummy||(h.push((null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??o.v),c+=t.value??0)}catch{}const u=[];let p=0;for(const o of e.outEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.w);n.dummy||(u.push((null==(s=n.data)?void 0:s.title)??(null==(a=n.data)?void 0:a.id)??o.w),p+=t.value??0)}catch{}let g=l;h.length>0&&(g+=`: receives ${c} units from ${h.join(", ")}`),u.length>0&&(g+=`${h.length>0?"; ":": "}flows ${p} units to ${u.join(", ")}`);return g}(o,e)),t.setAttribute("tabindex","0"))})),this.nodeGroups=a;const d=[],l=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,n,i,r;const s=t.getAttribute("data-edge-source"),a=t.getAttribute("data-edge-target"),c=t.getAttribute("data-edge-name")??void 0;if(s&&a)try{const u=e.edge(s,a,c),p=u.source,g=u.target;if(!p||!g)return;const f=(null==(o=p.data)?void 0:o.title)??(null==(n=p.data)?void 0:n.id)??s,m=(null==(i=g.data)?void 0:i.title)??(null==(r=g.data)?void 0:r.id)??a,v=u.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",`Flow from ${f} to ${m}: ${v} units`),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),d.push(t),h.set(t,s),l.has(s)||l.set(s,[]);const y=l.get(s);y&&y.push(t)}catch{}})),this.edgePaths=d,this.nodeOutEdges=l,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(o=>{const n=o.key;if("Enter"===n||" "===n){o.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===n)o.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===n||"ArrowDown"===n){o.preventDefault();const n=t.getAttribute(ft),i=n?this.nodeOutEdges.get(n)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===n||"ArrowUp"===n){o.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const o=t.getAttribute(ft);o&&(null==(e=this.pathHighlighter)||e.highlightNode(o))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},o=()=>{const e=this.edgeSourceNode.get(t),o=e?this.nodeGroups.find((t=>t.getAttribute(ft)===e)):void 0;o&&o.focus()};t.addEventListener("keydown",(n=>{const i=n.key;if("Enter"===i||" "===i)n.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)n.preventDefault(),o();else if("ArrowDown"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i+1)%o.length].focus()}else if("ArrowUp"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i-1+o.length)%o.length].focus()}else if("ArrowRight"===i){n.preventDefault();const e=t.getAttribute(Et),o=e?this.nodeGroups.find((t=>t.getAttribute(ft)===e)):void 0;o&&o.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),o=this.nodeGroups.findIndex((t=>t.getAttribute(ft)===e));if(-1!==o){const t=n.shiftKey?(o-1+this.nodeGroups.length)%this.nodeGroups.length:(o+1)%this.nodeGroups.length;n.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const o=t.getAttribute("data-edge-source"),n=t.getAttribute(Et);o&&n&&(null==(e=this.pathHighlighter)||e.highlightEdge(o,n))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const o=t.relatedTarget;o&&this.edgePaths.includes(o)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(mt,e.getAttribute(yt)??""),e.setAttribute(vt,e.getAttribute(bt)??""),e.setAttribute(yt,ut),e.setAttribute(bt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const o=e.getAttribute(mt),n=e.getAttribute(vt);null!==o&&(e.setAttribute(yt,o),e.removeAttribute(mt)),null!==n&&(e.setAttribute(bt,n),e.removeAttribute(vt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(xt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(xt):this.svgEl.classList.remove(xt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Ct="http://www.w3.org/2000/svg";class kt extends lt{constructor(t,e,o){super(t,e,o),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e}construct(t){const{edgeGap:e,nodeWidth:o,spacing:n,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=tt({edgeGap:e,nodeWidth:o,whitespace:s});a.size([r-o,i-n]);const d=t.nodes.map(((t,e)=>{const o=e%et.length;return{...t,color:t.color??et[o],colorIndex:o}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l}render({keepOldPosition:t=!1}={}){var e,o;this.renderOptions=ct(this.element,this.options);const{tooltipTheme:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===n?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===n&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltipTemplate:y,onNodeClick:x,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:S,tooltipId:A}=this.renderOptions,C=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new ht(this.canvas.node,this.graph,p):null;const k=((t={})=>{const e=[];for(const n in t){const i=`${o=n,o.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[n]};`;e.push(i)}var o;return e.join(" ")})({color:d,fontFamily:l,fontSize:h,fontWeight:c}),$=f(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(o=this.graph)?void 0:o.edges())||[],T=f();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const _=f();_.node.setAttribute("role","list"),_.node.setAttribute("aria-label","Sankey nodes"),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let o;if(a&&y){const e=this.graph.inEdges(t)??[],n=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),r=n.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),s=Math.max(i,r);o={chartContext:this.chartContext,isCustomTooltip:y!==dt.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:S,tooltipId:A}}const n=at(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:o,onNodeClick:x});if(n.node.setAttribute("data-node-id",t),n.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;n.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),n.node.addEventListener("mouseleave",(()=>e.reset()))}_.add(n)})),$.add(_),this.add($);const{animation:B}=this.renderOptions;if((null==B?void 0:B.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,o,n,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(Ct,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,h=document.createElementNS(Ct,"clipPath");h.setAttribute("id",l);const c=document.createElementNS(Ct,"rect");c.setAttribute("x",String(a)),c.setAttribute("y","-9999"),c.setAttribute("height","99999"),c.setAttribute("width","0"),h.appendChild(c),d.appendChild(h),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(o){null===u&&(u=o);const n=o-u,r=Math.min(n/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;c.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),h.remove())}));const p=o.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),o=g+(n>0?e/n:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:o,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,_.node,this.maxRank,B.duration)),t&&this.updateViewBox(C.x,C.y,C.width,C.height),a){const t=b(this.chartContext,A);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const N=this.renderOptions.a11y;!1!==(null==N?void 0:N.enabled)&&(this.a11yHelper=new At(this.canvas.node,this.graph,N,A,this.pathHighlighter),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:o,edgeOpacity:n,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:l,tooltipBorderColor:c,tooltipFontColor:u,tooltipId:p,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),y=f.source,E=f.target;if(!y||!E)return;m.dummy&&(f.x0=(f.x0??0)-d/2),v.dummy&&(f.x1=(f.x1??0)+d/2);const S=it(f);if(!S)return;const A=function(t,{edgeColor:e,id:o="",opacity:n=1}={}){const i=new h({d:t});return i.id(o),i.fill(e).opacity(n),i}(S,{edgeColor:this.canvas.gradient("linear",(t=>{var e,n,i;t.stop(0,(null==(e=y.data)?void 0:e.color)??""),t.stop(1,o?(null==(n=E.data)?void 0:n.color)??"":(null==(i=y.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:n});if(A.node.setAttribute("data-edge-source",t.v),A.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&A.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,o=t.v,n=t.w;A.on("mouseenter",(()=>e.highlightEdge(o,n))),A.on("mouseleave",(()=>e.reset()))}if(i&&y.data&&E.data){const t=g?g({source:y.data,target:E.data,value:f.value}):`${y.data.title} → ${E.data.title}: ${f.value}`,e=g!==dt.tooltipTemplate;A.on("mouseover",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),A.on("mousemove",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),A.on("mouseout",(()=>{b(this.chartContext,p).style.display="none"}))}e.add(A)}}class $t extends n{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...dt,...e};const{height:o,width:n}=this.options;this.graph=new kt(this.element,this.options,this.chartContext),this.setupElementDimensions(n,o),this.handleWatermark()}static setLicense(t){A.setLicense(t)}setupElementDimensions(t,e){let o=!1,n=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(n=Number(t.substring(0,t.length-1)),o=!0):n=Number(t);const i="auto"===e?n/1.6:e;this.element.style.width=`${n}${o?"%":"px"}`,this.element.style.height=`${i}${o?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(A.isLicenseValid()?k.remove(this.element):k.add(this.element))}render(t){if(!this.element)throw new Error("Element not found");if(this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new v(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}}"undefined"!=typeof window&&(window.ApexSankey=$t),t.ApexSankey=$t,t.default=$t,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSankey={})}(this,(function(t){"use strict";const e=()=>{};class o{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),o=Array.from(e);return{item:t=>o[t]||null,get length(){return o.length},[Symbol.iterator]:()=>o[Symbol.iterator](),...Object.fromEntries(o.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,o):this.context.addEventListener(t,e,o)}removeEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,o):this.context.removeEventListener(t,e,o)}injectStyles(t,e,o={}){const{force:n=!1,priority:i="normal"}=o;if(!n&&this.injectedStyles.has(e))return;if(n){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!n)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:o})=>{this.injectStyles(t,e,o)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class n{constructor(t,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new o(t,e)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,o){this.chartContext.addEventListener(t,e,o)}removeEventListener(t,e,o){this.chartContext.removeEventListener(t,e,o)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class i{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const r="http://www.w3.org/2000/svg";let s=0;class a{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:o}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==o&&this.node.setAttribute("stroke-dasharray",String(o)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof a?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new a(e):null}first(){const t=this.node.firstElementChild;return t?new a(t):null}}class d extends a{constructor(t){super(document.createElementNS(r,"g")),t&&this.attr(t)}}class l extends a{constructor(){super(document.createElementNS(r,"rect"))}}class c extends a{constructor(t){super(document.createElementNS(r,"path")),t&&this.attr(t)}}class h extends a{constructor(){super(document.createElementNS(r,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(r,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class u{constructor(t){this.gradient=t}stop(t,e){const o=document.createElementNS(r,"stop");o.setAttribute("offset",String(t)),o.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(o)}}function p(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class g{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));return this}add(t){return this.node.appendChild(t instanceof a?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(r,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const o=document.createElementNS(r,"linearGradient"),n="apx-grad-"+ ++s;return o.setAttribute("id",n),o.setAttribute("x1","0%"),o.setAttribute("y1","0%"),o.setAttribute("x2","100%"),o.setAttribute("y2","0%"),e(new u(o)),this._defs.appendChild(o),o}panZoom(t={}){return this._panZoomState=function(t,e){const o=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),n={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...o},vb:{...o}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const o=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=n.currentZoom/o;if(i<n.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=n,l=d.w*o,c=d.h*o,h=d.x+s*(d.w-l),u=d.y+a*(d.h-c);n.vb={x:h,y:u,w:l,h:c},n.currentZoom=i,p(t,n.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const o=e.clientX-a,n=e.clientY-d;if(Math.abs(o)<4&&Math.abs(n)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const o=t.getBoundingClientRect(),l=n.vb.w/o.width,c=n.vb.h/o.height,h=(e.clientX-a)*l,u=(e.clientY-d)*c;n.vb={x:n.vb.x-h,y:n.vb.y-u,w:n.vb.w,h:n.vb.h},p(t,n.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),n}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const o=this._panZoomState;if(t<o.zoomMin)return this;const n=o.currentZoom/t,{vb:i}=o,r=i.w*n,s=i.h*n,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return o.vb={x:a,y:d,w:r,h:s},o.currentZoom=t,p(this.node,o.vb),this}}function f(t,e,o,n){const i=new d;return i.attr({"data-parent":n,"data-self":o,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const m={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class v{constructor(t,e){this.element=t,t&&(this.chartContext=e||new o(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n /* Logical inset: stays on the right in LTR, mirrors to the left in RTL\n (so it never collides with RTL-flipped chrome such as the search box). */\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,o){const n=this.chartContext.createElement("div");return n.id=t,n.className="toolbar-item",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.innerHTML=e,o&&(n.setAttribute("data-tooltip",o),n.setAttribute("aria-label",o)),n.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())})),n}render({enableExport:t=!1,enableFitscreen:o=!1,enableZoom:n=!1,onExport:i=e,onFitscreen:r=e,onZoom:s=e}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),t){const t=this.createToolbarItem("export",m.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(n){const t=this.createToolbarItem("zoom-in",m["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",m["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(o){const t=this.createToolbarItem("fit-screen",m["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const y="aria-hidden",b=(t,e="apex-tooltip-container")=>{let o=t.getElementById(e);if(!o){o=t.createElement("div"),o.id=e,o.setAttribute("role","tooltip"),o.setAttribute(y,"true");t.getAppendContainer().appendChild(o),t.trackTooltip(o)}return o},x=(t,e="",o,n="",i=!1)=>{const r=t.getElementById(e);if(!r)return b(t,e),x(t,e,o,n,i);if(o&&n){const e=n.includes("tooltip-content"),s=o.match(/background-color:\s*([^;]+);?/),a=o.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=n;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${n}</div>`}const d=o+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(r.setAttribute("style",d),r.classList.add("visible"),r.setAttribute(y,"false"),i&&"undefined"!=typeof window){const e=r.offsetWidth,o=parseFloat(r.style.left),n=t.getChartBounds();if(e>0&&!Number.isNaN(o)&&n.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=n.left+t,s=((t,e,o,n,i=8)=>{if(t+e<=o-i)return t;const r=t-e;return r<n+i?Math.max(n+i,o-e-i):r})(o,e,n.right+t,i);s!==o&&(r.style.left=`${s}px`)}}}else r.removeAttribute("style"),r.classList.remove("visible"),r.setAttribute(y,"true"),r.innerHTML=""},w=({bgColor:t,borderColor:e,fontColor:o,fontFamily:n,fontSize:i,fontWeight:r,maxWidth:s,padding:a,placement:d="top",x:l,y:c})=>{const h=["position: absolute;","z-index: 1000;","pointer-events: none;"];return h.push("box-sizing: border-box;"),h.push("word-wrap: break-word;"),h.push("overflow-wrap: break-word;"),h.push(`left: ${l}px;`),h.push(`top: ${c}px;`),h.push(`data-placement: ${d};`),s&&(h.push(`width: ${s}px;`),h.push(`max-width: ${s}px;`)),e&&h.push(`border: 1px solid ${e};`),o&&h.push(`color: ${o};`),n&&h.push(`font-family: ${n};`),r&&h.push(`font-weight: ${r};`),i&&h.push(`font-size: ${i};`),t&&(h.push(`background-color: ${t};`),h.push("border-radius: 6px;"),h.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&h.push(`padding: ${a}px;`),h.join(" ")},E=globalThis.console;const A=class{static decodeLicenseData(t){try{const e=window.atob(t),o=JSON.parse(e);return o.issueDate&&o.expiryDate&&o.plan?{domains:Array.isArray(o.domains)?o.domains:void 0,expiryDate:o.expiryDate,issueDate:o.issueDate,plan:o.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,o="standard",n){const i={expiryDate:e,issueDate:t,plan:o};n&&n.length>0&&(i.domains=n);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,E.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.indexOf("-"),o=-1!==e?t.slice(e+1):"";if(!o)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=this.decodeLicenseData(o);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(n.expiryDate)<i)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,valid:!1};if(n.domains&&n.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!n.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:n,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${n.domains.join(", ")}.`,valid:!1}}return{data:n,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};A.licenseKey=null,A.validationResult=null;let S=A;const C=class{static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text \n x="50%" \n y="50%" \n dominant-baseline="middle" \n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};C.WATERMARK_ATTR="data-apexcharts-watermark",C.WATERMARK_TEXT="APEXCHARTS";let k=C;function $(t,e){let o=null;for(let n=0;n<t.length;++n)if(e(t[n])){o=n;break}return o}function M(t,e){if(0===t.length)return;let o,n=0;for(let i=t.length-1;i>=0;--i)o=(t[i].dy??0)/2,(t[i][e]??0)-o<n&&(t[i][e]=Math.min(t[i].Rmax??0,n+o)),n=(t[i][e]??0)+o;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let n=0;n<t.length;++n)o=(t[n].dy??0)/2,(t[n][e]??0)+o>i&&(t[n][e]=Math.max(o,i-o)),i=(t[n][e]??0)-o}function L(t){const e=t.edgeGap||0;return function(o){!function(t,e,o){t.nodes().forEach((n=>{const i=t.node(n),r=T(t,i.outgoing||[],"outgoing"),s=T(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),c=s.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),h=l+Math.max(0,a-1)*o,u=c+Math.max(0,d-1)*o;let p=((i.dy??0)-h)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),r.forEach(((n,r)=>{const s=t.edge(n);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=o)})),s.forEach(((n,r)=>{const s=t.edge(n);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<d-1&&(g+=o)}))}))}(o,t,e),function(t){t.nodes().forEach((e=>{const o=t.node(e),n=(o.outgoing||[]).map((e=>t.edge(e))),i=(o.incoming||[]).map((e=>t.edge(e)));n.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),_(n,"r0"),_(i,"r1")}))}(o);const n=[];return o.edges().forEach((t=>{const e=o.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,n.push(e)})),n}}function T(t,e,o){return e.slice().sort(((e,n)=>{let i,r;if("outgoing"===o){const o=t.node(e.w),s=t.node(n.w);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}else{const o=t.node(e.v),s=t.node(n.v);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==n.name){if("number"==typeof e.name&&"number"==typeof n.name)return e.name-n.name;if("string"==typeof e.name&&"string"==typeof n.name)return e.name.localeCompare(n.name)}return 0}))}function _(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),o=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(o)/2.1:0!==o?(e*e+o*o)/Math.abs(4*o):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let o=$(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===o&&(o=t.length),M(t.slice(o),e),o>0){const n=[];for(let e=o-1;e>=0;e--)n.push(t[e]);M(n,e)}}function R(t,e,o,n,i){if(0===n.length)return;const r=n.map((o=>{const n=`__${e.v}_${e.w}_${o}`;return t.setNode(n,{data:null,direction:i,dummy:!0,rank:o}),n})),s=[e.v,...r,e.w];s.forEach(((n,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:o,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function B(t,e,o){return function(t,e,o){let n,i;e.length>o.length?(n=e,i=o):(n=o,i=e);const r=i.length,s=[];n.forEach((e=>{i.forEach(((o,n)=>{(t.hasEdge(e,o)||t.hasEdge(o,e))&&s.push(n)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let c=0;return s.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(c+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),c}(t,e,o)}function N(t){const e=[];let o=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===o.length&&(o=t.nodes().slice(0,1)),function(t,e){const o=new Set,n=[];function i(e){if(!o.has(e)){o.add(e),n.push(e);for(const o of t.successors(e))i(o)}}for(const t of e)i(t);return n}(t,o).forEach((o=>{const n=t.node(o).rank;if(void 0!==n){for(;n>=e.length;)e.push([]);e[n].push(o)}})),e}function F(t,e){let o=!0;for(;o;){o=!1;for(let n=0;n<e.length;++n)for(let i=0;i<e[n].length-1;++i){const r=I(t,e,n);O(e[n],i,i+1);I(t,e,n)<r?o=!0:O(e[n],i,i+1)}}}function I(t,e,o){let n=0;return o>0&&(n+=B(t,e[o-1],e[o])),o+1<e.length&&(n+=B(t,e[o],e[o+1])),n}function O(t,e,o){const n=t[e];t[e]=t[o],t[o]=n}function W(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const o=t[e-1]-t[0],n=t[t.length-1]-t[e];return(t[e-1]*n+t[e]*o)/(o+n)}function z(t,e,o=1,n=!1){if(o>0)for(let o=1;o<e.length;++o){const i=new Map;e[o].forEach((r=>{const s=W(j(t,e,o,o-1,r,n));i.set(r,s)})),G(e[o],i)}else for(let o=e.length-2;o>=0;--o){const i=new Map;e[o].forEach((r=>{const s=W(j(t,e,o,o+1,r,n));i.set(r,s)})),G(e[o],i)}}function j(t,e,o,n,i,r=!1){const s=e[o],a=e[n],d=[];return a.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o)})),0===d.length&&r&&s.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o+.5)})),d.sort(((t,e)=>t-e)),d}function G(t,e){const o=new Map(t.map(((t,e)=>[t,e])));for(let n=1;n<t.length;++n)for(let i=n;i>0;--i){let n=i-1,r=e.get(t[n]),s=e.get(t[i]);for(;-1===(r=e.get(t[n]))&&n>0;)n--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=o.get(t[n])??r,s=o.get(t[i])??s),s>=r)break;[t[i],t[n]]=[t[n],t[i]]}}function q(t,e){let o=0;for(let n=0;n<e.length-1;++n)o+=B(t,e[n],e[n+1]);return o}function D(t){const e=[];for(const o of t){const t=[];e.push(t);for(const e of o)t.push(e)}return e}const H=(t,e)=>(t||[]).reduce(((t,o)=>t+(e?e(o):o)),0);function Y(){let t=[100,100],e=null,o=.18,n=function(t,e,o){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),P(a,i,r),function(t,e,o,n=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);i.dy=i.value*o+l*n})),t.edges().forEach((n=>{const i=t.edge(n);i.value=e(i),i.dy=i.value*o}))}(a,i,e,l);const c=Z(a,d,l,e),h=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;h[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=c[d]/H(c)*t[1],p=0===s?0:o*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?n(l[e],l[e+1],a):0)),m=H(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=H(f)?v/H(f):0;let b=s+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),h[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o];for(let t=0;t<n.length;t++){const i=n[t];for(let n=0;n<i.length;n++)e.push({rankIndex:o,bandIndex:t,nodeIndex:n,nodeId:i[n]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:o,nodeId:n})=>{var i;t===g&&e===f||(g=t,f=e,u=h[t][e],p=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(n);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[o]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),o===p.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const o=[];return e.forEach(((n,i)=>{if(i===e.length-1)return;let r=0;n.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const o=t.edge(e).dy,n=t.node(e.w).y-t.node(e.v).y,i=Math.abs(n)-o,s=o*o-i*i,a=s>=0?Math.sqrt(s):o;a>r&&(r=a)}))}))})),o.push(r)})),o}(a,d);!function(t,e,o,n){const i=n.reduce(((t,e)=>t+e),0);let r;if(i>o)r=n.map((t=>o*t/i));else{const t=o-i;r=n.map((o=>o+t/(e.length-1)))}let s=0;e.forEach(((e,o)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[o]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return s.scaleToFit=function(n,s,a=0){P(n,i,r);let d=0;a>0&&n.nodes().forEach((t=>{d=Math.max(d,function(t,e,o){if(o<=0)return 0;const n=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,n.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*o}(n,t,a))}));const l=H(Z(n,s,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==o&&(e*=1-o)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(n="function"==typeof t?t:()=>t,s):n},s.whitespace=function(t){return arguments.length?(o=t,s):o},s.scale=function(t){return arguments.length?(e=t,s):e},s}function P(t,e,o){t.nodes().forEach((n=>{const i=H(t.inEdges(n),(o=>e(t.edge(o)))),r=H(t.outEdges(n),(o=>e(t.edge(o))));let s=t.node(n);s||t.setNode(n,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=o(s)||"r")}))}function Z(t,e,o=0,n=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=H(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*o/n}));r[i]=Math.max(r[i],s)}))})),r}function K(t,e,o){return void 0!==o?`${t}${e}${o}`:`${t}${e}`}class X{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,o;if(!this._nodes.has(t))return this;this._nodes.delete(t);const n=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of n){const o=this._edges.get(t);o&&(null==(e=this._in.get(o.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(o=this._out.get(e.v))||o.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,o,n){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,n=t.name,o=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?K(s,a,n):K(s,a),l=this._edges.get(d);if(l)void 0!==o&&(l.label=o);else{const t={v:s,w:a,name:n,label:void 0!==o?o:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,o){var n;let i;return i="string"==typeof t?this._isMultigraph?K(t,e,o):K(t,e):this._isMultigraph?K(t.v,t.w,t.name):K(t.v,t.w),null==(n=this._edges.get(i))?void 0:n.label}hasEdge(t,e,o){const n=this._isMultigraph?K(t,e,o):K(t,e);return this._edges.has(n)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:o})=>({v:t,w:e,name:o})))}removeEdge(t){var e,o;const n=this._isMultigraph?K(t.v,t.w,t.name):K(t.v,t.w),i=this._edges.get(n);return i?(null==(e=this._out.get(i.v))||e.delete(n),null==(o=this._in.get(i.w))||o.delete(n),this._edges.delete(n),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const o=[],n=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=K(i.v,i.w,i.name);n.has(t)||(n.add(t),o.push(i))}return o}}function V(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function U(t,e){const o=function(t,e){const o=new Set,n=new X({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Q(t,e,o,n,i),t.nodes().forEach((e=>{o.has(e)||Q(t,e,o,n,i)})),i.forEach(((t,e)=>{n.node(t).thread=e+1<i.length?i[e+1]:i[0]})),n}(t,e);return t.edges().forEach((e=>{const n=function(t,e,o){const n=t.node(e),i=t.node(o);if((n.depth??0)<(i.depth??0)){let e=n.thread;for(;void 0!==e&&(t.node(e).depth??0)>(n.depth??0);){if(e===o)return 1;e=t.node(e).thread}}else if((i.depth??0)<(n.depth??0)){let o=i.thread;for(;void 0!==o&&(t.node(o).depth??0)>(i.depth??0);){if(o===e)return-1;o=t.node(o).thread}}return 0}(o,e.v,e.w);if(n<0){const o=t.edge(e)||{};o.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,o)}})),t}function Q(t,e,o,n,i,r=0){if(!o.has(e)){o.add(e),i.push(e),n.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{o.has(s)||n.setEdge(e,s,{delta:1}),Q(t,s,o,n,i,r+1)}))}}function J(t,e){if(0===t.nodes().length)return;const o=function(t,e){const o=new X({directed:!0});let n=!1;for(const t of e)if("min"===t.type){n=!0;break}if(!n){const o=t.sources();e=o.length>0?[{nodes:[o[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;t.nodes.forEach((t=>{i.set(t,e)})),o.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,n={nodes:[t],type:"same"};i.set(t,e),o.setNode(e,n)}})),t.edges().forEach((e=>{const n=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=o.edge(n,r)||{delta:0};n===r?(d.delta=0,o.setEdge(n,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),o.setEdge(r,n,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),o.setEdge(n,r,d))})),o}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(o),U(o,"0"),function(t){var e;const o=t.sources(),n=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(V(t))}));o.length>0;){const r=o.shift();if(void 0===r)break;n.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const o of t.inEdges(r)){const n=(null==(e=t.edge(o)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(o.v).rank??0)+n)}for(const e of t.outEdges(r))i.add(V(e));for(const e of t.nodes())o.indexOf(e)<0&&!n.has(e)&&!t.inEdges(e).some((t=>!i.has(V(t))))&&o.push(e)}}(o),function(t){function e(e){const o=t.node(e),n=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==n&&(o.rank=n)}t.edges().forEach((o=>{t.edge(o).temp&&e(o.w)}))}(o),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),o.nodes().forEach((e=>{var n;const i=o.node(e);null==(n=i.nodes)||n.forEach((e=>{t.node(e).rank=i.rank}))}))}function tt(t){const e=Y(),o=L(t);let n=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const o=new X({directed:!0,multigraph:!0});return e.forEach((t=>{o.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),o.nodes().forEach((t=>o.setNode(t,{data:{}}))),t.forEach((t=>{o.hasNode(t.id)&&(o.node(t.id).data=t,void 0!==t.direction&&(o.node(t.id).direction=t.direction))})),o.edges().forEach((t=>{o.edge(t).source=o.node(t.v),o.edge(t).target=o.node(t.w)})),o}(a,s);var c;return d.order?(J(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(J(l,d.rankSets||[]),(c=l).edges().forEach((t=>{const e=c.node(t.v),o=c.node(t.w),n=c.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==o.rank&&i+1<=o.rank){for("l"===e.direction&&r.push(i);++i<o.rank;)r.push(i);"l"===o.direction&&r.push(i),R(c,t,n,r,"r")}else if(void 0!==i&&void 0!==o.rank&&i>o.rank){for("l"!==e.direction&&r.push(i);i-- >o.rank+1;)r.push(i);"l"!==o.direction&&r.push(i),R(c,t,n,r,"l")}})),r=function(t,e=25){const o=N(t);let n=o,i=q(t,o),r=0;for(;r++<e;){z(t,o,r%2==0?1:0),F(t,o);const e=q(t,o);if(e<i&&(n=D(o),i=e),0===i)break}return n.map((t=>[t]))}(l)),n=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const o=t.node(e);o.incoming=t.inEdges(e),o.outgoing=t.outEdges(e)}))}(l),i=o(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var o;let n=t.node(e);if(!n)return;let i=(null==(o=t.inEdges(e))?void 0:o.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let r,s=i.map((t=>t.r1));for(;n.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:s[e],x:n.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),n=t.node(e=r);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(l),function(t){t.edges().forEach((e=>{const o=t.edge(e);o.points||(o.points=[]),o.points.unshift({d:o.d0,ro:o.r0,x:o.x0,y:o.y0}),o.points.push({d:o.d1,ri:o.r1,x:o.x1,y:o.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return n},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const et=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],ot=t=>0===t.dy?0:2;function nt(t){const e=Math.max(ot(t),t.dy)/2;let{x0:o}=t,{x1:n}=t,{y0:i}=t,{y1:r}=t;n<o&&([o,n]=[n,o],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,o=t.y1-t.y0;return[t.dy/2,(e*e+o*o)/Math.abs(4*o)]}(t),d=Math.max(a[0],Math.min(a[1],(n-o)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),c=Math.max(a[0],Math.min(a[1],t.r1||d));const h=n-o,u=r-i-s*(l+c),p=Math.sqrt(h*h+u*u),g=-s*Math.acos(Math.min(1,(l+c)/p)),f=Math.atan2(u,h);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=o+1*l*Math.sin(Math.abs(m)),x=n-1*c*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-c*s*(1-Math.cos(m));function A(t,o){const n=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?o+e:o-e;return 0===m&&(s=o),`A${s} ${s} ${Math.abs(m)} 0 ${n} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,c=0,b=o,x=n,w=i,E=r,v=0,y=e),`M${[o,i-e]} ${A(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${A(-1,c)}${[n,r-e]} L${[n,r+e]} ${A(1,c)}${[x-v,E+y]} L${[b-v,w+y]} ${A(-1,l)}${[o,i+e]} Z`}function it(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],o=Math.max(ot(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-o]} L${[e.x??0,(e.y??0)-o]} L${[e.x??0,(e.y??0)+o]} L${[(e.x??0)-20,(e.y??0)+o]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)+o]} L${[e.x??0,(e.y??0)+o]} Z`:null}(t);if(!t.points)return null;let o,n="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];o={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},n+=nt(o)}return n}const rt=(t,e)=>{const o=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&o.length>e?`${o.substr(0,15)}...`:o};function st(t,{fontColor:e,isRtl:o,maxRank:n,nodeWidth:i}){const{data:r}=t;if(!r)return null;const s=function(t,e,o){let n=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,n=!1),o&&(i=!i),{right:i,top:n}}(t,n,o),{x:a,y:d}=function(t,e,o){const n=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+o/2:-o/2-10,{x:(t.x??0)+i,y:(t.y??0)+n}}(t,s,i);return function(t="",{fontColor:e="#666767",pointerEvents:o="all",textAnchor:n="start",x:i,y:r}={}){const s=new h;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":o,"text-anchor":n}),s}(rt(r,s.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:s.top?"middle":s.right?"start":"end",x:a,y:d})}function at(t,e,o){var n,i;const{dy:r,x:s,y:a}=t,{fontColor:c="#212121",fontSize:h="14px",fontFamily:u,fontWeight:p,isRtl:g=!1,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v=0,onNodeClick:y,nodeTooltip:E}=o,A=new d({class:"node"}),S=function({borderColor:t="#caced0",color:e="#97cbe6",height:o=0,opacity:n=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const d=new l;return d.attr({height:o,opacity:n,rx:i,ry:i,width:r,x:s,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}({height:r,width:v,x:(s??0)-v/2,y:a});if(S.fill(null==(n=t.data)?void 0:n.color),S.stroke({color:f??(null==(i=t.data)?void 0:i.color),width:m}),S.on("click",(()=>{"function"==typeof y&&y(t)})),E){const{chartContext:e,isCustomTooltip:o,nodeValue:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=E,l=d({node:t.data,value:n});S.on("mouseover",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||c,fontFamily:o?void 0:u??"",fontSize:o?void 0:h??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mousemove",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||c,fontFamily:o?void 0:u??"",fontSize:o?void 0:h??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mouseout",(()=>{b(e,a).style.display="none"}))}if(A.add(S),t.data&&(r??0)>Number.parseInt(h,10)){const o=st(t,{fontColor:c,isRtl:g,maxRank:e,nodeWidth:v});o&&A.add(o)}return A}const dt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",locale:{direction:"ltr"},nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:o})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${o}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}},lt={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:o})=>{let n=`Sankey flow diagram: ${o} nodes, ${t} flows.`;return e&&(n+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),n},edgeAriaLabel:({source:t,target:e,value:o})=>`Flow from ${t} to ${e}: ${o} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:o})=>{let n=e;if(t&&(n+=`: receives ${t.total} units from ${t.sources.join(", ")}`),o){n+=`${t?"; ":": "}flows ${o.total} units to ${o.targets.join(", ")}`}return n},nodesGroupLabel:"Sankey nodes"};function ct(t){var e;return function(t,e){if(!e)return{...t};const o={...t};for(const t of Object.keys(e)){const n=e[t];void 0!==n&&(o[t]=n)}return o}(lt,null==(e=t.locale)?void 0:e.messages)}class ht{constructor(t,e,o){this.element=t,this.options=e,this.chartContext=o,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(r,"svg");return new g(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new i(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,o,n){this.canvas.viewbox(`${t} ${e} ${o} ${n}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class ut{constructor(t,e,o){this.svgRoot=t,this.graph=e,this.dimOpacity=o}highlightNode(t){const e=this.prefersReducedMotion(),o=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],n=new Set([t]);o.forEach((t=>{var e,o,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(o=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:o.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&n.add(a),d&&n.add(d)})),this.dimAll(e),o.forEach((t=>{const o=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);o&&this.setOpacity(o,1,e)})),n.forEach((t=>{const o=this.svgRoot.querySelector(`[data-node-id="${t}"]`);o&&this.setOpacity(o,1,e)}))}highlightEdge(t,e){var o,n,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(n=null==(o=null==a?void 0:a.source)?void 0:o.data)?void 0:n.id)??t,l=(null==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const c=this.svgRoot.querySelector(`[data-node-id="${d}"]`),h=this.svgRoot.querySelector(`[data-node-id="${l}"]`);c&&this.setOpacity(c,1,s),h&&this.setOpacity(h,1,s)}reset(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,o){t.style.transition=o?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function pt(t,e){const o=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),n=o("--apex-sankey-edge-opacity"),i=""!==n?Number(n):e.edgeOpacity,r=o("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=o("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=o("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=o("--apex-sankey-node-border-color")||e.nodeBorderColor,u=o("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=o("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=o("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=o("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:o("--apex-sankey-label-color")||e.fontColor,fontSize:o("--apex-sankey-label-font-size")||e.fontSize,fontFamily:o("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:h,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const gt="#005FCC",ft="role",mt="aria-label",vt="data-node-id",yt="data-orig-stroke",bt="data-orig-stroke-width",xt="stroke",wt="stroke-width",Et="forced-colors",At="apexsankey-desc",St="data-edge-target";const Ct="apexsankey-a11y-styles";class kt{constructor(t,e,o={},n,i,r=lt){this.svgEl=t,this.graph=e,this.options=o,this.tooltipId=n,this.pathHighlighter=i,this.messages=r,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(Ct))return;const t=document.createElement("style");t.id=Ct,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${gt};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,messages:o,options:n}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),r=e.edges(),s=function(t,e,o,n,i){var r,s,a,d;if(i)return i;let l=0,c="",h="";for(const e of o)try{const o=t.edge(e.v,e.w,e.name).value??0;if(o>l){const n=t.node(e.v),i=t.node(e.w);n.dummy||i.dummy||(l=o,c=(null==(r=n.data)?void 0:r.title)??(null==(s=n.data)?void 0:s.id)??e.v,h=(null==(a=i.data)?void 0:a.title)??(null==(d=i.data)?void 0:d.id)??e.w)}}catch{}const u=c&&h?{source:c,target:h,value:l}:void 0;return n.diagramLabel({flowCount:o.length,largestFlow:u,nodeCount:e.length})}(e,i,r,o,n.diagramLabel);t.setAttribute(ft,"img"),t.setAttribute(mt,s),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),n.description){let e=t.querySelector("desc");if(!e){const o=document.createElementNS("http://www.w3.org/2000/svg","desc");o.id=At,t.insertBefore(o,t.firstChild),e=o}e.textContent=n.description,t.setAttribute("aria-describedby",At)}const d=Array.from(t.querySelectorAll(`[${vt}]`));d.forEach((t=>{const n=t.getAttribute(vt);n&&(t.setAttribute(ft,"listitem"),t.setAttribute(mt,function(t,e,o){var n,i,r,s,a,d;const l=e.node(t),c=(null==(n=l.data)?void 0:n.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const o of e.inEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.v);n.dummy||(h.push((null==(r=n.data)?void 0:r.title)??(null==(s=n.data)?void 0:s.id)??o.v),u+=t.value??0)}catch{}const p=[];let g=0;for(const o of e.outEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.w);n.dummy||(p.push((null==(a=n.data)?void 0:a.title)??(null==(d=n.data)?void 0:d.id)??o.w),g+=t.value??0)}catch{}return o.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:p.length>0?{targets:p,total:g}:void 0})}(n,e,o)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var n,i,r,s;const a=t.getAttribute("data-edge-source"),d=t.getAttribute("data-edge-target"),u=t.getAttribute("data-edge-name")??void 0;if(a&&d)try{const p=e.edge(a,d,u),g=p.source,f=p.target;if(!g||!f)return;const m=(null==(n=g.data)?void 0:n.title)??(null==(i=g.data)?void 0:i.id)??a,v=(null==(r=f.data)?void 0:r.title)??(null==(s=f.data)?void 0:s.id)??d,y=p.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",o.edgeAriaLabel({source:m,target:v,value:y})),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),l.push(t),h.set(t,a),c.has(a)||c.set(a,[]);const b=c.get(a);b&&b.push(t)}catch{}})),this.edgePaths=l,this.nodeOutEdges=c,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(o=>{const n=o.key;if("Enter"===n||" "===n){o.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===n)o.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===n||"ArrowDown"===n){o.preventDefault();const n=t.getAttribute(vt),i=n?this.nodeOutEdges.get(n)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===n||"ArrowUp"===n){o.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const o=t.getAttribute(vt);o&&(null==(e=this.pathHighlighter)||e.highlightNode(o))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},o=()=>{const e=this.edgeSourceNode.get(t),o=e?this.nodeGroups.find((t=>t.getAttribute(vt)===e)):void 0;o&&o.focus()};t.addEventListener("keydown",(n=>{const i=n.key;if("Enter"===i||" "===i)n.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)n.preventDefault(),o();else if("ArrowDown"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i+1)%o.length].focus()}else if("ArrowUp"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i-1+o.length)%o.length].focus()}else if("ArrowRight"===i){n.preventDefault();const e=t.getAttribute(St),o=e?this.nodeGroups.find((t=>t.getAttribute(vt)===e)):void 0;o&&o.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),o=this.nodeGroups.findIndex((t=>t.getAttribute(vt)===e));if(-1!==o){const t=n.shiftKey?(o-1+this.nodeGroups.length)%this.nodeGroups.length:(o+1)%this.nodeGroups.length;n.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const o=t.getAttribute("data-edge-source"),n=t.getAttribute(St);o&&n&&(null==(e=this.pathHighlighter)||e.highlightEdge(o,n))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const o=t.relatedTarget;o&&this.edgePaths.includes(o)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(yt,e.getAttribute(xt)??""),e.setAttribute(bt,e.getAttribute(wt)??""),e.setAttribute(xt,gt),e.setAttribute(wt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const o=e.getAttribute(yt),n=e.getAttribute(bt);null!==o&&(e.setAttribute(xt,o),e.removeAttribute(yt)),null!==n&&(e.setAttribute(wt,n),e.removeAttribute(bt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(Et),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(Et):this.svgEl.classList.remove(Et)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const $t="http://www.w3.org/2000/svg";class Mt extends ht{constructor(t,e,o){super(t,e,o),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e,this.messages=ct(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var o;if("rtl"===t)return!0;if("ltr"===t)return!1;if("undefined"==typeof window||"undefined"==typeof document)return!1;if(e){const t=e.closest('[dir="rtl"], [dir="ltr"]');return t?"rtl"===t.getAttribute("dir"):"rtl"===window.getComputedStyle(e).direction}return"rtl"===((null==(o=document.documentElement)?void 0:o.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){const{edgeGap:e,nodeWidth:o,spacing:n,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=tt({edgeGap:e,nodeWidth:o,whitespace:s});a.size([r-o,i-n]);const d=t.nodes.map(((t,e)=>{const o=e%et.length;return{...t,color:t.color??et[o],colorIndex:o}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l,this.isRtl&&this.mirrorLayoutForRtl()}mirrorLayoutForRtl(){const t=this.graph.nodes();let e=1/0,o=-1/0;for(const n of t){const t=this.graph.node(n).x;void 0!==t&&(e=Math.min(e,t),o=Math.max(o,t))}if(!Number.isFinite(e))return;const n=e+o;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=n-t.x)}for(const t of this.graph.edges()){const e=this.graph.edge(t.v,t.w,t.name);if(void 0!==e.x0&&(e.x0=n-e.x0),void 0!==e.x1&&(e.x1=n-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=n-t.x)}}render({keepOldPosition:t=!1}={}){var e,o;this.renderOptions=pt(this.element,this.options);const{tooltipTheme:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===n?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===n&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltipTemplate:y,onNodeClick:x,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}=this.renderOptions,C=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new ut(this.canvas.node,this.graph,p):null;const k=((t={})=>{const e=[];for(const n in t){const i=`${o=n,o.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[n]};`;e.push(i)}var o;return e.join(" ")})({color:d,fontFamily:l,fontSize:c,fontWeight:h}),$=f(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(o=this.graph)?void 0:o.edges())||[],T=f();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const _=f();_.node.setAttribute("role","list"),_.node.setAttribute("aria-label",this.messages.nodesGroupLabel),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let o;if(a&&y){const e=this.graph.inEdges(t)??[],n=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),r=n.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),s=Math.max(i,r);o={chartContext:this.chartContext,isCustomTooltip:y!==dt.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}}const n=at(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,isRtl:this.isRtl,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:o,onNodeClick:x});if(n.node.setAttribute("data-node-id",t),n.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;n.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),n.node.addEventListener("mouseleave",(()=>e.reset()))}_.add(n)})),$.add(_),this.add($);const{animation:R}=this.renderOptions;if((null==R?void 0:R.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,o,n,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS($t,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS($t,"clipPath");c.setAttribute("id",l);const h=document.createElementNS($t,"rect");h.setAttribute("x",String(a)),h.setAttribute("y","-9999"),h.setAttribute("height","99999"),h.setAttribute("width","0"),c.appendChild(h),d.appendChild(c),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(o){null===u&&(u=o);const n=o-u,r=Math.min(n/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;h.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),c.remove())}));const p=o.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),o=g+(n>0?e/n:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:o,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,_.node,this.maxRank,R.duration)),t&&this.updateViewBox(C.x,C.y,C.width,C.height),a){const t=b(this.chartContext,S);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const B=this.renderOptions.a11y;!1!==(null==B?void 0:B.enabled)&&(this.a11yHelper=new kt(this.canvas.node,this.graph,B,S,this.pathHighlighter,this.messages),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:o,edgeOpacity:n,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:l,tooltipBorderColor:h,tooltipFontColor:u,tooltipId:p,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),y=f.source,E=f.target;if(!y||!E)return;const A=this.isRtl?-1:1;m.dummy&&(f.x0=(f.x0??0)-d/2*A),v.dummy&&(f.x1=(f.x1??0)+d/2*A);const S=it(f);if(!S)return;const C=function(t,{edgeColor:e,id:o="",opacity:n=1}={}){const i=new c({d:t});return i.id(o),i.fill(e).opacity(n),i}(S,{edgeColor:this.canvas.gradient("linear",(t=>{var e,n,i;t.stop(0,(null==(e=y.data)?void 0:e.color)??""),t.stop(1,o?(null==(n=E.data)?void 0:n.color)??"":(null==(i=y.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:n});if(C.node.setAttribute("data-edge-source",t.v),C.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&C.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,o=t.v,n=t.w;C.on("mouseenter",(()=>e.highlightEdge(o,n))),C.on("mouseleave",(()=>e.reset()))}if(i&&y.data&&E.data){const t=g?g({source:y.data,target:E.data,value:f.value}):`${y.data.title} → ${E.data.title}: ${f.value}`,e=g!==dt.tooltipTemplate;C.on("mouseover",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:h,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),C.on("mousemove",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:h,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),C.on("mouseout",(()=>{b(this.chartContext,p).style.display="none"}))}e.add(C)}}class Lt extends n{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...dt,...e};const{height:o,width:n}=this.options;this.graph=new Mt(this.element,this.options,this.chartContext),this.setupElementDimensions(n,o),this.handleWatermark()}static setLicense(t){S.setLicense(t)}setupElementDimensions(t,e){let o=!1,n=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(n=Number(t.substring(0,t.length-1)),o=!0):n=Number(t);const i="auto"===e?n/1.6:e;this.element.style.width=`${n}${o?"%":"px"}`,this.element.style.height=`${i}${o?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(S.isLicenseValid()?k.remove(this.element):k.add(this.element))}render(t){var e,o,n;if(!this.element)throw new Error("Element not found");if(o=this.element,n=(null==(e=this.options.locale)?void 0:e.direction)??"ltr",o&&("ltr"===n?o.removeAttribute("dir"):o.setAttribute("dir",n)),this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new v(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}}"undefined"!=typeof window&&(window.ApexSankey=Lt),t.ApexSankey=Lt,t.DEFAULT_SANKEY_MESSAGES=lt,t.default=Lt,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -0,0 +1,256 @@
1
+ <!doctype html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ApexSankey - Localization &amp; RTL</title>
7
+ <script src="../apexsankey.min.js"></script>
8
+ <style>
9
+ :root {
10
+ --ink: #1a1a2e;
11
+ --muted: #64748b;
12
+ --line: #e2e8f0;
13
+ --accent: #6366f1;
14
+ --accent-bg: #eef2ff;
15
+ }
16
+ * {
17
+ box-sizing: border-box;
18
+ }
19
+ body {
20
+ font-family: 'Segoe UI', Tahoma, system-ui, sans-serif;
21
+ margin: 0 auto;
22
+ padding: 24px;
23
+ max-width: 1040px;
24
+ color: var(--ink);
25
+ background: #fff;
26
+ }
27
+ h2 {
28
+ font-size: 22px;
29
+ margin: 0 0 4px;
30
+ }
31
+ .subtitle {
32
+ font-size: 13px;
33
+ color: var(--muted);
34
+ margin: 0;
35
+ line-height: 1.5;
36
+ }
37
+ .switcher {
38
+ display: flex;
39
+ flex-wrap: wrap;
40
+ gap: 8px;
41
+ margin: 18px 0;
42
+ }
43
+ .lang-btn {
44
+ display: inline-flex;
45
+ align-items: center;
46
+ gap: 8px;
47
+ border: 1px solid var(--line);
48
+ background: #fff;
49
+ color: var(--ink);
50
+ padding: 8px 14px;
51
+ border-radius: 999px;
52
+ font-size: 14px;
53
+ cursor: pointer;
54
+ transition:
55
+ border-color 0.15s,
56
+ background 0.15s,
57
+ color 0.15s;
58
+ }
59
+ .lang-btn:hover {
60
+ border-color: var(--accent);
61
+ }
62
+ .lang-btn.active {
63
+ background: var(--accent-bg);
64
+ border-color: var(--accent);
65
+ color: var(--accent);
66
+ font-weight: 600;
67
+ }
68
+ .lang-btn .dir {
69
+ font-size: 10px;
70
+ letter-spacing: 0.5px;
71
+ opacity: 0.75;
72
+ border: 1px solid currentColor;
73
+ border-radius: 4px;
74
+ padding: 0 4px;
75
+ }
76
+ .legend {
77
+ margin-top: 14px;
78
+ font-size: 12.5px;
79
+ color: var(--muted);
80
+ line-height: 1.7;
81
+ }
82
+ .legend code {
83
+ background: #f1f5f9;
84
+ padding: 1px 5px;
85
+ border-radius: 3px;
86
+ font-size: 12px;
87
+ }
88
+ .legend b {
89
+ color: var(--ink);
90
+ }
91
+ </style>
92
+ </head>
93
+ <body>
94
+ <header>
95
+ <h2>Localization &amp; RTL</h2>
96
+ <p class="subtitle">
97
+ Pick a language to re-render the flow. For Arabic / Hebrew the layout mirrors so flows read right-to-left (<code
98
+ >locale.direction: 'rtl'</code
99
+ >); for every language the screen-reader summaries come from <code>locale.messages</code>. Node titles are
100
+ translated so the change is visible.
101
+ </p>
102
+ </header>
103
+
104
+ <div class="switcher" id="switcher"></div>
105
+
106
+ <div id="host"></div>
107
+
108
+ <p class="legend">
109
+ Localized here: the <b>diagram aria-summary</b>, <b>per-flow edge aria-labels</b>, and the
110
+ <b>nodes-group label</b> (open DevTools to inspect the SVG aria text), plus <b>RTL layout mirroring</b> for Arabic
111
+ / Hebrew. Defaults (no <code>locale</code>) stay English, left-to-right.
112
+ </p>
113
+
114
+ <script>
115
+ // titles: budget-flow node names, translated so the re-render is visually obvious.
116
+ // messages: the screen-reader strings ApexSankey exposes via locale.messages.
117
+ const LOCALES = {
118
+ en: {
119
+ label: 'English',
120
+ dir: 'ltr',
121
+ titles: {
122
+ income: 'Income',
123
+ housing: 'Housing',
124
+ food: 'Food',
125
+ savings: 'Savings',
126
+ rent: 'Rent',
127
+ groceries: 'Groceries',
128
+ investments: 'Investments',
129
+ },
130
+ messages: {
131
+ nodesGroupLabel: 'Sankey nodes',
132
+ diagramLabel: ({nodeCount, flowCount}) => `Sankey flow diagram: ${nodeCount} nodes, ${flowCount} flows`,
133
+ edgeAriaLabel: ({source, target, value}) => `Flow from ${source} to ${target}: ${value} units`,
134
+ },
135
+ },
136
+ fr: {
137
+ label: 'Français',
138
+ dir: 'ltr',
139
+ titles: {
140
+ income: 'Revenu',
141
+ housing: 'Logement',
142
+ food: 'Alimentation',
143
+ savings: 'Épargne',
144
+ rent: 'Loyer',
145
+ groceries: 'Courses',
146
+ investments: 'Investissements',
147
+ },
148
+ messages: {
149
+ nodesGroupLabel: 'Nœuds du diagramme',
150
+ diagramLabel: ({nodeCount, flowCount}) => `Diagramme de flux : ${nodeCount} nœuds, ${flowCount} flux`,
151
+ edgeAriaLabel: ({source, target, value}) => `Flux de ${source} vers ${target} : ${value} unités`,
152
+ },
153
+ },
154
+ ar: {
155
+ label: 'العربية',
156
+ dir: 'rtl',
157
+ titles: {
158
+ income: 'الدخل',
159
+ housing: 'السكن',
160
+ food: 'الطعام',
161
+ savings: 'المدخرات',
162
+ rent: 'الإيجار',
163
+ groceries: 'البقالة',
164
+ investments: 'الاستثمارات',
165
+ },
166
+ messages: {
167
+ nodesGroupLabel: 'عقد المخطط',
168
+ diagramLabel: ({nodeCount, flowCount}) => `مخطط التدفق: ${nodeCount} عقدة، ${flowCount} تدفق`,
169
+ edgeAriaLabel: ({source, target, value}) => `تدفق من ${source} إلى ${target}: ${value} وحدة`,
170
+ },
171
+ },
172
+ he: {
173
+ label: 'עברית',
174
+ dir: 'rtl',
175
+ titles: {
176
+ income: 'הכנסה',
177
+ housing: 'דיור',
178
+ food: 'מזון',
179
+ savings: 'חיסכון',
180
+ rent: 'שכר דירה',
181
+ groceries: 'מצרכים',
182
+ investments: 'השקעות',
183
+ },
184
+ messages: {
185
+ nodesGroupLabel: 'צמתים בתרשים',
186
+ diagramLabel: ({nodeCount, flowCount}) => `תרשים זרימה: ${nodeCount} צמתים, ${flowCount} זרימות`,
187
+ edgeAriaLabel: ({source, target, value}) => `זרימה מ-${source} ל-${target}: ${value} יחידות`,
188
+ },
189
+ },
190
+ };
191
+
192
+ const ORDER = ['en', 'fr', 'ar', 'he'];
193
+
194
+ function buildData(t) {
195
+ return {
196
+ nodes: [
197
+ {id: 'income', title: t.income, color: '#6366F1'},
198
+ {id: 'housing', title: t.housing, color: '#F43F5E'},
199
+ {id: 'food', title: t.food, color: '#F97316'},
200
+ {id: 'savings', title: t.savings, color: '#10B981'},
201
+ {id: 'rent', title: t.rent, color: '#FB7185'},
202
+ {id: 'groceries', title: t.groceries, color: '#FDBA74'},
203
+ {id: 'investments', title: t.investments, color: '#6EE7B7'},
204
+ ],
205
+ edges: [
206
+ {source: 'income', target: 'housing', value: 1800, type: 'flow'},
207
+ {source: 'income', target: 'food', value: 900, type: 'flow'},
208
+ {source: 'income', target: 'savings', value: 1200, type: 'flow'},
209
+ {source: 'housing', target: 'rent', value: 1500, type: 'flow'},
210
+ {source: 'food', target: 'groceries', value: 750, type: 'flow'},
211
+ {source: 'savings', target: 'investments', value: 1000, type: 'flow'},
212
+ ],
213
+ };
214
+ }
215
+
216
+ const host = document.getElementById('host');
217
+ const switcher = document.getElementById('switcher');
218
+
219
+ function mount(key) {
220
+ const cfg = LOCALES[key];
221
+
222
+ document.documentElement.setAttribute('lang', key);
223
+ document.documentElement.setAttribute('dir', cfg.dir);
224
+ [...switcher.children].forEach((b) => b.classList.toggle('active', b.dataset.key === key));
225
+
226
+ // Fresh mount node guarantees the previous SVG / listeners are gone.
227
+ host.innerHTML = '';
228
+ const el = document.createElement('div');
229
+ host.appendChild(el);
230
+
231
+ const s = new ApexSankey(el, {
232
+ nodeWidth: 18,
233
+ fontFamily: 'Segoe UI, Tahoma, sans-serif',
234
+ fontSize: '13px',
235
+ width: '100%',
236
+ height: 460,
237
+ canvasStyle: 'border: 1px solid #e2e8f0; border-radius: 8px; box-sizing: border-box;',
238
+ locale: {direction: cfg.dir, messages: cfg.messages},
239
+ });
240
+ s.render(buildData(cfg.titles));
241
+ }
242
+
243
+ ORDER.forEach((key) => {
244
+ const cfg = LOCALES[key];
245
+ const btn = document.createElement('button');
246
+ btn.className = 'lang-btn';
247
+ btn.dataset.key = key;
248
+ btn.innerHTML = `<span>${cfg.label}</span><span class="dir">${cfg.dir.toUpperCase()}</span>`;
249
+ btn.addEventListener('click', () => mount(key));
250
+ switcher.appendChild(btn);
251
+ });
252
+
253
+ mount('en');
254
+ </script>
255
+ </body>
256
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apexsankey",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "dependencies": {},
5
5
  "repository": {
6
6
  "type": "git",