semiotic 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +10 -4
- package/README.md +1 -1
- package/ai/dist/mcp-server.js +104 -9
- package/ai/schema.json +1 -1
- package/dist/components/LinkedCharts.d.ts +8 -0
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +7 -1
- package/dist/components/charts/ordinal/DotPlot.d.ts +9 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +2 -2
- package/dist/components/charts/ordinal/LikertChart.d.ts +5 -2
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +2 -2
- package/dist/components/charts/shared/hooks.d.ts +15 -2
- package/dist/components/charts/shared/selectionUtils.d.ts +9 -7
- package/dist/components/charts/shared/tooltipUtils.d.ts +13 -1
- package/dist/components/charts/shared/types.d.ts +5 -6
- package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
- package/dist/components/charts/shared/useResolvedSelection.d.ts +2 -0
- package/dist/components/realtime/types.d.ts +12 -0
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +7 -0
- package/dist/components/semiotic-ordinal.d.ts +8 -0
- package/dist/components/semiotic-xy.d.ts +9 -0
- package/dist/components/server/renderToStaticSVG.d.ts +1 -1
- package/dist/components/store/ThemeStore.d.ts +2 -0
- package/dist/components/stream/CanvasHitTester.d.ts +8 -3
- package/dist/components/stream/DataSourceAdapter.d.ts +17 -0
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +19 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +5 -0
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +3 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +38 -1
- package/dist/components/stream/ParticlePool.d.ts +4 -0
- package/dist/components/stream/PipelineStore.d.ts +17 -2
- package/dist/components/stream/StreamXYFrame.d.ts +17 -0
- package/dist/components/stream/geoTypes.d.ts +7 -0
- package/dist/components/stream/hoverUtils.d.ts +12 -0
- package/dist/components/stream/networkTypes.d.ts +19 -1
- package/dist/components/stream/ordinalTypes.d.ts +53 -12
- package/dist/components/stream/pipelineTransitionUtils.d.ts +21 -0
- package/dist/components/stream/quadtreeHitTest.d.ts +22 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +23 -6
- package/dist/components/stream/types.d.ts +18 -0
- package/dist/components/stream/useFrame.d.ts +122 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +7 -0
- package/dist/semiotic-ordinal.d.ts +8 -0
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +9 -0
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/canvasMock.d.ts +26 -0
- package/dist/test-utils/ordinalFixtures.d.ts +48 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +15 -14
package/dist/realtime.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),r=require("d3-scale"),o=require("d3-quadtree"),i=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function f(e){return e&&e.__esModule?e:{default:e}}function y(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const g=y(e),p=f(c);function v(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function m(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function x({width:r,height:o,totalWidth:i,totalHeight:l,margin:a,dimension:s,scales:c,onBrush:u,binSize:d,snap:h,binBoundaries:f,snapDuring:y,streaming:p}){const x=e.useRef(null),b=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const E=e.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),A=e.useRef(E);A.current=E;const M=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!x.current)return;const e=t.select(x.current).select(".brush-g"),i="x"===s?n.brushX():"y"===s?n.brushY():n.brush();return i.extent([[0,0],[r,o]]),i.on("brush end",t=>{if(M.current)return;const n=w.current;if(!n)return;if(!t.selection)return S.current=null,void k.current(null);let l,a;if("x"===s){const[e,r]=t.selection;l=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(0)]}else if("y"===s){const[e,o]=t.selection;l=[n.x.invert(0),n.x.invert(r)],a=[n.y.invert(o),n.y.invert(e)]}else{const[[e,r],[o,i]]=t.selection;l=[n.x.invert(e),n.x.invert(o)],a=[n.y.invert(i),n.y.invert(r)]}if("bin"===h&&"y"!==s&&("end"===t.type||"brush"===t.type&&y)){const r=A.current;r&&r.length>0?l=function(e,t){return 0===t.length?e:[v(e[0],t),m(e[1],t)]}(l,r):d&&d>0&&(l=[Math.floor(l[0]/d)*d,Math.ceil(l[1]/d)*d]);const o=n.x(l[0]),a=n.x(l[1]);if(M.current=!0,"x"===s)e.call(i.move,[o,a]);else if("xy"===s){const n=t.selection;e.call(i.move,[[o,n[0][1]],[a,n[1][1]]])}M.current=!1}const c={x:l,y:a};S.current=c,k.current(c)}),e.call(i),b.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),b.current=null}},[r,o,s,h,d,y]),e.useEffect(()=>{if(!(p&&c&&b.current&&S.current))return;if(!x.current)return;if("y"===s)return;const e=S.current,n=c.x.domain()[0],r=t.select(x.current).select(".brush-g");if(n>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);let o=e.x[0],i=!1;if(n>e.x[0]){if(o=n,"bin"===h){const e=A.current;e&&e.length>0?o=m(n,e):d&&d>0&&(o=Math.ceil(n/d)*d)}if(o>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);i=!0}const l=c.x(o),a=c.x(e.x[1]);if(M.current=!0,"x"===s)r.call(b.current.move,[l,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);r.call(b.current.move,[[l,t],[a,n]])}if(M.current=!1,i){const t={x:[o,e.x[1]],y:e.y};S.current=t,k.current(t)}},[c,p,s,h,d]),g.createElement("svg",{ref:x,width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class b{constructor(e,t){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==t?void 0:t.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,l=this.buffer[i];if(e(l)){let e;e="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(e),this.buffer[i]=t(l)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class w{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function E(e,t,n,r,o){const i=new Map;for(const l of e){const e=t(l),a=n(l);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const s=Math.floor(e/r)*r;let c=i.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},i.set(s,c)),c.total+=a,o){const e=o(l);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function A(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function M(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function P(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const _=i.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function T(e,t,n){var r,o,i;if(1>=n)return 1;const l=null!==(r=e.minOpacity)&&void 0!==r?r:.1,a=n-1-t;switch(e.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,a/t)*(1-l)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:l;default:return 1}}function D(e,t,n){var r;const o=null!==(r=e.duration)&&void 0!==r?r:500,i=n-t;return o>i?1-i/o:0}function L(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function N(e,t){return Math.min((e-t.startTime)/t.duration,1)}function I(e,t,n){return e+(t-e)*n}function O(e,t,n){var r,o,i,l;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(l=null!==(o=null===(r=t.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function $(e,t,n,r,o,i){const l=[];for(const o of e){const e=n(o),i=r(o);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||l.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}l.sort((e,t)=>e.px-t.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];a[e]=[t.px,t.py],s[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:s,style:o,datum:c,group:i}}function W(e,t,n,r,o,i,l,a){const s=[];for(const i of e){const e=n(i),l=r(i);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const c=t.x(e),u=a?a(i):o;s.push({px:c,topY:t.y(l),botY:t.y(u)})}s.sort((e,t)=>e.px-t.px);const c=Array(s.length),u=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:l}}function z(e,t,n,r,o,i,l){const a=n(e),s=r(e);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:t.x(a),y:t.y(s),r:o,style:i,datum:e};return void 0!==l&&(c.pointId=l),c}function R(e,t,n,r,o,i,l){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:l}}function B(e,t,n,r,o,i,l){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function j(e,t,n){if(!e.getBounds||!e.scales)return null;const r=[],o=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const l=e.getBounds(n),a=e.scales.x(t);if(l&&0!==l)r.push([a,e.scales.y(i+l)]),o.push([a,e.scales.y(i-l)]);else{const t=e.scales.y(i);r.push([a,t]),o.push([a,t])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function F(e,t,n,r){var o;if(!e.config.pointStyle)return;const i=null!=r?r:e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const l of r.data){let r=e.config.pointStyle(l);!r.fill&&t&&(r=Object.assign(Object.assign({},r),{fill:t}));const a=null!==(o=r.r)&&void 0!==o?o:3,s=e.getPointId?e.getPointId(l)+"":void 0,c=z(l,e.scales,e.getX,i,a,r,s);c&&n.push(c)}}}const Y={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},H=new Map;class X{constructor(e){if(this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new k(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=M(e.timeAccessor||e.xAccessor,"time"),this.getY=M(e.valueAccessor||e.yAccessor,"value")):(this.getX=M(e.xAccessor,"x"),this.getY=M(e.yAccessor,"y")),this.getGroup=P(e.groupAccessor),this.getCategory=P(e.categoryAccessor),this.getSize=e.sizeAccessor?M(e.sizeAccessor,"size"):void 0,this.getColor=P(e.colorAccessor),this.getBounds=e.boundsAccessor?M(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?M(e.y0Accessor,"y0"):void 0,this.getPointId=P(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?M(e.openAccessor,"open"):void 0,this.getHigh=M(e.highAccessor,"high"),this.getLow=M(e.lowAccessor,"low"),this.getClose=n?M(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new k(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?M(this.config.timeAccessor||this.config.xAccessor,"time"):M(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,i,l,a,s;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let y=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(o=c.xExtent[1])&&void 0!==o?o:h[1]]:h,g=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:f[0],null!==(l=c.yExtent[1])&&void 0!==l?l:f[1]]:f;const p=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!p&&u.size>0)if(c.normalize)g=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),r=this.getY(t);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||n.set(e,(n.get(e)||0)+r)}let r=0;for(const e of n.values())e>r&&(r=e);g=[0,r+(r>0?r*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.size>0){const[,e]=function(e,t,n,r,o){const i=E(e,t,n,r,o);if(0===i.size)return[0,0];let l=0;for(const e of i.values())e.total>l&&(l=e.total);return[0,l]}(u,this.getX,this.getY,c.binSize,this.getCategory);g=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.size>0){const[e,t]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(u,this.getY),n=t-e,r=n>0?n*c.extentPadding:1;g=[Math.min(0,e-Math.abs(r)),Math.max(0,t+Math.abs(r))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=r?g[1]:g[1]+t],"log"===c.yScaleType&&0>=g[0]&&f[0]>0&&(g[0]=null!=n?g[0]:f[0]/(1+c.extentPadding))}if(y[0]===1/0||y[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();y=[e-864e5,e]}else y=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(v)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const t="right"===c.arrowOfTime?[m,e.width-m]:[e.width-m,m];this.scales={x:r.scaleLinear().domain(y).range(t),y:r.scaleLinear().domain(g).range([e.height-m,m])}}else{const t="down"===c.arrowOfTime?[m,e.height-m]:[e.height-m,m];this.scales={x:r.scaleLinear().domain(g).range([m,e.width-m]),y:r.scaleLinear().domain(y).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,y,[m,e.width-m]),y:t(c.yScaleType,g,[e.height-m,m])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>X.QUADTREE_THRESHOLD?o.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),l=this.scales.x.range(),a=this.scales.y.range(),s=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:s(this.config.xScaleType,o,l[0]>l[1]?[e.width-c,c]:[c,e.width-c]),y:s(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:r,scales:o}=this;if(!o||0===t.length)return[];const l={scales:o,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(e,t){var n;const r=e.groupData(t),o=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of r){const n=j(e,t.data,t.key);n&&o.push(n)}for(const t of r){const n=e.resolveLineStyle(t.key,t.data[0]),r=$(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(r.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return F(e,r,o),o}(l,t);case"area":return function(e,t){const n=e.groupData(t),r=[],o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),l=W(t.data,e.scales,e.getX,e.getY,o,n,t.key,i);e.config.gradientFill&&(l.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(l.curve=e.config.curve),e.config.lineGradient&&(l.strokeGradient=e.config.lineGradient),r.push(l)}return F(e,n,r),r}(l,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],l=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=W(t.data,e.scales,e.getX,e.getY,i,n,t.key,l);e.config.gradientFill&&(o.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=$(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return F(e,n,r),r}(l,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const r=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:o,stackedTops:i}=function(e,t,n,r,o,i,l){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const c=Array.from(s).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const r of e)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(t))||0;d.set(t,n||1)}}const h=[],f=new Map,y=new Map;for(const e of c)y.set(e,0);for(const n of e){const e=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let o=e.get(n)||0;const l=y.get(n);i&&(o/=d.get(n));const c=l+o,u=t.x(n);a.push([u,t.y(l)]),r.push([u,t.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),h.push(g)}return{nodes:h,stackedTops:f}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,r),l=o;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=i.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>{var r;return null!==(r=t.get(n))&&void 0!==r?r:e.getY(n)};F(e,n,l,r)}return l}(l,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const l=e.getColor?e.resolveColorMap(t):null;for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(a=i(t))}if(l&&e.getColor&&!t.fill){const n=e.getColor(o);n&&l.has(n)&&(t=Object.assign(Object.assign({},t),{fill:l.get(n)}))}const s=e.getPointId?e.getPointId(o)+"":void 0,c=z(o,e.scales,e.getX,e.getY,a,t,s);c&&n.push(c)}return n}(l,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var r,o,i;const l=Math.max(1,Math.floor(null!==(r=e.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(o=e.config.heatmapYBins)&&void 0!==o?o:20)),s=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=M(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,f]=e.scales.y.domain(),y=(d-u||1)/l,g=(f-h||1)/a,p=l*a;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;t.length>n;n++){const r=t[n],o=e.getX(r),i=e.getY(r);if(!isFinite(o)||!isFinite(i))continue;const s=Math.min(Math.floor((o-u)/y),l-1),d=Math.min(Math.floor((i-h)/g),a-1);if(0>s||0>d)continue;const f=d*l+s;v[f]++;const p=c(r);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let e=0;p>e;e++){if(0===v[e])continue;let t;switch(s){case"sum":t=m[e];break;case"mean":t=m[e]/v[e];break;default:t=v[e]}x>t&&(x=t),t>b&&(b=t)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,E=n.height/a,A=e.config.showValues,S=e.config.heatmapValueFormat,P=[];for(let e=0;a>e;e++){const t=e*l;for(let n=0;l>n;n++){const r=t+n;if(0===v[r])continue;let o;switch(s){case"sum":o=m[r];break;case"mean":o=m[r]/v[r];break;default:o=v[r]}const i=(o-x)/k;P.push(B(n*w,(a-1-e)*E,w,E,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:o,count:v[r],sum:m[r]},A?{value:o,showValues:!0,valueFormat:S}:void 0))}}return P}(e,t,n);if(0===t.length)return[];const r=M(e.config.valueAccessor,"value"),o=S(e.config.xAccessor,"x"),l=S(e.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),i=l(n);c[e]=r,u[e]=i,a.has(r)||a.set(r,a.size),s.has(i)||s.set(i,s.size)}const d=a.size,h=s.size;if(0===d||0===h)return[];const f=Array.from(a.keys()),y=Array.from(s.keys()),g=f.every(e=>"number"==typeof e&&!isNaN(e)),p=y.every(e=>"number"==typeof e&&!isNaN(e));if(g){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}if(p){y.sort((e,t)=>e-t),s.clear();for(let e=0;y.length>e;e++)s.set(y[e],e)}const v=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),b=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],o=a.get(c[e]),i=s.get(u[e]);if(void 0===o||void 0===i)continue;const l=r(n),h=i*d+o,f=b.get(h);let y;void 0!==f?y=f:(y=k++,b.set(h,y)),v[y]=h,m[y]=l,x[y]=n}let w=1/0,E=-1/0;for(let e=0;k>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>E&&(E=t))}if(!isFinite(w)||!isFinite(E))return[];const A=function(e){const t=e in Y?e:"blues";let n=H.get(t);if(n)return n;n=Array(256);const r=Y[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=r(e/255);return H.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),P=255/(E-w||1),_=n.width/d,C=n.height/h,T=e.config.showValues,D=e.config.heatmapValueFormat,L=[];for(let e=0;k>e;e++){const t=m[e];if(!isFinite(t))continue;const n=v[e],r=n%d;L.push(B(r*_,(h-1-(n-r)/d)*C,_,C,A[Math.min((t-w)*P+.5|0,255)],x[e],T?{value:t,showValues:!0,valueFormat:D}:void 0))}return L}(l,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const r=E(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(e.getCategory){const t=new Set;for(const e of r.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),l=Array.from(t).filter(e=>!i.has(e)).sort(),a=n.filter(e=>t.has(e)),s=a.join("\0")+""+l.join("\0");e.barCategoryCache&&e.barCategoryCache.key===s?o=e.barCategoryCache.order:(o=[...a,...l],e.barCategoryCache={key:s,order:o})}const i=[],l=e.scales,[a,s]=l.x.domain();for(const t of r.values()){const r=Math.max(t.start,a),c=Math.min(t.end,s);if(r>=c)continue;const u=l.x(r),d=l.x(c),h=Math.abs(d-u),f=h>2?1:0,y=Math.min(u,d)+f/2,g=Math.max(h-f,1);if(g>0)if(o&&t.categories.size>0){let r=0;for(const a of o){const o=t.categories.get(a)||0;if(0===o)continue;const s=l.y(r),c=l.y(r+o);i.push(R(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:o},a)),r+=o}}else{const e=l.y(0),n=l.y(t.total);i.push(R(y,Math.min(e,n),g,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of r.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(l,t);return this._barCategoryCache=null!==(n=l.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,r,o,i;const l=[],a=e.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),r=e.getY(n);if(null==r||Number.isNaN(r))continue;const o=e.scales.x(t),a=e.scales.y(r);let f=c;if(e.getCategory){const t=e.getCategory(n);f=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||f}const y={type:"point",x:o,y:a,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(y.pointId=e.getPointId(n)+""),l.push(y)}return l}(l,t);case"waterfall":return function(e,t,n){var r,o,i;const l=[],a=e.scales,s=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",d=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let t=0;c.length>t;t++){const r=c[t],o=e.getX(r),i=e.getY(r),p=g+i;let v;v=c.length-1>t?e.getX(c[t+1])-o:t>0?o-e.getX(c[t-1]):0;const m=a.x(o),x=0!==v?a.x(o+v):m+n.width/10,b=Math.min(m,x)+h/2,k=Math.max(m,x)-h/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(R(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>i?d:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(l,t,e);case"candlestick":return function(e,t){var n,r;if(!e.getHigh||!e.getLow||!e.scales)return[];const o=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||e.getOpen&&e.getClose))return[];const i=[],l=e.config.candlestickStyle||{},a=l.rangeColor||"#6366f1",s=o?a:l.upColor||"#28a745",c=o?a:l.downColor||"#dc3545",u=o?a:l.wickColor||"#333",d=l.wickWidth||(o?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let f=o?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!o&&null==l.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));r>0&&t>r&&(t=r)}f=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else o||null!=l.bodyWidth||(f=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const r=e.getHigh(n),l=e.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=o?r:e.getOpen(n),h=o?l:e.getClose(n);if(!o&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const y=h>=a,g={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(r),lowY:e.scales.y(l),bodyWidth:f,upColor:s,downColor:c,wickColor:u,wickWidth:d,isUp:y,datum:n};o&&(g.isRange=!0),i.push(g)}return i}(l,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?T(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var r,o;const i=n.length;if(1>=i)return;const l=new Map;for(let e=0;n.length>e;e++)l.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const r=Array(t.length);let o=!1;for(let n=0;t.length>n;n++){const a=l.get(t[n]);null!=a?(r[n]=T(e,a,i),1>r[n]&&(o=!0)):r[n]=1}o&&(n._decayOpacities=r);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:t.length;if(2>r)continue;if(t.length===r){const o=Array(r);let a=!1;for(let n=0;t.length>n;n++){const r=l.get(t[n]);null!=r?(o[n]=T(e,r,i),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of t){const t=l.get(n);if(null!=t){const n=T(e,t,i);o>n&&(o=n)}}if(1>o){const e=Array(r);e.fill(o),n._decayOpacities=e}}continue}const t=l.get(n.datum);if(null==t)continue;const a=T(e,t,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(o=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,r){var o,i;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=e.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",s=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=r.get(t);if(null==i)continue;const a=D(e,i,l);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=r.get(t);if(null==o)continue;const i=D(e,o,l);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&o>r-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){var o,i,l;n.clear(),r.clear();for(let a=0;t.length>a;a++){const s=t[a],c=O(e,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(e=>[e[0],e[1]]),opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(e=>[e[0],e[1]]),bottomPath:s.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o){var i,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M,S,P,_,C,T,D,L;if(0===r.size&&0===o.size)return n;const N=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let I=!1;const $=new Set,W=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],E=O(e,i,t);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const e=o.get(E);if(e){if(W.add(E),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];I=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];I=!0}i._targetOpacity=null!==(l=i.style.opacity)&&void 0!==l?l:1,i._startOpacity=null!==(s=null!==(a=e.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==s?s:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),I=!0;continue}const A=r.get(E);if("point"===i.type)if(A){$.add(E);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,A.x===e.x&&A.y===e.y&&A.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=A.x,i.y=A.y,i.r=null!==(d=A.r)&&void 0!==d?d:i.r,I=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),I=!0;else if("rect"===i.type)if(A){$.add(E);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(f=i.style.opacity)&&void 0!==f?f:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=A.x,i.y=A.y,i.w=null!==(y=A.w)&&void 0!==y?y:i.w,i.h=null!==(g=A.h)&&void 0!==g?g:i.h,I=!0)}else i._targetOpacity=null!==(p=i.style.opacity)&&void 0!==p?p:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),I=!0;else if("heatcell"===i.type)if(A){$.add(E);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(m=null===(v=i.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=A.x,i.y=A.y,i.w=null!==(x=A.w)&&void 0!==x?x:i.w,i.h=null!==(b=A.h)&&void 0!==b?b:i.h,I=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),I=!0}for(const[e,t]of o)if(!W.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),I=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),I=!0}for(const[e,t]of r)if(!$.has(e)){if(e.startsWith("p:")){const r={type:"point",x:t.x,y:t.y,r:null!==(M=t.r)&&void 0!==M?M:3,style:{opacity:null!==(S=t.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("r:")){const r={type:"rect",x:t.x,y:t.y,w:null!==(P=t.w)&&void 0!==P?P:0,h:null!==(_=t.h)&&void 0!==_?_:0,style:{opacity:null!==(C=t.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("h:")){const r={type:"heatcell",x:t.x,y:t.y,w:null!==(T=t.w)&&void 0!==T?T:0,h:null!==(D=t.h)&&void 0!==D?D:0,fill:"#999",datum:null,style:{opacity:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}I=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),I&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:N}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){var o,i,l,a,s;if(!n.activeTransition)return!1;const c=N(e,n.activeTransition),u=L(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=I(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=I(n.x,e._targetX,u),e.y=I(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=I(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=I(o,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=I(n.x,e._targetX,u),e.y=I(n.y,e._targetY,u),void 0!==n.w&&(e.w=I(n.w,e._targetW,u)),void 0!==n.h&&(e.h=I(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:I(o,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=I(n.x,e._targetX,u),e.y=I(n.y,e._targetY,u),void 0!==n.w&&(e.w=I(n.w,e._targetW,u)),void 0!==n.h&&(e.h=I(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:I(t,e._targetOpacity,u)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=I(t[r][0],n[r][0],u),e.path[r][1]=I(t[r][1],n[r][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(s=e._startOpacity)&&void 0!==s?s:0;e.style=Object.assign(Object.assign({},e.style),{opacity:I(t,e._targetOpacity,u)})}const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=I(t[n][0],r[n][0],u),e.topPath[n][1]=I(t[n][1],r[n][1],u);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=I(n[t][0],o[t][0],u),e.bottomPath[t][1]=I(n[t][1],o[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],o[e%o.length]);return this._colorMapCache={key:r,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const r=n(t||{},e);if(r&&!r.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},r),{stroke:t})}return r}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const o=this.resolveGroupColor(e)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:C,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,r=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{r(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const e of o)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(e)),t);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,r,o;const i=Object.assign({},this.config);void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null);let l=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(a||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const s=a||!A(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!A(null!==(r=e.yAccessor)&&void 0!==r?r:e.valueAccessor,null!==(o=i.yAccessor)&&void 0!==o?o:i.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=M(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=M(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=M(this.config.xAccessor,"x"),this.getY=M(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in e&&!A(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?P(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in e&&!A(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?P(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in e&&!A(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?M(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in e&&!A(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?P(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in e&&!A(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?M(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in e&&!A(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?P(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!A(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!A(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!A(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!A(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?M(this.config.openAccessor,"open"):void 0,this.getHigh=M(this.config.highAccessor,"high"),this.getLow=M(this.config.lowAccessor,"low"),this.getClose=t?M(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,l=!0}if(!l){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function G(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function V(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function q(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function U(e,t){const n=q(e);if(!n)return!1;const r=q(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function K(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Z(e,t,n,r=30,o){let i=null,l=!1;if(o){const e=o.find(t,n,r);if(e){const o=J(e,t,n,r);o&&r>o.distance&&(i=o,l=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(o&&l)break;e=J(a,t,n,r);break;case"line":e=ee(a,t,n,r);break;case"rect":e=ne(a,t,n);break;case"heatcell":e=re(a,t,n);break;case"area":if(!1===a.interactive)break;e=ie(a,t,n);break;case"candlestick":e=oe(a,t,n)}e&&r>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function Q(e,t,n){if(0===e.length)return null;const r=le(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[l,a]=e[o],[s,c]=e[i];return s===l?a:a+Math.max(0,Math.min(1,(t-l)/(s-l)))*(c-a)}function J(e,t,n,r=30){const o=t-e.x,i=n-e.y,l=Math.sqrt(o*o+i*i);return l>V(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:l}}function ee(e,t,n,r=30){var o,i,l,a;if(0===e.path.length)return null;const s=le(e.path,t);if(0>s)return null;const[c,u]=e.path[s];let d;if(e.path.length>1){let r=1/0;const o=Math.max(0,s-1),i=Math.min(e.path.length-2,s);for(let l=o;i>=l;l++){const[o,i]=e.path[l],[a,s]=e.path[l+1],c=te(t,n,o,i,a,s);r>c&&(r=c)}d=r}else{const e=t-c,r=n-u;d=Math.sqrt(e*e+r*r)}const h=null!==(a=null!==(i=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(l=e.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:c,y:u,distance:d}}function te(e,t,n,r,o,i){const l=o-n,a=i-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-r,2));let c=((e-n)*l+(t-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function ne(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function re(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function oe(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,l=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+l*l)}}return null}function ie(e,t,n){if(0===e.topPath.length)return null;const r=le(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],l=t-o,a=n-i,s=Math.sqrt(l*l+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:s}}function le(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ae(e){var t,n;const r=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let o=r.get(e);o||(o=[],r.set(e,o)),o.push(n)}for(const e of r.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(r.keys()).sort((e,t)=>{const n=r.get(e),o=r.get(t);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const l=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&l.set(t+"",e)}return{flat:i,groups:o,byGroup:r,idToIdx:l}}function se(e,t){var n,r;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}function ce(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?ue(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?ue(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function ue(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function de(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function he(t,n,r){const o=e.useRef(null),[i,l]=e.useState(null);return e.useEffect(()=>{if(!n&&!r)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,r]),[o,[n&&i?i.w:t[0],r&&i?i.h:t[1]]]}function fe(t,n,r,o,i,l){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-a.lastIngestTime>c;u!==i&&(l(u),r.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}X.QUADTREE_THRESHOLD=500;const ye={fill:e=>g.createElement("rect",{style:e,width:16,height:16}),line:e=>g.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function ge(e,t,n,r){let o;return o="function"==typeof n?n(e):(0,ye[n])(r(e,t)),o}function pe(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ve(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function me({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:l}=e,a=l||(e=>Math.round(100*e)/100+""),s="grad-legend-"+g.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&g.createElement("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("rect",{x:l,y:0,width:t,height:e,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])),g.createElement("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))}))}return g.createElement("g",{"aria-label":i||"Gradient legend"},i&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(o[0])))}function xe(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:l,title:a="Legend",width:s=100,height:c=20,orientation:u="vertical"}=e,[d,h]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((e,t)=>{h(e),y(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(g.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(g.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,r,o,i,l,a,s,c)=>{const{type:u="fill",styleFn:d,items:h}=e,f=[];let y=0;const p=!(!t&&!n),v="isolate"===c||void 0===c&&null!=o;return h.forEach((e,c)=>{const m=ge(e,c,u,d),x=ve(e,r,o),b=o&&o.size>0&&o.has(e.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?a===i&&c===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(pe,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),f})(e,n,r,o,i,l,a,h,s,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const y=((e,t,n,r,o,i,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,y=[];let p=0,v=0;const m=!(!t&&!n),x="isolate"===c||void 0===c&&null!=o;f.forEach((e,c)=>{const b=ge(e,c,d,h),k=ve(e,r,o),w=o&&o.size>0&&o.has(e.label),E=26+7*e.label.length;u&&u>0&&p>0&&p+E>u&&(v++,p=0),y.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},${22*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?a===i&&c===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:m?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:m?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&g.createElement(pe,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),p+=E});let b=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(b=Math.max(b,k),k=t):k+=t}b=Math.max(b,k);const w=v+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,r,o,i,l,a,s,t,c,u,n);f+=y.offset+5,h.push(Object.assign(Object.assign({label:e.label},y),{offset:f,totalRows:y.totalRows,totalHeight:y.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const y=[];return h.forEach((n,r)=>{const o=e[r];o.label&&(y.push(g.createElement("text",{key:"legend-text-"+r,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[r+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}),m=!(!n&&!r);return g.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==l&&(void 0!==l||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==a&&""!==a&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),v)}function be(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",title:l,legendHoverBehavior:a,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i;let f,y;return"left"===i?(f=4,y=o.top):"top"===i?(f=0,y=l?32:8):"bottom"===i?(f=0,y=r-o.bottom+50):(f=n-o.right+10,y=o.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?g.createElement(me,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?g.createElement(xe,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function ke(e){return"string"==typeof e?{type:e}:e}function we({orient:t,config:n,values:r,scale:o,size:i,length:a}){const s=function(e){var t,n,r,o,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=e.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(o=e.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===r.length)return null;const e=o.domain(),n=i-8;if("boxplot"===s.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],l=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*l),whiskerHigh:Math.min(t[n-1],i+1.5*l)}}(r);if(!e)return null;const{q1:i,median:l,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),f=(n-h)/2+4;if(c){const e=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="top"===t?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:c,y1:v+p*(f+h/2),x2:y,y2:v+p*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:v+p*f,x2:c,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:v+p*f,x2:y,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(e,n),y:"top"===t?v-f-h:v+f,width:Math.abs(n-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:r,y1:"top"===t?v-f-h:v+f,x2:r,y2:"top"===t?v-f:v+f+h,stroke:s.fill,strokeWidth:2}))}{const e=o(i),n=o(a),r=o(l),c=o(u),y=o(d),p="left"===t?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:v+p*(f+h/2),y1:c,x2:v+p*(f+h/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:c,x2:v+p*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:y,x2:v+p*(f+h),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===t?v-f-h:v+f,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===t?v-f-h:v+f,y1:r,x2:"left"===t?v-f:v+f+h,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=l.bin().domain(e).thresholds(s.bins)(r);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return g.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,r)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=o(e.x0),l=o(e.x1)-o(e.x0);return g.createElement("rect",{key:r,x:n,y:"top"===t?-4-i:4,width:Math.max(l,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(e.x0),l=o(e.x1)-o(e.x0);return g.createElement("rect",{key:r,x:"left"===t?-4-i:4,y:Math.min(n,n+l),width:i,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const e=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const l=i.length/d*(n/2),a=o((i.x0+i.x1)/2);r.push(c?`${a},${"top"===t?-(e-l):e-l}`:`${"left"===t?-(e-l):e-l},${a}`)}for(let i=u.length-1;i>=0;i--){const l=u[i];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(n/2),s=o((l.x0+l.x1)/2);r.push(c?`${s},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+t},g.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const e=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/d*n,l=o((r.x0+r.x1)/2);e.push(`L${l},${"top"===t?-i-4:i+4}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;e.push(`L${l},${r}`),e.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/d*n,l=o((r.x0+r.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${l}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;e.push(`L${r},${l}`),e.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+t},g.createElement("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,i,a,t,c,4]);return u?g.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Ee(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let l="";for(const e of o)l&&l.length+1+e.length>r?(i.push(l),l=e):l=l?`${l} ${e}`:e;return l&&i.push(l),i}function Ae(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Me(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:l,note:a,connector:s,subject:c,type:u,color:d,className:h,disable:f,events:y={},"data-testid":p}=e,v=new Set(Array.isArray(f)?f:[]);let m=r||0,x=o||0;null!=i&&(m=i-t),null!=l&&(x=l-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===m&&0===x)if(void 0!==c.width){m=c.width/2;const e=c.depth||30;x=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;m=e+(0>e?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},y),!v.has("connector")&&function(e,t,n,r,o,i){const l=[];let a=0,s=0;if("callout-circle"!==o&&"label"!==o||!(null==i?void 0:i.radius)){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,l=e-o,c=t-i;if(0!==l||0!==c){const e=Math.abs(l),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;a=o+l*h,s=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,s=n):void 0!==t&&(a=n,s=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-s,2))>.5&&(l.push(g.createElement("line",{key:"connector-line",x1:a,y1:s,x2:e,y2:t,stroke:r||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,o=16/180*Math.PI,i=Math.atan2(t-s,e-a);l.push(g.createElement("path",{key:"connector-arrow",d:`M${a},${s}L${a+n*Math.cos(i+o)},${s+n*Math.sin(i+o)}L${a+n*Math.cos(i-o)},${s+n*Math.sin(i-o)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},l)}(m,x,s,d,b,c),!v.has("subject")&&function(e,t,n,r,o){var i;const l=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&l.push(g.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,r=(null==t?void 0:t.height)||0;(e>0||r>0)&&l.push(g.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&l.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,i=o||0;if(void 0!==(null==t?void 0:t.x)){const r=(t.x||0)-e;l.push(g.createElement("line",{key:"threshold-line",x1:r,y1:(t.y1||0)-i,x2:r,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const r=(t.y||0)-i;l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||l.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&l.push(g.createElement("path",{key:"bracket-path",d:Ae((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return g.createElement("g",{className:"annotation-subject"},l)}(b,c,d,t,n),!v.has("note")&&function(e,t,n,r){if(!e)return g.createElement("g",{className:"annotation-note"});const{label:o,title:i,orientation:l,align:a,wrap:s=120,noWrap:c}=e;if(!o&&!i)return g.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,y=i?c?[i]:Ee(i,s):[],p=o?c?[o]:Ee(o,s):[],v="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold"},y.map((e,t)=>g.createElement("tspan",{key:t,x:v,dy:0===t?0:f},e)))),m=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:h,y:m},p.map((e,t)=>g.createElement("tspan",{key:t,x:v,dy:0===t?0:f},e))));let k=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(s,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*f;let E=0;return"topBottom"===u?E=0>n?-(w+2):18:"leftRight"===u&&(E="middle"===d?-(w+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(a,m,x,d))}function Se(e){var t,n;const{noteData:r}=e,{screenCoordinates:o}=r,i="string"==typeof r.type?r.type:"label",l=r.eventListeners||r.events||{};if(r.coordinates&&o){const e=r.nx||o[0][0]+(null!==(t=r.dx)&&void 0!==t?t:0),l=r.ny||o[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),a=o.map((t,n)=>{const o=Object.assign({},r,{note:0===n?r.note:{label:""},x:t[0],y:t[1],nx:e,ny:l});return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},o,{type:i}))});return g.createElement("g",null,a)}const a=r.note||{title:"none",label:r.label};return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${r.i}`,events:l},r,{type:i}))}function Pe(e,t){var n,r,o;const i=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(o=t.scales)||void 0===o?void 0:o.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function _e(e,t){var n,r,o;const i=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(o=t.scales)||void 0===o?void 0:o.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Ce(e,t,n){var r,o,i,l;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,e),e}}const i=function(e){var t,n,r,o,i,l;const a=e.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(r=e.scales)||void 0===r?void 0:r.time,u=null!==(i=null===(o=e.scales)||void 0===o?void 0:o.y)&&void 0!==i?i:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[e.xAccessor||"x"],h=s[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(t,i)),i}let s=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,c=t.y)}if(null!=s&&null!=c||(s=Pe(e,n),c=_e(e,n)),null!=s&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function Te(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}const De={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let Le={positions:new Map};const Ne=new Set;function Ie(){for(const e of Ne)e()}function Oe(e,t){const n=Le.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Le.positions);r.delete(e),Le={positions:r},Ie()}function $e(e,t){const n=Le.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const r=new Map(Le.positions);r.delete(e),Le={positions:r},Ie()}function We(){return Le}function ze(e){return Ne.add(e),()=>Ne.delete(e)}const Re={positions:new Map};function Be(){return()=>{}}function je(){return Re}function Fe(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ye(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let l="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${r+4*o}`,l+=`L${Math.min(n,t)},${r}`}return l}{const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let l=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);l+=`L${r+4*o},${Math.min(8*e+4,n)}`,l+=`L${r},${Math.min(t,n)}`}return l}}function He(t){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,scales:a,showAxes:s,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,f=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=(null==t?void 0:t.tickFormat)||d||Xe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=a.x.ticks(Math.min(o,Math.max(2,Math.floor(n/70)))),l=i.map(e=>e.valueOf()),s=i.map((e,t)=>({value:e,pixel:a.x(e),label:r(e,t,l)})),u=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Ge(s,Math.max(55,u+8))},[a,c,d,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||Xe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Ge(a.y.ticks(Math.min(o,Math.max(2,Math.floor(r/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)})),22)},[a,c,h,r]),p=u&&a,v=s&&a;if(!p&&!v)return null;const m=null==c?void 0:c.find(e=>"bottom"===e.orient),x=null==c?void 0:c.find(e=>"left"===e.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return g.createElement("svg",{width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&(()=>{var e,t;const o=Fe(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Fe(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},f.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})),y.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),b&&!w&&g.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:Ye("bottom",n,r),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:Ye("left",n,r),fill:"none",stroke:A,strokeWidth:1})))}function Xe(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Ge(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ve(t){var n,r;const{width:o,height:i,totalWidth:l,totalHeight:c,margin:u,scales:d,showAxes:h,axes:f,xLabel:y,yLabel:v,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P,legendPosition:_="right",foregroundGraphics:C,marginalGraphics:T,xValues:D,yValues:L,annotations:N,svgAnnotationRules:I,xAccessor:O,yAccessor:$,annotationData:W,pointNodes:z,curve:R,underlayRendered:B,linkedCrosshairName:j,linkedCrosshairSourceId:F,children:Y}=t,H=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Xe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=d.x.ticks(Math.min(r,Math.max(2,Math.floor(o/70)))),l=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:d.x(e),label:n(e,t,l)})),s=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Ge(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),r=u[u.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,u.length,l);c>t-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:o})}}return u},[h,d,f,x,o]),X=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||Xe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let o=Ge(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(o.length>1&&(o=o.filter((e,t)=>0===t||e.label+""!=o[t-1].label+"")),(null==t?void 0:t.includeMax)&&o.length>0){const e=d.y.domain()[1],t=d.y(e),r=o[o.length-1].pixel;if(Math.abs(t-r)>1){const i=n(e);22>Math.abs(t-r)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:e,pixel:t,label:i})}}return o},[h,d,f,b,i]),G=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||b||Xe,r=null!==(e=t.ticks)&&void 0!==e?e:5;return Ge(d.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[h,d,f,b,i]),V=e.useRef(new Map),q=e.useRef(null!==(n=null==N?void 0:N.length)&&void 0!==n?n:0),K=null!==(r=null==N?void 0:N.length)&&void 0!==r?r:0;q.current!==K&&(q.current=K,V.current=new Map);const Z=e.useMemo(()=>{if(!N||0===N.length)return null;const e=function(e,t,n){var r,o,i,l,c,u,d,h,f,y,v,m,x,b,k,w,E,A,M,S,P,_,C,T,D,L,N,I,O,$,W,z,R,B,j,F,Y,H,X,G,V,q,U,K,Z,Q,J,ee;switch(e.type){case"label":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return Te(o,i,n)?g.createElement(Se,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return Te(o,i,n)?g.createElement(Se,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const r=Pe(e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let l;return l="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:r+4,y:l,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const r=_e(e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let l,a;return"left"===i?(l=4,a="start"):"center"===i?(l=(n.width||0)/2,a="middle"):(l=(n.width||0)-4,a="end"),g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:l,y:r-4,textAnchor:a,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const r=(e.coordinates||[]).map(e=>({x:Pe(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=a.packEnclose(r),i=e.padding||10;return g.createElement("g",{key:"ann-"+t},g.createElement("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const r=(e.coordinates||[]).map(e=>({x:Pe(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=e.padding||10,i=r.map(e=>e.x),l=r.map(e=>e.y),a=Math.min(...i)-o,s=Math.max(...i)+o,c=Math.min(...l)-o,u=Math.max(...l)+o;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:a,y:c,width:s-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:(a+s)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const r=n.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+t},o.map((t,r)=>{const o=Pe(t,n),l=_e(t,n);if(null==o||null==l)return null;const a="function"==typeof e.r?e.r(t):e.r||6,s="function"==typeof e.style?e.style(t):e.style||i;return g.createElement("circle",Object.assign({key:"hl-"+r,cx:o,cy:l,r:a},s))}))}case"bracket":{const r=Pe(e,n),o=_e(e,n);return g.createElement(Se,{key:"ann-"+t,noteData:{x:null!=r?r:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const s=n.xAccessor||"x",h=n.yAccessor||"y",f=a.map(e=>[e[s],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(o=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==o?o:null===(i=n.scales)||void 0===i?void 0:i.time,v=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!v)return null;const m=e.method||"linear";let x;x="loess"===m?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),s=r.slice().sort((e,t)=>e-t)[Math.min(l-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===s?0:r[e]/s;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([t,h/u]);else{const e=(u*y-d*h)/g;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?p.default.polynomial(f,{order:e.order||2}):p.default.linear(f)).points;const b=x.map(([e,t])=>`${y(e)},${v(t)}`).join(" "),k=e.color||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const r=null!==(f=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,o=null!==(v=null==r?void 0:r(e.y0))&&void 0!==v?v:0,i=null!==(m=null==r?void 0:r(e.y1))&&void 0!==m?m:n.height||0;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(o,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,l=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!i||!l)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=r.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[o]-t[o]);if(2>d.length)return null;const h=De[n.curve||"linear"]||s.curveLinear,f=s.area().x(e=>i(e[o])).y0(e=>l(e[c])).y1(e=>l(e[a])).curve(h)(d);if(!f)return null;const y=e.fill||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&d.length>0&&g.createElement("text",{x:i(d[d.length-1][o])+4,y:l(d[d.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=null!==(P=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.time,l=null!==(T=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==T?T:null===(D=n.scales)||void 0===D?void 0:D.value;if(!i||!l)return null;const a=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const s=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-s,2),0)/a.length,u=Math.sqrt(c),d=null!==(L=e.threshold)&&void 0!==L?L:2,h=s-d*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(N=e.fillOpacity)&&void 0!==N?N:.1,v=e.anomalyColor||"#ef4444",m=null!==(I=e.anomalyRadius)&&void 0!==I?I:6,x=l(s+d*u),b=l(h),k=r.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-s)>d*u});return g.createElement("g",{key:"ann-"+t},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,t)=>{const r=Pe(e,n),o=_e(e,n);return null==r||null==o?null:g.createElement("circle",{key:"anomaly-"+t,cx:r,cy:o,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",l=null!==($=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==$?$:null===(W=n.scales)||void 0===W?void 0:W.time,a=null!==(R=null===(z=n.scales)||void 0===z?void 0:z.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!l||!a)return null;const s=r.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>s.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=p.default.polynomial(s,{order:e.order||2}).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=s.length;let t=0,n=0,r=0,o=0;for(const[e,i]of s)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const l=(e*o-t*n)/i,a=(n-l*t)/e;c=e=>a+l*e}const u=s.length,d=s.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=s.reduce((e,t)=>e+t[0],0)/u,y=s.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),v=null!==(j=e.confidence)&&void 0!==j?j:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(F=e.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let e=1;x>=e;e++)w.push(b+e*k);const E=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(y>0?Math.pow(e-f,2)/y:0))*m;E.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${E.map(e=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${E.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=E.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(c(b))}`,P=e.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(Y=e.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&E.length>0&&g.createElement("text",{x:l(E[E.length-1].x)+4,y:a(E[E.length-1].yCenter)-4,fill:P,fontSize:11},e.label))}case"widget":{let r=null,o=null;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{const i=Ce(e,t,n);if(!i)return null;r=i.x,o=i.y}if(null==r||null==o)return null;if(!Te(r,o,n))return null;const i=null!==(G=e.dx)&&void 0!==G?G:0,l=null!==(V=e.dy)&&void 0!==V?V:0,a=null!==(q=e.width)&&void 0!==q?q:32,s=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+t,x:r+i-a/2,y:o+l-s/2,width:a,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:a,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const r=Ce(e,t,n);if(!r)return null;const{x:o,y:i}=r;return g.createElement("text",{key:"ann-text-"+t,x:o+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const r=e.category;if(null==r)return null;const o=null===(Z=n.scales)||void 0===Z?void 0:Z.o,i=null===(Q=n.scales)||void 0===Q?void 0:Q.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,a=(null==o?void 0:o.bandwidth)?o:(null==i?void 0:i.bandwidth)?i:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const s=a(r);if(null==s)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,h=e.label;return(n.projection?"vertical"===n.projection:a===i)?g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:s,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:s+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},h)):g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:s,width:n.width||0,height:c,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:12,y:s+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},h))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:O,yAccessor:$,width:o,height:i,data:W,frameType:"xy",pointNodes:z,curve:R,stickyPositionCache:V.current};return N.map((n,r)=>{if(I){const o=I(n,r,t);return null!=o?o:e(n,r,t)}return e(n,r,t)}).filter(Boolean)},[N,I,o,i,O,$,W,d,z,R]),Q=function(t){var n;const r=e.useSyncExternalStore(t?ze:Be,t?We:je,t?We:je);return t&&null!==(n=r.positions.get(t))&&void 0!==n?n:null}(j);return e.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!j)return;const e=e=>{"Escape"===e.key&&$e(j)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==Q?void 0:Q.locked,j]),h||w||E||C||T||Z&&Z.length>0||k||Y||Q?g.createElement("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},g.createElement("title",null,"string"==typeof w?w:"XY Chart"),g.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!B&&(()=>{var e,t;const n=Fe(null===(e=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),r=Fe(null===(t=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},H.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),X.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})))})(),h&&d&&(()=>{const e=null==f?void 0:f.find(e=>"left"===e.orient),t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,r=!t||!1!==t.baseline,l=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",x=!!(null==t?void 0:t.autoRotate)&&H.length>1&&(()=>{const e=o/Math.max(H.length-1,1);return H.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&r&&!a&&g.createElement("line",{x1:0,y1:i,x2:o,y2:i,stroke:d,strokeWidth:1}),!B&&a&&g.createElement("path",{d:Ye("bottom",o,i),fill:"none",stroke:d,strokeWidth:1}),H.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):U(e.value,t>0?H[t-1].value:void 0));return g.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},g.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0},e.label):g.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&g.createElement("text",{x:o/2,y:i+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},y),!B&&n&&!l&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:d,strokeWidth:1}),!B&&l&&g.createElement("path",{d:Ye("left",o,i),fill:"none",stroke:d,strokeWidth:1}),X.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):U(e.value,t>0?X[t-1].value:void 0));return g.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},g.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||v;return t?g.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==f?void 0:f.find(e=>"right"===e.orient);if(!e||0===G.length)return null;const t=e.landmarkTicks,n=e.label||m;return g.createElement(g.Fragment,null,!1!==e.baseline&&g.createElement("line",{x1:o,y1:0,x2:o,y2:i,stroke:d,strokeWidth:1}),G.map((e,n)=>{const r=!!t&&("function"==typeof t?t(e.value,n):U(e.value,n>0?G[n-1].value:void 0));return g.createElement("g",{key:"ytick-r-"+n,transform:`translate(${o},${e.pixel})`},g.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&g.createElement("text",{x:o+u.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${o+u.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),Z,T&&d&&D&&L&&g.createElement(g.Fragment,null,T.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(we,{orient:"top",config:ke(T.top),values:D,scale:d.x,size:u.top,length:o})),T.bottom&&g.createElement("g",{transform:`translate(0, ${i})`},g.createElement(we,{orient:"bottom",config:ke(T.bottom),values:D,scale:d.x,size:u.bottom,length:o})),T.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(we,{orient:"left",config:ke(T.left),values:L,scale:d.y,size:u.left,length:i})),T.right&&g.createElement("g",{transform:`translate(${o}, 0)`},g.createElement(we,{orient:"right",config:ke(T.right),values:L,scale:d.y,size:u.right,length:i}))),C,Q&&Q.sourceId!==F&&(null==d?void 0:d.x)&&(()=>{const e=d.x(Q.xValue);if(null==e||0>e||e>o)return null;const t=Q.locked;return g.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),Y),w&&g.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),be({legend:E,totalWidth:l,totalHeight:c,margin:u,legendPosition:_,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P})):null}function qe(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Ue="undefined"==typeof window||"undefined"==typeof document,Ke=g.createContext(null);function Ze(){return g.useContext(Ke)}const Qe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Je(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of l)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function et(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const tt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},nt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},rt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ot={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},it={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},lt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},at={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},st={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function ct({scene:e,chartType:t,tableId:n,chartTitle:r}){var o;const[i,l]=g.useState(!1),a=Ze(),s=null!==(o=null==a?void 0:a.visible)&&void 0!==o&&o,c=i||s,u=g.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t,h=g.useCallback(()=>{i||s||l(!0)},[i,s]),f=g.useCallback(e=>{var t;s||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||l(!1)},[s]);if(!e||0===e.length)return n?g.createElement("span",{id:n,tabIndex:-1,style:Qe}):null;if(!c)return g.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:Qe,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>l(!0)},"View data summary (",e.length," elements)"));const y=function(e){var t,n,r,o,i,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(e))return S;for(const P of e)if(P&&"object"==typeof P)try{switch(P.type){case"point":S.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const e=P.path,t=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=P.topPath,t=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=P.datum&&"object"==typeof P.datum?P.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(r=e.value)&&void 0!==r?r:e.__aggregateValue)&&void 0!==o?o:e.total;S.push({label:"Bar",values:{category:i,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(i=P.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:null===(a=P.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(y=P.cy)&&void 0!==y?y:P.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=P.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m:P.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=P.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(e){}return S}(e),p=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),v=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${tt(e.min)} to ${tt(e.max)}, mean ${tt(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(y.length,p),m=y.slice(0,5),x=new Set;for(const e of m)for(const t of Object.keys(e.values))x.add(t);const b=Array.from(x);return g.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:nt,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>{s&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:ot},"×"),g.createElement("div",{role:"note",style:rt},v),g.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:it},g.createElement("caption",{style:st},"First ",m.length," of ",y.length," data points"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:lt},"type"),b.map(e=>g.createElement("th",{key:e,style:lt},e)))),g.createElement("tbody",null,m.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:at},e.label),b.map(t=>{return g.createElement("td",{key:t,style:at},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":tt(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function ut({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){var i,l,a,s,c,u,d,h,f,y,p,v,m,x;const[b,k]=g.useState(!1),w=Ze(),E=null!==(i=null==w?void 0:w.visible)&&void 0!==i&&i,A=b||E,M=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,S=g.useRef(null),P=g.useCallback(()=>{b||E||k(!0)},[b,E]),_=g.useCallback(e=>{var t;E||(null===(t=S.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return r?g.createElement("span",{id:r,tabIndex:-1,style:Qe}):null;if(!A)return g.createElement("div",{id:r,tabIndex:-1,onFocus:P,style:Qe,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],T=Array.isArray(t)?t:[],D=new Map,L=new Map,N=new Map,I=new Map;for(const e of T){if(!e||"object"!=typeof e)continue;const t=null!==(l=e.datum)&&void 0!==l?l:e,n="object"==typeof t.source?null===(a=t.source)||void 0===a?void 0:a.id:t.source,r="object"==typeof t.target?null===(s=t.target)||void 0===s?void 0:s.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";L.set(e,(null!==(c=L.get(e))&&void 0!==c?c:0)+1),I.set(e,(null!==(u=I.get(e))&&void 0!==u?u:0)+o)}if(null!=r&&""!==r){const e=r+"";D.set(e,(null!==(d=D.get(e))&&void 0!==d?d:0)+1),N.set(e,(null!==(h=N.get(e))&&void 0!==h?h:0)+o)}}const O=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(y=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:t.id,r=null!=n?n+"":"node-"+e,o=null!==(p=D.get(r))&&void 0!==p?p:0,i=null!==(v=L.get(r))&&void 0!==v?v:0,l=null!==(m=N.get(r))&&void 0!==m?m:0,a=null!==(x=I.get(r))&&void 0!==x?x:0;O.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:l+a,wInDeg:l,wOutDeg:a})}O.sort((e,t)=>t.degree-e.degree);let $=0,W=0;if(O.length>0){let e=0;for(const t of O)e+=t.degree,t.degree>W&&(W=t.degree);$=e/O.length}const z=T.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),R=[`${O.length} nodes, ${T.length} edges.`];O.length>0&&R.push(`Mean degree: ${tt($)}, max degree: ${W}.`);const B=O.slice(0,5);return g.createElement("div",{ref:S,id:r,tabIndex:-1,onBlur:_,style:nt,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:ot},"×"),g.createElement("div",{role:"note",style:rt},R.join(" ")),g.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:it},g.createElement("caption",{style:st},"Top ",B.length," of ",O.length," nodes by degree"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:lt},"id"),g.createElement("th",{style:lt},"degree"),g.createElement("th",{style:lt},"in"),g.createElement("th",{style:lt},"out"),z&&g.createElement("th",{style:lt},"w. degree"),z&&g.createElement("th",{style:lt},"w. in"),z&&g.createElement("th",{style:lt},"w. out"))),g.createElement("tbody",null,B.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:at},e.id),g.createElement("td",{style:at},e.degree),g.createElement("td",{style:at},e.inDeg),g.createElement("td",{style:at},e.outDeg),z&&g.createElement("td",{style:at},tt(e.wDegree)),z&&g.createElement("td",{style:at},tt(e.wInDeg)),z&&g.createElement("td",{style:at},tt(e.wOutDeg)))))))}function dt({summary:e}){return e?g.createElement("div",{role:"note",style:Qe},e):null}function ht({tableId:e}){return g.createElement("a",{href:"#"+e,style:Qe,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Qe)}},"Skip to data table")}function ft({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Qe},t)}const yt="var(--semiotic-focus, #005fcc)";function gt({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:l}){if(!e||!t)return null;const a=t.x+n.left,s=t.y+n.top;let c;if("rect"===o&&null!=i&&null!=l){const e=Math.max(i,4),t=Math.max(l,4);c=g.createElement("rect",{x:a-e/2-3,y:s-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===o?{cx:a,cy:s,r:12,fill:"none",stroke:yt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:s,r:8,fill:"none",stroke:yt,strokeWidth:2,strokeDasharray:"4,2"});return g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function pt({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:l="stream-frame-tooltip",zIndex:a=1}){const s=g.useRef(null),[c,u]=g.useState(null);g.useLayoutEffect(()=>{const e=s.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,l,n,r]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`,g.createElement("div",{ref:s,className:l,style:{position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},i)}function vt(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}function mt(t){const n=e.createContext(null),r=xt(t);return[function({children:r}){const o=e.useMemo(()=>xt(t),[]);return g.createElement(n.Provider,{value:o,children:r})},t=>{var o;const i=null!==(o=e.useContext(n))&&void 0!==o?o:r,l=e.useRef(t);l.current=t;const a=e.useCallback(()=>l.current(i.getState()),[i]),s=e.useCallback(()=>l.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,s)}]}function xt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const bt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},kt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},wt={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Et,At]=mt(e=>({theme:bt,setTheme(t){e(e=>{if("light"===t)return{theme:bt};if("dark"===t)return{theme:kt};if("high-contrast"===t)return{theme:wt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?kt:bt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}}));function Mt(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=t[0]*r,l=t[1]*r,a=t[0]+"px",s=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==s&&(e.style.height=s),e.width===i&&e.height===l||(e.width=i,e.height=l),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}function St(){return"undefined"!=typeof window&&window.devicePixelRatio||1}const Pt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,_t=new WeakMap;function Ct(e,t){var n,r;if(!t)return t;const o=Pt.exec(t);if(!o)return t;const i=e.canvas;if(!i)return(null===(n=o[2])||void 0===n?void 0:n.trim())||t;let l=_t.get(i);if(l||(l=new Map,_t.set(i,l)),l.has(t))return l.get(t);const a=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(r=o[2])||void 0===r?void 0:r.trim())||t;return l.set(t,a),a}function Tt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Dt(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function Lt(e,t,n,r,o,i){if(2>t.length)return;const l=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];l.push(l[e-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(l[n]+l[n+1])/2;let i=o;s>r&&(i*=r/s),s>a-r&&(i*=(a-r)/s),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const Nt=(e,t,n,r)=>{var o,i;const l=t.filter(e=>"line"===e.type);for(const a of l){if(2>a.path.length)continue;const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,d=a.colorThresholds,h=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const p=null!==(o=a.style.opacity)&&void 0!==o?o:1;Lt(e,a.path,c,u,p,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const f=Tt(a.curve),y=d&&d.length>0&&h&&h.length===a.path.length,g=a._decayOpacities;if(g&&g.length===a.path.length&&!y){e.strokeStyle=c;const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let m=0;a.path.length-1>m;m++)e.globalAlpha=.5*(g[m]+g[m+1])*v,e.beginPath(),e.moveTo(a.path[m][0],a.path[m][1]),e.lineTo(a.path[m+1][0],a.path[m+1][1]),e.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),E=!0}function M(){E&&(e.stroke(),E=!1)}for(let S=0;a.path.length>S;S++){const[P,_]=a.path[S],C=h[S],T=Dt(C,d,c);if(null!==x&&null!==w&&null!==k){if(T===w)e.lineTo(P,_);else{const D=[];for(const L of d){const N=L.value;(k>N||N>C)&&(N>k||C>N)||k===N||C===N||D.push({t:(N-k)/(C-k)})}D.sort((e,t)=>e.t-t.t);for(const I of D){const O=x+(P-x)*I.t,$=b+(_-b)*I.t,W=Dt(k+(C-k)*Math.min(I.t+1e-4,1),d,c);e.lineTo(O,$),M(),A(W,O,$)}e.lineTo(P,_)}x=P,b=_,k=C,w=T}else A(T,P,_),x=P,b=_,k=C,w=T}M()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=c;else{const z=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const R of a.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);e.strokeStyle=z}if(f)s.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[B,j]=a.path[0];e.moveTo(B,j);for(let F=1;a.path.length>F;F++)e.lineTo(a.path[F][0],a.path[F][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?Ct(e,a.style.fill):a.style.fill)||a.style.fill,f&&!y)s.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(a.path);else{const[H,X]=a.path[0];e.moveTo(H,X);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const Y=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],r.height),e.lineTo(Y,r.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function It(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ot(e,t,n=.3){It(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function $t(e,t,n=.6){var r,o,i,l,a;if(!It(t))return;const s=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,c=t.r+s*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Wt(e,t,n,r=.35){It(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function zt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Rt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Bt(e,t){const n=zt(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=s.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}const jt=(e,t,n,r)=>{var o,i,l;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",r=t._decayOpacities;if(r&&r.length===t.topPath.length){const i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(r[n]+r[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Ct(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(r[n]+r[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Bt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let r=1/0;for(const e of t.topPath)r>e[1]&&(r=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const i=e.createLinearGradient(0,r,0,o);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=Rt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=a}else{const r=null!==(l=t.style.fillOpacity)&&void 0!==l?l:.7;e.globalAlpha=r*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Bt(e,t),Wt(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=a,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Ct(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=zt(t.curve);if(e.beginPath(),n)s.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},Ft=(e,t,n,r)=>{var o;const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(o=t.style.opacity)&&void 0!==o?o:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?Ct(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Ct(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),$t(e,t),e.globalAlpha=1}}finally{e.restore()}}},Yt=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Ht(e,t);else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=("string"==typeof t.style.fill?Ct(e,t.style.fill):t.style.fill)||"#007bff";const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:r,y:o,w:i,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(r,o),e.lineTo(r+i-n,o),e.arcTo(r+i,o,r+i,o+n,n),e.lineTo(r+i,o+l-n),e.arcTo(r+i,o+l,r+i-n,o+l,n),e.lineTo(r,o+l);break;case"left":e.moveTo(r+i,o),e.lineTo(r+n,o),e.arcTo(r,o,r,o+n,n),e.lineTo(r,o+l-n),e.arcTo(r,o+l,r+n,o+l,n),e.lineTo(r+i,o+l);break;case"bottom":e.moveTo(r,o),e.lineTo(r+i,o),e.lineTo(r+i,o+l-n),e.arcTo(r+i,o+l,r+i-n,o+l,n),e.lineTo(r+n,o+l),e.arcTo(r,o+l,r,o+l-n,n);break;default:e.moveTo(r,o+l),e.lineTo(r,o+n),e.arcTo(r,o,r+n,o,n),e.lineTo(r+i-n,o),e.arcTo(r+i,o,r+i,o+n,n),e.lineTo(r+i,o+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ct(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else e.fillStyle=("string"==typeof t.style.fill?Ct(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ct(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h));Ot(e,t),e.globalAlpha=1}};function Ht(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=o+r,l=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,l,r,o,o)}else{const i=o+r,l=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,l,o,o)}e.restore()}function Xt(e,t,n,r){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),r)}function Gt(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function Vt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const qt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ut(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${qt[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${qt[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Kt={line:[jt,Nt,Ft],area:[jt,Ft],stackedarea:[jt,Ft],scatter:[Ft],bubble:[Ft],heatmap:[(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Ot(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Vt(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Gt(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}}],bar:[Yt],swarm:[Ft],waterfall:[(e,t,n,r)=>{var o,i,l;Yt(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const r=a[t],o=a[t+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=o.x;e.beginPath(),e.moveTo(c,s),e.lineTo(u,s),e.stroke()}e.restore()}}],candlestick:[(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=t._decayOpacity;if(null!=r&&1!==r&&(e.globalAlpha=r),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}e.restore()}}],mixed:[jt,Nt,Ft]},Zt={top:20,right:20,bottom:30,left:40},Qt={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Jt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function en({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:Jt},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const tn=e.forwardRef(function(t,n){var r,o,i,l,a,s,c,u,d,h,f;const{chartType:y,runtimeMode:p,data:v,chunkThreshold:m,chunkSize:k,xAccessor:w,yAccessor:E,colorAccessor:A,sizeAccessor:M,groupAccessor:S,lineDataAccessor:P,curve:_,normalize:C,binSize:T,valueAccessor:D,arrowOfTime:L="right",windowMode:N="sliding",windowSize:I=200,timeAccessor:O,xExtent:$,yExtent:W,extentPadding:z=.1,scalePadding:R,sizeRange:B,size:j=[500,300],responsiveWidth:F,responsiveHeight:Y,margin:H,className:G,background:V,lineStyle:q,pointStyle:U,areaStyle:K,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:re,boundsStyle:oe,y0Accessor:ie,gradientFill:ue,lineGradient:ye,areaGroups:ge,openAccessor:pe,highAccessor:ve,lowAccessor:me,closeAccessor:xe,candlestickStyle:be,showAxes:ke=!0,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:Se,yFormat:Pe,tickFormatTime:_e,tickFormatValue:Ce,hoverAnnotation:Te,tooltipContent:De,customHoverBehavior:Le,customClickBehavior:Ne,enableHover:Ie,hoverRadius:Oe=30,tooltipMode:$e,annotations:We,svgAnnotationRules:ze,showGrid:Re,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,backgroundGraphics:Ke,foregroundGraphics:Ze,canvasPreRenderers:Qe,svgPreRenderers:et,title:tt,categoryAccessor:nt,brush:rt,onBrush:ot,decay:it,pulse:lt,transition:at,staleness:st,heatmapAggregation:ut,heatmapXBins:yt,heatmapYBins:mt,showValues:xt,heatmapValueFormat:bt,marginalGraphics:kt,pointIdAccessor:wt,xScaleType:Et,yScaleType:Pt,accessibleTable:Ct=!0,description:Tt,summary:Dt,linkedCrosshairName:Lt,linkedCrosshairSourceId:Nt}=t,It=vt(),Ot=e.useRef(It);Ot.current=It;const[$t,Wt]=he(j,F,Y),zt=Object.assign(Object.assign({},Zt),H);if(kt){const e=60;kt.top&&e>zt.top&&(zt.top=e),kt.bottom&&e>zt.bottom&&(zt.bottom=e),kt.left&&e>zt.left&&(zt.left=e),kt.right&&e>zt.right&&(zt.right=e)}const Rt=Wt[0]-zt.left-zt.right,Bt=Wt[1]-zt.top-zt.bottom,jt="function"==typeof Ze?Ze({size:Wt,margin:zt}):Ze,Ft="function"==typeof Ke?Ke({size:Wt,margin:zt}):Ke,Yt=null!=Te?Te:Ie,Ht=e.useRef(null),Gt=e.useRef(null),Vt=e.useRef(0),qt=e.useRef(!1),Jt=At(e=>e.theme),[tn,nn]=e.useState(0),[rn,on]=e.useState(null),ln=e.useRef(null),an=e.useRef(null),[sn,cn]=e.useState(null),[un,dn]=e.useState(!1),[hn,fn]=e.useState([]),[yn,gn]=e.useState([]),pn=e.useRef(()=>{}),vn="streaming"===p||["bar","swarm","waterfall"].includes(y),mn=e.useMemo(()=>({chartType:y,runtimeMode:vn?"streaming":"bounded",windowSize:I,windowMode:N,arrowOfTime:vn?L:"right",extentPadding:z,scalePadding:R,xAccessor:vn?void 0:w,yAccessor:vn?void 0:E,timeAccessor:vn?O:void 0,valueAccessor:D,colorAccessor:A,sizeAccessor:M,groupAccessor:S||(P?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:P,xScaleType:Et,yScaleType:Pt,xExtent:$,yExtent:W,sizeRange:B,binSize:T,normalize:C,boundsAccessor:re,boundsStyle:oe,y0Accessor:ie,gradientFill:!0===ue?{topOpacity:.8,bottomOpacity:.05}:!1===ue?void 0:ue,areaGroups:ge?new Set(ge):void 0,lineGradient:ye,openAccessor:pe,highAccessor:ve,lowAccessor:me,closeAccessor:xe,candlestickStyle:be,lineStyle:q,pointStyle:U,areaStyle:K,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:We,decay:it,pulse:lt,transition:at,staleness:st,heatmapAggregation:ut,heatmapXBins:yt,heatmapYBins:mt,showValues:xt,heatmapValueFormat:bt,pointIdAccessor:wt,curve:_}),[y,I,N,L,z,R,w,E,O,D,Et,Pt,A,M,S,nt,P,$,W,B,T,C,re,oe,ie,ue,ye,ge,pe,ve,me,xe,be,q,U,K,ee,J,ne,te,We,it,lt,at,st,ut,yt,mt,xt,bt,vn,wt,_]),xn=e.useRef(null);xn.current||(xn.current=new X(mn));const bn=e.useCallback(()=>{Vt.current||(Vt.current=requestAnimationFrame(()=>pn.current()))},[]);e.useEffect(()=>{var e;null===(e=xn.current)||void 0===e||e.updateConfig(mn),qt.current=!0,bn()},[mn,bn]),e.useEffect(()=>{Ht.current&&_t.delete(Ht.current),qt.current=!0,bn()},[Jt,bn]);const kn=e.useRef(null);kn.current||(kn.current=new b(e=>{const t=xn.current;t&&t.ingest(e)&&(qt.current=!0,bn())},{chunkThreshold:m,chunkSize:k})),e.useEffect(()=>{var e;null===(e=kn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:k})},[m,k]);const wn=e.useCallback(e=>{var t;null===(t=kn.current)||void 0===t||t.push(e)},[]),En=e.useCallback(e=>{var t;null===(t=kn.current)||void 0===t||t.pushMany(e)},[]),An=e.useCallback(()=>{var e,t;null===(e=kn.current)||void 0===e||e.clear(),null===(t=xn.current)||void 0===t||t.clear(),qt.current=!0,bn()},[bn]);e.useImperativeHandle(n,()=>({push:wn,pushMany:En,remove:e=>{var t,n,r;null===(t=kn.current)||void 0===t||t.flush();const o=null!==(r=null===(n=xn.current)||void 0===n?void 0:n.remove(e))&&void 0!==r?r:[];return o.length>0&&(ln.current&&o.some(e=>{var t;return e===(null===(t=ln.current)||void 0===t?void 0:t.data)})&&(ln.current=null,cn(null)),qt.current=!0,bn()),o},update:(e,t)=>{var n,r,o;null===(n=kn.current)||void 0===n||n.flush();const i=null!==(o=null===(r=xn.current)||void 0===r?void 0:r.update(e,t))&&void 0!==o?o:[];return i.length>0&&(qt.current=!0,bn()),i},clear:An,getData:()=>{var e,t,n;return null===(e=kn.current)||void 0===e||e.flush(),null!==(n=null===(t=xn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=xn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=xn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[wn,En,An,bn]),e.useEffect(()=>{var e,t;if(v){if(P&&v.length>0&&"object"==typeof v[0]&&null!==v[0]){const t="string"==typeof P?P:"coordinates";if(Array.isArray(v[0][t])){const n=[];for(const e of v){const r=e[t];if(Array.isArray(r)){const t=e.label||e.id||e.key;if(null!=t)for(const e of r)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of r)n.push(e)}}return void(null===(e=kn.current)||void 0===e||e.setBoundedData(n))}}null===(t=kn.current)||void 0===t||t.setBoundedData(v)}},[v,P]);const Mn=e.useRef(()=>{}),Sn=e.useRef(()=>{});Mn.current=e=>{if(!Yt)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-zt.left,o=e.clientY-n.top-zt.top;if(0>r||r>Rt||0>o||o>Bt)return void(ln.current&&(ln.current=null,an.current=null,cn(null),Le&&(Le(null),qt.current=!0),bn()));const i=xn.current;if(!i||0===i.scene.length)return;const l=Z(i.scene,r,o,Oe,i.quadtree);if(!l)return void(ln.current&&(ln.current=null,an.current=null,cn(null),Le&&Le(null),bn()));const a=Xt(l.datum||{},l.x,l.y);if("multi"===$e&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=Q(e.path,t,n);if(null===i)continue;const l=le(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.path[l][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Q(e.topPath,t,n);if(null===i)continue;const l=le(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(i.scene,l.x,Oe),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const r=n?n(l.x):l.x;a.xValue=r,a.xPx=l.x,a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}ln.current=a,an.current=l.node,cn(a),Le&&(Le(a),qt.current=!0),bn()},Sn.current=()=>{ln.current&&(ln.current=null,an.current=null,cn(null),Le&&(Le(null),qt.current=!0),bn())},e.useCallback(e=>Mn.current(e),[]);const Pn=e.useCallback(()=>Sn.current(),[]),_n=e.useRef(()=>{});_n.current=e=>{if(!Ne)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-zt.left,o=e.clientY-n.top-zt.top;if(0>r||r>Rt||0>o||o>Bt)return void Ne(null);const i=xn.current;if(!i||0===i.scene.length)return void Ne(null);const l=Z(i.scene,r,o,Oe,i.quadtree);Ne(l?Xt(l.datum||{},l.x,l.y):null)};const Cn=e.useCallback(e=>_n.current(e),[]),Tn=e.useRef(-1),Dn=e.useRef(null),Ln=e.useRef(null),Nn=e.useCallback(e=>{const t=xn.current;if(!t||0===t.scene.length)return;const n=t.version;let r;if(Ln.current&&Ln.current.version===n)r=Ln.current.graph;else{const e=function(e){var t,n,r,o;const i=[];for(const l of e)switch(l.type){case"point":i.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(t=l.group)&&void 0!==t?t:"_default"});break;case"line":{const e=l,t=Array.isArray(e.datum)?e.datum:[],r=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:r});break}case"area":{const e=l,t=Array.isArray(e.datum)?e.datum:[],n=null!==(r=e.group)&&void 0!==r?r:"_default";for(let r=0;e.topPath.length>r&&t.length>r;r++)i.push({x:e.topPath[r][0],y:e.topPath[r][1],datum:t[r],shape:"circle",group:n});break}case"rect":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=l.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;r=ae(e),Ln.current={version:n,graph:r}}const o=Tn.current;if(0>o){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Tn.current=0;const t=r.flat[0];Dn.current={shape:t.shape,w:t.w,h:t.h};const n=de(t);return ln.current=n,cn(n),Le&&Le(n),void bn()}const i=se(r,o),l=ce(e.key,i,r);if(null===l)return;if(e.preventDefault(),0>l)return Tn.current=-1,Dn.current=null,ln.current=null,an.current=null,cn(null),Le&&Le(null),void bn();Tn.current=l;const a=r.flat[l];Dn.current={shape:a.shape,w:a.w,h:a.h};const s=de(a);ln.current=s,cn(s),Le&&Le(s),bn()},[Le,bn]),In=e.useCallback(e=>{Tn.current=-1,Dn.current=null,Mn.current(e)},[]);pn.current=()=>{var e,t;Vt.current=0;const n=Ht.current,r=Gt.current;if(!n||!r)return;const o=xn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Ot.current?i+1e6:i),a=!Ot.current&&l,s=qt.current||l;s&&!a&&o.computeScene({width:Rt,height:Bt});const c=St(),u=function(e){if(!e)return Qt;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=r||t.getPropertyValue("--text-secondary").trim(),l=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),s=o||t.getPropertyValue("--surface-0").trim();return i||l||n?{axisStroke:a||Qt.axisStroke,tickText:i||Qt.tickText,crosshair:i?i+"66":Qt.crosshair,hoverFill:s?s+"4D":Qt.hoverFill,hoverStroke:i?i+"99":Qt.hoverStroke,pointRing:s||Qt.pointRing}:Qt}(n),d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&o.lastIngestTime>0&&i-o.lastIngestTime>d;if(s){const e=Mt(n,Wt,zt,c);if(e){e.clearRect(-zt.left,-zt.top,Wt[0],Wt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=V||(r&&"transparent"!==r?r:null);if(i&&(e.fillStyle=i,e.fillRect(-zt.left,-zt.top,Wt[0],Wt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Rt,Bt),e.clip()),Qe&&o.scales)for(const t of Qe)e.save(),t(e,o.scene,o.scales,{width:Rt,height:Bt}),e.restore();const l=Kt[y];if(l&&o.scales)for(const t of l)t(e,o.scene,o.scales,{width:Rt,height:Bt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Mt(r,Wt,zt,c);if(e&&(e.clearRect(-zt.left,-zt.top,Wt[0],Wt[1]),Yt&&ln.current&&o.scales&&function(e,t,n,r,o,i,l){var a,s;if(!1===o.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=h.stroke||l.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,r),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=l.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(s=e.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const r=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=r,e.fill(),e.strokeStyle=l.pointRing,e.lineWidth=2,e.stroke()}}(e,ln.current,Rt,Bt,"object"==typeof Yt?Yt:{},an.current,u),an.current&&Array.isArray(Te))){const t=Te.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r){var o;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?r.style(n.datum):r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(o=t.opacity)&&void 0!==o?o:1,e.stroke(),e.restore()}}(e,o.scene,an.current,t)}}s&&n&&n.setAttribute("aria-label",Je(o.scene,y+" chart"));const f=qt.current;if(qt.current=!1,f&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!rn||e(rn.x.domain()[0])!==e(o.scales.x.domain()[0])||e(rn.x.domain()[1])!==e(o.scales.x.domain()[1])||e(rn.y.domain()[0])!==e(o.scales.y.domain()[0])||e(rn.y.domain()[1])!==e(o.scales.y.domain()[1])||rn.x.range()[0]!==o.scales.x.range()[0]||rn.x.range()[1]!==o.scales.x.range()[1]||rn.y.range()[0]!==o.scales.y.range()[0]||rn.y.range()[1]!==o.scales.y.range()[1])&&on(o.scales),kt){const e=o.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof E?E:e=>e[E||"y"];fn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),gn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}f&&We&&We.length>0&&nn(e=>e+1),(null==st?void 0:st.showBadge)&&dn(!!h),(a||o.hasActivePulses)&&(Vt.current=requestAnimationFrame(()=>pn.current()))},e.useEffect(()=>(bn(),()=>{Vt.current&&(cancelAnimationFrame(Vt.current),Vt.current=0)}),[bn]),e.useEffect(()=>{qt.current=!0,bn()},[y,Rt,Bt,ke,V,q,Qe,bn]),fe(st,xn,qt,bn,un,dn);const On=e.useMemo(()=>{if(Se||_e)return;const e=xn.current;return(null==e?void 0:e.xIsDate)&&rn?Ut(rn.x.domain()):void 0},[Se,_e,rn]),$n=Se||_e||On,Wn=Yt&&sn?De?De(sn):g.createElement(en,{hover:sn}):null,zn=Wn?g.createElement(pt,{x:sn.x,y:sn.y,containerWidth:Rt,containerHeight:Bt,margin:zt,className:"stream-frame-tooltip"},Wn):null,Rn=Dn.current,Bn=g.createElement(gt,{active:Tn.current>=0,hoverPoint:sn,margin:zt,size:Wt,shape:null==Rn?void 0:Rn.shape,width:null==Rn?void 0:Rn.w,height:null==Rn?void 0:Rn.h}),jn=(e,t,n,r)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null},Fn=jn(w,O,"__semiotic_resolvedX","__semiotic_resolvedTime"),Yn=jn(E,D,"__semiotic_resolvedY","__semiotic_resolvedValue"),Hn=Fn.key,Xn=Yn.key,Gn=We&&We.length>0,Vn=e=>{if(!e||!Gn||!Fn.fn&&!Yn.fn)return e;let t=!1;const n=e.map(e=>{const n=Fn.fn&&Fn.key&&!(Fn.key in e),r=Yn.fn&&Yn.key&&!(Yn.key in e);if(!n&&!r)return e;t=!0;const o=Object.assign({},e);return n&&(o[Fn.key]=Fn.fn(e)),r&&(o[Yn.key]=Yn.fn(e)),o});return t?n:e};if(Ue){const e=xn.current;e&&v&&(e.ingest({inserts:v,bounded:!0}),e.computeScene({width:Rt,height:Bt}));const t=null!==(r=null==e?void 0:e.scene)&&void 0!==r?r:[],n=null!==(o=null==e?void 0:e.scales)&&void 0!==o?o:null,i=$n||(()=>{if((null==e?void 0:e.xIsDate)&&n)return Ut(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":Tt||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:Wt[0],height:Wt[1]}},g.createElement(dt,{summary:Dt}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Wt[0],height:Wt[1],style:{position:"absolute",left:0,top:0}},g.createElement("g",{transform:`translate(${zt.left},${zt.top})`},Ft),g.createElement("g",{transform:`translate(${zt.left},${zt.top})`},V&&g.createElement("rect",{x:0,y:0,width:Rt,height:Bt,fill:V}),et&&n&&et.map((e,r)=>g.createElement(g.Fragment,{key:"svgpre-"+r},e(t,n,{width:Rt,height:Bt}))),t.map((e,t)=>function(e,t){var n,r,o;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"line-"+t,d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const i=o.topPath.map(([e,t])=>`${e},${t}`).join("L"),l=[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"area-"+t,d:`M${i}L${l}Z`,fill:qe(o.style.fill),fillOpacity:null!==(r=null!==(n=o.style.fillOpacity)&&void 0!==n?n:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const n=e;return g.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:qe(n.style.fill),opacity:null!==(o=n.style.opacity)&&void 0!==o?o:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return g.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:qe(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),l=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+t},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px"},e))}return g.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+t},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),g.createElement(Ve,{width:Rt,height:Bt,totalWidth:Wt[0],totalHeight:Wt[1],margin:zt,scales:n,showAxes:ke,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:i,yFormat:Pe||Ce,showGrid:Re,title:tt,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,foregroundGraphics:jt,marginalGraphics:kt,xValues:[],yValues:[],annotations:We,svgAnnotationRules:ze,annotationFrame:0,xAccessor:Hn,yAccessor:Xn,annotationData:Vn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof _?_:void 0,linkedCrosshairName:Lt,linkedCrosshairSourceId:Nt}))}const qn="semiotic-table-"+g.useId();return g.createElement("div",{ref:$t,className:"stream-xy-frame"+(G?" "+G:""),role:"group","aria-label":Tt||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:F?"100%":Wt[0],height:Y?"100%":Wt[1],overflow:"visible"},onKeyDown:Nn},Ct&&g.createElement(ht,{tableId:qn}),Ct&&g.createElement(ct,{scene:null!==(l=null===(i=xn.current)||void 0===i?void 0:i.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:qn,chartTitle:"string"==typeof tt?tt:void 0}),g.createElement(dt,{summary:Dt}),g.createElement("div",{role:"img","aria-label":Tt||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Yt?In:void 0,onMouseLeave:Yt?Pn:void 0,onClick:Ne?Cn:void 0},Ft&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Wt[0],height:Wt[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${zt.left},${zt.top})`},Ft)),g.createElement(He,{width:Rt,height:Bt,totalWidth:Wt[0],totalHeight:Wt[1],margin:zt,scales:rn,showAxes:ke,axes:we,showGrid:Re,xFormat:$n,yFormat:Pe||Ce}),g.createElement("canvas",{ref:Ht,"aria-label":Je(null!==(s=null===(a=xn.current)||void 0===a?void 0:a.scene)&&void 0!==s?s:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Gt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(ft,{hoverPoint:sn}),g.createElement(Ve,{width:Rt,height:Bt,totalWidth:Wt[0],totalHeight:Wt[1],margin:zt,scales:rn,showAxes:ke,axes:we,xLabel:Ee,yLabel:Ae,yLabelRight:Me,xFormat:$n,yFormat:Pe||Ce,showGrid:Re,title:tt,legend:Be,legendHoverBehavior:je,legendClickBehavior:Fe,legendHighlightedCategory:Ye,legendIsolatedCategories:Xe,legendPosition:Ge,foregroundGraphics:jt,marginalGraphics:kt,xValues:hn,yValues:yn,annotations:We,svgAnnotationRules:ze,annotationFrame:tn,xAccessor:Hn,yAccessor:Xn,annotationData:Vn(null===(c=xn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=xn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof _?_:void 0,underlayRendered:!0,linkedCrosshairName:Lt,linkedCrosshairSourceId:Nt}),(rt||ot)&&g.createElement(x,{width:Rt,height:Bt,totalWidth:Wt[0],totalHeight:Wt[1],margin:zt,dimension:null!==(d=null==rt?void 0:rt.dimension)&&void 0!==d?d:"xy",scales:rn,onBrush:null!=ot?ot:()=>{},binSize:T,snap:null==rt?void 0:rt.snap,binBoundaries:null!==(h=null==rt?void 0:rt.binBoundaries)&&void 0!==h?h:"bar"===y?null===(f=xn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==rt?void 0:rt.snapDuring,streaming:"streaming"===p}),(null==st?void 0:st.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:un?"#dc3545":"#28a745",color:"white"})},un?"STALE":"LIVE"),Bn,zn))});tn.displayName="StreamXYFrame";const nn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},rn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class on{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,r){var o;for(let i=0;this.capacity>i;i++){const l=this.particles[i];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=r&&null!==(o=r[l.edgeIndex])&&void 0!==o?o:1;if(l.t+=e*t*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=ln(a.bezier,l.t,l.offset);l.x=c.x,l.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function ln(e,t,n){if(e.circular&&e.segments)return function(e,t,n,r){const o=e.length,i=t*o,l=Math.min(Math.floor(i),o-1),a=i-l,[s,c,u,d]=e[l],h=an(s,c,u,d,a),f=d.x-s.x,y=d.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const e=f/g;h.x+=-y/g*n*r*2,h.y+=e*n*r*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[r,o,i,l]=e.points,a=an(r,o,i,l,t),s=l.x-r.x,c=l.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;a.x+=-c/u*n*e.halfWidth*2,a.y+=t*n*e.halfWidth*2}return a}function an(e,t,n,r,o){const i=1-o,l=i*i,a=l*i,s=o*o,c=s*o;return{x:a*e.x+3*l*o*t.x+3*i*s*n.x+c*r.x,y:a*e.y+3*l*o*t.y+3*i*s*n.y+c*r.y}}function sn(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function cn(e,t){var n,r=[],o=[],i=[],l={},a=[];function s(e){i[e]=!1,l.hasOwnProperty(e)&&Object.keys(l[e]).forEach(function(t){delete l[e][t],i[t]&&s(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)s(e);else for(t=0;a[e].length>t;t++){var h=l[r=a[e][t]];h||(l[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,t){var n=[].concat(t).concat(e);r.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),l=Array(t),a=Array(t),s=0;t>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,l[s]=-1,a[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(r[t]=0|Math.min(r[t],r[g])),0>l[g]||a[t].push(l[g])}i[t]=y}else{if(r[t]===n[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),v.push(a[x]),m+=a[x].length,l[x]=d.length,x===t){s.length=y;break}}d.push(p);var b=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)b[--m]=v[y][k];h.push(b)}c.pop()}}}for(s=0;t>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,l=0;o.length>l;l++)for(var a=0;o[l].length>a;a++)i>o[l][a]&&(i=o[l][a],n=l);var s=o[n];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];i[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return r}function un(e){return e.y0-e.y1>0?"up":"down"}function dn(e,t){return t(e.source)==t(e.target)}function hn(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function fn(e){return e.target.x0-e.source.x1}function yn(e,t){var n=pn(e),r=fn(t)/Math.tan(n);return"up"==un(e)?e.y1-r:e.y1+r}function gn(e,t){var n=pn(e),r=fn(t)/Math.tan(n);return"up"==un(e)?e.y1+r:e.y1-r}function pn(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function vn(e,t){return t(e)}function mn(e){return bn(e.source)}function xn(e){return bn(e.target)}function bn(e){return(e.y0+e.y1)/2}function kn(e){return e.virtual?0:e.value}function wn(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!dn(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!dn(e,t)?r+1:r}),n+r}function En(e){return e.target.depth}function An(e,t){return e.sourceLinks.length?e.depth:t-1}function Mn(e,t){return e.y0-t.y0}function Sn(e,t){return t.y0-e.y0}function Pn(e,t){return e.y1-t.y1}function _n(e,t){return t.y1-e.y1}function Cn(e,t){return Dn(e.source,t.source)||e.index-t.index}function Tn(e,t){return Dn(e.target,t.target)||e.index-t.index}function Dn(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Ln(e,t){return Nn(e)==Nn(t)?"bottom"==e.circularLinkType?Sn(e,t):Mn(e,t):Nn(t)-Nn(e)}function Nn(e){return e.target.column-e.source.column}function In(e,t){return On(e)==On(t)}function On(e){return e.y0-e.y1>0?"up":"down"}function $n(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=l.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Wn(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Wn(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,dn(e,t)&&hn(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var l=e.source.column,a=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==l&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?Sn:Mn);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),l=e.target.column,(c=i.links.filter(function(e){return e.target.column==l&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?_n:Pn),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Wn(e,t,n){e.sort(Ln);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(dn(e,t)&&hn(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&zn(e,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function zn(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Rn(e){return function(){return e}}function Bn(e){return e.index}function jn(e){return e.nodes}function Fn(e){return e.links}function Yn(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var l=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=bn(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=bn(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?wn(t,n)-wn(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==l||0==t.depth&&1==l?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==wn(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/l*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-l/2+o,t.y1=t.y0+t.value*e.ky)})})}function Hn(e,t,n,r,o,i){var a=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=i;c>0;--c)u(s*=.99,n),d();function u(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&wn(o,n)>0){var c=l.mean(o.sourceLinks,xn),u=l.mean(o.targetLinks,mn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-bn(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=l.mean(o.sourceLinks,xn),y=l.mean(o.targetLinks,mn),g=((f&&y?(f+y)/2:f||y)-bn(o))*t;o.y0+=g,o.y1+=g}})})}function d(){a.forEach(function(n){var i,l,a,s=e.y0,c=n.length;for(n.sort(t||Dn),a=0;c>a;++a)(l=s-(i=n[a]).y0)>0&&(i.y0+=l,i.y1+=l),s=i.y1+r;if((l=s-r-e.y1)>0)for(s=i.y0-=l,i.y1-=l,a=c-2;a>=0;--a)(l=(i=n[a]).y1+o-s)>0&&(i.y0-=l,i.y1-=l),s=i.y0})}}function Xn(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Tn),e.targetLinks.sort(Cn)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Gn(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=Bn,c=An,u=void 0,d=32,h=2,f=jn,y=Fn;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=r,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return l.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=sn(n,r)),"object"!=typeof o&&(o=e.target=sn(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],l=i.source.index,a=i.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=cn(r);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,u),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){vn(e,t)!=vn(o.source,t)&&vn(e,t)!=vn(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),dn(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(l.sum(e.sourceLinks,kn),l.sum(e.targetLinks,kn)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var l=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){l=t(e)==a?l:l+1,a=t(e)==a?a:t(e),e.column=l})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(f,u,c);var y=i;if(null!==a){var g=l.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=l.max(g,function(e){return e.length});p>1&&(y=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=l.min(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/l.sum(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=l.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,o),Yn(f,u,s),Hn(f,u,s,y,y,d),Xn(f),$n(f,s,h,10,8),Yn(f,u,s),Hn(f,u,s,y,y,d),Xn(f),$n(f,s,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return vn(n.source,t)==vn(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!In(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=yn(t,e);return e.y1-n}if(t.target.column>e.target.column)return yn(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;t.y0=e.y1-l-t.width/2}})})}(f,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return vn(n.target,t)==vn(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!In(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=gn(t,e);return e.y0-n}if(t.source.column>e.source.column)return gn(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;t.y1=e.y1-l-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){var i=l.min(t,function(e){return e.y0}),a=l.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);function c(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(f),$n(f,s,h,10,8)}(g),g}return g.update=function(e){return Xn(e),$n(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:Rn(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:Rn(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Rn(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Rn(e),g):c},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}const Vn=e=>{let t,n,r,o,i,l,a,s,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,l=e.target.x0,a=u.interpolateNumber(i,l),s=a(.5),c=a(.5),`M${t},${i}C${t},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${o},${s} ${o},${i}Z`):(t=e.source.x1,n=e.target.x0,a=u.interpolateNumber(t,n),r=a(.5),o=a(.5),i=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,s=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${r},${i} ${o},${l} ${n},${l}L${n},${s}C${o},${s} ${r},${c} ${t},${c}Z`)};function qn(e){var t;const n=e.sankeyWidth/2,r=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,r=o.sourceY,i=o.targetX,l=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${r-n}L${t+a},${r-n}L${t+a},${r+n}L${t},${r+n}ZM${i},${l-n}L${i-s},${l-n}L${i-s},${l+n}L${i},${l+n}Z`}const i=o.sourceX,l=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${l-h*n}L${c},${l-h*n}L${c+r},${l-h*n+h*f}L${c+r},${d+h*r-h*f}L${c+r-f},${d+h*r}L${u-r+f},${d+h*r}L${u-r},${d+h*r-h*f}L${u-r},${s-h*n+h*f}L${u-r+f},${s-h*n}L${a},${s-h*n}L${a},${s+h*n}L${u+r},${s+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${l+h*n}L${i},${l+h*n}Z`}const Un=new Set,Kn=new WeakMap;function Zn(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Kn.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Kn.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Un.has(e)||(Un.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}const Qn={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(En))-1:0},justify:An},Jn={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i,l,a,s,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Gn().extent(m).links(v).nodes(p).nodeAlign(Qn[h]||An).nodeId(e=>e.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of p)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of v){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-l&&(e=i.leftFullExtent-l),i.rightFullExtent+l>t&&(t=i.rightFullExtent+l),n>i.verticalFullExtent-l&&(n=i.verticalFullExtent-l),i.verticalFullExtent+l>o&&(o=i.verticalFullExtent+l)}const i=t-e,l=o-n,u=r[0],d=r[1];if(i>0&&l>0&&(0>e||0>n||t>u||o>d)){const t=Math.min(u/i,d/l),r=-e*t+(u-i*t)/2,o=-n*t+(d-l*t)/2;for(const e of p)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of p){const t=b.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,n=e.target,r="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof n&&null!==n?n.id:n+"",i=k.get(e._edgeKey?e._edgeKey:`${r}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=b.get(r),n=b.get(o);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,r){var o,l,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=u?u(Zn(t,"nodeStyle")):{},o={fill:r.fill||g.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};x.set(t.id,("string"==typeof o.fill?o.fill:null)||g.get(t.id)||"#4d430c"),p.push("down"===c?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r="#999";r="function"==typeof f?f(e)||r:"target"===f?x.get(n.id)||g.get(n.id)||r:x.get(t.id)||g.get(t.id)||r;const o=d?d(Zn(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||r;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?qn(e):Vn(e),!i)continue;const c={fill:o.fill||r,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const i=t?t(n):n.id;if(!i)continue;let l,a,s;"down"===c?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,s="middle"):(r[0]/2>n.x0+e/2?(l=n.x0-6,s="end"):(l=n.x1+6,s="start"),a=n.y0+o/2),m.push({x:l,y:a,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:v,labels:m}}},er={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i;if(0===e.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const f=u>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const r=tr(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=nr(e.id),i=o%360*(Math.PI/180),l=10+o%20;e.x=t/r.length+l*Math.cos(i),e.y=n/r.length+l*Math.sin(i)}else{const t=nr(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=a+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=a+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const y=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=0===n.iterations?0:f?40:y,p=rr(n.nodeSize,n.nodeSizeRange,e),v=e=>p(e);if(g>0){const n=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),r=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*v(e))).force("center",d.forceCenter(a,s).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(s).strength(.15));if(r.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));r.force("link",n),r.force("link").links(e)}f?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let e=0;g>e;++e)r.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){var o,l,a;const s=n.nodeStyle,c=n.edgeStyle,u=rr(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(Zn(t,"nodeSize")),n=s?s(Zn(t,"nodeStyle")):{},r={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(Zn(e,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:o,datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=u(Zn(n,"nodeSize"));g.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function tr(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let l=null;if(t===e?l=i:i===e&&(l=t),l){const e=n.get(l);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function nr(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function rr(e,t,n){var o,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const a=t||[5,20],s=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>a[0];const c=null!==(o=l.min(s))&&void 0!==o?o:0,u=null!==(i=l.max(s))&&void 0!==i?i:1;if(c===u)return()=>(a[0]+a[1])/2;const d=r.scaleLinear().domain([c,u]).range(a).clamp(!0);return t=>{var n;const r=null===(n=t.data)||void 0===n?void 0:n[e];return null==r||"number"!=typeof r?a[0]:d(r)}}const or=i.schemeCategory10,ir={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,c=a-i,u=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=g.get("string"==typeof e.source?e.source:e.source.id),r=g.get(t);if(void 0===n||void 0===r)continue;const o=f(e);v[n][r]=o}const m=h.chord().padAngle(o);l&&m.sortGroups(l);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const t of b){const n=e[t.index],r=k.centroid(t);n.x=r[0]+u,n.y=r[1]+d,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),r=w.get(t);n&&(e.source=n),r&&(e.target=r)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of x){const n=e[t.source.index].id,r=e[t.target.index].id,o=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);o&&(o.chordData=t)}},buildScene(e,t,n,r){var o,i;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:or,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=h.ribbon().radius(c),x=[],b=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.arcData;if(!r)continue;let i;i=f?f(Zn(n,"nodeStyle")).fill||v.get(n.id)||p[t%p.length]:v.get(n.id)||p[t%p.length];const l=f?f(Zn(n,"nodeStyle")):{},a={fill:i,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};x.push({type:"arc",cx:u,cy:d,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=m(t);if(!n)continue;const r=lr(n,u,d);let o="#999";if(y)o=y(Zn(e,"edgeStyle")).fill||o;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===g&&n?o=v.get(n.id)||o:t&&(o=v.get(t.id)||o)}const l=y?y(Zn(e,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=l.fillOpacity)&&void 0!==i?i:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,r=s+12;for(const n of e){const e=n.arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,l=i-Math.PI/2;k.push({x:u+Math.cos(l)*r,y:d+Math.sin(l)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function lr(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}const ar=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function sr(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function cr(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function ur(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function dr(e){return Array.isArray(e.colorScheme)?e.colorScheme:ar}function hr(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:"#4d430c"}function fr(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}const yr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const l=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=a.hierarchy(i,s);d.sum(u),d.sort((e,t)=>{var n,r;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(r=e.value)&&void 0!==r?r:0)});const[h,f]=r;switch(l){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=a.tree();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,h,f);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=a.cluster();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,h,f);break;case"treemap":!function(e,t,n,r){var o,i;const l=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=a.treemap().size([n,r]).tile(a.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(e)}(d,n,h,f);break;case"circlepack":!function(e,t,n,r){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;a.pack().size([n,r]).padding(i)(e)}(d,n,h,f);break;case"partition":!function(e,t,n,r){var o;a.partition().size([n,r]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,n,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const r=y[t],i={id:cr(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?gr(i,r,n):"treemap"===l||"partition"===l?pr(i,r):"circlepack"===l&&vr(i,r),i.__hierarchyNode=r,e.push(i),g.set(r,i)}if("tree"===l||"cluster"===l)for(const e of y)if(e.parent){const n=g.get(e.parent),r=g.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){var l,a,s,c,u;const d=[],h=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,v=r[1]/2,m="number"==typeof(x=n.nodeSize)?x:5;var x;for(const t of e){let e=t.x,r=t.y;g&&(e+=p,r+=v);const i=o(Zn(t,"nodeStyle"));let a=i.fill||hr(n);if(n.colorByDepth&&void 0!==t.depth){const e=dr(n);a=e[t.depth%e.length]}const s={fill:a,stroke:i.stroke||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:r,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r=t.x,o=t.y,l=n.x,a=n.y;g&&(r+=p,o+=v,l+=p,a+=v);const u=fr(r,o,l,a,y),d=i(Zn(e,"edgeStyle")),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:b};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==n.showLabels){const t=ur(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,l=n.x,a=n.y;if(g&&(l+=p,a+=v),g){const e=l-p,t=a-v,n=Math.sqrt(e*e+t*t);n>0?(r=l+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=l,o=a-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-m-6,i="end"):(r=l+m+6,i="start"),o=a):(r=l,o=a+m+14,i="middle");f.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){var o,i;const l=[],a=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Zn(n,"nodeStyle"));let s=a.fill||hr(t);if(t.colorByDepth&&void 0!==n.depth){const e=dr(t);s=e[n.depth%e.length]}const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ur(t.nodeLabel),o=t.labelMode||"leaf",l="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const u=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!l){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=n?n(s):s.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>c)continue;let h=r(Zn(s,"nodeStyle")).fill||hr(t);if(t.colorByDepth&&void 0!==s.depth){const e=dr(t);h=e[s.depth%e.length]}const f=sr(h);a.push(u?{x:s.x0+e/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(e,n,0,o);case"circlepack":return function(e,t,n,r){var o,i,l,a,s;const c=[],u=[];for(const n of e){const e=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=e)continue;const a=r(Zn(n,"nodeStyle"));let s=a.fill||hr(t);if(t.colorByDepth&&void 0!==n.depth){const e=dr(t);s=e[n.depth%e.length]}const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ur(t.nodeLabel);for(const o of e){const e=null!==(a=o.__radius)&&void 0!==a?a:5,i=n?n(o):o.id;if(!i)continue;if(15>e)continue;const l=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(Zn(o,"nodeStyle")).fill||hr(t);if(t.colorByDepth&&void 0!==o.depth){const e=dr(t);c=e[o.depth%e.length]}if(l){const t=sr(c);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function gr(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function pr(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function vr(e,t){var n;const r=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}function mr(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const xr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){var i,l;const a=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof d?()=>d:d,y="number"==typeof h?()=>h:h,g=mr(n);g.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function v(e){var t;const n=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,n+1),0===n?e:`${e}__${n}`}const m=t[0]/2,x=t[1]/2,b=Math.min(t[0],t[1])/2*.85,k=v(c(e));r.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:e}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,l,d,h,p){const m=a(t);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:h,data:t,parentId:n},S=p?d/f(M)*A:d*A,P=s.pie().value(e=>{var t;return(null===(t=a(e))||void 0===t?void 0:t.length)?4:1}).sort(null),_=P(w),C=y(M);for(let t=0;w.length>t;t++){const a=(_[t].startAngle+_[t].endAngle)/2,s=w[t],u=v(c(s)),d=i+S*Math.sin(a),f=l+S*Math.cos(a)*C;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:s}),g.metaMap.set(u,{ring:S,angle:a,depth:h,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,S,h+1,!0)}E+=k}}(e,k,m,x,b,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){var o,i,l,a,s;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],y=[];if(!1!==n.orbitShowRings){const t=mr(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(s),y2:t+n*Math.cos(s)*r,style:l,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(Zn(t,"nodeSize")),n=c?c(Zn(t,"nodeStyle")):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id,depth:t.depth})}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:g.get(e.source),n="object"==typeof e.target?e.target:g.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(Zn(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[t])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:y}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){var n,r;const o=mr(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=t.orbitRevolution)&&void 0!==r?r:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const r=e.angle+a*s*l({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(r),t.y=n.y+e.ring*Math.cos(r)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},br={sankey:Jn,force:er,chord:ir,tree:yr,cluster:yr,treemap:yr,circlepack:yr,partition:yr,orbit:xr};function kr(e){return br[e]}class wr{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},nn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new on(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},nn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new on(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:e=>e[r],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof l?l:e=>{var t;return null!==(t=e[l])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Er(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],r=s(n)+"",o=c(n)+"",i=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Er(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Er(o)),{data:n}));const l=`${r}\0${o}\0${e}`;this.edges.set(l,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Er(t)),this.nodeTimestamps.set(t,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Er(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,r,o,i,l;const a=kr(this.config.chartType);if(!a)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!a.hierarchical)return;if(this.prepareForRelayout(),a.supportsStreaming&&!a.hierarchical){const e=new Map;for(const a of s)if(void 0!==a._prevX0){const s=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(o=a._prevY0)&&void 0!==o?o:0);e.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(a.computeLayout(s,c,this.config,e),this.config.__previousPositions=void 0,a.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of s)this.nodes.set(e.id,e);for(let e=0;c.length>e;e++){const t=c[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=kr(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:l}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=l}get isAnimating(){const e=kr(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=kr(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=N(e,this.transition),n=L(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=I(e._prevX0,e._targetX0,n),e.x1=I(e._prevX1,e._targetX1,n),e.y0=I(e._prevY0,e._targetY0,n),e.y1=I(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=I(e._prevY0,e._targetY0,n),e.y1=I(e._prevY1,e._targetY1,n),e.sankeyWidth=I(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:i}],halfWidth:r}}const o=t.x1,i=n.x0,l=u.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,l=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+l/3},{x:t.x+2*i/3,y:t.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,r,o,i;const l=this.config.pulse;if(!l)return;const a=null!==(t=l.duration)&&void 0!==t?t:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=e-r;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=s)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const r=this.nodeTimestamps.size;if(1>=r)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const o=this._decaySortedNodes,i=new Map;for(let e=0;o.length>e;e++)i.set(o[e][0],e);for(const o of this.sceneNodes){const l=o.id;if(!l)continue;const a=i.get(l);if(void 0===a)continue;const s=T(n,a,r),c=null!==(t=null===(e=o.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*s})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,r),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const r=this.config.thresholds;if(!r)return;const o=null!==(t=r.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),l&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const r=this.nodes.get(e);if(!r)return null;const o=r.data?Object.assign({},r.data):{};return r.data=t(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(e,t,n){var r;const o=this.config.valueAccessor,i="function"==typeof o?o:o?e=>e[o]:e=>e.value,l=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){l.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(r=o.data)&&void 0!==r?r:{});const e=i(o.data);null!=e&&(o.value=Number(e))}return l.length>0&&this.layoutVersion++,l}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,o]of this.edges)r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Er(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Ar(e,t,n,r,o=30){let i=null,l=o,a=1/0;for(const t of e){const e=Mr(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;a>n&&(i=e,a=n)}else l>e.distance&&(i=e,l=e.distance)}if(i)return i;for(const e of t){const t=Cr(e,n,r);t&&l>t.distance&&(i=t,l=t.distance)}return i}function Mr(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,l=Math.sqrt(o*o+i*i);return l>V(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:l}}(e,t,n,r);case"rect":return function(e,t,n){const r=G(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const l=K(Math.atan2(o,r)),a=K(e.startAngle),s=K(e.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Sr=null,Pr=null;function _r(){return Pr||(Sr=document.createElement("canvas"),Sr.width=1,Sr.height=1,Pr=Sr.getContext("2d")),Pr}function Cr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var r,o;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),l=_r();if(!l)return null;if(l.isPointInPath(i,t,n)){const i="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.source)?e.datum.source:null,l="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&l?(i.x1+l.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(i,t,n);if(l.lineWidth=a,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let l=((t-e.x1)*r+(n-e.y1)*o)/i;l=Math.max(0,Math.min(1,l));const a=e.x1+l*r,s=e.y1+l*o,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:s,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const r=new Path2D(e.pathD),o=_r();if(!o)return null;if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(r,t,n);if(o.lineWidth=i,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Tr(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:l,title:a,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=e;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof a?a:"Network Chart"),g.createElement("desc",null,"string"==typeof a?a+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${i.left},${i.top})`},l.map((e,t)=>g.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),v&&v.filter(e=>"widget"!==e.type).map((e,r)=>{if(m){const o=m(e,r,{width:t,height:n,sceneNodes:p});if(o)return g.createElement(g.Fragment,{key:"annotation-"+r},o)}return null}),y),a&&"string"==typeof a?g.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?g.createElement("foreignObject",{x:0,y:0,width:r,height:i.top},a):null,be({legend:s,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var n,r,o,l,a,s,c,u,d;const h=p.find(t=>{var n,r,o,i,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===l?void 0:l.name)===e.nodeId});if(!h)return null;const f=i.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(r=h.x)&&void 0!==r?r:0),y=i.top+(null!==(o=h.cy)&&void 0!==o?o:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(l=h.y)&&void 0!==l?l:0),v=null!==(a=e.dx)&&void 0!==a?a:0,m=null!==(s=e.dy)&&void 0!==s?s:-16,x=null!==(c=e.width)&&void 0!==c?c:32,b=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:f+v-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Dr(e,t){var n,r,o,i,l,a;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const l=t._gradient;if(l){const o=e.createLinearGradient(l.x0,0,l.x1,0),i=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,a="string"==typeof t.style.fill?t.style.fill:"#999";o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(l=t.style.strokeWidth)&&void 0!==l?l:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Lr(e,t){var n,r;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(r=t.style.strokeWidth)&&void 0!==r?r:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Nr(e,t){var n,r,o,i;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,e.fill(l)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(l)),e.restore()}function Ir(e,t){var n,r;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.1,e.fill(o)),e.restore()}Tr.displayName="NetworkSVGOverlay";const Or={top:20,right:80,bottom:20,left:80},$r={top:40,right:40,bottom:40,left:40},Wr=new Set(["chord","force","circlepack","orbit"]),zr=[800,600],Rr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Br({data:e}){var t,n,r,o,i,l;if("edge"===e.nodeOrEdge){const t=e.data;return g.createElement("div",{className:"semiotic-tooltip",style:Rr},g.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const a=e.data,s=null==a?void 0:a.__hierarchyNode;if(s){const e=[];let i=s;for(;i;){const l=null!==(o=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(r=i.data)||void 0===r?void 0:r.id)&&void 0!==o?o:a.id;null!=l&&e.unshift(l+""),i=i.parent}e.length>1&&e.shift();const l=e.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Rr},g.createElement("div",null,e.map((e,t)=>g.createElement("span",{key:t},t>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===l?g.createElement("strong",null,e):g.createElement("span",{style:{opacity:.7}},e)))),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(i=a.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),u=(a.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(a.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Rr},g.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const jr=e.forwardRef(function(t,n){var r,o,i,l,a,c,u,d,h,f,y,p,v,m;const{chartType:x,nodes:b,edges:k,data:w,initialEdges:E,nodeIDAccessor:A="id",sourceAccessor:M="source",targetAccessor:S="target",valueAccessor:P="value",edgeIdAccessor:C,childrenAccessor:T,hierarchySum:D,orientation:L="horizontal",nodeAlign:N="justify",nodePaddingRatio:I=.05,nodeWidth:O=15,iterations:$=300,forceStrength:W=.1,padAngle:z=.01,groupWidth:R=20,sortGroups:B,edgeSort:j,treeOrientation:F="vertical",edgeType:Y="curve",padding:H,paddingTop:X,tensionConfig:G,showParticles:V=!1,particleStyle:q,nodeStyle:U,edgeStyle:K,colorBy:Z,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:ee=.5,colorByDepth:te=!1,nodeSize:ne=8,nodeSizeRange:re=[5,20],nodeLabel:oe,showLabels:ie=!0,labelMode:le,size:ue=zr,responsiveWidth:de,responsiveHeight:ye,margin:ge,className:pe,background:ve,enableHover:me=!0,tooltipContent:xe,customHoverBehavior:be,customClickBehavior:ke,onObservation:we,chartId:Ee,onTopologyChange:Ae,annotations:Me,svgAnnotationRules:Se,legend:Pe,legendPosition:_e,legendHoverBehavior:Ce,legendClickBehavior:Te,legendHighlightedCategory:De,legendIsolatedCategories:Le,title:Ne,foregroundGraphics:Ie,backgroundGraphics:Oe,decay:$e,pulse:We,staleness:ze,thresholds:Re,accessibleTable:Be=!0,description:je,summary:Fe,orbitMode:Ye,orbitSize:He,orbitSpeed:Xe,orbitRevolution:Ge,orbitRevolutionStyle:Ve,orbitEccentricity:Ke,orbitShowRings:Ze,orbitAnimated:Qe}=t,Je=vt(),tt=e.useRef(Je);tt.current=Je;const nt="semiotic-table-"+g.useId(),rt=Wr.has(x)?$r:Or,[ot,it]=he(ue,de,ye),lt=Object.assign(Object.assign({},rt),ge),at=it[0]-lt.left-lt.right,st=it[1]-lt.top-lt.bottom,ct="function"==typeof Ie?Ie({size:it,margin:lt}):Ie,yt=e.useMemo(()=>Object.assign(Object.assign({},nn),G),[G]),mt=e.useMemo(()=>Object.assign(Object.assign({},rn),q),[q]),xt=e.useMemo(()=>({chartType:x,nodeIDAccessor:A,sourceAccessor:M,targetAccessor:S,valueAccessor:P,edgeIdAccessor:C,childrenAccessor:T,hierarchySum:D,orientation:L,nodeAlign:N,nodePaddingRatio:I,nodeWidth:O,iterations:$,forceStrength:W,padAngle:z,groupWidth:R,sortGroups:B,edgeSort:j,treeOrientation:F,edgeType:Y,padding:H,paddingTop:X,tensionConfig:yt,showParticles:V,particleStyle:mt,nodeStyle:U,edgeStyle:K,nodeLabel:oe,showLabels:ie,labelMode:le,colorBy:Z,colorScheme:Q,edgeColorBy:J,edgeOpacity:ee,colorByDepth:te,nodeSize:ne,nodeSizeRange:re,decay:$e,pulse:We,staleness:ze,thresholds:Re,orbitMode:Ye,orbitSize:He,orbitSpeed:Xe,orbitRevolution:Ge,orbitRevolutionStyle:Ve,orbitEccentricity:Ke,orbitShowRings:Ze,orbitAnimated:Qe}),[x,A,M,S,P,T,D,L,N,I,O,$,W,z,R,B,j,F,Y,H,X,yt,V,mt,U,K,oe,ie,le,Z,Q,J,ee,te,ne,re,$e,We,ze,Re,Ye,He,Xe,Ge,Ve,Ke,Ze,Qe]),bt=e.useRef(null),kt=e.useRef(0),wt=e.useRef(0),Et=e.useRef(!0),Pt=At(e=>e.theme),_t=e.useRef(()=>{}),Ct=e.useRef(null);Ct.current||(Ct.current=new wr(xt));const[Tt,Dt]=e.useState(null),[Lt,Nt]=e.useState(0),[It,Wt]=e.useState(0),[zt,Rt]=e.useState(!1),Bt=e.useRef(null),jt=e.useRef(new Map),Ft=e.useRef(0),Yt=e.useCallback(e=>{if("function"==typeof Z)return Z(e)+"";if("string"==typeof Z&&e.data){const t=e.data[Z];if(void 0!==t){if(!jt.current.has(t+"")){const e=Array.isArray(Q)?Q:_;jt.current.set(t+"",e[Ft.current++%e.length])}return jt.current.get(t+"")}}if(jt.current.has(e.id))return jt.current.get(e.id);const t=Array.isArray(Q)?Q:_,n=Z?t[Ft.current++%t.length]:t[0];return jt.current.set(e.id,n),n},[Z,Q]),Ht=e.useCallback(e=>{if("function"==typeof J)return J(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===J&&n?Yt(n):t?Yt(t):"#999"},[J,Yt]),Gt=e.useCallback(e=>{if(!(null==q?void 0:q.colorBy))return Ht(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===mt.colorBy&&n?Yt(n):t?Yt(t):"#999"},[null==q?void 0:q.colorBy,mt.colorBy,Yt,Ht]),Vt="sankey"===x&&V||!!We||null!==(o=null===(r=Ct.current)||void 0===r?void 0:r.isAnimating)&&void 0!==o&&o,qt=e.useCallback(()=>{kt.current&&!Vt||kt.current||(kt.current=requestAnimationFrame(()=>_t.current()))},[Vt]);e.useEffect(()=>{var e;null===(e=Ct.current)||void 0===e||e.updateConfig(xt),Et.current=!0,qt()},[xt,qt]),e.useEffect(()=>{Et.current=!0,qt()},[Pt,qt]);const Ut=e.useCallback(()=>{var e;const t=Ct.current;if(!t)return;t.runLayout([at,st]),t.buildScene([at,st]),Et.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&jt.current.set(n.id,n.style.fill);const n=Array.isArray(Q)?Q:_,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];jt.current.has(t.id)||jt.current.set(t.id,n[e%n.length])}if(Ft.current=r.length,Nt(t.layoutVersion),Ae){const{nodes:e,edges:n}=t.getLayoutData();Ae(e,n)}},[at,st,Ae,Q]),Kt=e.useCallback(e=>{const t=Ct.current;t&&(t.ingestEdge(e)&&Ut(),qt())},[Ut,qt]),Zt=e.useCallback(e=>{const t=Ct.current;if(!t)return;let n=!1;for(const r of e)t.ingestEdge(r)&&(n=!0);n&&Ut(),qt()},[Ut,qt]),Qt=e.useCallback(()=>{var e;null===(e=Ct.current)||void 0===e||e.clear(),jt.current.clear(),Ft.current=0,Nt(0),Dt(null),Bt.current=null,Et.current=!0,qt()},[qt]),Jt=e.useCallback(()=>{const e=Ct.current;e&&(e.tension+=999,Ut(),qt())},[Ut,qt]);e.useImperativeHandle(n,()=>({push:Kt,pushMany:Zt,removeNode:e=>{var t,n,r;const o=null!==(n=null===(t=Ct.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(o){const t=(null===(r=Bt.current)||void 0===r?void 0:r.data)?"function"==typeof A?A(Bt.current.data):Bt.current.data[A]:void 0;Bt.current&&"node"===Bt.current.nodeOrEdge&&t===e&&(Bt.current=null,Dt(null)),jt.current.delete(e),Ut(),Et.current=!0,qt()}return o},removeEdge:(e,t)=>{var n,r;const o=null!==(r=null===(n=Ct.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==r&&r;if(o){if(Bt.current&&"edge"===Bt.current.nodeOrEdge){const n=Bt.current.data;let r;r=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!C||!n||("function"==typeof C?C:e=>null==e?void 0:e[C])(n)===e,r&&(Bt.current=null,Dt(null))}Ut(),Et.current=!0,qt()}return o},updateNode:(e,t)=>{var n,r;const o=null!==(r=null===(n=Ct.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==r?r:null;return o&&(Et.current=!0,qt()),o},updateEdge:(e,t,n)=>{var r,o;const i=null!==(o=null===(r=Ct.current)||void 0===r?void 0:r.updateEdge(e,t,n))&&void 0!==o?o:[];return i.length>0&&(Ut(),Et.current=!0,qt()),i},clear:Qt,getTopology:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ct.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Jt,getTension:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Kt,Zt,Qt,Jt,Ut,qt]);const en=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),tn=en?w||(Array.isArray(k)?void 0:k):void 0;e.useEffect(()=>{var e;const t=Ct.current;if(t)if(en&&tn)t.ingestHierarchy(tn,[at,st]),t.buildScene([at,st]),Et.current=!0,qt();else{const n=b||[],r=Array.isArray(k)?k:[];if(0===n.length&&0===r.length)return;t.ingestBounded(n,r,[at,st]),t.buildScene([at,st]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&jt.current.set(n.id,n.style.fill+"");const o=Array.isArray(Q)?Q:_,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];jt.current.has(t.id)||jt.current.set(t.id,o[e%o.length])}Ft.current=i.length,Et.current=!0,qt()}},[b,k,w,tn,en,at,st,xt,qt,Q]),e.useEffect(()=>{E&&E.length>0&&Zt(E)},[]);const on=e.useCallback(e=>{if(be&&be(e),we){const t=Date.now();we(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ee}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ee})}},[be,we,Ee]),ln=e.useCallback(e=>{if(ke&&ke(e),we){const t=Date.now();we(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ee}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ee})}},[ke,we,Ee]),an=e.useRef(()=>{}),sn=e.useRef(()=>{});an.current=e=>{if(!me)return;const t=bt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-lt.left,o=e.clientY-n.top-lt.top;if(0>r||r>at||0>o||o>st)return void(Bt.current&&(Bt.current=null,Dt(null),on&&(on(null),Et.current=!0),qt()));const i=Ct.current;if(!i)return;const l=Ar(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(Bt.current&&(Bt.current=null,Dt(null),on&&(on(null),Et.current=!0),qt()));const a=Xt(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});Bt.current=a,Dt(a),on&&(on(a),Et.current=!0),qt()},sn.current=()=>{Bt.current&&(Bt.current=null,Dt(null),on&&(on(null),Et.current=!0),qt())};const cn=e.useRef(()=>{});cn.current=e=>{if(!ke&&!we)return;const t=bt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-lt.left,o=e.clientY-n.top-lt.top;if(0>r||r>at||0>o||o>st)return;const i=Ct.current;if(!i)return;const l=Ar(i.sceneNodes,i.sceneEdges,r,o);ln(l?Xt(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)},e.useCallback(e=>an.current(e),[]);const un=e.useCallback(()=>sn.current(),[]),dn=e.useCallback(e=>cn.current(e),[]),hn=e.useRef(-1),fn=e.useRef(null),yn=e.useRef(-1),gn=e.useCallback(e=>{var t;const n=Ct.current;if(!n)return;const r=function(e){var t,n,r,o,i,l;const a=[];for(const s of e)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(t=s.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==l?l:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(n.sceneNodes);if(0===r.length)return;const o=ae(r),i=hn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),hn.current=0,yn.current=-1;const t=o.flat[0];fn.current={shape:t.shape,w:t.w,h:t.h};const n=Xt(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Bt.current=n,Dt(n),on&&(on(n),Et.current=!0),void qt()}const l=se(o,i),a=function(e,t,n,r,o){var i,l,a;const s=n.flat[t.flatIndex];if(!s)return ce(e,t,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const l=e.flat[i];if(l===t)continue;const a=l.x-t.x,s=l.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==l?l:t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n,r,o;const i=e+"",l=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,a="object"==typeof t.source?null===(r=t.source)||void 0===r?void 0:r.id:t.source,s="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,c=null!=a,u=null!=s;c&&a+""===i&&u?l.push(s+""):u&&s+""===i&&c&&l.push(a+"")}return l}(c,r);if(0===e.length)return t.flatIndex;const i=null!==(a=n.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==a?a:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=ce(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,l,o,null!==(t=n.sceneEdges)&&void 0!==t?t:[],yn);if(null===a)return;if(e.preventDefault(),0>a)return hn.current=-1,fn.current=null,yn.current=-1,Bt.current=null,Dt(null),on&&(on(null),Et.current=!0),void qt();hn.current=a;const s=o.flat[a];fn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:s.x,y:s.y,time:s.x,value:s.y,nodeOrEdge:"node"});Bt.current=u,Dt(u),on&&(on(u),Et.current=!0),qt()},[on,qt]),pn=e.useCallback(e=>{hn.current=-1,fn.current=null,an.current(e)},[]);_t.current=()=>{var e,t,n,r,o,i,l;kt.current=0;const a=bt.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=Ct.current;if(!c)return;const u=performance.now(),d=wt.current?Math.min((u-wt.current)/1e3,.1):.016;wt.current=u;const h=c.advanceTransition(tt.current?u+1e6:u),f=!tt.current&&h,y=!tt.current&&c.tickAnimation([at,st],d);(h||Et.current||y)&&c.buildScene([at,st]);const g=St();if(!Mt(a,it,lt,g))return;s.clearRect(-lt.left,-lt.top,it[0],it[1]),ve&&(s.fillStyle=ve,s.fillRect(0,0,at,st)),$e&&c.applyDecay(),We&&c.applyPulse(u),Re&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,v=ze&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Dr(e,n);break;case"line":Lr(e,n);break;case"ribbon":Nr(e,n);break;case"curved":Ir(e,n)}}(s,c.sceneEdges),function(e,t){var n,r,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),Ot(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,o;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),$t(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(s,c.sceneNodes),V&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,r){var o,i;const l=null!==(o=r.spawnRate)&&void 0!==o?o:rn.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:rn.maxPerEdge;for(let r=0;t.length>r;r++){const o=t[r];if(!o.bezier)continue;if(e.countForEdge(r)>=a)continue;const i=o.value*l*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<a;t++)e.spawn(r)}}(c.particlePool,e,d,mt);const t=.5*(null!==(n=mt.speedMultiplier)&&void 0!==n?n:1);let r;if(mt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,r),function(e,t,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:rn.radius,s=null!==(l=r.opacity)&&void 0!==l?l:rn.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const l=t.particles[i];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?r.color(s,t):"#666"}else e.fillStyle=r.color&&"inherit"!==r.color?r.color:o(s);e.beginPath(),e.arc(l.x,l.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(s,c.particlePool,e,mt,Gt)}}v&&(s.globalAlpha=1);const m=Et.current;if(Et.current=!1,m||f||y){const e=bt.current;e&&e.setAttribute("aria-label",et(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(l=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==l?l:0,"Network chart"))}(m||f||y)&&Wt(e=>e+1),(Vt||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(kt.current=requestAnimationFrame(()=>_t.current()))},e.useEffect(()=>(qt(),()=>{kt.current&&(cancelAnimationFrame(kt.current),kt.current=0)}),[qt]),e.useEffect(()=>{Et.current=!0,qt()},[x,at,st,ve,qt]),fe(ze,Ct,Et,qt,zt,Rt);const vn=me&&Tt?g.createElement(pt,{x:Tt.x,y:Tt.y,containerWidth:at,containerHeight:st,margin:lt,className:"stream-network-tooltip",zIndex:2},xe?xe(Tt):g.createElement(Br,{data:Tt})):null;if(Ue){const e=Ct.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),n=t?w||(Array.isArray(k)?void 0:k):void 0;if(t&&n)e.ingestHierarchy(n,[at,st]),e.buildScene([at,st]);else{const t=b||[],n=Array.isArray(k)?k:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[at,st]),e.buildScene([at,st]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],n=null!==(l=null==e?void 0:e.sceneEdges)&&void 0!==l?l:[],r=null!==(a=null==e?void 0:e.labels)&&void 0!==a?a:[];return g.createElement("div",{className:"stream-network-frame"+(pe?" "+pe:""),role:"img","aria-label":je||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:it[0],height:it[1]}},g.createElement(dt,{summary:Fe}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:it[0],height:it[1],style:{position:"absolute",left:0,top:0}},Oe&&g.createElement("g",{transform:`translate(${lt.left},${lt.top})`},Oe),g.createElement("g",{transform:`translate(${lt.left},${lt.top})`},ve&&g.createElement("rect",{x:0,y:0,width:at,height:st,fill:ve}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return g.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:qe(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return g.createElement("circle",{key:"net-circle-"+t,cx:n.cx,cy:n.cy,r:n.r,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=e;return g.createElement("rect",{key:"net-rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=e,r=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return g.createElement("path",{key:"net-arc-"+t,d:r,transform:`translate(${n.cx},${n.cy})`,fill:qe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),r.map((e,t)=>function(e,t){return g.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),g.createElement(Tr,{width:at,height:st,totalWidth:it[0],totalHeight:it[1],margin:lt,labels:r,sceneNodes:t,title:Ne,legend:Pe,legendPosition:_e,legendHoverBehavior:Ce,legendClickBehavior:Te,legendHighlightedCategory:De,legendIsolatedCategories:Le,foregroundGraphics:ct,annotations:Me,svgAnnotationRules:Se,annotationFrame:0}))}const mn=Ct.current;return g.createElement("div",{ref:ot,className:"stream-network-frame"+(pe?" "+pe:""),role:"group","aria-label":je||("string"==typeof Ne?Ne:"Network chart"),tabIndex:0,style:{position:"relative",width:de?"100%":it[0],height:ye?"100%":it[1],overflow:"visible"},onKeyDown:gn},Be&&g.createElement(ht,{tableId:nt}),Be&&g.createElement(ut,{nodes:null!==(c=null==mn?void 0:mn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==mn?void 0:mn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:nt,chartTitle:"string"==typeof Ne?Ne:void 0}),g.createElement(dt,{summary:Fe}),g.createElement("div",{role:"img","aria-label":je||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:me?pn:void 0,onMouseLeave:me?un:void 0,onClick:ke||we?dn:void 0},Oe&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:it[0],height:it[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${lt.left},${lt.top})`},Oe)),g.createElement("canvas",{ref:bt,"aria-label":et(null!==(h=null===(d=null==mn?void 0:mn.sceneNodes)||void 0===d?void 0:d.length)&&void 0!==h?h:0,null!==(y=null===(f=null==mn?void 0:mn.sceneEdges)||void 0===f?void 0:f.length)&&void 0!==y?y:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(ft,{hoverPoint:Tt}),g.createElement(Tr,{width:at,height:st,totalWidth:it[0],totalHeight:it[1],margin:lt,labels:(null==mn?void 0:mn.labels)||[],sceneNodes:null==mn?void 0:mn.sceneNodes,title:Ne,legend:Pe,legendPosition:_e,legendHoverBehavior:Ce,legendClickBehavior:Te,legendHighlightedCategory:De,legendIsolatedCategories:Le,foregroundGraphics:ct,annotations:Me,svgAnnotationRules:Se,annotationFrame:It}),g.createElement(gt,{active:hn.current>=0,hoverPoint:Tt,margin:lt,size:it,shape:null===(p=fn.current)||void 0===p?void 0:p.shape,width:null===(v=fn.current)||void 0===v?void 0:v.w,height:null===(m=fn.current)||void 0===m?void 0:m.h}),vn,(null==ze?void 0:ze.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ze.badgePosition?{top:4,left:4}:"bottom-left"===ze.badgePosition?{bottom:4,left:4}:"bottom-right"===ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:zt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},zt?"STALE":"LIVE")))});function Fr(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Yr(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}jr.displayName="StreamNetworkFrame";const[Hr,Xr]=mt(e=>({selections:new Map,setClause(t,n){e(e=>{const r=new Map(e.selections),o=Yr(r,t),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r)return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(t,n){e(e=>{const r=new Map(e.selections),o=Yr(r,t);return r.set(t,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(t){e(e=>{const n=new Map(e.selections),r=n.get(t);return r&&n.set(t,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Gr,Vr]=mt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function qr(t){const n=e.useId(),r=t.clientId||n,{name:o}=t,i=Xr(e=>e.selections.get(o)),l=Xr(e=>e.setClause),a=Xr(e=>e.clearClause),s=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Fr(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,r):()=>!0,[i,r]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};l(o,{clientId:r,type:"point",fields:t})},[r,o,l]),selectInterval:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r};l(o,{clientId:r,type:"interval",fields:t})},[r,o,l]),clear:e.useCallback(()=>{a(o,r)},[a,o,r]),clientId:r}}function Ur({selection:t,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:l,chartId:a,onClick:s,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,r),f=qr({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const n=t.name||"hover",{fields:r}=t,{predicate:o,isActive:i,selectPoints:l,clear:a}=qr({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&l(t)},[r,l,a,n]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||r||[]}),g=Vr(e=>e.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=e.useState(null),x=u||r[0],b=e.useMemo(()=>{if(!c||null==v||!x)return null;const e=v,t=x;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[t]?n[t]:(null!==(r=n[t])&&void 0!==r?r:"")+"")===e}}},[c,v,x]),k=e.useCallback(e=>{var t,r;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const r=Le.positions.get(e);(null==r?void 0:r.locked)||r&&r.xValue===t&&r.sourceId===n||(Le={positions:new Map(Le.positions).set(e,{xValue:t,sourceId:n})},Ie())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Oe(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];m(null!=n?n+"":null)}else m(null);if(i||g){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(l),g&&g(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),g&&g(e)}}},[n,y,h,d,i,l,a,g,c,x]),w=e.useCallback(e=>{var t,n,r,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const r=Le.positions.get(e);if(null==r?void 0:r.locked){const t=new Map(Le.positions);return t.delete(e),Le={positions:t},Ie(),!1}Le={positions:new Map(Le.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ie()}(h.name||"hover",Number(n),d)}if(e&&s){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]),s(r,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||g){const t={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(l),g&&g(l)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),g&&g(e)}}},[s,i,g,l,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{$e(e,d),Oe(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}const Kr={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Zr(e,t,n){var r,o,i,l,a,s,c;const u=Kr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(r=t.width)&&void 0!==r?r:u.width,height:null!==(o=t.height)&&void 0!==o?o:u.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(l=t.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Qr(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function Qr(e,t,n){if(!1!==t)return e;const r=Object.assign({},e);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const Jr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},eo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function to(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?g.createElement("div",{style:Object.assign(Object.assign({},Jr),{width:t,height:n})},r||"No data available"):null}function no(e,t,n){if(!e)return null;const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),i=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(o+i)-i))/2);return g.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(e,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},eo),{position:"absolute",top:l+n*(o+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2})})))}const ro=e.forwardRef(function(t,n){var r,o,i,l;const a=Zr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:P,annotations:_,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:N,staleness:I,transition:O,linkedHover:$,selection:W,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=M?M:S,U=e.useRef(null),{customHoverBehavior:K}=Ur({selection:W,linkedHover:$,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:R}),Z=e.useCallback(e=>{P&&P(e),K(e)},[P,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=no(B,V[0],V[1]),J=Q?null:to(y,V[0],V[1],j),ee={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(tn,{ref:U,chartType:"line",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:ee,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:_,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:N,staleness:I,transition:O,pointIdAccessor:t.pointIdAccessor,legendPosition:Y})});ro.displayName="RealtimeLineChart";const oo=e.forwardRef(function(t,n){var r,o,i,l;const a=Zr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:s,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:P,background:_,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,linkedHover:$,selection:W,decay:z,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:V,brush:q,onBrush:U,linkedBrush:K}=t,Z=a.showAxes,Q=a.enableHover,J=null!=u?u:a.marginDefaults,ee=null!=c?c:[a.width,a.height],te=null!=C?C:T,ne=e.useRef(null),{customHoverBehavior:re}=Ur({selection:W,linkedHover:$,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),oe=e.useCallback(e=>{D&&D(e),re(e)},[D,re]),ie=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,le=(ae=K)?"string"==typeof ae?{name:ae}:ae:null;var ae;const se=function(t){const{name:n,xField:r,yField:o}=t,{predicate:i,isActive:l,selectInterval:a,clear:s}=qr({name:n}),c=r&&o?"xyBrush":r?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void s();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(r&&(t[r]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?r&&(t[r]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,r,o,a,s]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:l,clear:s}}(Object.assign({name:(null==le?void 0:le.name)||"__unused_hist_brush__",xField:(null==le?void 0:le.xField)||("string"==typeof v?v:"time")},(null==le?void 0:le.yField)?{yField:le.yField}:{})),ce=e.useRef(se.brushInteraction);ce.current=se.brushInteraction;const ue=e.useCallback(e=>{if(U&&U(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),le){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,F,Y,le]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=ne.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const de=no(H,ee[0],ee[1]),he=de?null:to(p,ee[0],ee[1],X),fe={};return null!=A&&(fe.fill=A),null!=M&&(fe.stroke=M),null!=S&&(fe.strokeWidth=S),null!=P&&(fe.gap=P),de||he||g.createElement(tn,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:J,className:G?`${d||""} semiotic-emphasis-${G}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:fe,showAxes:Z,background:_,hoverAnnotation:Q,tooltipContent:te,customHoverBehavior:oe,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,decay:z,pulse:R,staleness:B,transition:j,pointIdAccessor:t.pointIdAccessor,legendPosition:V,brush:ie||(K?{dimension:"x"}:void 0),onBrush:ie||K?ue:void 0})});oo.displayName="RealtimeTemporalHistogram";const io=oo,lo=e.forwardRef(function(t,n){var r,o,i,l;const a=Zr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,linkedHover:$,selection:W,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:T,U=e.useRef(null),{customHoverBehavior:K}=Ur({selection:W,linkedHover:$,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:R}),Z=e.useCallback(e=>{D&&D(e),K(e)},[D,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=no(B,V[0],V[1]),J=Q?null:to(y,V[0],V[1],j),ee={};return null!=E&&(ee.radius=E),null!=A&&(ee.fill=A),null!=M&&(ee.opacity=M),null!=S&&(ee.stroke=S),null!=P&&(ee.strokeWidth=P),Q||J||g.createElement(tn,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});lo.displayName="RealtimeSwarmChart";const ao=e.forwardRef(function(t,n){var r,o,i,l;const a=Zr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:P,background:_,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,linkedHover:$,selection:W,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:T,U=e.useRef(null),{customHoverBehavior:K}=Ur({selection:W,linkedHover:$,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:R}),Z=e.useCallback(e=>{D&&D(e),K(e)},[D,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=no(B,V[0],V[1]),J=Q?null:to(y,V[0],V[1],j),ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=E&&(ee.connectorStroke=E),null!=A&&(ee.connectorWidth=A),null!=M&&(ee.gap=M),null!=S&&(ee.stroke=S),null!=P&&(ee.strokeWidth=P),Q||J||g.createElement(tn,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:ee,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:L,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:O,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});ao.displayName="RealtimeWaterfallChart";const so=e.forwardRef(function(t,n){var r,o,i,l;const a=Zr(t.mode,{width:null!==(o=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==o?o:t.width,height:null!==(l=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:P,onHover:_,annotations:C,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:L,decay:N,pulse:I,staleness:O,linkedHover:$,selection:W,onObservation:z,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=S?S:P,U=e.useRef(null),{customHoverBehavior:K}=Ur({selection:W,linkedHover:$,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:R}),Z=e.useCallback(e=>{_&&_(e),K(e)},[_,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q=no(B,V[0],V[1]),J=Q?null:to(y,V[0],V[1],j);return Q||J||g.createElement(tn,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:L,decay:N,pulse:I,staleness:O,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});so.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=so,exports.RealtimeHistogram=io,exports.RealtimeLineChart=ro,exports.RealtimeSwarmChart=lo,exports.RealtimeWaterfallChart=ao,exports.RingBuffer=k,exports.StreamNetworkFrame=jr,exports.StreamXYFrame=tn;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),r=require("d3-scale"),i=require("d3-quadtree"),o=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function f(e){return e&&e.__esModule?e:{default:e}}function y(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const g=y(e),p=f(c);function v(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r+1>>1;t[i]>e?r=i-1:n=i}return t[n]}function m(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r>>1;e>t[i]?n=i+1:r=i}return t[n]}function x({width:r,height:i,totalWidth:o,totalHeight:l,margin:a,dimension:s,scales:c,onBrush:u,binSize:d,snap:h,binBoundaries:f,snapDuring:y,streaming:p}){const x=e.useRef(null),b=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const E=e.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),A=e.useRef(E);A.current=E;const M=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!x.current)return;const e=t.select(x.current).select(".brush-g"),o="x"===s?n.brushX():"y"===s?n.brushY():n.brush();return o.extent([[0,0],[r,i]]),o.on("brush end",t=>{if(M.current)return;const n=w.current;if(!n)return;if(!t.selection)return S.current=null,void k.current(null);let l,a;if("x"===s){const[e,r]=t.selection;l=[n.x.invert(e),n.x.invert(r)],a=[n.y.invert(i),n.y.invert(0)]}else if("y"===s){const[e,i]=t.selection;l=[n.x.invert(0),n.x.invert(r)],a=[n.y.invert(i),n.y.invert(e)]}else{const[[e,r],[i,o]]=t.selection;l=[n.x.invert(e),n.x.invert(i)],a=[n.y.invert(o),n.y.invert(r)]}if("bin"===h&&"y"!==s&&("end"===t.type||"brush"===t.type&&y)){const r=A.current;r&&r.length>0?l=function(e,t){return 0===t.length?e:[v(e[0],t),m(e[1],t)]}(l,r):d&&d>0&&(l=[Math.floor(l[0]/d)*d,Math.ceil(l[1]/d)*d]);const i=n.x(l[0]),a=n.x(l[1]);if(M.current=!0,"x"===s)e.call(o.move,[i,a]);else if("xy"===s){const n=t.selection;e.call(o.move,[[i,n[0][1]],[a,n[1][1]]])}M.current=!1}const c={x:l,y:a};S.current=c,k.current(c)}),e.call(o),b.current=o,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),b.current=null}},[r,i,s,h,d,y]),e.useEffect(()=>{if(!(p&&c&&b.current&&S.current))return;if(!x.current)return;if("y"===s)return;const e=S.current,n=c.x.domain()[0],r=t.select(x.current).select(".brush-g");if(n>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);let i=e.x[0],o=!1;if(n>e.x[0]){if(i=n,"bin"===h){const e=A.current;e&&e.length>0?i=m(n,e):d&&d>0&&(i=Math.ceil(n/d)*d)}if(i>=e.x[1])return M.current=!0,r.call(b.current.move,null),M.current=!1,S.current=null,void k.current(null);o=!0}const l=c.x(i),a=c.x(e.x[1]);if(M.current=!0,"x"===s)r.call(b.current.move,[l,a]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);r.call(b.current.move,[[l,t],[a,n]])}if(M.current=!1,o){const t={x:[i,e.x[1]],y:e.y};S.current=t,k.current(t)}},[c,p,s,h,d]),g.createElement("svg",{ref:x,width:o,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}class b{constructor(e,t){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==t?void 0:t.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const o=(r+i)%this._capacity,l=this.buffer[o];if(e(l)){let e;e="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(e),this.buffer[o]=t(l)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class w{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function E(e,t,n,r,i){const o=new Map;for(const l of e){const e=t(l),a=n(l);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const s=Math.floor(e/r)*r;let c=o.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},o.set(s,c)),c.total+=a,i){const e=i(l);c.categories.set(e,(c.categories.get(e)||0)+a)}}return o}function A(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function M(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function _(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const P=o.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function T(e,t,n){var r,i,o;if(1>=n)return 1;const l=null!==(r=e.minOpacity)&&void 0!==r?r:.1,a=n-1-t;switch(e.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:n/2;return l+Math.pow(.5,a/t)*(1-l)}case"step":return(null!==(o=e.stepThreshold)&&void 0!==o?o:.5*n)>a?1:l;default:return 1}}function D(e,t,n){var r;const i=null!==(r=e.duration)&&void 0!==r?r:500,o=n-t;return i>o?1-o/i:0}function L(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function O(e,t){return Math.min((e-t.startTime)/t.duration,1)}function N(e,t,n){return e+(t-e)*n}function I(e,t,n){var r,i,o,l;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(l=null!==(i=null===(r=t.datum)||void 0===r?void 0:r.binStart)&&void 0!==i?i:null===(o=t.datum)||void 0===o?void 0:o.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function $(e,t,n,r,i,o){const l=[];for(const i of e){const e=n(i),o=r(i);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||l.push({px:t.x(e),py:t.y(o),rawY:o,d:i})}l.sort((e,t)=>e.px-t.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];a[e]=[t.px,t.py],s[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:s,style:i,datum:c,group:o}}function W(e,t,n,r,i,o,l,a){const s=[];for(const o of e){const e=n(o),l=r(o);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const c=t.x(e),u=a?a(o):i;s.push({px:c,topY:t.y(l),botY:t.y(u)})}s.sort((e,t)=>e.px-t.px);const c=Array(s.length),u=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:o,datum:e,group:l}}function R(e,t,n,r,i,o,l){const a=n(e),s=r(e);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:t.x(a),y:t.y(s),r:i,style:o,datum:e};return void 0!==l&&(c.pointId=l),c}function z(e,t,n,r,i,o,l){return{type:"rect",x:e,y:t,w:n,h:r,style:i,datum:o,group:l}}function B(e,t,n,r,i,o,l){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:i,datum:o};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function F(e,t,n){if(!e.getBounds||!e.scales)return null;const r=[],i=[];for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const l=e.getBounds(n),a=e.scales.x(t);if(l&&0!==l)r.push([a,e.scales.y(o+l)]),i.push([a,e.scales.y(o-l)]);else{const t=e.scales.y(o);r.push([a,t]),i.push([a,t])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function j(e,t,n,r){var i;if(!e.config.pointStyle)return;const o=null!=r?r:e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const l of r.data){let r=e.config.pointStyle(l);!r.fill&&t&&(r=Object.assign(Object.assign({},r),{fill:t}));const a=null!==(i=r.r)&&void 0!==i?i:3,s=e.getPointId?e.getPointId(l)+"":void 0,c=R(l,e.scales,e.getX,o,a,r,s);c&&n.push(c)}}}const Y={blues:o.interpolateBlues,reds:o.interpolateReds,greens:o.interpolateGreens,viridis:o.interpolateViridis},H=new Map;class X{constructor(e){if(this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=e,this.buffer=new k(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=M(e.timeAccessor||e.xAccessor,"time"),this.getY=M(e.valueAccessor||e.yAccessor,"value")):(this.getX=M(e.xAccessor,"x"),this.getY=M(e.yAccessor,"y")),this.getGroup=_(e.groupAccessor),this.getCategory=_(e.categoryAccessor),this.getSize=e.sizeAccessor?M(e.sizeAccessor,"size"):void 0,this.getColor=_(e.colorAccessor),this.getBounds=e.boundsAccessor?M(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?M(e.y0Accessor,"y0"):void 0,this.getPointId=_(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?M(e.openAccessor,"open"):void 0,this.getHigh=M(e.highAccessor,"high"),this.getLow=M(e.lowAccessor,"low"),this.getClose=n?M(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new k(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?M(this.config.timeAccessor||this.config.xAccessor,"time"):M(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],i=r instanceof Date,o="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=i||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,i,o,l,a,s;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let y=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(i=c.xExtent[1])&&void 0!==i?i:h[1]]:h,g=c.yExtent?[null!==(o=c.yExtent[0])&&void 0!==o?o:f[0],null!==(l=c.yExtent[1])&&void 0!==l?l:f[1]]:f;const p=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!p&&u.size>0)if(c.normalize)g=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;let r=0;for(const e of t)for(const t of e.data){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const o=(n.get(e)||0)+i;n.set(e,o),o>r&&(r=o)}g=[0,r+(r>0?r*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.size>0){const[,e]=function(e,t,n,r,i){const o=E(e,t,n,r,i);if(0===o.size)return[0,0];let l=0;for(const e of o.values())e.total>l&&(l=e.total);return[0,l]}(u,this.getX,this.getY,c.binSize,this.getCategory);g=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.size>0){const[e,t]=function(e,t){let n=0,r=0,i=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>r&&(r=i))}return[n,r]}(u,this.getY),n=t-e,r=n>0?n*c.extentPadding:1;g=[Math.min(0,e-Math.abs(r)),Math.max(0,t+Math.abs(r))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*c.extentPadding:1,n=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=r?g[1]:g[1]+t],"log"===c.yScaleType&&0>=g[0]&&f[0]>0&&(g[0]=null!=n?g[0]:f[0]/(1+c.extentPadding))}if(y[0]===1/0||y[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();y=[e-864e5,e]}else y=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(v)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const t="right"===c.arrowOfTime?[m,e.width-m]:[e.width-m,m];this.scales={x:r.scaleLinear().domain(y).range(t),y:r.scaleLinear().domain(g).range([e.height-m,m])}}else{const t="down"===c.arrowOfTime?[m,e.height-m]:[e.height-m,m];this.scales={x:r.scaleLinear().domain(g).range([m,e.width-m]),y:r.scaleLinear().domain(y).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,y,[m,e.width-m]),y:t(c.yScaleType,g,[e.height-m,m])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return this._quadtree=null,void(this._maxPointRadius=0);let t=0,n=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxPointRadius=n,X.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const r=Array(t);let o=0;for(const e of this.scene)"point"===e.type&&(r[o++]=e);this._quadtree=i.quadtree().x(e=>e.x).y(e=>e.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const i=this.scales.x.domain(),o=this.scales.y.domain(),l=this.scales.x.range(),a=this.scales.y.range(),s=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return r.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?r.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):r.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:s(this.config.xScaleType,i,l[0]>l[1]?[e.width-c,c]:[c,e.width-c]),y:s(this.config.yScaleType,o,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:r,scales:i}=this;if(!i||0===t.length)return[];const l={scales:i,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(e,t){var n;const r=e.groupData(t),i=[],o=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of r){const n=F(e,t.data,t.key);n&&i.push(n)}for(const t of r){const n=e.resolveLineStyle(t.key,t.data[0]),r=$(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(r.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}return j(e,r,i),i}(l,t);case"area":return function(e,t){const n=e.groupData(t),r=[],i=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),l=W(t.data,e.scales,e.getX,e.getY,i,n,t.key,o);e.config.gradientFill&&(l.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(l.curve=e.config.curve),e.config.lineGradient&&(l.strokeGradient=e.config.lineGradient),r.push(l)}return j(e,n,r),r}(l,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],i=e.config.areaGroups||new Set,o=e.scales.y.domain()[0],l=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n)if(i.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),i=W(t.data,e.scales,e.getX,e.getY,o,n,t.key,l);e.config.gradientFill&&(i.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}else{const n=e.resolveLineStyle(t.key,t.data[0]),i=$(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return j(e,n,r),r}(l,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const r=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:i,stackedTops:o}=function(e,t,n,r,i,o,l){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const c=Array.from(s).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),o=r(i);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let d;if(o){d=new Map;for(const t of c){let n=0;for(const r of e)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(t))||0;d.set(t,n||1)}}const h=[],f=new Map,y=new Map;for(const e of c)y.set(e,0);for(const n of e){const e=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let i=e.get(n)||0;const l=y.get(n);o&&(i/=d.get(n));const c=l+i,u=t.x(n);a.push([u,t.y(l)]),r.push([u,t.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),h.push(g)}return{nodes:h,stackedTops:f}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,r),l=i;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=o.get(r.key);if(n)for(const i of r.data){const r=e.getX(i),o=e.getY(i);null==r||Number.isNaN(r)||null==o||Number.isNaN(o)||!n.has(r)||t.set(i,n.get(r))}}const r=n=>{var r;return null!==(r=t.get(n))&&void 0!==r?r:e.getY(n)};j(e,n,l,r)}return l}(l,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,i=e.config.sizeRange||[3,15];let o=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);o=n=>e===t?(i[0]+i[1])/2:i[0]+(n-e)/(t-e)*(i[1]-i[0])}}const l=e.getColor?e.resolveColorMap(t):null;for(const i of t){let t=e.config.pointStyle?e.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},a=t.r||r;if(o&&e.getSize){const t=e.getSize(i);null==t||Number.isNaN(t)||(a=o(t))}if(l&&e.getColor&&!t.fill){const n=e.getColor(i);n&&l.has(n)&&(t=Object.assign(Object.assign({},t),{fill:l.get(n)}))}const s=e.getPointId?e.getPointId(i)+"":void 0,c=R(i,e.scales,e.getX,e.getY,a,t,s);c&&n.push(c)}return n}(l,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var r,i,o;const l=Math.max(1,Math.floor(null!==(r=e.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(i=e.config.heatmapYBins)&&void 0!==i?i:20)),s=null!==(o=e.config.heatmapAggregation)&&void 0!==o?o:"count",c=M(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,f]=e.scales.y.domain(),y=(d-u||1)/l,g=(f-h||1)/a,p=l*a;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;t.length>n;n++){const r=t[n],i=e.getX(r),o=e.getY(r);if(!isFinite(i)||!isFinite(o))continue;const s=Math.min(Math.floor((i-u)/y),l-1),d=Math.min(Math.floor((o-h)/g),a-1);if(0>s||0>d)continue;const f=d*l+s;v[f]++;const p=c(r);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let e=0;p>e;e++){if(0===v[e])continue;let t;switch(s){case"sum":t=m[e];break;case"mean":t=m[e]/v[e];break;default:t=v[e]}x>t&&(x=t),t>b&&(b=t)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,E=n.height/a,A=e.config.showValues,S=e.config.heatmapValueFormat,_=[];for(let e=0;a>e;e++){const t=e*l;for(let n=0;l>n;n++){const r=t+n;if(0===v[r])continue;let i;switch(s){case"sum":i=m[r];break;case"mean":i=m[r]/v[r];break;default:i=v[r]}const o=(i-x)/k;_.push(B(n*w,(a-1-e)*E,w,E,`rgb(${220-(180*o+.5)|0},${220-(100*o+.5)|0},${255-(50*o+.5)|0})`,{xi:n,yi:e,value:i,count:v[r],sum:m[r]},A?{value:i,showValues:!0,valueFormat:S}:void 0))}}return _}(e,t,n);if(0===t.length)return[];const r=M(e.config.valueAccessor,"value"),i=S(e.config.xAccessor,"x"),l=S(e.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=i(n),o=l(n);c[e]=r,u[e]=o,a.has(r)||a.set(r,a.size),s.has(o)||s.set(o,s.size)}const d=a.size,h=s.size;if(0===d||0===h)return[];const f=Array.from(a.keys()),y=Array.from(s.keys()),g=f.every(e=>"number"==typeof e&&!isNaN(e)),p=y.every(e=>"number"==typeof e&&!isNaN(e));if(g){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}if(p){y.sort((e,t)=>e-t),s.clear();for(let e=0;y.length>e;e++)s.set(y[e],e)}const v=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),b=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],i=a.get(c[e]),o=s.get(u[e]);if(void 0===i||void 0===o)continue;const l=r(n),h=o*d+i,f=b.get(h);let y;void 0!==f?y=f:(y=k++,b.set(h,y)),v[y]=h,m[y]=l,x[y]=n}let w=1/0,E=-1/0;for(let e=0;k>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>E&&(E=t))}if(!isFinite(w)||!isFinite(E))return[];const A=function(e){const t=e in Y?e:"blues";let n=H.get(t);if(n)return n;n=Array(256);const r=Y[t]||o.interpolateBlues;for(let e=0;256>e;e++)n[e]=r(e/255);return H.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),_=255/(E-w||1),P=n.width/d,C=n.height/h,T=e.config.showValues,D=e.config.heatmapValueFormat,L=[];for(let e=0;k>e;e++){const t=m[e];if(!isFinite(t))continue;const n=v[e],r=n%d;L.push(B(r*P,(h-1-(n-r)/d)*C,P,C,A[Math.min((t-w)*_+.5|0,255)],x[e],T?{value:t,showValues:!0,valueFormat:D}:void 0))}return L}(l,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const r=E(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let i=null;if(e.getCategory){const t=new Set;for(const e of r.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(n),l=Array.from(t).filter(e=>!o.has(e)).sort(),a=n.filter(e=>t.has(e)),s=a.join("\0")+""+l.join("\0");e.barCategoryCache&&e.barCategoryCache.key===s?i=e.barCategoryCache.order:(i=[...a,...l],e.barCategoryCache={key:s,order:i})}const o=[],l=e.scales,[a,s]=l.x.domain();for(const t of r.values()){const r=Math.max(t.start,a),c=Math.min(t.end,s);if(r>=c)continue;const u=l.x(r),d=l.x(c),h=Math.abs(d-u),f=h>2?1:0,y=Math.min(u,d)+f/2,g=Math.max(h-f,1);if(g>0)if(i&&t.categories.size>0){let r=0;for(const a of i){const i=t.categories.get(a)||0;if(0===i)continue;const s=l.y(r),c=l.y(r+i);o.push(z(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:i},a)),r+=i}}else{const e=l.y(0),n=l.y(t.total);o.push(z(y,Math.min(e,n),g,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of r.values())c.add(e.start),c.add(e.end);return{nodes:o,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(l,t);return this._barCategoryCache=null!==(n=l.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,r,i,o;const l=[],a=e.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(i=a.opacity)&&void 0!==i?i:.7,d=a.stroke,h=a.strokeWidth;for(const n of t){const t=e.getX(n),r=e.getY(n);if(null==r||Number.isNaN(r))continue;const i=e.scales.x(t),a=e.scales.y(r);let f=c;if(e.getCategory){const t=e.getCategory(n);f=(null===(o=e.config.barColors)||void 0===o?void 0:o[t])||f}const y={type:"point",x:i,y:a,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(y.pointId=e.getPointId(n)+""),l.push(y)}return l}(l,t);case"waterfall":return function(e,t,n){var r,i,o;const l=[],a=e.scales,s=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",d=null!==(i=null==s?void 0:s.negativeColor)&&void 0!==i?i:"#dc3545",h=null!==(o=null==s?void 0:s.gap)&&void 0!==o?o:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let t=0;c.length>t;t++){const r=c[t],i=e.getX(r),o=e.getY(r),p=g+o;let v;v=c.length-1>t?e.getX(c[t+1])-i:t>0?i-e.getX(c[t-1]):0;const m=a.x(i),x=0!==v?a.x(i+v):m+n.width/10,b=Math.min(m,x)+h/2,k=Math.max(m,x)-h/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(z(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>o?d:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:o,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(l,t,e);case"candlestick":return function(e,t){var n,r;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||e.getOpen&&e.getClose))return[];const o=[],l=e.config.candlestickStyle||{},a=l.rangeColor||"#6366f1",s=i?a:l.upColor||"#28a745",c=i?a:l.downColor||"#dc3545",u=i?a:l.wickColor||"#333",d=l.wickWidth||(i?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let f=i?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!i&&null==l.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));r>0&&t>r&&(t=r)}f=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else i||null!=l.bodyWidth||(f=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const r=e.getHigh(n),l=e.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=i?r:e.getOpen(n),h=i?l:e.getClose(n);if(!i&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const y=h>=a,g={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(r),lowY:e.scales.y(l),bodyWidth:f,upColor:s,downColor:c,wickColor:u,wickWidth:d,isUp:y,datum:n};i&&(g.isRange=!0),o.push(g)}return o}(l,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?T(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var r,i;const o=n.length;if(1>=o)return;const l=new Map;for(let e=0;n.length>e;e++)l.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const r=Array(t.length);let i=!1;for(let n=0;t.length>n;n++){const a=l.get(t[n]);null!=a?(r[n]=T(e,a,o),1>r[n]&&(i=!0)):r[n]=1}i&&(n._decayOpacities=r);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:t.length;if(2>r)continue;if(t.length===r){const i=Array(r);let a=!1;for(let n=0;t.length>n;n++){const r=l.get(t[n]);null!=r?(i[n]=T(e,r,o),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of t){const t=l.get(n);if(null!=t){const n=T(e,t,o);i>n&&(i=n)}}if(1>i){const e=Array(r);e.fill(i),n._decayOpacities=e}}continue}const t=l.get(n.datum);if(null==t)continue;const a=T(e,t,o);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(i=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,r){var i,o;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=e.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",s=null!==(o=e.glowRadius)&&void 0!==o?o:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let i=0;for(const n of t){const t=c.get(n);if(null==t)continue;const o=r.get(t);if(null==o)continue;const a=D(e,o,l);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const i=r.get(t);if(null==i)continue;const o=D(e,i,l);o>0&&(n._pulseIntensity=o,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=e.duration)&&void 0!==n?n:500,o=t.peek();return null!=o&&i>r-o}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){var i,o,l;n.clear(),r.clear();for(let a=0;t.length>a;a++){const s=t[a],c=I(e,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(e=>[e[0],e[1]]),opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(e=>[e[0],e[1]]),bottomPath:s.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const r=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.y(0))&&void 0!==t?t:0;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],i=I(this.transitionContext,t,e);i&&("point"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,r:0,opacity:0}):"rect"===t.type?this.prevPositionMap.set(i,{x:t.x,y:r,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}):"heatcell"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,w:t.w,h:t.h,opacity:0}):"line"===t.type?(t._introClipFraction=0,this.prevPathMap.set(i,{path:t.path.map(e=>[e[0],e[1]]),opacity:t.style.opacity})):"area"===t.type&&(t._introClipFraction=0,this.prevPathMap.set(i,{topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),opacity:t.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,i){var o,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M,S,_,P,C,T,D,L;if(0===r.size&&0===i.size)return n;const O=null!==(o=t.duration)&&void 0!==o?o:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let N=!1;const $=new Set,W=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],E=I(e,o,t);if(!E)continue;if(o._transitionKey=E,"line"===o.type||"area"===o.type){const e=i.get(E);if(e){if(W.add(E),"line"===o.type&&e.path&&e.path.length===o.path.length){o._targetPath=o.path.map(e=>[e[0],e[1]]),o._prevPath=e.path;for(let t=0;o.path.length>t;t++)o.path[t]=[e.path[t][0],e.path[t][1]];N=!0}else if("area"===o.type&&e.topPath&&e.bottomPath&&e.topPath.length===o.topPath.length&&e.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(e=>[e[0],e[1]]),o._targetBottomPath=o.bottomPath.map(e=>[e[0],e[1]]),o._prevTopPath=e.topPath,o._prevBottomPath=e.bottomPath;for(let t=0;o.topPath.length>t;t++)o.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;o.bottomPath.length>t;t++)o.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];N=!0}o._targetOpacity=null!==(l=o.style.opacity)&&void 0!==l?l:1,o._startOpacity=null!==(s=null!==(a=e.opacity)&&void 0!==a?a:o.style.opacity)&&void 0!==s?s:1}else o._targetOpacity=null!==(c=o.style.opacity)&&void 0!==c?c:1,o._startOpacity=0,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),N=!0;continue}const A=r.get(E);if("point"===o.type)if(A){$.add(E);const e={x:o.x,y:o.y,r:o.r};o._targetOpacity=null!==(u=o.style.opacity)&&void 0!==u?u:1,A.x===e.x&&A.y===e.y&&A.r===e.r||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.r,o.x=A.x,o.y=A.y,o.r=null!==(d=A.r)&&void 0!==d?d:o.r,N=!0)}else o._targetOpacity=null!==(h=o.style.opacity)&&void 0!==h?h:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),N=!0;else if("rect"===o.type)if(A){$.add(E);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(f=o.style.opacity)&&void 0!==f?f:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=A.x,o.y=A.y,o.w=null!==(y=A.w)&&void 0!==y?y:o.w,o.h=null!==(g=A.h)&&void 0!==g?g:o.h,N=!0)}else o._targetOpacity=null!==(p=o.style.opacity)&&void 0!==p?p:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),N=!0;else if("heatcell"===o.type)if(A){$.add(E);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(m=null===(v=o.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,A.x===e.x&&A.y===e.y&&A.w===e.w&&A.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=A.x,o.y=A.y,o.w=null!==(x=A.w)&&void 0!==x?x:o.w,o.h=null!==(b=A.h)&&void 0!==b?b:o.h,N=!0)}else o._targetOpacity=null!==(w=null===(k=o.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,o.style=Object.assign(Object.assign({},o.style||{}),{opacity:0}),N=!0}for(const[e,t]of i)if(!W.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),N=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),N=!0}for(const[e,t]of r)if(!$.has(e)){if(e.startsWith("p:")){const r={type:"point",x:t.x,y:t.y,r:null!==(M=t.r)&&void 0!==M?M:3,style:{opacity:null!==(S=t.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("r:")){const r={type:"rect",x:t.x,y:t.y,w:null!==(_=t.w)&&void 0!==_?_:0,h:null!==(P=t.h)&&void 0!==P?P:0,style:{opacity:null!==(C=t.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}else if(e.startsWith("h:")){const r={type:"heatcell",x:t.x,y:t.y,w:null!==(T=t.w)&&void 0!==T?T:0,h:null!==(D=t.h)&&void 0!==D?D:0,fill:"#999",datum:null,style:{opacity:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(r)}N=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),N&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:O}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){var i,o,l,a,s;if(!n.activeTransition)return!1;const c=O(e,n.activeTransition),u=L(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=N(o,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=N(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=N(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0,i=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:N(i,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=N(n.x,e._targetX,u),e.y=N(n.y,e._targetY,u),void 0!==n.w&&(e.w=N(n.w,e._targetW,u)),void 0!==n.h&&(e.h=N(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(a=e._startOpacity)&&void 0!==a?a:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}void 0!==e._introClipFraction&&(e._introClipFraction=u);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=N(t[r][0],n[r][0],u),e.path[r][1]=N(t[r][1],n[r][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(s=e._startOpacity)&&void 0!==s?s:0;e.style=Object.assign(Object.assign({},e.style),{opacity:N(t,e._targetOpacity,u)})}void 0!==e._introClipFraction&&(e._introClipFraction=u);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,i=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=N(t[n][0],r[n][0],u),e.topPath[n][1]=N(t[n][1],r[n][1],u);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=N(n[t][0],i[t][0],u),e.bottomPath[t][1]=N(n[t][1],i[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||C,o=new Map;for(let e=0;n.length>e;e++)o.set(n[e],i[e%i.length]);return this._colorMapCache={key:r,map:o,version:this._ingestVersion},o}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const r=n(t||{},e);if(r&&!r.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},r),{stroke:t})}return r}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const i=this.resolveGroupColor(e)||"#4e79a7";return{fill:i,fillOpacity:.7,stroke:i,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||C,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,r=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{r(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const i=this.buffer.remove(r);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),r=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&i.add(t)});const o=this.buffer.update(e=>n.has(r(e)),t);if(0===o.length)return o;for(const e of o)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,r,i;const o=Object.assign({},this.config);("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let l=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==o.chartType||"runtimeMode"in e&&e.runtimeMode!==o.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const s=a||!A(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=o.xAccessor)&&void 0!==n?n:o.timeAccessor),c=a||!A(null!==(r=e.yAccessor)&&void 0!==r?r:e.valueAccessor,null!==(i=o.yAccessor)&&void 0!==i?i:o.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=M(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=M(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=M(this.config.xAccessor,"x"),this.getY=M(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in e&&!A(e.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?_(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in e&&!A(e.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?_(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in e&&!A(e.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?M(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in e&&!A(e.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?_(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in e&&!A(e.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?M(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in e&&!A(e.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?_(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!A(e.openAccessor,o.openAccessor)||"closeAccessor"in e&&!A(e.closeAccessor,o.closeAccessor)||"highAccessor"in e&&!A(e.highAccessor,o.highAccessor)||"lowAccessor"in e&&!A(e.lowAccessor,o.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?M(this.config.openAccessor,"open"):void 0,this.getHigh=M(this.config.highAccessor,"high"),this.getLow=M(this.config.lowAccessor,"low"),this.getClose=t?M(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,l=!0}if(!l){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==o[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function G(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function V(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function q(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function U(e,t){const n=q(e);if(!n)return!1;const r=q(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function K(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Z(e,t,n,r=30,i,o=0){let l=null;if(i){const e=function(e,t,n,r,i){const o=Math.max(r,i+5,12),l=t-o,a=t+o,s=n-o,c=n+o;let u=null,d=1/0;return e.visit((e,i,o,h,f)=>{if(i>a||l>h||o>c||s>f)return!0;if(!e.length){let i=e;do{const e=i.data,o=e.x-t,l=e.y-n,a=Math.sqrt(o*o+l*l);V(e.r,r)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}(i,t,n,r,o);e&&(l={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const o of e){let e=null;switch(o.type){case"point":if(i)break;e=J(o,t,n,r);break;case"line":e=ee(o,t,n,r);break;case"rect":e=ne(o,t,n);break;case"heatcell":e=re(o,t,n);break;case"area":if(!1===o.interactive)break;e=oe(o,t,n);break;case"candlestick":e=ie(o,t,n)}e&&r>e.distance&&(l&&e.distance>=l.distance||(l=e))}return l}function Q(e,t,n){if(0===e.length)return null;const r=le(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let i=r,o=r;r>0&&e[r][0]>=t?(i=r-1,o=r):e.length-1>r&&(i=r,o=r+1);const[l,a]=e[i],[s,c]=e[o];return s===l?a:a+Math.max(0,Math.min(1,(t-l)/(s-l)))*(c-a)}function J(e,t,n,r=30){const i=t-e.x,o=n-e.y,l=Math.sqrt(i*i+o*o);return l>V(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:l}}function ee(e,t,n,r=30){var i,o,l,a;if(0===e.path.length)return null;const s=le(e.path,t);if(0>s)return null;const[c,u]=e.path[s];let d;if(e.path.length>1){let r=1/0;const i=Math.max(0,s-1),o=Math.min(e.path.length-2,s);for(let l=i;o>=l;l++){const[i,o]=e.path[l],[a,s]=e.path[l+1],c=te(t,n,i,o,a,s);r>c&&(r=c)}d=r}else{const e=t-c,r=n-u;d=Math.sqrt(e*e+r*r)}const h=null!==(a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==o?o:null===(l=e.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:c,y:u,distance:d}}function te(e,t,n,r,i,o){const l=i-n,a=o-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-r,2));let c=((e-n)*l+(t-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function ne(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function re(e,t,n){const r=G(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function ie(e,t,n){const r=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,o=t-e.x,l=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(o*o+l*l)}}return null}function oe(e,t,n){if(0===e.topPath.length)return null;const r=le(e.topPath,t);if(0>r)return null;const[i,o]=e.topPath[r],l=t-i,a=n-o,s=Math.sqrt(l*l+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:o,distance:s}}function le(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const i=n+r>>1;t>e[i][0]?n=i+1:r=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function ae(e){var t,n;const r=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let i=r.get(e);i||(i=[],r.set(e,i)),i.push(n)}for(const e of r.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const i=Array.from(r.keys()).sort((e,t)=>{const n=r.get(e),i=r.get(t);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),o=Array.from(r.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const l=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=null===(n=o[e].datum)||void 0===n?void 0:n.id;null!=t&&l.set(t+"",e)}return{flat:o,groups:i,byGroup:r,idToIdx:l}}function se(e,t){var n,r;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[i];return{flatIndex:i,group:null!==(n=o.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=o._groupIndex)&&void 0!==r?r:0}}function ce(e,t,n){const{group:r,indexInGroup:i}=t,o=n.byGroup.get(r);switch(e){case"ArrowRight":return o.length-1>i?o[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?o[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?ue(n,n.groups[e+1],o[i]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?ue(n,n.groups[e-1],o[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function ue(e,t,n){const r=e.byGroup.get(t);let i=0,o=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);o>t&&(o=t,i=e)}return r[i]._flatIndex}function de(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function he(t,n,r,i,o,l){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-a.lastIngestTime>c;u!==o&&(l(u),r.current=!0,i())},1e3);return()=>clearInterval(e)},[t,o,i])}X.QUADTREE_THRESHOLD=500;const fe={fill:e=>g.createElement("rect",{style:e,width:16,height:16}),line:e=>g.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function ye(e,t,n,r){let i;return i="function"==typeof n?n(e):(0,fe[n])(r(e,t)),i}function ge(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function pe(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function ve({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:i,label:o,format:l}=e,a=l||(e=>Math.round(100*e)/100+""),s="grad-legend-"+g.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(i[0]+t*(i[1]-i[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),o&&g.createElement("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("rect",{x:l,y:0,width:t,height:e,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(i[0])),g.createElement("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(i[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(g.createElement("stop",{key:e,offset:100*t+"%",stopColor:r(i[1]-t*(i[1]-i[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},o&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(i[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(i[0])))}function me(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,legendInteraction:l,title:a="Legend",width:s=100,height:c=20,orientation:u="vertical"}=e,[d,h]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((e,t)=>{h(e),y(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(g.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(g.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,r,i,o,l,a,s,c)=>{const{type:u="fill",styleFn:d,items:h}=e,f=[];let y=0;const p=!(!t&&!n),v="isolate"===c||void 0===c&&null!=i;return h.forEach((e,c)=>{const m=ye(e,c,u,d),x=pe(e,r,i),b=i&&i.size>0&&i.has(e.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?a===o&&c===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(ge,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),f})(e,n,r,i,o,l,a,h,s,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let f=0;e.label&&(f+=16);const y=((e,t,n,r,i,o,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,y=[];let p=0,v=0;const m=!(!t&&!n),x="isolate"===c||void 0===c&&null!=i;f.forEach((e,c)=>{const b=ye(e,c,d,h),k=pe(e,r,i),w=i&&i.size>0&&i.has(e.label),E=26+7*e.label.length;u&&u>0&&p>0&&p+E>u&&(v++,p=0),y.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},${22*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?a===o&&c===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:m?n=>{var r;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;s(a,e);const t=null===(r=n.currentTarget.parentElement)||void 0===r?void 0:r.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:m?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&g.createElement(ge,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),p+=E});let b=0,k=0;for(const e of f){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(b=Math.max(b,k),k=t):k+=t}b=Math.max(b,k);const w=v+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,r,i,o,l,a,s,t,c,u,n);f+=y.offset+5,h.push(Object.assign(Object.assign({label:e.label},y),{offset:f,totalRows:y.totalRows,totalHeight:y.totalHeight})),d+=f+12});let f=d>n?0:Math.max(0,(n-d)/2);const y=[];return h.forEach((n,r)=>{const i=e[r];i.label&&(y.push(g.createElement("text",{key:"legend-text-"+r,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},i.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,e[r+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:l}),m=!(!n&&!r);return g.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==l&&(void 0!==l||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==a&&""!==a&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},a),v)}function xe(e){const{legend:t,totalWidth:n,totalHeight:r,margin:i,legendPosition:o="right",title:l,legendHoverBehavior:a,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===o||"bottom"===o;let f,y;return"left"===o?(f=4,y=i.top):"top"===o?(f=0,y=l?32:8):"bottom"===o?(f=0,y=r-i.bottom+50):(f=n-i.right+10,y=i.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?g.createElement(ve,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?g.createElement(me,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function be(e){return"string"==typeof e?{type:e}:e}function ke({orient:t,config:n,values:r,scale:i,size:o,length:a}){const s=function(e){var t,n,r,i,o;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=e.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(o=e.strokeWidth)&&void 0!==o?o:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===r.length)return null;const e=i.domain(),n=o-8;if("boxplot"===s.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],l=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(t[0],r-1.5*l),whiskerHigh:Math.min(t[n-1],o+1.5*l)}}(r);if(!e)return null;const{q1:o,median:l,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),f=(n-h)/2+4;if(c){const e=i(o),n=i(a),r=i(l),c=i(u),y=i(d),p="top"===t?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:c,y1:v+p*(f+h/2),x2:y,y2:v+p*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:v+p*f,x2:c,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:v+p*f,x2:y,y2:v+p*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(e,n),y:"top"===t?v-f-h:v+f,width:Math.abs(n-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:r,y1:"top"===t?v-f-h:v+f,x2:r,y2:"top"===t?v-f:v+f+h,stroke:s.fill,strokeWidth:2}))}{const e=i(o),n=i(a),r=i(l),c=i(u),y=i(d),p="left"===t?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+t},g.createElement("line",{x1:v+p*(f+h/2),y1:c,x2:v+p*(f+h/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:c,x2:v+p*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:y,x2:v+p*(f+h),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===t?v-f-h:v+f,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===t?v-f-h:v+f,y1:r,x2:"left"===t?v-f:v+f+h,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=l.bin().domain(e).thresholds(s.bins)(r);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return g.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,r)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/d*n;if(c){const n=i(e.x0),l=i(e.x1)-i(e.x0);return g.createElement("rect",{key:r,x:n,y:"top"===t?-4-o:4,width:Math.max(l,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=i(e.x0),l=i(e.x1)-i(e.x0);return g.createElement("rect",{key:r,x:"left"===t?-4-o:4,y:Math.min(n,n+l),width:o,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const e=n/2+4,r=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const l=o.length/d*(n/2),a=i((o.x0+o.x1)/2);r.push(c?`${a},${"top"===t?-(e-l):e-l}`:`${"left"===t?-(e-l):e-l},${a}`)}for(let o=u.length-1;o>=0;o--){const l=u[o];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(n/2),s=i((l.x0+l.x1)/2);r.push(c?`${s},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+t},g.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const e=[];if(c){const r=0,o=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const o=r.length/d*n,l=i((r.x0+r.x1)/2);e.push(`L${l},${"top"===t?-o-4:o+4}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;e.push(`L${l},${r}`),e.push("Z")}else{const r=0,o=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const o=r.length/d*n,l=i((r.x0+r.x1)/2);e.push(`L${"left"===t?-o-4:o+4},${l}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;e.push(`L${r},${l}`),e.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+t},g.createElement("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,i,s,o,a,t,c,4]);return u?g.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function we(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),o=[];let l="";for(const e of i)l&&l.length+1+e.length>r?(o.push(l),l=e):l=l?`${l} ${e}`:e;return l&&o.push(l),o}function Ee(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Ae(e){const{x:t=0,y:n=0,dx:r,dy:i,nx:o,ny:l,note:a,connector:s,subject:c,type:u,color:d,className:h,disable:f,events:y={},"data-testid":p}=e,v=new Set(Array.isArray(f)?f:[]);let m=r||0,x=i||0;null!=o&&(m=o-t),null!=l&&(x=l-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===m&&0===x)if(void 0!==c.width){m=c.width/2;const e=c.depth||30;x=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;m=e+(0>e?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},y),!v.has("connector")&&function(e,t,n,r,i,o){const l=[];let a=0,s=0;if("callout-circle"!==i&&"label"!==i||!(null==o?void 0:o.radius)){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,l=e-i,c=t-o;if(0!==l||0!==c){const e=Math.abs(l),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;a=i+l*h,s=o+c*h}}}else if("bracket"===i&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,s=n):void 0!==t&&(a=n,s=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-s,2))>.5&&(l.push(g.createElement("line",{key:"connector-line",x1:a,y1:s,x2:e,y2:t,stroke:r||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,o=Math.atan2(t-s,e-a);l.push(g.createElement("path",{key:"connector-arrow",d:`M${a},${s}L${a+n*Math.cos(o+i)},${s+n*Math.sin(o+i)}L${a+n*Math.cos(o-i)},${s+n*Math.sin(o-i)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},l)}(m,x,s,d,b,c),!v.has("subject")&&function(e,t,n,r,i){var o;const l=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&l.push(g.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,r=(null==t?void 0:t.height)||0;(e>0||r>0)&&l.push(g.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&l.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,o=i||0;if(void 0!==(null==t?void 0:t.x)){const r=(t.x||0)-e;l.push(g.createElement("line",{key:"threshold-line",x1:r,y1:(t.y1||0)-o,x2:r,y2:(t.y2||0)-o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const r=(t.y||0)-o;l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?l.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||l.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-o,x2:0,y2:(t.y2||0)-o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:null==t?void 0:t.height;void 0!==e&&l.push(g.createElement("path",{key:"bracket-path",d:Ee((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return g.createElement("g",{className:"annotation-subject"},l)}(b,c,d,t,n),!v.has("note")&&function(e,t,n,r){if(!e)return g.createElement("g",{className:"annotation-note"});const{label:i,title:o,orientation:l,align:a,wrap:s=120,noWrap:c}=e;if(!i&&!o)return g.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,y=o?c?[o]:we(o,s):[],p=i?c?[i]:we(i,s):[],v="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold"},y.map((e,t)=>g.createElement("tspan",{key:t,x:v,dy:0===t?0:f},e)))),m=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:h,y:m},p.map((e,t)=>g.createElement("tspan",{key:t,x:v,dy:0===t?0:f},e))));let k=null;if((o||i)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(s,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*f;let E=0;return"topBottom"===u?E=0>n?-(w+2):18:"leftRight"===u&&(E="middle"===d?-(w+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(a,m,x,d))}function Me(e){var t,n;const{noteData:r}=e,{screenCoordinates:i}=r,o="string"==typeof r.type?r.type:"label",l=r.eventListeners||r.events||{};if(r.coordinates&&i){const e=r.nx||i[0][0]+(null!==(t=r.dx)&&void 0!==t?t:0),l=r.ny||i[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),a=i.map((t,n)=>{const i=Object.assign({},r,{note:0===n?r.note:{label:""},x:t[0],y:t[1],nx:e,ny:l});return g.createElement(Ae,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:o}))});return g.createElement("g",null,a)}const a=r.note||{title:"none",label:r.label};return g.createElement(Ae,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${r.i}`,events:l},r,{type:o}))}function Se(e,t){var n,r,i;const o=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(i=t.scales)||void 0===i?void 0:i.time;return o?null!=e.x?o(e.x):t.xAccessor&&null!=e[t.xAccessor]?o(e[t.xAccessor]):null:null}function _e(e,t){var n,r,i;const o=null!==(r=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(i=t.scales)||void 0===i?void 0:i.value;return o?null!=e.y?o(e.y):t.yAccessor&&null!=e[t.yAccessor]?o(e[t.yAccessor]):null:null}function Pe(e,t,n){var r,i,o,l;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const o=n.pointNodes[i];if(o.pointId===e.pointId){const e={x:o.x,y:o.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,e),e}}const o=function(e){var t,n,r,i,o,l;const a=e.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(r=e.scales)||void 0===r?void 0:r.time,u=null!==(o=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==o?o:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[e.xAccessor||"x"],h=s[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(t,o)),o}let s=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,c=t.y)}if(null!=s&&null!=c||(s=Se(e,n),c=_e(e,n)),null!=s&&null!=c)return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function Ce(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}const Te={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let De={positions:new Map};const Le=new Set;function Oe(){for(const e of Le)e()}function Ne(e,t){const n=De.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(De.positions);r.delete(e),De={positions:r},Oe()}function Ie(e,t){const n=De.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const r=new Map(De.positions);r.delete(e),De={positions:r},Oe()}function $e(){return De}function We(e){return Le.add(e),()=>Le.delete(e)}const Re={positions:new Map};function ze(){return()=>{}}function Be(){return Re}function Fe(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function je(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,i="left"===e?-1:1,o=Math.ceil(t/8);let l="M0,"+r;for(let e=0;o>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${r+4*i}`,l+=`L${Math.min(n,t)},${r}`}return l}{const r="bottom"===e?0:t,i="bottom"===e?1:-1,o=Math.ceil(n/8);let l=`M${r},0`;for(let e=0;o>e;e++){const t=8*(e+1);l+=`L${r+4*i},${Math.min(8*e+4,n)}`,l+=`L${r},${Math.min(t,n)}`}return l}}function Ye(t){const{width:n,height:r,totalWidth:i,totalHeight:o,margin:l,scales:a,showAxes:s,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,f=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=(null==t?void 0:t.tickFormat)||d||He,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,o=a.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))),l=o.map(e=>e.valueOf()),s=o.map((e,t)=>({value:e,pixel:a.x(e),label:r(e,t,l)})),u=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Xe(s,Math.max(55,u+8))},[a,c,d,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||He,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return Xe(a.y.ticks(Math.min(i,Math.max(2,Math.floor(r/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)})),22)},[a,c,h,r]),p=u&&a,v=s&&a;if(!p&&!v)return null;const m=null==c?void 0:c.find(e=>"bottom"===e.orient),x=null==c?void 0:c.find(e=>"left"===e.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return g.createElement("svg",{width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&(()=>{var e,t;const i=Fe(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Fe(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},f.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})),y.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),b&&!w&&g.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:je("bottom",n,r),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:je("left",n,r),fill:"none",stroke:A,strokeWidth:1})))}function He(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Xe(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ge(t){var n,r;const{width:i,height:o,totalWidth:l,totalHeight:c,margin:u,scales:d,showAxes:h,axes:f,xLabel:y,yLabel:v,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:_,legendPosition:P="right",foregroundGraphics:C,marginalGraphics:T,xValues:D,yValues:L,annotations:O,svgAnnotationRules:N,xAccessor:I,yAccessor:$,annotationData:W,pointNodes:R,curve:z,underlayRendered:B,linkedCrosshairName:F,linkedCrosshairSourceId:j,children:Y}=t,H=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||x||He,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,o=d.x.ticks(Math.min(r,Math.max(2,Math.floor(i/70)))),l=o.map(e=>e.valueOf()),a=o.map((e,t)=>({value:e,pixel:d.x(e),label:n(e,t,l)})),s=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=Xe(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=d.x.domain()[1],t=d.x(e),r=u[u.length-1].pixel;if(Math.abs(t-r)>1){const i=n(e,u.length,l);c>t-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:i})}}return u},[h,d,f,x,i]),X=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||He,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let i=Xe(d.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),(null==t?void 0:t.includeMax)&&i.length>0){const e=d.y.domain()[1],t=d.y(e),r=i[i.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e);22>Math.abs(t-r)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:t,label:o})}}return i},[h,d,f,b,o]),G=e.useMemo(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||b||He,r=null!==(e=t.ticks)&&void 0!==e?e:5;return Xe(d.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)})),22)},[h,d,f,b,o]),V=e.useRef(new Map),q=e.useRef(null!==(n=null==O?void 0:O.length)&&void 0!==n?n:0),K=null!==(r=null==O?void 0:O.length)&&void 0!==r?r:0;q.current!==K&&(q.current=K,V.current=new Map);const Z=e.useMemo(()=>{if(!O||0===O.length)return null;const e=function(e,t,n){var r,i,o,l,c,u,d,h,f,y,v,m,x,b,k,w,E,A,M,S,_,P,C,T,D,L,O,N,I,$,W,R,z,B,F,j,Y,H,X,G,V,q,U,K,Z,Q,J,ee;switch(e.type){case"label":{const r=Pe(e,t,n);if(!r)return null;const{x:i,y:o}=r;return Ce(i,o,n)?g.createElement(Me,{key:"ann-"+t,noteData:{x:i,y:o,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const r=Pe(e,t,n);if(!r)return null;const{x:i,y:o}=r;return Ce(i,o,n)?g.createElement(Me,{key:"ann-"+t,noteData:{x:i,y:o,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const r=Se(e,n);if(null==r)return null;const i=e.color||"#f97316",o=e.labelPosition||"top";let l;return l="bottom"===o?(n.height||0)-4:"center"===o?(n.height||0)/2:12,g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:r+4,y:l,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const r=_e(e,n);if(null==r)return null;const i=e.color||"#f97316",o=e.labelPosition||"right";let l,a;return"left"===o?(l=4,a="start"):"center"===o?(l=(n.width||0)/2,a="middle"):(l=(n.width||0)-4,a="end"),g.createElement("g",{key:"ann-"+t},g.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:l,y:r-4,textAnchor:a,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const r=(e.coordinates||[]).map(e=>({x:Se(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=a.packEnclose(r),o=e.padding||10;return g.createElement("g",{key:"ann-"+t},g.createElement("circle",{cx:i.x,cy:i.y,r:i.r+o,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:i.x,y:i.y-i.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const r=(e.coordinates||[]).map(e=>({x:Se(Object.assign(Object.assign({},e),{type:"point"}),n),y:_e(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=e.padding||10,o=r.map(e=>e.x),l=r.map(e=>e.y),a=Math.min(...o)-i,s=Math.max(...o)+i,c=Math.min(...l)-i,u=Math.max(...l)+i;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:a,y:c,width:s-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&g.createElement("text",{x:(a+s)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const r=n.data||[],i="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+t},i.map((t,r)=>{const i=Se(t,n),l=_e(t,n);if(null==i||null==l)return null;const a="function"==typeof e.r?e.r(t):e.r||6,s="function"==typeof e.style?e.style(t):e.style||o;return g.createElement("circle",Object.assign({key:"hl-"+r,cx:i,cy:l,r:a},s))}))}case"bracket":{const r=Se(e,n),i=_e(e,n);return g.createElement(Me,{key:"ann-"+t,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const s=n.xAccessor||"x",h=n.yAccessor||"y",f=a.map(e=>[e[s],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(i=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(o=n.scales)||void 0===o?void 0:o.time,v=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!v)return null;const m=e.method||"linear";let x;x="loess"===m?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),i=r.map(e=>e[0]),o=r.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],r=i.map(e=>Math.abs(e-t)),s=r.slice().sort((e,t)=>e-t)[Math.min(l-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===s?0:r[e]/s;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*o[e],f+=t*i[e]*i[e],y+=t*i[e]*o[e])}if(0===u){a.push([t,o[e]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([t,h/u]);else{const e=(u*y-d*h)/g;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?p.default.polynomial(f,{order:e.order||2}):p.default.linear(f)).points;const b=x.map(([e,t])=>`${y(e)},${v(t)}`).join(" "),k=e.color||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const r=null!==(f=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,i=null!==(v=null==r?void 0:r(e.y0))&&void 0!==v?v:0,o=null!==(m=null==r?void 0:r(e.y1))&&void 0!==m?m:n.height||0;return g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:Math.min(i,o),width:n.width||0,height:Math.abs(o-i),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(i,o)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const i=n.xAccessor||"x",o=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,l=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!o||!l)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=r.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>d.length)return null;const h=Te[n.curve||"linear"]||s.curveLinear,f=s.area().x(e=>o(e[i])).y0(e=>l(e[c])).y1(e=>l(e[a])).curve(h)(d);if(!f)return null;const y=e.fill||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&d.length>0&&g.createElement("text",{x:o(d[d.length-1][i])+4,y:l(d[d.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const i=n.yAccessor||"y",o=null!==(_=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==_?_:null===(P=n.scales)||void 0===P?void 0:P.time,l=null!==(T=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==T?T:null===(D=n.scales)||void 0===D?void 0:D.value;if(!o||!l)return null;const a=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const s=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-s,2),0)/a.length,u=Math.sqrt(c),d=null!==(L=e.threshold)&&void 0!==L?L:2,h=s-d*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(O=e.fillOpacity)&&void 0!==O?O:.1,v=e.anomalyColor||"#ef4444",m=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,x=l(s+d*u),b=l(h),k=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-s)>d*u});return g.createElement("g",{key:"ann-"+t},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,t)=>{const r=Se(e,n),i=_e(e,n);return null==r||null==i?null:g.createElement("circle",{key:"anomaly-"+t,cx:r,cy:i,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",l=null!==($=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==$?$:null===(W=n.scales)||void 0===W?void 0:W.time,a=null!==(z=null===(R=n.scales)||void 0===R?void 0:R.y)&&void 0!==z?z:null===(B=n.scales)||void 0===B?void 0:B.value;if(!l||!a)return null;const s=r.map(e=>[e[i],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>s.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=p.default.polynomial(s,{order:e.order||2}).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=s.length;let t=0,n=0,r=0,i=0;for(const[e,o]of s)t+=e,n+=o,r+=e*e,i+=e*o;const o=e*r-t*t;if(1e-12>Math.abs(o))return null;const l=(e*i-t*n)/o,a=(n-l*t)/e;c=e=>a+l*e}const u=s.length,d=s.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=s.reduce((e,t)=>e+t[0],0)/u,y=s.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),v=null!==(F=e.confidence)&&void 0!==F?F:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(j=e.steps)&&void 0!==j?j:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let e=1;x>=e;e++)w.push(b+e*k);const E=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(y>0?Math.pow(e-f,2)/y:0))*m;E.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${E.map(e=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${E.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=E.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(c(b))}`,_=e.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+t},g.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(Y=e.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:_,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&E.length>0&&g.createElement("text",{x:l(E[E.length-1].x)+4,y:a(E[E.length-1].yCenter)-4,fill:_,fontSize:11},e.label))}case"widget":{let r=null,i=null;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const o=Pe(e,t,n);if(!o)return null;r=o.x,i=o.y}if(null==r||null==i)return null;if(!Ce(r,i,n))return null;const o=null!==(G=e.dx)&&void 0!==G?G:0,l=null!==(V=e.dy)&&void 0!==V?V:0,a=null!==(q=e.width)&&void 0!==q?q:32,s=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+t,x:r+o-a/2,y:i+l-s/2,width:a,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:a,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const r=Pe(e,t,n);if(!r)return null;const{x:i,y:o}=r;return g.createElement("text",{key:"ann-text-"+t,x:i+(e.dx||0),y:o+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const r=e.category;if(null==r)return null;const i=null===(Z=n.scales)||void 0===Z?void 0:Z.o,o=null===(Q=n.scales)||void 0===Q?void 0:Q.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,a=(null==i?void 0:i.bandwidth)?i:(null==o?void 0:o.bandwidth)?o:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const s=a(r);if(null==s)return null;const c=a.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,h=e.label;return(n.projection?"vertical"===n.projection:a===o)?g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:s,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:s+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},h)):g.createElement("g",{key:"ann-"+t},g.createElement("rect",{x:0,y:s,width:n.width||0,height:c,fill:u,fillOpacity:d}),h&&g.createElement("text",{x:12,y:s+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},h))}default:return null}},t={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:I,yAccessor:$,width:i,height:o,data:W,frameType:"xy",pointNodes:R,curve:z,stickyPositionCache:V.current};return O.map((n,r)=>{if(N){const i=N(n,r,t);return null!=i?i:e(n,r,t)}return e(n,r,t)}).filter(Boolean)},[O,N,i,o,I,$,W,d,R,z]),Q=function(t){var n;const r=e.useSyncExternalStore(t?We:ze,t?$e:Be,t?$e:Be);return t&&null!==(n=r.positions.get(t))&&void 0!==n?n:null}(F);return e.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!F)return;const e=e=>{"Escape"===e.key&&Ie(F)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==Q?void 0:Q.locked,F]),h||w||E||C||T||Z&&Z.length>0||k||Y||Q?g.createElement("svg",{role:"img",width:l,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},g.createElement("title",null,"string"==typeof w?w:"XY Chart"),g.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},k&&d&&!B&&(()=>{var e,t;const n=Fe(null===(e=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),r=Fe(null===(t=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return g.createElement("g",{className:"stream-grid"},H.map((e,t)=>g.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),X.map((e,t)=>g.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})))})(),h&&d&&(()=>{const e=null==f?void 0:f.find(e=>"left"===e.orient),t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,r=!t||!1!==t.baseline,l=(null==e?void 0:e.jaggedBase)||!1,a=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",x=!!(null==t?void 0:t.autoRotate)&&H.length>1&&(()=>{const e=i/Math.max(H.length-1,1);return H.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return g.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&r&&!a&&g.createElement("line",{x1:0,y1:o,x2:i,y2:o,stroke:d,strokeWidth:1}),!B&&a&&g.createElement("path",{d:je("bottom",i,o),fill:"none",stroke:d,strokeWidth:1}),H.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):U(e.value,t>0?H[t-1].value:void 0));return g.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},g.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0},e.label):g.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),y&&g.createElement("text",{x:i/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},y),!B&&n&&!l&&g.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:d,strokeWidth:1}),!B&&l&&g.createElement("path",{d:je("left",i,o),fill:"none",stroke:d,strokeWidth:1}),X.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):U(e.value,t>0?X[t-1].value:void 0));return g.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},g.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||v;return t?g.createElement("text",{x:15-u.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-u.left}, ${o/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==f?void 0:f.find(e=>"right"===e.orient);if(!e||0===G.length)return null;const t=e.landmarkTicks,n=e.label||m;return g.createElement(g.Fragment,null,!1!==e.baseline&&g.createElement("line",{x1:i,y1:0,x2:i,y2:o,stroke:d,strokeWidth:1}),G.map((e,n)=>{const r=!!t&&("function"==typeof t?t(e.value,n):U(e.value,n>0?G[n-1].value:void 0));return g.createElement("g",{key:"ytick-r-"+n,transform:`translate(${i},${e.pixel})`},g.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?g.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:h,style:{userSelect:"none"}},e.label):g.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},g.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&g.createElement("text",{x:i+u.right-15,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${i+u.right-15}, ${o/2})`,style:{userSelect:"none"}},n))})())})(),Z,T&&d&&D&&L&&g.createElement(g.Fragment,null,T.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(ke,{orient:"top",config:be(T.top),values:D,scale:d.x,size:u.top,length:i})),T.bottom&&g.createElement("g",{transform:`translate(0, ${o})`},g.createElement(ke,{orient:"bottom",config:be(T.bottom),values:D,scale:d.x,size:u.bottom,length:i})),T.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(ke,{orient:"left",config:be(T.left),values:L,scale:d.y,size:u.left,length:o})),T.right&&g.createElement("g",{transform:`translate(${i}, 0)`},g.createElement(ke,{orient:"right",config:be(T.right),values:L,scale:d.y,size:u.right,length:o}))),C,Q&&Q.sourceId!==j&&(null==d?void 0:d.x)&&(()=>{const e=d.x(Q.xValue);if(null==e||0>e||e>i)return null;const t=Q.locked;return g.createElement("line",{x1:e,y1:0,x2:e,y2:o,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),Y),w&&g.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),xe({legend:E,totalWidth:l,totalHeight:c,margin:u,legendPosition:P,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:_})):null}function Ve(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const qe="undefined"==typeof window||"undefined"==typeof document,Ue=g.createContext(null);function Ke(){return g.useContext(Ue)}const Ze={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Qe(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const r=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),r=o.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of l)r.push(`${n[e]} ${i[e]||e}`);return`${t}, ${r.join(", ")}`}function Je(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const et=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},tt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},nt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},rt={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},it={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ot={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},lt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},at={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function st({scene:e,chartType:t,tableId:n,chartTitle:r}){var i;const[o,l]=g.useState(!1),a=Ke(),s=null!==(i=null==a?void 0:a.visible)&&void 0!==i&&i,c=o||s,u=g.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t,h=g.useCallback(()=>{o||s||l(!0)},[o,s]),f=g.useCallback(e=>{var t;s||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||l(!1)},[s]);if(!e||0===e.length)return n?g.createElement("span",{id:n,tabIndex:-1,style:Ze}):null;if(!c)return g.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:Ze,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>l(!0)},"View data summary (",e.length," elements)"));const y=function(e){var t,n,r,i,o,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(e))return S;for(const _ of e)if(_&&"object"==typeof _)try{switch(_.type){case"point":S.push({label:"Point",values:{x:_.x,y:_.y}});break;case"line":{const e=_.path,t=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=_.topPath,t=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=_.datum&&"object"==typeof _.datum?_.datum:{},o=null!==(n=null!==(t=e.category)&&void 0!==t?t:_.group)&&void 0!==n?n:"",l=null!==(i=null!==(r=e.value)&&void 0!==r?r:e.__aggregateValue)&&void 0!==i?i:e.total;S.push({label:"Bar",values:{category:o,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:_.x,y:_.y,value:_.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(o=_.datum)||void 0===o?void 0:o.category)&&void 0!==l?l:null===(a=_.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=_.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=_.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=_.cx)&&void 0!==f?f:_.x,y:null!==(y=_.cy)&&void 0!==y?y:_.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=_.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(v=_.cx)&&void 0!==v?v:_.x,y:null!==(m=_.cy)&&void 0!==m?m:_.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:_.x,open:_.open,high:_.high,low:_.low,close:_.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=_.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=_.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=_.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(e){}return S}(e),p=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],i=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],o=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),o+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:i,mean:o/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),v=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${et(e.min)} to ${et(e.max)}, mean ${et(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(y.length,p),m=y.slice(0,5),x=new Set;for(const e of m)for(const t of Object.keys(e.values))x.add(t);const b=Array.from(x);return g.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:f,style:tt,role:"region","aria-label":d},g.createElement("button",{type:"button",onClick:()=>{s&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:rt},"×"),g.createElement("div",{role:"note",style:nt},v),g.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:it},g.createElement("caption",{style:at},"First ",m.length," of ",y.length," data points"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:ot},"type"),b.map(e=>g.createElement("th",{key:e,style:ot},e)))),g.createElement("tbody",null,m.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:lt},e.label),b.map(t=>{return g.createElement("td",{key:t,style:lt},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":et(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function ct({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:i}){var o,l,a,s,c,u,d,h,f,y,p,v,m,x;const[b,k]=g.useState(!1),w=Ke(),E=null!==(o=null==w?void 0:w.visible)&&void 0!==o&&o,A=b||E,M=i?"Data summary for "+i:r?`Data summary for ${n} ${r}`:"Data summary for "+n,S=g.useRef(null),_=g.useCallback(()=>{b||E||k(!0)},[b,E]),P=g.useCallback(e=>{var t;E||(null===(t=S.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return r?g.createElement("span",{id:r,tabIndex:-1,style:Ze}):null;if(!A)return g.createElement("div",{id:r,tabIndex:-1,onFocus:_,style:Ze,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],T=Array.isArray(t)?t:[],D=new Map,L=new Map,O=new Map,N=new Map;for(const e of T){if(!e||"object"!=typeof e)continue;const t=null!==(l=e.datum)&&void 0!==l?l:e,n="object"==typeof t.source?null===(a=t.source)||void 0===a?void 0:a.id:t.source,r="object"==typeof t.target?null===(s=t.target)||void 0===s?void 0:s.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";L.set(e,(null!==(c=L.get(e))&&void 0!==c?c:0)+1),N.set(e,(null!==(u=N.get(e))&&void 0!==u?u:0)+i)}if(null!=r&&""!==r){const e=r+"";D.set(e,(null!==(d=D.get(e))&&void 0!==d?d:0)+1),O.set(e,(null!==(h=O.get(e))&&void 0!==h?h:0)+i)}}const I=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(y=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:t.id,r=null!=n?n+"":"node-"+e,i=null!==(p=D.get(r))&&void 0!==p?p:0,o=null!==(v=L.get(r))&&void 0!==v?v:0,l=null!==(m=O.get(r))&&void 0!==m?m:0,a=null!==(x=N.get(r))&&void 0!==x?x:0;I.push({id:r,degree:i+o,inDeg:i,outDeg:o,wDegree:l+a,wInDeg:l,wOutDeg:a})}I.sort((e,t)=>t.degree-e.degree);let $=0,W=0;if(I.length>0){let e=0;for(const t of I)e+=t.degree,t.degree>W&&(W=t.degree);$=e/I.length}const R=T.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),z=[`${I.length} nodes, ${T.length} edges.`];I.length>0&&z.push(`Mean degree: ${et($)}, max degree: ${W}.`);const B=I.slice(0,5);return g.createElement("div",{ref:S,id:r,tabIndex:-1,onBlur:P,style:tt,role:"region","aria-label":M},g.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:rt},"×"),g.createElement("div",{role:"note",style:nt},z.join(" ")),g.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:it},g.createElement("caption",{style:at},"Top ",B.length," of ",I.length," nodes by degree"),g.createElement("thead",null,g.createElement("tr",null,g.createElement("th",{style:ot},"id"),g.createElement("th",{style:ot},"degree"),g.createElement("th",{style:ot},"in"),g.createElement("th",{style:ot},"out"),R&&g.createElement("th",{style:ot},"w. degree"),R&&g.createElement("th",{style:ot},"w. in"),R&&g.createElement("th",{style:ot},"w. out"))),g.createElement("tbody",null,B.map((e,t)=>g.createElement("tr",{key:t},g.createElement("td",{style:lt},e.id),g.createElement("td",{style:lt},e.degree),g.createElement("td",{style:lt},e.inDeg),g.createElement("td",{style:lt},e.outDeg),R&&g.createElement("td",{style:lt},et(e.wDegree)),R&&g.createElement("td",{style:lt},et(e.wInDeg)),R&&g.createElement("td",{style:lt},et(e.wOutDeg)))))))}function ut({summary:e}){return e?g.createElement("div",{role:"note",style:Ze},e):null}function dt({tableId:e}){return g.createElement("a",{href:"#"+e,style:Ze,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ze)}},"Skip to data table")}function ht({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Ze},t)}const ft="var(--semiotic-focus, #005fcc)";function yt({active:e,hoverPoint:t,margin:n,size:r,shape:i="circle",width:o,height:l}){if(!e||!t)return null;const a=t.x+n.left,s=t.y+n.top;let c;if("rect"===i&&null!=o&&null!=l){const e=Math.max(o,4),t=Math.max(l,4);c=g.createElement("rect",{x:a-e/2-3,y:s-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ft,strokeWidth:2,strokeDasharray:"4,2"})}else c=g.createElement("circle","wedge"===i?{cx:a,cy:s,r:12,fill:"none",stroke:ft,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:s,r:8,fill:"none",stroke:ft,strokeWidth:2,strokeDasharray:"4,2"});return g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function gt({x:e,y:t,containerWidth:n,containerHeight:r,margin:i,children:o,className:l="stream-frame-tooltip",zIndex:a=1}){const s=g.useRef(null),[c,u]=g.useState(null);g.useLayoutEffect(()=>{const e=s.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[o,l,n,r]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`,g.createElement("div",{ref:s,className:l,style:{position:"absolute",left:i.left+e,top:i.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"}},o)}function pt(t){const n=e.createContext(null),r=vt(t);return[function({children:r}){const i=e.useMemo(()=>vt(t),[]);return g.createElement(n.Provider,{value:i,children:r})},t=>{var i;const o=null!==(i=e.useContext(n))&&void 0!==i?i:r,l=e.useRef(t);l.current=t;const a=e.useCallback(()=>l.current(o.getState()),[o]),s=e.useCallback(()=>l.current(o.getState()),[o]);return e.useSyncExternalStore(o.subscribe,a,s)}]}function vt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function mt(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:xt})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const xt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],bt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},kt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},wt={mode:"light",colors:{primary:"#0000cc",categorical:xt,sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Et,At]=pt(e=>({theme:bt,setTheme(t){e(e=>{if("light"===t)return{theme:bt};if("dark"===t)return{theme:kt};if("high-contrast"===t)return{theme:wt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?kt:bt;return{theme:mt(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}}return{theme:mt(Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})}))}})}}));const Mt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,St=new WeakMap;let _t=0,Pt=!1,Ct=null,Tt=null,Dt=null;function Lt(e,t){var n,r;if(!t)return t;const i=Mt.exec(t);if(!i)return t;const o=e.canvas;if(!o)return(null===(n=i[2])||void 0===n?void 0:n.trim())||t;!function(){if(Pt)return;if("undefined"==typeof window||"undefined"==typeof document)return;Pt=!0;const e=()=>{_t++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Ct=new MutationObserver(e),Ct.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Tt=window.matchMedia("(prefers-color-scheme: dark)"),Dt=e,"function"==typeof Tt.addEventListener?Tt.addEventListener("change",Dt):"function"==typeof Tt.addListener&&Tt.addListener(Dt)}catch(e){}}();let l=St.get(o);l&&l.version===_t||(l={version:_t,map:new Map},St.set(o,l));const a=l.map.get(t);if(void 0!==a)return a;const s=getComputedStyle(o).getPropertyValue(i[1]).trim()||(null===(r=i[2])||void 0===r?void 0:r.trim())||t;return l.map.set(t,s),s}function Ot(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Nt(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),t}(),r=e.useRef(n);r.current=n;const[i,o]=function(t,n,r){const i=e.useRef(null),[o,l]=e.useState(null);return e.useEffect(()=>{if(!n&&!r)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,r]),[i,[n&&o?o.w:t[0],r&&o?o.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),l=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),a=o[0]-l.left-l.right,s=o[1]-l.top-l.bottom,c=Ot(t.foregroundGraphics,o,l),u=Ot(t.backgroundGraphics,o,l),d=At(e=>e.theme),{transition:h,introEnabled:f}=function(e,t){var n,r;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(r=e.duration)&&void 0!==r?r:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(t.animate,t.transitionProp),y="semiotic-table-"+g.useId(),p=e.useRef(0),v=e.useRef(()=>{}),m=e.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);e.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),E=e.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&x.current(e)},[]),A=e.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(E))},[E]),M=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const S=t.themeDirtyRef;return e.useEffect(()=>{S&&(_t++,S.current=!0,m())},[d,m,S]),{reducedMotion:n,reducedMotionRef:r,responsiveRef:i,size:o,margin:l,adjustedWidth:a,adjustedHeight:s,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:y,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:A,onPointerLeave:M}}function It(e,t,n,r){const i=e.getContext("2d");if(!i)return null;const o=t[0]*r,l=t[1]*r,a=t[0]+"px",s=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==s&&(e.style.height=s),e.width===o&&e.height===l||(e.width=o,e.height=l),i.setTransform(r,0,0,r,0,0),i.translate(n.left,n.top),i}function $t(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Wt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Rt(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function zt(e,t,n,r,i,o){if(2>t.length)return;const l=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];l.push(l[e-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=o;for(let n=0;t.length-1>n;n++){const r=(l[n]+l[n+1])/2;let o=i;s>r&&(o*=r/s),s>a-r&&(o*=(a-r)/s),e.globalAlpha=Math.max(0,o),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const Bt=(e,t,n,r)=>{var i,o;const l=t.filter(e=>"line"===e.type);for(const a of l){if(2>a.path.length)continue;const c=a._introClipFraction;void 0!==c&&1>c&&(e.save(),e.beginPath(),e.rect(0,0,r.width*c,r.height),e.clip());const u=a.style.stroke||"#007bff",d=a.style.strokeWidth||2,h=a.colorThresholds,f=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=d,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;zt(e,a.path,u,d,v,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const y=Wt(a.curve),g=h&&h.length>0&&f&&f.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!g){e.strokeStyle=u;const m=null!==(o=a.style.opacity)&&void 0!==o?o:1;for(let x=0;a.path.length-1>x;x++)e.globalAlpha=.5*(p[x]+p[x+1])*m,e.beginPath(),e.moveTo(a.path[x][0],a.path[x][1]),e.lineTo(a.path[x+1][0],a.path[x+1][1]),e.stroke()}else if(g){let b=null,k=null,w=null,E=null,A=!1;function M(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let _=0;a.path.length>_;_++){const[P,C]=a.path[_],T=f[_],D=Rt(T,h,u);if(null!==b&&null!==E&&null!==w){if(D===E)e.lineTo(P,C);else{const L=[];for(const O of h){const N=O.value;(w>N||N>T)&&(N>w||T>N)||w===N||T===N||L.push({t:(N-w)/(T-w)})}L.sort((e,t)=>e.t-t.t);for(const I of L){const $=b+(P-b)*I.t,W=k+(C-k)*I.t,R=Rt(w+(T-w)*Math.min(I.t+1e-4,1),h,u);e.lineTo($,W),S(),M(R,$,W)}e.lineTo(P,C)}b=P,k=C,w=T,E=D}else M(D,P,C),b=P,k=C,w=T,E=D}S()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=u;else{const z=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const B of a.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,B.offset)),B.color);e.strokeStyle=z}if(y)s.line().x(e=>e[0]).y(e=>e[1]).curve(y).context(e)(a.path);else{const[F,j]=a.path[0];e.moveTo(F,j);for(let Y=1;a.path.length>Y;Y++)e.lineTo(a.path[Y][0],a.path[Y][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?Lt(e,a.style.fill):a.style.fill)||a.style.fill,y&&!g)s.line().x(e=>e[0]).y(e=>e[1]).curve(y).context(e)(a.path);else{const[X,G]=a.path[0];e.moveTo(X,G);for(let V=1;a.path.length>V;V++)e.lineTo(a.path[V][0],a.path[V][1])}const H=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],r.height),e.lineTo(H,r.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Ft(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function jt(e,t,n=.3){Ft(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Yt(e,t,n=.6){var r,i,o,l,a;if(!Ft(t))return;const s=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,c=t.r+s*t._pulseIntensity,u=null!==(o=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==o?o:0,d=null!==(a=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ht(e,t,n,r=.35){Ft(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function Xt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Gt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Vt(e,t){const n=Xt(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=s.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}const qt=(e,t,n,r)=>{var i,o,l;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const a=t.style.fill||"#4e79a7",c=t._decayOpacities;if(c&&c.length===t.topPath.length){const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=a;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(c[r]+c[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Lt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(c[n]+c[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const u=null!==(o=t.style.opacity)&&void 0!==o?o:1;if(Vt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=e.createLinearGradient(0,n,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=Gt("string"==typeof a?a:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=u}else{const n=null!==(l=t.style.fillOpacity)&&void 0!==l?l:.7;e.globalAlpha=n*u,e.fillStyle=a}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Vt(e,t),Ht(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=u,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Lt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=Xt(t.curve);if(e.beginPath(),n)s.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1}},Ut=(e,t,n,r)=>{var i;const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{for(const t of o){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?Lt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Lt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Yt(e,t),e.globalAlpha=1}}finally{e.restore()}}},Kt=(e,t,n,r)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Zt(e,t);else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=("string"==typeof t.style.fill?Lt(e,t.style.fill):t.style.fill)||"#007bff";const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:r,y:i,w:o,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(r,i),e.lineTo(r+o-n,i),e.arcTo(r+o,i,r+o,i+n,n),e.lineTo(r+o,i+l-n),e.arcTo(r+o,i+l,r+o-n,i+l,n),e.lineTo(r,i+l);break;case"left":e.moveTo(r+o,i),e.lineTo(r+n,i),e.arcTo(r,i,r,i+n,n),e.lineTo(r,i+l-n),e.arcTo(r,i+l,r+n,i+l,n),e.lineTo(r+o,i+l);break;case"bottom":e.moveTo(r,i),e.lineTo(r+o,i),e.lineTo(r+o,i+l-n),e.arcTo(r+o,i+l,r+o-n,i+l,n),e.lineTo(r+n,i+l),e.arcTo(r,i+l,r,i+l-n,n);break;default:e.moveTo(r,i+l),e.lineTo(r,i+n),e.arcTo(r,i,r+n,i,n),e.lineTo(r+o-n,i),e.arcTo(r+o,i,r+o,i+n,n),e.lineTo(r+o,i+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Lt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else e.fillStyle=("string"==typeof t.style.fill?Lt(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Lt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h));jt(e,t),e.globalAlpha=1}};function Zt(e,t){const n=t.style.icon,r=t.style.iconPadding||2,i=Math.min(t.w,t.h)-r;if(0>=i)return;const o=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),o){const o=i+r,l=t.x+(t.w-i)/2;for(let r=t.y+t.h-i;r>=t.y-i;r-=o)e.drawImage(n,l,r,i,i)}else{const o=i+r,l=t.y+(t.h-i)/2;for(let r=t.x;t.x+t.w>r;r+=o)e.drawImage(n,r,l,i,i)}e.restore()}function Qt(e,t,n,r){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),r)}function Jt(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function en(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const tn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nn(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${tn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${tn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const rn={line:[qt,Bt,Ut],area:[qt,Ut],stackedarea:[qt,Ut],scatter:[Ut],bubble:[Ut],heatmap:[(e,t,n,r)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),jt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):en(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=Jt(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,o)}}}finally{e.restore()}}],bar:[Kt],swarm:[Ut],waterfall:[(e,t,n,r)=>{var i,o,l;Kt(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const r=a[t],i=a[t+1];if(!(null===(o=r.datum)||void 0===o?void 0:o.cumEnd)||!(null===(l=i.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(c,s),e.lineTo(u,s),e.stroke()}e.restore()}}],candlestick:[(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=t._decayOpacity;if(null!=r&&1!==r&&(e.globalAlpha=r),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}e.restore()}}],mixed:[qt,Bt,Ut]},on={top:20,right:20,bottom:30,left:40},ln={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"};function an(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],i=n[3];return`#${e}${e}${r}${r}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}const sn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function cn({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:sn},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const un=e.forwardRef(function(t,n){var r,i,o,l,a,s,c,u,d,h,f;const{chartType:y,runtimeMode:p,data:v,chunkThreshold:m,chunkSize:k,xAccessor:w,yAccessor:E,colorAccessor:A,sizeAccessor:M,groupAccessor:S,lineDataAccessor:_,curve:P,normalize:C,binSize:T,valueAccessor:D,arrowOfTime:L="right",windowMode:O="sliding",windowSize:N=200,timeAccessor:I,xExtent:$,yExtent:W,extentPadding:R=.1,scalePadding:z,sizeRange:B,size:F=[500,300],responsiveWidth:j,responsiveHeight:Y,margin:H,className:G,background:V,lineStyle:q,pointStyle:U,areaStyle:K,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:re,boundsStyle:ie,y0Accessor:oe,gradientFill:ue,lineGradient:fe,areaGroups:ye,openAccessor:ge,highAccessor:pe,lowAccessor:ve,closeAccessor:me,candlestickStyle:xe,showAxes:be=!0,axes:ke,xLabel:we,yLabel:Ee,yLabelRight:Ae,xFormat:Me,yFormat:Se,tickFormatTime:_e,tickFormatValue:Pe,hoverAnnotation:Ce,tooltipContent:Te,customHoverBehavior:De,customClickBehavior:Le,enableHover:Oe,hoverRadius:Ne=30,tooltipMode:Ie,annotations:$e,svgAnnotationRules:We,showGrid:Re,legend:ze,legendHoverBehavior:Be,legendClickBehavior:Fe,legendHighlightedCategory:je,legendIsolatedCategories:He,legendPosition:Xe,backgroundGraphics:Ue,foregroundGraphics:Ke,canvasPreRenderers:Ze,svgPreRenderers:Je,title:et,categoryAccessor:tt,brush:nt,onBrush:rt,decay:it,pulse:ot,transition:lt,animate:at,staleness:ct,heatmapAggregation:ft,heatmapXBins:pt,heatmapYBins:vt,showValues:mt,heatmapValueFormat:xt,marginalGraphics:bt,pointIdAccessor:kt,xScaleType:wt,yScaleType:Et,accessibleTable:At=!0,description:Mt,summary:St,linkedCrosshairName:_t,linkedCrosshairSourceId:Pt}=t,Ct=e.useRef(!1),Tt=Nt({sizeProp:F,responsiveWidth:j,responsiveHeight:Y,userMargin:H,marginDefault:on,animate:at,transitionProp:lt,themeDirtyRef:Ct}),{reducedMotionRef:Dt,responsiveRef:Lt,size:Ot,currentTheme:Wt,transition:Rt,introEnabled:zt,tableId:Bt,rafRef:Ft,renderFnRef:jt,scheduleRender:Yt}=Tt;let Ht=Tt.margin;if(bt){const e=60,t=Object.assign({},Tt.margin);bt.top&&e>t.top&&(t.top=e),bt.bottom&&e>t.bottom&&(t.bottom=e),bt.left&&e>t.left&&(t.left=e),bt.right&&e>t.right&&(t.right=e),Ht=t}const Xt="function"==typeof Ke?Ke({size:Ot,margin:Ht}):Ke,Gt="function"==typeof Ue?Ue({size:Ot,margin:Ht}):Ue,Vt=Ot[0]-Ht.left-Ht.right,qt=Ot[1]-Ht.top-Ht.bottom,Ut=null!=Ce?Ce:Oe,Kt=e.useRef(null),Zt=e.useRef(null),[Jt,en]=e.useState(0),[tn,sn]=e.useState(null),un=e.useRef(null),dn=e.useRef(null),[hn,fn]=e.useState(null),[yn,gn]=e.useState(!1),[pn,vn]=e.useState([]),[mn,xn]=e.useState([]),bn="streaming"===p||["bar","swarm","waterfall"].includes(y),kn=e.useMemo(()=>{var e;return{chartType:y,runtimeMode:bn?"streaming":"bounded",windowSize:N,windowMode:O,arrowOfTime:bn?L:"right",extentPadding:R,scalePadding:z,xAccessor:bn?void 0:w,yAccessor:bn?void 0:E,timeAccessor:bn?I:void 0,valueAccessor:D,colorAccessor:A,sizeAccessor:M,groupAccessor:S||(_?"_lineGroup":void 0),categoryAccessor:tt,lineDataAccessor:_,xScaleType:wt,yScaleType:Et,xExtent:$,yExtent:W,sizeRange:B,binSize:T,normalize:C,boundsAccessor:re,boundsStyle:ie,y0Accessor:oe,gradientFill:!0===ue?{topOpacity:.8,bottomOpacity:.05}:!1===ue?void 0:ue,areaGroups:ye?new Set(ye):void 0,lineGradient:fe,openAccessor:ge,highAccessor:pe,lowAccessor:ve,closeAccessor:me,candlestickStyle:xe,lineStyle:q,pointStyle:U,areaStyle:K,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:$e,decay:it,pulse:ot,transition:Rt,introAnimation:zt,staleness:ct,heatmapAggregation:ft,heatmapXBins:pt,heatmapYBins:vt,showValues:mt,heatmapValueFormat:xt,pointIdAccessor:kt,curve:P,themeCategorical:null===(e=null==Wt?void 0:Wt.colors)||void 0===e?void 0:e.categorical}},[y,N,O,L,R,z,w,E,I,D,wt,Et,A,M,S,tt,_,$,W,B,T,C,re,ie,oe,ue,fe,ye,ge,pe,ve,me,xe,q,U,K,ee,J,ne,te,$e,it,ot,null==Rt?void 0:Rt.duration,null==Rt?void 0:Rt.easing,zt,ct,ft,pt,vt,mt,xt,bn,kt,P,Wt]),wn=e.useRef(null);wn.current||(wn.current=new X(kn)),e.useEffect(()=>{var e;null===(e=wn.current)||void 0===e||e.updateConfig(kn),Ct.current=!0,Yt()},[kn,Yt]);const En=e.useRef(null);En.current||(En.current=new b(e=>{const t=wn.current;t&&t.ingest(e)&&(Ct.current=!0,Yt())},{chunkThreshold:m,chunkSize:k})),e.useEffect(()=>{var e;null===(e=En.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:k})},[m,k]);const An=e.useCallback(e=>{var t;null===(t=En.current)||void 0===t||t.push(e)},[]),Mn=e.useCallback(e=>{var t;null===(t=En.current)||void 0===t||t.pushMany(e)},[]),Sn=e.useCallback(()=>{var e,t;null===(e=En.current)||void 0===e||e.clear(),null===(t=wn.current)||void 0===t||t.clear(),Ct.current=!0,Yt()},[Yt]);e.useImperativeHandle(n,()=>({push:An,pushMany:Mn,remove:e=>{var t,n,r;null===(t=En.current)||void 0===t||t.flush();const i=null!==(r=null===(n=wn.current)||void 0===n?void 0:n.remove(e))&&void 0!==r?r:[];return i.length>0&&(un.current&&i.some(e=>{var t;return e===(null===(t=un.current)||void 0===t?void 0:t.data)})&&(un.current=null,fn(null)),Ct.current=!0,Yt()),i},update:(e,t)=>{var n,r,i;null===(n=En.current)||void 0===n||n.flush();const o=null!==(i=null===(r=wn.current)||void 0===r?void 0:r.update(e,t))&&void 0!==i?i:[];return o.length>0&&(Ct.current=!0,Yt()),o},clear:Sn,getData:()=>{var e,t,n;return null===(e=En.current)||void 0===e||e.flush(),null!==(n=null===(t=wn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=wn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=wn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[An,Mn,Sn,Yt]),e.useEffect(()=>{var e,t;if(v){if(_&&v.length>0&&"object"==typeof v[0]&&null!==v[0]){const t="string"==typeof _?_:"coordinates";if(Array.isArray(v[0][t])){const n=[];for(const e of v){const r=e[t];if(Array.isArray(r)){const t=e.label||e.id||e.key;if(null!=t)for(const e of r)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of r)n.push(e)}}return void(null===(e=En.current)||void 0===e||e.setBoundedData(n))}}null===(t=En.current)||void 0===t||t.setBoundedData(v)}},[v,_]);const{hoverHandlerRef:_n,hoverLeaveRef:Pn,onPointerMove:Cn,onPointerLeave:Tn}=Tt;_n.current=e=>{if(!Ut)return;const t=Kt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-Ht.left,i=e.clientY-n.top-Ht.top;if(0>r||r>Vt||0>i||i>qt)return void(un.current&&(un.current=null,dn.current=null,fn(null),De&&(De(null),Ct.current=!0),Yt()));const o=wn.current;if(!o||0===o.scene.length)return;const l=Z(o.scene,r,i,Ne,o.quadtree,o.maxPointRadius);if(!l)return void(un.current&&(un.current=null,dn.current=null,fn(null),De&&De(null),Yt()));const a=Qt(l.datum||{},l.x,l.y);if("multi"===Ie&&o.scene.length>0&&o.scales){const e=function(e,t,n=30){const r=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const o=Q(e.path,t,n);if(null===o)continue;const l=le(e.path,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.path[l][0],y:o,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const o=Q(e.topPath,t,n);if(null===o)continue;const l=le(e.topPath,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:o,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(o.scene,l.x,Ne),t=o.scales.y.invert,n=o.scales.x.invert;if(e.length>0){const r=n?n(l.x):l.x;a.xValue=r,a.xPx=l.x,a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}un.current=a,dn.current=l.node,fn(a),De&&(De(a),Ct.current=!0),Yt()},Pn.current=()=>{un.current&&(un.current=null,dn.current=null,fn(null),De&&(De(null),Ct.current=!0),Yt())};const Dn=e.useRef(()=>{});Dn.current=e=>{if(!Le)return;const t=Kt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-Ht.left,i=e.clientY-n.top-Ht.top;if(0>r||r>Vt||0>i||i>qt)return void Le(null);const o=wn.current;if(!o||0===o.scene.length)return void Le(null);const l=Z(o.scene,r,i,Ne,o.quadtree,o.maxPointRadius);Le(l?Qt(l.datum||{},l.x,l.y):null)};const Ln=e.useCallback(e=>Dn.current(e),[]),On=e.useRef(-1),Nn=e.useRef(null),In=e.useRef(null),$n=e.useCallback(e=>{const t=wn.current;if(!t||0===t.scene.length)return;const n=t.version;let r;if(In.current&&In.current.version===n)r=In.current.graph;else{const e=function(e){var t,n,r,i;const o=[];for(const l of e)switch(l.type){case"point":o.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(t=l.group)&&void 0!==t?t:"_default"});break;case"line":{const e=l,t=Array.isArray(e.datum)?e.datum:[],r=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)o.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:r});break}case"area":{const e=l,t=Array.isArray(e.datum)?e.datum:[],n=null!==(r=e.group)&&void 0!==r?r:"_default";for(let r=0;e.topPath.length>r&&t.length>r;r++)o.push({x:e.topPath[r][0],y:e.topPath[r][1],datum:t[r],shape:"circle",group:n});break}case"rect":o.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(i=l.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return o.sort((e,t)=>e.x-t.x||e.y-t.y),o}(t.scene);if(0===e.length)return;r=ae(e),In.current={version:n,graph:r}}const i=On.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),On.current=0;const t=r.flat[0];Nn.current={shape:t.shape,w:t.w,h:t.h};const n=de(t);return un.current=n,fn(n),De&&De(n),void Yt()}const o=se(r,i),l=ce(e.key,o,r);if(null===l)return;if(e.preventDefault(),0>l)return On.current=-1,Nn.current=null,un.current=null,dn.current=null,fn(null),De&&De(null),void Yt();On.current=l;const a=r.flat[l];Nn.current={shape:a.shape,w:a.w,h:a.h};const s=de(a);un.current=s,fn(s),De&&De(s),Yt()},[De,Yt]),Wn=e.useCallback(e=>{On.current=-1,Nn.current=null,Cn(e)},[Cn]);jt.current=()=>{var e,t;Ft.current=0;const n=Kt.current,r=Zt.current;if(!n||!r)return;const i=wn.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(Dt.current?o+1e6:o),a=!Dt.current&&l,s=Ct.current||l;s&&!a&&i.computeScene({width:Vt,height:qt});const c=$t(),u=function(e){if(!e)return ln;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),o=r||t.getPropertyValue("--text-secondary").trim(),l=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),s=i||t.getPropertyValue("--surface-0").trim();return o||l||n?{axisStroke:a||ln.axisStroke,tickText:o||ln.tickText,crosshair:o?an(o,"66"):ln.crosshair,hoverFill:s?an(s,"4D"):ln.hoverFill,hoverStroke:o?an(o,"99"):ln.hoverStroke,pointRing:s||ln.pointRing}:ln}(n),d=null!==(e=null==ct?void 0:ct.threshold)&&void 0!==e?e:5e3,h=ct&&i.lastIngestTime>0&&o-i.lastIngestTime>d;if(s){const e=It(n,Ot,Ht,c);if(e){if(e.clearRect(-Ht.left,-Ht.top,Ot[0],Ot[1]),h&&(e.globalAlpha=null!==(t=null==ct?void 0:ct.dimOpacity)&&void 0!==t?t:.5),"transparent"!==V&&!Ue){const t=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),r=V||(t&&"transparent"!==t?t:null);r&&(e.fillStyle=r,e.fillRect(-Ht.left,-Ht.top,Ot[0],Ot[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Vt,qt),e.clip()),Ze&&i.scales)for(const t of Ze)e.save(),t(e,i.scene,i.scales,{width:Vt,height:qt}),e.restore();const r=rn[y];if(r&&i.scales)for(const t of r)t(e,i.scene,i.scales,{width:Vt,height:qt});e.restore(),h&&(e.globalAlpha=1)}}{const e=It(r,Ot,Ht,c);if(e&&(e.clearRect(-Ht.left,-Ht.top,Ot[0],Ot[1]),Ut&&un.current&&i.scales&&function(e,t,n,r,i,o,l){var a,s;if(!1===i.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const h="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=h.stroke||l.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,r),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=l.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(s=e.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const r=i.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(o)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=r,e.fill(),e.strokeStyle=l.pointRing,e.lineWidth=2,e.stroke()}}(e,un.current,Vt,qt,"object"==typeof Ut?Ut:{},dn.current,u),dn.current&&Array.isArray(Ce))){const t=Ce.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r){var i;if(!n)return;const o=n.group;if(void 0!==o)for(const n of t){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?r.style(n.datum):r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(e,i.scene,dn.current,t)}}s&&n&&n.setAttribute("aria-label",Qe(i.scene,y+" chart"));const f=Ct.current;if(Ct.current=!1,f&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!tn||e(tn.x.domain()[0])!==e(i.scales.x.domain()[0])||e(tn.x.domain()[1])!==e(i.scales.x.domain()[1])||e(tn.y.domain()[0])!==e(i.scales.y.domain()[0])||e(tn.y.domain()[1])!==e(i.scales.y.domain()[1])||tn.x.range()[0]!==i.scales.x.range()[0]||tn.x.range()[1]!==i.scales.x.range()[1]||tn.y.range()[0]!==i.scales.y.range()[0]||tn.y.range()[1]!==i.scales.y.range()[1])&&sn(i.scales),bt){const e=i.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof E?E:e=>e[E||"y"];vn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),xn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}f&&$e&&$e.length>0&&en(e=>e+1),(null==ct?void 0:ct.showBadge)&&gn(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Ft.current=requestAnimationFrame(()=>jt.current()))},e.useEffect(()=>(Yt(),()=>{var e;null===(e=En.current)||void 0===e||e.clear()}),[Yt]),e.useEffect(()=>{Ct.current=!0,Yt()},[y,Vt,qt,be,V,q,Ze,Yt]),he(ct,wn,Ct,Yt,yn,gn);const Rn=e.useMemo(()=>{if(Me||_e)return;const e=wn.current;return(null==e?void 0:e.xIsDate)&&tn?nn(tn.x.domain()):void 0},[Me,_e,tn]),zn=Me||_e||Rn,Bn=Ut&&hn?Te?Te(hn):g.createElement(cn,{hover:hn}):null,Fn=Bn?g.createElement(gt,{x:hn.x,y:hn.y,containerWidth:Vt,containerHeight:qt,margin:Ht,className:"stream-frame-tooltip"},Bn):null,jn=Nn.current,Yn=g.createElement(yt,{active:On.current>=0,hoverPoint:hn,margin:Ht,size:Ot,shape:null==jn?void 0:jn.shape,width:null==jn?void 0:jn.w,height:null==jn?void 0:jn.h}),Hn=(e,t,n,r)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null},Xn=Hn(w,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Gn=Hn(E,D,"__semiotic_resolvedY","__semiotic_resolvedValue"),Vn=Xn.key,qn=Gn.key,Un=$e&&$e.length>0,Kn=e=>{if(!e||!Un||!Xn.fn&&!Gn.fn)return e;let t=!1;const n=e.map(e=>{const n=Xn.fn&&Xn.key&&!(Xn.key in e),r=Gn.fn&&Gn.key&&!(Gn.key in e);if(!n&&!r)return e;t=!0;const i=Object.assign({},e);return n&&(i[Xn.key]=Xn.fn(e)),r&&(i[Gn.key]=Gn.fn(e)),i});return t?n:e};if(qe){const e=wn.current;e&&v&&(e.ingest({inserts:v,bounded:!0}),e.computeScene({width:Vt,height:qt}));const t=null!==(r=null==e?void 0:e.scene)&&void 0!==r?r:[],n=null!==(i=null==e?void 0:e.scales)&&void 0!==i?i:null,o=zn||(()=>{if((null==e?void 0:e.xIsDate)&&n)return nn(n.x.domain())})();return g.createElement("div",{className:"stream-xy-frame"+(G?" "+G:""),role:"img","aria-label":Mt||("string"==typeof et?et:"XY chart"),style:{position:"relative",width:Ot[0],height:Ot[1]}},g.createElement(ut,{summary:St}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ot[0],height:Ot[1],style:{position:"absolute",left:0,top:0}},g.createElement("g",{transform:`translate(${Ht.left},${Ht.top})`},Gt),g.createElement("g",{transform:`translate(${Ht.left},${Ht.top})`},V&&g.createElement("rect",{x:0,y:0,width:Vt,height:qt,fill:V}),Je&&n&&Je.map((e,r)=>g.createElement(g.Fragment,{key:"svgpre-"+r},e(t,n,{width:Vt,height:qt}))),t.map((e,t)=>function(e,t){var n,r,i;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"line-"+t,d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const i=e;if(0===i.topPath.length)return null;const o=i.topPath.map(([e,t])=>`${e},${t}`).join("L"),l=[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return g.createElement("path",{key:"area-"+t,d:`M${o}L${l}Z`,fill:Ve(i.style.fill),fillOpacity:null!==(r=null!==(n=i.style.fillOpacity)&&void 0!==n?n:i.style.opacity)&&void 0!==r?r:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const n=e;return g.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:Ve(n.style.fill),opacity:null!==(i=n.style.opacity)&&void 0!==i?i:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return g.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:Ve(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,i,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),l=.299*r+.587*i+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+t},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px"},e))}return g.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),i=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+t},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:i,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),g.createElement(Ge,{width:Vt,height:qt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,scales:n,showAxes:be,axes:ke,xLabel:we,yLabel:Ee,yLabelRight:Ae,xFormat:o,yFormat:Se||Pe,showGrid:Re,title:et,legend:ze,legendHoverBehavior:Be,legendClickBehavior:Fe,legendHighlightedCategory:je,legendIsolatedCategories:He,legendPosition:Xe,foregroundGraphics:Xt,marginalGraphics:bt,xValues:[],yValues:[],annotations:$e,svgAnnotationRules:We,annotationFrame:0,xAccessor:Vn,yAccessor:qn,annotationData:Kn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,linkedCrosshairName:_t,linkedCrosshairSourceId:Pt}))}return g.createElement("div",{ref:Lt,className:"stream-xy-frame"+(G?" "+G:""),role:"group","aria-label":Mt||("string"==typeof et?et:"XY chart"),tabIndex:0,style:{position:"relative",width:j?"100%":Ot[0],height:Y?"100%":Ot[1],overflow:"visible"},onKeyDown:$n},At&&g.createElement(dt,{tableId:Bt}),At&&g.createElement(st,{scene:null!==(l=null===(o=wn.current)||void 0===o?void 0:o.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:Bt,chartTitle:"string"==typeof et?et:void 0}),g.createElement(ut,{summary:St}),g.createElement("div",{role:"img","aria-label":Mt||("string"==typeof et?et:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ut?Wn:void 0,onMouseLeave:Ut?Tn:void 0,onClick:Le?Ln:void 0},Gt&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ot[0],height:Ot[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${Ht.left},${Ht.top})`},Gt)),g.createElement(Ye,{width:Vt,height:qt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,scales:tn,showAxes:be,axes:ke,showGrid:Re,xFormat:zn,yFormat:Se||Pe}),g.createElement("canvas",{ref:Kt,"aria-label":Qe(null!==(s=null===(a=wn.current)||void 0===a?void 0:a.scene)&&void 0!==s?s:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Zt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(ht,{hoverPoint:hn}),g.createElement(Ge,{width:Vt,height:qt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,scales:tn,showAxes:be,axes:ke,xLabel:we,yLabel:Ee,yLabelRight:Ae,xFormat:zn,yFormat:Se||Pe,showGrid:Re,title:et,legend:ze,legendHoverBehavior:Be,legendClickBehavior:Fe,legendHighlightedCategory:je,legendIsolatedCategories:He,legendPosition:Xe,foregroundGraphics:Xt,marginalGraphics:bt,xValues:pn,yValues:mn,annotations:$e,svgAnnotationRules:We,annotationFrame:Jt,xAccessor:Vn,yAccessor:qn,annotationData:Kn(null===(c=wn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=wn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0,linkedCrosshairName:_t,linkedCrosshairSourceId:Pt}),(nt||rt)&&g.createElement(x,{width:Vt,height:qt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,dimension:null!==(d=null==nt?void 0:nt.dimension)&&void 0!==d?d:"xy",scales:tn,onBrush:null!=rt?rt:()=>{},binSize:T,snap:null==nt?void 0:nt.snap,binBoundaries:null!==(h=null==nt?void 0:nt.binBoundaries)&&void 0!==h?h:"bar"===y?null===(f=wn.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==nt?void 0:nt.snapDuring,streaming:"streaming"===p}),(null==ct?void 0:ct.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ct.badgePosition?{top:4,left:4}:"bottom-left"===ct.badgePosition?{bottom:4,left:4}:"bottom-right"===ct.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:yn?"#dc3545":"#28a745",color:"white"})},yn?"STALE":"LIVE"),Yn,Fn))});un.displayName="StreamXYFrame";const dn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},hn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class fn{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,r){var i;for(let o=0;this.capacity>o;o++){const l=this.particles[o];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1,this._freeIndices.push(o);continue}const s=r&&null!==(i=r[l.edgeIndex])&&void 0!==i?i:1;l.t+=e*t*s*(a.bezier.circular?.3:1),1>l.t?yn(a.bezier,l.t,l.offset,l):(l.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}}function yn(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,i){const o=e.length,l=t*o,a=Math.min(Math.floor(l),o-1),s=l-a,[c,u,d,h]=e[a];gn(c,u,d,h,s,i);const f=h.x-c.x,y=h.y-c.y,g=Math.sqrt(f*f+y*y);if(g>.001){const e=f/g;i.x+=-y/g*n*r*2,i.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[i,o,l,a]=e.points;gn(i,o,l,a,t,r);const s=a.x-i.x,c=a.y-i.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function gn(e,t,n,r,i,o){const l=1-i,a=l*l,s=a*l,c=i*i,u=c*i;o.x=s*e.x+3*a*i*t.x+3*l*c*n.x+u*r.x,o.y=s*e.y+3*a*i*t.y+3*l*c*n.y+u*r.y}function pn(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function vn(e,t){var n,r=[],i=[],o=[],l={},a=[];function s(e){o[e]=!1,l.hasOwnProperty(e)&&Object.keys(l[e]).forEach(function(t){delete l[e][t],o[t]&&s(t)})}function c(e){var t,r,d=!1;for(i.push(e),o[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,i),d=!0):o[r]||(d=c(r));if(d)s(e);else for(t=0;a[e].length>t;t++){var h=l[r=a[e][t]];h||(l[r]=h={}),h[r]=!0}return i.pop(),d}function u(e,t){var n=[].concat(t).concat(e);r.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),i=Array(t),o=Array(t),l=Array(t),a=Array(t),s=0;t>s;++s)n[s]=-1,r[s]=0,i[s]=!1,o[s]=0,l[s]=-1,a[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(n[t]=r[t]=u,i[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>o[t]){for(var y=o[t];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,i[g]=!0,u+=1,s.push(g),c.push(g);break}i[g]&&(r[t]=0|Math.min(r[t],r[g])),0>l[g]||a[t].push(l[g])}o[t]=y}else{if(r[t]===n[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(i[x]=!1,p.push(x),v.push(a[x]),m+=a[x].length,l[x]=d.length,x===t){s.length=y;break}}d.push(p);var b=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)b[--m]=v[y][k];h.push(b)}c.pop()}}}for(s=0;t>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(e),i=r.components.filter(function(e){return e.length>1}),o=1/0,l=0;i.length>l;l++)for(var a=0;i[l].length>a;a++)o>i[l][a]&&(o=i[l][a],n=l);var s=i[n];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:o,adjList:c}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];o[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return r}function mn(e){return e.y0-e.y1>0?"up":"down"}function xn(e,t){return t(e.source)==t(e.target)}function bn(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function kn(e){return e.target.x0-e.source.x1}function wn(e,t){var n=An(e),r=kn(t)/Math.tan(n);return"up"==mn(e)?e.y1-r:e.y1+r}function En(e,t){var n=An(e),r=kn(t)/Math.tan(n);return"up"==mn(e)?e.y1+r:e.y1-r}function An(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Mn(e,t){return t(e)}function Sn(e){return Pn(e.source)}function _n(e){return Pn(e.target)}function Pn(e){return(e.y0+e.y1)/2}function Cn(e){return e.virtual?0:e.value}function Tn(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!xn(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!xn(e,t)?r+1:r}),n+r}function Dn(e){return e.target.depth}function Ln(e,t){return e.sourceLinks.length?e.depth:t-1}function On(e,t){return e.y0-t.y0}function Nn(e,t){return t.y0-e.y0}function In(e,t){return e.y1-t.y1}function $n(e,t){return t.y1-e.y1}function Wn(e,t){return zn(e.source,t.source)||e.index-t.index}function Rn(e,t){return zn(e.target,t.target)||e.index-t.index}function zn(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Bn(e,t){return Fn(e)==Fn(t)?"bottom"==e.circularLinkType?Nn(e,t):On(e,t):Fn(t)-Fn(e)}function Fn(e){return e.target.column-e.source.column}function jn(e,t){return Yn(e)==Yn(t)}function Yn(e){return e.y0-e.y1>0?"up":"down"}function Hn(e,t,n,r,i){let o=e;var a=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=l.min(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=o.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Xn(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Xn(o.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),o.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,xn(e,t)&&bn(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var l=e.source.column,a=e.circularLinkType,c=o.links.filter(function(e){return e.source.column==l&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?Nn:On);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),l=e.target.column,(c=o.links.filter(function(e){return e.target.column==l&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?$n:In),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,i=e.y1,o=(t+r)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(e)}),o}function Xn(e,t,n){e.sort(Bn);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xn(e,t)&&bn(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Gn(e,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=s>o?s:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function Gn(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Vn(e){return function(){return e}}function qn(e){return e.index}function Un(e){return e.nodes}function Kn(e){return e.links}function Zn(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(i,o){var l=i.length;if(t)i.sort(t);else if(o>0){var a=new Map;i.forEach(function(e,t){var n,r,i,o=(r=0,i=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Pn(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Pn(e.target)*t,r+=t}}),r>0?i/r:NaN);a.set(e,{bc:o,idx:t})}),i.sort(function(e,t){var n=a.get(e),r=a.get(t),i=n.bc,o=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(o)?isNaN(i)?isNaN(o)?n.idx-r.idx:1:-1:i-o})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Tn(t,n)-Tn(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==r.length-1&&1==l||0==t.depth&&1==l?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Tn(t,n)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/l*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-l/2+i,t.y1=t.y0+t.value*e.ky)})})}function Qn(e,t,n,r,i,o){var a=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=o;c>0;--c)u(s*=.99,n),d();function u(t,n){var r=a.length;a.forEach(function(i){var o=i.length,a=i[0].depth;i.forEach(function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Tn(i,n)>0){var c=l.mean(i.sourceLinks,_n),u=l.mean(i.targetLinks,Sn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Pn(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==o)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(a==r-1&&1==o)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)s=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+s;else{var f=l.mean(i.sourceLinks,_n),y=l.mean(i.targetLinks,Sn),g=((f&&y?(f+y)/2:f||y)-Pn(i))*t;i.y0+=g,i.y1+=g}})})}function d(){a.forEach(function(n){var o,l,a,s=e.y0,c=n.length;for(n.sort(t||zn),a=0;c>a;++a)(l=s-(o=n[a]).y0)>0&&(o.y0+=l,o.y1+=l),s=o.y1+r;if((l=s-r-e.y1)>0)for(s=o.y0-=l,o.y1-=l,a=c-2;a>=0;--a)(l=(o=n[a]).y1+i-s)>0&&(o.y0-=l,o.y1-=l),s=o.y0})}}function Jn(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Rn),e.targetLinks.sort(Wn)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,i=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function er(){var e=0,t=0,n=1,r=1,i=24,o=8,a=null,s=qn,c=Ln,u=void 0,d=32,h=2,f=Un,y=Kn;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=r,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return l.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,i=e.target;"object"!=typeof r&&(r=e.source=pn(n,r)),"object"!=typeof i&&(i=e.target=pn(n,i)),r.sourceLinks.push(e),i.targetLinks.push(e)})}(f,s),function(e,t){var n=0;if(null==t){for(var r=[],i=0;e.links.length>i;i++){var o=e.links[i],l=o.source.index,a=o.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=vn(r);s.sort(function(e,t){return e.length-t.length});var c={};for(i=0;s.length>i;i++){var u=s[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,u),function(e,t){var n=0,r=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:r>n?"top":"bottom","top"==i.circularLinkType?n++:r++,e.nodes.forEach(function(e){Mn(e,t)!=Mn(i.source,t)&&Mn(e,t)!=Mn(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xn(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(l.sum(e.sourceLinks,Cn),l.sum(e.targetLinks,Cn)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,n){var r,i,o;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var l=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){l=t(e)==a?l:l+1,a=t(e)==a?a:t(e),e.column=l})}for(r=e.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(r=e.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(f,u,c);var y=o;if(null!==a){var g=l.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=l.max(g,function(e){return e.length});p>1&&(y=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=l.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=l.min(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/l.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var o=l.max(e.nodes,function(e){return e.column});e.nodes.forEach(o>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/o),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,i),Zn(f,u,s),Qn(f,u,s,y,y,d),Jn(f),Hn(f,s,h,10,8),Zn(f,u,s),Qn(f,u,s,y,y,d),Jn(f),Hn(f,s,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return Mn(n.source,t)==Mn(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!jn(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=wn(t,e);return e.y1-n}if(t.target.column>e.target.column)return wn(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;r.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,l=0;i>o;o++)l+=r[o].width;t.y0=e.y1-l-t.width/2}})})}(f,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return Mn(n.target,t)==Mn(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!jn(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=En(t,e);return e.y0-n}if(t.source.column>e.source.column)return En(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;r.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,l=0;i>o;o++)l+=r[o].width;t.y1=e.y1-l-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,r=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==r||0==i){var o=l.min(t,function(e){return e.y0}),a=l.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-o);function c(t){return(t-o)/(a-o)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(f),Hn(f,s,h,10,8)}(g),g}return g.update=function(e){return Jn(e),Hn(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(i=+e,g):i},g.nodePadding=function(e){return arguments.length?(o=+e,g):o},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:Vn(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:Vn(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Vn(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Vn(e),g):c},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],n=+i[1][0],r=+i[1][1],g):[[e,t],[n,r]]},g.size=function(i){return arguments.length?(e=t=0,n=+i[0],r=+i[1],g):[n-e,r-t]},g}const tr=e=>{let t,n,r,i,o,l,a,s,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,o=e.source.x1,l=e.target.x0,a=u.interpolateNumber(o,l),s=a(.5),c=a(.5),`M${t},${o}C${t},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${i},${s} ${i},${o}Z`):(t=e.source.x1,n=e.target.x0,a=u.interpolateNumber(t,n),r=a(.5),i=a(.5),o=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,s=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${o}C${r},${o} ${i},${l} ${n},${l}L${n},${s}C${i},${s} ${r},${c} ${t},${c}Z`)};function nr(e){var t;const n=e.sankeyWidth/2,r=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const t=i.sourceX,r=i.sourceY,o=i.targetX,l=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${t},${r-n}L${t+a},${r-n}L${t+a},${r+n}L${t},${r+n}ZM${o},${l-n}L${o-s},${l-n}L${o-s},${l+n}L${o},${l+n}Z`}const o=i.sourceX,l=i.sourceY,a=i.targetX,s=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${o},${l-h*n}L${c},${l-h*n}L${c+r},${l-h*n+h*f}L${c+r},${d+h*r-h*f}L${c+r-f},${d+h*r}L${u-r+f},${d+h*r}L${u-r},${d+h*r-h*f}L${u-r},${s-h*n+h*f}L${u-r+f},${s-h*n}L${a},${s-h*n}L${a},${s+h*n}L${u+r},${s+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${l+h*n}L${o},${l+h*n}Z`}const rr=new Set,ir=new WeakMap;function or(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=ir.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,ir.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;rr.has(e)||(rr.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}const lr={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Dn))-1:0},justify:Ln},ar={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var i,o,l,a,s,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,y=null!==(o=n.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=er().extent(m).links(v).nodes(p).nodeAlign(lr[h]||Ln).nodeId(e=>e.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let e=1/0,t=-1/0,n=1/0,i=-1/0;for(const r of p)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>i&&(i=r.y1);for(const r of v){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;e>o.leftFullExtent-l&&(e=o.leftFullExtent-l),o.rightFullExtent+l>t&&(t=o.rightFullExtent+l),n>o.verticalFullExtent-l&&(n=o.verticalFullExtent-l),o.verticalFullExtent+l>i&&(i=o.verticalFullExtent+l)}const o=t-e,l=i-n,u=r[0],d=r[1];if(o>0&&l>0&&(0>e||0>n||t>u||i>d)){const t=Math.min(u/o,d/l),r=-e*t+(u-o*t)/2,i=-n*t+(d-l*t)/2;for(const e of p)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of v)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+i,n.targetY=n.targetY*t+i,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+i,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+i,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of p){const t=b.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,n=e.target,r="object"==typeof t&&null!==t?t.id:t+"",i="object"==typeof n&&null!==n?n.id:n+"",o=k.get(e._edgeKey?e._edgeKey:`${r}\0${i}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=d;const t=b.get(r),n=b.get(i);t&&(o.source=t),n&&(o.target=n)}}},buildScene(e,t,n,r){var i,l,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:o.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=u?u(or(t,"nodeStyle")):{},i={fill:r.fill||g.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};x.set(t.id,("string"==typeof i.fill?i.fill:null)||g.get(t.id)||"#4d430c"),p.push("down"===c?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:i,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r="#999";r="function"==typeof f?f(e)||r:"target"===f?x.get(n.id)||g.get(n.id)||r:x.get(t.id)||g.get(t.id)||r;const i=d?d(or(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||r;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(l=i.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let o;if(o=e.circular&&e.circularPathData?nr(e):tr(e),!o)continue;const c={fill:i.fill||r,fillOpacity:null!==(s=i.fillOpacity)&&void 0!==s?s:h,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};v.push({type:"bezier",pathD:o,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const o=t?t(n):n.id;if(!o)continue;let l,a,s;"down"===c?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,s="middle"):(r[0]/2>n.x0+e/2?(l=n.x0-6,s="end"):(l=n.x1+6,s="start"),a=n.y0+i/2),m.push({x:l,y:a,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:v,labels:m}}},sr={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var i,o;if(0===e.length)return;const l=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const f=u>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const r=cr(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const i=ur(e.id),o=i%360*(Math.PI/180),l=10+i%20;e.x=t/r.length+l*Math.cos(o),e.y=n/r.length+l*Math.sin(o)}else{const t=ur(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=a+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),i=n*t;r.x=a+e*Math.cos(i),r.y=s+e*Math.sin(i)}}}const y=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=0===n.iterations?0:f?40:y,p=dr(n.nodeSize,n.nodeSizeRange,e),v=e=>p(e);if(g>0){const n=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),r=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*v(e))).force("center",d.forceCenter(a,s).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(s).strength(.15));if(r.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));r.force("link",n),r.force("link").links(e)}f?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let e=0;g>e;++e)r.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){var i,l,a;const s=n.nodeStyle,c=n.edgeStyle,u=dr(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:o.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(or(t,"nodeSize")),n=s?s(or(t,"nodeStyle")):{},r={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:2,opacity:n.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(or(e,"edgeStyle")):{},i={stroke:r.stroke||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:i,datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=u(or(n,"nodeSize"));g.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function cr(e,t,n){const r=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,o="string"==typeof i.target?i.target:i.target.id;let l=null;if(t===e?l=o:o===e&&(l=t),l){const e=n.get(l);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function ur(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function dr(e,t,n){var i,o;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const a=t||[5,20],s=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>a[0];const c=null!==(i=l.min(s))&&void 0!==i?i:0,u=null!==(o=l.max(s))&&void 0!==o?o:1;if(c===u)return()=>(a[0]+a[1])/2;const d=r.scaleLinear().domain([c,u]).range(a).clamp(!0);return t=>{var n;const r=null===(n=t.data)||void 0===n?void 0:n[e];return null==r||"number"!=typeof r?a[0]:d(r)}}const hr=o.schemeCategory10,fr={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,c=a-o,u=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=g.get("string"==typeof e.source?e.source:e.source.id),r=g.get(t);if(void 0===n||void 0===r)continue;const i=f(e);v[n][r]=i}const m=h.chord().padAngle(i);l&&m.sortGroups(l);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(a);for(const t of b){const n=e[t.index],r=k.centroid(t);n.x=r[0]+u,n.y=r[1]+d,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),r=w.get(t);n&&(e.source=n),r&&(e.target=r)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of x){const n=e[t.source.index].id,r=e[t.target.index].id,i=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);i&&(i.chordData=t)}},buildScene(e,t,n,r){var i,o;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:hr,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=h.ribbon().radius(c),x=[],b=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.arcData;if(!r)continue;let o;o=f?f(or(n,"nodeStyle")).fill||v.get(n.id)||p[t%p.length]:v.get(n.id)||p[t%p.length];const l=f?f(or(n,"nodeStyle")):{},a={fill:o,stroke:l.stroke||"black",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};x.push({type:"arc",cx:u,cy:d,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=m(t);if(!n)continue;const r=yr(n,u,d);let i="#999";if(y)i=y(or(e,"edgeStyle")).fill||i;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===g&&n?i=v.get(n.id)||i:t&&(i=v.get(t.id)||i)}const l=y?y(or(e,"edgeStyle")):{},s={fill:i,fillOpacity:null!==(o=l.fillOpacity)&&void 0!==o?o:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,r=s+12;for(const n of e){const e=n.arcData;if(!e)continue;const i=t?t(n):n.id;if(!i)continue;const o=(e.startAngle+e.endAngle)/2,l=o-Math.PI/2;k.push({x:u+Math.cos(l)*r,y:d+Math.sin(l)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function yr(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const i=[];let o=0;for(;r.length>o;){const e=r[o];if("M"===e||"L"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("C"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;3>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("Q"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;2>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("A"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&(i.push(Number(r[o])+t+""),o++),r.length>o&&(i.push(Number(r[o])+n+""),o++);else"Z"===e||"z"===e?(i.push(e),o++):(i.push(r[o]),o++)}return i.join(" ")}const gr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function pr(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function vr(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function mr(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function xr(e){return Array.isArray(e.colorScheme)?e.colorScheme:gr}function br(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:"#4d430c"}function kr(e,t,n,r,i){if("horizontal"===i){const i=(e+n)/2;return`M ${e},${t} C ${i},${t} ${i},${r} ${n},${r}`}if("radial"===i){const i=(e+n)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+r)/2} T ${n},${r}`}{const i=(t+r)/2;return`M ${e},${t} C ${e},${i} ${n},${i} ${n},${r}`}}const wr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){var i;const o=n.__hierarchyRoot;if(!o)return;const l=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=a.hierarchy(o,s);d.sum(u),d.sort((e,t)=>{var n,r;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(r=e.value)&&void 0!==r?r:0)});const[h,f]=r;switch(l){case"tree":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=a.tree();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(d,n,h,f);break;case"cluster":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=a.cluster();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(d,n,h,f);break;case"treemap":!function(e,t,n,r){var i,o;const l=null!==(i=t.padding)&&void 0!==i?i:4,s=null!==(o=t.paddingTop)&&void 0!==o?o:0,c=a.treemap().size([n,r]).tile(a.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(e)}(d,n,h,f);break;case"circlepack":!function(e,t,n,r){var i;const o=null!==(i=t.padding)&&void 0!==i?i:4;a.pack().size([n,r]).padding(o)(e)}(d,n,h,f);break;case"partition":!function(e,t,n,r){var i;a.partition().size([n,r]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,n,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const r=y[t],o={id:vr(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=r.value)&&void 0!==i?i:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?Er(o,r,n):"treemap"===l||"partition"===l?Ar(o,r):"circlepack"===l&&Mr(o,r),o.__hierarchyNode=r,e.push(o),g.set(r,o)}if("tree"===l||"cluster"===l)for(const e of y)if(e.parent){const n=g.get(e.parent),r=g.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,i,o){var l,a,s,c,u;const d=[],h=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,v=r[1]/2,m="number"==typeof(x=n.nodeSize)?x:5;var x;for(const t of e){let e=t.x,r=t.y;g&&(e+=p,r+=v);const o=i(or(t,"nodeStyle"));let a=o.fill||br(n);if(n.colorByDepth&&void 0!==t.depth){const e=xr(n);a=e[t.depth%e.length]}const s={fill:a,stroke:o.stroke||"#fff",strokeWidth:null!==(l=o.strokeWidth)&&void 0!==l?l:1,opacity:o.opacity};d.push({type:"circle",cx:e,cy:r,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let r=t.x,i=t.y,l=n.x,a=n.y;g&&(r+=p,i+=v,l+=p,a+=v);const u=kr(r,i,l,a,y),d=o(or(e,"edgeStyle")),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:b};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==n.showLabels){const t=mr(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,i,o,l=n.x,a=n.y;if(g&&(l+=p,a+=v),g){const e=l-p,t=a-v,n=Math.sqrt(e*e+t*t);n>0?(r=l+e/n*10,i=a+t/n*10,o=0>e?"end":"start"):(r=l,i=a-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-m-6,o="end"):(r=l+m+6,o="start"),i=a):(r=l,i=a+m+14,o="middle");f.push({x:r,y:i,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,n,r,i,o);case"treemap":case"partition":return function(e,t,n,r){var i,o;const l=[],a=[];for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const a=r(or(n,"nodeStyle"));let s=a.fill||br(t);if(t.colorByDepth&&void 0!==n.depth){const e=xr(t);s=e[n.depth%e.length]}const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:e,h:o,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=mr(t.nodeLabel),i=t.labelMode||"leaf",l="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const u=!((null===(o=s.data)||void 0===o?void 0:o.children)&&s.data.children.length>0);if(!l){if("leaf"===i&&!u)continue;if("parent"===i&&u)continue}const d=n?n(s):s.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>c)continue;let h=r(or(s,"nodeStyle")).fill||br(t);if(t.colorByDepth&&void 0!==s.depth){const e=xr(t);h=e[s.depth%e.length]}const f=pr(h);a.push(u?{x:s.x0+e/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(e,n,0,i);case"circlepack":return function(e,t,n,r){var i,o,l,a,s;const c=[],u=[];for(const n of e){const e=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=e)continue;const a=r(or(n,"nodeStyle"));let s=a.fill||br(t);if(t.colorByDepth&&void 0!==n.depth){const e=xr(t);s=e[n.depth%e.length]}const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=mr(t.nodeLabel);for(const i of e){const e=null!==(a=i.__radius)&&void 0!==a?a:5,o=n?n(i):i.id;if(!o)continue;if(15>e)continue;const l=!((null===(s=i.data)||void 0===s?void 0:s.children)&&i.data.children.length>0);let c=r(or(i,"nodeStyle")).fill||br(t);if(t.colorByDepth&&void 0!==i.depth){const e=xr(t);c=e[i.depth%e.length]}if(l){const t=pr(c);u.push({x:i.x,y:i.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:i.x,y:i.y-e+14,text:o+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Er(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ar(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Mr(e,t){var n;const r=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}function Sr(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const _r={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const i=n.__hierarchyRoot;i&&function(e,t,n,r,i){var o,l;const a=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(o=n.orbitSize)&&void 0!==o?o:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,f="number"==typeof d?()=>d:d,y="number"==typeof h?()=>h:h,g=Sr(n);g.metaMap.clear(),r.length=0,i.length=0;const p=new Map;function v(e){var t;const n=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,n+1),0===n?e:`${e}__${n}`}const m=t[0]/2,x=t[1]/2,b=Math.min(t[0],t[1])/2*.85,k=v(c(e));r.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:e}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,o,l,d,h,p){const m=a(t);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:h,data:t,parentId:n},S=p?d/f(M)*A:d*A,_=s.pie().value(e=>{var t;return(null===(t=a(e))||void 0===t?void 0:t.length)?4:1}).sort(null),P=_(w),C=y(M);for(let t=0;w.length>t;t++){const a=(P[t].startAngle+P[t].endAngle)/2,s=w[t],u=v(c(s)),d=o+S*Math.sin(a),f=l+S*Math.cos(a)*C;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:s}),g.metaMap.set(u,{ring:S,angle:a,depth:h,parentId:n,eccentricity:C}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,S,h+1,!0)}E+=k}}(e,k,m,x,b,1,!1)}(i,r,n,e,t)},buildScene(e,t,n,r){var i,o,l,a,s;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],y=[];if(!1!==n.orbitShowRings){const t=Sr(n),r=new Map;for(const t of e)r.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;i.has(n)||i.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const o=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of i)for(let i=0;o>i;i++){const a=i/o*Math.PI*2,s=(i+1)/o*Math.PI*2;f.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(s),y2:t+n*Math.cos(s)*r,style:l,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(or(t,"nodeSize")),n=c?c(or(t,"nodeStyle")):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(o=n.opacity)&&void 0!==o?o:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id,depth:t.depth})}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:g.get(e.source),n="object"==typeof e.target?e.target:g.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(or(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[t])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:y}},tick:(e,t,n,r,i)=>!1!==n.orbitAnimated&&(function(e,t){var n,r;const i=Sr(t),o=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=t.orbitRevolution)&&void 0!==r?r:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const r=e.angle+a*s*l({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(r),t.y=n.y+e.ring*Math.cos(r)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},Pr={sankey:ar,force:sr,chord:fr,tree:wr,cluster:wr,treemap:wr,circlepack:wr,partition:wr,orbit:_r};function Cr(e){return Pr[e]}class Tr{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},dn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new fn(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},dn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new fn(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n){const{nodeIDAccessor:r="id",sourceAccessor:i="source",targetAccessor:o="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:e=>e[r],s="function"==typeof i?i:e=>e[i],c="function"==typeof o?o:e=>e[o],u="function"==typeof l?l:e=>{var t;return null!==(t=e[l])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Dr(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],r=s(n)+"",i=c(n)+"",o=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Dr(r)),{data:n})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Dr(i)),{data:n}));const l=`${r}\0${i}\0${e}`;this.edges.set(l,{source:r,target:i,value:o,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,i=0===this.nodes.size;let o=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Dr(t)),this.nodeTimestamps.set(t,l),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,Dr(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,o=!0);const a=this.edgeKey(t,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,o=!0),i||o||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,r,i,o,l,a,s;const c=Cr(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values()),d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const a of u)if(void 0!==a._prevX0){const s=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(i=a._prevY0)&&void 0!==i?i:0);e.set(a.id,{x:(null!==(o=a._prevX0)&&void 0!==o?o:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),y=null!==(s=null===(a=this.config.transition)||void 0===a?void 0:a.duration)&&void 0!==s?s:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&y>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:y}}else f&&y>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:y});this._hasRenderedOnce=!0;const g=new Set(this.nodes.keys()),p=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of g)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)g.has(e)||this.removedNodes.add(e);for(const e of p)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)p.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=g,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(e){const t=Cr(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:o,labels:l}=t.buildScene(n,r,this.config,e);this.sceneNodes=i,this.sceneEdges=o,this.labels=l}get isAnimating(){const e=Cr(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Cr(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return n.tick(r,i,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=O(e,this.transition),n=L(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=N(e._prevX0,e._targetX0,n),e.x1=N(e._prevX1,e._targetX1,n),e.y0=N(e._prevY0,e._targetY0,n),e.y1=N(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=N(e._prevY0,e._targetY0,n),e.y1=N(e._prevY1,e._targetY1,n),e.sankeyWidth=N(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=null==e?void 0:e.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,o=n.x0,l=u.interpolateNumber(i,o);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:o}],halfWidth:r}}const i=t.x1,o=n.x0,l=u.interpolateNumber(i,o);return{circular:!1,points:[{x:i,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:o,y:e.y1}],halfWidth:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const i=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],o=n.x-t.x,l=n.y-t.y;i.push([t,{x:t.x+o/3,y:t.y+l/3},{x:t.x+2*o/3,y:t.y+2*l/3},n])}return{circular:!0,segments:i,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,r,i,o;const l=this.config.pulse;if(!l)return;const a=null!==(t=l.duration)&&void 0!==t?t:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const i=e-r;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const r="object"==typeof n.source?null===(i=n.source)||void 0===i?void 0:i.id:n.source,l="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=s)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const r=this.nodeTimestamps.size;if(1>=r)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const i=this._decaySortedNodes,o=new Map;for(let e=0;i.length>e;e++)o.set(i[e][0],e);for(const i of this.sceneNodes){const l=i.id;if(!l)continue;const a=o.get(l);if(void 0===a)continue;const s=T(n,a,r),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*s})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,r),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const r=this.config.thresholds;if(!r)return;const i=null!==(t=r.warningColor)&&void 0!==t?t:"#f59e0b",o=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=i):c=o,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),l&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const r=this.nodes.get(e);if(!r)return null;const i=r.data?Object.assign({},r.data):{};return r.data=t(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,i}updateEdge(e,t,n){var r;const i=this.config.valueAccessor,o="function"==typeof i?i:i?e=>e[i]:e=>e.value,l=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t){l.push(i.data?Object.assign({},i.data):{}),i.data=n(null!==(r=i.data)&&void 0!==r?r:{});const e=o(i.data);null!=e&&(i.value=Number(e))}return l.length>0&&this.layoutVersion++,l}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)r(i.data)===e&&n.push(t)}else for(const[r,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Dr(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Lr(e,t,n,r,i=30){let o=null,l=i,a=1/0;for(const t of e){const e=Or(t,n,r,i);if(e)if("rect"===t.type){const n=t.w*t.h;a>n&&(o=e,a=n)}else l>e.distance&&(o=e,l=e.distance)}if(o)return o;for(const e of t){const t=Rr(e,n,r);t&&l>t.distance&&(o=t,l=t.distance)}return o}function Or(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const i=t-e.cx,o=n-e.cy,l=Math.sqrt(i*i+o*o);return l>V(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:l}}(e,t,n,r);case"rect":return function(e,t,n){const r=G(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,i=n-e.cy,o=Math.sqrt(r*r+i*i);if(e.innerR-2>o||o>e.outerR+2)return null;const l=K(Math.atan2(i,r)),a=K(e.startAngle),s=K(e.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Nr=null,Ir=null;function $r(){return Ir||(Nr=document.createElement("canvas"),Nr.width=1,Nr.height=1,Ir=Nr.getContext("2d")),Ir}function Wr(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function Rr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var r,i;if(!e.pathD)return null;const o=Wr(e),l=$r();if(!o||!l)return null;try{if(l.isPointInPath(o,t,n)){const o="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.source)?e.datum.source:null,l="object"==typeof(null===(i=e.datum)||void 0===i?void 0:i.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:o&&l?(o.x1+l.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(o,t,n);if(l.lineWidth=a,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,i=e.y2-e.y1,o=r*r+i*i;if(0===o)return null;let l=((t-e.x1)*r+(n-e.y1)*i)/o;l=Math.max(0,Math.min(1,l));const a=e.x1+l*r,s=e.y1+l*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:s,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=Wr(e),i=$r();if(!r||!i)return null;try{if(i.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const l=i.isPointInStroke(r,t,n);if(i.lineWidth=o,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function zr(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,labels:l,title:a,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=e;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof a?a:"Network Chart"),g.createElement("desc",null,"string"==typeof a?a+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${o.left},${o.top})`},l.map((e,t)=>g.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),v&&v.filter(e=>"widget"!==e.type).map((e,r)=>{if(m){const i=m(e,r,{width:t,height:n,sceneNodes:p});if(i)return g.createElement(g.Fragment,{key:"annotation-"+r},i)}return null}),y),a&&"string"==typeof a?g.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?g.createElement("foreignObject",{x:0,y:0,width:r,height:o.top},a):null,xe({legend:s,totalWidth:r,totalHeight:i,margin:o,legendPosition:f,title:a,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var n,r,i,l,a,s,c,u,d;const h=p.find(t=>{var n,r,i,o,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(i=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)===e.nodeId||(null===(l=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===l?void 0:l.name)===e.nodeId});if(!h)return null;const f=o.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(r=h.x)&&void 0!==r?r:0),y=o.top+(null!==(i=h.cy)&&void 0!==i?i:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(l=h.y)&&void 0!==l?l:0),v=null!==(a=e.dx)&&void 0!==a?a:0,m=null!==(s=e.dy)&&void 0!==s?s:-16,x=null!==(c=e.width)&&void 0!==c?c:32,b=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:f+v-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Br(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Fr(e,t){var n,r,i,o,l,a;if(!t.pathD)return;e.save();const s=Br(t);if(t.style.fill&&"none"!==t.style.fill){const l=t._gradient;if(l){const i=e.createLinearGradient(l.x0,0,l.x1,0),o=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,a="string"==typeof t.style.fill?t.style.fill:"#999";i.addColorStop(0,1===l.from?a:"transparent"),i.addColorStop(1,1===l.to?a:"transparent"),e.fillStyle=i,e.globalAlpha=o}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==o?o:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(l=t.style.strokeWidth)&&void 0!==l?l:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function jr(e,t){var n,r;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(r=t.style.strokeWidth)&&void 0!==r?r:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Yr(e,t){var n,r,i,o;if(!t.pathD)return;e.save();const l=Br(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,e.fill(l)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.3*(null!==(o=t.style.opacity)&&void 0!==o?o:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(l)),e.restore()}function Hr(e,t){var n,r;if(!t.pathD)return;e.save();const i=Br(t);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(i),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.1,e.fill(i)),e.restore()}zr.displayName="NetworkSVGOverlay";const Xr={top:20,right:80,bottom:20,left:80},Gr={top:40,right:40,bottom:40,left:40},Vr=new Set(["chord","force","circlepack","orbit"]),qr=[800,600],Ur={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Kr({data:e}){var t,n,r,i,o,l;if("edge"===e.nodeOrEdge){const t=e.data;return g.createElement("div",{className:"semiotic-tooltip",style:Ur},g.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const a=e.data,s=null==a?void 0:a.__hierarchyNode;if(s){const e=[];let o=s;for(;o;){const l=null!==(i=null!==(n=null===(t=o.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(r=o.data)||void 0===r?void 0:r.id)&&void 0!==i?i:a.id;null!=l&&e.unshift(l+""),o=o.parent}e.length>1&&e.shift();const l=e.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Ur},g.createElement("div",null,e.map((e,t)=>g.createElement("span",{key:t},t>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===l?g.createElement("strong",null,e):g.createElement("span",{style:{opacity:.7}},e)))),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(o=a.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),u=(a.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(a.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Ur},g.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Zr=e.forwardRef(function(t,n){var r,i,o,l,a,c,u,d,h,f,y,p,v,m;const{chartType:x,nodes:b,edges:k,data:w,initialEdges:E,nodeIDAccessor:A="id",sourceAccessor:M="source",targetAccessor:S="target",valueAccessor:_="value",edgeIdAccessor:C,childrenAccessor:T,hierarchySum:D,orientation:L="horizontal",nodeAlign:O="justify",nodePaddingRatio:N=.05,nodeWidth:I=15,iterations:$=300,forceStrength:W=.1,padAngle:R=.01,groupWidth:z=20,sortGroups:B,edgeSort:F,treeOrientation:j="vertical",edgeType:Y="curve",padding:H,paddingTop:X,tensionConfig:G,showParticles:V=!1,particleStyle:q,nodeStyle:U,edgeStyle:K,colorBy:Z,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:ee=.5,colorByDepth:te=!1,nodeSize:ne=8,nodeSizeRange:re=[5,20],nodeLabel:ie,showLabels:oe=!0,labelMode:le,size:ue=qr,responsiveWidth:de,responsiveHeight:fe,margin:ye,className:ge,background:pe,enableHover:ve=!0,tooltipContent:me,customHoverBehavior:xe,customClickBehavior:be,onObservation:ke,chartId:we,onTopologyChange:Ee,annotations:Ae,svgAnnotationRules:Me,legend:Se,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Ce,legendHighlightedCategory:Te,legendIsolatedCategories:De,title:Le,foregroundGraphics:Oe,backgroundGraphics:Ne,decay:Ie,pulse:$e,transition:We,animate:Re,staleness:ze,thresholds:Be,accessibleTable:Fe=!0,description:je,summary:Ye,orbitMode:He,orbitSize:Xe,orbitSpeed:Ge,orbitRevolution:Ue,orbitRevolutionStyle:Ke,orbitEccentricity:Ze,orbitShowRings:Qe,orbitAnimated:et}=t,tt=Vr.has(x)?Gr:Xr,nt=e.useRef(!0),rt=Nt({sizeProp:ue,responsiveWidth:de,responsiveHeight:fe,userMargin:ye,marginDefault:tt,foregroundGraphics:Oe,backgroundGraphics:Ne,animate:Re,transitionProp:We,themeDirtyRef:nt}),{reducedMotionRef:it,responsiveRef:ot,size:lt,margin:at,adjustedWidth:st,adjustedHeight:ft,resolvedForeground:pt,resolvedBackground:vt,transition:mt,introEnabled:xt,tableId:bt,rafRef:kt,renderFnRef:wt,scheduleRender:Et}=rt,At=e.useMemo(()=>Object.assign(Object.assign({},dn),G),[G]),Mt=e.useMemo(()=>Object.assign(Object.assign({},hn),q),[q]),St=e.useMemo(()=>({chartType:x,nodeIDAccessor:A,sourceAccessor:M,targetAccessor:S,valueAccessor:_,edgeIdAccessor:C,childrenAccessor:T,hierarchySum:D,orientation:L,nodeAlign:O,nodePaddingRatio:N,nodeWidth:I,iterations:$,forceStrength:W,padAngle:R,groupWidth:z,sortGroups:B,edgeSort:F,treeOrientation:j,edgeType:Y,padding:H,paddingTop:X,tensionConfig:At,showParticles:V,particleStyle:Mt,nodeStyle:U,edgeStyle:K,nodeLabel:ie,showLabels:oe,labelMode:le,colorBy:Z,colorScheme:Q,edgeColorBy:J,edgeOpacity:ee,colorByDepth:te,nodeSize:ne,nodeSizeRange:re,decay:Ie,pulse:$e,transition:mt,introAnimation:xt,staleness:ze,thresholds:Be,orbitMode:He,orbitSize:Xe,orbitSpeed:Ge,orbitRevolution:Ue,orbitRevolutionStyle:Ke,orbitEccentricity:Ze,orbitShowRings:Qe,orbitAnimated:et}),[x,A,M,S,_,T,D,L,O,N,I,$,W,R,z,B,F,j,Y,H,X,At,V,Mt,U,K,ie,oe,le,Z,Q,J,ee,te,ne,re,Ie,$e,null==mt?void 0:mt.duration,null==mt?void 0:mt.easing,xt,ze,Be,He,Xe,Ge,Ue,Ke,Ze,Qe,et]),_t=e.useRef(null),Pt=e.useRef(0),Ct=e.useRef(null);Ct.current||(Ct.current=new Tr(St));const[Tt,Dt]=e.useState(null),[Lt,Ot]=e.useState(0),[Wt,Rt]=e.useState(0),[zt,Bt]=e.useState(!1),Ft=e.useRef(null),Ht=e.useRef(new Map),Xt=e.useRef(0),Gt=e.useCallback(e=>{if("function"==typeof Z)return Z(e)+"";if("string"==typeof Z&&e.data){const t=e.data[Z];if(void 0!==t){if(!Ht.current.has(t+"")){const e=Array.isArray(Q)?Q:P;Ht.current.set(t+"",e[Xt.current++%e.length])}return Ht.current.get(t+"")}}if(Ht.current.has(e.id))return Ht.current.get(e.id);const t=Array.isArray(Q)?Q:P,n=Z?t[Xt.current++%t.length]:t[0];return Ht.current.set(e.id,n),n},[Z,Q]),Vt=e.useCallback(e=>{if("function"==typeof J)return J(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===J&&n?Gt(n):t?Gt(t):"#999"},[J,Gt]),qt=e.useCallback(e=>{if(!(null==q?void 0:q.colorBy))return Vt(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Mt.colorBy&&n?Gt(n):t?Gt(t):"#999"},[null==q?void 0:q.colorBy,Mt.colorBy,Gt,Vt]),Ut="sankey"===x&&V||!!$e||null!==(i=null===(r=Ct.current)||void 0===r?void 0:r.isAnimating)&&void 0!==i&&i;e.useEffect(()=>{var e;null===(e=Ct.current)||void 0===e||e.updateConfig(St),nt.current=!0,Et()},[St,Et]);const Kt=e.useCallback(()=>{var e;const t=Ct.current;if(!t)return;t.runLayout([st,ft]),t.buildScene([st,ft]),nt.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill);const n=Array.isArray(Q)?Q:P,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Ht.current.has(t.id)||Ht.current.set(t.id,n[e%n.length])}if(Xt.current=r.length,Ot(t.layoutVersion),Ee){const{nodes:e,edges:n}=t.getLayoutData();Ee(e,n)}},[st,ft,Ee,Q]),Zt=e.useCallback(e=>{const t=Ct.current;t&&(t.ingestEdge(e)&&Kt(),Et())},[Kt,Et]),Jt=e.useCallback(e=>{const t=Ct.current;if(!t)return;let n=!1;for(const r of e)t.ingestEdge(r)&&(n=!0);n&&Kt(),Et()},[Kt,Et]),en=e.useCallback(()=>{var e;null===(e=Ct.current)||void 0===e||e.clear(),Ht.current.clear(),Xt.current=0,Ot(0),Dt(null),Ft.current=null,nt.current=!0,Et()},[Et]),tn=e.useCallback(()=>{const e=Ct.current;e&&(e.tension+=999,Kt(),Et())},[Kt,Et]);e.useImperativeHandle(n,()=>({push:Zt,pushMany:Jt,removeNode:e=>{var t,n,r;const i=null!==(n=null===(t=Ct.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(i){const t=(null===(r=Ft.current)||void 0===r?void 0:r.data)?"function"==typeof A?A(Ft.current.data):Ft.current.data[A]:void 0;Ft.current&&"node"===Ft.current.nodeOrEdge&&t===e&&(Ft.current=null,Dt(null)),Ht.current.delete(e),Kt(),nt.current=!0,Et()}return i},removeEdge:(e,t)=>{var n,r;const i=null!==(r=null===(n=Ct.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==r&&r;if(i){if(Ft.current&&"edge"===Ft.current.nodeOrEdge){const n=Ft.current.data;let r;r=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!C||!n||("function"==typeof C?C:e=>null==e?void 0:e[C])(n)===e,r&&(Ft.current=null,Dt(null))}Kt(),nt.current=!0,Et()}return i},updateNode:(e,t)=>{var n,r;const i=null!==(r=null===(n=Ct.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==r?r:null;return i&&(nt.current=!0,Et()),i},updateEdge:(e,t,n)=>{var r,i;const o=null!==(i=null===(r=Ct.current)||void 0===r?void 0:r.updateEdge(e,t,n))&&void 0!==i?i:[];return o.length>0&&(Kt(),nt.current=!0,Et()),o},clear:en,getTopology:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ct.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:tn,getTension:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Zt,Jt,en,tn,Kt,Et]);const nn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),rn=nn?w||(Array.isArray(k)?void 0:k):void 0;e.useEffect(()=>{var e;const t=Ct.current;if(t)if(nn&&rn)t.ingestHierarchy(rn,[st,ft]),t.buildScene([st,ft]),nt.current=!0,Et();else{const n=b||[],r=Array.isArray(k)?k:[];if(0===n.length&&0===r.length)return;t.ingestBounded(n,r,[st,ft]),t.buildScene([st,ft]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill+"");const i=Array.isArray(Q)?Q:P,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];Ht.current.has(t.id)||Ht.current.set(t.id,i[e%i.length])}Xt.current=o.length,nt.current=!0,Et()}},[b,k,w,rn,nn,st,ft,St,Et,Q]),e.useEffect(()=>{E&&E.length>0&&Jt(E)},[]);const on=e.useCallback(e=>{if(xe&&xe(e),ke){const t=Date.now();ke(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[xe,ke,we]),ln=e.useCallback(e=>{if(be&&be(e),ke){const t=Date.now();ke(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[be,ke,we]),{hoverHandlerRef:an,hoverLeaveRef:sn,onPointerMove:cn,onPointerLeave:un}=rt;an.current=e=>{if(!ve)return;const t=_t.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-at.left,i=e.clientY-n.top-at.top;if(0>r||r>st||0>i||i>ft)return void(Ft.current&&(Ft.current=null,Dt(null),on&&(on(null),nt.current=!0),Et()));const o=Ct.current;if(!o)return;const l=Lr(o.sceneNodes,o.sceneEdges,r,i);if(!l)return void(Ft.current&&(Ft.current=null,Dt(null),on&&(on(null),nt.current=!0),Et()));const a=Qt(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});Ft.current=a,Dt(a),on&&(on(a),nt.current=!0),Et()},sn.current=()=>{Ft.current&&(Ft.current=null,Dt(null),on&&(on(null),nt.current=!0),Et())};const fn=e.useRef(()=>{});fn.current=e=>{if(!be&&!ke)return;const t=_t.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-at.left,i=e.clientY-n.top-at.top;if(0>r||r>st||0>i||i>ft)return;const o=Ct.current;if(!o)return;const l=Lr(o.sceneNodes,o.sceneEdges,r,i);ln(l?Qt(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)};const yn=e.useCallback(e=>fn.current(e),[]),gn=e.useRef(-1),pn=e.useRef(null),vn=e.useRef(-1),mn=e.useCallback(e=>{var t;const n=Ct.current;if(!n)return;const r=function(e){var t,n,r,i,o,l;const a=[];for(const s of e)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(t=s.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(i=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==i?i:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(o=s.datum)||void 0===o?void 0:o.id)&&void 0!==l?l:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(n.sceneNodes);if(0===r.length)return;const i=ae(r),o=gn.current;if(0>o){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),gn.current=0,vn.current=-1;const t=i.flat[0];pn.current={shape:t.shape,w:t.w,h:t.h};const n=Qt(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Ft.current=n,Dt(n),on&&(on(n),nt.current=!0),void Et()}const l=se(i,o),a=function(e,t,n,r,i){var o,l,a;const s=n.flat[t.flatIndex];if(!s)return ce(e,t,n);const c=null===(o=s.datum)||void 0===o?void 0:o.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(e,t,n){let r=null,i=1/0;for(let o=0;e.flat.length>o;o++){const l=e.flat[o];if(l===t)continue;const a=l.x-t.x,s=l.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;i>u&&(i=u,r=o)}return r}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==l?l:t.flatIndex;return r!==t.flatIndex&&(i.current=-1),r}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n,r,i;const o=e+"",l=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,a="object"==typeof t.source?null===(r=t.source)||void 0===r?void 0:r.id:t.source,s="object"==typeof t.target?null===(i=t.target)||void 0===i?void 0:i.id:t.target,c=null!=a,u=null!=s;c&&a+""===o&&u?l.push(s+""):u&&s+""===o&&c&&l.push(a+"")}return l}(c,r);if(0===e.length)return t.flatIndex;const o=null!==(a=n.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>o?t.flatIndex:(i.current=-1,o)}default:{const r=ce(e,t,n);return null!==r&&r!==t.flatIndex&&(i.current=-1),r}}}(e.key,l,i,null!==(t=n.sceneEdges)&&void 0!==t?t:[],vn);if(null===a)return;if(e.preventDefault(),0>a)return gn.current=-1,pn.current=null,vn.current=-1,Ft.current=null,Dt(null),on&&(on(null),nt.current=!0),void Et();gn.current=a;const s=i.flat[a];pn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:s.x,y:s.y,time:s.x,value:s.y,nodeOrEdge:"node"});Ft.current=u,Dt(u),on&&(on(u),nt.current=!0),Et()},[on,Et]),xn=e.useCallback(e=>{gn.current=-1,pn.current=null,cn(e)},[cn]);wt.current=()=>{var e,t,n,r,i,o,l;kt.current=0;const a=_t.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=Ct.current;if(!c)return;const u=performance.now(),d=Pt.current?Math.min((u-Pt.current)/1e3,.1):.016;Pt.current=u;const h=c.advanceTransition(it.current?u+1e6:u),f=!it.current&&h,y=!it.current&&c.tickAnimation([st,ft],d);(h||nt.current||y)&&c.buildScene([st,ft]);const g=$t();if(!It(a,lt,at,g))return;s.clearRect(-at.left,-at.top,lt[0],lt[1]),pe&&(s.fillStyle=pe,s.fillRect(0,0,st,ft)),Ie&&c.applyDecay(),$e&&c.applyPulse(u),Be&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,v=ze&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Fr(e,n);break;case"line":jr(e,n);break;case"ribbon":Yr(e,n);break;case"curved":Hr(e,n)}}(s,c.sceneEdges),function(e,t){var n,r,i;for(const o of t){if("rect"!==o.type)continue;const t=o;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),jt(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,i;for(const o of t){if("circle"!==o.type)continue;const t=o;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),Yt(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,i;for(const o of t){if("arc"!==o.type)continue;const t=o;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),e.restore()}}(s,c.sceneNodes),V&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,r){var i,o;const l=null!==(i=r.spawnRate)&&void 0!==i?i:hn.spawnRate,a=null!==(o=r.maxPerEdge)&&void 0!==o?o:hn.maxPerEdge;for(let r=0;t.length>r;r++){const i=t[r];if(!i.bezier)continue;if(e.countForEdge(r)>=a)continue;const o=i.value*l*n*(i.bezier.circular?.3:1),s=Math.floor(o),c=o-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<a;t++)e.spawn(r)}}(c.particlePool,e,d,Mt);const t=.5*(null!==(n=Mt.speedMultiplier)&&void 0!==n?n:1);let r;if(Mt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,r),function(e,t,n,r,i){var o,l;const a=null!==(o=r.radius)&&void 0!==o?o:hn.radius,s=null!==(l=r.opacity)&&void 0!==l?l:hn.opacity;e.globalAlpha=s;for(let o=0;t.particles.length>o;o++){const l=t.particles[o];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?r.color(s,t):"#666"}else e.fillStyle=r.color&&"inherit"!==r.color?r.color:i(s);e.beginPath(),e.arc(l.x,l.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(s,c.particlePool,e,Mt,qt)}}v&&(s.globalAlpha=1);const m=nt.current;if(nt.current=!1,m||f||y){const e=_t.current;e&&e.setAttribute("aria-label",Je(null!==(i=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==i?i:0,null!==(l=null===(o=c.sceneEdges)||void 0===o?void 0:o.length)&&void 0!==l?l:0,"Network chart"))}(m||f||y)&&Rt(e=>e+1),(Ut||f||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(kt.current=requestAnimationFrame(()=>wt.current()))},e.useEffect(()=>(Et(),()=>{}),[Et]),e.useEffect(()=>{nt.current=!0,Et()},[x,st,ft,pe,Et]),he(ze,Ct,nt,Et,zt,Bt);const bn=ve&&Tt?g.createElement(gt,{x:Tt.x,y:Tt.y,containerWidth:st,containerHeight:ft,margin:at,className:"stream-network-tooltip",zIndex:2},me?me(Tt):g.createElement(Kr,{data:Tt})):null;if(qe){const e=Ct.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),n=t?w||(Array.isArray(k)?void 0:k):void 0;if(t&&n)e.ingestHierarchy(n,[st,ft]),e.buildScene([st,ft]);else{const t=b||[],n=Array.isArray(k)?k:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[st,ft]),e.buildScene([st,ft]))}}const t=null!==(o=null==e?void 0:e.sceneNodes)&&void 0!==o?o:[],n=null!==(l=null==e?void 0:e.sceneEdges)&&void 0!==l?l:[],r=null!==(a=null==e?void 0:e.labels)&&void 0!==a?a:[];return g.createElement("div",{className:"stream-network-frame"+(ge?" "+ge:""),role:"img","aria-label":je||("string"==typeof Le?Le:"Network chart"),style:{position:"relative",width:lt[0],height:lt[1]}},g.createElement(ut,{summary:Ye}),g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:lt[0],height:lt[1],style:{position:"absolute",left:0,top:0}},vt&&g.createElement("g",{transform:`translate(${at.left},${at.top})`},vt),g.createElement("g",{transform:`translate(${at.left},${at.top})`},pe&&g.createElement("rect",{x:0,y:0,width:st,height:ft,fill:pe}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return g.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:Ve(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:Ve(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=e;return g.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:Ve(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return g.createElement("circle",{key:"net-circle-"+t,cx:n.cx,cy:n.cy,r:n.r,fill:Ve(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=e;return g.createElement("rect",{key:"net-rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:Ve(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=e,r=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return g.createElement("path",{key:"net-arc-"+t,d:r,transform:`translate(${n.cx},${n.cy})`,fill:Ve(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),r.map((e,t)=>function(e,t){return g.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),g.createElement(zr,{width:st,height:ft,totalWidth:lt[0],totalHeight:lt[1],margin:at,labels:r,sceneNodes:t,title:Le,legend:Se,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Ce,legendHighlightedCategory:Te,legendIsolatedCategories:De,foregroundGraphics:pt,annotations:Ae,svgAnnotationRules:Me,annotationFrame:0}))}const kn=Ct.current;return g.createElement("div",{ref:ot,className:"stream-network-frame"+(ge?" "+ge:""),role:"group","aria-label":je||("string"==typeof Le?Le:"Network chart"),tabIndex:0,style:{position:"relative",width:de?"100%":lt[0],height:fe?"100%":lt[1],overflow:"visible"},onKeyDown:mn},Fe&&g.createElement(dt,{tableId:bt}),Fe&&g.createElement(ct,{nodes:null!==(c=null==kn?void 0:kn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==kn?void 0:kn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:bt,chartTitle:"string"==typeof Le?Le:void 0}),g.createElement(ut,{summary:Ye}),g.createElement("div",{role:"img","aria-label":je||("string"==typeof Le?Le:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ve?xn:void 0,onMouseLeave:ve?un:void 0,onClick:be||ke?yn:void 0},vt&&g.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:lt[0],height:lt[1],pointerEvents:"none",overflow:"visible"}},g.createElement("g",{transform:`translate(${at.left},${at.top})`},vt)),g.createElement("canvas",{ref:_t,"aria-label":Je(null!==(h=null===(d=null==kn?void 0:kn.sceneNodes)||void 0===d?void 0:d.length)&&void 0!==h?h:0,null!==(y=null===(f=null==kn?void 0:kn.sceneEdges)||void 0===f?void 0:f.length)&&void 0!==y?y:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(ht,{hoverPoint:Tt}),g.createElement(zr,{width:st,height:ft,totalWidth:lt[0],totalHeight:lt[1],margin:at,labels:(null==kn?void 0:kn.labels)||[],sceneNodes:null==kn?void 0:kn.sceneNodes,title:Le,legend:Se,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Ce,legendHighlightedCategory:Te,legendIsolatedCategories:De,foregroundGraphics:pt,annotations:Ae,svgAnnotationRules:Me,annotationFrame:Wt}),g.createElement(yt,{active:gn.current>=0,hoverPoint:Tt,margin:at,size:lt,shape:null===(p=pn.current)||void 0===p?void 0:p.shape,width:null===(v=pn.current)||void 0===v?void 0:v.w,height:null===(m=pn.current)||void 0===m?void 0:m.h}),bn,(null==ze?void 0:ze.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ze.badgePosition?{top:4,left:4}:"bottom-left"===ze.badgePosition?{bottom:4,left:4}:"bottom-right"===ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:zt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},zt?"STALE":"LIVE")))});function Qr(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,i]=r.range;t.push(t=>{const r=t[n];return r>=e&&i>=r})}return e=>t.every(t=>t(e))}function Jr(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}Zr.displayName="StreamNetworkFrame";const[ei,ti]=pt(e=>({selections:new Map,setClause(t,n){e(e=>{const r=new Map(e.selections),i=Jr(r,t),o=new Map(i.clauses);return o.set(n.clientId,n),r.set(t,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r)return{};const i=new Map(e.selections),o=new Map(r.clauses);return o.delete(n),i.set(t,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},setResolution(t,n){e(e=>{const r=new Map(e.selections),i=Jr(r,t);return r.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:r}})},clearSelection(t){e(e=>{const n=new Map(e.selections),r=n.get(t);return r&&n.set(t,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[ni,ri]=pt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function ii(t){const n=e.useId(),r=t.clientId||n,{name:i}=t,o=ti(e=>e.selections.get(i)),l=ti(e=>e.setClause),a=ti(e=>e.clearClause),s=e.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:e.useMemo(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,i]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Qr(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,r):()=>!0,[o,r]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};l(i,{clientId:r,type:"point",fields:t})},[r,i,l]),selectInterval:e.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r};l(i,{clientId:r,type:"interval",fields:t})},[r,i,l]),clear:e.useCallback(()=>{a(i,r)},[a,i,r]),clientId:r}}function oi({selection:t,linkedHover:n,fallbackFields:r=[],unwrapData:i=!1,onObservation:o,chartType:l,chartId:a,onClick:s,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,r),f=ii({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const n=t.name||"hover",{fields:r}=t,{predicate:i,isActive:o,selectPoints:l,clear:a}=ii({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&l(t)},[r,l,a,n]),predicate:i,isActive:o}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||r||[]}),g=ri(e=>e.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=e.useState(null),x=u||r[0],b=e.useMemo(()=>{if(!c||null==v||!x)return null;const e=v,t=x;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[t]?n[t]:(null!==(r=n[t])&&void 0!==r?r:"")+"")===e}}},[c,v,x]),k=e.useCallback(e=>{var t,r;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const r=De.positions.get(e);(null==r?void 0:r.locked)||r&&r.xValue===t&&r.sourceId===n||(De={positions:new Map(De.positions).set(e,{xValue:t,sourceId:n})},Oe())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Ne(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];m(null!=n?n+"":null)}else m(null);if(o||g){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(l),g&&g(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(e),g&&g(e)}}},[n,y,h,d,o,l,a,g,c,x]),w=e.useCallback(e=>{var t,n,r,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const r=De.positions.get(e);if(null==r?void 0:r.locked){const t=new Map(De.positions);return t.delete(e),De={positions:t},Oe(),!1}De={positions:new Map(De.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Oe()}(h.name||"hover",Number(n),d)}if(e&&s){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]),s(r,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(o||g){const t={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(i=e.y)&&void 0!==i?i:0});o&&o(l),g&&g(l)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});o&&o(e),g&&g(e)}}},[s,o,g,l,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ie(e,d),Ne(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}const li={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function ai(e,t,n){var r,i,o,l,a,s,c;const u=li[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(r=t.width)&&void 0!==r?r:u.width,height:null!==(i=t.height)&&void 0!==i?i:u.height,showAxes:null!==(o=t.showAxes)&&void 0!==o?o:u.showAxes,showGrid:null!==(l=t.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:si(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function si(e,t,n){if(!1!==t)return e;const r=Object.assign({},e);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const ci={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},ui={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function di(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?g.createElement("div",{style:Object.assign(Object.assign({},ci),{width:t,height:n})},r||"No data available"):null}function hi(e,t,n){if(!e)return null;const r=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*r))),o=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(i+o)-o))/2);return g.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(e,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ui),{position:"absolute",top:l+n*(i+o),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})})))}const fi=e.forwardRef(function(t,n){var r,i,o,l;const a=ai(t.mode,{width:null!==(i=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==i?i:t.width,height:null!==(l=null===(o=t.size)||void 0===o?void 0:o[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:_,annotations:P,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:I,linkedHover:$,selection:W,onObservation:R,chartId:z,loading:B,emptyContent:F,emphasis:j,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=M?M:S,U=e.useRef(null),{customHoverBehavior:K}=oi({selection:W,linkedHover:$,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:z}),Z=e.useCallback(e=>{_&&_(e),K(e)},[_,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Q=hi(B,V[0],V[1]),J=Q?null:di(y,V[0],V[1],F),ee={stroke:k,strokeWidth:w,strokeDasharray:E};return Q||J||g.createElement(un,{ref:U,chartType:"line",runtimeMode:"streaming",size:V,margin:G,className:j?`${u||""} semiotic-emphasis-${j}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:ee,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:P,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:I,pointIdAccessor:t.pointIdAccessor,legendPosition:Y})});fi.displayName="RealtimeLineChart";const yi=e.forwardRef(function(t,n){var r,i,o,l;const a=ai(t.mode,{width:null!==(i=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==i?i:t.width,height:null!==(l=null===(o=t.size)||void 0===o?void 0:o[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:s,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:_,background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,linkedHover:$,selection:W,decay:R,pulse:z,staleness:B,transition:F,onObservation:j,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:V,brush:q,onBrush:U,linkedBrush:K}=t,Z=a.showAxes,Q=a.enableHover,J=null!=u?u:a.marginDefaults,ee=null!=c?c:[a.width,a.height],te=null!=C?C:T,ne=e.useRef(null),{customHoverBehavior:re}=oi({selection:W,linkedHover:$,unwrapData:!0,onObservation:j,chartType:"RealtimeTemporalHistogram",chartId:Y}),ie=e.useCallback(e=>{D&&D(e),re(e)},[D,re]),oe=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,le=(ae=K)?"string"==typeof ae?{name:ae}:ae:null;var ae;const se=function(t){const{name:n,xField:r,yField:i}=t,{predicate:o,isActive:l,selectInterval:a,clear:s}=ii({name:n}),c=r&&i?"xyBrush":r?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void s();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(r&&(t[r]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?r&&(t[r]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,r,i,a,s]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:o,isActive:l,clear:s}}(Object.assign({name:(null==le?void 0:le.name)||"__unused_hist_brush__",xField:(null==le?void 0:le.xField)||("string"==typeof v?v:"time")},(null==le?void 0:le.yField)?{yField:le.yField}:{})),ce=e.useRef(se.brushInteraction);ce.current=se.brushInteraction;const ue=e.useCallback(e=>{if(U&&U(e),j&&j(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),le){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,j,Y,le]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=ne.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const de=hi(H,ee[0],ee[1]),he=de?null:di(p,ee[0],ee[1],X),fe={};return null!=A&&(fe.fill=A),null!=M&&(fe.stroke=M),null!=S&&(fe.strokeWidth=S),null!=_&&(fe.gap=_),de||he||g.createElement(un,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:J,className:G?`${d||""} semiotic-emphasis-${G}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:fe,showAxes:Z,background:P,hoverAnnotation:Q,tooltipContent:te,customHoverBehavior:ie,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,decay:R,pulse:z,staleness:B,transition:F,pointIdAccessor:t.pointIdAccessor,legendPosition:V,brush:oe||(K?{dimension:"x"}:void 0),onBrush:oe||K?ue:void 0})});yi.displayName="RealtimeTemporalHistogram";const gi=yi,pi=e.forwardRef(function(t,n){var r,i,o,l;const a=ai(t.mode,{width:null!==(i=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==i?i:t.width,height:null!==(l=null===(o=t.size)||void 0===o?void 0:o[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:_,background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,linkedHover:$,selection:W,onObservation:R,chartId:z,loading:B,emptyContent:F,emphasis:j,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:T,U=e.useRef(null),{customHoverBehavior:K}=oi({selection:W,linkedHover:$,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:z}),Z=e.useCallback(e=>{D&&D(e),K(e)},[D,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Q=hi(B,V[0],V[1]),J=Q?null:di(y,V[0],V[1],F),ee={};return null!=E&&(ee.radius=E),null!=A&&(ee.fill=A),null!=M&&(ee.opacity=M),null!=S&&(ee.stroke=S),null!=_&&(ee.strokeWidth=_),Q||J||g.createElement(un,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:j?`${u||""} semiotic-emphasis-${j}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});pi.displayName="RealtimeSwarmChart";const vi=e.forwardRef(function(t,n){var r,i,o,l;const a=ai(t.mode,{width:null!==(i=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==i?i:t.width,height:null!==(l=null===(o=t.size)||void 0===o?void 0:o[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:_,background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,linkedHover:$,selection:W,onObservation:R,chartId:z,loading:B,emptyContent:F,emphasis:j,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=C?C:T,U=e.useRef(null),{customHoverBehavior:K}=oi({selection:W,linkedHover:$,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:z}),Z=e.useCallback(e=>{D&&D(e),K(e)},[D,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Q=hi(B,V[0],V[1]),J=Q?null:di(y,V[0],V[1],F),ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=E&&(ee.connectorStroke=E),null!=A&&(ee.connectorWidth=A),null!=M&&(ee.gap=M),null!=S&&(ee.stroke=S),null!=_&&(ee.strokeWidth=_),Q||J||g.createElement(un,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:G,className:j?`${u||""} semiotic-emphasis-${j}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:ee,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:I,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});vi.displayName="RealtimeWaterfallChart";const mi=e.forwardRef(function(t,n){var r,i,o,l;const a=ai(t.mode,{width:null!==(i=null===(r=t.size)||void 0===r?void 0:r[0])&&void 0!==i?i:t.width,height:null!==(l=null===(o=t.size)||void 0===o?void 0:o[1])&&void 0!==l?l:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:_,onHover:P,annotations:C,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:L,decay:O,pulse:N,staleness:I,linkedHover:$,selection:W,onObservation:R,chartId:z,loading:B,emptyContent:F,emphasis:j,legendPosition:Y}=t,H=a.showAxes,X=a.enableHover,G=null!=c?c:a.marginDefaults,V=null!=s?s:[a.width,a.height],q=null!=S?S:_,U=e.useRef(null),{customHoverBehavior:K}=oi({selection:W,linkedHover:$,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:z}),Z=e.useCallback(e=>{P&&P(e),K(e)},[P,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Q=hi(B,V[0],V[1]),J=Q?null:di(y,V[0],V[1],F);return Q||J||g.createElement(un,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:j?`${u||""} semiotic-emphasis-${j}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:T,tickFormatTime:D,tickFormatValue:L,decay:O,pulse:N,staleness:I,legendPosition:Y,pointIdAccessor:t.pointIdAccessor})});mi.displayName="RealtimeHeatmap",exports.IncrementalExtent=w,exports.RealtimeHeatmap=mi,exports.RealtimeHistogram=gi,exports.RealtimeLineChart=fi,exports.RealtimeSwarmChart=pi,exports.RealtimeWaterfallChart=vi,exports.RingBuffer=k,exports.StreamNetworkFrame=Zr,exports.StreamXYFrame=un;
|