semiotic 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +16 -3
- package/ai/schema.json +42 -1
- package/ai/system-prompt.md +4 -0
- package/dist/components/Annotation.d.ts +42 -2
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartGrid.d.ts +1 -1
- package/dist/components/ContextLayout.d.ts +1 -1
- package/dist/components/DataSummaryContext.d.ts +1 -1
- package/dist/components/DetailsPanel.d.ts +3 -2
- package/dist/components/Legend.d.ts +2 -3
- package/dist/components/LinkedCharts.d.ts +1 -1
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
- package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
- package/dist/components/charts/geo/FlowMap.d.ts +4 -4
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
- package/dist/components/charts/index.d.ts +2 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
- package/dist/components/charts/network/CirclePack.d.ts +3 -3
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
- package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
- package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
- package/dist/components/charts/network/Treemap.d.ts +3 -3
- package/dist/components/charts/ordinal/BarChart.d.ts +24 -4
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
- package/dist/components/charts/ordinal/DotPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
- package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -3
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
- package/dist/components/charts/ordinal/LikertChart.d.ts +4 -3
- package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -3
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
- package/dist/components/charts/shared/ChartError.d.ts +1 -2
- package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/colorUtils.d.ts +4 -3
- package/dist/components/charts/shared/datumTypes.d.ts +20 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
- package/dist/components/charts/shared/formatUtils.d.ts +4 -2
- package/dist/components/charts/shared/hooks.d.ts +27 -23
- package/dist/components/charts/shared/legendUtils.d.ts +3 -2
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
- package/dist/components/charts/shared/networkUtils.d.ts +7 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -4
- package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
- package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
- package/dist/components/charts/shared/tooltipUtils.d.ts +7 -6
- package/dist/components/charts/shared/types.d.ts +22 -13
- package/dist/components/charts/shared/useChartSetup.d.ts +7 -6
- package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
- package/dist/components/charts/shared/validateChartData.d.ts +2 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -8
- package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +4 -3
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
- package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
- package/dist/components/charts/xy/Heatmap.d.ts +12 -7
- package/dist/components/charts/xy/LineChart.d.ts +4 -3
- package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
- package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
- package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
- package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
- package/dist/components/data/transforms.d.ts +8 -7
- package/dist/components/export/chartConfig.d.ts +4 -3
- package/dist/components/geo/mergeData.d.ts +2 -1
- package/dist/components/realtime/BinAccumulator.d.ts +3 -2
- package/dist/components/realtime/renderers/types.d.ts +2 -1
- package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
- package/dist/components/realtime/types.d.ts +20 -16
- package/dist/components/semiotic-themes.d.ts +2 -1
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/animatedGif.d.ts +4 -18
- package/dist/components/server/renderToStaticSVG.d.ts +5 -4
- package/dist/components/server/serverChartConfigs.d.ts +2 -10
- package/dist/components/server/staticAnnotations.d.ts +2 -1
- package/dist/components/server/staticLegend.d.ts +2 -1
- package/dist/components/store/ObservationStore.d.ts +4 -3
- package/dist/components/store/SelectionStore.d.ts +3 -8
- package/dist/components/store/ThemeStore.d.ts +32 -4
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/useSelection.d.ts +6 -5
- package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
- package/dist/components/stream/CanvasHitTester.d.ts +2 -1
- package/dist/components/stream/DataSourceAdapter.d.ts +2 -1
- package/dist/components/stream/FocusRing.d.ts +1 -2
- package/dist/components/stream/GeoParticlePool.d.ts +2 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +7 -6
- package/dist/components/stream/MarginalGraphics.d.ts +1 -2
- package/dist/components/stream/NetworkPipelineStore.d.ts +3 -2
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -4
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
- package/dist/components/stream/OrdinalPipelineStore.d.ts +6 -5
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
- package/dist/components/stream/PipelineStore.d.ts +63 -28
- package/dist/components/stream/SVGOverlay.d.ts +10 -10
- package/dist/components/stream/SceneGraph.d.ts +6 -5
- package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
- package/dist/components/stream/StreamXYFrame.d.ts +2 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
- package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
- package/dist/components/stream/geoTypes.d.ts +25 -18
- package/dist/components/stream/hoverUtils.d.ts +2 -1
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
- package/dist/components/stream/networkTypes.d.ts +33 -28
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
- package/dist/components/stream/ordinalTypes.d.ts +54 -22
- package/dist/components/stream/pipelineDecay.d.ts +2 -1
- package/dist/components/stream/pipelinePulse.d.ts +2 -1
- package/dist/components/stream/pipelineTransitions.d.ts +16 -4
- package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
- package/dist/components/stream/types.d.ts +45 -8
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
- package/dist/components/types/marginType.d.ts +15 -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-statisticalOverlays-Ckd_jM8z.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -1
- 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 +2 -0
- package/dist/semiotic.d.ts +3 -3
- 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 +10 -2
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +38 -31
- package/dist/components/types/annotationTypes.d.ts +0 -145
- package/dist/components/types/generalTypes.d.ts +0 -241
- package/dist/components/types/interactionTypes.d.ts +0 -72
- package/dist/components/types/networkTypes.d.ts +0 -174
- package/dist/components/types/ordinalTypes.d.ts +0 -112
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
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"),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;
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("d3-selection"),i=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-scale-chromatic"),l=require("d3-array"),a=require("d3-hierarchy"),c=require("d3-shape"),u=require("regression"),d=require("d3-interpolate"),h=require("d3-force"),f=require("d3-chord");function g(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const p=y(e),v=g(u);function m(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function x(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function b({width:o,height:r,totalWidth:s,totalHeight:l,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:y,streaming:p}){const v=e.useRef(null),b=e.useRef(null),k=e.useRef(d);k.current=d;const w=e.useRef(u);w.current=u;const A=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),S=e.useRef(A);S.current=A;const M=e.useRef(!1),_=e.useRef(null);return e.useEffect(()=>{if(!v.current)return;const t=n.select(v.current).select(".brush-g"),e="x"===c?i.brushX():"y"===c?i.brushY():i.brush();return e.extent([[0,0],[o,r]]),e.on("brush end",n=>{if(M.current)return;const i=w.current;if(!i)return;if(!n.selection)return _.current=null,void k.current(null);let s,l;if("x"===c){const[t,e]=n.selection;s=[i.x.invert(t),i.x.invert(e)],l=[i.y.invert(r),i.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;s=[i.x.invert(0),i.x.invert(o)],l=[i.y.invert(e),i.y.invert(t)]}else{const[[t,e],[o,r]]=n.selection;s=[i.x.invert(t),i.x.invert(o)],l=[i.y.invert(r),i.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===n.type||"brush"===n.type&&y)){const o=S.current;o&&o.length>0?s=function(t,e){return 0===e.length?t:[m(t[0],e),x(t[1],e)]}(s,o):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=i.x(s[0]),l=i.x(s[1]);if(M.current=!0,"x"===c)t.call(e.move,[r,l]);else if("xy"===c){const i=n.selection;t.call(e.move,[[r,i[0][1]],[l,i[1][1]]])}M.current=!1}const a={x:s,y:l};_.current=a,k.current(a)}),t.call(e),b.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),b.current=null}},[o,r,c,f,h,y]),e.useEffect(()=>{if(!(p&&u&&b.current&&_.current))return;if(!v.current)return;if("y"===c)return;const t=_.current,e=u.x.domain()[0],i=n.select(v.current).select(".brush-g");if(e>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);let o=t.x[0],r=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=S.current;t&&t.length>0?o=x(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return M.current=!0,i.call(b.current.move,null),M.current=!1,_.current=null,void k.current(null);r=!0}const s=u.x(o),l=u.x(t.x[1]);if(M.current=!0,"x"===c)i.call(b.current.move,[s,l]);else{const e=u.y(t.y[1]),n=u.y(t.y[0]);i.call(b.current.move,[[s,e],[l,n]])}if(M.current=!1,r){const e={x:[o,t.x[1]],y:t.y};_.current=e,k.current(e)}},[u,p,c,f,h]),t.jsx("svg",{ref:v,width:s,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class k{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function w(n){const i=e.createContext(null),o=A(n);return[function({children:o}){const r=e.useMemo(()=>A(n),[]);return t.jsx(i.Provider,{value:r,children:o})},t=>{var n;const r=null!==(n=e.useContext(i))&&void 0!==n?n:o,s=e.useRef(t);s.current=t;const l=e.useCallback(()=>s.current(r.getState()),[r]),a=e.useCallback(()=>s.current(r.getState()),[r]);return e.useSyncExternalStore(r.subscribe,l,a)}]}function A(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}function S(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function M(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:_})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const _=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],j={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},P={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},C={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:_,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},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"},[E,T]=w(t=>({theme:j,setTheme(e){t(t=>{if("light"===e)return{theme:j};if("dark"===e)return{theme:P};if("high-contrast"===e)return{theme:C};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?P:j;return{theme:M(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}}return{theme:M(Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})}))}})}}));class D{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);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 L{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 O(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),l=n(s);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=l,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+l)}}return r}function N(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function $(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function I(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function W(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const R=s.schemeCategory10,z=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Y(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,l=n-1-e;switch(t.type){case"linear":return s+(1-l/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return s+Math.pow(.5,l/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>l?1:s;default:return 1}}function B(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function F(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function H(t,e){return Math.min((t-e.startTime)/e.duration,1)}function X(t,e,n){return t+(e-t)*n}function G(t,e,n){var i,o,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function V(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}s.sort((t,e)=>t.px-e.px);const l=Array(s.length),a=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];l[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:a,style:o,datum:c,group:r}}function q(t,e,n,i,o,r,s,l){const a=[];for(const r of t){const t=n(r),s=i(r);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=e.x(t),u=l?l(r):o;a.push({px:c,topY:e.y(s),botY:e.y(u)})}a.sort((t,e)=>t.px-e.px);const c=Array(a.length),u=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function U(t,e,n,i,o,r,s){const l=n(t),a=i(t);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:e.x(l),y:e.y(a),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function K(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function Z(t,e,n,i,o,r,s){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(l.showValues=!0,l.value=s.value,s.valueFormat&&(l.valueFormat=s.valueFormat)),l}function Q(t,e,n){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const s=t.getBounds(n),l=t.scales.x(e);if(s&&0!==s)i.push([l,t.scales.y(r+s)]),o.push([l,t.scales.y(r-s)]);else{const e=t.scales.y(r);i.push([l,e]),o.push([l,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function J(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const l=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(s)+"":void 0,c=U(s,t.scales,t.getX,r,l,i,a);c&&n.push(c)}}}const tt={blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo},et=new Map;class nt{constructor(t){if(this.xExtent=new L,this.yExtent=new L,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._groupColorCounter=0,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=t,this.buffer=new D(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=$(t.timeAccessor||t.xAccessor,"time"),this.getY=$(t.valueAccessor||t.yAccessor,"value")):(this.getX=$(t.xAccessor,"x"),this.getY=$(t.yAccessor,"y")),this.getGroup=W(t.groupAccessor),this.getCategory=W(t.categoryAccessor),this.getSize=t.sizeAccessor?$(t.sizeAccessor,"size"):void 0,this.getColor=W(t.colorAccessor),this.getBounds=t.boundsAccessor?$(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?$(t.y0Accessor,"y0"):void 0,this.getPointId=W(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?$(t.openAccessor,"open"):void 0,this.getHigh=$(t.highAccessor,"high"),this.getLow=$(t.lowAccessor,"low"),this.getClose=n?$(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new D(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.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?$(this.config.timeAccessor||this.config.xAccessor,"time"):$(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),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 t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),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!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,i,r,s,l,a;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);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 t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,f=this.yExtent.extent;let g=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,y=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:f[0],null!==(s=c.yExtent[1])&&void 0!==s?s: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)y=[0,1+c.extentPadding];else{const t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(d),n=new Map;let i=0;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const r=(n.get(t)||0)+o;n.set(t,r),r>i&&(i=r)}y=[0,i+(i>0?i*c.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===c.chartType&&c.binSize&&!p&&u.size>0){const[,t]=function(t,e,n,i,o){const r=O(t,e,n,i,o);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);y=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!p&&u.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(u,this.getY),n=e-t,i=n>0?n*c.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!p&&y[0]!==1/0){if(this.getBounds)for(const t of d){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*c.extentPadding:1,n=null===(l=c.yExtent)||void 0===l?void 0:l[0],i=null===(a=c.yExtent)||void 0===a?void 0:a[1];y=[null!=n?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===c.yScaleType&&0>=y[0]&&f[0]>0&&(y[0]=null!=n?y[0]:f[0]/(1+c.extentPadding))}if(g[0]===1/0||g[1]===-1/0)if("time"===c.xScaleType){const t=Date.now();g=[t-864e5,t]}else g=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(x=c.arrowOfTime)||"down"===x?"y":"x")){const e="right"===c.arrowOfTime?[m,t.width-m]:[t.width-m,m];this.scales={x:o.scaleLinear().domain(g).range(e),y:o.scaleLinear().domain(y).range([t.height-m,m])}}else{const e="down"===c.arrowOfTime?[m,t.height-m]:[t.height-m,m];this.scales={x:o.scaleLinear().domain(y).range([m,t.width-m]),y:o.scaleLinear().domain(g).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(c.xScaleType,g,[m,t.width-m]),y:e(c.yScaleType,y,[t.height-m,m])}}var x;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,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:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,nt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=l[1]>l[0];this.scales={x:a(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:i,scales:o}=this;if(!o||0===e.length)return[];const r={scales:o,config:i,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:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const n=Q(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=V(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return J(t,i,o),o}(r,e);case"area":return function(t,e){const n=t.groupData(e),i=[],o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=q(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return J(t,n,i),i}(r,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set,r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=q(e.data,t.scales,t.getX,t.getY,r,n,e.key,s);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=V(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return J(t,n,i),i}(r,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:r}=function(t,e,n,i,o,r,s){var l;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const c=Array.from(a).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let d;if(r){d=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(l=u.get(i.key))||void 0===l?void 0:l.get(e))||0;d.set(e,n||1)}}const h=[],f=new Map,g=new Map;for(const t of c)g.set(t,0);for(const n of t){const t=u.get(n.key),i=[],l=[],a=new Map;for(const n of c){let o=t.get(n)||0;const s=g.get(n);r&&(o/=d.get(n));const c=s+o,u=e.x(n);l.push([u,e.y(s)]),i.push([u,e.y(c)]),g.set(n,c),a.set(n,c)}f.set(n.key,a);const y={type:"area",topPath:i,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(y.curve=s),h.push(y)}return{nodes:h,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,i),s=o;if(t.config.pointStyle){const e=new WeakMap;for(const i of n){const n=r.get(i.key);if(n)for(const o of i.data){const i=t.getX(o),r=t.getY(o);null==i||Number.isNaN(i)||null==r||Number.isNaN(r)||!n.has(i)||e.set(o,n.get(i))}}const i=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};J(t,n,s,i)}return s}(r,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const l=t.getColor?t.resolveColorMap(e):null,a=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(l&&t.getColor&&!e.fill){const i=t.getColor(n);i&&l.has(i)&&(e=Object.assign(Object.assign({},e),{fill:l.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=U(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(r,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),l=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),a=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=$(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/l,p=s*l;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const a=Math.min(Math.floor((o-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),l-1);if(0>a||0>d)continue;const f=d*s+a;v[f]++;const p=c(i);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(a){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/s,A=n.height/l,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;l>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===v[i])continue;let o;switch(a){case"sum":o=m[i];break;case"mean":o=m[i]/v[i];break;default:o=v[i]}const r=(o-x)/k;_.push(Z(n*w,(l-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:v[i],sum:m[i]},S?{value:o,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const i=$(t.config.valueAccessor,"value"),o=I(t.config.xAccessor,"x"),r=I(t.config.yAccessor,"y"),l=new Map,a=new Map,c=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),s=r(n);c[t]=i,u[t]=s,l.has(i)||l.set(i,l.size),a.has(s)||a.set(s,a.size)}const d=l.size,h=a.size;if(0===d||0===h)return[];const f=Array.from(l.keys()),g=Array.from(a.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),l.clear();for(let t=0;f.length>t;t++)l.set(f[t],t)}if(p){g.sort((t,e)=>t-e),a.clear();for(let t=0;g.length>t;t++)a.set(g[t],t)}const v=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let k=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(c[t]),r=a.get(u[t]);if(void 0===o||void 0===r)continue;const s=i(n),h=r*d+o,f=b.get(h);let g;void 0!==f?g=f:(g=k++,b.set(h,g)),v[g]=h,m[g]=s,x[g]=n}let w=1/0,A=-1/0;for(let t=0;k>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>A&&(A=e))}if(!isFinite(w)||!isFinite(A))return[];const S=function(t){const e=t in tt?t:"blues";let n=et.get(e);if(n)return n;n=Array(256);const i=tt[e]||s.interpolateBlues;for(let t=0;256>t;t++)n[t]=i(t/255);return et.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),M=255/(A-w||1),_=n.width/d,j=n.height/h,P=t.config.showValues,C=t.config.heatmapValueFormat,E=[];for(let t=0;k>t;t++){const e=m[t];if(!isFinite(e))continue;const n=v[t],i=n%d;E.push(Z(i*_,(h-1-(n-i)/d)*j,_,j,S[Math.min((e-w)*M+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return E}(r,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=O(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.has(t)).sort(),l=n.filter(t=>e.has(t)),a=l.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...l,...s],t.barCategoryCache={key:a,order:r})}const s=[],l=t.scales,[a,c]=l.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,a),o=Math.min(e.end,c);if(n>=o)continue;const h=l.x(n),y=l.x(o),p=Math.abs(y-h),v=p>f+1?f:0,m=Math.min(h,y)+v/2,x=Math.max(p-v,1);if(x>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const a=l.y(n),c=l.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(K(m,Math.min(a,c),x,Math.abs(a-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=l.y(0),n=l.y(e.total);s.push(K(m,Math.min(t,n),x,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of o.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(r,e);return this._barCategoryCache=null!==(n=r.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,l;const a=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(l=t.config.barColors)||void 0===l?void 0:l[e])||s}const c={type:"point",x:o,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),a.push(c)}return a}(r,e);case"waterfall":return function(t,e,n){var i,o,r,s,l,a,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",y=null!==(a=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(l=t.config.themeSemantic)||void 0===l?void 0:l.danger)&&void 0!==a?a:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=b+r;let l;l=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const a=d.x(o),c=0!==l?d.x(o+l):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=s;continue}const A=d.y(b),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),j={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(j.opacity=x),u.push(K(k,M,w,_,j,Object.assign(Object.assign({},i),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=s}return u}(r,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},l=s.rangeColor||"#6366f1",a=o?l:s.upColor||"#28a745",c=o?l:s.downColor||"#dc3545",u=o?l:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const l=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[l,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=l,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(l),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:a,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(y.isRange=!0),r.push(y)}return r}(r,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Y(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const l=s.get(e[n]);null!=l?(i[n]=Y(t,l,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let l=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=Y(t,i,r),1>o[n]&&(l=!0)):o[n]=1}l&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=Y(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const l=Y(t,e,r);if("heatcell"===n.type)n.style={opacity:l};else if("candlestick"===n.type)n._decayOpacity=l;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*l})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",a=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const l=B(t,r,s);l>o&&(o=l)}o>0&&(n._pulseIntensity=o,n._pulseColor=l);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=B(t,o,s);r>0&&(n._pulseIntensity=r,n._pulseColor=l,n._pulseGlowRadius=a)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,s,l;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=G(t,c,a);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=c.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=G(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M,_,j,P,C,E,T,D,L,O,N,$,I,W,R,z,Y,B,F,H,X;if(0===i.size&&0===o.size)return n;const V=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let q=!1;const U=new Set,K=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],E=G(t,r,e);if(!E)continue;if(r._transitionKey=E,"line"===r.type||"area"===r.type){const t=o.get(E);if(t){if(K.add(E),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];q=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];q=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(a=null!==(l=t.opacity)&&void 0!==l?l:r.style.opacity)&&void 0!==a?a:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;continue}const T=i.get(E);if("point"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,T.x===t.x&&T.y===t.y&&T.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=T.x,r.y=T.y,r.r=null!==(d=T.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,T.x===t.x&&T.y===t.y&&T.w===t.w&&T.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=T.x,r.y=T.y,r.w=null!==(g=T.w)&&void 0!==g?g:r.w,r.h=null!==(y=T.h)&&void 0!==y?y:r.h,q=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(T){U.add(E);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,T.x===t.x&&T.y===t.y&&T.w===t.w&&T.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=T.x,r.y=T.y,r.w=null!==(x=T.w)&&void 0!==x?x:r.w,r.h=null!==(b=T.h)&&void 0!==b?b:r.h,q=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0;else if("candlestick"===r.type)if(T&&null!=T.openY){U.add(E);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(T.x!==t.x||T.openY!==t.openY||T.closeY!==t.closeY||T.highY!==t.highY||T.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=T.x,r.openY=T.openY,r.closeY=null!==(M=T.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=T.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(j=T.lowY)&&void 0!==j?j:r.lowY,q=!0)}else r._targetOpacity=null!==(C=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==C?C:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of o)if(!K.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}for(const[t,e]of i)if(!U.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(D=e.r)&&void 0!==D?D:3,style:{opacity:null!==(L=e.opacity)&&void 0!==L?L:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(O=e.w)&&void 0!==O?O:0,h:null!==(N=e.h)&&void 0!==N?N:0,style:{opacity:null!==($=e.opacity)&&void 0!==$?$:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(I=e.w)&&void 0!==I?I:0,h:null!==(W=e.h)&&void 0!==W?W:0,fill:"#999",datum:null,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(z=e.openY)&&void 0!==z?z:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(Y=e.closeY)&&void 0!==Y?Y:i,highY:null!==(B=e.highY)&&void 0!==B?B:i,lowY:null!==(F=e.lowY)&&void 0!==F?F:i,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(X=e.opacity)&&void 0!==X?X:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:V}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,s,l,a,c;if(!n.activeTransition)return!1;const u=H(t,n.activeTransition),d=F(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=X(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=X(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=X(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==n.w&&(t.w=X(n.w,t._targetW,d)),void 0!==n.h&&(t.h=X(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:X(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),t.y=X(n.y,t._targetY,d),void 0!==n.w&&(t.w=X(n.w,t._targetW,d)),void 0!==n.h&&(t.h=X(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:X(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=X(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=X(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=X(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=X(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=X(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:X(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=X(e[i][0],n[i][0],d),t.path[i][1]=X(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:X(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=X(e[n][0],i[n][0],d),t.topPath[n][1]=X(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=X(n[e][0],o[e][0],d),t.bottomPath[e][1]=X(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||z,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||z;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>nt.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}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._groupColorCounter=0,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(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const a=l||!N(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),c=l||!N(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(a||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=$(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=$(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=$(this.config.xAccessor,"x"),this.getY=$(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!N(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?W(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!N(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?W(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!N(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?$(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!N(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?W(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!N(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?$(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!N(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?W(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!N(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!N(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!N(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!N(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?$(this.config.openAccessor,"open"):void 0,this.getHigh=$(this.config.highAccessor,"high"),this.getLow=$(this.config.lowAccessor,"low"),this.getClose=e?$(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function it(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>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 ot(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function rt(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function st(t,e){const n=rt(t);if(!n)return!1;const i=rt(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function lt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function at(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),s=e-r,l=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>l||s>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,s=t.y-n,l=Math.sqrt(r*r+s*s);ot(t.r,i)>=l&&d>l&&(u=t,d=l),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(o)break;t=ut(r,e,n,i);break;case"line":t=dt(r,e,n,i);break;case"rect":t=ft(r,e,n);break;case"heatcell":t=gt(r,e,n);break;case"area":if(!1===r.interactive)break;t=pt(r,e,n);break;case"candlestick":t=yt(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function ct(t,e,n){if(0===t.length)return null;const i=vt(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,l]=t[o],[a,c]=t[r];return a===s?l:l+Math.max(0,Math.min(1,(e-s)/(a-s)))*(c-l)}function ut(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>ot(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function dt(t,e,n,i=30){var o,r,s,l;if(0===t.path.length)return null;const a=vt(t.path,e);if(0>a)return null;const[c,u]=t.path[a];let d;if(t.path.length>1){let i=1/0;const o=Math.max(0,a-1),r=Math.min(t.path.length-2,a);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[l,a]=t.path[s+1],c=ht(e,n,o,r,l,a);i>c&&(i=c)}d=i}else{const t=e-c,i=n-u;d=Math.sqrt(t*t+i*i)}const h=null!==(l=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(s=t.style)||void 0===s?void 0:s.lineWidth)&&void 0!==l?l:1;return d>Math.max(5,h/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:c,y:u,distance:d}}function ht(t,e,n,i,o,r){const s=o-n,l=r-i,a=s*s+l*l;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*l)/a;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function ft(t,e,n){const i=it(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function gt(t,e,n){const i=it(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function yt(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function pt(t,e,n){if(0===t.topPath.length)return null;const i=vt(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,l=n-r,a=Math.sqrt(s*s+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function vt(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function mt(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:s}}function xt(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}function bt(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?kt(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?kt(n,n.groups[t-1],r[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.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 kt(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function wt(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function At(t,n,i,o,r,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=n.current;if(!l||0===l.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-l.lastIngestTime>c;u!==r&&(s(u),i.current=!0,o())},1e3);return()=>clearInterval(e)},[t,r,o])}nt.GROUP_COLOR_MAP_CAP=1e3,nt.QUADTREE_THRESHOLD=500;const St={fill:e=>t.jsx("rect",{style:e,width:16,height:16}),line:e=>t.jsx("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Mt(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,St[n])(i(t,e)),o}function _t(){return t.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function jt(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Pt=(e,n,i,o,r,s,l,a,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=r;return f.forEach((e,u)=>{const m=Mt(e,u,d,h),x=jt(e,o,r),b=r&&r.size>0&&r.has(e.label);g.push(t.jsxs("g",{transform:`translate(0,${y})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:p?a===s&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&t.jsx("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&&t.jsx(_t,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),y+=22}),g};function Ct({config:e,orientation:n="vertical",width:i=100}){const{colorFn:o,domain:r,label:s,format:l}=e,a=l||(t=>Math.round(100*t)/100+""),c="grad-legend-"+p.useId();if("horizontal"===n){const e=12,n=Math.min(i,200),l=Math.max(0,(i-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:l+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:l,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),t.jsx("text",{x:l+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:o(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function Et(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,legendInteraction:l,title:a="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=p.useState(0),[g,y]=p.useState(0),v=p.useCallback((t,e)=>{f(t),y(e)},[]),m="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:Pt(e,i,o,r,s,l,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}):(({legendGroups:e,height:n,width:i,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let g=0;e.label&&(g+=16);const y=((e,n,i,o,r,s,l,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[];let p=0,v=0;const m=!(!n&&!i),x="isolate"===u||void 0===u&&null!=r;g.forEach((e,u)=>{const b=Mt(e,u,h,f),k=jt(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;d&&d>0&&p>0&&p+A>d&&(v++,p=0),y.push(t.jsxs("g",{transform:`translate(${p},${22*v})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:m?a===s&&u===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:m?t=>{var i;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+g.length)%g.length;c(a,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(a,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t.jsx("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&&t.jsx(_t,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=A});let b=0,k=0;for(const t of g){const e=26+7*t.label.length;d&&d>0&&k>0&&k+e>d?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=v+1;return{items:y,offset:b,totalRows:w,totalHeight:22*w}})(e,o,r,s,l,a,c,n,u,d,i);g+=y.offset+5,f.push(Object.assign(Object.assign({label:e.label},y),{offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=g+12});let g=h>i?0:Math.max(0,(i-h)/2);const y=[];return f.forEach((i,o)=>{const r=e[o];r.label&&(y.push(t.jsx("text",{transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),g+=16),y.push(t.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:i.items},"legend-group-"+o)),g+=i.offset+5,e[o+1]&&y.push(t.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(i.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),t.jsx("g",{children:y})})({legendGroups:n||[],title:a,height:u,width:c,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:v,legendInteraction:l}),x=!(!i&&!o);return t.jsxs("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==l&&(void 0!==l||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&t.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),m]})}function Tt(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Dt(t){return"object"==typeof t&&null!==t&&"gradient"in t}function Lt(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:s="right",title:l,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===s||"bottom"===s;let g,y;return"left"===s?(g=4,y=r.top):"top"===s?(g=0,y=l?32:8):"bottom"===s?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t.jsx("g",{transform:`translate(${g}, ${y})`,children:Dt(n)?t.jsx(Ct,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):Tt(n)?t.jsx(Et,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function Ot(t){return"string"==typeof t?{type:t}:t}function Nt({orient:n,config:i,values:o,scale:r,size:s,length:a}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),i=s-8;if("boxplot"===c.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!e)return null;const{q1:s,median:l,q3:a,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*i,20),g=(i-f)/2+4;if(u){const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="top"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:v+p*(g+f/2),x2:y,y2:v+p*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:v+p*g,x2:u,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:y,y1:v+p*g,x2:y,y2:v+p*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,i),y:"top"===n?v-g-f:v+g,width:Math.abs(i-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:o,y1:"top"===n?v-g-f:v+g,x2:o,y2:"top"===n?v-g:v+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=r(s),i=r(a),o=r(l),u=r(d),y=r(h),p="left"===n?-1:1,v=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:v+p*(g+f/2),y1:u,x2:v+p*(g+f/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:u,x2:v+p*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:v+p*g,y1:y,x2:v+p*(g+f),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?v-g-f:v+g,y:Math.min(e,i),width:f,height:Math.abs(i-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?v-g-f:v+g,y1:o,x2:"left"===n?v-g:v+g+f,y2:o,stroke:c.fill,strokeWidth:2})]})}}const d=l.bin().domain(e).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*i;if(u){const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:i,y:"top"===n?-4-s:4,width:Math.max(l,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(i,i+l),width:s,height:Math.abs(l),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=i/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(i/2),l=r((t.x0+t.x1)/2);o.push(u?`${l},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${l}`)}for(let t=d.length-1;t>=0;t--){const s=d[t];if(null==s.x0||null==s.x1)continue;const l=s.length/h*(i/2),a=r((s.x0+s.x1)/2);o.push(u?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-o-4:o+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?r(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):a;e.push(`L${t},${s}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,r,c,s,a,n,u,4]);return d?t.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function $t(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function It(t,e,n,i){return"curly"===t?i?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Wt(e,n,i,o){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:l,align:a,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=l;d||(d=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>i?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,y=s?u?[s]:$t(s,c):[],p=r?u?[r]:$t(r,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:y.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-title")),m=y.length*g),p.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:m,children:p.map((e,n)=>t.jsx("tspan",{x:v,dy:0===n?0:g,children:e},n))},"annotation-note-label"));let k=null;if((s||r)&&(0!==n||0!==i))if("topBottom"===d){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*g+(p.length>0?g:0);let n=0,i=e;"bottom"===h?(n=-e,i=0):"middle"===h&&(n=-e/2,i=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,y.length+p.length-1)*g;let A=0;return"topBottom"===d?A=0>i?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${i})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function Rt(e,n,i,o,r){var s;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t.jsx("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&l.push(t.jsx("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;l.push(t.jsx("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t.jsx("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&l.push(t.jsx("path",{d:It((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t.jsx("g",{className:"annotation-subject",children:l})}function zt(e,n,i,o,r,s){const l=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,l=n-r;if(0!==s||0!==l){const e=Math.abs(s),n=Math.abs(l),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+s*h,c=r+l*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);a=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(n-c,2))>.5&&(l.push(t.jsx("line",{x1:a,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,s=Math.atan2(n-c,e-a);l.push(t.jsx("path",{d:`M${a},${c}L${a+i*Math.cos(s+r)},${c+i*Math.sin(s+r)}L${a+i*Math.cos(s-r)},${c+i*Math.sin(s-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t.jsx("g",{className:"annotation-connector",children:l})}function Yt(e){const{x:n=0,y:i=0,dx:o,dy:r,nx:s,ny:l,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=e,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=s&&(m=s-n),null!=l&&(x=l-i);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&zt(m,x,c,h,b,u),!v.has("subject")&&Rt(b,u,h,n,i),!v.has("note")&&Wt(a,m,x,h)]}))}function Bt(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),l=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),a=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t.jsx(Yt,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t.jsx("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t.jsx(Yt,Object.assign({"data-testid":"semiotic-annotation",events:l},o,{type:s}),c)}function Ft(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function Ht(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function Xt(t,e,n){var i,o,r,s;const l=t.anchor||"fixed";if("latest"===l){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,s;const l=t.data;if(!l||0===l.length)return null;const a=l[l.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=a[t.xAccessor||"x"],h=a[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let a=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(a=e.x,c=e.y)}if(null!=a&&null!=c||(a=Ft(t,n),c=Ht(t,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:a,y:c}),{x:a,y:c};if("sticky"===l){const t=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(e);if(t)return t}return null}function Gt(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const Vt={linear:c.curveLinear,monotoneX:c.curveMonotoneX,monotoneY:c.curveMonotoneY,step:c.curveStep,stepAfter:c.curveStepAfter,stepBefore:c.curveStepBefore,basis:c.curveBasis,cardinal:c.curveCardinal,catmullRom:c.curveCatmullRom};let qt={positions:new Map};const Ut=new Set;function Kt(){for(const t of Ut)t()}function Zt(t,e){const n=qt.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(qt.positions);i.delete(t),qt={positions:i},Kt()}function Qt(t,e){const n=qt.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(qt.positions);i.delete(t),qt={positions:i},Kt()}function Jt(){return qt}function te(t){return Ut.add(t),()=>Ut.delete(t)}const ee={positions:new Map};function ne(){return()=>{}}function ie(){return ee}function oe(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function re(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function se(n){const{width:i,height:o,totalWidth:r,totalHeight:s,margin:l,scales:a,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f}=n,g=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||h||le,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=a.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),s=r.map(t=>t.valueOf()),l=r.map((t,e)=>({value:t,pixel:a.x(t),label:n(t,e,s)})),c=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return ae(l,Math.max(55,c+8))},[a,u,h,i]),y=e.useMemo(()=>{var t;if(!a)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return ae(a.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:a.y(t),label:n(t)})),22)},[a,u,f,o]),p=d&&a,v=c&&a;if(!p&&!v)return null;const m=null==u?void 0:u.find(t=>"bottom"===t.orient),x=null==u?void 0:u.find(t=>"left"===t.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,A=(null==x?void 0:x.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[p&&(()=>{var e,n;const r=oe(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=oe(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[g.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),y.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),b&&!w&&t.jsx("line",{x1:0,y1:o,x2:i,y2:o,stroke:S,strokeWidth:1}),w&&t.jsx("path",{d:re("bottom",i,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&t.jsx("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&t.jsx("path",{d:re("left",i,o),fill:"none",stroke:S,strokeWidth:1})]})})}function le(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ae(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function ce(n){var i,o;const{width:r,height:s,totalWidth:l,totalHeight:u,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:p,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j,legendPosition:P="right",foregroundGraphics:C,marginalGraphics:E,xValues:T,yValues:D,annotations:L,svgAnnotationRules:O,xAccessor:N,yAccessor:$,annotationData:I,pointNodes:W,curve:R,underlayRendered:z,linkedCrosshairName:Y,linkedCrosshairSourceId:B,children:F}=n,H=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=h.x.ticks(Math.min(i,Math.max(2,Math.floor(r/70)))),s=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,s)})),a=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),c=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(a+8,55)):Math.max(55,a+8);let u=ae(l,c);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=h.x.domain()[1],e=h.x(t),i=u[u.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,u.length,s);c>e-i&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[f,h,g,x,r]),X=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=ae(h.y.ticks(Math.min(i,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=h.y.domain()[1],e=h.y(t),i=o[o.length-1].pixel;if(Math.abs(e-i)>1){const r=n(t);22>Math.abs(e-i)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:r})}}return o},[f,h,g,b,s]),G=e.useMemo(()=>{var t;if(!f||!h)return[];const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||le,i=null!==(t=e.ticks)&&void 0!==t?t:5;return ae(h.y.ticks(Math.min(i,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[f,h,g,b,s]),V=e.useRef(new Map),q=e.useRef(null!==(i=null==L?void 0:L.length)&&void 0!==i?i:0),U=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;q.current!==U&&(q.current=U,V.current=new Map);const K=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,n,i){var o,r,s,l,u,d,h,f,g,y,p,m,x,b,k,w,A,S,M,_,j,P,C,E,T,D,L,O,N,$,I,W,R,z,Y,B,F,H,X,G,V,q,U,K,Z,Q,J,tt;switch(e.type){case"label":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Gt(r,s,i)?t.jsx(Bt,{noteData:{x:r,y:s,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}},"ann-"+n):null}case"callout":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return Gt(r,s,i)?t.jsx(Bt,{noteData:{x:r,y:s,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}},"ann-"+n):null}case"x-threshold":{const o=Ft(e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let l;return l="bottom"===s?(i.height||0)-4:"center"===s?(i.height||0)/2:12,t.jsxs("g",{children:[t.jsx("line",{x1:o,y1:0,x2:o,y2:i.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:o+4,y:l,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"y-threshold":{const o=Ht(e,i);if(null==o)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let l,a;return"left"===s?(l=4,a="start"):"center"===s?(l=(i.width||0)/2,a="middle"):(l=(i.width||0)-4,a="end"),t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:o,x2:i.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:l,y:o-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:Ft(Object.assign(Object.assign({},t),{type:"point"}),i),y:Ht(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=a.packEnclose(o),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:Ft(Object.assign(Object.assign({},t),{type:"point"}),i),y:Ht(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const r=e.padding||10,s=o.map(t=>t.x),l=o.map(t=>t.y),a=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...l)-r,d=Math.max(...l)+r;return t.jsxs("g",{children:[t.jsx("rect",{x:a,y:u,width:c-a,height:d-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(a+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const o=i.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,o)=>{const r=Ft(n,i),l=Ht(n,i);if(null==r||null==l)return null;const a="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:l,r:a},c),"hl-"+o)})},"ann-"+n)}case"bracket":{const o=Ft(e,i),r=Ht(e,i);return t.jsx(Bt,{noteData:{x:null!=o?o:0,y:null!=r?r: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}},"ann-"+n)}case"trend":{const a=i.data||[];if(2>a.length)return null;const c=i.xAccessor||"x",f=i.yAccessor||"y",g=a.map(t=>[t[c],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>g.length)return null;const y=null!==(r=null===(o=i.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(s=i.scales)||void 0===s?void 0:s.time,p=null!==(u=null===(l=i.scales)||void 0===l?void 0:l.y)&&void 0!==u?u:null===(d=i.scales)||void 0===d?void 0:d.value;if(!y||!p)return null;const m=e.method||"linear";let x;x="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),a=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===a?0:i[t]/a;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){l.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))l.push([e,h/u]);else{const t=(u*g-d*h)/y;l.push([e,(h-t*d)/u+t*e])}}return l}(g,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?v.default.polynomial(g,{order:e.order||2}):v.default.linear(g)).points;const b=x.map(([t,e])=>`${y(t)},${p(e)}`).join(" "),k=e.color||"#6366f1";return t.jsxs("g",{children:[t.jsx("polyline",{points:b,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:y(x[x.length-1][0])+4,y:p(x[x.length-1][1])-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const o=null!==(g=null===(f=i.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(y=i.scales)||void 0===y?void 0:y.value,r=null!==(p=null==o?void 0:o(e.y0))&&void 0!==p?p:0,s=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:i.height||0;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:i.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:e.label})]},"ann-"+n)}case"envelope":{const o=i.data||[];if(2>o.length)return null;const r=i.xAccessor||"x",s=null!==(b=null===(x=i.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=i.scales)||void 0===k?void 0:k.time,l=null!==(A=null===(w=i.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=i.scales)||void 0===S?void 0:S.value;if(!s||!l)return null;const a=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=o.filter(t=>null!=t[a]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const f=Vt[i.curve||"linear"]||c.curveLinear,g=c.area().x(t=>s(t[r])).y0(t=>l(t[u])).y1(t=>l(t[a])).curve(f)(h);if(!g)return null;const y=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:y,fillOpacity:null!==(M=e.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:s(h[h.length-1][r])+4,y:l(h[h.length-1][a])-4,fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const o=i.data||[];if(2>o.length)return null;const r=i.yAccessor||"y",s=null!==(j=null===(_=i.scales)||void 0===_?void 0:_.x)&&void 0!==j?j:null===(P=i.scales)||void 0===P?void 0:P.time,l=null!==(E=null===(C=i.scales)||void 0===C?void 0:C.y)&&void 0!==E?E:null===(T=i.scales)||void 0===T?void 0:T.value;if(!s||!l)return null;const a=o.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const c=a.reduce((t,e)=>t+e,0)/a.length,u=a.reduce((t,e)=>t+Math.pow(e-c,2),0)/a.length,d=Math.sqrt(u),h=null!==(D=e.threshold)&&void 0!==D?D:2,f=c-h*d,g=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(L=e.fillOpacity)&&void 0!==L?L:.1,v=e.anomalyColor||"#ef4444",m=null!==(O=e.anomalyRadius)&&void 0!==O?O:6,x=l(c+h*d),b=l(f),k=o.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:i.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((e,n)=>{const o=Ft(e,i),r=Ht(e,i);return null==o||null==r?null:t.jsx("circle",{cx:o,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const o=i.data||[];if(3>o.length)return null;const r=i.xAccessor||"x",s=i.yAccessor||"y",l=null!==($=null===(N=i.scales)||void 0===N?void 0:N.x)&&void 0!==$?$:null===(I=i.scales)||void 0===I?void 0:I.time,a=null!==(R=null===(W=i.scales)||void 0===W?void 0:W.y)&&void 0!==R?R:null===(z=i.scales)||void 0===z?void 0:z.value;if(!l||!a)return null;const c=o.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=v.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,o=0;for(const[t,r]of c)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,l=(n-s*e)/t;u=t=>l+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((t,e)=>t+e[0],0)/d,y=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),p=null!==(Y=e.confidence)&&void 0!==Y?Y:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,x=null!==(B=e.steps)&&void 0!==B?B:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(y>0?Math.pow(t-g,2)/y:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${a(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${a(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${a(t.yCenter)}`).join(" "),_=`${l(b)},${a(u(b))}`,j=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),t.jsx("polyline",{points:`${_} ${M}`,fill:"none",stroke:j,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=e.strokeDasharray)&&void 0!==X?X:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:l(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:j,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const t=Xt(e,n,i);if(!t)return null;o=t.x,r=t.y}if(null==o||null==r)return null;if(!Gt(o,r,i))return null;const s=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,c=null!==(U=e.height)&&void 0!==U?U:32,u=null!==(K=e.content)&&void 0!==K?K:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:o+s-a/2,y:r+l-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const o=Xt(e,n,i);if(!o)return null;const{x:r,y:s}=o;return t.jsx("text",{x:r+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label},"ann-text-"+n)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(Z=i.scales)||void 0===Z?void 0:Z.o,s=null===(Q=i.scales)||void 0===Q?void 0:Q.x,l=null===(J=i.scales)||void 0===J?void 0:J.y,a=(null==r?void 0:r.bandwidth)?r:(null==s?void 0:s.bandwidth)?s:(null==l?void 0:l.bandwidth)?l:null;if(!a)return null;const c=a(o);if(null==c)return null;const u=a.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(tt=e.opacity)&&void 0!==tt?tt:.15,f=e.label;return t.jsxs("g",(i.projection?"vertical"===i.projection:a===s)?{children:[t.jsx("rect",{x:c,y:0,width:u,height:i.height||0,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[t.jsx("rect",{x:0,y:c,width:i.width||0,height:u,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:$,width:r,height:s,data:I,frameType:"xy",pointNodes:W,curve:R,stickyPositionCache:V.current};return L.map((t,i)=>{if(O){const o=O(t,i,n);return null!=o?o:e(t,i,n)}return e(t,i,n)}).filter(Boolean)},[L,O,r,s,N,$,I,h,W,R]),Z=function(t){var n;const i=e.useSyncExternalStore(t?te:ne,t?Jt:ie,t?Jt:ie);return t&&null!==(n=i.positions.get(t))&&void 0!==n?n:null}(Y);return e.useEffect(()=>{if(!(null==Z?void 0:Z.locked)||!Y)return;const t=t=>{"Escape"===t.key&&Qt(Y)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==Z?void 0:Z.locked,Y]),f||w||A||C||E||K&&K.length>0||k||F||Z?t.jsxs("svg",{role:"img",width:l,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof w?w:"XY Chart"}),t.jsx("desc",{children:"string"==typeof w?w+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[k&&h&&!z&&(()=>{var e,n;const i=oe(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),o=oe(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[H.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),X.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,o=!n||!1!==n.baseline,l=(null==e?void 0:e.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&H.length>1&&(()=>{const t=r/Math.max(H.length-1,1);return H.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})();return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!z&&o&&!a&&t.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:h,strokeWidth:1}),!z&&a&&t.jsx("path",{d:re("bottom",r,s),fill:"none",stroke:h,strokeWidth:1}),H.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):st(e.value,n>0?H[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${s})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:e.label})})]},"xtick-"+n)}),y&&t.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"},children:y}),!z&&i&&!l&&t.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:h,strokeWidth:1}),!z&&l&&t.jsx("path",{d:re("left",r,s),fill:"none",stroke:h,strokeWidth:1}),X.map((e,n)=>{const i=!!u&&("function"==typeof u?u(e.value,n):st(e.value,n>0?X[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||p;return n?t.jsx("text",{x:15-d.left,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-d.left}, ${s/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===G.length)return null;const n=e.landmarkTicks,i=e.label||m;return t.jsxs(t.Fragment,{children:[!1!==e.baseline&&t.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:h,strokeWidth:1}),G.map((e,i)=>{const o=!!n&&("function"==typeof n?n(e.value,i):st(e.value,i>0?G[i-1].value:void 0));return t.jsxs("g",{transform:`translate(${r},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-r-"+i)}),i&&t.jsx("text",{x:r+d.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${r+d.right-15}, ${s/2})`,style:{userSelect:"none"},children:i})]})})()]})})(),K,E&&h&&T&&D&&t.jsxs(t.Fragment,{children:[E.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Nt,{orient:"top",config:Ot(E.top),values:T,scale:h.x,size:d.top,length:r})}),E.bottom&&t.jsx("g",{transform:`translate(0, ${s})`,children:t.jsx(Nt,{orient:"bottom",config:Ot(E.bottom),values:T,scale:h.x,size:d.bottom,length:r})}),E.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(Nt,{orient:"left",config:Ot(E.left),values:D,scale:h.y,size:d.left,length:s})}),E.right&&t.jsx("g",{transform:`translate(${r}, 0)`,children:t.jsx(Nt,{orient:"right",config:Ot(E.right),values:D,scale:h.y,size:d.right,length:s})})]}),C,Z&&Z.sourceId!==B&&(null==h?void 0:h.x)&&(()=>{const e=h.x(Z.xValue);if(null==e||0>e||e>r)return null;const n=Z.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:s,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),F]}),w&&t.jsx("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof w?w:null}),Lt({legend:A,totalWidth:l,totalHeight:u,margin:d,legendPosition:P,title:w,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:j})]}):null}function ue(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const de="undefined"==typeof window||"undefined"==typeof document,he=p.createContext(null);function fe(){return p.useContext(he)}const ge={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ye(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const i=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function pe(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}const ve=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},me={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"},xe={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},be={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)"},ke={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},we={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)"},Ae={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Se={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Me({scene:e,chartType:n,tableId:i,chartTitle:o}){var r;const[s,l]=p.useState(!1),a=fe(),c=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,u=s||c,d=p.useRef(null),h=o?"Data summary for "+o:i?`Data summary for ${n} ${i}`:"Data summary for "+n,f=p.useCallback(()=>{s||c||l(!0)},[s,c]),g=p.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||l(!1)},[c]);if(!e||0===e.length)return i?t.jsx("span",{id:i,tabIndex:-1,style:ge}):null;if(!u)return t.jsx("div",{id:i,tabIndex:-1,onFocus:f,style:ge,role:"region","aria-label":h,children:t.jsxs("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," elements)"]})});const y=function(t){var e,n,i,o,r,s,l,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,M;const _=[];if(!Array.isArray(t))return _;for(const j of t)if(j&&"object"==typeof j)try{switch(j.type){case"point":_.push({label:"Point",values:{x:j.x,y:j.y}});break;case"line":{const t=j.path,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=j.topPath,e=Array.isArray(j.datum)?j.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=j.datum&&"object"==typeof j.datum?j.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:j.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;_.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":_.push({label:"Cell",values:{x:j.x,y:j.y,value:j.value}});break;case"wedge":_.push({label:"Wedge",values:{category:null!==(a=null!==(s=null===(r=j.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(l=j.datum)||void 0===l?void 0:l.label)&&void 0!==a?a:"",value:null!==(u=null===(c=j.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":_.push({label:"Node",values:{id:null!==(h=null===(d=j.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=j.cx)&&void 0!==f?f:j.x,y:null!==(g=j.cy)&&void 0!==g?g:j.y}});break;case"arc":_.push({label:"Arc",values:{id:null!==(p=null===(y=j.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=j.cx)&&void 0!==v?v:j.x,y:null!==(m=j.cy)&&void 0!==m?m:j.y}});break;case"candlestick":_.push({label:"Candlestick",values:{x:j.x,open:j.open,high:j.high,low:j.low,close:j.close}});break;case"geoarea":_.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=j.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=j.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(M=null===(S=j.datum)||void 0===S?void 0:S.value)&&void 0!==M?M:""}})}}catch(t){}return _}(e),v=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(y),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ve(t.min)} to ${ve(t.max)}, mean ${ve(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(y.length,v),x=y.slice(0,5),b=new Set;for(const t of x)for(const e of Object.keys(t.values))b.add(e);const k=Array.from(b);return t.jsxs("div",{ref:d,id:i,tabIndex:-1,onBlur:g,style:me,role:"region","aria-label":h,children:[t.jsx("button",{type:"button",onClick:()=>{c&&a&&a.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:be,children:"×"}),t.jsx("div",{role:"note",style:xe,children:m}),t.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:ke,children:[t.jsxs("caption",{style:Se,children:["First ",x.length," of ",y.length," data points"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:we,children:"type"}),k.map(e=>t.jsx("th",{style:we,children:e},e))]})}),t.jsx("tbody",{children:x.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Ae,children:e.label}),k.map(n=>{return t.jsx("td",{style:Ae,children:(i=e.values[n],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":ve(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},n);var i})]},n))})]})]})}function _e({nodes:e,edges:n,chartType:i,tableId:o,chartTitle:r}){var s,l,a,c,u,d,h,f,g,y,v,m,x,b;const[k,w]=p.useState(!1),A=fe(),S=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,M=k||S,_=r?"Data summary for "+r:o?`Data summary for ${i} ${o}`:"Data summary for "+i,j=p.useRef(null),P=p.useCallback(()=>{k||S||w(!0)},[k,S]),C=p.useCallback(t=>{var e;S||(null===(e=j.current)||void 0===e?void 0:e.contains(t.relatedTarget))||w(!1)},[S]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:ge}):null;if(!M)return t.jsx("div",{id:o,tabIndex:-1,onFocus:P,style:ge,role:"region","aria-label":_,children:t.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",e.length," nodes, ",n.length," edges)"]})});const E=Array.isArray(e)?e:[],T=Array.isArray(n)?n:[],D=new Map,L=new Map,O=new Map,N=new Map;for(const t of T){if(!t||"object"!=typeof t)continue;const e=null!==(l=t.datum)&&void 0!==l?l:t,n="object"==typeof e.source?null===(a=e.source)||void 0===a?void 0:a.id:e.source,i="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";L.set(t,(null!==(u=L.get(t))&&void 0!==u?u:0)+1),N.set(t,(null!==(d=N.get(t))&&void 0!==d?d:0)+o)}if(null!=i&&""!==i){const t=i+"";D.set(t,(null!==(h=D.get(t))&&void 0!==h?h:0)+1),O.set(t,(null!==(f=O.get(t))&&void 0!==f?f:0)+o)}}const $=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(y=null===(g=e.datum)||void 0===g?void 0:g.id)&&void 0!==y?y:e.id,i=null!=n?n+"":"node-"+t,o=null!==(v=D.get(i))&&void 0!==v?v:0,r=null!==(m=L.get(i))&&void 0!==m?m:0,s=null!==(x=O.get(i))&&void 0!==x?x:0,l=null!==(b=N.get(i))&&void 0!==b?b:0;$.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:s+l,wInDeg:s,wOutDeg:l})}$.sort((t,e)=>e.degree-t.degree);let I=0,W=0;if($.length>0){let t=0;for(const e of $)t+=e.degree,e.degree>W&&(W=e.degree);I=t/$.length}const R=T.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),z=[`${$.length} nodes, ${T.length} edges.`];$.length>0&&z.push(`Mean degree: ${ve(I)}, max degree: ${W}.`);const Y=$.slice(0,5);return t.jsxs("div",{ref:j,id:o,tabIndex:-1,onBlur:C,style:me,role:"region","aria-label":_,children:[t.jsx("button",{type:"button",onClick:()=>{S&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:be,children:"×"}),t.jsx("div",{role:"note",style:xe,children:z.join(" ")}),t.jsxs("table",{role:"table","aria-label":"Node degree summary for "+i,style:ke,children:[t.jsxs("caption",{style:Se,children:["Top ",Y.length," of ",$.length," nodes by degree"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:we,children:"id"}),t.jsx("th",{style:we,children:"degree"}),t.jsx("th",{style:we,children:"in"}),t.jsx("th",{style:we,children:"out"}),R&&t.jsx("th",{style:we,children:"w. degree"}),R&&t.jsx("th",{style:we,children:"w. in"}),R&&t.jsx("th",{style:we,children:"w. out"})]})}),t.jsx("tbody",{children:Y.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:Ae,children:e.id}),t.jsx("td",{style:Ae,children:e.degree}),t.jsx("td",{style:Ae,children:e.inDeg}),t.jsx("td",{style:Ae,children:e.outDeg}),R&&t.jsx("td",{style:Ae,children:ve(e.wDegree)}),R&&t.jsx("td",{style:Ae,children:ve(e.wInDeg)}),R&&t.jsx("td",{style:Ae,children:ve(e.wOutDeg)})]},n))})]})]})}function je({summary:e}){return e?t.jsx("div",{role:"note",style:ge,children:e}):null}function Pe({tableId:e}){return t.jsx("a",{href:"#"+e,style:ge,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.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:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,ge)},children:"Skip to data table"})}function Ce({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:ge,children:n})}const Ee="var(--semiotic-focus, #005fcc)";function Te({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:l}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=l){const e=Math.max(s,4),n=Math.max(l,4);u=t.jsx("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Ee,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Ee,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Ee,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function De({x:e,y:n,containerWidth:i,containerHeight:o,margin:r,children:s,className:l="stream-frame-tooltip",zIndex:a=1}){const c=p.useRef(null),[u,d]=p.useState(null);p.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();d(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,l,i,o]);let h;return h=u?`translate(${u.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`,t.jsx("div",{ref:c,className:l,style:{position:"absolute",left:r.left+e,top:r.top+n,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:s})}const Le=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Oe=new WeakMap;let Ne=0,$e=!1,Ie=null,We=null,Re=null;function ze(t,e){var n,i;if(!e)return e;const o=Le.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if($e)return;if("undefined"==typeof window||"undefined"==typeof document)return;$e=!0;const t=()=>{Ne++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Ie=new MutationObserver(t),Ie.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{We=window.matchMedia("(prefers-color-scheme: dark)"),Re=t,"function"==typeof We.addEventListener?We.addEventListener("change",Re):"function"==typeof We.addListener&&We.addListener(Re)}catch(t){}}();let s=Oe.get(r);s&&s.version===Ne||(s={version:Ne,map:new Map},Oe.set(r,s));const l=s.map.get(e);if(void 0!==l)return l;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,a),a}function Ye(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Be(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 t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>n(t.matches))},[]),t}(),i=e.useRef(n);i.current=n;const[o,r]=function(t,n,i){const o=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!i)return;const t=o.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[o,[n&&r?r.w:t[0],i&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),l=r[0]-s.left-s.right,a=r[1]-s.top-s.bottom,c=Ye(t.foregroundGraphics,r,s),u=Ye(t.backgroundGraphics,r,s),d=T(t=>t.theme),{transition:h,introEnabled:f}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+p.useId(),y=e.useRef(0),v=e.useRef(()=>{}),m=e.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>v.current()))},[]);e.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),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 _=t.themeDirtyRef;return e.useEffect(()=>{_&&(Ne++,_.current=!0,m())},[d,m,_]),{reducedMotion:n,reducedMotionRef:i,responsiveRef:o,size:r,margin:s,adjustedWidth:l,adjustedHeight:a,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:y,renderFnRef:v,scheduleRender:m,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:M}}function Fe(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,l=e[0]+"px",a=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function He(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Xe(t){switch(t){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function Ge(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Ve(t,e,n,i,o,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const l=s[s.length-1];if(0===l)return;const a=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;a>i&&(r*=i/a),a>l-i&&(r*=(l-i)/a),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const qe=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"line"===t.type);for(const l of s){if(2>l.path.length)continue;const a=l._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const u=l.style.stroke||"#007bff",d=ze(t,u)||u,h=l.style.strokeWidth||2,f=l.colorThresholds,g=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=h,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const m=null!==(o=l.style.opacity)&&void 0!==o?o:1;Ve(t,l.path,d,h,m,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const y=Xe(l.curve),p=f&&f.length>0&&g&&g.length===l.path.length,v=l._decayOpacities;if(v&&v.length===l.path.length&&!p){t.strokeStyle=d;const x=null!==(r=l.style.opacity)&&void 0!==r?r:1;for(let b=0;l.path.length-1>b;b++)t.globalAlpha=.5*(v[b]+v[b+1])*x,t.beginPath(),t.moveTo(l.path[b][0],l.path[b][1]),t.lineTo(l.path[b+1][0],l.path[b+1][1]),t.stroke()}else if(p){let k=null,w=null,A=null,S=null,M=!1;function _(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),M=!0}function j(){M&&(t.stroke(),M=!1)}for(let P=0;l.path.length>P;P++){const[C,E]=l.path[P],T=g[P],D=Ge(T,f,d);if(null!==k&&null!==S&&null!==A){if(D===S)t.lineTo(C,E);else{const L=[];for(const O of f){const N=O.value;(A>N||N>T)&&(N>A||T>N)||A===N||T===N||L.push({t:(N-A)/(T-A)})}L.sort((t,e)=>t.t-e.t);for(const $ of L){const I=k+(C-k)*$.t,W=w+(E-w)*$.t,R=Ge(A+(T-A)*Math.min($.t+1e-4,1),f,d);t.lineTo(I,W),j(),_(R,I,W)}t.lineTo(C,E)}k=C,w=E,A=T,S=D}else _(D,C,E),k=C,w=E,A=T,S=D}j()}else{if(t.beginPath(),!l.strokeGradient||2>l.strokeGradient.colorStops.length||2>l.path.length)t.strokeStyle=d;else{const z=t.createLinearGradient(l.path[0][0],0,l.path[l.path.length-1][0],0);for(const Y of l.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,Y.offset)),Y.color);t.strokeStyle=z}if(y)c.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[B,F]=l.path[0];t.moveTo(B,F);for(let H=1;l.path.length>H;H++)t.lineTo(l.path[H][0],l.path[H][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=("string"==typeof l.style.fill?ze(t,l.style.fill):l.style.fill)||l.style.fill,y&&!p)c.line().x(t=>t[0]).y(t=>t[1]).curve(y).context(t)(l.path);else{const[G,V]=l.path[0];t.moveTo(G,V);for(let q=1;l.path.length>q;q++)t.lineTo(l.path[q][0],l.path[q][1])}const X=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],i.height),t.lineTo(X,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Ue(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function Ke(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ze(t,e,n=.3){Ke(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Qe(t,e,n=.6){var i,o,r,s,l;if(!Ke(e))return;const a=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+a*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(l=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==l?l:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Je(t,e,n,i=.35){Ke(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function tn(t){switch(t){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function en(t,e){const n=tn(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const i=c.area().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const nn=(t,e,n,i)=>{var o,r,s;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,i.width*n,i.height),t.clip());const l=e.style.fill||"#4e79a7",a=e._decayOpacities;if(a&&a.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=l;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(a[i]+a[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(a[n]+a[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(en(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=t.createLinearGradient(0,n,0,i);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||o.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const[n,i,r]=Ue(t,"string"==typeof l?l:"#4e79a7");o.addColorStop(0,`rgba(${n},${i},${r},${e.fillGradient.topOpacity})`),o.addColorStop(1,`rgba(${n},${i},${r},${e.fillGradient.bottomOpacity})`)}t.fillStyle=o,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(en(t,e),Je(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=u,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke;else{const n=t.createLinearGradient(e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);for(const t of e.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,t.offset)),t.color);t.strokeStyle=n}t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=tn(e.curve);if(t.beginPath(),n)c.line().x(t=>t[0]).y(t=>t[1]).curve(n).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1}},on=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?ze(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Qe(t,e),t.globalAlpha=1}}finally{t.restore()}}};function rn(t,e,n){const i=e.fillGradient;if(!i)return null;const o=e.roundedEdge;let r=e.x,s=e.y,l=e.x,a=e.y+e.h;if("bottom"===o?(s=e.y+e.h,a=e.y):"right"===o?(r=e.x+e.w,s=e.y,l=e.x,a=e.y):"left"===o&&(r=e.x,s=e.y,l=e.x+e.w,a=e.y),"colorStops"in i){const e=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;const n=t.createLinearGradient(r,s,l,a);for(const t of e)n.addColorStop(t.offset,t.color);return n}const c=t.createLinearGradient(r,s,l,a),[u,d,h]=Ue(t,n);return c.addColorStop(0,`rgba(${u},${d},${h},${i.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${i.bottomOpacity})`),c}const sn=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)ln(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||ze(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?rn(t,e,n):null;t.fillStyle=i||n;const o=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:r,y:s,w:l,h:a}=e;switch(e.roundedEdge){case"right":t.moveTo(r,s),t.lineTo(r+l-o,s),t.arcTo(r+l,s,r+l,s+o,o),t.lineTo(r+l,s+a-o),t.arcTo(r+l,s+a,r+l-o,s+a,o),t.lineTo(r,s+a);break;case"left":t.moveTo(r+l,s),t.lineTo(r+o,s),t.arcTo(r,s,r,s+o,o),t.lineTo(r,s+a-o),t.arcTo(r,s+a,r+o,s+a,o),t.lineTo(r+l,s+a);break;case"bottom":t.moveTo(r,s),t.lineTo(r+l,s),t.lineTo(r+l,s+a-o),t.arcTo(r+l,s+a,r+l-o,s+a,o),t.lineTo(r+o,s+a),t.arcTo(r,s+a,r,s+a-o,o);break;default:t.moveTo(r,s+a),t.lineTo(r,s+o),t.arcTo(r,s,r+o,s,o),t.lineTo(r+l-o,s),t.arcTo(r+l,s,r+l,s+o,o),t.lineTo(r+l,s+a)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=("string"==typeof e.style.fill?ze(t,e.style.fill):e.style.fill)||ze(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?rn(t,e,n):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Ze(t,e),t.globalAlpha=1}};function ln(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function an(t,e,n,i){return Object.assign(Object.assign(Object.assign({},function(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}(t)),{data:t,x:e,y:n,time:e,value:n}),i)}function cn(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function un(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const dn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hn(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${dn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${dn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const fn={line:[nn,qe,on],area:[nn,on],stackedarea:[nn,on],scatter:[on],bubble:[on],heatmap:[(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=ze(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Ze(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):un(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=cn(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}}],bar:[sn],swarm:[on],waterfall:[(t,e,n,i)=>{var o,r,s;sn(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=ze(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const i=l[e],o=l[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=o.datum)||void 0===s?void 0:s.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const l=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==l&&(t.globalAlpha=l);const a=ze(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=a,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=a,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=ze(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}}],mixed:[nn,qe,on]},gn={top:20,right:20,bottom:30,left:40},yn={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",primary:"#007bff"};function pn(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const vn={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 mn({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.jsxs("div",{className:"semiotic-tooltip",style:vn,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:n(e.value)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:n(e.time)})]})}const xn=e.forwardRef(function(n,i){var o,r,s,l,a,c,u,d,h,f,g;const{chartType:y,runtimeMode:v,data:m,chunkThreshold:x,chunkSize:w,xAccessor:A,yAccessor:M,colorAccessor:_,sizeAccessor:j,groupAccessor:P,lineDataAccessor:C,curve:E,normalize:T,binSize:D,valueAccessor:L,arrowOfTime:O="right",windowMode:N="sliding",windowSize:$=200,timeAccessor:I,xExtent:W,yExtent:R,extentPadding:z=.1,scalePadding:Y,sizeRange:B,size:F=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,lineStyle:U,pointStyle:K,areaStyle:Z,barStyle:Q,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:it,boundsAccessor:ot,boundsStyle:rt,y0Accessor:st,gradientFill:lt,lineGradient:ut,areaGroups:dt,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,showAxes:kt=!0,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:Pt,yFormat:Ct,tickFormatTime:Et,tickFormatValue:Tt,hoverAnnotation:Dt,tooltipContent:Lt,customHoverBehavior:Ot,customClickBehavior:Nt,enableHover:$t,hoverRadius:It=30,tooltipMode:Wt,annotations:Rt,svgAnnotationRules:zt,showGrid:Yt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,backgroundGraphics:qt,foregroundGraphics:Ut,canvasPreRenderers:Kt,svgPreRenderers:Zt,title:Qt,categoryAccessor:Jt,brush:te,onBrush:ee,decay:ne,pulse:ie,transition:oe,animate:re,staleness:le,heatmapAggregation:ae,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,marginalGraphics:ve,pointIdAccessor:me,xScaleType:xe,yScaleType:be,accessibleTable:ke=!0,description:we,summary:Ae,linkedCrosshairName:Se,linkedCrosshairSourceId:_e}=n,Ee=e.useRef(!1),Le=Be({sizeProp:F,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:gn,animate:re,transitionProp:oe,themeDirtyRef:Ee}),{reducedMotionRef:Oe,responsiveRef:Ne,size:$e,currentTheme:Ie,transition:We,introEnabled:Re,tableId:ze,rafRef:Ye,renderFnRef:Xe,scheduleRender:Ge}=Le;let Ve=Le.margin;if(ve){const t=60,e=Object.assign({},Le.margin);ve.top&&t>e.top&&(e.top=t),ve.bottom&&t>e.bottom&&(e.bottom=t),ve.left&&t>e.left&&(e.left=t),ve.right&&t>e.right&&(e.right=t),Ve=e}const qe="function"==typeof Ut?Ut({size:$e,margin:Ve}):Ut,Ue="function"==typeof qt?qt({size:$e,margin:Ve}):qt,Ke=$e[0]-Ve.left-Ve.right,Ze=$e[1]-Ve.top-Ve.bottom,Qe=null!=Dt?Dt:$t,Je=e.useRef(null),tn=e.useRef(null),[en,nn]=e.useState(0),[on,rn]=e.useState(null),sn=e.useRef(null),ln=e.useRef(null),[cn,un]=e.useState(null),dn=e.useRef(yn.primary),[vn,xn]=e.useState(!1),[bn,kn]=e.useState([]),[wn,An]=e.useState([]),Sn="streaming"===v||["bar","swarm","waterfall"].includes(y),Mn=e.useMemo(()=>{var t,e,n;return{chartType:y,runtimeMode:Sn?"streaming":"bounded",windowSize:$,windowMode:N,arrowOfTime:Sn?O:"right",extentPadding:z,scalePadding:Y,xAccessor:Sn?void 0:A,yAccessor:Sn?void 0:M,timeAccessor:Sn?I:void 0,valueAccessor:L,colorAccessor:_,sizeAccessor:j,groupAccessor:P||(C?"_lineGroup":void 0),categoryAccessor:Jt,lineDataAccessor:C,xScaleType:xe,yScaleType:be,xExtent:W,yExtent:R,sizeRange:B,binSize:D,normalize:T,boundsAccessor:ot,boundsStyle:rt,y0Accessor:st,gradientFill:!0===lt?{topOpacity:.8,bottomOpacity:.05}:!1===lt?void 0:lt,areaGroups:dt?new Set(dt):void 0,lineGradient:ut,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:tt,waterfallStyle:J,colorScheme:it,barColors:et,barStyle:Q,annotations:Rt,decay:ne,pulse:ie,transition:We,introAnimation:Re,staleness:le,heatmapAggregation:ae,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,pointIdAccessor:me,curve:E,themeCategorical:null===(t=null==Ie?void 0:Ie.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(Ie),themeSequential:null===(e=null==Ie?void 0:Ie.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Ie?void 0:Ie.colors)||void 0===n?void 0:n.diverging}},[y,$,N,O,z,Y,A,M,I,L,xe,be,_,j,P,Jt,C,W,R,B,D,T,ot,rt,st,lt,ut,dt,ht,ft,gt,yt,pt,U,K,Z,tt,J,Q,it,et,Rt,ne,ie,null==We?void 0:We.duration,null==We?void 0:We.easing,Re,le,ae,he,fe,ge,pe,Sn,me,E,Ie]),_n=e.useRef(null);_n.current||(_n.current=new nt(Mn)),e.useEffect(()=>{var t;null===(t=_n.current)||void 0===t||t.updateConfig(Mn),Ee.current=!0,Ge()},[Mn,Ge]);const jn=e.useRef(null);jn.current||(jn.current=new k(t=>{const e=_n.current;e&&e.ingest(t)&&(Ee.current=!0,Ge())},{chunkThreshold:x,chunkSize:w})),e.useEffect(()=>{var t;null===(t=jn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:x,chunkSize:w})},[x,w]);const Pn=e.useCallback(t=>{var e;null===(e=jn.current)||void 0===e||e.push(t)},[]),Cn=e.useCallback(t=>{var e;null===(e=jn.current)||void 0===e||e.pushMany(t)},[]),En=e.useCallback(()=>{var t,e;null===(t=jn.current)||void 0===t||t.clear(),null===(e=_n.current)||void 0===e||e.clear(),Ee.current=!0,Ge()},[Ge]);e.useImperativeHandle(i,()=>({push:Pn,pushMany:Cn,remove:t=>{var e,n,i;null===(e=jn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=_n.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(sn.current&&o.some(t=>{var e;return t===(null===(e=sn.current)||void 0===e?void 0:e.data)})&&(sn.current=null,un(null)),Ee.current=!0,Ge()),o},update:(t,e)=>{var n,i,o;null===(n=jn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=_n.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Ee.current=!0,Ge()),r},clear:En,getData:()=>{var t,e,n;return null===(t=jn.current)||void 0===t||t.flush(),null!==(n=null===(e=_n.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=_n.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=_n.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Pn,Cn,En,Ge]),e.useEffect(()=>{var t,e;if(m){if(C&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(m[0][e])){const n=[];for(const t of m){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=jn.current)||void 0===t||t.setBoundedData(n))}}null===(e=jn.current)||void 0===e||e.setBoundedData(m)}},[m,C]);const{hoverHandlerRef:Tn,hoverLeaveRef:Dn,onPointerMove:Ln,onPointerLeave:On}=Le;Tn.current=t=>{if(!Qe)return;const e=Je.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ve.left,o=t.clientY-n.top-Ve.top;if(0>i||i>Ke||0>o||o>Ze)return void(sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&(Ot(null),Ee.current=!0),Ge()));const r=_n.current;if(!r||0===r.scene.length)return;const s=at(r.scene,i,o,It,r.quadtree,r.maxPointRadius);if(!s)return void(sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&Ot(null),Ge()));const l=an(s.datum||{},s.x,s.y);if("multi"===Wt&&r.scene.length>0&&r.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=ct(t.path,e,n);if(null===r)continue;const s=vt(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=ct(t.topPath,e,n);if(null===r)continue;const s=vt(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.topPath[s][0],y:r,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(r.scene,s.x,It),e=r.scales.y.invert,n=r.scales.x.invert;if(t.length>0){const i=n?n(s.x):s.x;l.xValue=i,l.xPx=s.x;const o=dn.current;l.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||o,datum:t.datum}))}}sn.current=l,ln.current=s.node,un(l),Ot&&(Ot(l),Ee.current=!0),Ge()},Dn.current=()=>{sn.current&&(sn.current=null,ln.current=null,un(null),Ot&&(Ot(null),Ee.current=!0),Ge())};const Nn=e.useRef(()=>{});Nn.current=t=>{if(!Nt)return;const e=Je.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ve.left,o=t.clientY-n.top-Ve.top;if(0>i||i>Ke||0>o||o>Ze)return void Nt(null);const r=_n.current;if(!r||0===r.scene.length)return void Nt(null);const s=at(r.scene,i,o,It,r.quadtree,r.maxPointRadius);Nt(s?an(s.datum||{},s.x,s.y):null)};const $n=e.useCallback(t=>Nn.current(t),[]),In=e.useRef(-1),Wn=e.useRef(null),Rn=e.useRef(null),zn=e.useCallback(t=>{const e=_n.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Rn.current&&Rn.current.version===n)i=Rn.current.graph;else{const t=function(t){var e,n,i,o;const r=[];for(const s of t)switch(s.type){case"point":r.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(e=s.group)&&void 0!==e?e:"_default"});break;case"line":{const t=s,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)r.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:i});break}case"area":{const t=s,e=Array.isArray(t.datum)?t.datum:[],n=null!==(i=t.group)&&void 0!==i?i:"_default";for(let i=0;t.topPath.length>i&&e.length>i;i++)r.push({x:t.topPath[i][0],y:t.topPath[i][1],datum:e[i],shape:"circle",group:n});break}case"rect":r.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=s.group)&&void 0!==o?o:"_default"});break;case"heatcell":r.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:"_default"})}return r.sort((t,e)=>t.x-e.x||t.y-e.y),r}(e.scene);if(0===t.length)return;i=mt(t),Rn.current={version:n,graph:i}}const o=In.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),In.current=0;const e=i.flat[0];Wn.current={shape:e.shape,w:e.w,h:e.h};const n=wt(e);return sn.current=n,un(n),Ot&&Ot(n),void Ge()}const r=xt(i,o),s=bt(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return In.current=-1,Wn.current=null,sn.current=null,ln.current=null,un(null),Ot&&Ot(null),void Ge();In.current=s;const l=i.flat[s];Wn.current={shape:l.shape,w:l.w,h:l.h};const a=wt(l);sn.current=a,un(a),Ot&&Ot(a),Ge()},[Ot,Ge]),Yn=e.useCallback(t=>{In.current=-1,Wn.current=null,Ln(t)},[Ln]);Xe.current=()=>{var t,e;Ye.current=0;const n=Je.current,i=tn.current;if(!n||!i)return;const o=_n.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(Oe.current?r+1e6:r),l=!Oe.current&&s,a=Ee.current||s;a&&!l&&o.computeScene({width:Ke,height:Ze});const c=He(),u=function(t){if(!t)return yn;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||l||n||r?{axisStroke:a||yn.axisStroke,tickText:s||yn.tickText,crosshair:s?pn(s,"66"):yn.crosshair,hoverFill:c?pn(c,"4D"):yn.hoverFill,hoverStroke:s?pn(s,"99"):yn.hoverStroke,pointRing:c||yn.pointRing,primary:r||yn.primary}:yn}(n);dn.current=u.primary;const d=null!==(t=null==le?void 0:le.threshold)&&void 0!==t?t:5e3,h=le&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=Fe(n,$e,Ve,c);if(t){if(t.clearRect(-Ve.left,-Ve.top,$e[0],$e[1]),h&&(t.globalAlpha=null!==(e=null==le?void 0:le.dimOpacity)&&void 0!==e?e:.5),"transparent"!==q&&!qt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=q||(e&&"transparent"!==e?e:null);i&&(t.fillStyle=i,t.fillRect(-Ve.left,-Ve.top,$e[0],$e[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ke,Ze),t.clip()),Kt&&o.scales)for(const e of Kt)t.save(),e(t,o.scene,o.scales,{width:Ke,height:Ze}),t.restore();const i=fn[y];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:Ke,height:Ze});t.restore(),h&&(t.globalAlpha=1)}}{const t=Fe(i,$e,Ve,c);if(t&&(t.clearRect(-Ve.left,-Ve.top,$e[0],$e[1]),Qe&&sn.current&&o.scales&&function(t,e,n,i,o,r,s){var l;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(l=e.xPx)&&void 0!==l?l:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,sn.current,Ke,Ze,"object"==typeof Qe?Qe:{},ln.current,u),ln.current&&Array.isArray(Dt))){const e=Dt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const s=n.group;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?i.style(n.datum):i.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,ln.current,e,u)}}a&&n&&n.setAttribute("aria-label",ye(o.scene,y+" chart"));const f=Ee.current;if(Ee.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!on||t(on.x.domain()[0])!==t(o.scales.x.domain()[0])||t(on.x.domain()[1])!==t(o.scales.x.domain()[1])||t(on.y.domain()[0])!==t(o.scales.y.domain()[0])||t(on.y.domain()[1])!==t(o.scales.y.domain()[1])||on.x.range()[0]!==o.scales.x.range()[0]||on.x.range()[1]!==o.scales.x.range()[1]||on.y.range()[0]!==o.scales.y.range()[0]||on.y.range()[1]!==o.scales.y.range()[1])&&rn(o.scales),ve){const t=o.getData(),e="function"==typeof A?A:t=>t[A||"x"],n="function"==typeof M?M:t=>t[M||"y"];kn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),An(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Rt&&Rt.length>0&&nn(t=>t+1),(null==le?void 0:le.showBadge)&&xn(!!h),(l||null!=o.activeTransition||o.hasActivePulses)&&(Ye.current=requestAnimationFrame(()=>Xe.current()))},e.useEffect(()=>(Ge(),()=>{var t;null===(t=jn.current)||void 0===t||t.clear()}),[Ge]),e.useEffect(()=>{Ee.current=!0,Ge()},[y,Ke,Ze,kt,q,U,Kt,Ge]),At(le,_n,Ee,Ge,vn,xn);const Bn=e.useMemo(()=>{if(Pt||Et)return;const t=_n.current;return(null==t?void 0:t.xIsDate)&&on?hn(on.x.domain()):void 0},[Pt,Et,on]),Fn=Pt||Et||Bn,Hn=Qe&&cn?Lt?Lt(cn):t.jsx(mn,{hover:cn}):null,Xn=Hn?t.jsx(De,{x:cn.x,y:cn.y,containerWidth:Ke,containerHeight:Ze,margin:Ve,className:"stream-frame-tooltip",children:Hn}):null,Gn=Wn.current,Vn=t.jsx(Te,{active:In.current>=0,hoverPoint:cn,margin:Ve,size:$e,shape:null==Gn?void 0:Gn.shape,width:null==Gn?void 0:Gn.w,height:null==Gn?void 0:Gn.h}),qn=(t,e,n,i)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:{key:void 0,fn:null},Un=qn(A,I,"__semiotic_resolvedX","__semiotic_resolvedTime"),Kn=qn(M,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),Zn=Un.key,Qn=Kn.key,Jn=Rt&&Rt.length>0,ti=t=>{if(!t||!Jn||!Un.fn&&!Kn.fn)return t;let e=!1;const n=t.map(t=>{const n=Un.fn&&Un.key&&!(Un.key in t),i=Kn.fn&&Kn.key&&!(Kn.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[Un.key]=Un.fn(t)),i&&(o[Kn.key]=Kn.fn(t)),o});return e?n:t};if(de){const e=_n.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:Ke,height:Ze}));const n=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],i=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,s=Fn||(()=>{if((null==e?void 0:e.xIsDate)&&i)return hn(i.x.domain())})();return t.jsxs("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:$e[0],height:$e[1]},children:[t.jsx(je,{summary:Ae}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:$e[0],height:$e[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Ue}),t.jsxs("g",{transform:`translate(${Ve.left},${Ve.top})`,children:[q&&t.jsx("rect",{x:0,y:0,width:Ke,height:Ze,fill:q}),Zt&&i&&Zt.map((e,o)=>t.jsx(p.Fragment,{children:e(n,i,{width:Ke,height:Ze})},"svgpre-"+o)),n.map((e,n)=>function(e,n){var i,o,r;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+n)}case"area":{const r=e;if(0===r.topPath.length)return null;const s=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),l=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:`M${s}L${l}Z`,fill:ue(r.style.fill),fillOpacity:null!==(o=null!==(i=r.style.fillOpacity)&&void 0!==i?i:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+n)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:ue(i.style.fill),opacity:null!==(r=i.style.opacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"point-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"rect-"+n)}case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,r,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),l=.299*o+.587*r+.114*s>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.jsx("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:a+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+n)}case"candlestick":{const i=e,o=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),s=i.isUp?i.upColor:i.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.jsx("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(e,n)).filter(Boolean)]})]}),t.jsx(ce,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:i,showAxes:kt,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:s,yFormat:Ct||Tt,showGrid:Yt,title:Qt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,foregroundGraphics:qe,marginalGraphics:ve,xValues:[],yValues:[],annotations:Rt,svgAnnotationRules:zt,annotationFrame:0,xAccessor:Zn,yAccessor:Qn,annotationData:ti(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof E?E:void 0,linkedCrosshairName:Se,linkedCrosshairSourceId:_e})]})}return t.jsxs("div",{ref:Ne,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":$e[0],height:X?"100%":$e[1],overflow:"visible"},onKeyDown:zn,children:[ke&&t.jsx(Pe,{tableId:ze}),ke&&t.jsx(Me,{scene:null!==(l=null===(s=_n.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],chartType:y+" chart",tableId:ze,chartTitle:"string"==typeof Qt?Qt:void 0}),t.jsx(je,{summary:Ae}),t.jsxs("div",{role:"img","aria-label":we||("string"==typeof Qt?Qt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Qe?Yn:void 0,onMouseLeave:Qe?On:void 0,onClick:Nt?$n:void 0,children:[Ue&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:$e[0],height:$e[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Ve.left},${Ve.top})`,children:Ue})}),t.jsx(se,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:on,showAxes:kt,axes:St,showGrid:Yt,xFormat:Fn,yFormat:Ct||Tt}),t.jsx("canvas",{ref:Je,"aria-label":ye(null!==(c=null===(a=_n.current)||void 0===a?void 0:a.scene)&&void 0!==c?c:[],y+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:tn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(Ce,{hoverPoint:cn}),t.jsx(ce,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,scales:on,showAxes:kt,axes:St,xLabel:Mt,yLabel:_t,yLabelRight:jt,xFormat:Fn,yFormat:Ct||Tt,showGrid:Yt,title:Qt,legend:Bt,legendHoverBehavior:Ft,legendClickBehavior:Ht,legendHighlightedCategory:Xt,legendIsolatedCategories:Gt,legendPosition:Vt,foregroundGraphics:qe,marginalGraphics:ve,xValues:bn,yValues:wn,annotations:Rt,svgAnnotationRules:zt,annotationFrame:en,xAccessor:Zn,yAccessor:Qn,annotationData:ti(null===(u=_n.current)||void 0===u?void 0:u.getData()),pointNodes:null===(d=_n.current)||void 0===d?void 0:d.scene.filter(t=>"point"===t.type),curve:"string"==typeof E?E:void 0,underlayRendered:!0,linkedCrosshairName:Se,linkedCrosshairSourceId:_e}),(te||ee)&&t.jsx(b,{width:Ke,height:Ze,totalWidth:$e[0],totalHeight:$e[1],margin:Ve,dimension:null!==(h=null==te?void 0:te.dimension)&&void 0!==h?h:"xy",scales:on,onBrush:null!=ee?ee:()=>{},binSize:D,snap:null==te?void 0:te.snap,binBoundaries:null!==(f=null==te?void 0:te.binBoundaries)&&void 0!==f?f:"bar"===y?null===(g=_n.current)||void 0===g?void 0:g.getBinBoundaries():void 0,snapDuring:null==te?void 0:te.snapDuring,streaming:"streaming"===v}),(null==le?void 0:le.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===le.badgePosition?{top:4,left:4}:"bottom-left"===le.badgePosition?{bottom:4,left:4}:"bottom-right"===le.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:vn?"#dc3545":"#28a745",color:"white"}),children:vn?"STALE":"LIVE"}),Vn,Xn]})]})});xn.displayName="StreamXYFrame";const bn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},kn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class wn{constructor(t){this.capacity=t,this.particles=Array(t),this._freeIndices=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[e]=t-1-e}spawn(t){const e=this._freeIndices.pop();if(void 0===e)return null;const n=this.particles[e];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}step(t,e,n,i){var o;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(!l||!l.bezier){s.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[s.edgeIndex])&&void 0!==o?o:1;s.t+=t*e*a*(l.bezier.circular?.3:1),1>s.t?An(l.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1;this._freeIndices.length=0;for(let t=this.capacity-1;t>=0;t--)this._freeIndices.push(t)}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)e.length>n?this.particles[n]=e[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=t}}function An(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,s=e*r,l=Math.min(Math.floor(s),r-1),a=s-l,[c,u,d,h]=t[l];Sn(c,u,d,h,a,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const t=f/y;o.x+=-g/y*n*i*2,o.y+=t*n*i*2}}(t.segments,e,n,t.halfWidth,i);if(!t.points)return i.x=0,void(i.y=0);const[o,r,s,l]=t.points;Sn(o,r,s,l,e,i);const a=l.x-o.x,c=l.y-o.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;i.x+=-c/u*n*t.halfWidth*2,i.y+=e*n*t.halfWidth*2}}function Sn(t,e,n,i,o,r){const s=1-o,l=s*s,a=l*s,c=o*o,u=c*o;r.x=a*t.x+3*l*o*e.x+3*s*c*n.x+u*i.x,r.y=a*t.y+3*l*o*e.y+3*s*c*n.y+u*i.y}function Mn(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function _n(t,e){var n,i=[],o=[],r=[],s={},l=[];function a(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;l[t].length>e;e++){var h=s[i=l[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),l=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,s[a]=-1,l[a]=[];var c,u=0,d=[],h=[];function f(e){var a=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=i[y]=u,o[y]=!0,u+=1,a.push(y),c.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||l[e].push(s[y])}r[e]=g}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(g=a.length-1;g>=0;--g){var x=a[g];if(o[x]=!1,p.push(x),v.push(l[x]),m+=l[x].length,s[x]=d.length,x===e){a.length=g;break}}d.push(p);var b=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)b[--m]=v[g][k];h.push(b)}c.pop()}}}for(a=0;e>a;++a)0>n[a]&&f(a);for(a=0;h.length>a;a++){var g=h[a];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[a]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var l=0;o[s].length>l;l++)r>o[s][l]&&(r=o[s][l],n=s);var a=o[n];if(!a)return!1;var c=t.map(function(t,e){return-1===a.indexOf(e)?[]:t.filter(function(t){return-1!==a.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return i}function jn(t){return t.y0-t.y1>0?"up":"down"}function Pn(t,e){return e(t.source)==e(t.target)}function Cn(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function En(t){return t.target.x0-t.source.x1}function Tn(t,e){var n=Ln(t),i=En(e)/Math.tan(n);return"up"==jn(t)?t.y1-i:t.y1+i}function Dn(t,e){var n=Ln(t),i=En(e)/Math.tan(n);return"up"==jn(t)?t.y1+i:t.y1-i}function Ln(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function On(t,e){return e(t)}function Nn(t){return In(t.source)}function $n(t){return In(t.target)}function In(t){return(t.y0+t.y1)/2}function Wn(t){return t.virtual?0:t.value}function Rn(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Pn(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Pn(t,e)?i+1:i}),n+i}function zn(t){return t.target.depth}function Yn(t,e){return t.sourceLinks.length?t.depth:e-1}function Bn(t,e){return t.y0-e.y0}function Fn(t,e){return e.y0-t.y0}function Hn(t,e){return t.y1-e.y1}function Xn(t,e){return e.y1-t.y1}function Gn(t,e){return qn(t.source,e.source)||t.index-e.index}function Vn(t,e){return qn(t.target,e.target)||t.index-e.index}function qn(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Un(t,e){return Kn(t)==Kn(e)?"bottom"==t.circularLinkType?Fn(t,e):Bn(t,e):Kn(e)-Kn(t)}function Kn(t){return t.target.column-t.source.column}function Zn(t,e){return Qn(t)==Qn(e)}function Qn(t){return t.y0-t.y1>0?"up":"down"}function Jn(t,e,n,i,o){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=l.min(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),ti(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),ti(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Pn(t,e)&&Cn(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Fn:Bn);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Xn:Hn),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function ti(t,e,n){t.sort(Un);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Pn(t,e)&&Cn(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var l=i[s];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&ei(t,l)){var a=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ei(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ni(t){return function(){return t}}function ii(t){return t.index}function oi(t){return t.nodes}function ri(t){return t.links}function si(t,e,n){var i=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var l=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=In(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=In(t.target)*e,i+=e}}),i>0?o/i:NaN);l.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=l.get(t),i=l.get(e),o=n.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Rn(e,n)-Rn(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Rn(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function li(t,e,n,i,o,r){var s=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var a=1,c=r;c>0;--c)u(a*=.99,n),d();function u(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rn(o,n)>0){var c=l.mean(o.sourceLinks,$n),u=l.mean(o.targetLinks,Nn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-In(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var f=l.mean(o.sourceLinks,$n),g=l.mean(o.targetLinks,Nn),y=((f&&g?(f+g)/2:f||g)-In(o))*e;o.y0+=y,o.y1+=y}})})}function d(){s.forEach(function(n){var r,s,l,a=t.y0,c=n.length;for(n.sort(e||qn),l=0;c>l;++l)(s=a-(r=n[l]).y0)>0&&(r.y0+=s,r.y1+=s),a=r.y1+i;if((s=a-i-t.y1)>0)for(a=r.y0-=s,r.y1-=s,l=c-2;l>=0;--l)(s=(r=n[l]).y1+o-a)>0&&(r.y0-=s,r.y1-=s),a=r.y0})}}function ai(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vn),t.targetLinks.sort(Gn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function ci(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=ii,c=Yn,u=void 0,d=32,h=2,f=oi,g=ri;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return l.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=Mn(n,i)),"object"!=typeof o&&(o=t.target=Mn(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(f,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,l=r.target.index;i[s]||(i[s]=[]),i[l]||(i[l]=[]),-1===i[s].indexOf(l)&&i[s].push(l)}var a=_n(i);a.sort(function(t,e){return t.length-e.length});var c={};for(o=0;a.length>o;o++){var u=a[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(f,u),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){On(t,e)!=On(o.source,e)&&On(t,e)!=On(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Pn(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(l.sum(t.sourceLinks,Wn),l.sum(t.targetLinks,Wn)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==l?s:s+1,l=e(t)==l?l:e(t),t.column=s})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(f,u,c);var g=r;if(null!==s){var y=l.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=l.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=l.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=l.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/l.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=l.max(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,g,o),si(f,u,a),li(f,u,a,g,g,d),ai(f),Jn(f,a,h,10,8),si(f,u,a),li(f,u,a,g,g,d),ai(f),Jn(f,a,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return On(n.source,e)==On(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Zn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Tn(e,t);return t.y1-n}if(e.target.column>t.target.column)return Tn(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(f,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return On(n.target,e)==On(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Zn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Dn(e,t);return t.y0-n}if(e.source.column>t.source.column)return Dn(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(f,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=l.min(e,function(t){return t.y0}),s=l.max(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function c(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),Jn(f,a,h,10,8)}(y),y}return y.update=function(t){return ai(t),Jn(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(r=+t,y):r},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ni(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:ni(t),y):g},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:ni(t),y):a},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ni(t),y):c},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(d=+t,y):d},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],y):[[t,e],[n,i]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],y):[n-t,i-e]},y}const ui=t=>{let e,n,i,o,r,s,l,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,l=d.interpolateNumber(r,s),a=l(.5),c=l(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,l=d.interpolateNumber(e,n),i=l(.5),o=l(.5),r=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${s} ${n},${s}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function di(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),a=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-a},${s-n}L${r-a},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,l=o.targetX,a=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${a-h*n+h*f}L${u-i+f},${a-h*n}L${l},${a-h*n}L${l},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const hi=new Set,fi=new WeakMap;function gi(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=fi.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,fi.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;hi.has(t)||(hi.add(t),console.warn(`[Semiotic] "${e}" 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(t,n,i)}});return n.set(e,i),i}const yi={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(zn))-1:0},justify:Yn},pi={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,l,a,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=ci().extent(m).links(v).nodes(p).nodeAlign(yi[h]||Yn).nodeId(t=>t.id).nodeWidth(f).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(a=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==a?a:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=t.source,n=t.target,i="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof n&&null!==n?n.id:n+"",r=k.get(t._edgeKey?t._edgeKey:`${i}\0${o}`);if(r){r.y0=t.y0,r.y1=t.y1,r.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,r.circular=!!t.circular,r.circularPathData=t.circularPathData,r._circularWidth=t._circularWidth,r._circularStub=t._circularStub,r.path=t.path,r.circularLinkType=t.circularLinkType,r.direction=d;const e=b.get(i),n=b.get(o);e&&(r.source=e),n&&(r.target=n)}}},buildScene(t,e,n,i){var o,r,l,a,c,u;const d="vertical"===n.orientation?"down":"right",h=n.nodeStyle,f=n.edgeStyle,g=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,y=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s.schemeCategory10,v=new Map;t.forEach((t,e)=>{v.set(t.id,p[e%p.length])});const m=[],x=[],b=[],k=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=h?h(gi(e,"nodeStyle")):{},o={fill:i.fill||v.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};k.set(e.id,("string"==typeof o.fill?o.fill:null)||v.get(e.id)||"#4d430c"),m.push("down"===d?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const w=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of w){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";o="function"==typeof y?y(t)||o:"target"===y?k.get(i.id)||v.get(i.id)||o:k.get(e.id)||v.get(e.id)||o;const s=f?f(gi(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=s.fill||o;x.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:null!==(a=s.fillOpacity)&&void 0!==a?a:g,stroke:"none",opacity:s.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),x.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:null!==(c=s.fillOpacity)&&void 0!==c?c:g,stroke:"none",opacity:s.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?di(t):ui(t),!d)continue;const h={fill:s.fill||o,fillOpacity:null!==(u=s.fillOpacity)&&void 0!==u?u:g,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};x.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:h,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let s,l,a;"down"===d?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,a="middle"):(i[0]/2>n.x0+t/2?(s=n.x0-6,a="end"):(s=n.x1+6,a="start"),l=n.y0+o/2),b.push({x:s,y:l,text:r+"",anchor:a,baseline:"middle",fontSize:11})}}var A;return{sceneNodes:m,sceneEdges:x,labels:b}}},vi={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=i[0]/2,a=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=mi(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=xi(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=xi(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=a+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=l+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:f?40:g,p=bi(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t);if(y>0){const n=h.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*v(t))).force("center",h.forceCenter(l,a).strength(.8)).force("x",h.forceX(l).strength(.15)).force("y",h.forceY(a).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",n),i.force("link").links(t)}f?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;y>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=v(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,l,a,c,u,d;const h=n.nodeStyle,f=n.edgeStyle,g=bi(n.nodeSize,n.nodeSizeRange,t),y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:s.schemeCategory10,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=g(gi(e,"nodeSize")),i=h?h(gi(e,"nodeStyle")):{},s={fill:i.fill||p.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:2,opacity:i.opacity};v.push({type:"circle",cx:e.x,cy:e.y,r:t,style:s,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),i="object"==typeof t.target?t.target:b.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=f?f(gi(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=n.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(u=o.strokeWidth)&&void 0!==u?u:1,opacity:null!==(d=o.opacity)&&void 0!==d?d:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=g(gi(n,"nodeSize"));x.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:m,labels:x}}};function mi(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function xi(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function bi(t,e,n){var i,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=e||[5,20],a=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===a.length)return()=>s[0];const c=null!==(i=l.min(a))&&void 0!==i?i:0,u=null!==(r=l.max(a))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?s[0]:d(i)}}const ki=s.schemeCategory10,wi={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,l=Math.min(i[0],i[1])/2,a=l-r,u=i[0]/2,d=i[1]/2,h=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=y.get("string"==typeof t.source?t.source:t.source.id),i=y.get(e);if(void 0===n||void 0===i)continue;const o=h(t);v[n][i]=o}const m=f.chord().padAngle(o);s&&m.sortGroups(s);const x=m(v),b=x.groups,k=c.arc().innerRadius(a).outerRadius(l);for(const e of b){const n=t[e.index],i=k.centroid(e);n.x=i[0]+u,n.y=i[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const A=new Map;for(const t of e)A.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,i=t[e.target.index].id,o=A.get(`${n}\0${i}`)||A.get(`${i}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,i){var o,r,s,l;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,g=i[1]/2,y=n.nodeStyle,p=n.edgeStyle,v=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ki,x=new Map;t.forEach((t,e)=>{x.set(t.id,m[e%m.length])});const b=f.ribbon().radius(d),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=y?y(gi(n,"nodeStyle")).fill||x.get(n.id)||m[e%m.length]:x.get(n.id)||m[e%m.length];const s=y?y(gi(n,"nodeStyle")):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};k.push({type:"arc",cx:h,cy:g,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=b(e);if(!i)continue;const o=Ai(i,h,g);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)a=p(gi(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===v&&n?a=x.get(n.id)||a:e&&(a=x.get(e.id)||a)}const u=p?p(gi(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,i=u+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;A.push({x:h+Math.cos(s)*i,y:g+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function Ai(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const Si=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Mi(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}function _i(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function ji(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Pi(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Si}function Ci(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Ei(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Ti={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,l=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},d=a.hierarchy(r,l);d.sum(u),d.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,f]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.tree();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=a.cluster();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(d,n,h,f);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,l=null!==(r=e.paddingTop)&&void 0!==r?r:0,c=a.treemap().size([n,i]).tile(a.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;a.pack().size([n,i]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,i){var o;a.partition().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const i=g[e],r={id:_i(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Di(r,i,n):"treemap"===s||"partition"===s?Li(r,i):"circlepack"===s&&Oi(r,i),r.__hierarchyNode=i,t.push(r),y.set(i,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,l,a,c,u,d,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,x=i[0]/2,b=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;m&&(t+=x,i+=b);const r=o(gi(e,"nodeStyle"));let a=r.fill||Ci(n);if(n.colorByDepth&&void 0!==e.depth){const t=Pi(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,l=i.x,a=i.y;m&&(o+=x,s+=b,l+=x,a+=b);const f=Ei(o,s,l,a,v),g=r(gi(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=ji(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,l=n.y;if(m&&(s+=x,l+=b),m){const t=s-x,e=l-b,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=l+e/n*10,r=0>t?"end":"start"):(i=s,o=l-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=l):(i=s,o=l+k+14,r="middle");p.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,s,l,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const l=i(gi(n,"nodeStyle"));let a=l.fill||Ci(e);if(e.colorByDepth&&void 0!==n.depth){const t=Pi(e);a=t[n.depth%t.length]}const u={fill:a,stroke:l.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ji(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(gi(c,"nodeStyle")).fill||Ci(e);if(e.colorByDepth&&void 0!==c.depth){const t=Pi(e);g=t[c.depth%t.length]}const y="string"==typeof g?Mi(g):null!==(a=null===(l=e.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==a?a:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,l,a,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(gi(n,"nodeStyle"));let c=a.fill||Ci(e);if(e.colorByDepth&&void 0!==n.depth){const t=Pi(e);c=t[n.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=a.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ji(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=i(gi(o,"nodeStyle")).fill||Ci(e);if(e.colorByDepth&&void 0!==o.depth){const t=Pi(e);l=t[o.depth%t.length]}if(s){const n="string"==typeof l?Mi(l):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Di(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Li(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Oi(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Ni(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const $i={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,s;const l=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ni(n);y.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(a(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,d,h,p){const m=l(e);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 A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,M={id:n,depth:h,data:e,parentId:n},_=p?d/f(M)*S:d*S,j=c.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=j(w),C=g(M);for(let e=0;w.length>e;e++){const l=(P[e].startAngle+P[e].endAngle)/2,c=w[e],u=v(a(c)),d=r+_*Math.sin(l),f=s+_*Math.cos(l)*C;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:c}),y.metaMap.set(u,{ring:_,angle:l,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}}),t(c,u,d,f,_,h+1,!0)}A+=k}}(t,k,m,x,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,l,a,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=Ni(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of o)for(let o=0;r>o;o++){const l=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(gi(e,"nodeSize")),i=d?d(gi(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),n="object"==typeof t.target?t.target:v.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(gi(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Ni(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+l*a*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Ii={sankey:pi,force:vi,chord:wi,tree:Ti,cluster:Ti,treemap:Ti,circlepack:Ti,partition:Ti,orbit:$i};function Wi(t){return Ii[t]}class Ri{constructor(t){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=t,this.tensionConfig=Object.assign(Object.assign({},bn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new wn(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},bn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new wn(2e3))}ingestHierarchy(t,e){this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e),this._boundedPrevSnapshot=null}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,l="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this._boundedPrevSnapshot=new Map;for(const[t,e]of this.nodes)0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1||this._boundedPrevSnapshot.set(t,{x0:e.x0,x1:e.x1,y0:e.y0,y1:e.y1});this._boundedEdgeSnapshot=new Map;for(const[,t]of this.edges)t.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,{y0:t.y0,y1:t.y1,sankeyWidth:t.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},zi(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=a(n)+"",o=c(n)+"",r=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},zi(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},zi(o)),{data:n}));const s=`${i}\0${o}\0${t}`;this.edges.set(s,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:s})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,zi(e)),this.nodeTimestamps.set(e,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,zi(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,r=!0);const l=this.edgeKey(e,n),a=this.edges.get(l);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,s),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,s,l,a;const c=Wi(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const t=new Map;for(const l of u)if(void 0!==l._prevX0){const a=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);t.set(l.id,{x:(null!==(r=l._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(s=l._prevY0)&&void 0!==s?s:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(c.computeLayout(u,d,this.config,t),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of u)this.nodes.set(t.id,t);for(let t=0;d.length>t;t++){const e=d[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}const t=this._boundedPrevSnapshot;if(t&&t.size>0)for(const e of this.nodes.values()){const n=t.get(e.id);n&&(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||h.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=u.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1)),g=null!==(a=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==a?a:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const e=t[0]/2,n=t[1]/2;for(const t of this.nodes.values())t._prevX0=e,t._prevX1=e,t._prevY0=n,t._prevY1=n;for(const t of this.edges.values())t._prevY0=n,t._prevY1=n,t._prevSankeyWidth=0,t._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0;const y=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 t of y)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)y.has(t)||this.removedNodes.add(t);for(const t of p)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)p.has(t)||this.removedEdges.add(t);(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=y,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(t){const e=Wi(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:s}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=s}get isAnimating(){const t=Wi(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Wi(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(i,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=H(t,this.transition),n=F(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=X(t._prevX0,t._targetX0,n),t.x1=X(t._prevX1,t._targetX1,n),t.y0=X(t._prevY0,t._targetY0,n),t.y1=X(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&(t._prevSankeyWidth>0||t._introFromZero)&&(t.y0=X(t._prevY0,t._targetY0,n),t.y1=X(t._prevY1,t._targetY1,n),t.sankeyWidth=X(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const t=this._boundedPrevSnapshot;for(const e of this.nodes.values()){const n=null==t?void 0:t.get(e.id);n&&0===e.x0&&0===e.x1&&0===e.y0&&0===e.y1?(e._prevX0=n.x0,e._prevX1=n.x1,e._prevY0=n.y0,e._prevY1=n.y1):(e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1)}const e=this._boundedEdgeSnapshot;for(const t of this.edges.values()){if(e&&0===t.sankeyWidth){const n=e.get(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`);if(n){t._prevY0=n.y0,t._prevY1=n.y1,t._prevSankeyWidth=n.sankeyWidth;continue}}t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth),t._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,r=n.x0,s=d.interpolateNumber(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:s(.5)},{x:t.y1,y:s(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,s=d.interpolateNumber(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:s(.5),y:t.y0},{x:s(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),i=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*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="down"===t.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 t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,i,o,r;const s=this.config.pulse;if(!s)return;const l=null!==(e=s.duration)&&void 0!==e?e:500,a=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=s.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const o=t-i;l>o&&(e._pulseIntensity=1-o/l,e._pulseColor=a,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,s="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!s)continue;const c=this.edgeTimestamps.get(`${i}\0${s}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=a)}}applyDecay(){var t,e;const n=this.config.decay;if(!n)return;const i=this.nodeTimestamps.size;if(1>=i)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const o=this._decaySortedNodes,r=new Map;for(let t=0;o.length>t;t++)r.set(o[t][0],t);for(const o of this.sceneNodes){const s=o.id;if(!s)continue;const l=r.get(s);if(void 0===l)continue;const a=Y(n,l,i),c=null!==(e=null===(t=o.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*a})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const i=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,i),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const i=this.config.thresholds;if(!i)return;const o=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",r=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const a=i.metric(l);let c=null;void 0===i.critical||i.critical>a?void 0===i.warning||i.warning>a||(c=o):c=r,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),s&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const i=this.nodes.get(t);if(!i)return null;const o=i.data?Object.assign({},i.data):{};return i.data=e(null!==(n=i.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var i;const o=this.config.valueAccessor,r="function"==typeof o?o:o?t=>t[o]:t=>t.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){s.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(i=o.data)&&void 0!==i?i:{});const t=r(o.data);null!=t&&(o.value=Number(t))}return s.length>0&&this.layoutVersion++,s}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];if(void 0===e){const e=this.config.edgeIdAccessor;if(!e)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const i="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,o]of this.edges)o.data&&i(o.data)===t&&n.push(e)}else for(const[i,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(i);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);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 zi(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Yi(t,e,n,i,o=30){let r=null,s=o,l=1/0;for(const e of t){const t=Bi(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(r=t,l=n)}else s>t.distance&&(r=t,s=t.distance)}if(r)return r;for(const t of e){const e=Vi(t,n,i);e&&s>e.distance&&(r=e,s=e.distance)}return r}function Bi(t,e,n,i=30){switch(t.type){case"circle":return function(t,e,n,i=30){const o=e-t.cx,r=n-t.cy,s=Math.sqrt(o*o+r*r);return s>ot(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:s}}(t,e,n,i);case"rect":return function(t,e,n){const i=it(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;const s=lt(Math.atan2(o,i)),l=lt(t.startAngle),a=lt(t.endAngle);if(l>a?s>=l||a>=s:s>=l&&a>=s){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let Fi=null,Hi=null;function Xi(){return Hi||(Fi=document.createElement("canvas"),Fi.width=1,Fi.height=1,Hi=Fi.getContext("2d")),Hi}function Gi(t){if(t._cachedPath2D&&t._cachedPath2DSource===t.pathD)return t._cachedPath2D;try{return t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD,t._cachedPath2D}catch(t){return null}}function Vi(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Gi(t),s=Xi();if(!r||!s)return null;try{if(s.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,s="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&s?(r.x1+s.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const l=s.lineWidth;s.lineWidth=10;const a=s.isPointInStroke(r,e,n);if(s.lineWidth=l,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const l=t.x1+s*i,a=t.y1+s*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Gi(t),o=Xi();if(!i||!o)return null;try{if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const r=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(i,e,n);if(o.lineWidth=r,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function qi(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,labels:l,title:a,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",foregroundGraphics:y,sceneNodes:v,annotations:m,svgAnnotationRules:x}=e;return t.jsxs(t.Fragment,{children:[t.jsxs("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t.jsx("title",{children:"string"==typeof a?a:"Network Chart"}),t.jsx("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),t.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[l.map((e,n)=>t.jsx("text",{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"},children:e.text},"label-"+n)),m&&m.filter(t=>"widget"!==t.type).map((e,o)=>{if(x){const r=x(e,o,{width:n,height:i,sceneNodes:v});if(r)return t.jsx(p.Fragment,{children:r},"annotation-"+o)}return null}),y]}),a&&"string"==typeof a?t.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:a}):a?t.jsx("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,Lt({legend:c,totalWidth:o,totalHeight:r,margin:s,legendPosition:g,title:a,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})]}),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&v).map((e,n)=>{var i,o,r,l,a,c,u,d,h;const f=v.find(t=>{var n,i,o,r,s;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(s=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===e.nodeId});if(!f)return null;const g=s.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=s.top+(null!==(r=f.cy)&&void 0!==r?r:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),p=null!==(a=e.dx)&&void 0!==a?a:0,m=null!==(c=e.dy)&&void 0!==c?c:-16,x=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t.jsx("div",{style:{position:"absolute",left:g+p-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function Ui(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function Ki(t,e){var n,i,o,r,s,l;if(!e.pathD)return;t.save();const a=Ui(e);if(e.style.fill&&"none"!==e.style.fill){const s=e._gradient;if(s){const o=t.createLinearGradient(s.x0,0,s.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l="string"==typeof e.style.fill?e.style.fill:"#999",a=ze(t,l)||l;o.addColorStop(0,1===s.from?a:"transparent"),o.addColorStop(1,1===s.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.5;t.fill(a)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(s=e.style.strokeWidth)&&void 0!==s?s:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(a)),t.restore()}function Zi(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=ze(t,o)||o,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(i=e.style.strokeWidth)&&void 0!==i?i:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Qi(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=Ui(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(s)),t.restore()}function Ji(t,e){var n,i;if(!e.pathD)return;t.save();const o=Ui(e),r=e.style.stroke||"#999";t.strokeStyle=ze(t,r)||r,t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}qi.displayName="NetworkSVGOverlay";const to={top:20,right:80,bottom:20,left:80},eo={top:40,right:40,bottom:40,left:40},no=new Set(["chord","force","circlepack","orbit"]),io=[800,600],oo={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 ro({data:e}){var n,i,o,r,s,l;if("edge"===e.nodeOrEdge){const n=e.data;return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""]})]})}const a=e.data,c=null==a?void 0:a.__hierarchyNode;if(c){const e=[];let s=c;for(;s;){const t=null!==(r=null!==(i=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(o=s.data)||void 0===o?void 0:o.id)&&void 0!==r?r:a.id;null!=t&&e.unshift(t+""),s=s.parent}e.length>1&&e.shift();const l=e.length-1;return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsx("div",{children:e.map((e,n)=>t.jsxs("span",{children:[n>0&&t.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===l?t.jsx("strong",{children:e}):t.jsx("span",{style:{opacity:.7},children:e})]},n))}),null!=a.value&&a.value>0&&t.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof a.value?a.value.toLocaleString():a.value+""})]})}const u=((null===(s=a.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),d=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.jsxs("div",{className:"semiotic-tooltip",style:oo,children:[t.jsx("div",{style:{fontWeight:600},children:a.id}),null!=a.value&&a.value>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""]}),u>0&&t.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const so=e.forwardRef(function(n,i){var o,r,s,l,a,u,d,h,f,g,y,p,v,m,x,b,k;const{chartType:w,nodes:A,edges:M,data:_,initialEdges:j,nodeIDAccessor:P="id",sourceAccessor:C="source",targetAccessor:E="target",valueAccessor:T="value",edgeIdAccessor:D,childrenAccessor:L,hierarchySum:O,orientation:N="horizontal",nodeAlign:$="justify",nodePaddingRatio:I=.05,nodeWidth:W=15,iterations:z=300,forceStrength:Y=.1,padAngle:B=.01,groupWidth:F=20,sortGroups:H,edgeSort:X,treeOrientation:G="vertical",edgeType:V="curve",padding:q,paddingTop:U,tensionConfig:K,showParticles:Z=!1,particleStyle:Q,nodeStyle:J,edgeStyle:tt,colorBy:et,colorScheme:nt="category10",edgeColorBy:it="source",edgeOpacity:ot=.5,colorByDepth:rt=!1,nodeSize:st=8,nodeSizeRange:lt=[5,20],nodeLabel:at,showLabels:ct=!0,labelMode:ut,size:dt=io,responsiveWidth:ht,responsiveHeight:ft,margin:gt,className:yt,background:pt,enableHover:vt=!0,tooltipContent:kt,customHoverBehavior:wt,customClickBehavior:St,onObservation:Mt,chartId:_t,onTopologyChange:jt,annotations:Pt,svgAnnotationRules:Ct,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,title:$t,foregroundGraphics:It,backgroundGraphics:Wt,decay:Rt,pulse:zt,transition:Yt,animate:Bt,staleness:Ft,thresholds:Ht,accessibleTable:Xt=!0,description:Gt,summary:Vt,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:Jt,orbitShowRings:te,orbitAnimated:ee}=n,ne=no.has(w)?eo:to,ie=e.useRef(!0),oe=Be({sizeProp:dt,responsiveWidth:ht,responsiveHeight:ft,userMargin:gt,marginDefault:ne,foregroundGraphics:It,backgroundGraphics:Wt,animate:Bt,transitionProp:Yt,themeDirtyRef:ie}),{reducedMotionRef:re,responsiveRef:se,size:le,margin:ae,adjustedWidth:ce,adjustedHeight:he,resolvedForeground:fe,resolvedBackground:ge,transition:ye,introEnabled:ve,tableId:me,rafRef:xe,renderFnRef:be,scheduleRender:ke,currentTheme:we}=oe,Ae=e.useMemo(()=>Object.assign(Object.assign({},bn),K),[K]),Se=e.useMemo(()=>Object.assign(Object.assign({},kn),Q),[Q]),Me=e.useMemo(()=>{var t;return{chartType:w,nodeIDAccessor:P,sourceAccessor:C,targetAccessor:E,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:L,hierarchySum:O,orientation:N,nodeAlign:$,nodePaddingRatio:I,nodeWidth:W,iterations:z,forceStrength:Y,padAngle:B,groupWidth:F,sortGroups:H,edgeSort:X,treeOrientation:G,edgeType:V,padding:q,paddingTop:U,tensionConfig:Ae,showParticles:Z,particleStyle:Se,nodeStyle:J,edgeStyle:tt,nodeLabel:at,showLabels:ct,labelMode:ut,colorBy:et,colorScheme:nt,themeCategorical:null===(t=null==we?void 0:we.colors)||void 0===t?void 0:t.categorical,themeSemantic:S(we),edgeColorBy:it,edgeOpacity:ot,colorByDepth:rt,nodeSize:st,nodeSizeRange:lt,decay:Rt,pulse:zt,transition:ye,introAnimation:ve,staleness:Ft,thresholds:Ht,orbitMode:qt,orbitSize:Ut,orbitSpeed:Kt,orbitRevolution:Zt,orbitRevolutionStyle:Qt,orbitEccentricity:Jt,orbitShowRings:te,orbitAnimated:ee}},[w,P,C,E,T,L,O,N,$,I,W,z,Y,B,F,H,X,G,V,q,U,Ae,Z,Se,J,tt,at,ct,ut,et,nt,it,ot,rt,st,lt,Rt,zt,null==ye?void 0:ye.duration,null==ye?void 0:ye.easing,ve,Ft,Ht,qt,Ut,Kt,Zt,Qt,Jt,te,ee,we]),Ee=e.useRef(null),Le=e.useRef(0),Oe=e.useRef(null);Oe.current||(Oe.current=new Ri(Me));const[Ne,$e]=e.useState(null),[Ie,We]=e.useState(0),[Re,Ye]=e.useState(0),[Xe,Ge]=e.useState(!1),Ve=e.useRef(null),qe=e.useRef(new Map),Ue=e.useRef(0),Ke=e.useCallback(t=>{if("function"==typeof et)return et(t)+"";if("string"==typeof et&&t.data){const e=t.data[et];if(void 0!==e){if(!qe.current.has(e+"")){const t=Array.isArray(nt)?nt:R;qe.current.set(e+"",t[Ue.current++%t.length])}return qe.current.get(e+"")}}if(qe.current.has(t.id))return qe.current.get(t.id);const e=Array.isArray(nt)?nt:R,n=et?e[Ue.current++%e.length]:e[0];return qe.current.set(t.id,n),n},[et,nt]),Je=(null===(o=null==we?void 0:we.colors)||void 0===o?void 0:o.border)||(null===(r=null==we?void 0:we.colors)||void 0===r?void 0:r.secondary)||(null===(s=null==we?void 0:we.colors)||void 0===s?void 0:s.primary)||"#999",tn=e.useCallback(t=>{if("function"==typeof it)return it(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===it&&n?Ke(n):e?Ke(e):Je},[it,Ke,Je]),en=e.useCallback(t=>{if(!(null==Q?void 0:Q.colorBy))return tn(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Se.colorBy&&n?Ke(n):e?Ke(e):Je},[null==Q?void 0:Q.colorBy,Se.colorBy,Ke,tn,Je]),nn="sankey"===w&&Z||!!zt||null!==(a=null===(l=Oe.current)||void 0===l?void 0:l.isAnimating)&&void 0!==a&&a;e.useEffect(()=>{var t;null===(t=Oe.current)||void 0===t||t.updateConfig(Me),ie.current=!0,ke()},[Me,ke]),e.useEffect(()=>{var t;const e=Oe.current;if(e){e.buildScene([ce,he]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill);ie.current=!0,ke()}},[we,ce,he,ke]);const on=e.useCallback(()=>{var t;const e=Oe.current;if(!e)return;e.runLayout([ce,he]),e.buildScene([ce,he]),ie.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill);const n=Array.isArray(nt)?nt:R,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];qe.current.has(e.id)||qe.current.set(e.id,n[t%n.length])}if(Ue.current=i.length,We(e.layoutVersion),jt){const{nodes:t,edges:n}=e.getLayoutData();jt(t,n)}},[ce,he,jt,nt]),rn=e.useCallback(t=>{const e=Oe.current;e&&(e.ingestEdge(t)&&on(),ke())},[on,ke]),sn=e.useCallback(t=>{const e=Oe.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&on(),ke()},[on,ke]),ln=e.useCallback(()=>{var t;null===(t=Oe.current)||void 0===t||t.clear(),qe.current.clear(),Ue.current=0,We(0),$e(null),Ve.current=null,ie.current=!0,ke()},[ke]),cn=e.useCallback(()=>{const t=Oe.current;t&&(t.tension+=999,on(),ke())},[on,ke]);e.useImperativeHandle(i,()=>({push:rn,pushMany:sn,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Oe.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=Ve.current)||void 0===i?void 0:i.data)?"function"==typeof P?P(Ve.current.data):Ve.current.data[P]:void 0;Ve.current&&"node"===Ve.current.nodeOrEdge&&e===t&&(Ve.current=null,$e(null)),qe.current.delete(t),on(),ie.current=!0,ke()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Oe.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(Ve.current&&"edge"===Ve.current.nodeOrEdge){const n=Ve.current.data;let i;i=void 0!==e?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===t&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===e:!D||!n||("function"==typeof D?D:t=>null==t?void 0:t[D])(n)===t,i&&(Ve.current=null,$e(null))}on(),ie.current=!0,ke()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Oe.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(ie.current=!0,ke()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Oe.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(on(),ie.current=!0,ke()),r},clear:ln,getTopology:()=>{var t,e;return null!==(e=null===(t=Oe.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Oe.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:cn,getTension:()=>{var t,e;return null!==(e=null===(t=Oe.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[rn,sn,ln,cn,on,ke]);const un=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),dn=un?_||(Array.isArray(M)?void 0:M):void 0;e.useEffect(()=>{var t;const e=Oe.current;if(e)if(un&&dn)e.ingestHierarchy(dn,[ce,he]),e.buildScene([ce,he]),ie.current=!0,ke();else{const n=A||[],i=Array.isArray(M)?M:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[ce,he]),e.buildScene([ce,he]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&qe.current.set(n.id,n.style.fill+"");const o=Array.isArray(nt)?nt:R,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];qe.current.has(e.id)||qe.current.set(e.id,o[t%o.length])}Ue.current=r.length,ie.current=!0,ke()}},[A,M,_,dn,un,ce,he,Me,ke,nt]),e.useEffect(()=>{j&&j.length>0&&sn(j)},[]);const hn=e.useCallback(t=>{if(wt&&wt(t),Mt){const e=Date.now();Mt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:_t}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:_t})}},[wt,Mt,_t]),fn=e.useCallback(t=>{if(St&&St(t),Mt){const e=Date.now();Mt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:_t}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:_t})}},[St,Mt,_t]),{hoverHandlerRef:gn,hoverLeaveRef:yn,onPointerMove:pn,onPointerLeave:vn}=oe;gn.current=t=>{if(!vt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>i||i>ce||0>o||o>he)return void(Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke()));const r=Oe.current;if(!r)return;const s=Yi(r.sceneNodes,r.sceneEdges,i,o);if(!s)return void(Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke()));const l=an(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Ve.current=l,$e(l),hn&&(hn(l),ie.current=!0),ke()},yn.current=()=>{Ve.current&&(Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),ke())};const mn=e.useRef(()=>{});mn.current=t=>{if(!St&&!Mt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>i||i>ce||0>o||o>he)return;const r=Oe.current;if(!r)return;const s=Yi(r.sceneNodes,r.sceneEdges,i,o);fn(s?an(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const xn=e.useCallback(t=>mn.current(t),[]),wn=e.useRef(-1),An=e.useRef(null),Sn=e.useRef(-1),Mn=e.useCallback(t=>{var e;const n=Oe.current;if(!n)return;const i=function(t){var e,n,i,o,r,s;const l=[];for(const a of t)"circle"===a.type&&null!=a.cx?l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(n=null===(e=a.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===a.type&&null!=a.x?l.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=null===(i=a.datum)||void 0===i?void 0:i.id)&&void 0!==o?o:"_default"}):"arc"===a.type&&null!=a.cx&&l.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(s=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return l.sort((t,e)=>t.x-e.x||t.y-e.y),l}(n.sceneNodes);if(0===i.length)return;const o=mt(i),r=wn.current;if(0>r){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),wn.current=0,Sn.current=-1;const e=o.flat[0];An.current={shape:e.shape,w:e.w,h:e.h};const n=an(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return Ve.current=n,$e(n),hn&&(hn(n),ie.current=!0),void ke()}const s=xt(o,r),l=function(t,e,n,i,o){var r,s,l;const a=n.flat[e.flatIndex];if(!a)return bt(t,e,n);const c=null===(r=a.datum)||void 0===r?void 0:r.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const i=null!==(s=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const s=t.flat[r];if(s===e)continue;const l=s.x-e.x,a=s.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(l)}if(!c)continue;const u=l*l+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==s?s:e.flatIndex;return i!==e.flatIndex&&(o.current=-1),i}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,i,o;const r=t+"",s=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,l="object"==typeof e.source?null===(i=e.source)||void 0===i?void 0:i.id:e.source,a="object"==typeof e.target?null===(o=e.target)||void 0===o?void 0:o.id:e.target,c=null!=l,u=null!=a;c&&l+""===r&&u?s.push(a+""):u&&a+""===r&&c&&s.push(l+"")}return s}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(l=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==l?l:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=bt(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,s,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],Sn);if(null===l)return;if(t.preventDefault(),0>l)return wn.current=-1,An.current=null,Sn.current=-1,Ve.current=null,$e(null),hn&&(hn(null),ie.current=!0),void ke();wn.current=l;const a=o.flat[l];An.current={shape:a.shape,w:a.w,h:a.h};const c=a.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:a.x,y:a.y,time:a.x,value:a.y,nodeOrEdge:"node"});Ve.current=u,$e(u),hn&&(hn(u),ie.current=!0),ke()},[hn,ke]),_n=e.useCallback(t=>{wn.current=-1,An.current=null,pn(t)},[pn]);be.current=()=>{var t,e,n,i,o,r,s;xe.current=0;const l=Ee.current;if(!l)return;const a=l.getContext("2d");if(!a)return;const c=Oe.current;if(!c)return;const u=performance.now(),d=Le.current?Math.min((u-Le.current)/1e3,.1):.016;Le.current=u;const h=c.advanceTransition(re.current?u+1e6:u),f=!re.current&&h,g=!re.current&&c.tickAnimation([ce,he],d);(h||ie.current||g)&&c.buildScene([ce,he]);const y=He();if(!Fe(l,le,ae,y))return;a.clearRect(-ae.left,-ae.top,le[0],le[1]),pt&&(a.fillStyle=pt,a.fillRect(0,0,ce,he)),Rt&&c.applyDecay(),zt&&c.applyPulse(u),Ht&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Ft?void 0:Ft.threshold)&&void 0!==t?t:5e3,v=Ft&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Ft?void 0:Ft.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Ki(t,n);break;case"line":Zi(t,n);break;case"ribbon":Qi(t,n);break;case"curved":Ji(t,n)}}(a,c.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),Ze(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Qe(t,e),t.restore())}}(a,c.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&ze(t,e.style.fill)||e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=ze(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(a,c.sceneNodes),Z&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:kn.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:kn.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=l)continue;const r=o.value*s*n*(o.bezier.circular?.3:1),a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,d,Se);const e=.5*(null!==(n=Se.speedMultiplier)&&void 0!==n?n:1);let i;if(Se.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,i),function(t,e,n,i,o){var r,s;const l=null!==(r=i.radius)&&void 0!==r?r:kn.radius,a=null!==(s=i.opacity)&&void 0!==s?s:kn.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):ze(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(s.x,s.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Se,en)}}v&&(a.globalAlpha=1);const m=ie.current;if(ie.current=!1,m||f||g){const t=Ee.current;t&&t.setAttribute("aria-label",pe(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}(m||f||g)&&Ye(t=>t+1),(nn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(xe.current=requestAnimationFrame(()=>be.current()))},e.useEffect(()=>(ke(),()=>{}),[ke]),e.useEffect(()=>{ie.current=!0,ke()},[w,ce,he,pt,ke]),At(Ft,Oe,ie,ke,Xe,Ge);const jn=vt&&Ne?t.jsx(De,{x:Ne.x,y:Ne.y,containerWidth:ce,containerHeight:he,margin:ae,className:"stream-network-tooltip",zIndex:2,children:kt?kt(Ne):t.jsx(ro,{data:Ne})}):null;if(de){const e=Oe.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),n=t?_||(Array.isArray(M)?void 0:M):void 0;if(t&&n)e.ingestHierarchy(n,[ce,he]),e.buildScene([ce,he]);else{const t=A||[],n=Array.isArray(M)?M:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[ce,he]),e.buildScene([ce,he]))}}const n=null!==(u=null==e?void 0:e.sceneNodes)&&void 0!==u?u:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],o=null!==(h=null==e?void 0:e.labels)&&void 0!==h?h:[];return t.jsxs("div",{className:"stream-network-frame"+(yt?" "+yt:""),role:"img","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),style:{position:"relative",width:le[0],height:le[1]},children:[t.jsx(je,{summary:Vt}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:le[0],height:le[1],style:{position:"absolute",left:0,top:0},children:[ge&&t.jsx("g",{transform:`translate(${ae.left},${ae.top})`,children:ge}),t.jsxs("g",{transform:`translate(${ae.left},${ae.top})`,children:[pt&&t.jsx("rect",{x:0,y:0,width:ce,height:he,fill:pt}),i.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("line",{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},"net-edge-"+n);case"bezier":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t.jsx("path",{d:i.pathD,fill:ue(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t.jsx("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)({})||"";return t.jsx("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),o.map((e,n)=>function(e,n){return t.jsx("text",{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,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean)]})]}),t.jsx(qi,{width:ce,height:he,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:o,sceneNodes:n,title:$t,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,foregroundGraphics:fe,annotations:Pt,svgAnnotationRules:Ct,annotationFrame:0})]})}const Pn=Oe.current;return t.jsxs("div",{ref:se,className:"stream-network-frame"+(yt?" "+yt:""),role:"group","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),tabIndex:0,style:{position:"relative",width:ht?"100%":le[0],height:ft?"100%":le[1],overflow:"visible"},onKeyDown:Mn,children:[Xt&&t.jsx(Pe,{tableId:me}),Xt&&t.jsx(_e,{nodes:null!==(f=null==Pn?void 0:Pn.sceneNodes)&&void 0!==f?f:[],edges:null!==(g=null==Pn?void 0:Pn.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:me,chartTitle:"string"==typeof $t?$t:void 0}),t.jsx(je,{summary:Vt}),t.jsxs("div",{role:"img","aria-label":Gt||("string"==typeof $t?$t:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:vt?_n:void 0,onMouseLeave:vt?vn:void 0,onClick:St||Mt?xn:void 0,children:[ge&&t.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:le[0],height:le[1],pointerEvents:"none",overflow:"visible"},children:t.jsx("g",{transform:`translate(${ae.left},${ae.top})`,children:ge})}),t.jsx("canvas",{ref:Ee,"aria-label":pe(null!==(p=null===(y=null==Pn?void 0:Pn.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==p?p:0,null!==(m=null===(v=null==Pn?void 0:Pn.sceneEdges)||void 0===v?void 0:v.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.jsx(Ce,{hoverPoint:Ne}),t.jsx(qi,{width:ce,height:he,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:(null==Pn?void 0:Pn.labels)||[],sceneNodes:null==Pn?void 0:Pn.sceneNodes,title:$t,legend:Et,legendPosition:Tt,legendHoverBehavior:Dt,legendClickBehavior:Lt,legendHighlightedCategory:Ot,legendIsolatedCategories:Nt,foregroundGraphics:fe,annotations:Pt,svgAnnotationRules:Ct,annotationFrame:Re}),t.jsx(Te,{active:wn.current>=0,hoverPoint:Ne,margin:ae,size:le,shape:null===(x=An.current)||void 0===x?void 0:x.shape,width:null===(b=An.current)||void 0===b?void 0:b.w,height:null===(k=An.current)||void 0===k?void 0:k.h}),jn,(null==Ft?void 0:Ft.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ft.badgePosition?{top:4,left:4}:"bottom-left"===Ft.badgePosition?{bottom:4,left:4}:"bottom-right"===Ft.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Xe?"STALE":"LIVE"})]})]})});function lo(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function ao(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}so.displayName="StreamNetworkFrame";const[co,uo]=w(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=ao(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=ao(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[ho,fo]=w(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function go(t){const n=e.useId(),i=t.clientId||n,{name:o}=t,r=uo(t=>t.selections.get(o)),s=uo(t=>t.setClause),l=uo(t=>t.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(lo(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,i):()=>!0,[r,i]),isActive:a,selectPoints:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(o,{clientId:i,type:"point",fields:e})},[i,o,s]),selectInterval:e.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(o,{clientId:i,type:"interval",fields:e})},[i,o,s]),clear:e.useCallback(()=>{l(o,i)},[l,o,i]),clientId:i}}function yo({selection:t,linkedHover:n,fallbackFields:i=[],unwrapData:o=!1,onObservation:r,chartType:s,chartId:l,onClick:a,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(n,i),f=go({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const n=t.name||"hover",{fields:i}=t,{predicate:o,isActive:r,selectPoints:s,clear:l}=go({name:n});return{onHover:e.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&s(e)},[i,s,l,n]),predicate:o,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||i||[]}),y=fo(t=>t.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=e.useState(null),x=u||i[0],b=e.useMemo(()=>{if(!c||null==v||!x)return null;const t=v,e=x;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[c,v,x]),k=e.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const t=null==e?void 0:e[h.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const i=qt.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(qt={positions:new Map(qt.positions).set(t,{xValue:e,sourceId:n})},Kt())}(h.name||"hover",Number(t),d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&Zt(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&x)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[x];m(null!=n?n+"":null)}else m(null);if(r||y){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),y&&y(t)}}},[n,g,h,d,r,s,l,y,c,x]),w=e.useCallback(t=>{var e,n,i,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[h.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const i=qt.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(qt.positions);return e.delete(t),qt={positions:e},Kt(),!1}qt={positions:new Map(qt.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Kt()}(h.name||"hover",Number(n),d)}if(t&&a){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),a(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||y){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),y&&y(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),y&&y(t)}}},[a,r,y,s,l,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{Qt(t,d),Zt(t,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 po={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 vo(t,e,n){var i,o,r,s,l,a,c;const u=po[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(r=e.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=e.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||u.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:mo(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function mo(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}"undefined"!=typeof process&&process;const xo={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"},bo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ko(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},xo),{width:n,height:i}),children:o||"No data available"}):null}function wo(e,n,i){if(!e)return null;const o=Math.min(5,Math.floor(i/40)),r=Math.max(8,Math.floor(i/(3*o))),s=Math.max(6,Math.floor(i/(2.5*o))),l=Math.floor((i-(o*(r+s)-s))/2);return t.jsx("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,i)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},bo),{position:"absolute",top:l+i*(r+s),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}const Ao=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,opacity:S,background:M,tooltipContent:_,tooltip:j,onHover:P,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:$,linkedHover:I,selection:W,onObservation:R,chartId:z,loading:Y,emptyContent:B,emphasis:F,legendPosition:H}=n,X=a.showAxes,G=a.enableHover,V=null!=u?u:a.marginDefaults,q=null!=c?c:[a.width,a.height],U=null!=_?_:j,K=e.useRef(null),{customHoverBehavior:Z}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:z}),Q=e.useCallback(t=>{P&&P(t),Z(t)},[P,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const J=wo(Y,q[0],q[1]),tt=J?null:ko(y,q[0],q[1],B),et={stroke:k,strokeWidth:w,strokeDasharray:A};return null!=S&&(et.opacity=S),J||tt||t.jsx(xn,{ref:K,chartType:"line",runtimeMode:"streaming",size:q,margin:V,className:F?`${d||""} semiotic-emphasis-${F}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:et,showAxes:X,background:M,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,transition:$,pointIdAccessor:n.pointIdAccessor,legendPosition:H})});Ao.displayName="RealtimeLineChart";const So=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:c,size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:A,fill:S,stroke:M,strokeWidth:_,opacity:j,gap:P,background:C,tooltipContent:E,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,linkedHover:I,selection:W,decay:R,pulse:z,staleness:Y,transition:B,onObservation:F,chartId:H,loading:X,emptyContent:G,emphasis:V,legendPosition:q,brush:U,onBrush:K,linkedBrush:Z}=n,Q=a.showAxes,J=a.enableHover,tt=null!=d?d:a.marginDefaults,et=null!=u?u:[a.width,a.height],nt=null!=E?E:T,it=e.useRef(null),{customHoverBehavior:ot}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:H}),rt=e.useCallback(t=>{D&&D(t),ot(t)},[D,ot]),st=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,lt=(at=Z)?"string"==typeof at?{name:at}:at:null;var at;const ct=function(t){const{name:n,xField:i,yField:o}=t,{predicate:r,isActive:s,selectInterval:l,clear:a}=go({name:n}),c=i&&o?"xyBrush":i?"xBrush":"yBrush",u=e.useCallback(t=>{if(!t)return void a();const e={};"xyBrush"===c&&Array.isArray(t)&&2===t.length?(i&&(e[i]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===c&&Array.isArray(t)?i&&(e[i]=[Math.min(...t),Math.max(...t)]):"yBrush"===c&&Array.isArray(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&l(e)},[c,i,o,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:a}}(Object.assign({name:(null==lt?void 0:lt.name)||"__unused_hist_brush__",xField:(null==lt?void 0:lt.xField)||("string"==typeof v?v:"time")},(null==lt?void 0:lt.yField)?{yField:lt.yField}:{})),ut=e.useRef(ct.brushInteraction);ut.current=ct.brushInteraction;const dt=e.useCallback(t=>{if(K&&K(t),F&&F(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:H}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:H}),lt){const e=ut.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[K,F,H,lt]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=it.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=it.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=it.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const ht=wo(X,et[0],et[1]),ft=ht?null:ko(p,et[0],et[1],G),gt={};return null!=S&&(gt.fill=S),null!=M&&(gt.stroke=M),null!=_&&(gt.strokeWidth=_),null!=j&&(gt.opacity=j),null!=P&&(gt.gap=P),ht||ft||t.jsx(xn,{ref:it,chartType:"bar",runtimeMode:"streaming",size:et,margin:tt,className:V?`${h||""} semiotic-emphasis-${V}`.trim():h,arrowOfTime:f,windowMode:g,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:c,categoryAccessor:w,barColors:A,barStyle:gt,showAxes:Q,background:C,hoverAnnotation:J,tooltipContent:nt,customHoverBehavior:rt,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,decay:R,pulse:z,staleness:Y,transition:B,pointIdAccessor:n.pointIdAccessor,legendPosition:q,brush:st||(Z?{dimension:"x"}:void 0),onBrush:st||Z?dt:void 0})});So.displayName="RealtimeTemporalHistogram";const Mo=So,_o=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:A,fill:S,opacity:M,stroke:_,strokeWidth:j,background:P,tooltipContent:C,tooltip:E,onHover:T,annotations:D,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:N,linkedHover:$,selection:I,onObservation:W,chartId:R,loading:z,emptyContent:Y,emphasis:B,legendPosition:F}=n,H=a.showAxes,X=a.enableHover,G=null!=u?u:a.marginDefaults,V=null!=c?c:[a.width,a.height],q=null!=C?C:E,U=e.useRef(null),{customHoverBehavior:K}=yo({selection:I,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeSwarmChart",chartId:R}),Z=e.useCallback(t=>{T&&T(t),K(t)},[T,K]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const Q=wo(z,V[0],V[1]),J=Q?null:ko(y,V[0],V[1],Y),tt={};return null!=A&&(tt.radius=A),null!=S&&(tt.fill=S),null!=M&&(tt.opacity=M),null!=_&&(tt.stroke=_),null!=j&&(tt.strokeWidth=j),Q||J||t.jsx(xn,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:V,margin:G,className:B?`${d||""} semiotic-emphasis-${B}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:D,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:N,legendPosition:F,pointIdAccessor:n.pointIdAccessor})});_o.displayName="RealtimeSwarmChart";const jo=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:S,gap:M,stroke:_,strokeWidth:j,opacity:P,background:C,tooltipContent:E,tooltip:T,onHover:D,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,linkedHover:I,selection:W,onObservation:R,chartId:z,loading:Y,emptyContent:B,emphasis:F,legendPosition:H}=n,X=a.showAxes,G=a.enableHover,V=null!=u?u:a.marginDefaults,q=null!=c?c:[a.width,a.height],U=null!=E?E:T,K=e.useRef(null),{customHoverBehavior:Z}=yo({selection:W,linkedHover:I,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:z}),Q=e.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=K.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=K.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const J=wo(Y,q[0],q[1]),tt=J?null:ko(y,q[0],q[1],B),et={};return null!=k&&(et.positiveColor=k),null!=w&&(et.negativeColor=w),null!=A&&(et.connectorStroke=A),null!=S&&(et.connectorWidth=S),null!=M&&(et.gap=M),null!=_&&(et.stroke=_),null!=j&&(et.strokeWidth=j),null!=P&&(et.opacity=P),J||tt||t.jsx(xn,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:V,className:F?`${d||""} semiotic-emphasis-${F}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:et,showAxes:X,background:C,hoverAnnotation:G,tooltipContent:U,customHoverBehavior:Q,annotations:L,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:$,legendPosition:H,pointIdAccessor:n.pointIdAccessor})});jo.displayName="RealtimeWaterfallChart";const Po=e.forwardRef(function(n,i){var o,r,s,l;const a=vo(n.mode,{width:null!==(r=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==r?r:n.width,height:null!==(l=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==l?l:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:f="sliding",windowSize:g=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:S="count",background:M,tooltipContent:_,tooltip:j,onHover:P,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,linkedHover:$,selection:I,onObservation:W,chartId:R,loading:z,emptyContent:Y,emphasis:B,legendPosition:F}=n,H=a.showAxes,X=a.enableHover,G=null!=u?u:a.marginDefaults,V=null!=c?c:[a.width,a.height],q=null!=_?_:j,U=e.useRef(null),{customHoverBehavior:K}=yo({selection:I,linkedHover:$,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:R}),Z=e.useCallback(t=>{P&&P(t),K(t)},[P,K]);e.useImperativeHandle(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=U.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=U.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const Q=wo(z,V[0],V[1]),J=Q?null:ko(y,V[0],V[1],Y);return Q||J||t.jsx(xn,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:V,margin:G,className:B?`${d||""} semiotic-emphasis-${B}`.trim():d,arrowOfTime:h,windowMode:f,windowSize:g,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:S,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:Z,annotations:C,svgAnnotationRules:E,tickFormatTime:T,tickFormatValue:D,decay:L,pulse:O,staleness:N,legendPosition:F,pointIdAccessor:n.pointIdAccessor})});Po.displayName="RealtimeHeatmap",exports.IncrementalExtent=L,exports.RealtimeHeatmap=Po,exports.RealtimeHistogram=Mo,exports.RealtimeLineChart=Ao,exports.RealtimeSwarmChart=_o,exports.RealtimeWaterfallChart=jo,exports.RingBuffer=D,exports.StreamNetworkFrame=so,exports.StreamXYFrame=xn;
|