apexsankey 1.9.0 → 1.10.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.
|
@@ -46,10 +46,15 @@ jobs:
|
|
|
46
46
|
fi
|
|
47
47
|
echo "✅ Version $PKG_VERSION confirmed"
|
|
48
48
|
|
|
49
|
+
# Must stay recent enough for the npm the next step installs. npm@12
|
|
50
|
+
# requires node ^22.22.2 || ^24.15.0 || >=26.0.0, so node 20 now fails at
|
|
51
|
+
# `npm install -g npm@latest` before anything is published.
|
|
49
52
|
- uses: actions/setup-node@v4
|
|
50
53
|
with:
|
|
51
|
-
node-version: "
|
|
54
|
+
node-version: "24"
|
|
52
55
|
|
|
56
|
+
# npm@latest, not the bundled npm: trusted publishing (OIDC, no token)
|
|
57
|
+
# needs npm >= 11.5.1.
|
|
53
58
|
- run: npm install -g npm@latest
|
|
54
59
|
- run: npm install
|
|
55
60
|
|
package/apexsankey.es.min.js
CHANGED
|
@@ -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 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};
|
|
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}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.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,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:o=!1,priority:i="normal"}=n;if(!o&&this.injectedStyles.has(e))return;if(o){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!o)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:n})=>{this.injectStyles(t,e,n)}))}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,n){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new e(t,n)}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,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class o{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 n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}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,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));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:n}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==n&&this.node.setAttribute("stroke-dasharray",String(n)),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 n=document.createElementNS(i,"stop");n.setAttribute("offset",String(t)),n.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(n)}}function u(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,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));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 n=document.createElementNS(i,"linearGradient"),o="apx-grad-"+ ++r;return n.setAttribute("id",o),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%"),e(new h(n)),this._defs.appendChild(n),n}panZoom(t={}){return this._panZoomState=function(t,e){const n=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),o={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...n},vb:{...n}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=o.currentZoom/n;if(i<o.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=o,l=d.w*n,c=d.h*n,h=d.x+s*(d.w-l),g=d.y+a*(d.h-c);o.vb={x:h,y:g,w:l,h:c},o.currentZoom=i,u(t,o.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 n=e.clientX-a,o=e.clientY-d;if(Math.abs(n)<4&&Math.abs(o)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const n=t.getBoundingClientRect(),l=o.vb.w/n.width,c=o.vb.h/n.height,h=(e.clientX-a)*l,g=(e.clientY-d)*c;o.vb={x:o.vb.x-h,y:o.vb.y-g,w:o.vb.w,h:o.vb.h},u(t,o.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),o}(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 n=this._panZoomState;if(t<n.zoomMin)return this;const o=n.currentZoom/t,{vb:i}=n,r=i.w*o,s=i.h*o,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return n.vb={x:a,y:d,w:r,h:s},n.currentZoom=t,u(this.node,n.vb),this}}function p(t,e,n,o){const i=new a;return i.attr({"data-parent":o,"data-self":n,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,n){this.element=t,t&&(this.chartContext=n||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,n){const o=this.chartContext.createElement("div");return o.id=t,o.className="toolbar-item",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.innerHTML=e,n&&(o.setAttribute("data-tooltip",n),o.setAttribute("aria-label",n)),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.click())})),o}render({enableExport:e=!1,enableFitscreen:n=!1,enableZoom:o=!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(o){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(n){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 n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(v,"true");t.getAppendContainer().appendChild(n),t.trackTooltip(n)}return n},b=(t,e="",n,o="",i=!1)=>{const r=t.getElementById(e);if(!r)return y(t,e),b(t,e,n,o,i);if(n&&o){const e=o.includes("tooltip-content"),s=n.match(/background-color:\s*([^;]+);?/),a=n.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=o;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${o}</div>`}const d=n+"; 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,n=parseFloat(r.style.left),o=t.getChartBounds();if(e>0&&!Number.isNaN(n)&&o.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=o.left+t,s=((t,e,n,o,i=8)=>{if(t+e<=n-i)return t;const r=t-e;return r<o+i?Math.max(o+i,n-e-i):r})(n,e,o.right+t,i);s!==n&&(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:n,fontFamily:o,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};`),n&&h.push(`color: ${n};`),o&&h.push(`font-family: ${o};`),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;function E(t){w.error(t)}const A="APEX-",S=new Date("2027-07-31T00:00:00Z"),C=class{static getLicenseStatus(){return this.licenseKey?this.validationResult??{expired:!1,signatureVerified:!1,valid:!1}:{expired:!1,signatureVerified:!1,valid:!1}}static isLicenseValid(){return this.getLicenseStatus().valid}static onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}static setLicense(t){this.licenseKey=t;const e=this.parseKey(t),n=this.validateStructure(t,e);this.publish(n),n.valid?(null==e?void 0:e.signature)&&this.verifySignature(t,e,n):E(`[Apex] ${n.message}`)}static base64ToBytes(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(4*Math.ceil(e.length/4),"="),o=globalThis.atob;if("function"!=typeof o)throw new Error("no base64 decoder available");const i=o(n),r=new Uint8Array(i.length);for(let t=0;t<i.length;t++)r[t]=i.charCodeAt(t);return r}static canonicalPayload(t){const e=t.domains&&t.domains.length>0?t.domains.join(","):"";return`v1|${t.issueDate}|${t.expiryDate}|${t.plan}|${e}`}static notify(t){for(const e of this.listeners)try{e(t)}catch{}}static parseKey(t){if("string"!=typeof t||!t.startsWith(A))return null;const e=t.slice(5);if(!e)return null;try{const t=(new TextDecoder).decode(this.base64ToBytes(e)),n=JSON.parse(t);return n.issueDate&&n.expiryDate&&n.plan?{data:{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0},signature:"string"==typeof n.sig&&n.sig?n.sig:null}:null}catch{return null}}static publish(t){this.validationResult=t,this.notify(t)}static validateStructure(t,e){const n=t=>({expired:!1,message:t,signatureVerified:!1,valid:!1});if("string"!=typeof t||!t.startsWith(A))return n('Invalid license key format. License key must start with "APEX-".');if(!e)return n("Invalid license key. Unable to decode license data.");const{data:o,signature:i}=e;if(!i&&new Date>=S)return n("This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.");if(new Date(o.expiryDate)<new Date)return{data:o,expired:!0,message:`License expired on ${o.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(o.domains&&o.domains.length>0){const t="undefined"==typeof location?"":location.hostname;if(!o.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:o,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${o.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}return{data:o,expired:!1,signatureVerified:!1,valid:!0}}static async verifySignature(t,e,n){var o;const i=null==(o=globalThis.crypto)?void 0:o.subtle;if(!i||0===this.publicKeysSpki.length)return void(this.warnedUnverifiable||(this.warnedUnverifiable=!0,function(t){w.warn(t)}(i?"[Apex] No license signing key is configured in this build, so license signatures cannot be verified.":"[Apex] Web Crypto is unavailable (a secure context is required), so the license signature cannot be verified.")));const r=(new TextEncoder).encode(this.canonicalPayload(e.data));let s=!1;for(const t of this.publicKeysSpki){try{const n=await i.importKey("spki",this.base64ToBytes(t),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);s=await i.verify({hash:"SHA-256",name:"ECDSA"},n,this.base64ToBytes(e.signature),r)}catch{s=!1}if(s)break}if(this.licenseKey!==t)return;if(s)return void this.publish({...n,signatureVerified:!0});const a="Invalid license key. The license signature does not verify.";this.publish({expired:!1,message:a,signatureVerified:!0,valid:!1}),E(`[Apex] ${a}`)}};C.licenseKey=null,C.listeners=new Set,C.publicKeysSpki=["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="],C.validationResult=null,C.warnedUnverifiable=!1;let k=C;const $=class{static add(t){this.track(t),this.paint(t)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){this.track(t),this.erase(t)}static untrack(t){this.managed.delete(t)}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 erase(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}static paint(t){this.erase(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 reconcile(){const t=k.isLicenseValid();for(const e of this.managed)e.isConnected?t?this.erase(e):this.paint(e):this.managed.delete(e)}static track(t){this.managed.add(t),this.subscribed||(this.subscribed=!0,k.onChange((()=>{this.reconcile()})))}};$.WATERMARK_ATTR="data-apexcharts-watermark",$.WATERMARK_TEXT="APEXCHARTS",$.managed=new Set,$.subscribed=!1;let M=$;function L(t,e){let n=null;for(let o=0;o<t.length;++o)if(e(t[o])){n=o;break}return n}function T(t,e){if(0===t.length)return;let n,o=0;for(let i=t.length-1;i>=0;--i)n=(t[i].dy??0)/2,(t[i][e]??0)-n<o&&(t[i][e]=Math.min(t[i].Rmax??0,o+n)),o=(t[i][e]??0)+n;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let o=0;o<t.length;++o)n=(t[o].dy??0)/2,(t[o][e]??0)+n>i&&(t[o][e]=Math.max(n,i-n)),i=(t[o][e]??0)-n}function B(t){const e=t.edgeGap||0;return function(n){!function(t,e,n){t.nodes().forEach((o=>{const i=t.node(o),r=_(t,i.outgoing||[],"outgoing"),s=_(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),c=s.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),h=l+Math.max(0,a-1)*n,u=c+Math.max(0,d-1)*n;let g=((i.dy??0)-h)/2,p=((i.dy??0)-u)/2;g=Math.max(0,g),p=Math.max(0,p),r.forEach(((o,r)=>{const s=t.edge(o);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+g+(s.dy??0)/2,s.d0=i.direction||"r",g+=s.dy??0,r<a-1&&(g+=n)})),s.forEach(((o,r)=>{const s=t.edge(o);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+p+(s.dy??0)/2,s.d1=i.direction||"r",p+=s.dy??0,r<d-1&&(p+=n)}))}))}(n,t,e),function(t){t.nodes().forEach((e=>{const n=t.node(e),o=(n.outgoing||[]).map((e=>t.edge(e))),i=(n.incoming||[]).map((e=>t.edge(e)));o.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),R(o,"r0"),R(i,"r1")}))}(n);const o=[];return n.edges().forEach((t=>{const e=n.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,o.push(e)})),o}}function _(t,e,n){return e.slice().sort(((e,o)=>{let i,r;if("outgoing"===n){const n=t.node(e.w),s=t.node(o.w);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}else{const n=t.node(e.v),s=t.node(o.v);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==o.name){if("number"==typeof e.name&&"number"==typeof o.name)return e.name-o.name;if("string"==typeof e.name&&"string"==typeof o.name)return e.name.localeCompare(o.name)}return 0}))}function R(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),n=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(n)/2.1:0!==n?(e*e+n*n)/Math.abs(4*n):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 n=L(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===n&&(n=t.length),T(t.slice(n),e),n>0){const o=[];for(let e=n-1;e>=0;e--)o.push(t[e]);T(o,e)}}function N(t,e,n,o,i){if(0===o.length)return;const r=o.map((n=>{const o=`__${e.v}_${e.w}_${n}`;return t.setNode(o,{data:null,direction:i,dummy:!0,rank:n}),o})),s=[e.v,...r,e.w];s.forEach(((o,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:n,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function I(t,e,n){return function(t,e,n){let o,i;e.length>n.length?(o=e,i=n):(o=n,i=e);const r=i.length,s=[];o.forEach((e=>{i.forEach(((n,o)=>{(t.hasEdge(e,n)||t.hasEdge(n,e))&&s.push(o)}))}));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,n)}function F(t){const e=[];let n=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===n.length&&(n=t.nodes().slice(0,1)),function(t,e){const n=new Set,o=[];function i(e){if(!n.has(e)){n.add(e),o.push(e);for(const n of t.successors(e))i(n)}}for(const t of e)i(t);return o}(t,n).forEach((n=>{const o=t.node(n).rank;if(void 0!==o){for(;o>=e.length;)e.push([]);e[o].push(n)}})),e}function W(t,e){let n=!0;for(;n;){n=!1;for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length-1;++i){const r=z(t,e,o);O(e[o],i,i+1);z(t,e,o)<r?n=!0:O(e[o],i,i+1)}}}function z(t,e,n){let o=0;return n>0&&(o+=I(t,e[n-1],e[n])),n+1<e.length&&(o+=I(t,e[n],e[n+1])),o}function O(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function D(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 n=t[e-1]-t[0],o=t[t.length-1]-t[e];return(t[e-1]*o+t[e]*n)/(n+o)}function j(t,e,n=1,o=!1){if(n>0)for(let n=1;n<e.length;++n){const i=new Map;e[n].forEach((r=>{const s=D(q(t,e,n,n-1,r,o));i.set(r,s)})),H(e[n],i)}else for(let n=e.length-2;n>=0;--n){const i=new Map;e[n].forEach((r=>{const s=D(q(t,e,n,n+1,r,o));i.set(r,s)})),H(e[n],i)}}function q(t,e,n,o,i,r=!1){const s=e[n],a=e[o],d=[];return a.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n)})),0===d.length&&r&&s.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n+.5)})),d.sort(((t,e)=>t-e)),d}function H(t,e){const n=new Map(t.map(((t,e)=>[t,e])));for(let o=1;o<t.length;++o)for(let i=o;i>0;--i){let o=i-1,r=e.get(t[o]),s=e.get(t[i]);for(;-1===(r=e.get(t[o]))&&o>0;)o--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=n.get(t[o])??r,s=n.get(t[i])??s),s>=r)break;[t[i],t[o]]=[t[o],t[i]]}}function G(t,e){let n=0;for(let o=0;o<e.length-1;++o)n+=I(t,e[o],e[o+1]);return n}function V(t){const e=[];for(const n of t){const t=[];e.push(t);for(const e of n)t.push(e)}return e}const Y=(t,e)=>(t||[]).reduce(((t,n)=>t+(e?e(n):n)),0);function Z(){let t=[100,100],e=null,n=.18,o=function(t,e,n){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),K(a,i,r),function(t,e,n,o=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*n+l*o})),t.edges().forEach((o=>{const i=t.edge(o);i.value=e(i),i.dy=i.value*n}))}(a,i,e,l);const c=P(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]/Y(c)*t[1],g=0===s?0:n*u/5,p=u-2*g,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?o(l[e],l[e+1],a):0)),m=Y(l,(t=>a.node(t).dy)),v=Math.max(0,p-m),y=Y(f)?v/Y(f):0;let b=s+g;1===l.length&&(b+=(p-a.node(l[0]).dy)/2),h[e][d]={margin:g,height:p,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,g,p=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n];for(let t=0;t<o.length;t++){const i=o[t];for(let o=0;o<i.length;o++)e.push({rankIndex:n,bandIndex:t,nodeIndex:o,nodeId:i[o]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:n,nodeId:o})=>{var i;t===p&&e===f||(p=t,f=e,u=h[t][e],g=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(o);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[n]*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)),n===g.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const n=[];return e.forEach(((o,i)=>{if(i===e.length-1)return;let r=0;o.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const n=t.edge(e).dy,o=t.node(e.w).y-t.node(e.v).y,i=Math.abs(o)-n,s=n*n-i*i,a=s>=0?Math.sqrt(s):n;a>r&&(r=a)}))}))})),n.push(r)})),n}(a,d);!function(t,e,n,o){const i=o.reduce(((t,e)=>t+e),0);let r;if(i>n)r=o.map((t=>n*t/i));else{const t=n-i;r=o.map((n=>n+t/(e.length-1)))}let s=0;e.forEach(((e,n)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[n]}))}(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(o,s,a=0){K(o,i,r);let d=0;a>0&&o.nodes().forEach((t=>{d=Math.max(d,function(t,e,n){if(n<=0)return 0;const o=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,o.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*n}(o,t,a))}));const l=Y(P(o,s,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==n&&(e*=1-n)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(o="function"==typeof t?t:()=>t,s):o},s.whitespace=function(t){return arguments.length?(n=t,s):n},s.scale=function(t){return arguments.length?(e=t,s):e},s}function K(t,e,n){t.nodes().forEach((o=>{const i=Y(t.inEdges(o),(n=>e(t.edge(n)))),r=Y(t.outEdges(o),(n=>e(t.edge(n))));let s=t.node(o);s||t.setNode(o,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=n(s)||"r")}))}function P(t,e,n=0,o=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=Y(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*n/o}));r[i]=Math.max(r[i],s)}))})),r}function U(t,e,n){return void 0!==n?`${t}${e}${n}`:`${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,n;if(!this._nodes.has(t))return this;this._nodes.delete(t);const o=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of o){const n=this._edges.get(t);n&&(null==(e=this._in.get(n.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(n=this._out.get(e.v))||n.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,n,o){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,o=t.name,n=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?U(s,a,o):U(s,a),l=this._edges.get(d);if(l)void 0!==n&&(l.label=n);else{const t={v:s,w:a,name:o,label:void 0!==n?n:{}};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,n){var o;let i;return i="string"==typeof t?this._isMultigraph?U(t,e,n):U(t,e):this._isMultigraph?U(t.v,t.w,t.name):U(t.v,t.w),null==(o=this._edges.get(i))?void 0:o.label}hasEdge(t,e,n){const o=this._isMultigraph?U(t,e,n):U(t,e);return this._edges.has(o)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:n})=>({v:t,w:e,name:n})))}removeEdge(t){var e,n;const o=this._isMultigraph?U(t.v,t.w,t.name):U(t.v,t.w),i=this._edges.get(o);return i?(null==(e=this._out.get(i.v))||e.delete(o),null==(n=this._in.get(i.w))||n.delete(o),this._edges.delete(o),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 n=[],o=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=U(i.v,i.w,i.name);o.has(t)||(o.add(t),n.push(i))}return n}}function Q(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function J(t,e){const n=function(t,e){const n=new Set,o=new X({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return tt(t,e,n,o,i),t.nodes().forEach((e=>{n.has(e)||tt(t,e,n,o,i)})),i.forEach(((t,e)=>{o.node(t).thread=e+1<i.length?i[e+1]:i[0]})),o}(t,e);return t.edges().forEach((e=>{const o=function(t,e,n){const o=t.node(e),i=t.node(n);if((o.depth??0)<(i.depth??0)){let e=o.thread;for(;void 0!==e&&(t.node(e).depth??0)>(o.depth??0);){if(e===n)return 1;e=t.node(e).thread}}else if((i.depth??0)<(o.depth??0)){let n=i.thread;for(;void 0!==n&&(t.node(n).depth??0)>(i.depth??0);){if(n===e)return-1;n=t.node(n).thread}}return 0}(n,e.v,e.w);if(o<0){const n=t.edge(e)||{};n.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,n)}})),t}function tt(t,e,n,o,i,r=0){if(!n.has(e)){n.add(e),i.push(e),o.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{n.has(s)||o.setEdge(e,s,{delta:1}),tt(t,s,n,o,i,r+1)}))}}function et(t,e){if(0===t.nodes().length)return;const n=function(t,e){const n=new X({directed:!0});let o=!1;for(const t of e)if("min"===t.type){o=!0;break}if(!o){const n=t.sources();e=n.length>0?[{nodes:[n[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)})),n.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,o={nodes:[t],type:"same"};i.set(t,e),n.setNode(e,o)}})),t.edges().forEach((e=>{const o=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=n.edge(o,r)||{delta:0};o===r?(d.delta=0,n.setEdge(o,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),n.setEdge(r,o,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),n.setEdge(o,r,d))})),n}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(n),J(n,"0"),function(t){var e;const n=t.sources(),o=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(Q(t))}));n.length>0;){const r=n.shift();if(void 0===r)break;o.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const n of t.inEdges(r)){const o=(null==(e=t.edge(n)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(n.v).rank??0)+o)}for(const e of t.outEdges(r))i.add(Q(e));for(const e of t.nodes())n.indexOf(e)<0&&!o.has(e)&&!t.inEdges(e).some((t=>!i.has(Q(t))))&&n.push(e)}}(n),function(t){function e(e){const n=t.node(e),o=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==o&&(n.rank=o)}t.edges().forEach((n=>{t.edge(n).temp&&e(n.w)}))}(n),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),n.nodes().forEach((e=>{var o;const i=n.node(e);null==(o=i.nodes)||o.forEach((e=>{t.node(e).rank=i.rank}))}))}function nt(t){const e=Z(),n=B(t);let o=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const n=new X({directed:!0,multigraph:!0});return e.forEach((t=>{n.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),n.nodes().forEach((t=>n.setNode(t,{data:{}}))),t.forEach((t=>{n.hasNode(t.id)&&(n.node(t.id).data=t,void 0!==t.direction&&(n.node(t.id).direction=t.direction))})),n.edges().forEach((t=>{n.edge(t).source=n.node(t.v),n.edge(t).target=n.node(t.w)})),n}(a,s);var c;return d.order?(et(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)))))))):(et(l,d.rankSets||[]),(c=l).edges().forEach((t=>{const e=c.node(t.v),n=c.node(t.w),o=c.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==n.rank&&i+1<=n.rank){for("l"===e.direction&&r.push(i);++i<n.rank;)r.push(i);"l"===n.direction&&r.push(i),N(c,t,o,r,"r")}else if(void 0!==i&&void 0!==n.rank&&i>n.rank){for("l"!==e.direction&&r.push(i);i-- >n.rank+1;)r.push(i);"l"!==n.direction&&r.push(i),N(c,t,o,r,"l")}})),r=function(t,e=25){const n=F(t);let o=n,i=G(t,n),r=0;for(;r++<e;){j(t,n,r%2==0?1:0),W(t,n);const e=G(t,n);if(e<i&&(o=V(n),i=e),0===i)break}return o.map((t=>[t]))}(l)),o=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const n=t.node(e);n.incoming=t.inEdges(e),n.outgoing=t.outEdges(e)}))}(l),i=n(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var n;let o=t.node(e);if(!o)return;let i=(null==(n=t.inEdges(e))?void 0:n.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(;o.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:o.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),o=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 n=t.edge(e);n.points||(n.points=[]),n.points.unshift({d:n.d0,ro:n.r0,x:n.x0,y:n.y0}),n.points.push({d:n.d1,ri:n.r1,x:n.x1,y:n.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return o},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 ot=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],it=t=>0===t.dy?0:2;function rt(t){const e=Math.max(it(t),t.dy)/2;let{x0:n}=t,{x1:o}=t,{y0:i}=t,{y1:r}=t;o<n&&([n,o]=[o,n],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,n=t.y1-t.y0;return[t.dy/2,(e*e+n*n)/Math.abs(4*n)]}(t),d=Math.max(a[0],Math.min(a[1],(o-n)/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=o-n,u=r-i-s*(l+c),g=Math.sqrt(h*h+u*u),p=-s*Math.acos(Math.min(1,(l+c)/g)),f=Math.atan2(u,h);let m=Math.PI/2+s*(f+p),v=e*s*Math.sin(m),y=e*Math.cos(m),b=n+1*l*Math.sin(Math.abs(m)),x=o-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,n){const o=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?n+e:n-e;return 0===m&&(s=n),`A${s} ${s} ${Math.abs(m)} 0 ${o} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,c=0,b=n,x=o,w=i,E=r,v=0,y=e),`M${[n,i-e]} ${A(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${A(-1,c)}${[o,r-e]} L${[o,r+e]} ${A(1,c)}${[x-v,E+y]} L${[b-v,w+y]} ${A(-1,l)}${[n,i+e]} Z`}function st(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],n=Math.max(it(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-n]} L${[e.x??0,(e.y??0)-n]} L${[e.x??0,(e.y??0)+n]} L${[(e.x??0)-20,(e.y??0)+n]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)+n]} L${[e.x??0,(e.y??0)+n]} Z`:null}(t);if(!t.points)return null;let n,o="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];n={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},o+=rt(n)}return o}const at=(t,e)=>{const n=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&n.length>e?`${n.substr(0,15)}...`:n};function dt(t,{fontColor:e,isRtl:n,maxRank:o,nodeWidth:i}){const{data:r}=t;if(!r)return null;const s=function(t,e,n){let o=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,o=!1),n&&(i=!i),{right:i,top:o}}(t,o,n),{x:a,y:d}=function(t,e,n){const o=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+n/2:-n/2-10,{x:(t.x??0)+i,y:(t.y??0)+o}}(t,s,i);return function(t="",{fontColor:e="#666767",pointerEvents:n="all",textAnchor:o="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":n,"text-anchor":o}),s}(at(r,s.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:s.top?"middle":s.right?"start":"end",x:a,y:d})}function lt(t,e,n){var o,i;const{dy:r,x:s,y:l}=t,{fontColor:c="#212121",fontSize:h="14px",fontFamily:u,fontWeight:g,isRtl:p=!1,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v=0,onNodeClick:w,nodeTooltip:E}=n,A=new a({class:"node"}),S=function({borderColor:t="#caced0",color:e="#97cbe6",height:n=0,opacity:o=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const l=new d;return l.attr({height:n,opacity:o,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(S.fill(null==(o=t.data)?void 0:o.color),S.stroke({color:f??(null==(i=t.data)?void 0:i.color),width:m}),S.on("click",(()=>{"function"==typeof w&&w(t)})),E){const{chartContext:e,isCustomTooltip:n,nodeValue:o,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=E,l=d({node:t.data,value:o});S.on("mouseover",(t=>{const{pageX:o,pageY:d}=t,p=x({bgColor:n?void 0:i,borderColor:n?void 0:r,fontColor:n?void 0:s||c,fontFamily:n?void 0:u??"",fontSize:n?void 0:h??"14px",fontWeight:n?void 0:g??"400",x:o,y:d});b(e,a,p,l,!0)})),S.on("mousemove",(t=>{const{pageX:o,pageY:d}=t,p=x({bgColor:n?void 0:i,borderColor:n?void 0:r,fontColor:n?void 0:s||c,fontFamily:n?void 0:u??"",fontSize:n?void 0:h??"14px",fontWeight:n?void 0:g??"400",x:o,y:d});b(e,a,p,l,!0)})),S.on("mouseout",(()=>{y(e,a).style.display="none"}))}if(A.add(S),t.data&&(r??0)>Number.parseInt(h,10)){const n=dt(t,{fontColor:c,isRtl:p,maxRank:e,nodeWidth:v});n&&A.add(n)}return A}const ct={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:n})=>`\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;'>${n}</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}},ht={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:n})=>{let o=`Sankey flow diagram: ${n} nodes, ${t} flows.`;return e&&(o+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),o},edgeAriaLabel:({source:t,target:e,value:n})=>`Flow from ${t} to ${e}: ${n} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:n})=>{let o=e;if(t&&(o+=`: receives ${t.total} units from ${t.sources.join(", ")}`),n){o+=`${t?"; ":": "}flows ${n.total} units to ${n.targets.join(", ")}`}return o},nodesGroupLabel:"Sankey nodes"};function ut(t){var e;return function(t,e){if(!e)return{...t};const n={...t};for(const t of Object.keys(e)){const o=e[t];void 0!==o&&(n[t]=o)}return n}(ht,null==(e=t.locale)?void 0:e.messages)}class gt{constructor(t,e,n){this.element=t,this.options=e,this.chartContext=n,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(i,"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 o(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,n,o){this.canvas.viewbox(`${t} ${e} ${n} ${o}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class pt{constructor(t,e,n){this.svgRoot=t,this.graph=e,this.dimOpacity=n}highlightNode(t){const e=this.prefersReducedMotion(),n=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],o=new Set([t]);n.forEach((t=>{var e,n,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(n=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:n.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&o.add(a),d&&o.add(d)})),this.dimAll(e),n.forEach((t=>{const n=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);n&&this.setOpacity(n,1,e)})),o.forEach((t=>{const n=this.svgRoot.querySelector(`[data-node-id="${t}"]`);n&&this.setOpacity(n,1,e)}))}highlightEdge(t,e){var n,o,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(o=null==(n=null==a?void 0:a.source)?void 0:n.data)?void 0:o.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,n){t.style.transition=n?"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 ft(t,e){const n=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),o=n("--apex-sankey-edge-opacity"),i=""!==o?Number(o):e.edgeOpacity,r=n("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=n("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=n("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=n("--apex-sankey-node-border-color")||e.nodeBorderColor,u=n("--apex-sankey-tooltip-bg")||e.tooltipBGColor,g=n("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,p=n("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=n("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:n("--apex-sankey-label-color")||e.fontColor,fontSize:n("--apex-sankey-label-font-size")||e.fontSize,fontFamily:n("--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:g,tooltipFontColor:p,tooltipTheme:m}}const mt="#005FCC",vt="role",yt="aria-label",bt="data-node-id",xt="data-orig-stroke",wt="data-orig-stroke-width",Et="stroke",At="stroke-width",St="forced-colors",Ct="apexsankey-desc",kt="data-edge-target";const $t="apexsankey-a11y-styles";class Mt{constructor(t,e,n={},o,i,r=ht){this.svgEl=t,this.graph=e,this.options=n,this.tooltipId=o,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($t))return;const t=document.createElement("style");t.id=$t,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: ${mt};\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:n,options:o}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),r=e.edges(),s=function(t,e,n,o,i){var r,s,a,d;if(i)return i;let l=0,c="",h="";for(const e of n)try{const n=t.edge(e.v,e.w,e.name).value??0;if(n>l){const o=t.node(e.v),i=t.node(e.w);o.dummy||i.dummy||(l=n,c=(null==(r=o.data)?void 0:r.title)??(null==(s=o.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 o.diagramLabel({flowCount:n.length,largestFlow:u,nodeCount:e.length})}(e,i,r,n,o.diagramLabel);t.setAttribute(vt,"img"),t.setAttribute(yt,s),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),o.description){let e=t.querySelector("desc");if(!e){const n=document.createElementNS("http://www.w3.org/2000/svg","desc");n.id=Ct,t.insertBefore(n,t.firstChild),e=n}e.textContent=o.description,t.setAttribute("aria-describedby",Ct)}const d=Array.from(t.querySelectorAll(`[${bt}]`));d.forEach((t=>{const o=t.getAttribute(bt);o&&(t.setAttribute(vt,"listitem"),t.setAttribute(yt,function(t,e,n){var o,i,r,s,a,d;const l=e.node(t),c=(null==(o=l.data)?void 0:o.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const n of e.inEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.v);o.dummy||(h.push((null==(r=o.data)?void 0:r.title)??(null==(s=o.data)?void 0:s.id)??n.v),u+=t.value??0)}catch{}const g=[];let p=0;for(const n of e.outEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.w);o.dummy||(g.push((null==(a=o.data)?void 0:a.title)??(null==(d=o.data)?void 0:d.id)??n.w),p+=t.value??0)}catch{}return n.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:g.length>0?{targets:g,total:p}:void 0})}(o,e,n)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,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 g=e.edge(a,d,u),p=g.source,f=g.target;if(!p||!f)return;const m=(null==(o=p.data)?void 0:o.title)??(null==(i=p.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=g.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",n.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",(n=>{const o=n.key;if("Enter"===o||" "===o){n.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===o)n.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===o||"ArrowDown"===o){n.preventDefault();const o=t.getAttribute(bt),i=o?this.nodeOutEdges.get(o)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===o||"ArrowUp"===o){n.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const n=t.getAttribute(bt);n&&(null==(e=this.pathHighlighter)||e.highlightNode(n))}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)??[]:[]},n=()=>{const e=this.edgeSourceNode.get(t),n=e?this.nodeGroups.find((t=>t.getAttribute(bt)===e)):void 0;n&&n.focus()};t.addEventListener("keydown",(o=>{const i=o.key;if("Enter"===i||" "===i)o.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)o.preventDefault(),n();else if("ArrowDown"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i+1)%n.length].focus()}else if("ArrowUp"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i-1+n.length)%n.length].focus()}else if("ArrowRight"===i){o.preventDefault();const e=t.getAttribute(kt),n=e?this.nodeGroups.find((t=>t.getAttribute(bt)===e)):void 0;n&&n.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),n=this.nodeGroups.findIndex((t=>t.getAttribute(bt)===e));if(-1!==n){const t=o.shiftKey?(n-1+this.nodeGroups.length)%this.nodeGroups.length:(n+1)%this.nodeGroups.length;o.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const n=t.getAttribute("data-edge-source"),o=t.getAttribute(kt);n&&o&&(null==(e=this.pathHighlighter)||e.highlightEdge(n,o))}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 n=t.relatedTarget;n&&this.edgePaths.includes(n)||(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(xt,e.getAttribute(Et)??""),e.setAttribute(wt,e.getAttribute(At)??""),e.setAttribute(Et,mt),e.setAttribute(At,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const n=e.getAttribute(xt),o=e.getAttribute(wt);null!==n&&(e.setAttribute(Et,n),e.removeAttribute(xt)),null!==o&&(e.setAttribute(At,o),e.removeAttribute(wt))}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(St),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(St):this.svgEl.classList.remove(St)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Lt="http://www.w3.org/2000/svg";class Tt extends gt{constructor(t,e,n){super(t,e,n),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e,this.messages=ut(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var n;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==(n=document.documentElement)?void 0:n.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){const{edgeGap:e,nodeWidth:n,spacing:o,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=nt({edgeGap:e,nodeWidth:n,whitespace:s});a.size([r-n,i-o]);const d=t.nodes.map(((t,e)=>{const n=e%ot.length;return{...t,color:t.color??ot[n],colorIndex:n}})),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,n=-1/0;for(const o of t){const t=this.graph.node(o).x;void 0!==t&&(e=Math.min(e,t),n=Math.max(n,t))}if(!Number.isFinite(e))return;const o=e+n;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=o-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=o-e.x0),void 0!==e.x1&&(e.x1=o-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=o-t.x)}}render({keepOldPosition:t=!1}={}){var e,n;this.renderOptions=ft(this.element,this.options);const{tooltipTheme:o,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===o?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===o&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,highlightConnectedPath:u,dimOpacity:g,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 pt(this.canvas.node,this.graph,g):null;const k=((t={})=>{const e=[];for(const o in t){const i=`${n=o,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[o]};`;e.push(i)}var n;return e.join(" ")})({color:d,fontFamily:l,fontSize:c,fontWeight:h}),$=p(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(n=this.graph)?void 0:n.edges())||[],T=p();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const B=p();B.node.setAttribute("role","list"),B.node.setAttribute("aria-label",this.messages.nodesGroupLabel),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let n;if(a&&b){const e=this.graph.inEdges(t)??[],o=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),r=o.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),s=Math.max(i,r);n={chartContext:this.chartContext,isCustomTooltip:b!==ct.nodeTooltipTemplate,nodeTooltipTemplate:b,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}}const o=lt(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,isRtl:this.isRtl,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:n,onNodeClick:x});if(o.node.setAttribute("data-node-id",t),o.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;o.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),o.node.addEventListener("mouseleave",(()=>e.reset()))}B.add(o)})),$.add(B),this.add($);const{animation:_}=this.renderOptions;if((null==_?void 0:_.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,n,o,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(Lt,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(Lt,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(Lt,"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(n){null===u&&(u=n);const o=n-u,r=Math.min(o/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 g=n.querySelectorAll("[data-node-rank]"),p=.1*i,f=.7*i-p,m=.45*i;g.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),n=p+(o>0?e/o:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:n,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,B.node,this.maxRank,_.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 R=this.renderOptions.a11y;!1!==(null==R?void 0:R.enabled)&&(this.a11yHelper=new Mt(this.canvas.node,this.graph,R,S,this.pathHighlighter,this.messages),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:n,edgeOpacity:o,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:c,tooltipBorderColor:h,tooltipFontColor:u,tooltipId:g,tooltipTemplate:p}=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 S=st(f);if(!S)return;const C=function(t,{edgeColor:e,id:n="",opacity:o=1}={}){const i=new l({d:t});return i.id(n),i.fill(e).opacity(o),i}(S,{edgeColor:this.canvas.gradient("linear",(t=>{var e,o,i;t.stop(0,(null==(e=w.data)?void 0:e.color)??""),t.stop(1,n?(null==(o=E.data)?void 0:o.color)??"":(null==(i=w.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:o});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,n=t.v,o=t.w;C.on("mouseenter",(()=>e.highlightEdge(n,o))),C.on("mouseleave",(()=>e.reset()))}if(i&&w.data&&E.data){const t=p?p({source:w.data,target:E.data,value:f.value}):`${w.data.title} → ${E.data.title}: ${f.value}`,e=p!==ct.tooltipTemplate;C.on("mouseover",(n=>{const{pageX:o,pageY:i}=n,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:o,y:i});b(this.chartContext,g,d,t,!0)})),C.on("mousemove",(n=>{const{pageX:o,pageY:i}=n,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:o,y:i});b(this.chartContext,g,d,t,!0)})),C.on("mouseout",(()=>{y(this.chartContext,g).style.display="none"}))}e.add(C)}}class Bt extends n{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...ct,...e};const{height:n,width:o}=this.options;this.graph=new Tt(this.element,this.options,this.chartContext),this.setupElementDimensions(o,n),this.handleWatermark()}static setLicense(t){k.setLicense(t)}setupElementDimensions(t,e){let n=!1,o=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(o=Number(t.substring(0,t.length-1)),n=!0):o=Number(t);const i="auto"===e?o/1.6:e;this.element.style.width=`${o}${n?"%":"px"}`,this.element.style.height=`${i}${n?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(k.isLicenseValid()?M.remove(this.element):M.add(this.element))}render(t){var e,n,o;if(!this.element)throw new Error("Element not found");if(n=this.element,o=(null==(e=this.options.locale)?void 0:e.direction)??"ltr",n&&("ltr"===o?n.removeAttribute("dir"):n.setAttribute("dir",o)),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=Bt);export{Bt as ApexSankey,ht as DEFAULT_SANKEY_MESSAGES,Bt 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 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"}})}));
|
|
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 n{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}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.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,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:o=!1,priority:i="normal"}=n;if(!o&&this.injectedStyles.has(e))return;if(o){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!o)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:n})=>{this.injectStyles(t,e,n)}))}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,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new n(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,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}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 n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}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,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));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:n}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==n&&this.node.setAttribute("stroke-dasharray",String(n)),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 n=document.createElementNS(r,"stop");n.setAttribute("offset",String(t)),n.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(n)}}function g(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,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));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 n=document.createElementNS(r,"linearGradient"),o="apx-grad-"+ ++s;return n.setAttribute("id",o),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%"),e(new u(n)),this._defs.appendChild(n),n}panZoom(t={}){return this._panZoomState=function(t,e){const n=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),o={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...n},vb:{...n}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=o.currentZoom/n;if(i<o.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=o,l=d.w*n,c=d.h*n,h=d.x+s*(d.w-l),u=d.y+a*(d.h-c);o.vb={x:h,y:u,w:l,h:c},o.currentZoom=i,g(t,o.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 n=e.clientX-a,o=e.clientY-d;if(Math.abs(n)<4&&Math.abs(o)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const n=t.getBoundingClientRect(),l=o.vb.w/n.width,c=o.vb.h/n.height,h=(e.clientX-a)*l,u=(e.clientY-d)*c;o.vb={x:o.vb.x-h,y:o.vb.y-u,w:o.vb.w,h:o.vb.h},g(t,o.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),o}(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 n=this._panZoomState;if(t<n.zoomMin)return this;const o=n.currentZoom/t,{vb:i}=n,r=i.w*o,s=i.h*o,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return n.vb={x:a,y:d,w:r,h:s},n.currentZoom=t,g(this.node,n.vb),this}}function f(t,e,n,o){const i=new d;return i.attr({"data-parent":o,"data-self":n,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 n(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,n){const o=this.chartContext.createElement("div");return o.id=t,o.className="toolbar-item",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.innerHTML=e,n&&(o.setAttribute("data-tooltip",n),o.setAttribute("aria-label",n)),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.click())})),o}render({enableExport:t=!1,enableFitscreen:n=!1,enableZoom:o=!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(o){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(n){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 n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(y,"true");t.getAppendContainer().appendChild(n),t.trackTooltip(n)}return n},x=(t,e="",n,o="",i=!1)=>{const r=t.getElementById(e);if(!r)return b(t,e),x(t,e,n,o,i);if(n&&o){const e=o.includes("tooltip-content"),s=n.match(/background-color:\s*([^;]+);?/),a=n.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=o;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${o}</div>`}const d=n+"; 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,n=parseFloat(r.style.left),o=t.getChartBounds();if(e>0&&!Number.isNaN(n)&&o.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=o.left+t,s=((t,e,n,o,i=8)=>{if(t+e<=n-i)return t;const r=t-e;return r<o+i?Math.max(o+i,n-e-i):r})(n,e,o.right+t,i);s!==n&&(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:n,fontFamily:o,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};`),n&&h.push(`color: ${n};`),o&&h.push(`font-family: ${o};`),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;function A(t){E.error(t)}const S="APEX-",C=new Date("2027-07-31T00:00:00Z"),k=class{static getLicenseStatus(){return this.licenseKey?this.validationResult??{expired:!1,signatureVerified:!1,valid:!1}:{expired:!1,signatureVerified:!1,valid:!1}}static isLicenseValid(){return this.getLicenseStatus().valid}static onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}static setLicense(t){this.licenseKey=t;const e=this.parseKey(t),n=this.validateStructure(t,e);this.publish(n),n.valid?(null==e?void 0:e.signature)&&this.verifySignature(t,e,n):A(`[Apex] ${n.message}`)}static base64ToBytes(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(4*Math.ceil(e.length/4),"="),o=globalThis.atob;if("function"!=typeof o)throw new Error("no base64 decoder available");const i=o(n),r=new Uint8Array(i.length);for(let t=0;t<i.length;t++)r[t]=i.charCodeAt(t);return r}static canonicalPayload(t){const e=t.domains&&t.domains.length>0?t.domains.join(","):"";return`v1|${t.issueDate}|${t.expiryDate}|${t.plan}|${e}`}static notify(t){for(const e of this.listeners)try{e(t)}catch{}}static parseKey(t){if("string"!=typeof t||!t.startsWith(S))return null;const e=t.slice(5);if(!e)return null;try{const t=(new TextDecoder).decode(this.base64ToBytes(e)),n=JSON.parse(t);return n.issueDate&&n.expiryDate&&n.plan?{data:{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0},signature:"string"==typeof n.sig&&n.sig?n.sig:null}:null}catch{return null}}static publish(t){this.validationResult=t,this.notify(t)}static validateStructure(t,e){const n=t=>({expired:!1,message:t,signatureVerified:!1,valid:!1});if("string"!=typeof t||!t.startsWith(S))return n('Invalid license key format. License key must start with "APEX-".');if(!e)return n("Invalid license key. Unable to decode license data.");const{data:o,signature:i}=e;if(!i&&new Date>=C)return n("This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.");if(new Date(o.expiryDate)<new Date)return{data:o,expired:!0,message:`License expired on ${o.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(o.domains&&o.domains.length>0){const t="undefined"==typeof location?"":location.hostname;if(!o.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:o,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${o.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}return{data:o,expired:!1,signatureVerified:!1,valid:!0}}static async verifySignature(t,e,n){var o;const i=null==(o=globalThis.crypto)?void 0:o.subtle;if(!i||0===this.publicKeysSpki.length)return void(this.warnedUnverifiable||(this.warnedUnverifiable=!0,function(t){E.warn(t)}(i?"[Apex] No license signing key is configured in this build, so license signatures cannot be verified.":"[Apex] Web Crypto is unavailable (a secure context is required), so the license signature cannot be verified.")));const r=(new TextEncoder).encode(this.canonicalPayload(e.data));let s=!1;for(const t of this.publicKeysSpki){try{const n=await i.importKey("spki",this.base64ToBytes(t),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);s=await i.verify({hash:"SHA-256",name:"ECDSA"},n,this.base64ToBytes(e.signature),r)}catch{s=!1}if(s)break}if(this.licenseKey!==t)return;if(s)return void this.publish({...n,signatureVerified:!0});const a="Invalid license key. The license signature does not verify.";this.publish({expired:!1,message:a,signatureVerified:!0,valid:!1}),A(`[Apex] ${a}`)}};k.licenseKey=null,k.listeners=new Set,k.publicKeysSpki=["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="],k.validationResult=null,k.warnedUnverifiable=!1;let $=k;const M=class{static add(t){this.track(t),this.paint(t)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){this.track(t),this.erase(t)}static untrack(t){this.managed.delete(t)}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 erase(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}static paint(t){this.erase(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 reconcile(){const t=$.isLicenseValid();for(const e of this.managed)e.isConnected?t?this.erase(e):this.paint(e):this.managed.delete(e)}static track(t){this.managed.add(t),this.subscribed||(this.subscribed=!0,$.onChange((()=>{this.reconcile()})))}};M.WATERMARK_ATTR="data-apexcharts-watermark",M.WATERMARK_TEXT="APEXCHARTS",M.managed=new Set,M.subscribed=!1;let L=M;function T(t,e){let n=null;for(let o=0;o<t.length;++o)if(e(t[o])){n=o;break}return n}function _(t,e){if(0===t.length)return;let n,o=0;for(let i=t.length-1;i>=0;--i)n=(t[i].dy??0)/2,(t[i][e]??0)-n<o&&(t[i][e]=Math.min(t[i].Rmax??0,o+n)),o=(t[i][e]??0)+n;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let o=0;o<t.length;++o)n=(t[o].dy??0)/2,(t[o][e]??0)+n>i&&(t[o][e]=Math.max(n,i-n)),i=(t[o][e]??0)-n}function B(t){const e=t.edgeGap||0;return function(n){!function(t,e,n){t.nodes().forEach((o=>{const i=t.node(o),r=R(t,i.outgoing||[],"outgoing"),s=R(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),c=s.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),h=l+Math.max(0,a-1)*n,u=c+Math.max(0,d-1)*n;let g=((i.dy??0)-h)/2,p=((i.dy??0)-u)/2;g=Math.max(0,g),p=Math.max(0,p),r.forEach(((o,r)=>{const s=t.edge(o);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+g+(s.dy??0)/2,s.d0=i.direction||"r",g+=s.dy??0,r<a-1&&(g+=n)})),s.forEach(((o,r)=>{const s=t.edge(o);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+p+(s.dy??0)/2,s.d1=i.direction||"r",p+=s.dy??0,r<d-1&&(p+=n)}))}))}(n,t,e),function(t){t.nodes().forEach((e=>{const n=t.node(e),o=(n.outgoing||[]).map((e=>t.edge(e))),i=(n.incoming||[]).map((e=>t.edge(e)));o.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),N(o,"r0"),N(i,"r1")}))}(n);const o=[];return n.edges().forEach((t=>{const e=n.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,o.push(e)})),o}}function R(t,e,n){return e.slice().sort(((e,o)=>{let i,r;if("outgoing"===n){const n=t.node(e.w),s=t.node(o.w);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}else{const n=t.node(e.v),s=t.node(o.v);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==o.name){if("number"==typeof e.name&&"number"==typeof o.name)return e.name-o.name;if("string"==typeof e.name&&"string"==typeof o.name)return e.name.localeCompare(o.name)}return 0}))}function N(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),n=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(n)/2.1:0!==n?(e*e+n*n)/Math.abs(4*n):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 n=T(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===n&&(n=t.length),_(t.slice(n),e),n>0){const o=[];for(let e=n-1;e>=0;e--)o.push(t[e]);_(o,e)}}function I(t,e,n,o,i){if(0===o.length)return;const r=o.map((n=>{const o=`__${e.v}_${e.w}_${n}`;return t.setNode(o,{data:null,direction:i,dummy:!0,rank:n}),o})),s=[e.v,...r,e.w];s.forEach(((o,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:n,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function F(t,e,n){return function(t,e,n){let o,i;e.length>n.length?(o=e,i=n):(o=n,i=e);const r=i.length,s=[];o.forEach((e=>{i.forEach(((n,o)=>{(t.hasEdge(e,n)||t.hasEdge(n,e))&&s.push(o)}))}));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,n)}function W(t){const e=[];let n=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===n.length&&(n=t.nodes().slice(0,1)),function(t,e){const n=new Set,o=[];function i(e){if(!n.has(e)){n.add(e),o.push(e);for(const n of t.successors(e))i(n)}}for(const t of e)i(t);return o}(t,n).forEach((n=>{const o=t.node(n).rank;if(void 0!==o){for(;o>=e.length;)e.push([]);e[o].push(n)}})),e}function z(t,e){let n=!0;for(;n;){n=!1;for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length-1;++i){const r=O(t,e,o);j(e[o],i,i+1);O(t,e,o)<r?n=!0:j(e[o],i,i+1)}}}function O(t,e,n){let o=0;return n>0&&(o+=F(t,e[n-1],e[n])),n+1<e.length&&(o+=F(t,e[n],e[n+1])),o}function j(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function D(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 n=t[e-1]-t[0],o=t[t.length-1]-t[e];return(t[e-1]*o+t[e]*n)/(n+o)}function q(t,e,n=1,o=!1){if(n>0)for(let n=1;n<e.length;++n){const i=new Map;e[n].forEach((r=>{const s=D(H(t,e,n,n-1,r,o));i.set(r,s)})),G(e[n],i)}else for(let n=e.length-2;n>=0;--n){const i=new Map;e[n].forEach((r=>{const s=D(H(t,e,n,n+1,r,o));i.set(r,s)})),G(e[n],i)}}function H(t,e,n,o,i,r=!1){const s=e[n],a=e[o],d=[];return a.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n)})),0===d.length&&r&&s.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n+.5)})),d.sort(((t,e)=>t-e)),d}function G(t,e){const n=new Map(t.map(((t,e)=>[t,e])));for(let o=1;o<t.length;++o)for(let i=o;i>0;--i){let o=i-1,r=e.get(t[o]),s=e.get(t[i]);for(;-1===(r=e.get(t[o]))&&o>0;)o--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=n.get(t[o])??r,s=n.get(t[i])??s),s>=r)break;[t[i],t[o]]=[t[o],t[i]]}}function V(t,e){let n=0;for(let o=0;o<e.length-1;++o)n+=F(t,e[o],e[o+1]);return n}function Y(t){const e=[];for(const n of t){const t=[];e.push(t);for(const e of n)t.push(e)}return e}const K=(t,e)=>(t||[]).reduce(((t,n)=>t+(e?e(n):n)),0);function P(){let t=[100,100],e=null,n=.18,o=function(t,e,n){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),Z(a,i,r),function(t,e,n,o=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*n+l*o})),t.edges().forEach((o=>{const i=t.edge(o);i.value=e(i),i.dy=i.value*n}))}(a,i,e,l);const c=U(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]/K(c)*t[1],g=0===s?0:n*u/5,p=u-2*g,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?o(l[e],l[e+1],a):0)),m=K(l,(t=>a.node(t).dy)),v=Math.max(0,p-m),y=K(f)?v/K(f):0;let b=s+g;1===l.length&&(b+=(p-a.node(l[0]).dy)/2),h[e][d]={margin:g,height:p,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,g,p=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n];for(let t=0;t<o.length;t++){const i=o[t];for(let o=0;o<i.length;o++)e.push({rankIndex:n,bandIndex:t,nodeIndex:o,nodeId:i[o]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:n,nodeId:o})=>{var i;t===p&&e===f||(p=t,f=e,u=h[t][e],g=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(o);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[n]*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)),n===g.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const n=[];return e.forEach(((o,i)=>{if(i===e.length-1)return;let r=0;o.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const n=t.edge(e).dy,o=t.node(e.w).y-t.node(e.v).y,i=Math.abs(o)-n,s=n*n-i*i,a=s>=0?Math.sqrt(s):n;a>r&&(r=a)}))}))})),n.push(r)})),n}(a,d);!function(t,e,n,o){const i=o.reduce(((t,e)=>t+e),0);let r;if(i>n)r=o.map((t=>n*t/i));else{const t=n-i;r=o.map((n=>n+t/(e.length-1)))}let s=0;e.forEach(((e,n)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[n]}))}(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(o,s,a=0){Z(o,i,r);let d=0;a>0&&o.nodes().forEach((t=>{d=Math.max(d,function(t,e,n){if(n<=0)return 0;const o=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,o.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*n}(o,t,a))}));const l=K(U(o,s,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==n&&(e*=1-n)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(o="function"==typeof t?t:()=>t,s):o},s.whitespace=function(t){return arguments.length?(n=t,s):n},s.scale=function(t){return arguments.length?(e=t,s):e},s}function Z(t,e,n){t.nodes().forEach((o=>{const i=K(t.inEdges(o),(n=>e(t.edge(n)))),r=K(t.outEdges(o),(n=>e(t.edge(n))));let s=t.node(o);s||t.setNode(o,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=n(s)||"r")}))}function U(t,e,n=0,o=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=K(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*n/o}));r[i]=Math.max(r[i],s)}))})),r}function X(t,e,n){return void 0!==n?`${t}${e}${n}`:`${t}${e}`}class Q{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,n;if(!this._nodes.has(t))return this;this._nodes.delete(t);const o=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of o){const n=this._edges.get(t);n&&(null==(e=this._in.get(n.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(n=this._out.get(e.v))||n.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,n,o){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,o=t.name,n=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?X(s,a,o):X(s,a),l=this._edges.get(d);if(l)void 0!==n&&(l.label=n);else{const t={v:s,w:a,name:o,label:void 0!==n?n:{}};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,n){var o;let i;return i="string"==typeof t?this._isMultigraph?X(t,e,n):X(t,e):this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),null==(o=this._edges.get(i))?void 0:o.label}hasEdge(t,e,n){const o=this._isMultigraph?X(t,e,n):X(t,e);return this._edges.has(o)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:n})=>({v:t,w:e,name:n})))}removeEdge(t){var e,n;const o=this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),i=this._edges.get(o);return i?(null==(e=this._out.get(i.v))||e.delete(o),null==(n=this._in.get(i.w))||n.delete(o),this._edges.delete(o),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 n=[],o=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);o.has(t)||(o.add(t),n.push(i))}return n}}function J(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function tt(t,e){const n=function(t,e){const n=new Set,o=new Q({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return et(t,e,n,o,i),t.nodes().forEach((e=>{n.has(e)||et(t,e,n,o,i)})),i.forEach(((t,e)=>{o.node(t).thread=e+1<i.length?i[e+1]:i[0]})),o}(t,e);return t.edges().forEach((e=>{const o=function(t,e,n){const o=t.node(e),i=t.node(n);if((o.depth??0)<(i.depth??0)){let e=o.thread;for(;void 0!==e&&(t.node(e).depth??0)>(o.depth??0);){if(e===n)return 1;e=t.node(e).thread}}else if((i.depth??0)<(o.depth??0)){let n=i.thread;for(;void 0!==n&&(t.node(n).depth??0)>(i.depth??0);){if(n===e)return-1;n=t.node(n).thread}}return 0}(n,e.v,e.w);if(o<0){const n=t.edge(e)||{};n.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,n)}})),t}function et(t,e,n,o,i,r=0){if(!n.has(e)){n.add(e),i.push(e),o.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{n.has(s)||o.setEdge(e,s,{delta:1}),et(t,s,n,o,i,r+1)}))}}function nt(t,e){if(0===t.nodes().length)return;const n=function(t,e){const n=new Q({directed:!0});let o=!1;for(const t of e)if("min"===t.type){o=!0;break}if(!o){const n=t.sources();e=n.length>0?[{nodes:[n[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)})),n.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,o={nodes:[t],type:"same"};i.set(t,e),n.setNode(e,o)}})),t.edges().forEach((e=>{const o=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=n.edge(o,r)||{delta:0};o===r?(d.delta=0,n.setEdge(o,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),n.setEdge(r,o,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),n.setEdge(o,r,d))})),n}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(n),tt(n,"0"),function(t){var e;const n=t.sources(),o=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(J(t))}));n.length>0;){const r=n.shift();if(void 0===r)break;o.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const n of t.inEdges(r)){const o=(null==(e=t.edge(n)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(n.v).rank??0)+o)}for(const e of t.outEdges(r))i.add(J(e));for(const e of t.nodes())n.indexOf(e)<0&&!o.has(e)&&!t.inEdges(e).some((t=>!i.has(J(t))))&&n.push(e)}}(n),function(t){function e(e){const n=t.node(e),o=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==o&&(n.rank=o)}t.edges().forEach((n=>{t.edge(n).temp&&e(n.w)}))}(n),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),n.nodes().forEach((e=>{var o;const i=n.node(e);null==(o=i.nodes)||o.forEach((e=>{t.node(e).rank=i.rank}))}))}function ot(t){const e=P(),n=B(t);let o=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const n=new Q({directed:!0,multigraph:!0});return e.forEach((t=>{n.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),n.nodes().forEach((t=>n.setNode(t,{data:{}}))),t.forEach((t=>{n.hasNode(t.id)&&(n.node(t.id).data=t,void 0!==t.direction&&(n.node(t.id).direction=t.direction))})),n.edges().forEach((t=>{n.edge(t).source=n.node(t.v),n.edge(t).target=n.node(t.w)})),n}(a,s);var c;return d.order?(nt(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)))))))):(nt(l,d.rankSets||[]),(c=l).edges().forEach((t=>{const e=c.node(t.v),n=c.node(t.w),o=c.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==n.rank&&i+1<=n.rank){for("l"===e.direction&&r.push(i);++i<n.rank;)r.push(i);"l"===n.direction&&r.push(i),I(c,t,o,r,"r")}else if(void 0!==i&&void 0!==n.rank&&i>n.rank){for("l"!==e.direction&&r.push(i);i-- >n.rank+1;)r.push(i);"l"!==n.direction&&r.push(i),I(c,t,o,r,"l")}})),r=function(t,e=25){const n=W(t);let o=n,i=V(t,n),r=0;for(;r++<e;){q(t,n,r%2==0?1:0),z(t,n);const e=V(t,n);if(e<i&&(o=Y(n),i=e),0===i)break}return o.map((t=>[t]))}(l)),o=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const n=t.node(e);n.incoming=t.inEdges(e),n.outgoing=t.outEdges(e)}))}(l),i=n(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var n;let o=t.node(e);if(!o)return;let i=(null==(n=t.inEdges(e))?void 0:n.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(;o.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:o.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),o=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 n=t.edge(e);n.points||(n.points=[]),n.points.unshift({d:n.d0,ro:n.r0,x:n.x0,y:n.y0}),n.points.push({d:n.d1,ri:n.r1,x:n.x1,y:n.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return o},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 it=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],rt=t=>0===t.dy?0:2;function st(t){const e=Math.max(rt(t),t.dy)/2;let{x0:n}=t,{x1:o}=t,{y0:i}=t,{y1:r}=t;o<n&&([n,o]=[o,n],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,n=t.y1-t.y0;return[t.dy/2,(e*e+n*n)/Math.abs(4*n)]}(t),d=Math.max(a[0],Math.min(a[1],(o-n)/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=o-n,u=r-i-s*(l+c),g=Math.sqrt(h*h+u*u),p=-s*Math.acos(Math.min(1,(l+c)/g)),f=Math.atan2(u,h);let m=Math.PI/2+s*(f+p),v=e*s*Math.sin(m),y=e*Math.cos(m),b=n+1*l*Math.sin(Math.abs(m)),x=o-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,n){const o=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?n+e:n-e;return 0===m&&(s=n),`A${s} ${s} ${Math.abs(m)} 0 ${o} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,c=0,b=n,x=o,w=i,E=r,v=0,y=e),`M${[n,i-e]} ${A(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${A(-1,c)}${[o,r-e]} L${[o,r+e]} ${A(1,c)}${[x-v,E+y]} L${[b-v,w+y]} ${A(-1,l)}${[n,i+e]} Z`}function at(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],n=Math.max(rt(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-n]} L${[e.x??0,(e.y??0)-n]} L${[e.x??0,(e.y??0)+n]} L${[(e.x??0)-20,(e.y??0)+n]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)+n]} L${[e.x??0,(e.y??0)+n]} Z`:null}(t);if(!t.points)return null;let n,o="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];n={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},o+=st(n)}return o}const dt=(t,e)=>{const n=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&n.length>e?`${n.substr(0,15)}...`:n};function lt(t,{fontColor:e,isRtl:n,maxRank:o,nodeWidth:i}){const{data:r}=t;if(!r)return null;const s=function(t,e,n){let o=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,o=!1),n&&(i=!i),{right:i,top:o}}(t,o,n),{x:a,y:d}=function(t,e,n){const o=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+n/2:-n/2-10,{x:(t.x??0)+i,y:(t.y??0)+o}}(t,s,i);return function(t="",{fontColor:e="#666767",pointerEvents:n="all",textAnchor:o="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":n,"text-anchor":o}),s}(dt(r,s.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:s.top?"middle":s.right?"start":"end",x:a,y:d})}function ct(t,e,n){var o,i;const{dy:r,x:s,y:a}=t,{fontColor:c="#212121",fontSize:h="14px",fontFamily:u,fontWeight:g,isRtl:p=!1,nodeBorderColor:f,nodeBorderWidth:m,nodeWidth:v=0,onNodeClick:y,nodeTooltip:E}=n,A=new d({class:"node"}),S=function({borderColor:t="#caced0",color:e="#97cbe6",height:n=0,opacity:o=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const d=new l;return d.attr({height:n,opacity:o,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==(o=t.data)?void 0:o.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:n,nodeValue:o,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=E,l=d({node:t.data,value:o});S.on("mouseover",(t=>{const{pageX:o,pageY:d}=t,p=w({bgColor:n?void 0:i,borderColor:n?void 0:r,fontColor:n?void 0:s||c,fontFamily:n?void 0:u??"",fontSize:n?void 0:h??"14px",fontWeight:n?void 0:g??"400",x:o,y:d});x(e,a,p,l,!0)})),S.on("mousemove",(t=>{const{pageX:o,pageY:d}=t,p=w({bgColor:n?void 0:i,borderColor:n?void 0:r,fontColor:n?void 0:s||c,fontFamily:n?void 0:u??"",fontSize:n?void 0:h??"14px",fontWeight:n?void 0:g??"400",x:o,y:d});x(e,a,p,l,!0)})),S.on("mouseout",(()=>{b(e,a).style.display="none"}))}if(A.add(S),t.data&&(r??0)>Number.parseInt(h,10)){const n=lt(t,{fontColor:c,isRtl:p,maxRank:e,nodeWidth:v});n&&A.add(n)}return A}const ht={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:n})=>`\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;'>${n}</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}},ut={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:n})=>{let o=`Sankey flow diagram: ${n} nodes, ${t} flows.`;return e&&(o+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),o},edgeAriaLabel:({source:t,target:e,value:n})=>`Flow from ${t} to ${e}: ${n} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:n})=>{let o=e;if(t&&(o+=`: receives ${t.total} units from ${t.sources.join(", ")}`),n){o+=`${t?"; ":": "}flows ${n.total} units to ${n.targets.join(", ")}`}return o},nodesGroupLabel:"Sankey nodes"};function gt(t){var e;return function(t,e){if(!e)return{...t};const n={...t};for(const t of Object.keys(e)){const o=e[t];void 0!==o&&(n[t]=o)}return n}(ut,null==(e=t.locale)?void 0:e.messages)}class pt{constructor(t,e,n){this.element=t,this.options=e,this.chartContext=n,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(r,"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 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,n,o){this.canvas.viewbox(`${t} ${e} ${n} ${o}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class ft{constructor(t,e,n){this.svgRoot=t,this.graph=e,this.dimOpacity=n}highlightNode(t){const e=this.prefersReducedMotion(),n=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],o=new Set([t]);n.forEach((t=>{var e,n,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(n=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:n.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&o.add(a),d&&o.add(d)})),this.dimAll(e),n.forEach((t=>{const n=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);n&&this.setOpacity(n,1,e)})),o.forEach((t=>{const n=this.svgRoot.querySelector(`[data-node-id="${t}"]`);n&&this.setOpacity(n,1,e)}))}highlightEdge(t,e){var n,o,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(o=null==(n=null==a?void 0:a.source)?void 0:n.data)?void 0:o.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,n){t.style.transition=n?"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 mt(t,e){const n=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),o=n("--apex-sankey-edge-opacity"),i=""!==o?Number(o):e.edgeOpacity,r=n("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=n("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=n("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=n("--apex-sankey-node-border-color")||e.nodeBorderColor,u=n("--apex-sankey-tooltip-bg")||e.tooltipBGColor,g=n("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,p=n("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=n("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:n("--apex-sankey-label-color")||e.fontColor,fontSize:n("--apex-sankey-label-font-size")||e.fontSize,fontFamily:n("--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:g,tooltipFontColor:p,tooltipTheme:m}}const vt="#005FCC",yt="role",bt="aria-label",xt="data-node-id",wt="data-orig-stroke",Et="data-orig-stroke-width",At="stroke",St="stroke-width",Ct="forced-colors",kt="apexsankey-desc",$t="data-edge-target";const Mt="apexsankey-a11y-styles";class Lt{constructor(t,e,n={},o,i,r=ut){this.svgEl=t,this.graph=e,this.options=n,this.tooltipId=o,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(Mt))return;const t=document.createElement("style");t.id=Mt,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: ${vt};\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:n,options:o}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),r=e.edges(),s=function(t,e,n,o,i){var r,s,a,d;if(i)return i;let l=0,c="",h="";for(const e of n)try{const n=t.edge(e.v,e.w,e.name).value??0;if(n>l){const o=t.node(e.v),i=t.node(e.w);o.dummy||i.dummy||(l=n,c=(null==(r=o.data)?void 0:r.title)??(null==(s=o.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 o.diagramLabel({flowCount:n.length,largestFlow:u,nodeCount:e.length})}(e,i,r,n,o.diagramLabel);t.setAttribute(yt,"img"),t.setAttribute(bt,s),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),o.description){let e=t.querySelector("desc");if(!e){const n=document.createElementNS("http://www.w3.org/2000/svg","desc");n.id=kt,t.insertBefore(n,t.firstChild),e=n}e.textContent=o.description,t.setAttribute("aria-describedby",kt)}const d=Array.from(t.querySelectorAll(`[${xt}]`));d.forEach((t=>{const o=t.getAttribute(xt);o&&(t.setAttribute(yt,"listitem"),t.setAttribute(bt,function(t,e,n){var o,i,r,s,a,d;const l=e.node(t),c=(null==(o=l.data)?void 0:o.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const n of e.inEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.v);o.dummy||(h.push((null==(r=o.data)?void 0:r.title)??(null==(s=o.data)?void 0:s.id)??n.v),u+=t.value??0)}catch{}const g=[];let p=0;for(const n of e.outEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.w);o.dummy||(g.push((null==(a=o.data)?void 0:a.title)??(null==(d=o.data)?void 0:d.id)??n.w),p+=t.value??0)}catch{}return n.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:g.length>0?{targets:g,total:p}:void 0})}(o,e,n)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,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 g=e.edge(a,d,u),p=g.source,f=g.target;if(!p||!f)return;const m=(null==(o=p.data)?void 0:o.title)??(null==(i=p.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=g.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",n.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",(n=>{const o=n.key;if("Enter"===o||" "===o){n.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===o)n.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===o||"ArrowDown"===o){n.preventDefault();const o=t.getAttribute(xt),i=o?this.nodeOutEdges.get(o)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===o||"ArrowUp"===o){n.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const n=t.getAttribute(xt);n&&(null==(e=this.pathHighlighter)||e.highlightNode(n))}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)??[]:[]},n=()=>{const e=this.edgeSourceNode.get(t),n=e?this.nodeGroups.find((t=>t.getAttribute(xt)===e)):void 0;n&&n.focus()};t.addEventListener("keydown",(o=>{const i=o.key;if("Enter"===i||" "===i)o.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)o.preventDefault(),n();else if("ArrowDown"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i+1)%n.length].focus()}else if("ArrowUp"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i-1+n.length)%n.length].focus()}else if("ArrowRight"===i){o.preventDefault();const e=t.getAttribute($t),n=e?this.nodeGroups.find((t=>t.getAttribute(xt)===e)):void 0;n&&n.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),n=this.nodeGroups.findIndex((t=>t.getAttribute(xt)===e));if(-1!==n){const t=o.shiftKey?(n-1+this.nodeGroups.length)%this.nodeGroups.length:(n+1)%this.nodeGroups.length;o.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const n=t.getAttribute("data-edge-source"),o=t.getAttribute($t);n&&o&&(null==(e=this.pathHighlighter)||e.highlightEdge(n,o))}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 n=t.relatedTarget;n&&this.edgePaths.includes(n)||(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(wt,e.getAttribute(At)??""),e.setAttribute(Et,e.getAttribute(St)??""),e.setAttribute(At,vt),e.setAttribute(St,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const n=e.getAttribute(wt),o=e.getAttribute(Et);null!==n&&(e.setAttribute(At,n),e.removeAttribute(wt)),null!==o&&(e.setAttribute(St,o),e.removeAttribute(Et))}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(Ct),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(Ct):this.svgEl.classList.remove(Ct)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Tt="http://www.w3.org/2000/svg";class _t extends pt{constructor(t,e,n){super(t,e,n),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e,this.messages=gt(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var n;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==(n=document.documentElement)?void 0:n.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){const{edgeGap:e,nodeWidth:n,spacing:o,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=ot({edgeGap:e,nodeWidth:n,whitespace:s});a.size([r-n,i-o]);const d=t.nodes.map(((t,e)=>{const n=e%it.length;return{...t,color:t.color??it[n],colorIndex:n}})),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,n=-1/0;for(const o of t){const t=this.graph.node(o).x;void 0!==t&&(e=Math.min(e,t),n=Math.max(n,t))}if(!Number.isFinite(e))return;const o=e+n;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=o-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=o-e.x0),void 0!==e.x1&&(e.x1=o-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=o-t.x)}}render({keepOldPosition:t=!1}={}){var e,n;this.renderOptions=mt(this.element,this.options);const{tooltipTheme:o,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===o?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===o&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,highlightConnectedPath:u,dimOpacity:g,nodeBorderColor:p,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 ft(this.canvas.node,this.graph,g):null;const k=((t={})=>{const e=[];for(const o in t){const i=`${n=o,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[o]};`;e.push(i)}var n;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==(n=this.graph)?void 0:n.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 n;if(a&&y){const e=this.graph.inEdges(t)??[],o=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),r=o.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),s=Math.max(i,r);n={chartContext:this.chartContext,isCustomTooltip:y!==ht.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:A,tooltipId:S}}const o=ct(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,isRtl:this.isRtl,nodeBorderColor:p,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:n,onNodeClick:x});if(o.node.setAttribute("data-node-id",t),o.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;o.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),o.node.addEventListener("mouseleave",(()=>e.reset()))}_.add(o)})),$.add(_),this.add($);const{animation:B}=this.renderOptions;if((null==B?void 0:B.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,n,o,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(Tt,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(Tt,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(Tt,"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(n){null===u&&(u=n);const o=n-u,r=Math.min(o/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 g=n.querySelectorAll("[data-node-rank]"),p=.1*i,f=.7*i-p,m=.45*i;g.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),n=p+(o>0?e/o:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:n,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,S);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const R=this.renderOptions.a11y;!1!==(null==R?void 0:R.enabled)&&(this.a11yHelper=new Lt(this.canvas.node,this.graph,R,S,this.pathHighlighter,this.messages),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:n,edgeOpacity:o,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:l,tooltipBorderColor:h,tooltipFontColor:u,tooltipId:g,tooltipTemplate:p}=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=at(f);if(!S)return;const C=function(t,{edgeColor:e,id:n="",opacity:o=1}={}){const i=new c({d:t});return i.id(n),i.fill(e).opacity(o),i}(S,{edgeColor:this.canvas.gradient("linear",(t=>{var e,o,i;t.stop(0,(null==(e=y.data)?void 0:e.color)??""),t.stop(1,n?(null==(o=E.data)?void 0:o.color)??"":(null==(i=y.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:o});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,n=t.v,o=t.w;C.on("mouseenter",(()=>e.highlightEdge(n,o))),C.on("mouseleave",(()=>e.reset()))}if(i&&y.data&&E.data){const t=p?p({source:y.data,target:E.data,value:f.value}):`${y.data.title} → ${E.data.title}: ${f.value}`,e=p!==ht.tooltipTemplate;C.on("mouseover",(n=>{const{pageX:o,pageY:i}=n,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:o,y:i});x(this.chartContext,g,d,t,!0)})),C.on("mousemove",(n=>{const{pageX:o,pageY:i}=n,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:o,y:i});x(this.chartContext,g,d,t,!0)})),C.on("mouseout",(()=>{b(this.chartContext,g).style.display="none"}))}e.add(C)}}class Bt extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...ht,...e};const{height:n,width:o}=this.options;this.graph=new _t(this.element,this.options,this.chartContext),this.setupElementDimensions(o,n),this.handleWatermark()}static setLicense(t){$.setLicense(t)}setupElementDimensions(t,e){let n=!1,o=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(o=Number(t.substring(0,t.length-1)),n=!0):o=Number(t);const i="auto"===e?o/1.6:e;this.element.style.width=`${o}${n?"%":"px"}`,this.element.style.height=`${i}${n?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&($.isLicenseValid()?L.remove(this.element):L.add(this.element))}render(t){var e,n,o;if(!this.element)throw new Error("Element not found");if(n=this.element,o=(null==(e=this.options.locale)?void 0:e.direction)??"ltr",n&&("ltr"===o?n.removeAttribute("dir"):n.setAttribute("dir",o)),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=Bt),t.ApexSankey=Bt,t.DEFAULT_SANKEY_MESSAGES=ut,t.default=Bt,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|