semiotic 3.4.0 → 3.4.2
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/export/selectionSerializer.d.ts +1 -1
- 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 +25 -21
- 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 +4 -9
- package/dist/components/store/ThemeStore.d.ts +32 -4
- package/dist/components/store/TooltipStore.d.ts +6 -2
- package/dist/components/store/useSelection.d.ts +13 -9
- 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 +21 -15
- 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 +43 -24
- package/dist/components/stream/hoverUtils.d.ts +2 -1
- package/dist/components/stream/keyboardNav.d.ts +18 -6
- 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 +73 -47
- 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 +65 -33
- 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 +58 -17
- 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 -32
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{useRef as e,useMemo as n,useEffect as r,useSyncExternalStore as i,createContext as o,useContext as l,useCallback as a,useState as s,forwardRef as c,useImperativeHandle as u,useId as d}from"react";import{select as h}from"d3-selection";import{brushX as f,brushY as y,brush as g}from"d3-brush";import{scaleLinear as p,scaleLog as v,scaleTime as m}from"d3-scale";import{quadtree as x}from"d3-quadtree";import{schemeCategory10 as b,interpolateViridis as k,interpolateGreens as w,interpolateReds as E,interpolateBlues as A}from"d3-scale-chromatic";import{bin as M,min as S,groups as _,max as P,sum as T,mean as D,group as C}from"d3-array";import{packEnclose as L,hierarchy as O,partition as $,pack as N,treemap as I,treemapBinary as W,cluster as z,tree as R}from"d3-hierarchy";import{area as B,curveCatmullRom as F,curveCardinal as j,curveBasis as Y,curveStepBefore as H,curveStepAfter as X,curveStep as G,curveMonotoneY as V,curveMonotoneX as q,curveLinear as U,arc as K,line as Z,curveNatural as Q,pie as J}from"d3-shape";import tt from"regression";import{interpolateNumber as et}from"d3-interpolate";import{forceLink as nt,forceSimulation as rt,forceManyBody as it,forceCenter as ot,forceX as lt,forceY as at}from"d3-force";import{ribbon as st,chord as ct}from"d3-chord";function ut(t,e){let n=0,r=e.length-1;for(;r>n;){const i=n+r+1>>1;e[i]>t?r=i-1:n=i}return e[n]}function dt(t,e){let n=0,r=e.length-1;for(;r>n;){const i=n+r>>1;t>e[i]?n=i+1:r=i}return e[n]}function ht({width:i,height:o,totalWidth:l,totalHeight:a,margin:s,dimension:c,scales:u,onBrush:d,binSize:p,snap:v,binBoundaries:m,snapDuring:x,streaming:b}){const k=e(null),w=e(null),E=e(d);E.current=d;const A=e(u);A.current=u;const M=n(()=>m?[...m].sort((t,e)=>t-e):void 0,[m]),S=e(M);S.current=M;const _=e(!1),P=e(null);return r(()=>{if(!k.current)return;const t=h(k.current).select(".brush-g"),e="x"===c?f():"y"===c?y():g();return e.extent([[0,0],[i,o]]),e.on("brush end",n=>{if(_.current)return;const r=A.current;if(!r)return;if(!n.selection)return P.current=null,void E.current(null);let l,a;if("x"===c){const[t,e]=n.selection;l=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(o),r.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;l=[r.x.invert(0),r.x.invert(i)],a=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[i,o]]=n.selection;l=[r.x.invert(t),r.x.invert(i)],a=[r.y.invert(o),r.y.invert(e)]}if("bin"===v&&"y"!==c&&("end"===n.type||"brush"===n.type&&x)){const i=S.current;i&&i.length>0?l=function(t,e){return 0===e.length?t:[ut(t[0],e),dt(t[1],e)]}(l,i):p&&p>0&&(l=[Math.floor(l[0]/p)*p,Math.ceil(l[1]/p)*p]);const o=r.x(l[0]),a=r.x(l[1]);if(_.current=!0,"x"===c)t.call(e.move,[o,a]);else if("xy"===c){const r=n.selection;t.call(e.move,[[o,r[0][1]],[a,r[1][1]]])}_.current=!1}const s={x:l,y:a};P.current=s,E.current(s)}),t.call(e),w.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),w.current=null}},[i,o,c,v,p,x]),r(()=>{if(!(b&&u&&w.current&&P.current))return;if(!k.current)return;if("y"===c)return;const t=P.current,e=u.x.domain()[0],n=h(k.current).select(".brush-g");if(e>=t.x[1])return _.current=!0,n.call(w.current.move,null),_.current=!1,P.current=null,void E.current(null);let r=t.x[0],i=!1;if(e>t.x[0]){if(r=e,"bin"===v){const t=S.current;t&&t.length>0?r=dt(e,t):p&&p>0&&(r=Math.ceil(e/p)*p)}if(r>=t.x[1])return _.current=!0,n.call(w.current.move,null),_.current=!1,P.current=null,void E.current(null);i=!0}const o=u.x(r),l=u.x(t.x[1]);if(_.current=!0,"x"===c)n.call(w.current.move,[o,l]);else{const e=u.y(t.y[1]),r=u.y(t.y[0]);n.call(w.current.move,[[o,e],[l,r]])}if(_.current=!1,i){const e={x:[r,t.x[1]],y:t.y};P.current=e,E.current(e)}},[u,b,c,v,p]),t.createElement("svg",{ref:k,width:l,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}class ft{constructor(t,e){var n,r;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!==(r=null==e?void 0:e.chunkSize)&&void 0!==r?r: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 r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,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 r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,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}}class yt{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;const e=this;return{next:()=>e._size>t?{done:!1,value:e.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=[],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(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[o]=e(l)}}return n}remove(t){const e=[],n=[];if(this.forEach(r=>{t(r)?n.push(r):e.push(r)}),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 gt{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 pt(t,e,n,r,i){const o=new Map;for(const l of t){const t=e(l),a=n(l);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const s=Math.floor(t/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 t=i(l);c.categories.set(t,(c.categories.get(t)||0)+a)}}return o}function vt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function mt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function xt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const kt=b,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Et(t,e,n){var r,i,o;if(1>=n)return 1;const l=null!==(r=t.minOpacity)&&void 0!==r?r:.1,a=n-1-e;switch(t.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const e=null!==(i=t.halfLife)&&void 0!==i?i:n/2;return l+Math.pow(.5,a/e)*(1-l)}case"step":return(null!==(o=t.stepThreshold)&&void 0!==o?o:.5*n)>a?1:l;default:return 1}}function At(t,e,n){var r;const i=null!==(r=t.duration)&&void 0!==r?r:500,o=n-e;return i>o?1-o/i:0}function Mt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function St(t,e){return Math.min((t-e.startTime)/e.duration,1)}function _t(t,e,n){return t+(e-t)*n}function Pt(t,e,n){var r,i,o,l;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(i=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==i?i:null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==l?l: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 Tt(t,e,n,r,i,o){const l=[];for(const i of t){const t=n(i),o=r(i);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||l.push({px:e.x(t),py:e.y(o),rawY:o,d:i})}l.sort((t,e)=>t.px-e.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];a[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:s,style:i,datum:c,group:o}}function Dt(t,e,n,r,i,o,l,a){const s=[];for(const o of t){const t=n(o),l=r(o);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=a?a(o):i;s.push({px:c,topY:e.y(l),botY:e.y(u)})}s.sort((t,e)=>t.px-e.px);const c=Array(s.length),u=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:o,datum:t,group:l}}function Ct(t,e,n,r,i,o,l){const a=n(t),s=r(t);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:e.x(a),y:e.y(s),r:i,style:o,datum:t};return void 0!==l&&(c.pointId=l),c}function Lt(t,e,n,r,i,o,l){return{type:"rect",x:t,y:e,w:n,h:r,style:i,datum:o,group:l}}function Ot(t,e,n,r,i,o,l){const a={type:"heatcell",x:t,y:e,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 $t(t,e,n){if(!t.getBounds||!t.scales)return null;const r=[],i=[];for(const n of e){const e=t.getX(n),o=t.getY(n);if(null==e||null==o||Number.isNaN(e)||Number.isNaN(o))continue;const l=t.getBounds(n),a=t.scales.x(e);if(l&&0!==l)r.push([a,t.scales.y(o+l)]),i.push([a,t.scales.y(o-l)]);else{const e=t.scales.y(o);r.push([a,e]),i.push([a,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function Nt(t,e,n,r){var i;if(!t.config.pointStyle)return;const o=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const l of r.data){let r=t.config.pointStyle(l);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const a=null!==(i=r.r)&&void 0!==i?i:3,s=t.getPointId?t.getPointId(l)+"":void 0,c=Ct(l,t.scales,t.getX,o,a,r,s);c&&n.push(c)}}}const It={blues:A,reds:E,greens:w,viridis:k},Wt=new Map;class zt{constructor(t){if(this.xExtent=new gt,this.yExtent=new gt,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=t,this.buffer=new yt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=mt(t.timeAccessor||t.xAccessor,"time"),this.getY=mt(t.valueAccessor||t.yAccessor,"value")):(this.getX=mt(t.xAccessor,"x"),this.getY=mt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?mt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?mt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?mt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?mt(t.openAccessor,"open"):void 0,this.getHigh=mt(t.highAccessor,"high"),this.getLow=mt(t.lowAccessor,"low"),this.getClose=n?mt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new yt(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?mt(this.config.timeAccessor||this.config.xAccessor,"time"):mt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[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 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,r,i,o,l,a;const{config:s,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),d=this.xExtent.extent,h=this.yExtent.extent;let f=s.xExtent?[null!==(n=s.xExtent[0])&&void 0!==n?n:d[0],null!==(r=s.xExtent[1])&&void 0!==r?r:d[1]]:d,y=s.yExtent?[null!==(i=s.yExtent[0])&&void 0!==i?i:h[0],null!==(o=s.yExtent[1])&&void 0!==o?o:h[1]]:h;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;let r=0;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const o=(n.get(t)||0)+i;n.set(t,o),o>r&&(r=o)}y=[0,r+(r>0?r*s.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===s.chartType&&s.binSize&&!g&&c.size>0){const[,t]=function(t,e,n,r,i){const o=pt(t,e,n,r,i);if(0===o.size)return[0,0];let l=0;for(const t of o.values())t.total>l&&(l=t.total);return[0,l]}(c,this.getX,this.getY,s.binSize,this.getCategory);y=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&c.size>0){const[t,e]=function(t,e){let n=0,r=0,i=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>r&&(r=i))}return[n,r]}(c,this.getY),n=e-t,r=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!g&&y[0]!==1/0){if(this.getBounds)for(const t of u){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*s.extentPadding:1,n=null===(l=s.yExtent)||void 0===l?void 0:l[0],r=null===(a=s.yExtent)||void 0===a?void 0:a[1];y=[null!=n?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&h[0]>0&&(y[0]=null!=n?y[0]:h[0]/(1+s.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===s.xScaleType){const t=Date.now();f=[t-864e5,t]}else f=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const x="streaming"===s.runtimeMode,b=Math.max(0,Math.min(s.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(k=s.arrowOfTime)||"down"===k?"y":"x")){const e="right"===s.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:p().domain(f).range(e),y:p().domain(y).range([t.height-b,b])}}else{const e="down"===s.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:p().domain(y).range([b,t.width-b]),y:p().domain(f).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 v().domain(t).range(n).clamp(!0)}return"time"===t?m().domain([new Date(e[0]),new Date(e[1])]).range(n):p().domain(e).range(n)};this.scales={x:e(s.xScaleType,f,[b,t.width-b]),y:e(s.yScaleType,y,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),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,zt.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const r=Array(e);let i=0;for(const t of this.scene)"point"===t.type&&(r[i++]=t);this._quadtree=x().x(t=>t.x).y(t=>t.y).addAll(r)}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 r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[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 r=this.scales.x.domain(),i=this.scales.y.domain(),o=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 v().domain(t).range(n).clamp(!0)}return"time"===t?m().domain([new Date(e[0]),new Date(e[1])]).range(n):p().domain(e).range(n)},s=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=l[1]>l[0];this.scales={x:a(this.config.xScaleType,r,o[0]>o[1]?[t.width-s,s]:[s,t.width-s]),y:a(this.config.yScaleType,i,c?[s,t.height-s]:[t.height-s,s])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:r,scales:i}=this;if(!i||0===e.length)return[];const o={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:(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(r.chartType){case"line":return function(t,e){var n;const r=t.groupData(e),i=[],o=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 r){const n=$t(t,e.data,e.key);n&&i.push(n)}for(const e of r){const n=t.resolveLineStyle(e.key,e.data[0]),r=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);o&&o.length>0&&(r.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),i.push(r)}return Nt(t,r,i),i}(o,e);case"area":return function(t,e){const n=t.groupData(e),r=[],i=t.scales.y.domain()[0],o=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=Dt(e.data,t.scales,t.getX,t.getY,i,n,e.key,o);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),r.push(l)}return Nt(t,n,r),r}(o,e);case"mixed":return function(t,e){const n=t.groupData(e),r=[],i=t.config.areaGroups||new Set,o=t.scales.y.domain()[0],l=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n)if(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=Dt(e.data,t.scales,t.getX,t.getY,o,n,e.key,l);t.config.gradientFill&&(i.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),r.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),r.push(i)}return Nt(t,n,r),r}(o,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 r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:i,stackedTops:o}=function(t,e,n,r,i,o,l){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),o=r(i);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let d;if(o){d=new Map;for(const e of c){let n=0;for(const r of t)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(e))||0;d.set(e,n||1)}}const h=[],f=new Map,y=new Map;for(const t of c)y.set(t,0);for(const n of t){const t=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let i=t.get(n)||0;const l=y.get(n);o&&(i/=d.get(n));const c=l+i,u=e.x(n);a.push([u,e.y(l)]),r.push([u,e.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,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r),l=i;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=o.get(r.key);if(n)for(const i of r.data){const r=t.getX(i),o=t.getY(i);null==r||Number.isNaN(r)||null==o||Number.isNaN(o)||!n.has(r)||e.set(i,n.get(r))}}const r=n=>{var r;return null!==(r=e.get(n))&&void 0!==r?r:t.getY(n)};Nt(t,n,l,r)}return l}(o,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,i=t.config.sizeRange||[3,15];let o=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 r of n)t>r&&(t=r),r>e&&(e=r);o=n=>t===e?(i[0]+i[1])/2:i[0]+(n-t)/(e-t)*(i[1]-i[0])}}const l=t.getColor?t.resolveColorMap(e):null;for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},a=e.r||r;if(o&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(a=o(e))}if(l&&t.getColor&&!e.fill){const n=t.getColor(i);n&&l.has(n)&&(e=Object.assign(Object.assign({},e),{fill:l.get(n)}))}const s=t.getPointId?t.getPointId(i)+"":void 0,c=Ct(i,t.scales,t.getX,t.getY,a,e,s);c&&n.push(c)}return n}(o,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,i,o;const l=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(i=t.config.heatmapYBins)&&void 0!==i?i:20)),s=null!==(o=t.config.heatmapAggregation)&&void 0!==o?o:"count",c=mt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.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;e.length>n;n++){const r=e[n],i=t.getX(r),o=t.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 t=0;p>t;t++){if(0===v[t])continue;let e;switch(s){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/l,E=n.height/a,A=t.config.showValues,M=t.config.heatmapValueFormat,S=[];for(let t=0;a>t;t++){const e=t*l;for(let n=0;l>n;n++){const r=e+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;S.push(Ot(n*w,(a-1-t)*E,w,E,`rgb(${220-(180*o+.5)|0},${220-(100*o+.5)|0},${255-(50*o+.5)|0})`,{xi:n,yi:t,value:i,count:v[r],sum:m[r]},A?{value:i,showValues:!0,valueFormat:M}:void 0))}}return S}(t,e,n);if(0===e.length)return[];const r=mt(t.config.valueAccessor,"value"),i=xt(t.config.xAccessor,"x"),o=xt(t.config.yAccessor,"y"),l=new Map,a=new Map,s=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],r=i(n),u=o(n);s[t]=r,c[t]=u,l.has(r)||l.set(r,l.size),a.has(u)||a.set(u,a.size)}const u=l.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(l.keys()),f=Array.from(a.keys()),y=h.every(t=>"number"==typeof t&&!isNaN(t)),g=f.every(t=>"number"==typeof t&&!isNaN(t));if(y){h.sort((t,e)=>t-e),l.clear();for(let t=0;h.length>t;t++)l.set(h[t],t)}if(g){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],i=l.get(s[t]),o=a.get(c[t]);if(void 0===i||void 0===o)continue;const d=r(n),h=o*u+i,f=x.get(h);let y;void 0!==f?y=f:(y=b++,x.set(h,y)),p[y]=h,v[y]=d,m[y]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const E=function(t){const e=t in It?t:"blues";let n=Wt.get(e);if(n)return n;n=Array(256);const r=It[e]||A;for(let t=0;256>t;t++)n[t]=r(t/255);return Wt.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),M=255/(w-k||1),S=n.width/u,_=n.height/d,P=t.config.showValues,T=t.config.heatmapValueFormat,D=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],r=n%u;D.push(Ot(r*S,(d-1-(n-r)/u)*_,S,_,E[Math.min((e-k)*M+.5|0,255)],m[t],P?{value:e,showValues:!0,valueFormat:T}:void 0))}return D}(o,e,t);case"bar":{const t=function(t,e){var n;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let i=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),l=Array.from(e).filter(t=>!o.has(t)).sort(),a=n.filter(t=>e.has(t)),s=a.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===s?i=t.barCategoryCache.order:(i=[...a,...l],t.barCategoryCache={key:s,order:i})}const o=[],l=t.scales,[a,s]=l.x.domain();for(const e of r.values()){const r=Math.max(e.start,a),c=Math.min(e.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&&e.categories.size>0){let r=0;for(const a of i){const i=e.categories.get(a)||0;if(0===i)continue;const s=l.y(r),c=l.y(r+i);o.push(Lt(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=t.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:i},a)),r+=i}}else{const t=l.y(0),n=l.y(e.total);o.push(Lt(y,Math.min(t,n),g,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const c=new Set;for(const t of r.values())c.add(t.start),c.add(t.end);return{nodes:o,binBoundaries:Array.from(c).sort((t,e)=>t-e)}}(o,e);return this._barCategoryCache=null!==(n=o.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,r,i,o;const l=[],a=t.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 e){const e=t.getX(n),r=t.getY(n);if(null==r||Number.isNaN(r))continue;const i=t.scales.x(e),a=t.scales.y(r);let f=c;if(t.getCategory){const e=t.getCategory(n);f=(null===(o=t.config.barColors)||void 0===o?void 0:o[e])||f}const y={type:"point",x:i,y:a,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),l.push(y)}return l}(o,e);case"waterfall":return function(t,e,n){var r,i,o;const l=[],a=t.scales,s=t.config.waterfallStyle,c=e.filter(e=>{const n=t.getY(e),r=t.getX(e);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 e=0;c.length>e;e++){const r=c[e],i=t.getX(r),o=t.getY(r),p=g+o;let v;v=c.length-1>e?t.getX(c[e+1])-i:e>0?i-t.getX(c[e-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(Lt(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}(o,e,t);case"candlestick":return function(t,e){var n,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const i=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||t.getOpen&&t.getClose))return[];const o=[],l=t.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=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=i?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!i&&null==l.bodyWidth&&h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));r>0&&e>r&&(e=r)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else i||null!=l.bodyWidth||(f=6);for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),l=t.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=i?r:t.getOpen(n),h=i?l:t.getClose(n);if(!i&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const y=h>=a,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(r),lowY:t.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}(o,e);default:return[]}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Et(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var r,i;const o=n.length;if(1>=o)return;const l=new Map;for(let t=0;n.length>t;t++)l.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 r=Array(e.length);let i=!1;for(let n=0;e.length>n;n++){const a=l.get(e[n]);null!=a?(r[n]=Et(t,a,o),1>r[n]&&(i=!0)):r[n]=1}i&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const i=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=l.get(e[n]);null!=r?(i[n]=Et(t,r,o),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of e){const e=l.get(n);if(null!=e){const n=Et(t,e,o);i>n&&(i=n)}}if(1>i){const t=Array(r);t.fill(i),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const a=Et(t,e,o);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=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:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,r){var i,o;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=t.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",s=null!==(o=t.glowRadius)&&void 0!==o?o: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 i=0;for(const n of e){const e=c.get(n);if(null==e)continue;const o=r.get(e);if(null==o)continue;const a=At(t,o,l);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const i=r.get(e);if(null==i)continue;const o=At(t,i,l);o>0&&(n._pulseIntensity=o,n._pulseColor=a,n._pulseGlowRadius=s)}}(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 r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=t.duration)&&void 0!==n?n:500,o=e.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(t,e,n,r){var i,o,l;n.clear(),r.clear();for(let a=0;e.length>a;a++){const s=e[a],c=Pt(t,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(t=>[t[0],t[1]]),opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(t=>[t[0],t[1]]),bottomPath:s.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=s.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 r=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],i=Pt(this.transitionContext,e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(i,{x:e.x,y:r,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(i,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(i,{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,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,T,D,C,L;if(0===r.size&&0===i.size)return n;const O=null!==(o=e.duration)&&void 0!==o?o:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let $=!1;const N=new Set,I=new Set;for(let e=0;n.scene.length>e;e++){const o=n.scene[e],E=Pt(t,o,e);if(!E)continue;if(o._transitionKey=E,"line"===o.type||"area"===o.type){const t=i.get(E);if(t){if(I.add(E),"line"===o.type&&t.path&&t.path.length===o.path.length){o._targetPath=o.path.map(t=>[t[0],t[1]]),o._prevPath=t.path;for(let e=0;o.path.length>e;e++)o.path[e]=[t.path[e][0],t.path[e][1]];$=!0}else if("area"===o.type&&t.topPath&&t.bottomPath&&t.topPath.length===o.topPath.length&&t.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(t=>[t[0],t[1]]),o._targetBottomPath=o.bottomPath.map(t=>[t[0],t[1]]),o._prevTopPath=t.topPath,o._prevBottomPath=t.bottomPath;for(let e=0;o.topPath.length>e;e++)o.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;o.bottomPath.length>e;e++)o.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];$=!0}o._targetOpacity=null!==(l=o.style.opacity)&&void 0!==l?l:1,o._startOpacity=null!==(s=null!==(a=t.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}),$=!0;continue}const A=r.get(E);if("point"===o.type)if(A){N.add(E);const t={x:o.x,y:o.y,r:o.r};o._targetOpacity=null!==(u=o.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.r,o.x=A.x,o.y=A.y,o.r=null!==(d=A.r)&&void 0!==d?d:o.r,$=!0)}else o._targetOpacity=null!==(h=o.style.opacity)&&void 0!==h?h:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),$=!0;else if("rect"===o.type)if(A){N.add(E);const t={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===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.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,$=!0)}else o._targetOpacity=null!==(p=o.style.opacity)&&void 0!==p?p:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),$=!0;else if("heatcell"===o.type)if(A){N.add(E);const t={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===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.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,$=!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}),$=!0}for(const[t,e]of i)if(!I.has(t))if(t.startsWith("l:")&&e.path){const r={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(r),$=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={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!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),$=!0}for(const[t,e]of r)if(!N.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(M=e.r)&&void 0!==M?M:3,style:{opacity:null!==(S=e.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(_=e.w)&&void 0!==_?_:0,h:null!==(P=e.h)&&void 0!==P?P:0,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(C=e.h)&&void 0!==C?C:0,fill:"#999",datum:null,style:{opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}$=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),$&&(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=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,r){var i,o,l,a,s;if(!n.activeTransition)return!1;const c=St(t,n.activeTransition),u=Mt(c,"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?r.get(e):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=_t(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==t._targetR&&void 0!==n.r&&(t.r=_t(n.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=_t(i,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==n.w&&(t.w=_t(n.w,t._targetW,u)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,i=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:_t(i,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==n.w&&(t.w=_t(n.w,t._targetW,u)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,u))}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:_t(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=u);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=_t(e[r][0],n[r][0],u),t.path[r][1]=_t(e[r][1],n[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:_t(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=u);const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,i=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=_t(e[n][0],r[n][0],u),t.topPath[n][1]=_t(e[n][1],r[n][1],u);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=_t(n[e][0],i[e][0],u),t.bottomPath[e][1]=_t(n[e][1],i[e][1],u)}}if(c>=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("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(),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||wt,o=new Map;for(let t=0;n.length>t;t++)o.set(n[t],i[t%i.length]);return this._colorMapCache={key:r,map:o,version:this._ingestVersion},o}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const r=n(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}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(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;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 r=this.config.lineStyle;if("function"==typeof r){const n=r(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}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(t)||"#4e79a7";return{fill:i,fillOpacity:.7,stroke:i,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:this.config.themeCategorical||wt,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,r),r}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,r=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)=>{r(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(r);if(0===i.length)return i;for(const t of i)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++,i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(r(t))&&i.add(e)});const o=this.buffer.update(t=>n.has(r(t)),e);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.buffer.forEach((t,e)=>{i.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++,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(t){var e,n,r,i;const o=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map),("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 l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==o.chartType||"runtimeMode"in t&&t.runtimeMode!==o.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const s=a||!vt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=o.xAccessor)&&void 0!==n?n:o.timeAccessor),c=a||!vt(null!==(r=t.yAccessor)&&void 0!==r?r:t.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=mt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=mt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=mt(this.config.xAccessor,"x"),this.getY=mt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!vt(t.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!vt(t.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!vt(t.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?mt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!vt(t.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!vt(t.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?mt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!vt(t.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!vt(t.openAccessor,o.openAccessor)||"closeAccessor"in t&&!vt(t.closeAccessor,o.closeAccessor)||"highAccessor"in t&&!vt(t.highAccessor,o.highAccessor)||"lowAccessor"in t&&!vt(t.lowAccessor,o.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?mt(this.config.openAccessor,"open"):void 0,this.getHigh=mt(this.config.highAccessor,"high"),this.getLow=mt(this.config.lowAccessor,"low"),this.getClose=e?mt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0}if(!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==o[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function Rt(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 Bt(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Ft(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function jt(t,e){const n=Ft(t);if(!n)return!1;const r=Ft(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Yt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Ht(t,e,n,r=30,i,o=0){let l=null;if(i){const t=function(t,e,n,r,i){const o=Math.max(r,i+5,12),l=e-o,a=e+o,s=n-o,c=n+o;let u=null,d=1/0;return t.visit((t,i,o,h,f)=>{if(i>a||l>h||o>c||s>f)return!0;if(!t.length){let i=t;do{const t=i.data,o=t.x-e,l=t.y-n,a=Math.sqrt(o*o+l*l);Bt(t.r,r)>=a&&d>a&&(u=t,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}(i,e,n,r,o);t&&(l={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const o of t){let t=null;switch(o.type){case"point":if(i)break;t=Gt(o,e,n,r);break;case"line":t=Vt(o,e,n,r);break;case"rect":t=Ut(o,e,n);break;case"heatcell":t=Kt(o,e,n);break;case"area":if(!1===o.interactive)break;t=Qt(o,e,n);break;case"candlestick":t=Zt(o,e,n)}t&&r>t.distance&&(l&&t.distance>=l.distance||(l=t))}return l}function Xt(t,e,n){if(0===t.length)return null;const r=Jt(t,e);if(0>r)return null;if(Math.abs(t[r][0]-e)>n)return null;let i=r,o=r;r>0&&t[r][0]>=e?(i=r-1,o=r):t.length-1>r&&(i=r,o=r+1);const[l,a]=t[i],[s,c]=t[o];return s===l?a:a+Math.max(0,Math.min(1,(e-l)/(s-l)))*(c-a)}function Gt(t,e,n,r=30){const i=e-t.x,o=n-t.y,l=Math.sqrt(i*i+o*o);return l>Bt(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function Vt(t,e,n,r=30){var i,o,l,a;if(0===t.path.length)return null;const s=Jt(t.path,e);if(0>s)return null;const[c,u]=t.path[s];let d;if(t.path.length>1){let r=1/0;const i=Math.max(0,s-1),o=Math.min(t.path.length-2,s);for(let l=i;o>=l;l++){const[i,o]=t.path[l],[a,s]=t.path[l+1],c=qt(e,n,i,o,a,s);r>c&&(r=c)}d=r}else{const t=e-c,r=n-u;d=Math.sqrt(t*t+r*r)}const h=null!==(a=null!==(o=null===(i=t.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==o?o:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:c,y:u,distance:d}}function qt(t,e,n,r,i,o){const l=i-n,a=o-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2));let c=((t-n)*l+(e-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function Ut(t,e,n){const r=Rt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Kt(t,e,n){const r=Rt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Zt(t,e,n){const r=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,o=e-t.x,l=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(o*o+l*l)}}return null}function Qt(t,e,n){if(0===t.topPath.length)return null;const r=Jt(t.topPath,e);if(0>r)return null;const[i,o]=t.topPath[r],l=e-i,a=n-o,s=Math.sqrt(l*l+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:i,y:o,distance:s}}function Jt(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const i=n+r>>1;e>t[i][0]?n=i+1:r=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function te(t){var e,n;const r=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let i=r.get(t);i||(i=[],r.set(t,i)),i.push(n)}for(const t of r.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 i=Array.from(r.keys()).sort((t,e)=>{const n=r.get(t),i=r.get(e);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),o=Array.from(r.values()).flat();o.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;o.length>t;t++){o[t]._flatIndex=t;const e=null===(n=o[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:o,groups:i,byGroup:r,idToIdx:l}}function ee(t,e){var n,r;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(e,t.flat.length-1)),o=t.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 ne(t,e,n){const{group:r,indexInGroup:i}=e,o=n.byGroup.get(r);switch(t){case"ArrowRight":return o.length-1>i?o[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?o[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?re(n,n.groups[t+1],o[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?re(n,n.groups[t-1],o[i]):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 re(t,e,n){const r=t.byGroup.get(e);let i=0,o=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);o>e&&(o=e,i=t)}return r[i]._flatIndex}function ie(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 oe(t,e,n,i,o,l){r(()=>{if(!t)return;const r=setInterval(()=>{var r;const a=e.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(r=t.threshold)&&void 0!==r?r:5e3,u=s-a.lastIngestTime>c;u!==o&&(l(u),n.current=!0,i())},1e3);return()=>clearInterval(r)},[t,o,i])}zt.QUADTREE_THRESHOLD=500;const le={fill:e=>t.createElement("rect",{style:e,width:16,height:16}),line:e=>t.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function ae(t,e,n,r){let i;return i="function"==typeof n?n(t):(0,le[n])(r(t,e)),i}function se(){return t.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ce(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function ue({config:e,orientation:n="vertical",width:r=100}){const{colorFn:i,domain:o,label:l,format:a}=e,s=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+t.useId();if("horizontal"===n){const e=12,n=Math.min(r,200),a=Math.max(0,(r-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:i(o[0]+n*(o[1]-o[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),l&&t.createElement("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])),t.createElement("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])))}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:i(o[1]-n*(o[1]-o[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},l&&t.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),t.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])),t.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function de(e){const{legendGroups:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,legendInteraction:a,title:s="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=t.useState(0),[y,g]=t.useState(0),p=t.useCallback((t,e)=>{f(t),g(e)},[]),v="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:d,x2:n,y2:d})),d+=8,e.label&&(d+=16,h.push(t.createElement("text",{key:"legend-text-"+f,y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label)),d+=8),h.push(t.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${d})`},((e,n,r,i,o,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,y=[];let g=0;const p=!(!n&&!r),v="isolate"===u||void 0===u&&null!=o;return f.forEach((e,u)=>{const m=ae(e,u,d,h),x=ce(e,i,o),b=o&&o.size>0&&o.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===l&&u===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:p?t=>{var r;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(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{r&&r(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"}},p&&t.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&&t.createElement(se,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),g+=22}),y})(e,r,i,o,l,a,s,f,c,u))),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:n,width:r,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let y=0;e.label&&(y+=16);const g=((e,n,r,i,o,l,a,s,c,u,d)=>{const{type:h="fill",styleFn:f,items:y}=e,g=[];let p=0,v=0;const m=!(!n&&!r),x="isolate"===u||void 0===u&&null!=o;y.forEach((e,u)=>{const b=ae(e,u,h,f),k=ce(e,i,o),w=o&&o.size>0&&o.has(e.label),E=26+7*e.label.length;d&&d>0&&p>0&&p+E>d&&(v++,p=0),g.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(${p},${22*v})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:m?s===l&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:m?t=>{var r;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)+y.length)%y.length;c(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{r&&r(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"}},m&&t.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&&t.createElement(se,null),t.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 t of y){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:g,offset:b,totalRows:w,totalHeight:22*w}})(e,i,o,l,a,s,c,n,u,d,r);y+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:y,totalRows:g.totalRows,totalHeight:g.totalHeight})),h+=y+12});let y=h>r?0:Math.max(0,(r-h)/2);const g=[];return f.forEach((r,i)=>{const o=e[i];o.label&&(g.push(t.createElement("text",{key:"legend-text-"+i,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},o.label)),y+=16),g.push(t.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${y},0)`},r.items)),y+=r.offset+5,e[i+1]&&g.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:y,y1:-8,x2:y,y2:(r.totalHeight||n)+0+8})),y+=12}),t.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}),m=!(!r&&!i);return t.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==a&&(void 0!==a||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===d&&t.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},s),v)}function he(e){const{legend:n,totalWidth:r,totalHeight:i,margin:o,legendPosition:l="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===l||"bottom"===l;let y,g;return"left"===l?(y=4,g=o.top):"top"===l?(y=0,g=a?32:8):"bottom"===l?(y=0,g=i-o.bottom+50):(y=r-o.right+10,g=o.top),t.createElement("g",{transform:`translate(${y}, ${g})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(n)?t.createElement(ue,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?r:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(n)?t.createElement(de,{legendGroups:n.legendGroups,title:"",width:f?r:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n)}function fe(t){return"string"==typeof t?{type:t}:t}function ye({orient:e,config:r,values:i,scale:o,size:l,length:a}){const s=function(t){var e,n,r,i,o;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!==(r=t.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(o=t.strokeWidth)&&void 0!==o?o:1}}(r),c="top"===e||"bottom"===e,u=n(()=>{if(0===i.length)return null;const n=o.domain(),r=l-8;if("boxplot"===s.type){const n=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],o=e[Math.floor(.75*n)],l=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(e[0],r-1.5*l),whiskerHigh:Math.min(e[n-1],o+1.5*l)}}(i);if(!n)return null;const{q1:l,median:a,q3:u,whiskerLow:d,whiskerHigh:h}=n,f=Math.min(.5*r,20),y=(r-f)/2+4;if(c){const n=o(l),r=o(u),i=o(a),c=o(d),g=o(h),p="top"===e?-1:1,v=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:c,y1:v+p*(y+f/2),x2:g,y2:v+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:c,y1:v+p*y,x2:c,y2:v+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:g,y1:v+p*y,x2:g,y2:v+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:Math.min(n,r),y:"top"===e?v-y-f:v+y,width:Math.abs(r-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:i,y1:"top"===e?v-y-f:v+y,x2:i,y2:"top"===e?v-y:v+y+f,stroke:s.fill,strokeWidth:2}))}{const n=o(l),r=o(u),i=o(a),c=o(d),g=o(h),p="left"===e?-1:1,v=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:v+p*(y+f/2),y1:c,x2:v+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:v+p*y,y1:c,x2:v+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:v+p*y,y1:g,x2:v+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:"left"===e?v-y-f:v+y,y:Math.min(n,r),width:f,height:Math.abs(r-n),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:"left"===e?v-y-f:v+y,y1:i,x2:"left"===e?v-y:v+y+f,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=M().domain(n).thresholds(s.bins)(i);if(0===u.length)return null;const d=Math.max(...u.map(t=>t.length));if(0===d)return null;if("histogram"===s.type)return t.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((n,i)=>{if(null==n.x0||null==n.x1)return null;const l=n.length/d*r;if(c){const r=o(n.x0),a=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,x:r,y:"top"===e?-4-l:4,width:Math.max(a,.5),height:l,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const r=o(n.x0),a=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,x:"left"===e?-4-l:4,y:Math.min(r,r+a),width:l,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const n=r/2+4,i=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const l=t.length/d*(r/2),a=o((t.x0+t.x1)/2);i.push(c?`${a},${"top"===e?-(n-l):n-l}`:`${"left"===e?-(n-l):n-l},${a}`)}for(let t=u.length-1;t>=0;t--){const l=u[t];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(r/2),s=o((l.x0+l.x1)/2);i.push(c?`${s},${"top"===e?-(n+a):n+a}`:`${"left"===e?-(n+a):n+a},${s}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+e},t.createElement("polygon",{points:i.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const n=[];if(c){const t=0,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${i},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/d*r,l=o((t.x0+t.x1)/2);n.push(`L${l},${"top"===e?-i-4:i+4}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;n.push(`L${l},${t}`),n.push("Z")}else{const t=0,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${t},${i}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/d*r,l=o((t.x0+t.x1)/2);n.push(`L${"left"===e?-i-4:i+4},${l}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;n.push(`L${t},${l}`),n.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+e},t.createElement("path",{d:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[i,o,s,l,a,e,c,4]);return u?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function ge(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),o=[];let l="";for(const t of i)l&&l.length+1+t.length>r?(o.push(l),l=t):l=l?`${l} ${t}`:t;return l&&o.push(l),o}function pe(t,e,n,r){return"curly"===t?r?`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`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function ve(e){const{x:n=0,y:r=0,dx:i,dy:o,nx:l,ny:a,note:s,connector:c,subject:u,type:d,color:h,className:f,disable:y,events:g={},"data-testid":p}=e,v=new Set(Array.isArray(y)?y:[]);let m=i||0,x=o||0;null!=l&&(m=l-n),null!=a&&(x=a-r);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.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${r})`,"data-testid":p},g),!v.has("connector")&&function(e,n,r,i,o,l){const a=[];let s=0,c=0;if("callout-circle"!==o&&"label"!==o||!(null==l?void 0:l.radius)){if("callout-rect"===o&&l){const t=l.width||0,r=l.height||0;if(t>0||r>0){const i=t/2,o=r/2,l=e-i,a=n-o;if(0!==l||0!==a){const e=Math.abs(l),n=Math.abs(a),u=t/2,d=r/2,h=e*d>n*u?u/e:d/n;s=i+l*h,c=o+a*h}}}else if("bracket"===o&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(s=t/2,c=n):void 0!==e&&(s=n,c=e/2)}}else{const t=(l.radius||0)+(l.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const r=Math.atan2(n,e);s=Math.cos(r)*t,c=Math.sin(r)*t}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(n-c,2))>.5&&(a.push(t.createElement("line",{key:"connector-line",x1:s,y1:c,x2:e,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==r?void 0:r.end))){const r=10,o=16/180*Math.PI,l=Math.atan2(n-c,e-s);a.push(t.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+r*Math.cos(l+o)},${c+r*Math.sin(l+o)}L${s+r*Math.cos(l-o)},${c+r*Math.sin(l-o)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},a)}(m,x,c,h,b,u),!v.has("subject")&&function(e,n,r,i,o){var l;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:r||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&a.push(t.createElement("rect",{key:"subject-rect",width:e,height:i,fill:"none",stroke:r||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,l=o||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;a.push(t.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-l,x2:i,y2:(n.y2||0)-l,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-l;a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&a.push(t.createElement("path",{key:"bracket-path",d:pe((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:r||"var(--semiotic-text-secondary, currentColor)"}));break}}return t.createElement("g",{className:"annotation-subject"},a)}(b,u,h,n,r),!v.has("note")&&function(e,n,r,i){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:o,title:l,orientation:a,align:s,wrap:c=120,noWrap:u}=e;if(!o&&!l)return t.createElement("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(r)?"leftRight":"topBottom");let h=s;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>r?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const y=16,g=l?u?[l]:ge(l,c):[],p=o?u?[o]:ge(o,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold"},g.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e)))),m=g.length*y),p.length>0&&x.push(t.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:f,y:m},p.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e))));let k=null;if((l||o)&&(0!==n||0!==r))if("topBottom"===d){const e=Math.min(c,120);let n=0,r=e;"end"===f?(n=-e,r=0):"middle"===f&&(n=-e/2,r=e/2),k=t.createElement("line",{className:"note-line",x1:n,x2:r,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,r=e;"bottom"===h?(n=-e,r=0):"middle"===h&&(n=-e/2,r=e/2),k=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:r,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,g.length+p.length-1)*y;let E=0;return"topBottom"===d?E=0>r?-(w+2):18:"leftRight"===d&&(E="middle"===h?-(w+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>r?-(w+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${r})`},t.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(s,m,x,h))}function me(e){var n,r;const{noteData:i}=e,{screenCoordinates:o}=i,l="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&o){const e=i.nx||o[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||o[0][1]+(null!==(r=i.dy)&&void 0!==r?r:0),s=o.map((n,r)=>{const o=Object.assign({},i,{note:0===r?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.createElement(ve,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+r},o,{type:l}))});return t.createElement("g",null,s)}const s=i.note||{title:"none",label:i.label};return t.createElement(ve,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${i.i}`,events:a},i,{type:l}))}function xe(t,e){var n,r,i;const o=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(i=e.scales)||void 0===i?void 0:i.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function be(t,e){var n,r,i;const o=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(i=e.scales)||void 0===i?void 0:i.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function ke(t,e,n){var r,i,o,l;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.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===t.pointId){const t={x:o.x,y:o.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,t),t}}const o=function(t){var e,n,r,i,o,l;const a=t.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(r=t.scales)||void 0===r?void 0:r.time,u=null!==(o=null===(i=t.scales)||void 0===i?void 0:i.y)&&void 0!==o?o:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[t.xAccessor||"x"],h=s[t.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(e,o)),o}let s=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,c=e.y)}if(null!=s&&null!=c||(s=xe(t,n),c=be(t,n)),null!=s&&null!=c)return null===(o=n.stickyPositionCache)||void 0===o||o.set(e,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function we(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}const Ee={linear:U,monotoneX:q,monotoneY:V,step:G,stepAfter:X,stepBefore:H,basis:Y,cardinal:j,catmullRom:F};let Ae={positions:new Map};const Me=new Set;function Se(){for(const t of Me)t()}function _e(t,e){const n=Ae.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(Ae.positions);r.delete(t),Ae={positions:r},Se()}function Pe(t,e){const n=Ae.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const r=new Map(Ae.positions);r.delete(t),Ae={positions:r},Se()}function Te(){return Ae}function De(t){return Me.add(t),()=>Me.delete(t)}const Ce={positions:new Map};function Le(){return()=>{}}function Oe(){return Ce}function $e(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Ne(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,i="left"===t?-1:1,o=Math.ceil(e/8);let l="M0,"+r;for(let t=0;o>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${r+4*i}`,l+=`L${Math.min(n,e)},${r}`}return l}{const r="bottom"===t?0:e,i="bottom"===t?1:-1,o=Math.ceil(n/8);let l=`M${r},0`;for(let t=0;o>t;t++){const e=8*(t+1);l+=`L${r+4*i},${Math.min(8*t+4,n)}`,l+=`L${r},${Math.min(e,n)}`}return l}}function Ie(e){const{width:r,height:i,totalWidth:o,totalHeight:l,margin:a,scales:s,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f}=e,y=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||h||We,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=s.x.ticks(Math.min(i,Math.max(2,Math.floor(r/70)))),l=o.map(t=>t.valueOf()),a=o.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,l)})),c=a.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 ze(a,Math.max(55,c+8))},[s,u,h,r]),g=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||We,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return ze(s.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:s.y(t),label:n(t)})),22)},[s,u,f,i]),p=d&&s,v=c&&s;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,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return t.createElement("svg",{width:o,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&(()=>{var e,n;const o=$e(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),l=$e(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.createElement("g",{className:"stream-grid"},y.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})),g.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l})))})(),b&&!w&&t.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:A,strokeWidth:1}),w&&t.createElement("path",{d:Ne("bottom",r,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&t.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&t.createElement("path",{d:Ne("left",r,i),fill:"none",stroke:A,strokeWidth:1})))}function We(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ze(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Re(o){var l,a;const{width:s,height:c,totalWidth:u,totalHeight:d,margin:h,scales:f,showAxes:y,axes:g,xLabel:p,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:T,marginalGraphics:D,xValues:C,yValues:O,annotations:$,svgAnnotationRules:N,xAccessor:I,yAccessor:W,annotationData:z,pointNodes:R,curve:F,underlayRendered:j,linkedCrosshairName:Y,linkedCrosshairSourceId:H,children:X}=o,G=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||We,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=f.x.ticks(Math.min(r,Math.max(2,Math.floor(s/70)))),o=i.map(t=>t.valueOf()),l=i.map((t,e)=>({value:t,pixel:f.x(t),label:n(t,e,o)})),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=ze(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=f.x.domain()[1],e=f.x(t),r=u[u.length-1].pixel;if(Math.abs(e-r)>1){const i=n(t,u.length,o);c>e-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:i})}}return u},[y,f,g,x,s]),V=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||We,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let i=ze(f.y.ticks(Math.min(r,Math.max(2,Math.floor(c/30)))).map(t=>({value:t,pixel:f.y(t),label:n(t)})),22);if(i.length>1&&(i=i.filter((t,e)=>0===e||t.label+""!=i[e-1].label+"")),(null==e?void 0:e.includeMax)&&i.length>0){const t=f.y.domain()[1],e=f.y(t),r=i[i.length-1].pixel;if(Math.abs(e-r)>1){const o=n(t);22>Math.abs(e-r)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:t,pixel:e,label:o})}}return i},[y,f,g,b,c]),q=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||We,r=null!==(t=e.ticks)&&void 0!==t?t:5;return ze(f.y.ticks(Math.min(r,Math.max(2,Math.floor(c/30)))).map(t=>({value:t,pixel:f.y(t),label:n(t)})),22)},[y,f,g,b,c]),K=e(new Map),Z=e(null!==(l=null==$?void 0:$.length)&&void 0!==l?l:0),Q=null!==(a=null==$?void 0:$.length)&&void 0!==a?a:0;Z.current!==Q&&(Z.current=Q,K.current=new Map);const J=n(()=>{if(!$||0===$.length)return null;const e=function(e,n,r){var i,o,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M,S,_,P,T,D,C,O,$,N,I,W,z,R,F,j,Y,H,X,G,V,q,K,Z,Q,J,et;switch(e.type){case"label":{const i=ke(e,n,r);if(!i)return null;const{x:o,y:l}=i;return we(o,l,r)?t.createElement(me,{key:"ann-"+n,noteData:{x:o,y:l,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 i=ke(e,n,r);if(!i)return null;const{x:o,y:l}=i;return we(o,l,r)?t.createElement(me,{key:"ann-"+n,noteData:{x:o,y:l,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 i=xe(e,r);if(null==i)return null;const o=e.color||"#f97316",l=e.labelPosition||"top";let a;return a="bottom"===l?(r.height||0)-4:"center"===l?(r.height||0)/2:12,t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:i,y1:0,x2:i,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:i+4,y:a,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const i=be(e,r);if(null==i)return null;const o=e.color||"#f97316",l=e.labelPosition||"right";let a,s;return"left"===l?(a=4,s="start"):"center"===l?(a=(r.width||0)/2,s="middle"):(a=(r.width||0)-4,s="end"),t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:i,x2:r.width||0,y2:i,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:a,y:i-4,textAnchor:s,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const i=(e.coordinates||[]).map(t=>({x:xe(Object.assign(Object.assign({},t),{type:"point"}),r),y:be(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=L(i),l=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:o.x,cy:o.y,r:o.r+l,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.createElement("text",{x:o.x,y:o.y-o.r-l-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const i=(e.coordinates||[]).map(t=>({x:xe(Object.assign(Object.assign({},t),{type:"point"}),r),y:be(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=e.padding||10,l=i.map(t=>t.x),a=i.map(t=>t.y),s=Math.min(...l)-o,c=Math.max(...l)+o,u=Math.min(...a)-o,d=Math.max(...a)+o;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:s,y:u,width:c-s,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.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const i=r.data||[],o="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],l={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},o.map((n,i)=>{const o=xe(n,r),a=be(n,r);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||l;return t.createElement("circle",Object.assign({key:"hl-"+i,cx:o,cy:a,r:s},c))}))}case"bracket":{const i=xe(e,r),o=be(e,r);return t.createElement(me,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const d=r.data||[];if(2>d.length)return null;const h=r.xAccessor||"x",f=r.yAccessor||"y",y=d.map(t=>[t[h],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(o=null===(i=r.scales)||void 0===i?void 0:i.x)&&void 0!==o?o:null===(l=r.scales)||void 0===l?void 0:l.time,p=null!==(s=null===(a=r.scales)||void 0===a?void 0:a.y)&&void 0!==s?s:null===(c=r.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const v=e.method||"linear";let m;m="loess"===v?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),i=r.map(t=>t[0]),o=r.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],r=i.map(t=>Math.abs(t-e)),s=r.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:r[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*i[t],h+=e*o[t],f+=e*i[t]*i[t],y+=e*i[t]*o[t])}if(0===u){a.push([e,o[t]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([e,h/u]);else{const t=(u*y-d*h)/g;a.push([e,(h-t*d)/u+t*e])}}return a}(y,null!==(u=e.bandwidth)&&void 0!==u?u:.3):("polynomial"===v?tt.polynomial(y,{order:e.order||2}):tt.linear(y)).points;const x=m.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=e.color||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:g(m[m.length-1][0])+4,y:p(m[m.length-1][1])-4,fill:b,fontSize:11},e.label))}case"band":{const i=null!==(h=null===(d=r.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(f=r.scales)||void 0===f?void 0:f.value,o=null!==(y=null==i?void 0:i(e.y0))&&void 0!==y?y:0,l=null!==(g=null==i?void 0:i(e.y1))&&void 0!==g?g:r.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(o,l),width:r.width||0,height:Math.abs(l-o),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(o,l)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const i=r.data||[];if(2>i.length)return null;const o=r.xAccessor||"x",l=null!==(v=null===(p=r.scales)||void 0===p?void 0:p.x)&&void 0!==v?v:null===(m=r.scales)||void 0===m?void 0:m.time,a=null!==(b=null===(x=r.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=r.scales)||void 0===k?void 0:k.value;if(!l||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=i.filter(t=>null!=t[s]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>d.length)return null;const h=Ee[r.curve||"linear"]||U,f=B().x(t=>l(t[o])).y0(t=>a(t[c])).y1(t=>a(t[s])).curve(h)(d);if(!f)return null;const y=e.fill||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:f,fill:y,fillOpacity:null!==(w=e.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),e.label&&d.length>0&&t.createElement("text",{x:l(d[d.length-1][o])+4,y:a(d[d.length-1][s])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const i=r.data||[];if(2>i.length)return null;const o=r.yAccessor||"y",l=null!==(A=null===(E=r.scales)||void 0===E?void 0:E.x)&&void 0!==A?A:null===(M=r.scales)||void 0===M?void 0:M.time,a=null!==(_=null===(S=r.scales)||void 0===S?void 0:S.y)&&void 0!==_?_:null===(P=r.scales)||void 0===P?void 0:P.value;if(!l||!a)return null;const s=i.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>s.length)return null;const c=s.reduce((t,e)=>t+e,0)/s.length,u=s.reduce((t,e)=>t+Math.pow(e-c,2),0)/s.length,d=Math.sqrt(u),h=null!==(T=e.threshold)&&void 0!==T?T:2,f=c-h*d,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,v=e.anomalyColor||"#ef4444",m=null!==(C=e.anomalyRadius)&&void 0!==C?C:6,x=a(c+h*d),b=a(f),k=i.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-c)>h*d});return t.createElement("g",{key:"ann-"+n},y&&t.createElement("rect",{x:0,y:Math.min(x,b),width:r.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const i=xe(e,r),o=be(e,r);return null==i||null==o?null:t.createElement("circle",{key:"anomaly-"+n,cx:i,cy:o,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const i=r.data||[];if(3>i.length)return null;const o=r.xAccessor||"x",l=r.yAccessor||"y",a=null!==($=null===(O=r.scales)||void 0===O?void 0:O.x)&&void 0!==$?$:null===(N=r.scales)||void 0===N?void 0:N.time,s=null!==(W=null===(I=r.scales)||void 0===I?void 0:I.y)&&void 0!==W?W:null===(z=r.scales)||void 0===z?void 0:z.value;if(!a||!s)return null;const c=i.map(t=>[t[o],t[l]]).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=tt.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const t=c.length;let e=0,n=0,r=0,i=0;for(const[t,o]of c)e+=t,n+=o,r+=t*t,i+=t*o;const o=t*r-e*e;if(1e-12>Math.abs(o))return null;const l=(t*i-e*n)/o,a=(n-l*e)/t;u=t=>a+l*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)),y=c.reduce((t,e)=>t+e[0],0)/d,g=c.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(R=e.confidence)&&void 0!==R?R:.95,v=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=null!==(F=e.steps)&&void 0!==F?F:5,x=c[d-1][0],b=(x-c[0][0])/Math.max(d-1,1),k=[];for(let t=1;m>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=u(t),n=f*Math.sqrt(1+1/d+(g>0?Math.pow(t-y,2)/g:0))*v;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const E=`M${w.map(t=>`${a(t.x)},${s(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${a(t.x)},${s(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${a(t.x)},${s(t.yCenter)}`).join(" "),M=`${a(x)},${s(u(x))}`,S=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(j=e.fillOpacity)&&void 0!==j?j:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:S,strokeWidth:null!==(Y=e.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(H=e.strokeDasharray)&&void 0!==H?H:"6,3"}),e.label&&w.length>0&&t.createElement("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}case"widget":{let i=null,o=null;if(null!=e.px&&null!=e.py)i=e.px,o=e.py;else{const t=ke(e,n,r);if(!t)return null;i=t.x,o=t.y}if(null==i||null==o)return null;if(!we(i,o,r))return null;const l=null!==(X=e.dx)&&void 0!==X?X:0,a=null!==(G=e.dy)&&void 0!==G?G:0,s=null!==(V=e.width)&&void 0!==V?V:32,c=null!==(q=e.height)&&void 0!==q?q:32,u=null!==(K=e.content)&&void 0!==K?K:t.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return t.createElement("foreignObject",{key:"ann-"+n,x:i+l-s/2,y:o+a-c/2,width:s,height:c,style:{overflow:"visible",pointerEvents:"auto"}},t.createElement("div",{style:{width:s,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const i=ke(e,n,r);if(!i)return null;const{x:o,y:l}=i;return t.createElement("text",{key:"ann-text-"+n,x:o+(e.dx||0),y:l+(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 i=e.category;if(null==i)return null;const o=null===(Z=r.scales)||void 0===Z?void 0:Z.o,l=null===(Q=r.scales)||void 0===Q?void 0:Q.x,a=null===(J=r.scales)||void 0===J?void 0:J.y,s=(null==o?void 0:o.bandwidth)?o:(null==l?void 0:l.bandwidth)?l:(null==a?void 0:a.bandwidth)?a:null;if(!s)return null;const c=s(i);if(null==c)return null;const u=s.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(et=e.opacity)&&void 0!==et?et:.15,f=e.label;return(r.projection?"vertical"===r.projection:s===l)?t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&t.createElement("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold"},f)):t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&t.createElement("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold"},f))}default:return null}},n={scales:f?{x:f.x,y:f.y,time:f.x,value:f.y}:null,timeAxis:"x",xAccessor:I,yAccessor:W,width:s,height:c,data:z,frameType:"xy",pointNodes:R,curve:F,stickyPositionCache:K.current};return $.map((t,r)=>{if(N){const i=N(t,r,n);return null!=i?i:e(t,r,n)}return e(t,r,n)}).filter(Boolean)},[$,N,s,c,I,W,z,f,R,F]),et=function(t){var e;const n=i(t?De:Le,t?Te:Oe,t?Te:Oe);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(Y);return r(()=>{if(!(null==et?void 0:et.locked)||!Y)return;const t=t=>{"Escape"===t.key&&Pe(Y)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==et?void 0:et.locked,Y]),y||w||E||T||D||J&&J.length>0||k||X||et?t.createElement("svg",{role:"img",width:u,height:d,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},t.createElement("title",null,"string"==typeof w?w:"XY Chart"),t.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),t.createElement("g",{transform:`translate(${h.left},${h.top})`},k&&f&&!j&&(()=>{var e,n;const r=$e(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),i=$e(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.createElement("g",{className:"stream-grid"},G.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:c,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),V.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:s,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),y&&f&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),r=!e||!1!==e.baseline,i=!n||!1!==n.baseline,o=(null==e?void 0:e.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,a=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&G.length>1&&(()=>{const t=s/Math.max(G.length-1,1),e=G.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})();return t.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!j&&i&&!l&&t.createElement("line",{x1:0,y1:c,x2:s,y2:c,stroke:d,strokeWidth:1}),!j&&l&&t.createElement("path",{d:Ne("bottom",s,c),fill:"none",stroke:d,strokeWidth:1}),G.map((e,n)=>{const r=!!a&&("function"==typeof a?a(e.value,n):jt(e.value,n>0?G[n-1].value:void 0));return t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${c})`},t.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0},e.label):t.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),p&&t.createElement("text",{x:s/2,y:c+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},p),!j&&r&&!o&&t.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:d,strokeWidth:1}),!j&&o&&t.createElement("path",{d:Ne("left",s,c),fill:"none",stroke:d,strokeWidth:1}),V.map((e,n)=>{const r=!!u&&("function"==typeof u?u(e.value,n):jt(e.value,n>0?V[n-1].value:void 0));return t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:f,style:{userSelect:"none"}},e.label):t.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const n=(null==e?void 0:e.label)||v;return n?t.createElement("text",{x:15-h.left,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-h.left}, ${c/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===q.length)return null;const n=e.landmarkTicks,r=e.label||m;return t.createElement(t.Fragment,null,!1!==e.baseline&&t.createElement("line",{x1:s,y1:0,x2:s,y2:c,stroke:d,strokeWidth:1}),q.map((e,r)=>{const i=!!n&&("function"==typeof n?n(e.value,r):jt(e.value,r>0?q[r-1].value:void 0));return t.createElement("g",{key:"ytick-r-"+r,transform:`translate(${s},${e.pixel})`},t.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"}},e.label):t.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),r&&t.createElement("text",{x:s+h.right-15,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(90, ${s+h.right-15}, ${c/2})`,style:{userSelect:"none"}},r))})())})(),J,D&&f&&C&&O&&t.createElement(t.Fragment,null,D.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ye,{orient:"top",config:fe(D.top),values:C,scale:f.x,size:h.top,length:s})),D.bottom&&t.createElement("g",{transform:`translate(0, ${c})`},t.createElement(ye,{orient:"bottom",config:fe(D.bottom),values:C,scale:f.x,size:h.bottom,length:s})),D.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ye,{orient:"left",config:fe(D.left),values:O,scale:f.y,size:h.left,length:c})),D.right&&t.createElement("g",{transform:`translate(${s}, 0)`},t.createElement(ye,{orient:"right",config:fe(D.right),values:O,scale:f.y,size:h.right,length:c}))),T,et&&et.sourceId!==H&&(null==f?void 0:f.x)&&(()=>{const e=f.x(et.xValue);if(null==e||0>e||e>s)return null;const n=et.locked;return t.createElement("line",{x1:e,y1:0,x2:e,y2:c,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"})})(),X),w&&t.createElement("text",{x:u/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),he({legend:E,totalWidth:u,totalHeight:d,margin:h,legendPosition:P,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:_})):null}function Be(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Fe="undefined"==typeof window||"undefined"==typeof document,je=t.createContext(null);function Ye(){return t.useContext(je)}const He={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Xe(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 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((t,e)=>{const n=o.indexOf(t),r=o.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of l)r.push(`${n[t]} ${i[t]||t}`);return`${e}, ${r.join(", ")}`}function Ge(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const Ve=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},qe={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"},Ue={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ke={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)"},Ze={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Qe={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)"},Je={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},tn={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function en({scene:e,chartType:n,tableId:r,chartTitle:i}){var o;const[l,a]=t.useState(!1),s=Ye(),c=null!==(o=null==s?void 0:s.visible)&&void 0!==o&&o,u=l||c,d=t.useRef(null),h=i?"Data summary for "+i:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=t.useCallback(()=>{l||c||a(!0)},[l,c]),y=t.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[c]);if(!e||0===e.length)return r?t.createElement("span",{id:r,tabIndex:-1,style:He}):null;if(!u)return t.createElement("div",{id:r,tabIndex:-1,onFocus:f,style:He,role:"region","aria-label":h},t.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",e.length," elements)"));const g=function(t){var e,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(t))return S;for(const _ of t)if(_&&"object"==typeof _)try{switch(_.type){case"point":S.push({label:"Point",values:{x:_.x,y:_.y}});break;case"line":{const t=_.path,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=_.topPath,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=_.datum&&"object"==typeof _.datum?_.datum:{},o=null!==(n=null!==(e=t.category)&&void 0!==e?e:_.group)&&void 0!==n?n:"",l=null!==(i=null!==(r=t.value)&&void 0!==r?r:t.__aggregateValue)&&void 0!==i?i:t.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(t){}return S}(e),p=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 r of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],o=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),o+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:i,mean:o/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(g),v=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,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(g.length,p),m=g.slice(0,5),x=new Set;for(const t of m)for(const e of Object.keys(t.values))x.add(e);const b=Array.from(x);return t.createElement("div",{ref:d,id:r,tabIndex:-1,onBlur:y,style:qe,role:"region","aria-label":h},t.createElement("button",{type:"button",onClick:()=>{c&&s&&s.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Ke},"×"),t.createElement("div",{role:"note",style:Ue},v),t.createElement("table",{role:"table","aria-label":"Sample data for "+n,style:Ze},t.createElement("caption",{style:tn},"First ",m.length," of ",g.length," data points"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Qe},"type"),b.map(e=>t.createElement("th",{key:e,style:Qe},e)))),t.createElement("tbody",null,m.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:Je},e.label),b.map(n=>{return t.createElement("td",{key:n,style:Je},null==(r=e.values[n])||""===r?"—":"number"==typeof r?Number.isNaN(r)?"—":Ve(r):"boolean"==typeof r?r?"true":"false":"object"==typeof r?"—":r+"");var r}))))))}function nn({nodes:e,edges:n,chartType:r,tableId:i,chartTitle:o}){var l,a,s,c,u,d,h,f,y,g,p,v,m,x;const[b,k]=t.useState(!1),w=Ye(),E=null!==(l=null==w?void 0:w.visible)&&void 0!==l&&l,A=b||E,M=o?"Data summary for "+o:i?`Data summary for ${r} ${i}`:"Data summary for "+r,S=t.useRef(null),_=t.useCallback(()=>{b||E||k(!0)},[b,E]),P=t.useCallback(t=>{var e;E||(null===(e=S.current)||void 0===e?void 0:e.contains(t.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return i?t.createElement("span",{id:i,tabIndex:-1,style:He}):null;if(!A)return t.createElement("div",{id:i,tabIndex:-1,onFocus:_,style:He,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",n.length," edges)"));const T=Array.isArray(e)?e:[],D=Array.isArray(n)?n:[],C=new Map,L=new Map,O=new Map,$=new Map;for(const t of D){if(!t||"object"!=typeof t)continue;const e=null!==(a=t.datum)&&void 0!==a?a:t,n="object"==typeof e.source?null===(s=e.source)||void 0===s?void 0:s.id:e.source,r="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,i="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),$.set(t,(null!==(d=$.get(t))&&void 0!==d?d:0)+i)}if(null!=r&&""!==r){const t=r+"";C.set(t,(null!==(h=C.get(t))&&void 0!==h?h:0)+1),O.set(t,(null!==(f=O.get(t))&&void 0!==f?f:0)+i)}}const N=[];for(let t=0;T.length>t;t++){const e=T[t];if(!e||"object"!=typeof e)continue;const n=null!==(g=null===(y=e.datum)||void 0===y?void 0:y.id)&&void 0!==g?g:e.id,r=null!=n?n+"":"node-"+t,i=null!==(p=C.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=$.get(r))&&void 0!==x?x:0;N.push({id:r,degree:i+o,inDeg:i,outDeg:o,wDegree:l+a,wInDeg:l,wOutDeg:a})}N.sort((t,e)=>e.degree-t.degree);let I=0,W=0;if(N.length>0){let t=0;for(const e of N)t+=e.degree,e.degree>W&&(W=e.degree);I=t/N.length}const z=D.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)}),R=[`${N.length} nodes, ${D.length} edges.`];N.length>0&&R.push(`Mean degree: ${Ve(I)}, max degree: ${W}.`);const B=N.slice(0,5);return t.createElement("div",{ref:S,id:i,tabIndex:-1,onBlur:P,style:qe,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:Ke},"×"),t.createElement("div",{role:"note",style:Ue},R.join(" ")),t.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:Ze},t.createElement("caption",{style:tn},"Top ",B.length," of ",N.length," nodes by degree"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Qe},"id"),t.createElement("th",{style:Qe},"degree"),t.createElement("th",{style:Qe},"in"),t.createElement("th",{style:Qe},"out"),z&&t.createElement("th",{style:Qe},"w. degree"),z&&t.createElement("th",{style:Qe},"w. in"),z&&t.createElement("th",{style:Qe},"w. out"))),t.createElement("tbody",null,B.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:Je},e.id),t.createElement("td",{style:Je},e.degree),t.createElement("td",{style:Je},e.inDeg),t.createElement("td",{style:Je},e.outDeg),z&&t.createElement("td",{style:Je},Ve(e.wDegree)),z&&t.createElement("td",{style:Je},Ve(e.wInDeg)),z&&t.createElement("td",{style:Je},Ve(e.wOutDeg)))))))}function rn({summary:e}){return e?t.createElement("div",{role:"note",style:He},e):null}function on({tableId:e}){return t.createElement("a",{href:"#"+e,style:He,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,He)}},"Skip to data table")}function ln({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.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:He},n)}const an="var(--semiotic-focus, #005fcc)";function sn({active:e,hoverPoint:n,margin:r,size:i,shape:o="circle",width:l,height:a}){if(!e||!n)return null;const s=n.x+r.left,c=n.y+r.top;let u;if("rect"===o&&null!=l&&null!=a){const e=Math.max(l,4),n=Math.max(a,4);u=t.createElement("rect",{x:s-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:an,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.createElement("circle","wedge"===o?{cx:s,cy:c,r:12,fill:"none",stroke:an,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:an,strokeWidth:2,strokeDasharray:"4,2"});return t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},u)}function cn({x:e,y:n,containerWidth:r,containerHeight:i,margin:o,children:l,className:a="stream-frame-tooltip",zIndex:s=1}){const c=t.useRef(null),[u,d]=t.useState(null);t.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})},[l,a,r,i]);let h;return h=u?`translate(${u.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`,t.createElement("div",{ref:c,className:a,style:{position:"absolute",left:o.left+e,top:o.top+n,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"}},l)}function un(r){const s=o(null),c=dn(r);return[function({children:e}){const i=n(()=>dn(r),[]);return t.createElement(s.Provider,{value:i,children:e})},t=>{var n;const r=null!==(n=l(s))&&void 0!==n?n:c,o=e(t);o.current=t;const u=a(()=>o.current(r.getState()),[r]),d=a(()=>o.current(r.getState()),[r]);return i(r.subscribe,u,d)}]}function dn(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 hn(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:fn})})),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 fn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],yn={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}},gn={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}},pn={mode:"light",colors:{primary:"#0000cc",categorical:fn,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"},[vn,mn]=un(t=>({theme:yn,setTheme(e){t(t=>{if("light"===e)return{theme:yn};if("dark"===e)return{theme:gn};if("high-contrast"===e)return{theme:pn};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?gn:yn;return{theme:hn(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:hn(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||{})}))}})}}));const xn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,bn=new WeakMap;let kn=0,wn=!1,En=null,An=null,Mn=null;function Sn(t,e){var n,r;if(!e)return e;const i=xn.exec(e);if(!i)return e;const o=t.canvas;if(!o)return(null===(n=i[2])||void 0===n?void 0:n.trim())||e;!function(){if(wn)return;if("undefined"==typeof window||"undefined"==typeof document)return;wn=!0;const t=()=>{kn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(En=new MutationObserver(t),En.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{An=window.matchMedia("(prefers-color-scheme: dark)"),Mn=t,"function"==typeof An.addEventListener?An.addEventListener("change",Mn):"function"==typeof An.addListener&&An.addListener(Mn)}catch(t){}}();let l=bn.get(o);l&&l.version===kn||(l={version:kn,map:new Map},bn.set(o,l));const a=l.map.get(e);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())||e;return l.map.set(e,s),s}function _n(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Pn(i){const o=function(){const[t,e]=s(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(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=>e(t.matches))},[]),t}(),l=e(o);l.current=o;const[c,u]=function(t,n,i){const o=e(null),[l,a]=s(null);return r(()=>{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;a(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[o,[n&&l?l.w:t[0],i&&l?l.h:t[1]]]}(i.sizeProp,i.responsiveWidth,i.responsiveHeight),d=n(()=>Object.assign(Object.assign({},i.marginDefault),i.userMargin),[i.marginDefault,i.userMargin]),h=u[0]-d.left-d.right,f=u[1]-d.top-d.bottom,y=_n(i.foregroundGraphics,u,d),g=_n(i.backgroundGraphics,u,d),p=mn(t=>t.theme),{transition:v,introEnabled:m}=function(t,e){var n,r;if(!1===t)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:t?!0===t?{duration:300}:{duration:null!==(r=t.duration)&&void 0!==r?r:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(i||!t||!0!==t&&!1===t.intro)}}(i.animate,i.transitionProp),x="semiotic-table-"+t.useId(),b=e(0),k=e(()=>{}),w=a(()=>{b.current||(b.current=requestAnimationFrame(()=>k.current()))},[]);r(()=>()=>{b.current&&(cancelAnimationFrame(b.current),b.current=0)},[]);const E=e(()=>{}),A=e(()=>{}),M=e(null),S=e(0),_=a(()=>{S.current=0;const t=M.current;M.current=null,t&&E.current(t)},[]),P=a(t=>{M.current={clientX:t.clientX,clientY:t.clientY},0===S.current&&(S.current=requestAnimationFrame(_))},[_]),T=a(()=>{M.current=null,0!==S.current&&(cancelAnimationFrame(S.current),S.current=0),A.current()},[]);r(()=>()=>{M.current=null,0!==S.current&&(cancelAnimationFrame(S.current),S.current=0)},[]);const D=i.themeDirtyRef;return r(()=>{D&&(kn++,D.current=!0,w())},[p,w,D]),{reducedMotion:o,reducedMotionRef:l,responsiveRef:c,size:u,margin:d,adjustedWidth:h,adjustedHeight:f,resolvedForeground:y,resolvedBackground:g,currentTheme:p,transition:v,introEnabled:m,tableId:x,rafRef:b,renderFnRef:k,scheduleRender:w,hoverHandlerRef:E,hoverLeaveRef:A,onPointerMove:P,onPointerLeave:T}}function Tn(t,e,n,r){const i=t.getContext("2d");if(!i)return null;const o=e[0]*r,l=e[1]*r,a=e[0]+"px",s=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==s&&(t.style.height=s),t.width===o&&t.height===l||(t.width=o,t.height=l),i.setTransform(r,0,0,r,0,0),i.translate(n.left,n.top),i}function Dn(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Cn(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return j;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function Ln(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function On(t,e,n,r,i,o){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],r=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=o;for(let n=0;e.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),t.globalAlpha=Math.max(0,o),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const $n=(t,e,n,r)=>{var i,o;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const s=a._introClipFraction;void 0!==s&&1>s&&(t.save(),t.beginPath(),t.rect(0,0,r.width*s,r.height),t.clip());const c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,d=a.colorThresholds,h=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=u,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const p=null!==(i=a.style.opacity)&&void 0!==i?i:1;On(t,a.path,c,u,p,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=Cn(a.curve),y=d&&d.length>0&&h&&h.length===a.path.length,g=a._decayOpacities;if(g&&g.length===a.path.length&&!y){t.strokeStyle=c;const v=null!==(o=a.style.opacity)&&void 0!==o?o:1;for(let m=0;a.path.length-1>m;m++)t.globalAlpha=.5*(g[m]+g[m+1])*v,t.beginPath(),t.moveTo(a.path[m][0],a.path[m][1]),t.lineTo(a.path[m+1][0],a.path[m+1][1]),t.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),E=!0}function M(){E&&(t.stroke(),E=!1)}for(let S=0;a.path.length>S;S++){const[_,P]=a.path[S],T=h[S],D=Ln(T,d,c);if(null!==x&&null!==w&&null!==k){if(D===w)t.lineTo(_,P);else{const C=[];for(const L of d){const O=L.value;(k>O||O>T)&&(O>k||T>O)||k===O||T===O||C.push({t:(O-k)/(T-k)})}C.sort((t,e)=>t.t-e.t);for(const $ of C){const N=x+(_-x)*$.t,I=b+(P-b)*$.t,W=Ln(k+(T-k)*Math.min($.t+1e-4,1),d,c);t.lineTo(N,I),M(),A(W,N,I)}t.lineTo(_,P)}x=_,b=P,k=T,w=D}else A(D,_,P),x=_,b=P,k=T,w=D}M()}else{if(t.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)t.strokeStyle=c;else{const z=t.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const R of a.strokeGradient.colorStops)z.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);t.strokeStyle=z}if(f)Z().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[B,F]=a.path[0];t.moveTo(B,F);for(let j=1;a.path.length>j;j++)t.lineTo(a.path[j][0],a.path[j][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=("string"==typeof a.style.fill?Sn(t,a.style.fill):a.style.fill)||a.style.fill,f&&!y)Z().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(a.path);else{const[H,X]=a.path[0];t.moveTo(H,X);for(let G=1;a.path.length>G;G++)t.lineTo(a.path[G][0],a.path[G][1])}const Y=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],r.height),t.lineTo(Y,r.height),t.closePath(),t.fill()}void 0!==s&&1>s&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Nn(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function In(t,e,n=.3){Nn(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 Wn(t,e,n=.6){var r,i,o,l,a;if(!Nn(e))return;const s=null!==(r=e._pulseGlowRadius)&&void 0!==r?r:4,c=e.r+s*e._pulseIntensity,u=null!==(o=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==o?o:0,d=null!==(a=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==a?a: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 zn(t,e,n,r=.35){Nn(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Rn(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return j;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function Bn(t){if(t.startsWith("#")){const e=4===t.length?t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t.slice(1,7);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[78,121,167]}function Fn(t,e){const n=Rn(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 r=B().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}const jn=(t,e,n,r)=>{var i,o,l;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,r.width*n,r.height),t.clip());const a=e.style.fill||"#4e79a7",s=e._decayOpacities;if(s&&s.length===e.topPath.length){const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.fillStyle=a;for(let r=0;e.topPath.length-1>r;r++)t.globalAlpha=.5*(s[r]+s[r+1])*n,t.beginPath(),t.moveTo(e.topPath[r][0],e.topPath[r][1]),t.lineTo(e.topPath[r+1][0],e.topPath[r+1][1]),t.lineTo(e.bottomPath[r+1][0],e.bottomPath[r+1][1]),t.lineTo(e.bottomPath[r][0],e.bottomPath[r][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Sn(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*(s[n]+s[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 c=null!==(o=e.style.opacity)&&void 0!==o?o:1;if(Fn(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 r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const i=t.createLinearGradient(0,n,0,r);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||i.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const t=Bn("string"==typeof a?a:"#4e79a7");i.addColorStop(0,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.bottomOpacity})`)}t.fillStyle=i,t.globalAlpha=c}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*c,t.fillStyle=a}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Fn(t,e),zn(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=c,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=Sn(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=Rn(e.curve);if(t.beginPath(),n)Z().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}},Yn=(t,e,n,r)=>{var i;const o=e.filter(t=>"point"===t.type);if(0!==o.length){t.save();try{for(const e of o){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(i=e.style.opacity)&&void 0!==i?i:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=("string"==typeof e.style.fill?Sn(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?Sn(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Wn(t,e),t.globalAlpha=1}}finally{t.restore()}}},Hn=(t,e,n,r)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Xn(t,e);else if(e.roundedTop&&e.roundedTop>0){t.fillStyle=("string"==typeof e.style.fill?Sn(t,e.style.fill):e.style.fill)||"#007bff";const n=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:r,y:i,w:o,h:l}=e;switch(e.roundedEdge){case"right":t.moveTo(r,i),t.lineTo(r+o-n,i),t.arcTo(r+o,i,r+o,i+n,n),t.lineTo(r+o,i+l-n),t.arcTo(r+o,i+l,r+o-n,i+l,n),t.lineTo(r,i+l);break;case"left":t.moveTo(r+o,i),t.lineTo(r+n,i),t.arcTo(r,i,r,i+n,n),t.lineTo(r,i+l-n),t.arcTo(r,i+l,r+n,i+l,n),t.lineTo(r+o,i+l);break;case"bottom":t.moveTo(r,i),t.lineTo(r+o,i),t.lineTo(r+o,i+l-n),t.arcTo(r+o,i+l,r+o-n,i+l,n),t.lineTo(r+n,i+l),t.arcTo(r,i+l,r,i+l-n,n);break;default:t.moveTo(r,i+l),t.lineTo(r,i+n),t.arcTo(r,i,r+n,i,n),t.lineTo(r+o-n,i),t.arcTo(r+o,i,r+o,i+n,n),t.lineTo(r+o,i+l)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else t.fillStyle=("string"==typeof e.style.fill?Sn(t,e.style.fill):e.style.fill)||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Sn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h));In(t,e),t.globalAlpha=1}};function Xn(t,e){const n=e.style.icon,r=e.style.iconPadding||2,i=Math.min(e.w,e.h)-r;if(0>=i)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=i+r,l=e.x+(e.w-i)/2;for(let r=e.y+e.h-i;r>=e.y-i;r-=o)t.drawImage(n,l,r,i,i)}else{const o=i+r,l=e.y+(e.h-i)/2;for(let r=e.x;e.x+e.w>r;r+=o)t.drawImage(n,r,l,i,i)}t.restore()}function Gn(t,e,n,r){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}),r)}function Vn(t){const[e,n,r]=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*r>128?"#000":"#fff"}function qn(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Un=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Kn(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`${Un[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Un[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Zn={line:[jn,$n,Yn],area:[jn,Yn],stackedarea:[jn,Yn],scatter:[Yn],bubble:[Yn],heatmap:[(t,e,n,r)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){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="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),In(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):qn(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,o=e.y+e.h/2;t.fillStyle=Vn(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,o)}}}finally{t.restore()}}],bar:[Hn],swarm:[Yn],waterfall:[(t,e,n,r)=>{var i,o,l;Hn(t,e);const a=e.filter(t=>"rect"===t.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const r=a[e],i=a[e+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;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const r=e._decayOpacity;if(null!=r&&1!==r&&(t.globalAlpha=r),t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke(),e.isRange){const n=Math.max(2*e.wickWidth,4);t.fillStyle=e.wickColor,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),r=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor;t.fillStyle=i,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1)),t.strokeStyle=i,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1))}t.restore()}}],mixed:[jn,$n,Yn]},Qn={top:20,right:20,bottom:30,left:40},Jn={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 tr(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],r=n[2],i=n[3];return`#${t}${t}${r}${r}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const er={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 nr({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:er},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}const rr=c(function(i,o){var l,c,d,h,f,y,g,p,v,m,x;const{chartType:b,runtimeMode:k,data:w,chunkThreshold:E,chunkSize:A,xAccessor:M,yAccessor:S,colorAccessor:_,sizeAccessor:P,groupAccessor:T,lineDataAccessor:D,curve:C,normalize:L,binSize:O,valueAccessor:$,arrowOfTime:N="right",windowMode:I="sliding",windowSize:W=200,timeAccessor:z,xExtent:R,yExtent:B,extentPadding:F=.1,scalePadding:j,sizeRange:Y,size:H=[500,300],responsiveWidth:X,responsiveHeight:G,margin:V,className:q,background:U,lineStyle:K,pointStyle:Z,areaStyle:Q,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:nt,boundsAccessor:rt,boundsStyle:it,y0Accessor:ot,gradientFill:lt,lineGradient:at,areaGroups:st,openAccessor:ct,highAccessor:ut,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,showAxes:pt=!0,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:kt,yFormat:wt,tickFormatTime:Et,tickFormatValue:At,hoverAnnotation:Mt,tooltipContent:St,customHoverBehavior:_t,customClickBehavior:Pt,enableHover:Tt,hoverRadius:Dt=30,tooltipMode:Ct,annotations:Lt,svgAnnotationRules:Ot,showGrid:$t,legend:Nt,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Rt,legendIsolatedCategories:Bt,legendPosition:Ft,backgroundGraphics:jt,foregroundGraphics:Yt,canvasPreRenderers:Gt,svgPreRenderers:Vt,title:qt,categoryAccessor:Ut,brush:Kt,onBrush:Zt,decay:Qt,pulse:re,transition:le,animate:ae,staleness:se,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,marginalGraphics:ye,pointIdAccessor:ge,xScaleType:pe,yScaleType:ve,accessibleTable:me=!0,description:xe,summary:be,linkedCrosshairName:ke,linkedCrosshairSourceId:we}=i,Ee=e(!1),Ae=Pn({sizeProp:H,responsiveWidth:X,responsiveHeight:G,userMargin:V,marginDefault:Qn,animate:ae,transitionProp:le,themeDirtyRef:Ee}),{reducedMotionRef:Me,responsiveRef:Se,size:_e,currentTheme:Pe,transition:Te,introEnabled:De,tableId:Ce,rafRef:Le,renderFnRef:Oe,scheduleRender:$e}=Ae;let Ne=Ae.margin;if(ye){const t=60,e=Object.assign({},Ae.margin);ye.top&&t>e.top&&(e.top=t),ye.bottom&&t>e.bottom&&(e.bottom=t),ye.left&&t>e.left&&(e.left=t),ye.right&&t>e.right&&(e.right=t),Ne=e}const We="function"==typeof Yt?Yt({size:_e,margin:Ne}):Yt,ze="function"==typeof jt?jt({size:_e,margin:Ne}):jt,je=_e[0]-Ne.left-Ne.right,Ye=_e[1]-Ne.top-Ne.bottom,He=null!=Mt?Mt:Tt,Ge=e(null),Ve=e(null),[qe,Ue]=s(0),[Ke,Ze]=s(null),Qe=e(null),Je=e(null),[tn,nn]=s(null),[an,un]=s(!1),[dn,hn]=s([]),[fn,yn]=s([]),gn="streaming"===k||["bar","swarm","waterfall"].includes(b),pn=n(()=>{var t;return{chartType:b,runtimeMode:gn?"streaming":"bounded",windowSize:W,windowMode:I,arrowOfTime:gn?N:"right",extentPadding:F,scalePadding:j,xAccessor:gn?void 0:M,yAccessor:gn?void 0:S,timeAccessor:gn?z:void 0,valueAccessor:$,colorAccessor:_,sizeAccessor:P,groupAccessor:T||(D?"_lineGroup":void 0),categoryAccessor:Ut,lineDataAccessor:D,xScaleType:pe,yScaleType:ve,xExtent:R,yExtent:B,sizeRange:Y,binSize:O,normalize:L,boundsAccessor:rt,boundsStyle:it,y0Accessor:ot,gradientFill:!0===lt?{topOpacity:.8,bottomOpacity:.05}:!1===lt?void 0:lt,areaGroups:st?new Set(st):void 0,lineGradient:at,openAccessor:ct,highAccessor:ut,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,lineStyle:K,pointStyle:Z,areaStyle:Q,swarmStyle:tt,waterfallStyle:J,colorScheme:nt,barColors:et,annotations:Lt,decay:Qt,pulse:re,transition:Te,introAnimation:De,staleness:se,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,pointIdAccessor:ge,curve:C,themeCategorical:null===(t=null==Pe?void 0:Pe.colors)||void 0===t?void 0:t.categorical}},[b,W,I,N,F,j,M,S,z,$,pe,ve,_,P,T,Ut,D,R,B,Y,O,L,rt,it,ot,lt,at,st,ct,ut,dt,yt,gt,K,Z,Q,tt,J,nt,et,Lt,Qt,re,null==Te?void 0:Te.duration,null==Te?void 0:Te.easing,De,se,ce,ue,de,he,fe,gn,ge,C,Pe]),vn=e(null);vn.current||(vn.current=new zt(pn)),r(()=>{var t;null===(t=vn.current)||void 0===t||t.updateConfig(pn),Ee.current=!0,$e()},[pn,$e]);const mn=e(null);mn.current||(mn.current=new ft(t=>{const e=vn.current;e&&e.ingest(t)&&(Ee.current=!0,$e())},{chunkThreshold:E,chunkSize:A})),r(()=>{var t;null===(t=mn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:E,chunkSize:A})},[E,A]);const xn=a(t=>{var e;null===(e=mn.current)||void 0===e||e.push(t)},[]),bn=a(t=>{var e;null===(e=mn.current)||void 0===e||e.pushMany(t)},[]),kn=a(()=>{var t,e;null===(t=mn.current)||void 0===t||t.clear(),null===(e=vn.current)||void 0===e||e.clear(),Ee.current=!0,$e()},[$e]);u(o,()=>({push:xn,pushMany:bn,remove:t=>{var e,n,r;null===(e=mn.current)||void 0===e||e.flush();const i=null!==(r=null===(n=vn.current)||void 0===n?void 0:n.remove(t))&&void 0!==r?r:[];return i.length>0&&(Qe.current&&i.some(t=>{var e;return t===(null===(e=Qe.current)||void 0===e?void 0:e.data)})&&(Qe.current=null,nn(null)),Ee.current=!0,$e()),i},update:(t,e)=>{var n,r,i;null===(n=mn.current)||void 0===n||n.flush();const o=null!==(i=null===(r=vn.current)||void 0===r?void 0:r.update(t,e))&&void 0!==i?i:[];return o.length>0&&(Ee.current=!0,$e()),o},clear:kn,getData:()=>{var t,e,n;return null===(t=mn.current)||void 0===t||t.flush(),null!==(n=null===(e=vn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=vn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=vn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[xn,bn,kn,$e]),r(()=>{var t,e;if(w){if(D&&w.length>0&&"object"==typeof w[0]&&null!==w[0]){const e="string"==typeof D?D:"coordinates";if(Array.isArray(w[0][e])){const n=[];for(const t of w){const r=t[e];if(Array.isArray(r)){const e=t.label||t.id||t.key;if(null!=e)for(const t of r)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of r)n.push(t)}}return void(null===(t=mn.current)||void 0===t||t.setBoundedData(n))}}null===(e=mn.current)||void 0===e||e.setBoundedData(w)}},[w,D]);const{hoverHandlerRef:wn,hoverLeaveRef:En,onPointerMove:An,onPointerLeave:Mn}=Ae;wn.current=t=>{if(!He)return;const e=Ge.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Ne.left,i=t.clientY-n.top-Ne.top;if(0>r||r>je||0>i||i>Ye)return void(Qe.current&&(Qe.current=null,Je.current=null,nn(null),_t&&(_t(null),Ee.current=!0),$e()));const o=vn.current;if(!o||0===o.scene.length)return;const l=Ht(o.scene,r,i,Dt,o.quadtree,o.maxPointRadius);if(!l)return void(Qe.current&&(Qe.current=null,Je.current=null,nn(null),_t&&_t(null),$e()));const a=Gn(l.datum||{},l.x,l.y);if("multi"===Ct&&o.scene.length>0&&o.scales){const t=function(t,e,n=30){const r=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const o=Xt(t.path,e,n);if(null===o)continue;const l=Jt(t.path,e);r.push({node:i,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][0],y:o,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const o=Xt(t.topPath,e,n);if(null===o)continue;const l=Jt(t.topPath,e);r.push({node:i,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:o,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return r}(o.scene,l.x,Dt),e=o.scales.y.invert,n=o.scales.x.invert;if(t.length>0){const r=n?n(l.x):l.x;a.xValue=r,a.xPx=l.x,a.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||"#007bff",datum:t.datum}))}}Qe.current=a,Je.current=l.node,nn(a),_t&&(_t(a),Ee.current=!0),$e()},En.current=()=>{Qe.current&&(Qe.current=null,Je.current=null,nn(null),_t&&(_t(null),Ee.current=!0),$e())};const Sn=e(()=>{});Sn.current=t=>{if(!Pt)return;const e=Ge.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Ne.left,i=t.clientY-n.top-Ne.top;if(0>r||r>je||0>i||i>Ye)return void Pt(null);const o=vn.current;if(!o||0===o.scene.length)return void Pt(null);const l=Ht(o.scene,r,i,Dt,o.quadtree,o.maxPointRadius);Pt(l?Gn(l.datum||{},l.x,l.y):null)};const _n=a(t=>Sn.current(t),[]),Cn=e(-1),Ln=e(null),On=e(null),$n=a(t=>{const e=vn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(On.current&&On.current.version===n)r=On.current.graph;else{const t=function(t){var e,n,r,i;const o=[];for(const l of t)switch(l.type){case"point":o.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(e=l.group)&&void 0!==e?e:"_default"});break;case"line":{const t=l,e=Array.isArray(t.datum)?t.datum:[],r=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)o.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:r});break}case"area":{const t=l,e=Array.isArray(t.datum)?t.datum:[],n=null!==(r=t.group)&&void 0!==r?r:"_default";for(let r=0;t.topPath.length>r&&e.length>r;r++)o.push({x:t.topPath[r][0],y:t.topPath[r][1],datum:e[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((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;r=te(t),On.current={version:n,graph:r}}const i=Cn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Cn.current=0;const e=r.flat[0];Ln.current={shape:e.shape,w:e.w,h:e.h};const n=ie(e);return Qe.current=n,nn(n),_t&&_t(n),void $e()}const o=ee(r,i),l=ne(t.key,o,r);if(null===l)return;if(t.preventDefault(),0>l)return Cn.current=-1,Ln.current=null,Qe.current=null,Je.current=null,nn(null),_t&&_t(null),void $e();Cn.current=l;const a=r.flat[l];Ln.current={shape:a.shape,w:a.w,h:a.h};const s=ie(a);Qe.current=s,nn(s),_t&&_t(s),$e()},[_t,$e]),Nn=a(t=>{Cn.current=-1,Ln.current=null,An(t)},[An]);Oe.current=()=>{var t,e;Le.current=0;const n=Ge.current,r=Ve.current;if(!n||!r)return;const i=vn.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(Me.current?o+1e6:o),a=!Me.current&&l,s=Ee.current||l;s&&!a&&i.computeScene({width:je,height:Ye});const c=Dn(),u=function(t){if(!t)return Jn;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),o=r||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),s=i||e.getPropertyValue("--surface-0").trim();return o||l||n?{axisStroke:a||Jn.axisStroke,tickText:o||Jn.tickText,crosshair:o?tr(o,"66"):Jn.crosshair,hoverFill:s?tr(s,"4D"):Jn.hoverFill,hoverStroke:o?tr(o,"99"):Jn.hoverStroke,pointRing:s||Jn.pointRing}:Jn}(n),d=null!==(t=null==se?void 0:se.threshold)&&void 0!==t?t:5e3,h=se&&i.lastIngestTime>0&&o-i.lastIngestTime>d;if(s){const t=Tn(n,_e,Ne,c);if(t){if(t.clearRect(-Ne.left,-Ne.top,_e[0],_e[1]),h&&(t.globalAlpha=null!==(e=null==se?void 0:se.dimOpacity)&&void 0!==e?e:.5),"transparent"!==U&&!jt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),r=U||(e&&"transparent"!==e?e:null);r&&(t.fillStyle=r,t.fillRect(-Ne.left,-Ne.top,_e[0],_e[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,je,Ye),t.clip()),Gt&&i.scales)for(const e of Gt)t.save(),e(t,i.scene,i.scales,{width:je,height:Ye}),t.restore();const r=Zn[b];if(r&&i.scales)for(const e of r)e(t,i.scene,i.scales,{width:je,height:Ye});t.restore(),h&&(t.globalAlpha=1)}}{const t=Tn(r,_e,Ne,c);if(t&&(t.clearRect(-Ne.left,-Ne.top,_e[0],_e[1]),He&&Qe.current&&i.scales&&function(t,e,n,r,i,o,l){var a,s;if(!1===i.crosshair)return;const c=e.allSeries,u=c&&c.length>0,d=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const h="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=h.stroke||l.crosshair,t.lineWidth=h.strokeWidth||1,t.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(u?d:e.x,0),t.lineTo(u?d:e.x,r),t.stroke(),u||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),u){t.lineWidth=2,t.strokeStyle=l.pointRing;for(const e of c)null!=e.valuePx&&(t.beginPath(),t.arc(d,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||"#007bff",t.fill(),t.stroke())}else{let n="";try{(null===(s=t.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(t.canvas).getPropertyValue("--semiotic-primary").trim())}catch(t){}const r=i.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}(o)||n||"#007bff";t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=r,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,Qe.current,je,Ye,"object"==typeof He?He:{},Je.current,u),Je.current&&Array.isArray(Mt))){const e=Mt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r){var i;if(!n)return;const o=n.group;if(void 0!==o)for(const n of e){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?r.style(n.datum):r.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||"#007bff",t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(i=e.opacity)&&void 0!==i?i:1,t.stroke(),t.restore()}}(t,i.scene,Je.current,e)}}s&&n&&n.setAttribute("aria-label",Xe(i.scene,b+" chart"));const f=Ee.current;if(Ee.current=!1,f&&i.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Ke||t(Ke.x.domain()[0])!==t(i.scales.x.domain()[0])||t(Ke.x.domain()[1])!==t(i.scales.x.domain()[1])||t(Ke.y.domain()[0])!==t(i.scales.y.domain()[0])||t(Ke.y.domain()[1])!==t(i.scales.y.domain()[1])||Ke.x.range()[0]!==i.scales.x.range()[0]||Ke.x.range()[1]!==i.scales.x.range()[1]||Ke.y.range()[0]!==i.scales.y.range()[0]||Ke.y.range()[1]!==i.scales.y.range()[1])&&Ze(i.scales),ye){const t=i.getData(),e="function"==typeof M?M:t=>t[M||"x"],n="function"==typeof S?S:t=>t[S||"y"];hn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),yn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Lt&&Lt.length>0&&Ue(t=>t+1),(null==se?void 0:se.showBadge)&&un(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Le.current=requestAnimationFrame(()=>Oe.current()))},r(()=>($e(),()=>{var t;null===(t=mn.current)||void 0===t||t.clear()}),[$e]),r(()=>{Ee.current=!0,$e()},[b,je,Ye,pt,U,K,Gt,$e]),oe(se,vn,Ee,$e,an,un);const In=n(()=>{if(kt||Et)return;const t=vn.current;return(null==t?void 0:t.xIsDate)&&Ke?Kn(Ke.x.domain()):void 0},[kt,Et,Ke]),Wn=kt||Et||In,zn=He&&tn?St?St(tn):t.createElement(nr,{hover:tn}):null,Rn=zn?t.createElement(cn,{x:tn.x,y:tn.y,containerWidth:je,containerHeight:Ye,margin:Ne,className:"stream-frame-tooltip"},zn):null,Bn=Ln.current,Fn=t.createElement(sn,{active:Cn.current>=0,hoverPoint:tn,margin:Ne,size:_e,shape:null==Bn?void 0:Bn.shape,width:null==Bn?void 0:Bn.w,height:null==Bn?void 0:Bn.h}),jn=(t,e,n,r)=>"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:r,fn:e}:{key:void 0,fn:null},Yn=jn(M,z,"__semiotic_resolvedX","__semiotic_resolvedTime"),Hn=jn(S,$,"__semiotic_resolvedY","__semiotic_resolvedValue"),Xn=Yn.key,Vn=Hn.key,qn=Lt&&Lt.length>0,Un=t=>{if(!t||!qn||!Yn.fn&&!Hn.fn)return t;let e=!1;const n=t.map(t=>{const n=Yn.fn&&Yn.key&&!(Yn.key in t),r=Hn.fn&&Hn.key&&!(Hn.key in t);if(!n&&!r)return t;e=!0;const i=Object.assign({},t);return n&&(i[Yn.key]=Yn.fn(t)),r&&(i[Hn.key]=Hn.fn(t)),i});return e?n:t};if(Fe){const e=vn.current;e&&w&&(e.ingest({inserts:w,bounded:!0}),e.computeScene({width:je,height:Ye}));const n=null!==(l=null==e?void 0:e.scene)&&void 0!==l?l:[],r=null!==(c=null==e?void 0:e.scales)&&void 0!==c?c:null,i=Wn||(()=>{if((null==e?void 0:e.xIsDate)&&r)return Kn(r.x.domain())})();return t.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":xe||("string"==typeof qt?qt:"XY chart"),style:{position:"relative",width:_e[0],height:_e[1]}},t.createElement(rn,{summary:be}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:_e[0],height:_e[1],style:{position:"absolute",left:0,top:0}},t.createElement("g",{transform:`translate(${Ne.left},${Ne.top})`},ze),t.createElement("g",{transform:`translate(${Ne.left},${Ne.top})`},U&&t.createElement("rect",{x:0,y:0,width:je,height:Ye,fill:U}),Vt&&r&&Vt.map((e,i)=>t.createElement(t.Fragment,{key:"svgpre-"+i},e(n,r,{width:je,height:Ye}))),n.map((e,n)=>function(e,n){var r,i,o;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const i="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+n,d:i,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const l=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+n,d:`M${l}L${a}Z`,fill:Be(o.style.fill),fillOpacity:null!==(i=null!==(r=o.style.fillOpacity)&&void 0!==r?r:o.style.opacity)&&void 0!==i?i:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const r=e;return t.createElement("circle",{key:"point-"+n,cx:r.x,cy:r.y,r:r.r,fill:Be(r.style.fill),opacity:null!==(o=r.style.opacity)&&void 0!==o?o:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"rect":{const r=e;return t.createElement("rect",{key:"rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Be(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"heatcell":{const r=e;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const e=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[i,o,l]=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]}(r.fill),a=.299*i+.587*o+.114*l>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return t.createElement("g",{key:"heatcell-"+n},t.createElement("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t.createElement("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return t.createElement("rect",{key:"heatcell-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill})}case"candlestick":{const r=e,i=Math.min(r.openY,r.closeY),o=Math.max(Math.abs(r.openY-r.closeY),1),l=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+n},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:i,width:r.bodyWidth,height:o,fill:l,stroke:l,strokeWidth:1}))}default:return null}}(e,n)).filter(Boolean))),t.createElement(Re,{width:je,height:Ye,totalWidth:_e[0],totalHeight:_e[1],margin:Ne,scales:r,showAxes:pt,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:i,yFormat:wt||At,showGrid:$t,title:qt,legend:Nt,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Rt,legendIsolatedCategories:Bt,legendPosition:Ft,foregroundGraphics:We,marginalGraphics:ye,xValues:[],yValues:[],annotations:Lt,svgAnnotationRules:Ot,annotationFrame:0,xAccessor:Xn,yAccessor:Vn,annotationData:Un(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof C?C:void 0,linkedCrosshairName:ke,linkedCrosshairSourceId:we}))}return t.createElement("div",{ref:Se,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":xe||("string"==typeof qt?qt:"XY chart"),tabIndex:0,style:{position:"relative",width:X?"100%":_e[0],height:G?"100%":_e[1],overflow:"visible"},onKeyDown:$n},me&&t.createElement(on,{tableId:Ce}),me&&t.createElement(en,{scene:null!==(h=null===(d=vn.current)||void 0===d?void 0:d.scene)&&void 0!==h?h:[],chartType:b+" chart",tableId:Ce,chartTitle:"string"==typeof qt?qt:void 0}),t.createElement(rn,{summary:be}),t.createElement("div",{role:"img","aria-label":xe||("string"==typeof qt?qt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:He?Nn:void 0,onMouseLeave:He?Mn:void 0,onClick:Pt?_n:void 0},ze&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:_e[0],height:_e[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${Ne.left},${Ne.top})`},ze)),t.createElement(Ie,{width:je,height:Ye,totalWidth:_e[0],totalHeight:_e[1],margin:Ne,scales:Ke,showAxes:pt,axes:vt,showGrid:$t,xFormat:Wn,yFormat:wt||At}),t.createElement("canvas",{ref:Ge,"aria-label":Xe(null!==(y=null===(f=vn.current)||void 0===f?void 0:f.scene)&&void 0!==y?y:[],b+" chart"),style:{position:"absolute",left:0,top:0}}),t.createElement("canvas",{ref:Ve,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.createElement(ln,{hoverPoint:tn}),t.createElement(Re,{width:je,height:Ye,totalWidth:_e[0],totalHeight:_e[1],margin:Ne,scales:Ke,showAxes:pt,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:Wn,yFormat:wt||At,showGrid:$t,title:qt,legend:Nt,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Rt,legendIsolatedCategories:Bt,legendPosition:Ft,foregroundGraphics:We,marginalGraphics:ye,xValues:dn,yValues:fn,annotations:Lt,svgAnnotationRules:Ot,annotationFrame:qe,xAccessor:Xn,yAccessor:Vn,annotationData:Un(null===(g=vn.current)||void 0===g?void 0:g.getData()),pointNodes:null===(p=vn.current)||void 0===p?void 0:p.scene.filter(t=>"point"===t.type),curve:"string"==typeof C?C:void 0,underlayRendered:!0,linkedCrosshairName:ke,linkedCrosshairSourceId:we}),(Kt||Zt)&&t.createElement(ht,{width:je,height:Ye,totalWidth:_e[0],totalHeight:_e[1],margin:Ne,dimension:null!==(v=null==Kt?void 0:Kt.dimension)&&void 0!==v?v:"xy",scales:Ke,onBrush:null!=Zt?Zt:()=>{},binSize:O,snap:null==Kt?void 0:Kt.snap,binBoundaries:null!==(m=null==Kt?void 0:Kt.binBoundaries)&&void 0!==m?m:"bar"===b?null===(x=vn.current)||void 0===x?void 0:x.getBinBoundaries():void 0,snapDuring:null==Kt?void 0:Kt.snapDuring,streaming:"streaming"===k}),(null==se?void 0:se.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===se.badgePosition?{top:4,left:4}:"bottom-left"===se.badgePosition?{bottom:4,left:4}:"bottom-right"===se.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:an?"#dc3545":"#28a745",color:"white"})},an?"STALE":"LIVE"),Fn,Rn))});rr.displayName="StreamXYFrame";const ir={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},or={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class lr{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,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+=t*e*s*(a.bezier.circular?.3:1),1>l.t?ar(a.bezier,l.t,l.offset,l):(l.active=!1,this._freeIndices.push(o))}}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 ar(t,e,n,r){if(t.circular&&t.segments)return void function(t,e,n,r,i){const o=t.length,l=e*o,a=Math.min(Math.floor(l),o-1),s=l-a,[c,u,d,h]=t[a];sr(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 t=f/g;i.x+=-y/g*n*r*2,i.y+=t*n*r*2}}(t.segments,e,n,t.halfWidth,r);if(!t.points)return r.x=0,void(r.y=0);const[i,o,l,a]=t.points;sr(i,o,l,a,e,r);const s=a.x-i.x,c=a.y-i.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;r.x+=-c/u*n*t.halfWidth*2,r.y+=e*n*t.halfWidth*2}}function sr(t,e,n,r,i,o){const l=1-i,a=l*l,s=a*l,c=i*i,u=c*i;o.x=s*t.x+3*a*i*e.x+3*l*c*n.x+u*r.x,o.y=s*t.y+3*a*i*e.y+3*l*c*n.y+u*r.y}function cr(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function ur(t,e){var n,r=[],i=[],o=[],l={},a=[];function s(t){o[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],o[e]&&s(e)})}function c(t){var e,r,d=!1;for(i.push(t),o[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,i),d=!0):o[r]||(d=c(r));if(d)s(t);else for(e=0;a[t].length>e;e++){var h=l[r=a[t][e]];h||(l[r]=h={}),h[r]=!0}return i.pop(),d}function u(t,e){var n=[].concat(e).concat(t);r.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,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),i=Array(e),o=Array(e),l=Array(e),a=Array(e),s=0;e>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(e){var s=[e],c=[e];for(n[e]=r[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>o[e]){for(var y=o[e];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[e]=0|Math.min(r[e],r[g])),0>l[g]||a[e].push(l[g])}o[e]=y}else{if(r[e]===n[e]){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===e){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;e>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(t,e){return t-e}),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}}(t),i=r.components.filter(function(t){return t.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=t.map(function(t,e){return-1===s.indexOf(e)?[]:t.filter(function(t){return-1!==s.indexOf(t)})});return{leastVertex:o,adjList:c}}n=0;for(var h=t.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 dr(t){return t.y0-t.y1>0?"up":"down"}function hr(t,e){return e(t.source)==e(t.target)}function fr(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 yr(t){return t.target.x0-t.source.x1}function gr(t,e){var n=vr(t),r=yr(e)/Math.tan(n);return"up"==dr(t)?t.y1-r:t.y1+r}function pr(t,e){var n=vr(t),r=yr(e)/Math.tan(n);return"up"==dr(t)?t.y1+r:t.y1-r}function vr(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function mr(t,e){return e(t)}function xr(t){return kr(t.source)}function br(t){return kr(t.target)}function kr(t){return(t.y0+t.y1)/2}function wr(t){return t.virtual?0:t.value}function Er(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!hr(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!hr(t,e)?r+1:r}),n+r}function Ar(t){return t.target.depth}function Mr(t,e){return t.sourceLinks.length?t.depth:e-1}function Sr(t,e){return t.y0-e.y0}function _r(t,e){return e.y0-t.y0}function Pr(t,e){return t.y1-e.y1}function Tr(t,e){return e.y1-t.y1}function Dr(t,e){return Lr(t.source,e.source)||t.index-e.index}function Cr(t,e){return Lr(t.target,e.target)||t.index-e.index}function Lr(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Or(t,e){return $r(t)==$r(e)?"bottom"==t.circularLinkType?_r(t,e):Sr(t,e):$r(e)-$r(t)}function $r(t){return t.target.column-t.source.column}function Nr(t,e){return Ir(t)==Ir(e)}function Ir(t){return t.y0-t.y1>0?"up":"down"}function Wr(t,e,n,r,i){let o=t;var l=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var a=S(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=o.links.filter(function(t){return t.circular});return s.sort(function(t,e){return e.value-t.value}),s.forEach(function(t,e){t._circularStub=e>=4}),zr(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),zr(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,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,hr(t,e)&&fr(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+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-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,s=t.circularLinkType,c=o.links.filter(function(t){return t.source.column==l&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?_r:Sr);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=o.links.filter(function(t){return t.target.column==l&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?Tr:Pr),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+i+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-i-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,r=t.target.x0,i=t.y1,o=(e+r)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(t)}),o}function zr(t,e,n){t.sort(Or);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(hr(t,e)&&fr(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Rr(t,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Rr(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Br(t){return function(){return t}}function Fr(t){return t.index}function jr(t){return t.nodes}function Yr(t){return t.links}function Hr(t,e,n){var r=_(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(i,o){var l=i.length;if(e)i.sort(e);else if(o>0){var a=new Map;i.forEach(function(t,e){var n,r,i,o=(r=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=kr(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=kr(t.target)*e,r+=e}}),r>0?i/r:NaN);a.set(t,{bc:o,idx:e})}),i.sort(function(t,e){var n=a.get(t),r=a.get(e),i=n.bc,o=r.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(i)||isNaN(o)?isNaN(i)?isNaN(o)?n.idx-r.idx:1:-1:i-o})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Er(e,n)-Er(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==r.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Er(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+i,e.y1=e.y0+e.value*t.ky)})})}function Xr(t,e,n,r,i,o){var l=_(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,s=o;s>0;--s)c(a*=.99,n),u();function c(e,n){var r=l.length;l.forEach(function(i){var o=i.length,l=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Er(i,n)>0){var s=D(i.sourceLinks,br),c=D(i.targetLinks,xr),u=s&&c?(s+c)/2:s||c;if(u){var d=(u-kr(i))*e*.3;i.y0+=d,i.y1+=d}}else if(0==l&&1==o)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(l==r-1&&1==o)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var h=D(i.sourceLinks,br),f=D(i.targetLinks,xr),y=((h&&f?(h+f)/2:h||f)-kr(i))*e;i.y0+=y,i.y1+=y}})})}function u(){l.forEach(function(n){var o,l,a,s=t.y0,c=n.length;for(n.sort(e||Lr),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-t.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 Gr(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Cr),t.targetLinks.sort(Dr)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,i=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Vr(){var t=0,e=0,n=1,r=1,i=24,o=8,l=null,a=Fr,s=Mr,c=void 0,u=32,d=2,h=jr,f=Yr;function y(){var y={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=r,h.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 C(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 r=t.source,i=t.target;"object"!=typeof r&&(r=t.source=cr(n,r)),"object"!=typeof i&&(i=t.target=cr(n,i)),r.sourceLinks.push(t),i.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var r=[],i=0;t.links.length>i;i++){var o=t.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=ur(r);s.sort(function(t,e){return t.length-e.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}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][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++)})}(h,c),function(t,e){var n=0,r=0;t.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++,t.nodes.forEach(function(t){mr(t,e)!=mr(i.source,e)&&mr(t,e)!=mr(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),hr(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(T(t.sourceLinks,wr),T(t.targetLinks,wr)),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)})})}(h),function(t,e,n){var r,i,o;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==a?l:l+1,a=e(t)==a?a:e(t),t.column=l})}for(r=t.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(r=t.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,o):t.column})}(h,c,s);var f=o;if(null!==l){var y=_(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=P(y,function(t){return t.length});g>1&&(f=Math.max(1,(r-e)*l/(g-1)))}(function(t,e,n){var r=_(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 i=S(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/T(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var o=P(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/o),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,i),Hr(h,c,a),Xr(h,c,a,f,f,u),Gr(h),Wr(h,a,d,10,8),Hr(h,c,a),Xr(h,c,a,f,f,u),Gr(h),Wr(h,a,d,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 r=n.links.filter(function(n){return mr(n.source,e)==mr(t,e)}),i=r.length;i>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Nr(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=gr(e,t);return t.y1-n}if(e.target.column>t.target.column)return gr(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 o=t.y0;r.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,l=0;i>o;o++)l+=r[o].width;e.y0=t.y1-l-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return mr(n.target,e)==mr(t,e)}),i=r.length;i>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Nr(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=pr(e,t);return t.y0-n}if(e.source.column>t.source.column)return pr(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 o=t.y0;r.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,l=0;i>o;o++)l+=r[o].width;e.y1=t.y1-l-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,r=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==r||0==i){var o=S(e,function(t){return t.y0}),l=P(e,function(t){return t.y1}),a=(t.y1-t.y0)/(l-o);function s(e){return(e-o)/(l-o)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1)}),n.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=s(t.y0)-t.y0;t.y0=s(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})})}}(h),Wr(h,a,d,10,8)}(y),y}return y.update=function(t){return Gr(t),Wr(t,a,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(i=+t,y):i},y.nodePadding=function(t){return arguments.length?(o=+t,y):o},y.nodePaddingRatio=function(t){return arguments.length?(l=+t,y):l},y.nodes=function(t){return arguments.length?(h="function"==typeof t?t:Br(t),y):h},y.links=function(t){return arguments.length?(f="function"==typeof t?t:Br(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Br(t),y):a},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:Br(t),y):s},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(d=+t,y):d},y.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],r=+i[1][1],y):[[t,e],[n,r]]},y.size=function(i){return arguments.length?(t=e=0,n=+i[0],r=+i[1],y):[n-t,r-e]},y}const qr=t=>{let e,n,r,i,o,l,a,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,o=t.source.x1,l=t.target.x0,a=et(o,l),s=a(.5),c=a(.5),`M${e},${o}C${e},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${i},${s} ${i},${o}Z`):(e=t.source.x1,n=t.target.x0,a=et(e,n),r=a(.5),i=a(.5),o=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${i},${l} ${n},${l}L${n},${s}C${i},${s} ${r},${c} ${e},${c}Z`)};function Ur(t){var e;const n=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,r=i.sourceY,o=i.targetX,l=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${e},${r-n}L${e+a},${r-n}L${e+a},${r+n}L${e},${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"===t.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 Kr=new Set,Zr=new WeakMap;function Qr(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Zr.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Zr.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Kr.has(t)||(Kr.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,r)}});return n.set(e,r),r}const Jr={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(Ar))-1:0},justify:Mr},ti={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var i,o,l,a,s,c,u;if(0===t.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=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],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Vr().extent(m).links(v).nodes(p).nodeAlign(Jr[h]||Mr).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=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;t>o.leftFullExtent-l&&(t=o.leftFullExtent-l),o.rightFullExtent+l>e&&(e=o.rightFullExtent+l),n>o.verticalFullExtent-l&&(n=o.verticalFullExtent-l),o.verticalFullExtent+l>i&&(i=o.verticalFullExtent+l)}const o=e-t,l=i-n,u=r[0],d=r[1];if(o>0&&l>0&&(0>t||0>n||e>u||i>d)){const e=Math.min(u/o,d/l),r=-t*e+(u-o*e)/2,i=-n*e+(d-l*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of v)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,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+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,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,r="object"==typeof e&&null!==e?e.id:e+"",i="object"==typeof n&&null!==n?n.id:n+"",o=k.get(t._edgeKey?t._edgeKey:`${r}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=d;const e=b.get(r),n=b.get(i);e&&(o.source=e),n&&(o.target=n)}}},buildScene(t,e,n,r){var i,o,l,a;const s="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,d=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:b,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const g=[],p=[],v=[],m=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 r=c?c(Qr(e,"nodeStyle")):{},i={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};m.set(e.id,("string"==typeof i.fill?i.fill:null)||y.get(e.id)||"#4d430c"),g.push("down"===s?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:i,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r="#999";r="function"==typeof h?h(t)||r:"target"===h?m.get(n.id)||y.get(n.id)||r:m.get(e.id)||y.get(e.id)||r;const i=u?u(Qr(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=i.fill||r;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+a},${e.sourceY-n}L${e.sourceX+a},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:d,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(l=i.fillOpacity)&&void 0!==l?l:d,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let s;if(s=t.circular&&t.circularPathData?Ur(t):qr(t),!s)continue;const c={fill:i.fill||r,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:d,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};p.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,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){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const o=e?e(n):n.id;if(!o)continue;let l,a,c;"down"===s?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,c="middle"):(r[0]/2>n.x0+t/2?(l=n.x0-6,c="end"):(l=n.x1+6,c="start"),a=n.y0+i/2),v.push({x:l,y:a,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:g,sceneEdges:p,labels:v}}},ei={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var i,o;if(0===t.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 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 h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const r=ni(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const i=ri(t.id),o=i%360*(Math.PI/180),l=10+i%20;t.x=e/r.length+l*Math.cos(o),t.y=n/r.length+l*Math.sin(o)}else{const e=ri(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=a+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),i=n*e;r.x=a+t*Math.cos(i),r.y=s+t*Math.sin(i)}}}const f=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:h?40:f,g=ii(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t);if(y>0){const n=nt().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),r=rt().force("charge",it().strength(t=>-25*p(t))).force("center",ot(a,s).strength(.8)).force("x",lt(a).strength(.15)).force("y",at(s).strength(.15));if(r.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}));r.force("link",n),r.force("link").links(t)}h?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;y>t;++t)r.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var i,o,l;const a=n.nodeStyle,s=n.edgeStyle,c=ii(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:b,d=new Map;t.forEach((t,e)=>{d.set(t.id,u[e%u.length])});const h=[],f=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=c(Qr(e,"nodeSize")),n=a?a(Qr(e,"nodeStyle")):{},r={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:2,opacity:n.opacity};h.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=s?s(Qr(t,"edgeStyle")):{},i={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(l=r.opacity)&&void 0!==l?l:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:i,datum:t})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||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 r=c(Qr(n,"nodeSize"));y.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:h,sceneEdges:f,labels:y}}};function ni(t,e,n){const r=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,o="string"==typeof i.target?i.target:i.target.id;let l=null;if(e===t?l=o:o===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function ri(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 ii(t,e,n){var r,i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],l=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===l.length)return()=>o[0];const a=null!==(r=S(l))&&void 0!==r?r:0,s=null!==(i=P(l))&&void 0!==i?i:1;if(a===s)return()=>(o[0]+o[1])/2;const c=p().domain([a,s]).range(o).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?o[0]:c(r)}}const oi=b,li={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,s=a-o,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),r=f.get(e);if(void 0===n||void 0===r)continue;const i=d(t);g[n][r]=i}const p=ct().padAngle(i);l&&p.sortGroups(l);const v=p(g),m=v.groups,x=K().innerRadius(s).outerRadius(a);for(const e of m){const n=t[e.index],r=x.centroid(e);n.x=r[0]+c,n.y=r[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}const k=new Map;for(const t of e)k.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 v){const n=t[e.source.index].id,r=t[e.target.index].id,i=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);i&&(i.chordData=e)}},buildScene(t,e,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,h=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:oi,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const v=st().radius(c),m=[],x=[],b=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let o;o=h?h(Qr(n,"nodeStyle")).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const l=h?h(Qr(n,"nodeStyle")):{},a={fill:o,stroke:l.stroke||"black",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};m.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 t of e){const e=t.chordData;if(!e)continue;const n=v(e);if(!n)continue;const r=ai(n,u,d);let i="#999";if(f)i=f(Qr(t,"edgeStyle")).fill||i;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?i=p.get(n.id)||i:e&&(i=p.get(e.id)||i)}const l=f?f(Qr(t,"edgeStyle")):{},s={fill:i,fillOpacity:null!==(o=l.fillOpacity)&&void 0!==o?o:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};x.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const o=(t.startAngle+t.endAngle)/2,l=o-Math.PI/2;b.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 k;return{sceneNodes:m,sceneEdges:x,labels:b}}};function ai(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const i=[];let o=0;for(;r.length>o;){const t=r[o];if("M"===t||"L"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("C"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;3>t&&r.length>o&&!isNaN(Number(r[o]));t++)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("Q"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;2>t&&r.length>o&&!isNaN(Number(r[o]));t++)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("A"===t)for(i.push(t),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])+e+""),o++),r.length>o&&(i.push(Number(r[o])+n+""),o++);else"Z"===t||"z"===t?(i.push(t),o++):(i.push(r[o]),o++)}return i.join(" ")}const si=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ci(t){const[e,n,r]=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*r>150?"#222":"#fff"}function ui(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function di(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 hi(t){return Array.isArray(t.colorScheme)?t.colorScheme:si}function fi(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:"#4d430c"}function yi(t,e,n,r,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${r} ${n},${r}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+r)/2} T ${n},${r}`}{const i=(e+r)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${r}`}}const gi={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var i;const o=n.__hierarchyRoot;if(!o)return;const l=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),s=n.hierarchySum,c="function"==typeof s?s:"string"==typeof s?t=>{var e;return null!==(e=t[s])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},u=O(o,a);u.sum(c),u.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[d,h]=r;switch(l){case"tree":!function(t,e,n,r){const i=e.treeOrientation||"vertical",o=R();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,r){const i=e.treeOrientation||"vertical",o=z();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,r){var i,o;const l=null!==(i=e.padding)&&void 0!==i?i:4,a=null!==(o=e.paddingTop)&&void 0!==o?o:0,s=I().size([n,r]).tile(W).padding(l);a>0&&s.paddingTop(a),s(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,r){var i;const o=null!==(i=e.padding)&&void 0!==i?i:4;N().size([n,r]).padding(o)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,r){var i;$().size([n,r]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const r=f[e],o={id:ui(r,n,e),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?pi(o,r,n):"treemap"===l||"partition"===l?vi(o,r):"circlepack"===l&&mi(o,r),o.__hierarchyNode=r,t.push(o),y.set(r,o)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=y.get(t.parent),r=y.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,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 e of t){let t=e.x,r=e.y;g&&(t+=p,r+=v);const o=i(Qr(e,"nodeStyle"));let a=o.fill||fi(n);if(n.colorByDepth&&void 0!==e.depth){const t=hi(n);a=t[e.depth%t.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:t,cy:r,r:m,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r=e.x,i=e.y,l=n.x,a=n.y;g&&(r+=p,i+=v,l+=p,a+=v);const u=yi(r,i,l,a,y),d=o(Qr(t,"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:t})}if(!1!==n.showLabels){const e=di(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,i,o,l=n.x,a=n.y;if(g&&(l+=p,a+=v),g){const t=l-p,e=a-v,n=Math.sqrt(t*t+e*e);n>0?(r=l+t/n*10,i=a+e/n*10,o=0>t?"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:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(t,e,n,r,i,o);case"treemap":case"partition":return function(t,e,n,r){var i,o;const l=[],a=[];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const a=r(Qr(n,"nodeStyle"));let s=a.fill||fi(e);if(e.colorByDepth&&void 0!==n.depth){const t=hi(e);s=t[n.depth%t.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:t,h:o,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=di(e.nodeLabel),i=e.labelMode||"leaf",l="partition"===e.chartType;for(const s of t){const t=s.x1-s.x0,c=s.y1-s.y0;if(0>=t||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)>t||(u?16:14)>c)continue;let h=r(Qr(s,"nodeStyle")).fill||fi(e);if(e.colorByDepth&&void 0!==s.depth){const t=hi(e);h=t[s.depth%t.length]}const f=ci(h);a.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,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}}(t,n,0,i);case"circlepack":return function(t,e,n,r){var i,o,l,a,s;const c=[],u=[];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const a=r(Qr(n,"nodeStyle"));let s=a.fill||fi(e);if(e.colorByDepth&&void 0!==n.depth){const t=hi(e);s=t[n.depth%t.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:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=di(e.nodeLabel);for(const i of t){const t=null!==(a=i.__radius)&&void 0!==a?a:5,o=n?n(i):i.id;if(!o)continue;if(15>t)continue;const l=!((null===(s=i.data)||void 0===s?void 0:s.children)&&i.data.children.length>0);let c=r(Qr(i,"nodeStyle")).fill||fi(e);if(e.colorByDepth&&void 0!==i.depth){const t=hi(e);c=t[i.depth%t.length]}if(l){const e=ci(c);u.push({x:i.x,y:i.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:i.x,y:i.y-t+14,text:o+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pi(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 vi(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 mi(t,e){var n;const r=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function xi(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const bi={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const i=n.__hierarchyRoot;i&&function(t,e,n,r,i){var o,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=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),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(o=n.orbitSize)&&void 0!==o?o:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,y=xi(n);y.metaMap.clear(),r.length=0,i.length=0;const g=new Map;function p(t){var e;const n=null!==(e=g.get(t))&&void 0!==e?e:0;return g.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(s(t));r.push({id:b,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,o,l,u,d,g){const v=a(e);if(!(null==v?void 0:v.length))return;const m=v.length;let x=0,b=0,k=0;for(;m>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let m=0;x>m;m++){const b=c[Math.min(m,c.length-1)],k=v.slice(w,w+b);if(!k.length)break;const E=(m+1)/x,A={id:n,depth:d,data:e,parentId:n},M=g?u/h(A)*E:u*E,S=J().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),_=S(k),P=f(A);for(let e=0;k.length>e;e++){const a=(_[e].startAngle+_[e].endAngle)/2,c=k[e],u=p(s(c)),h=o+M*Math.sin(a),f=l+M*Math.cos(a)*P;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),y.metaMap.set(u,{ring:M,angle:a,depth:d,parentId:n,eccentricity:P}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,M,d+1,!0)}w+=b}}(t,b,v,m,x,1,!1)}(i,r,n,t,e)},buildScene(t,e,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 e=xi(n),r=new Map;for(const e of t)r.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,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:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*r,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=d(Qr(e,"nodeSize")),n=c?c(Qr(e,"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=e.depth)&&void 0!==l?l:0)?1:.85};h.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&f.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=d(Qr(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[e])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:y}},tick:(t,e,n,r,i)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const i=xi(e),o=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=e.orbitRevolution)&&void 0!==r?r: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),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const r=t.angle+a*s*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(r),e.y=n.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},ki={sankey:ti,force:ei,chord:li,tree:gi,cluster:gi,treemap:gi,circlepack:gi,partition:gi,orbit:bi};function wi(t){return ki[t]}class Ei{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({},ir),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new lr(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({},ir),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new lr(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:r="id",sourceAccessor:i="source",targetAccessor:o="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:t=>t[r],s="function"==typeof i?i:t=>t[i],c="function"==typeof o?o:t=>t[o],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&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=a(e)+"";this.nodes.set(t,Object.assign(Object.assign({},Ai(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],r=s(n)+"",i=c(n)+"",o=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Ai(r)),{data:n})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Ai(i)),{data:n}));const l=`${r}\0${i}\0${t}`;this.edges.set(l,{source:r,target:i,value:o,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,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(e)||(this.nodes.set(e,Ai(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,Ai(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,o=!0);const a=this.edgeKey(e,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:e,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(t){var e,n,r,i,o,l,a,s;const c=wi(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 t=new Map;for(const a of u)if(void 0!==a._prevX0){const s=(null!==(e=a._prevX1)&&void 0!==e?e: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);t.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||t.set(a.id,{x:a.x,y:a.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)),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 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: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 t of g)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)g.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=g,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(t){const e=wi(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:o,labels:l}=e.buildScene(n,r,this.config,t);this.sceneNodes=i,this.sceneEdges=o,this.labels=l}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 r=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return n.tick(r,i,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=St(t,this.transition),n=Mt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=_t(t._prevX0,t._targetX0,n),t.x1=_t(t._prevX1,t._targetX1,n),t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(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=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n),t.sankeyWidth=_t(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 r=(t.sankeyWidth||1)/2;if("down"===t.direction){const i=e.x1,o=n.x0,l=et(i,o);return{circular:!1,points:[{x:t.y0,y:i},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:o}],halfWidth:r}}const i=e.x1,o=n.x0,l=et(i,o);return{circular:!1,points:[{x:i,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:o,y:t.y1}],halfWidth:r}}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))),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*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,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:e}}let r;r="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 i=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],o=n.x-e.x,l=n.y-e.y;i.push([e,{x:e.x+o/3,y:e.y+l/3},{x:e.x+2*o/3,y:e.y+2*l/3},n])}return{circular:!0,segments:i,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,r,i,o;const l=this.config.pulse;if(!l)return;const a=null!==(e=l.duration)&&void 0!==e?e: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 e of this.sceneNodes){const n=e.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const i=t-r;a>i&&(e._pulseIntensity=1-i/a,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.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=t-c;a>u&&(e._pulseIntensity=1-u/a,e._pulseColor=s)}}applyDecay(){var t,e;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((t,e)=>t[1]-e[1]));const i=this._decaySortedNodes,o=new Map;for(let t=0;i.length>t;t++)o.set(i[t][0],t);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=Et(n,a,r),c=null!==(e=null===(t=i.style)||void 0===t?void 0:t.opacity)&&void 0!==e?e:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*s})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const r=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,r),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 r=this.config.thresholds;if(!r)return;const i=null!==(e=r.warningColor)&&void 0!==e?e:"#f59e0b",o=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.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&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(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 r=this.nodes.get(t);if(!r)return null;const i=r.data?Object.assign({},r.data):{};return r.data=e(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,i}updateEdge(t,e,n){var r;const i=this.config.valueAccessor,o="function"==typeof i?i:i?t=>t[i]:t=>t.value,l=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===t&&("string"==typeof i.target?i.target:i.target.id)===e){l.push(i.data?Object.assign({},i.data):{}),i.data=n(null!==(r=i.data)&&void 0!==r?r:{});const t=o(i.data);null!=t&&(i.value=Number(t))}return l.length>0&&this.layoutVersion++,l}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 r="function"==typeof e?e:t=>null==t?void 0:t[e];for(const[e,i]of this.edges)r(i.data)===t&&n.push(e)}else for(const[r,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===t&&("string"==typeof i.target?i.target:i.target.id)===e&&n.push(r);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 Ai(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 Mi(t,e,n,r,i=30){let o=null,l=i,a=1/0;for(const e of t){const t=Si(e,n,r,i);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(o=t,a=n)}else l>t.distance&&(o=t,l=t.distance)}if(o)return o;for(const t of e){const e=Ci(t,n,r);e&&l>e.distance&&(o=e,l=e.distance)}return o}function Si(t,e,n,r=30){switch(t.type){case"circle":return function(t,e,n,r=30){const i=e-t.cx,o=n-t.cy,l=Math.sqrt(i*i+o*o);return l>Bt(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,r);case"rect":return function(t,e,n){const r=Rt(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,i=n-t.cy,o=Math.sqrt(r*r+i*i);if(t.innerR-2>o||o>t.outerR+2)return null;const l=Yt(Math.atan2(i,r)),a=Yt(t.startAngle),s=Yt(t.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){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 _i=null,Pi=null;function Ti(){return Pi||(_i=document.createElement("canvas"),_i.width=1,_i.height=1,Pi=_i.getContext("2d")),Pi}function Di(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 Ci(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,i;if(!t.pathD)return null;const o=Di(t),l=Ti();if(!o||!l)return null;try{if(l.isPointInPath(o,e,n)){const o="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,l="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:o&&l?(o.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(o,e,n);if(l.lineWidth=a,s)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 r=t.x2-t.x1,i=t.y2-t.y1,o=r*r+i*i;if(0===o)return null;let l=((e-t.x1)*r+(n-t.y1)*i)/o;l=Math.max(0,Math.min(1,l));const a=t.x1+l*r,s=t.y1+l*i,c=Math.sqrt(Math.pow(e-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:a,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const r=Di(t),i=Ti();if(!r||!i)return null;try{if(i.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const l=i.isPointInStroke(r,e,n);if(i.lineWidth=o,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function Li(e){const{width:n,height:r,totalWidth:i,totalHeight:o,margin:l,labels:a,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:y="right",foregroundGraphics:g,sceneNodes:p,annotations:v,svgAnnotationRules:m}=e;return t.createElement(t.Fragment,null,t.createElement("svg",{role:"img",width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("title",null,"string"==typeof s?s:"Network Chart"),t.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),t.createElement("g",{transform:`translate(${l.left},${l.top})`},a.map((e,n)=>t.createElement("text",{key:"label-"+n,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(t=>"widget"!==t.type).map((e,i)=>{if(m){const o=m(e,i,{width:n,height:r,sceneNodes:p});if(o)return t.createElement(t.Fragment,{key:"annotation-"+i},o)}return null}),g),s&&"string"==typeof s?t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:i,height:l.top},s):null,he({legend:c,totalWidth:i,totalHeight:o,margin:l,legendPosition:y,title:s,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((e,n)=>{var r,i,o,a,s,c,u,d,h;const f=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(!f)return null;const y=l.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(i=f.x)&&void 0!==i?i:0),g=l.top+(null!==(o=f.cy)&&void 0!==o?o:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),v=null!==(s=e.dx)&&void 0!==s?s: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.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return t.createElement("div",{key:"widget-"+n,style:{position:"absolute",left:y+v-x/2,top:g+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Oi(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function $i(t,e){var n,r,i,o,l,a;if(!e.pathD)return;t.save();const s=Oi(e);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const i=t.createLinearGradient(l.x0,0,l.x1,0),o=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,a="string"==typeof e.style.fill?e.style.fill:"#999";i.addColorStop(0,1===l.from?a:"transparent"),i.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=i,t.globalAlpha=o}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(o=null!==(i=e.style.fillOpacity)&&void 0!==i?i:e.style.opacity)&&void 0!==o?o:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(a=e.style.opacity)&&void 0!==a?a:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(s)),t.restore()}function Ni(t,e){var n,r;t.save(),t.strokeStyle=e.style.stroke||"#999",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!==(r=e.style.strokeWidth)&&void 0!==r?r: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 Ii(t,e){var n,r,i,o;if(!e.pathD)return;t.save();const l=Oi(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:.5,t.globalAlpha=.3*(null!==(o=e.style.opacity)&&void 0!==o?o:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function Wi(t,e){var n,r;if(!e.pathD)return;t.save();const i=Oi(e);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(i),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.1,t.fill(i)),t.restore()}Li.displayName="NetworkSVGOverlay";const zi={top:20,right:80,bottom:20,left:80},Ri={top:40,right:40,bottom:40,left:40},Bi=new Set(["chord","force","circlepack","orbit"]),Fi=[800,600],ji={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 Yi({data:e}){var n,r,i,o,l,a;if("edge"===e.nodeOrEdge){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:ji},t.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let l=c;for(;l;){const t=null!==(o=null!==(r=null===(n=l.data)||void 0===n?void 0:n.name)&&void 0!==r?r:null===(i=l.data)||void 0===i?void 0:i.id)&&void 0!==o?o:s.id;null!=t&&e.unshift(t+""),l=l.parent}e.length>1&&e.shift();const a=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:ji},t.createElement("div",null,e.map((e,n)=>t.createElement("span",{key:n},n>0&&t.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===a?t.createElement("strong",null,e):t.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const u=((null===(l=s.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),d=(s.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(s.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.createElement("div",{className:"semiotic-tooltip",style:ji},t.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),u>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Hi=c(function(i,o){var l,c,d,h,f,y,g,p,v,m,x,b,k,w;const{chartType:E,nodes:A,edges:M,data:S,initialEdges:_,nodeIDAccessor:P="id",sourceAccessor:T="source",targetAccessor:D="target",valueAccessor:C="value",edgeIdAccessor:L,childrenAccessor:O,hierarchySum:$,orientation:N="horizontal",nodeAlign:I="justify",nodePaddingRatio:W=.05,nodeWidth:z=15,iterations:R=300,forceStrength:B=.1,padAngle:F=.01,groupWidth:j=20,sortGroups:Y,edgeSort:H,treeOrientation:X="vertical",edgeType:G="curve",padding:V,paddingTop:q,tensionConfig:U,showParticles:Z=!1,particleStyle:Q,nodeStyle:J,edgeStyle:tt,colorBy:et,colorScheme:nt="category10",edgeColorBy:rt="source",edgeOpacity:it=.5,colorByDepth:ot=!1,nodeSize:lt=8,nodeSizeRange:at=[5,20],nodeLabel:st,showLabels:ct=!0,labelMode:ut,size:dt=Fi,responsiveWidth:ht,responsiveHeight:ft,margin:yt,className:gt,background:pt,enableHover:vt=!0,tooltipContent:mt,customHoverBehavior:xt,customClickBehavior:bt,onObservation:wt,chartId:Et,onTopologyChange:At,annotations:Mt,svgAnnotationRules:St,legend:_t,legendPosition:Pt,legendHoverBehavior:Tt,legendClickBehavior:Dt,legendHighlightedCategory:Ct,legendIsolatedCategories:Lt,title:Ot,foregroundGraphics:$t,backgroundGraphics:Nt,decay:It,pulse:Wt,transition:zt,animate:Rt,staleness:Bt,thresholds:Ft,accessibleTable:jt=!0,description:Yt,summary:Ht,orbitMode:Xt,orbitSize:Gt,orbitSpeed:Vt,orbitRevolution:qt,orbitRevolutionStyle:Ut,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Qt}=i,Jt=Bi.has(E)?Ri:zi,re=e(!0),ie=Pn({sizeProp:dt,responsiveWidth:ht,responsiveHeight:ft,userMargin:yt,marginDefault:Jt,foregroundGraphics:$t,backgroundGraphics:Nt,animate:Rt,transitionProp:zt,themeDirtyRef:re}),{reducedMotionRef:le,responsiveRef:ae,size:se,margin:ce,adjustedWidth:ue,adjustedHeight:de,resolvedForeground:he,resolvedBackground:fe,transition:ye,introEnabled:ge,tableId:pe,rafRef:ve,renderFnRef:me,scheduleRender:xe}=ie,be=n(()=>Object.assign(Object.assign({},ir),U),[U]),ke=n(()=>Object.assign(Object.assign({},or),Q),[Q]),we=n(()=>({chartType:E,nodeIDAccessor:P,sourceAccessor:T,targetAccessor:D,valueAccessor:C,edgeIdAccessor:L,childrenAccessor:O,hierarchySum:$,orientation:N,nodeAlign:I,nodePaddingRatio:W,nodeWidth:z,iterations:R,forceStrength:B,padAngle:F,groupWidth:j,sortGroups:Y,edgeSort:H,treeOrientation:X,edgeType:G,padding:V,paddingTop:q,tensionConfig:be,showParticles:Z,particleStyle:ke,nodeStyle:J,edgeStyle:tt,nodeLabel:st,showLabels:ct,labelMode:ut,colorBy:et,colorScheme:nt,edgeColorBy:rt,edgeOpacity:it,colorByDepth:ot,nodeSize:lt,nodeSizeRange:at,decay:It,pulse:Wt,transition:ye,introAnimation:ge,staleness:Bt,thresholds:Ft,orbitMode:Xt,orbitSize:Gt,orbitSpeed:Vt,orbitRevolution:qt,orbitRevolutionStyle:Ut,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Qt}),[E,P,T,D,C,O,$,N,I,W,z,R,B,F,j,Y,H,X,G,V,q,be,Z,ke,J,tt,st,ct,ut,et,nt,rt,it,ot,lt,at,It,Wt,null==ye?void 0:ye.duration,null==ye?void 0:ye.easing,ge,Bt,Ft,Xt,Gt,Vt,qt,Ut,Kt,Zt,Qt]),Ee=e(null),Ae=e(0),Me=e(null);Me.current||(Me.current=new Ei(we));const[Se,_e]=s(null),[Pe,Te]=s(0),[De,Ce]=s(0),[Le,Oe]=s(!1),$e=e(null),Ne=e(new Map),Ie=e(0),We=a(t=>{if("function"==typeof et)return et(t)+"";if("string"==typeof et&&t.data){const e=t.data[et];if(void 0!==e){if(!Ne.current.has(e+"")){const t=Array.isArray(nt)?nt:kt;Ne.current.set(e+"",t[Ie.current++%t.length])}return Ne.current.get(e+"")}}if(Ne.current.has(t.id))return Ne.current.get(t.id);const e=Array.isArray(nt)?nt:kt,n=et?e[Ie.current++%e.length]:e[0];return Ne.current.set(t.id,n),n},[et,nt]),ze=a(t=>{if("function"==typeof rt)return rt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===rt&&n?We(n):e?We(e):"#999"},[rt,We]),Re=a(t=>{if(!(null==Q?void 0:Q.colorBy))return ze(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===ke.colorBy&&n?We(n):e?We(e):"#999"},[null==Q?void 0:Q.colorBy,ke.colorBy,We,ze]),je="sankey"===E&&Z||!!Wt||null!==(c=null===(l=Me.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;r(()=>{var t;null===(t=Me.current)||void 0===t||t.updateConfig(we),re.current=!0,xe()},[we,xe]);const Ye=a(()=>{var t;const e=Me.current;if(!e)return;e.runLayout([ue,de]),e.buildScene([ue,de]),re.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Ne.current.set(n.id,n.style.fill);const n=Array.isArray(nt)?nt:kt,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];Ne.current.has(e.id)||Ne.current.set(e.id,n[t%n.length])}if(Ie.current=r.length,Te(e.layoutVersion),At){const{nodes:t,edges:n}=e.getLayoutData();At(t,n)}},[ue,de,At,nt]),He=a(t=>{const e=Me.current;e&&(e.ingestEdge(t)&&Ye(),xe())},[Ye,xe]),Xe=a(t=>{const e=Me.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Ye(),xe()},[Ye,xe]),Ve=a(()=>{var t;null===(t=Me.current)||void 0===t||t.clear(),Ne.current.clear(),Ie.current=0,Te(0),_e(null),$e.current=null,re.current=!0,xe()},[xe]),qe=a(()=>{const t=Me.current;t&&(t.tension+=999,Ye(),xe())},[Ye,xe]);u(o,()=>({push:He,pushMany:Xe,removeNode:t=>{var e,n,r;const i=null!==(n=null===(e=Me.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(i){const e=(null===(r=$e.current)||void 0===r?void 0:r.data)?"function"==typeof P?P($e.current.data):$e.current.data[P]:void 0;$e.current&&"node"===$e.current.nodeOrEdge&&e===t&&($e.current=null,_e(null)),Ne.current.delete(t),Ye(),re.current=!0,xe()}return i},removeEdge:(t,e)=>{var n,r;const i=null!==(r=null===(n=Me.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==r&&r;if(i){if($e.current&&"edge"===$e.current.nodeOrEdge){const n=$e.current.data;let r;r=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:!L||!n||("function"==typeof L?L:t=>null==t?void 0:t[L])(n)===t,r&&($e.current=null,_e(null))}Ye(),re.current=!0,xe()}return i},updateNode:(t,e)=>{var n,r;const i=null!==(r=null===(n=Me.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==r?r:null;return i&&(re.current=!0,xe()),i},updateEdge:(t,e,n)=>{var r,i;const o=null!==(i=null===(r=Me.current)||void 0===r?void 0:r.updateEdge(t,e,n))&&void 0!==i?i:[];return o.length>0&&(Ye(),re.current=!0,xe()),o},clear:Ve,getTopology:()=>{var t,e;return null!==(e=null===(t=Me.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Me.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:qe,getTension:()=>{var t,e;return null!==(e=null===(t=Me.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[He,Xe,Ve,qe,Ye,xe]);const Ue=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),Ke=Ue?S||(Array.isArray(M)?void 0:M):void 0;r(()=>{var t;const e=Me.current;if(e)if(Ue&&Ke)e.ingestHierarchy(Ke,[ue,de]),e.buildScene([ue,de]),re.current=!0,xe();else{const n=A||[],r=Array.isArray(M)?M:[];if(0===n.length&&0===r.length)return;e.ingestBounded(n,r,[ue,de]),e.buildScene([ue,de]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Ne.current.set(n.id,n.style.fill+"");const i=Array.isArray(nt)?nt:kt,o=Array.from(e.nodes.values());for(let t=0;o.length>t;t++){const e=o[t];Ne.current.has(e.id)||Ne.current.set(e.id,i[t%i.length])}Ie.current=o.length,re.current=!0,xe()}},[A,M,S,Ke,Ue,ue,de,we,xe,nt]),r(()=>{_&&_.length>0&&Xe(_)},[]);const Ze=a(t=>{if(xt&&xt(t),wt){const e=Date.now();wt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Et}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Et})}},[xt,wt,Et]),Qe=a(t=>{if(bt&&bt(t),wt){const e=Date.now();wt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Et}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Et})}},[bt,wt,Et]),{hoverHandlerRef:Je,hoverLeaveRef:tn,onPointerMove:en,onPointerLeave:an}=ie;Je.current=t=>{if(!vt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ce.left,i=t.clientY-n.top-ce.top;if(0>r||r>ue||0>i||i>de)return void($e.current&&($e.current=null,_e(null),Ze&&(Ze(null),re.current=!0),xe()));const o=Me.current;if(!o)return;const l=Mi(o.sceneNodes,o.sceneEdges,r,i);if(!l)return void($e.current&&($e.current=null,_e(null),Ze&&(Ze(null),re.current=!0),xe()));const a=Gn(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});$e.current=a,_e(a),Ze&&(Ze(a),re.current=!0),xe()},tn.current=()=>{$e.current&&($e.current=null,_e(null),Ze&&(Ze(null),re.current=!0),xe())};const un=e(()=>{});un.current=t=>{if(!bt&&!wt)return;const e=Ee.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ce.left,i=t.clientY-n.top-ce.top;if(0>r||r>ue||0>i||i>de)return;const o=Me.current;if(!o)return;const l=Mi(o.sceneNodes,o.sceneEdges,r,i);Qe(l?Gn(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)};const dn=a(t=>un.current(t),[]),hn=e(-1),fn=e(null),yn=e(-1),gn=a(t=>{var e;const n=Me.current;if(!n)return;const r=function(t){var e,n,r,i,o,l;const a=[];for(const s of t)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(e=s.datum)||void 0===e?void 0:e.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((t,e)=>t.x-e.x||t.y-e.y),a}(n.sceneNodes);if(0===r.length)return;const i=te(r),o=hn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),hn.current=0,yn.current=-1;const e=i.flat[0];fn.current={shape:e.shape,w:e.w,h:e.h};const n=Gn(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return $e.current=n,_e(n),Ze&&(Ze(n),re.current=!0),void xe()}const l=ee(i,o),a=function(t,e,n,r,i){var o,l,a;const s=n.flat[e.flatIndex];if(!s)return ne(t,e,n);const c=null===(o=s.datum)||void 0===o?void 0:o.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(t,e,n){let r=null,i=1/0;for(let o=0;t.flat.length>o;o++){const l=t.flat[o];if(l===e)continue;const a=l.x-e.x,s=l.y-e.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"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return r!==e.flatIndex&&(i.current=-1),r}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,r,i;const o=t+"",l=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,a="object"==typeof e.source?null===(r=e.source)||void 0===r?void 0:r.id:e.source,s="object"==typeof e.target?null===(i=e.target)||void 0===i?void 0:i.id:e.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===t.length)return e.flatIndex;const o=null!==(a=n.idToIdx.get(t[(i.current+1)%t.length]))&&void 0!==a?a:-1;return 0>o?e.flatIndex:(i.current=-1,o)}default:{const r=ne(t,e,n);return null!==r&&r!==e.flatIndex&&(i.current=-1),r}}}(t.key,l,i,null!==(e=n.sceneEdges)&&void 0!==e?e:[],yn);if(null===a)return;if(t.preventDefault(),0>a)return hn.current=-1,fn.current=null,yn.current=-1,$e.current=null,_e(null),Ze&&(Ze(null),re.current=!0),void xe();hn.current=a;const s=i.flat[a];fn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:s.x,y:s.y,time:s.x,value:s.y,nodeOrEdge:"node"});$e.current=u,_e(u),Ze&&(Ze(u),re.current=!0),xe()},[Ze,xe]),pn=a(t=>{hn.current=-1,fn.current=null,en(t)},[en]);me.current=()=>{var t,e,n,r,i,o,l;ve.current=0;const a=Ee.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=Me.current;if(!c)return;const u=performance.now(),d=Ae.current?Math.min((u-Ae.current)/1e3,.1):.016;Ae.current=u;const h=c.advanceTransition(le.current?u+1e6:u),f=!le.current&&h,y=!le.current&&c.tickAnimation([ue,de],d);(h||re.current||y)&&c.buildScene([ue,de]);const g=Dn();if(!Tn(a,se,ce,g))return;s.clearRect(-ce.left,-ce.top,se[0],se[1]),pt&&(s.fillStyle=pt,s.fillRect(0,0,ue,de)),It&&c.applyDecay(),Wt&&c.applyPulse(u),Ft&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Bt?void 0:Bt.threshold)&&void 0!==t?t:5e3,v=Bt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(e=null==Bt?void 0:Bt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":$i(t,n);break;case"line":Ni(t,n);break;case"ribbon":Ii(t,n);break;case"curved":Wi(t,n)}}(s,c.sceneEdges),function(t,e){var n,r,i;for(const o of e){if("rect"!==o.type)continue;const e=o;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=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=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.strokeRect(e.x,e.y,e.w,e.h)),In(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,i;for(const o of e){if("circle"!==o.type)continue;const e=o;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=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=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.stroke()),Wn(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,i;for(const o of e){if("arc"!==o.type)continue;const e=o;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=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=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.stroke()),t.restore()}}(s,c.sceneNodes),Z&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,r){var i,o;const l=null!==(i=r.spawnRate)&&void 0!==i?i:or.spawnRate,a=null!==(o=r.maxPerEdge)&&void 0!==o?o:or.maxPerEdge;for(let r=0;e.length>r;r++){const i=e[r];if(!i.bezier)continue;if(t.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 e=0;u>e&&t.countForEdge(r)<a;e++)t.spawn(r)}}(c.particlePool,t,d,ke);const e=.5*(null!==(n=ke.speedMultiplier)&&void 0!==n?n:1);let r;if(ke.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,r),function(t,e,n,r,i){var o,l;const a=null!==(o=r.radius)&&void 0!==o?o:or.radius,s=null!==(l=r.opacity)&&void 0!==l?l:or.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const l=e.particles[o];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?r.color(s,e):"#666"}else t.fillStyle=r.color&&"inherit"!==r.color?r.color:i(s);t.beginPath(),t.arc(l.x,l.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,ke,Re)}}v&&(s.globalAlpha=1);const m=re.current;if(re.current=!1,m||f||y){const t=Ee.current;t&&t.setAttribute("aria-label",Ge(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)&&Ce(t=>t+1),(je||f||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(ve.current=requestAnimationFrame(()=>me.current()))},r(()=>(xe(),()=>{}),[xe]),r(()=>{re.current=!0,xe()},[E,ue,de,pt,xe]),oe(Bt,Me,re,xe,Le,Oe);const vn=vt&&Se?t.createElement(cn,{x:Se.x,y:Se.y,containerWidth:ue,containerHeight:de,margin:ce,className:"stream-network-tooltip",zIndex:2},mt?mt(Se):t.createElement(Yi,{data:Se})):null;if(Fe){const e=Me.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),n=t?S||(Array.isArray(M)?void 0:M):void 0;if(t&&n)e.ingestHierarchy(n,[ue,de]),e.buildScene([ue,de]);else{const t=A||[],n=Array.isArray(M)?M:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[ue,de]),e.buildScene([ue,de]))}}const n=null!==(d=null==e?void 0:e.sceneNodes)&&void 0!==d?d:[],r=null!==(h=null==e?void 0:e.sceneEdges)&&void 0!==h?h:[],i=null!==(f=null==e?void 0:e.labels)&&void 0!==f?f:[];return t.createElement("div",{className:"stream-network-frame"+(gt?" "+gt:""),role:"img","aria-label":Yt||("string"==typeof Ot?Ot:"Network chart"),style:{position:"relative",width:se[0],height:se[1]}},t.createElement(rn,{summary:Ht}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:se[0],height:se[1],style:{position:"absolute",left:0,top:0}},fe&&t.createElement("g",{transform:`translate(${ce.left},${ce.top})`},fe),t.createElement("g",{transform:`translate(${ce.left},${ce.top})`},pt&&t.createElement("rect",{x:0,y:0,width:ue,height:de,fill:pt}),r.map((e,n)=>function(e,n){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+n,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 r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Be(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Be(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Be(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const r=e;return t.createElement("circle",{key:"net-circle-"+n,cx:r.cx,cy:r.cy,r:r.r,fill:Be(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return t.createElement("rect",{key:"net-rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Be(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,i=K().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2)({})||"";return t.createElement("path",{key:"net-arc-"+n,d:i,transform:`translate(${r.cx},${r.cy})`,fill:Be(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),i.map((e,n)=>function(e,n){return t.createElement("text",{key:"net-label-"+n,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,n)).filter(Boolean))),t.createElement(Li,{width:ue,height:de,totalWidth:se[0],totalHeight:se[1],margin:ce,labels:i,sceneNodes:n,title:Ot,legend:_t,legendPosition:Pt,legendHoverBehavior:Tt,legendClickBehavior:Dt,legendHighlightedCategory:Ct,legendIsolatedCategories:Lt,foregroundGraphics:he,annotations:Mt,svgAnnotationRules:St,annotationFrame:0}))}const mn=Me.current;return t.createElement("div",{ref:ae,className:"stream-network-frame"+(gt?" "+gt:""),role:"group","aria-label":Yt||("string"==typeof Ot?Ot:"Network chart"),tabIndex:0,style:{position:"relative",width:ht?"100%":se[0],height:ft?"100%":se[1],overflow:"visible"},onKeyDown:gn},jt&&t.createElement(on,{tableId:pe}),jt&&t.createElement(nn,{nodes:null!==(y=null==mn?void 0:mn.sceneNodes)&&void 0!==y?y:[],edges:null!==(g=null==mn?void 0:mn.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:pe,chartTitle:"string"==typeof Ot?Ot:void 0}),t.createElement(rn,{summary:Ht}),t.createElement("div",{role:"img","aria-label":Yt||("string"==typeof Ot?Ot:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:vt?pn:void 0,onMouseLeave:vt?an:void 0,onClick:bt||wt?dn:void 0},fe&&t.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:se[0],height:se[1],pointerEvents:"none",overflow:"visible"}},t.createElement("g",{transform:`translate(${ce.left},${ce.top})`},fe)),t.createElement("canvas",{ref:Ee,"aria-label":Ge(null!==(v=null===(p=null==mn?void 0:mn.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==v?v:0,null!==(x=null===(m=null==mn?void 0:mn.sceneEdges)||void 0===m?void 0:m.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.createElement(ln,{hoverPoint:Se}),t.createElement(Li,{width:ue,height:de,totalWidth:se[0],totalHeight:se[1],margin:ce,labels:(null==mn?void 0:mn.labels)||[],sceneNodes:null==mn?void 0:mn.sceneNodes,title:Ot,legend:_t,legendPosition:Pt,legendHoverBehavior:Tt,legendClickBehavior:Dt,legendHighlightedCategory:Ct,legendIsolatedCategories:Lt,foregroundGraphics:he,annotations:Mt,svgAnnotationRules:St,annotationFrame:De}),t.createElement(sn,{active:hn.current>=0,hoverPoint:Se,margin:ce,size:se,shape:null===(b=fn.current)||void 0===b?void 0:b.shape,width:null===(k=fn.current)||void 0===k?void 0:k.w,height:null===(w=fn.current)||void 0===w?void 0:w.h}),vn,(null==Bt?void 0:Bt.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Bt.badgePosition?{top:4,left:4}:"bottom-left"===Bt.badgePosition?{bottom:4,left:4}:"bottom-right"===Bt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Le?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Le?"STALE":"LIVE")))});function Xi(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,i]=r.range;e.push(e=>{const r=e[n];return r>=t&&i>=r})}return t=>e.every(e=>e(t))}function Gi(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Hi.displayName="StreamNetworkFrame";const[Vi,qi]=un(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),i=Gi(r,e),o=new Map(i.clauses);return o.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r)return{};const i=new Map(t.selections),o=new Map(r.clauses);return o.delete(n),i.set(e,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},setResolution(e,n){t(t=>{const r=new Map(t.selections),i=Gi(r,e);return r.set(e,Object.assign(Object.assign({},i),{resolution:n})),{selections:r}})},clearSelection(e){t(t=>{const n=new Map(t.selections),r=n.get(e);return r&&n.set(e,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Ui,Ki]=un(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 Zi(t){const e=d(),r=t.clientId||e,{name:i}=t,o=qi(t=>t.selections.get(i)),l=qi(t=>t.setClause),s=qi(t=>t.clearClause),c=n(()=>!!o&&o.clauses.size>0,[o]);return{predicate:n(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,i]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(Xi(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,r):()=>!0,[o,r]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};l(i,{clientId:r,type:"point",fields:e})},[r,i,l]),selectInterval:a(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};l(i,{clientId:r,type:"interval",fields:e})},[r,i,l]),clear:a(()=>{s(i,r)},[s,i,r]),clientId:r}}function Qi({selection:t,linkedHover:e,fallbackFields:i=[],unwrapData:o=!1,onObservation:l,chartType:c,chartId:u,onClick:h,hoverHighlight:f,colorByField:y}){const g=d(),p=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}(e,i),v=Zi({name:(null==t?void 0:t.name)||"__unused__"}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:i,selectPoints:o,clear:l}=Zi({name:e});return{onHover:a(t=>{if(!t)return void l();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}Object.keys(e).length>0&&o(e)},[n,o,l,e]),predicate:r,isActive:i}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||i||[]}),x=Ki(t=>t.pushObservation),b=t?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=s(null),E=y||i[0],A=n(()=>{if(!f||null==k||!E)return null;const t=k,e=E;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[e]?n[e]:(null!==(r=n[e])&&void 0!==r?r:"")+"")===t}}},[f,k,E]),M=a(t=>{var n,r;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const t=null==e?void 0:e[p.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const r=Ae.positions.get(t);(null==r?void 0:r.locked)||r&&r.xValue===e&&r.sourceId===n||(Ae={positions:new Map(Ae.positions).set(t,{xValue:e,sourceId:n})},Se())}(p.name||"hover",Number(t),g)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&_e(p.name||"hover",g),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(f&&E)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[E];w(null!=n?n+"":null)}else w(null);if(l||x){const e={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const o=Object.assign(Object.assign({},e),{type:"hover",datum:i||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0});l&&l(o),x&&x(o)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});l&&l(t),x&&x(t)}}},[e,m,p,g,l,c,u,x,f,E]),S=a(t=>{var e,n,r,i;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[p.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const r=Ae.positions.get(t);if(null==r?void 0:r.locked){const e=new Map(Ae.positions);return e.delete(t),Ae={positions:e},Se(),!1}Ae={positions:new Map(Ae.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Se()}(p.name||"hover",Number(n),g)}if(t&&h){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]),h(r,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(l||x){const e={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const o=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(r=t.x)&&void 0!==r?r:0,y:null!==(i=t.y)&&void 0!==i?i:0});l&&l(o),x&&x(o)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});l&&l(t),x&&x(t)}}},[h,l,x,c,u,p,g]);return r(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{Pe(t,g),_e(t,g)}},[null==p?void 0:p.mode,null==p?void 0:p.name,g]),{activeSelectionHook:b,hoverSelectionHook:A,customHoverBehavior:M,customClickBehavior:S,crosshairSourceId:g}}const Ji={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 to(t,e,n){var r,i,o,l,a,s,c;const u=Ji[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:u.width,height:null!==(i=e.height)&&void 0!==i?i:u.height,showAxes:null!==(o=e.showAxes)&&void 0!==o?o:u.showAxes,showGrid:null!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||u.enableHover,showLegend:null!==(s=e.showLegend)&&void 0!==s?s: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:eo(u.marginDefaults,e.showCategoryTicks,e.orientation)}}function eo(t,e,n){if(!1!==e)return t;const r=Object.assign({},t);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const no={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"},ro={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function io(e,n,r,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.createElement("div",{style:Object.assign(Object.assign({},no),{width:n,height:r})},i||"No data available"):null}function oo(e,n,r){if(!e)return null;const i=Math.min(5,Math.floor(r/40)),o=Math.max(8,Math.floor(r/(3*i))),l=Math.max(6,Math.floor(r/(2.5*i))),a=Math.floor((r-(i*(o+l)-l))/2);return t.createElement("div",{style:{width:n,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:i},(e,r)=>t.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ro),{position:"absolute",top:a+r*(o+l),left:Math.floor(.1*n),width:30+(37*r+13)%50+"%",height:o,opacity:.5+r%2*.2})})))}const lo=c(function(n,r){var i,o,l,s;const c=to(n.mode,{width:null!==(o=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:S,tooltipContent:_,tooltip:P,onHover:T,annotations:D,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:O,decay:$,pulse:N,staleness:I,transition:W,linkedHover:z,selection:R,onObservation:B,chartId:F,loading:j,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=_?_:P,Z=e(null),{customHoverBehavior:Q}=Qi({selection:R,linkedHover:z,unwrapData:!0,onObservation:B,chartType:"RealtimeLineChart",chartId:F}),J=a(t=>{T&&T(t),Q(t)},[T,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=oo(j,U[0],U[1]),et=tt?null:io(v,U[0],U[1],Y),nt={stroke:E,strokeWidth:A,strokeDasharray:M};return tt||et||t.createElement(rr,{ref:Z,chartType:"line",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:nt,showAxes:G,background:S,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:D,svgAnnotationRules:C,tickFormatTime:L,tickFormatValue:O,decay:$,pulse:N,staleness:I,transition:W,pointIdAccessor:n.pointIdAccessor,legendPosition:X})});lo.displayName="RealtimeLineChart";const ao=c(function(r,i){var o,l,s,c;const d=to(r.mode,{width:null!==(l=null===(o=r.size)||void 0===o?void 0:o[0])&&void 0!==l?l:r.width,height:null!==(c=null===(s=r.size)||void 0===s?void 0:s[1])&&void 0!==c?c:r.height,enableHover:null!=r.enableHover?!!r.enableHover:void 0}),{binSize:h,size:f,margin:y,className:g,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m=200,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:E,extentPadding:A,categoryAccessor:M,colors:S,fill:_,stroke:P,strokeWidth:T,gap:D,background:C,tooltipContent:L,tooltip:O,onHover:$,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,linkedHover:R,selection:B,decay:F,pulse:j,staleness:Y,transition:H,onObservation:X,chartId:G,loading:V,emptyContent:q,emphasis:U,legendPosition:K,brush:Z,onBrush:Q,linkedBrush:J}=r,tt=d.showAxes,et=d.enableHover,nt=null!=y?y:d.marginDefaults,rt=null!=f?f:[d.width,d.height],it=null!=L?L:O,ot=e(null),{customHoverBehavior:lt}=Qi({selection:B,linkedHover:R,unwrapData:!0,onObservation:X,chartType:"RealtimeTemporalHistogram",chartId:G}),at=a(t=>{$&&$(t),lt(t)},[$,lt]),st=!0===Z?{dimension:"x",snap:"bin"}:"x"===Z?{dimension:"x"}:"object"==typeof Z?Z:void 0,ct=(ut=J)?"string"==typeof ut?{name:ut}:ut:null;var ut;const dt=function(t){const{name:e,xField:r,yField:i}=t,{predicate:o,isActive:l,selectInterval:s,clear:c}=Zi({name:e}),u=r&&i?"xyBrush":r?"xBrush":"yBrush",d=a(t=>{if(!t)return void c();const e={};"xyBrush"===u&&Array.isArray(t)&&2===t.length?(r&&(e[r]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),i&&(e[i]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&Array.isArray(t)?r&&(e[r]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&Array.isArray(t)&&i&&(e[i]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&s(e)},[u,r,i,s,c]);return{brushInteraction:n(()=>({brush:u,during:d,end:d}),[u,d]),predicate:o,isActive:l,clear:c}}(Object.assign({name:(null==ct?void 0:ct.name)||"__unused_hist_brush__",xField:(null==ct?void 0:ct.xField)||("string"==typeof b?b:"time")},(null==ct?void 0:ct.yField)?{yField:ct.yField}:{})),ht=e(dt.brushInteraction);ht.current=dt.brushInteraction;const ft=a(t=>{if(Q&&Q(t),X&&X(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}),ct){const e=ht.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)}},[Q,X,G,ct]);u(i,()=>({push:t=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=ot.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=ot.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=ot.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=ot.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=ot.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const yt=oo(V,rt[0],rt[1]),gt=yt?null:io(x,rt[0],rt[1],q),pt={};return null!=_&&(pt.fill=_),null!=P&&(pt.stroke=P),null!=T&&(pt.strokeWidth=T),null!=D&&(pt.gap=D),yt||gt||t.createElement(rr,{ref:ot,chartType:"bar",runtimeMode:"streaming",size:rt,margin:nt,className:U?`${g||""} semiotic-emphasis-${U}`.trim():g,arrowOfTime:p,windowMode:v,windowSize:m,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:E,extentPadding:A,binSize:h,categoryAccessor:M,barColors:S,barStyle:pt,showAxes:tt,background:C,hoverAnnotation:et,tooltipContent:it,customHoverBehavior:at,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,decay:F,pulse:j,staleness:Y,transition:H,pointIdAccessor:r.pointIdAccessor,legendPosition:K,brush:st||(J?{dimension:"x"}:void 0),onBrush:st||J?ft:void 0})});ao.displayName="RealtimeTemporalHistogram";const so=ao,co=c(function(n,r){var i,o,l,s;const c=to(n.mode,{width:null!==(o=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:S,opacity:_,stroke:P,strokeWidth:T,background:D,tooltipContent:C,tooltip:L,onHover:O,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:R,onObservation:B,chartId:F,loading:j,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=C?C:L,Z=e(null),{customHoverBehavior:Q}=Qi({selection:R,linkedHover:z,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:F}),J=a(t=>{O&&O(t),Q(t)},[O,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=oo(j,U[0],U[1]),et=tt?null:io(v,U[0],U[1],Y),nt={};return null!=M&&(nt.radius=M),null!=S&&(nt.fill=S),null!=_&&(nt.opacity=_),null!=P&&(nt.stroke=P),null!=T&&(nt.strokeWidth=T),tt||et||t.createElement(rr,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:E,barColors:A,swarmStyle:nt,showAxes:G,background:D,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});co.displayName="RealtimeSwarmChart";const uo=c(function(n,r){var i,o,l,s;const c=to(n.mode,{width:null!==(o=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:S,gap:_,stroke:P,strokeWidth:T,background:D,tooltipContent:C,tooltip:L,onHover:O,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:R,onObservation:B,chartId:F,loading:j,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=C?C:L,Z=e(null),{customHoverBehavior:Q}=Qi({selection:R,linkedHover:z,unwrapData:!0,onObservation:B,chartType:"RealtimeWaterfallChart",chartId:F}),J=a(t=>{O&&O(t),Q(t)},[O,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=oo(j,U[0],U[1]),et=tt?null:io(v,U[0],U[1],Y),nt={};return null!=E&&(nt.positiveColor=E),null!=A&&(nt.negativeColor=A),null!=M&&(nt.connectorStroke=M),null!=S&&(nt.connectorWidth=S),null!=_&&(nt.gap=_),null!=P&&(nt.stroke=P),null!=T&&(nt.strokeWidth=T),tt||et||t.createElement(rr,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:nt,showAxes:G,background:D,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});uo.displayName="RealtimeWaterfallChart";const ho=c(function(n,r){var i,o,l,s;const c=to(n.mode,{width:null!==(o=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:S="count",background:_,tooltipContent:P,tooltip:T,onHover:D,annotations:C,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,linkedHover:z,selection:R,onObservation:B,chartId:F,loading:j,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=P?P:T,Z=e(null),{customHoverBehavior:Q}=Qi({selection:R,linkedHover:z,unwrapData:!0,onObservation:B,chartType:"RealtimeHeatmap",chartId:F}),J=a(t=>{D&&D(t),Q(t)},[D,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=oo(j,U[0],U[1]),et=tt?null:io(v,U[0],U[1],Y);return tt||et||t.createElement(rr,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:E,heatmapXBins:A,heatmapYBins:M,heatmapAggregation:S,showAxes:G,background:_,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:C,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});ho.displayName="RealtimeHeatmap";export{gt as IncrementalExtent,ho as RealtimeHeatmap,so as RealtimeHistogram,lo as RealtimeLineChart,co as RealtimeSwarmChart,uo as RealtimeWaterfallChart,yt as RingBuffer,Hi as StreamNetworkFrame,rr as StreamXYFrame};
|
|
1
|
+
import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useEffect as l,createContext as s,useContext as a,useCallback as c,useSyncExternalStore as u,useState as d,forwardRef as h,useImperativeHandle as f,useId as g}from"react";import{select as y}from"d3-selection";import{brushX as p,brushY as v,brush as m}from"d3-brush";import{scaleLinear as x,scaleLog as b,scaleTime as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{schemeCategory10 as A,interpolateTurbo as S,interpolateCividis as _,interpolateMagma as M,interpolateInferno as P,interpolatePlasma as C,interpolateGreys as T,interpolatePurples as D,interpolateOranges as E,interpolateViridis as L,interpolateGreens as O,interpolateReds as $,interpolateBlues as N}from"d3-scale-chromatic";import{bin as I,min as W,groups as z,max as Y,sum as R,mean as B,group as j}from"d3-array";import{packEnclose as F,hierarchy as H,partition as X,pack as G,treemap as V,treemapBinary as q,cluster as U,tree as K}from"d3-hierarchy";import{area as Z,curveCatmullRom as Q,curveCardinal as J,curveBasis as tt,curveStepBefore as et,curveStepAfter as nt,curveStep as it,curveMonotoneY as ot,curveMonotoneX as rt,curveLinear as lt,arc as st,line as at,curveNatural as ct,pie as ut}from"d3-shape";import dt from"regression";import{interpolateNumber as ht}from"d3-interpolate";import{forceLink as ft,forceSimulation as gt,forceManyBody as yt,forceCenter as pt,forceX as vt,forceY as mt}from"d3-force";import{ribbon as xt,chord as bt}from"d3-chord";function kt(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 wt(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 At({width:e,height:n,totalWidth:i,totalHeight:s,margin:a,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:x,streaming:b}){const k=o(null),w=o(null),A=o(d);A.current=d;const S=o(u);S.current=u;const _=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),M=o(_);M.current=_;const P=o(!1),C=o(null);return l(()=>{if(!k.current)return;const t=y(k.current).select(".brush-g"),i="x"===c?p():"y"===c?v():m();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(P.current)return;const r=S.current;if(!r)return;if(!o.selection)return C.current=null,void A.current(null);let l,s;if("x"===c){const[t,e]=o.selection;l=[r.x.invert(t),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(0)]}else if("y"===c){const[t,n]=o.selection;l=[r.x.invert(0),r.x.invert(e)],s=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;l=[r.x.invert(t),r.x.invert(n)],s=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==c&&("end"===o.type||"brush"===o.type&&x)){const e=M.current;e&&e.length>0?l=function(t,e){return 0===e.length?t:[kt(t[0],e),wt(t[1],e)]}(l,e):h&&h>0&&(l=[Math.floor(l[0]/h)*h,Math.ceil(l[1]/h)*h]);const n=r.x(l[0]),s=r.x(l[1]);if(P.current=!0,"x"===c)t.call(i.move,[n,s]);else if("xy"===c){const e=o.selection;t.call(i.move,[[n,e[0][1]],[s,e[1][1]]])}P.current=!1}const a={x:l,y:s};C.current=a,A.current(a)}),t.call(i),w.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),w.current=null}},[e,n,c,f,h,x]),l(()=>{if(!(b&&u&&w.current&&C.current))return;if(!k.current)return;if("y"===c)return;const t=C.current,e=u.x.domain()[0],n=y(k.current).select(".brush-g");if(e>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=M.current;t&&t.length>0?i=wt(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,C.current=null,void A.current(null);o=!0}const r=u.x(i),l=u.x(t.x[1]);if(P.current=!0,"x"===c)n.call(w.current.move,[r,l]);else{const e=u.y(t.y[1]),i=u.y(t.y[0]);n.call(w.current.move,[[r,e],[l,i]])}if(P.current=!1,o){const e={x:[i,t.x[1]],y:t.y};C.current=e,A.current(e)}},[u,b,c,f,h]),t("svg",{ref:k,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class St{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 _t(e){const n=s(null),i=Mt(e);return[function({children:i}){const o=r(()=>Mt(e),[]);return t(n.Provider,{value:o,children:i})},t=>{var e;const r=null!==(e=a(n))&&void 0!==e?e:i,l=o(t);l.current=t;const s=c(()=>l.current(r.getState()),[r]),d=c(()=>l.current(r.getState()),[r]);return u(r.subscribe,s,d)}]}function Mt(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 Pt(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 Ct(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:Tt})})),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 Tt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Dt={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}},Et={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}},Lt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Tt,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"},[Ot,$t]=_t(t=>({theme:Dt,setTheme(e){t(t=>{if("light"===e)return{theme:Dt};if("dark"===e)return{theme:Et};if("high-contrast"===e)return{theme:Lt};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Et:Dt;return{theme:Ct(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:Ct(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 Nt{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,l=this.buffer[r];if(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[r]=e(l)}}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 It{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 Wt(t,e,n,i,o){const r=new Map;for(const l of t){const t=e(l),s=n(l);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))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+=s,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+s)}}return r}function zt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Yt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Rt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const jt=A,Ft=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Ht(t,e,n){var i,o,r;if(1>=n)return 1;const l=null!==(i=t.minOpacity)&&void 0!==i?i:.1,s=n-1-e;switch(t.type){case"linear":return l+(1-s/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,s/e)*(1-l)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>s?1:l;default:return 1}}function Xt(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 Gt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Vt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function qt(t,e,n){return t+(e-t)*n}function Ut(t,e,n){var i,o,r,l;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!==(l=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!==l?l: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 Kt(t,e,n,i,o,r){const l=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||l.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}l.sort((t,e)=>t.px-e.px);const s=Array(l.length),a=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];s[t]=[e.px,e.py],a[t]=e.rawY,c[t]=e.d}return{type:"line",path:s,rawValues:a,style:o,datum:c,group:r}}function Zt(t,e,n,i,o,r,l,s){const a=[];for(const r of t){const t=n(r),l=i(r);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=s?s(r):o;a.push({px:c,topY:e.y(l),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:l}}function Qt(t,e,n,i,o,r,l){const s=n(t),a=i(t);if(null==s||null==a||Number.isNaN(s)||Number.isNaN(a))return null;const c={type:"point",x:e.x(s),y:e.y(a),r:o,style:r,datum:t};return void 0!==l&&(c.pointId=l),c}function Jt(t,e,n,i,o,r,l){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:l}}function te(t,e,n,i,o,r,l){const s={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==l?void 0:l.showValues)&&(s.showValues=!0,s.value=l.value,l.valueFormat&&(s.valueFormat=l.valueFormat)),s}function ee(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 l=t.getBounds(n),s=t.scales.x(e);if(l&&0!==l)i.push([s,t.scales.y(r+l)]),o.push([s,t.scales.y(r-l)]);else{const e=t.scales.y(r);i.push([s,e]),o.push([s,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 ne(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 l of i.data){let i=t.config.pointStyle(l);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const s=null!==(o=i.r)&&void 0!==o?o:3,a=t.getPointId?t.getPointId(l)+"":void 0,c=Qt(l,t.scales,t.getX,r,s,i,a);c&&n.push(c)}}}const ie={blues:N,reds:$,greens:O,viridis:L,oranges:E,purples:D,greys:T,plasma:C,inferno:P,magma:M,cividis:_,turbo:S},oe=new Map;class re{constructor(t){if(this.xExtent=new It,this.yExtent=new It,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 Nt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Yt(t.timeAccessor||t.xAccessor,"time"),this.getY=Yt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Yt(t.xAccessor,"x"),this.getY=Yt(t.yAccessor,"y")),this.getGroup=Bt(t.groupAccessor),this.getCategory=Bt(t.categoryAccessor),this.getSize=t.sizeAccessor?Yt(t.sizeAccessor,"size"):void 0,this.getColor=Bt(t.colorAccessor),this.getBounds=t.boundsAccessor?Yt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?Yt(t.y0Accessor,"y0"):void 0,this.getPointId=Bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Yt(t.openAccessor,"open"):void 0,this.getHigh=Yt(t.highAccessor,"high"),this.getLow=Yt(t.lowAccessor,"low"),this.getClose=n?Yt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new Nt(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?Yt(this.config.timeAccessor||this.config.xAccessor,"time"):Yt(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,o,r,l,s;const{config:a,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),d=this.xExtent.extent,h=this.yExtent.extent;let f=a.xExtent?[null!==(n=a.xExtent[0])&&void 0!==n?n:d[0],null!==(i=a.xExtent[1])&&void 0!==i?i:d[1]]:d,g=a.yExtent?[null!==(o=a.yExtent[0])&&void 0!==o?o:h[0],null!==(r=a.yExtent[1])&&void 0!==r?r:h[1]]:h;const y=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!y&&c.size>0)if(a.normalize)g=[0,1+a.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)g=this._stackExtentCache.yDomain;else{const e=this.groupData(u),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)}g=[0,i+(i>0?i*a.extentPadding:1)],this._stackExtentCache={key:t,yDomain:g}}}else if("bar"===a.chartType&&a.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,i,o){const r=Wt(t,e,n,i,o);if(0===r.size)return[0,0];let l=0;for(const t of r.values())t.total>l&&(l=t.total);return[0,l]}(c,this.getX,this.getY,a.binSize,this.getCategory);g=[0,t+t*a.extentPadding]}else if("waterfall"===a.chartType&&!y&&c.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]}(c,this.getY),n=e-t,i=n>0?n*a.extentPadding:1;g=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!y&&g[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}const t=g[1]-g[0],e=t>0?t*a.extentPadding:1,n=null===(l=a.yExtent)||void 0===l?void 0:l[0],i=null===(s=a.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-e,null!=i?g[1]:g[1]+e],"log"===a.yScaleType&&0>=g[0]&&h[0]>0&&(g[0]=null!=n?g[0]:h[0]/(1+a.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===a.xScaleType){const t=Date.now();f=[t-864e5,t]}else f=[0,1];g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]);const p="streaming"===a.runtimeMode,v=Math.max(0,Math.min(a.scalePadding||0,Math.min(t.width,t.height)/2-1));if(p)if("x"==("up"===(m=a.arrowOfTime)||"down"===m?"y":"x")){const e="right"===a.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:x().domain(f).range(e),y:x().domain(g).range([t.height-v,v])}}else{const e="down"===a.arrowOfTime?[v,t.height-v]:[t.height-v,v];this.scales={x:x().domain(g).range([v,t.width-v]),y:x().domain(f).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 b().domain(t).range(n).clamp(!0)}return"time"===t?k().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)};this.scales={x:e(a.xScaleType,f,[v,t.width-v]),y:e(a.yScaleType,g,[t.height-v,v])}}var m;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),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,re.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=w().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(),o=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?k().domain([new Date(e[0]),new Date(e[1])]).range(n):x().domain(e).range(n)},a=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=l[1]>l[0];this.scales={x:s(this.config.xScaleType,i,r[0]>r[1]?[t.width-a,a]:[a,t.width-a]),y:s(this.config.yScaleType,o,c?[a,t.height-a]:[t.height-a,a])},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=ee(t,e.data,e.key);n&&o.push(n)}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Kt(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 ne(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]),l=Zt(e.data,t.scales,t.getX,t.getY,o,n,e.key,r);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),i.push(l)}return ne(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],l=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=Zt(e.data,t.scales,t.getX,t.getY,r,n,e.key,l);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=Kt(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 ne(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,l){var s;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===(s=u.get(i.key))||void 0===s?void 0:s.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=[],s=[],a=new Map;for(const n of c){let o=t.get(n)||0;const l=g.get(n);r&&(o/=d.get(n));const c=l+o,u=e.x(n);s.push([u,e.y(l)]),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:s,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(y.curve=l),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),l=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)};ne(t,n,l,i)}return l}(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 l=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);l=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const s=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(l&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=l(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=Qt(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 l=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),s=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=Yt(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)/l,y=(f-h||1)/s,p=l*s;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),l-1),d=Math.min(Math.floor((r-h)/y),s-1);if(0>a||0>d)continue;const f=d*l+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/l,A=n.height/s,S=t.config.showValues,_=t.config.heatmapValueFormat,M=[];for(let t=0;s>t;t++){const e=t*l;for(let n=0;l>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;M.push(te(n*w,(s-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:_}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const i=Yt(t.config.valueAccessor,"value"),o=Rt(t.config.xAccessor,"x"),r=Rt(t.config.yAccessor,"y"),l=new Map,s=new Map,a=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);a[t]=i,c[t]=u,l.has(i)||l.set(i,l.size),s.has(u)||s.set(u,s.size)}const u=l.size,d=s.size;if(0===u||0===d)return[];const h=Array.from(l.keys()),f=Array.from(s.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),l.clear();for(let t=0;h.length>t;t++)l.set(h[t],t)}if(y){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(a[t]),r=s.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),p[g]=h,v[g]=d,m[g]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ie?t:"blues";let n=oe.get(e);if(n)return n;n=Array(256);const i=ie[e]||N;for(let t=0;256>t;t++)n[t]=i(t/255);return oe.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/d,P=t.config.showValues,C=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],i=n%u;T.push(te(i*_,(d-1-(n-i)/u)*M,_,M,A[Math.min((e-k)*S+.5|0,255)],m[t],P?{value:e,showValues:!0,valueFormat:C}:void 0))}return T}(r,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Wt(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),l=Array.from(e).filter(t=>!i.has(t)).sort(),s=n.filter(t=>e.has(t)),a=s.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===a?r=t.barCategoryCache.order:(r=[...s,...l],t.barCategoryCache={key:a,order:r})}const l=[],s=t.scales,[a,c]=s.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=s.x(n),y=s.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=s.y(n),c=s.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";l.push(Jt(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=s.y(0),n=s.y(e.total);l.push(Jt(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:l,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,l,s;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!==(l=c.opacity)&&void 0!==l?l:.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 l=d;if(t.getCategory){const e=t.getCategory(n);l=(null===(s=t.config.barColors)||void 0===s?void 0:s[e])||l}const c={type:"point",x:o,y:r,r:u,style:{fill:l,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,l,s,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!==(l=null==h?void 0:h.negativeColor)&&void 0!==l?l:null===(s=t.config.themeSemantic)||void 0===s?void 0:s.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),l=b+r;let s;s=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!==s?d.x(o+s):a+n.width/10,k=Math.min(a,c)+p/2,w=Math.max(a,c)-p/2-k;if(0>=w){b=l;continue}const A=d.y(b),S=d.y(l),_=Math.min(A,S),M=Math.abs(A-S),P={fill:0>r?y:g,stroke:v,strokeWidth:m};null!=x&&(P.opacity=x),u.push(Jt(k,_,w,M,P,Object.assign(Object.assign({},i),{baseline:b,cumEnd:l,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=l}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=[],l=t.config.candlestickStyle||{},s=l.rangeColor||"#6366f1",a=o?s:l.upColor||"#28a745",c=o?s:l.downColor||"#dc3545",u=o?s:l.wickColor||"#333",d=l.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=l.bodyWidth)&&void 0!==i?i:0;if(null==l.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),l=t.getLow(n);if(null==i||Number.isNaN(i)||null==l||Number.isNaN(l))continue;const s=o?i:t.getOpen(n),h=o?l:t.getClose(n);if(!o&&[s,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(l),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?Ht(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 l=new Map;for(let t=0;n.length>t;t++)l.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 s=l.get(e[n]);null!=s?(i[n]=Ht(t,s,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 s=!1;for(let n=0;e.length>n;n++){const i=l.get(e[n]);null!=i?(o[n]=Ht(t,i,r),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=Ht(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const s=Ht(t,e,r);if("heatcell"===n.type)n.style={opacity:s};else if("candlestick"===n.type)n._decayOpacity=s;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*s})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const l="undefined"!=typeof performance?performance.now():Date.now(),s=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 s=Xt(t,r,l);s>o&&(o=s)}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=Xt(t,o,l);r>0&&(n._pulseIntensity=r,n._pulseColor=s,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,l,s;n.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],u=Ut(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===(l=c.style)||void 0===l?void 0:l.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===(s=c.style)||void 0===s?void 0:s.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=Ut(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,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_,M,P,C,T,D,E,L,O,$,N,I,W,z,Y,R,B,j,F,H,X;if(0===i.size&&0===o.size)return n;const G=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 V=!1;const q=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],D=Ut(t,r,e);if(!D)continue;if(r._transitionKey=D,"line"===r.type||"area"===r.type){const t=o.get(D);if(t){if(U.add(D),"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]];V=!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]];V=!0}r._targetOpacity=null!==(l=r.style.opacity)&&void 0!==l?l:1,r._startOpacity=null!==(a=null!==(s=t.opacity)&&void 0!==s?s: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}),V=!0;continue}const E=i.get(D);if("point"===r.type)if(E){q.add(D);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,E.x===t.x&&E.y===t.y&&E.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=E.x,r.y=E.y,r.r=null!==(d=E.r)&&void 0!==d?d:r.r,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(E){q.add(D);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,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=E.x,r.y=E.y,r.w=null!==(g=E.w)&&void 0!==g?g:r.w,r.h=null!==(y=E.h)&&void 0!==y?y:r.h,V=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(E){q.add(D);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,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=E.x,r.y=E.y,r.w=null!==(x=E.w)&&void 0!==x?x:r.w,r.h=null!==(b=E.h)&&void 0!==b?b:r.h,V=!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}),V=!0;else if("candlestick"===r.type)if(E&&null!=E.openY){q.add(D);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,(E.x!==t.x||E.openY!==t.openY||E.closeY!==t.closeY||E.highY!==t.highY||E.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=E.x,r.openY=E.openY,r.closeY=null!==(_=E.closeY)&&void 0!==_?_:r.closeY,r.highY=null!==(M=E.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(P=E.lowY)&&void 0!==P?P:r.lowY,V=!0)}else r._targetOpacity=null!==(T=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0}for(const[t,e]of o)if(!U.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!==(D=e.opacity)&&void 0!==D?D:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!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!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),V=!0}for(const[t,e]of i)if(!q.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O: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!==($=e.w)&&void 0!==$?$:0,h:null!==(N=e.h)&&void 0!==N?N:0,style:{opacity:null!==(I=e.opacity)&&void 0!==I?I: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!==(W=e.w)&&void 0!==W?W:0,h:null!==(z=e.h)&&void 0!==z?z:0,fill:"#999",datum:null,style:{opacity:null!==(Y=e.opacity)&&void 0!==Y?Y:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(R=e.openY)&&void 0!==R?R:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(B=e.closeY)&&void 0!==B?B:i,highY:null!==(j=e.highY)&&void 0!==j?j: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)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:G}),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,l,s,a,c;if(!n.activeTransition)return!1;const u=Vt(t,n.activeTransition),d=Gt(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=qt(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=qt(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=qt(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==n.w&&(t.w=qt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=qt(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!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:qt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),t.y=qt(n.y,t._targetY,d),void 0!==n.w&&(t.w=qt(n.w,t._targetW,d)),void 0!==n.h&&(t.h=qt(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!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:qt(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=qt(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=qt(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=qt(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=qt(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=qt(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:qt(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]=qt(e[i][0],n[i][0],d),t.path[i][1]=qt(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:qt(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]=qt(e[n][0],i[n][0],d),t.topPath[n][1]=qt(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]=qt(n[e][0],o[e][0],d),t.bottomPath[e][1]=qt(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||Ft,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 l=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:l,fillOpacity:.7,stroke:l,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)||Ft;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>re.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 l=!1;Object.assign(this.config,t);const s="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(s||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const a=s||!zt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),c=s||!zt(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=Yt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Yt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Yt(this.config.xAccessor,"x"),this.getY=Yt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!zt(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Bt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!zt(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Bt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!zt(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Yt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!zt(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Bt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!zt(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Yt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!zt(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Bt(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!zt(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!zt(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!zt(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!zt(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Yt(this.config.openAccessor,"open"):void 0,this.getHigh=Yt(this.config.highAccessor,"high"),this.getLow=Yt(this.config.lowAccessor,"low"),this.getClose=e?Yt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0}if(!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function le(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 se(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function ae(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function ce(t,e){const n=ae(t);if(!n)return!1;const i=ae(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}function ue(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function de(t,e,n,i=30,o,r=0){let l=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),l=e-r,s=e+r,a=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>s||l>h||r>c||a>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,l=t.y-n,s=Math.sqrt(r*r+l*l);se(t.r,i)>=s&&d>s&&(u=t,d=s),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,r);t&&(l={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=fe(r,e,n,i);break;case"line":t=ge(r,e,n,i);break;case"rect":t=pe(r,e,n);break;case"heatcell":t=ve(r,e,n);break;case"area":if(!1===r.interactive)break;t=xe(r,e,n);break;case"candlestick":t=me(r,e,n)}t&&i>t.distance&&(l&&t.distance>=l.distance||(l=t))}return l}function he(t,e,n){if(0===t.length)return null;const i=be(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[l,s]=t[o],[a,c]=t[r];return a===l?s:s+Math.max(0,Math.min(1,(e-l)/(a-l)))*(c-s)}function fe(t,e,n,i=30){const o=e-t.x,r=n-t.y,l=Math.sqrt(o*o+r*r);return l>se(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function ge(t,e,n,i=30){var o,r,l,s;if(0===t.path.length)return null;const a=be(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 l=o;r>=l;l++){const[o,r]=t.path[l],[s,a]=t.path[l+1],c=ye(e,n,o,r,s,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!==(s=null!==(r=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==s?s: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 ye(t,e,n,i,o,r){const l=o-n,s=r-i,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*l+(e-i)*s)/a;c=Math.max(0,Math.min(1,c));const u=i+c*s;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function pe(t,e,n){const i=le(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function ve(t,e,n){const i=le(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function me(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,l=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+l*l)}}return null}function xe(t,e,n){if(0===t.topPath.length)return null;const i=be(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],l=e-o,s=n-r,a=Math.sqrt(l*l+s*s);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function be(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 ke(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 l=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&&l.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:l}}function we(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 Ae(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?Se(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Se(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 Se(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 _e(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function Me(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 Pe(t,e,n,i,o,r){l(()=>{if(!t)return;const l=setInterval(()=>{var l;const s=e.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(l=t.threshold)&&void 0!==l?l:5e3,u=a-s.lastIngestTime>c;u!==o&&(r(u),n.current=!0,i())},1e3);return()=>clearInterval(l)},[t,o,i])}re.GROUP_COLOR_MAP_CAP=1e3,re.QUADTREE_THRESHOLD=500;const Ce={fill:e=>t("rect",{style:e,width:16,height:16}),line:e=>t("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Te(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,Ce[n])(i(t,e)),o}function De(){return t("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ee(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Le=(n,i,o,r,l,s,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=n,y=[];let p=0;const v=!(!i&&!o),m="isolate"===d||void 0===d&&null!=l;return g.forEach((n,d)=>{const x=Te(n,d,h,f),b=Ee(n,r,l),k=l&&l.size>0&&l.has(n.label);y.push(e("g",{transform:`translate(0,${p})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?c===s&&d===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&m?k||!1:void 0,"aria-current":v&&!m&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+g.length)%g.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:v?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,k&&t(De,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),p+=22}),y};function Oe({config:n,orientation:o="vertical",width:r=100}){const{colorFn:l,domain:s,label:a,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:l(s[0]+n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),a&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:l(s[1]-n*(s[1]-s[0]))},e))}return e("g",{"aria-label":a||"Gradient legend",children:[a&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(s[0])})]})}function $e(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical"}=n,[g,y]=i.useState(0),[p,v]=i.useState(0),m=i.useCallback((t,e)=>{y(t),v(e)},[]),x="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t("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("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("g",{className:"legend-item",transform:`translate(0,${d})`,children:Le(e,i,o,r,l,s,a,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h})=>{let f=0;const g=[];n.forEach((n,i)=>{let y=0;n.label&&(y+=16);const p=((n,i,o,r,l,s,a,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let v=0,m=0;const x=!(!i&&!o),b="isolate"===d||void 0===d&&null!=l;y.forEach((n,d)=>{const k=Te(n,d,f,g),w=Ee(n,r,l),A=l&&l.size>0&&l.has(n.label),S=26+7*n.label.length;h&&h>0&&v>0&&v+S>h&&(m++,v=0),p.push(e("g",{transform:`translate(${v},${22*m})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:x?c===s&&d===a?0:-1:void 0,role:x?"option":void 0,"aria-selected":x&&b?A||!1:void 0,"aria-current":x&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:x?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(d+("ArrowRight"===t.key?1:-1)+y.length)%y.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:x?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:x?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:x?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[x&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,A&&t(De,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),v+=S});let k=0,w=0;for(const t of y){const e=26+7*t.label.length;h&&h>0&&w>0&&w+e>h?(k=Math.max(k,w),w=e):w+=e}k=Math.max(k,w);const A=m+1;return{items:p,offset:k,totalRows:A,totalHeight:22*A}})(n,r,l,s,a,c,u,i,d,h,o);y+=p.offset+5,g.push(Object.assign(Object.assign({label:n.label},p),{offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight})),f+=y+12});let y=f>o?0:Math.max(0,(o-f)/2);const p=[];return g.forEach((e,o)=>{const r=n[o];r.label&&(p.push(t("text",{transform:`translate(${y},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)),y+=16),p.push(t("g",{className:"legend-item",transform:`translate(${y},0)`,children:e.items},"legend-group-"+o)),y+=e.offset+5,n[o+1]&&p.push(t("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),t("g",{children:p})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:l,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:g,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:c}),b=!(!r&&!l);return e("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==c&&(void 0!==c||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),x]})}function Ne(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ie(t){return"object"==typeof t&&null!==t&&"gradient"in t}function We(e){const{legend:n,totalWidth:i,totalHeight:o,margin:r,legendPosition:l="right",title:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===l||"bottom"===l;let g,y;return"left"===l?(g=4,y=r.top):"top"===l?(g=0,y=s?32:8):"bottom"===l?(g=0,y=o-r.bottom+50):(g=i-r.right+10,y=r.top),t("g",{transform:`translate(${g}, ${y})`,children:Ie(n)?t(Oe,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):Ne(n)?t($e,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function ze(t){return"string"==typeof t?{type:t}:t}function Ye({orient:n,config:i,values:o,scale:l,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=r(()=>{if(0===o.length)return null;const i=l.domain(),r=s-8;if("boxplot"===c.type){const i=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)],l=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*l),whiskerHigh:Math.min(e[n-1],r+1.5*l)}}(o);if(!i)return null;const{q1:s,median:a,q3:d,whiskerLow:h,whiskerHigh:f}=i,g=Math.min(.5*r,20),y=(r-g)/2+4;if(u){const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="top"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:m+v*(y+g/2),x2:p,y2:m+v*(y+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:m+v*y,x2:u,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:p,y1:m+v*y,x2:p,y2:m+v*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?m-y-g:m+y,width:Math.abs(o-i),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?m-y-g:m+y,x2:r,y2:"top"===n?m-y:m+y+g,stroke:c.fill,strokeWidth:2})]})}{const i=l(s),o=l(d),r=l(a),u=l(h),p=l(f),v="left"===n?-1:1,m=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:m+v*(y+g/2),y1:u,x2:m+v*(y+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:u,x2:m+v*(y+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:m+v*y,y1:p,x2:m+v*(y+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?m-y-g:m+y,y:Math.min(i,o),width:g,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?m-y-g:m+y,y1:r,x2:"left"===n?m-y:m+y+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=I().domain(i).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("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(s,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=l(e.x0),s=l(e.x1)-l(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+s),width:o,height:Math.abs(s),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),s=l((t.x0+t.x1)/2);i.push(u?`${s},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${s}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const s=o.length/h*(r/2),a=l((o.x0+o.x1)/2);i.push(u?`${a},${"top"===n?-(e+s):e+s}`:`${"left"===n?-(e+s):e+s},${a}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:i.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,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?l(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=l((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,l,c,s,a,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Re(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let l="";for(const t of o)l&&l.length+1+t.length>i?(r.push(l),l=t):l=l?`${l} ${t}`:t;return l&&r.push(l),r}function Be(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 je(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:l,title:s,orientation:a,align:c,wrap:u=120,noWrap:d}=n;if(!l&&!s)return t("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>i?"end":"start";const y=16,p=s?d?[s]:Re(s,u):[],v=l?d?[l]:Re(l,u):[],m="leftRight"===h?"end"===g?-4:4:0;let x=0;const b=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:p.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-title")),x=p.length*y),v.length>0&&b.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:x,children:v.map((e,n)=>t("tspan",{x:m,dy:0===n?0:y,children:e},n))},"annotation-note-label"));let w=null;if((s||l)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===g?(n=-e,i=0):"middle"===g&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+v.length)*y+(v.length>0?y:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,p.length+v.length-1)*y;let S=0;return"topBottom"===h?S=0>o?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+y+(v.length>0&&p.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:b}),w]})}function Fe(e,n,i,o,r){var l;const s=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&s.push(t("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)&&s.push(t("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)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,l=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;s.push(t("line",{x1:o,y1:(n.y1||0)-l,x2:o,y2:(n.y2||0)-l,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)-l;s.push(t("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)?s.push(t("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)||s.push(t("line",{x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&s.push(t("path",{d:Be((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("g",{className:"annotation-subject",children:s})}function He(e,n,i,o,r,l){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==l?void 0:l.radius)){if("callout-rect"===r&&l){const t=l.width||0,i=l.height||0;if(t>0||i>0){const o=t/2,r=i/2,l=e-o,s=n-r;if(0!==l||0!==s){const e=Math.abs(l),n=Math.abs(s),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;a=o+l*h,c=r+s*h}}}else if("bracket"===r&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(a=t/2,c=n):void 0!==e&&(a=n,c=e/2)}}else{const t=(l.radius||0)+(l.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&&(s.push(t("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,l=Math.atan2(n-c,e-a);s.push(t("path",{d:`M${a},${c}L${a+i*Math.cos(l+r)},${c+i*Math.sin(l+r)}L${a+i*Math.cos(l-r)},${c+i*Math.sin(l-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t("g",{className:"annotation-connector",children:s})}function Xe(t){const{x:n=0,y:i=0,dx:o,dy:r,nx:l,ny:s,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(g)?g:[]);let m=o||0,x=r||0;null!=l&&(m=l-n),null!=s&&(x=s-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 e("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":p},y,{children:[!v.has("connector")&&He(m,x,c,h,b,u),!v.has("subject")&&Fe(b,u,h,n,i),!v.has("note")&&je(a,m,x,h)]}))}function Ge(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,l="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),s=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:s});return t(Xe,Object.assign({"data-testid":"semiotic-annotation"},r,{type:l}),"multi-annotation-"+i)});return t("g",{children:a})}const a=o.note||{title:"none",label:o.label},c=`${a.label}-${a.title}-${o.i}`;return t(Xe,Object.assign({"data-testid":"semiotic-annotation",events:s},o,{type:l}),c)}function Ve(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 qe(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 Ue(t,e,n){var i,o,r,l;const s=t.anchor||"fixed";if("latest"===s){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,l;const s=t.data;if(!s||0===s.length)return null;const a=s[s.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===(l=t.scales)||void 0===l?void 0:l.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=Ve(t,n),c=qe(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"===s){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function Ke(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const Ze={linear:lt,monotoneX:rt,monotoneY:ot,step:it,stepAfter:nt,stepBefore:et,basis:tt,cardinal:J,catmullRom:Q};let Qe={positions:new Map};const Je=new Set;function tn(){for(const t of Je)t()}function en(t,e){const n=Qe.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(Qe.positions);i.delete(t),Qe={positions:i},tn()}function nn(t,e){const n=Qe.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(Qe.positions);i.delete(t),Qe={positions:i},tn()}function on(){return Qe}function rn(t){return Je.add(t),()=>Je.delete(t)}const ln={positions:new Map};function sn(){return()=>{}}function an(){return ln}function cn(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function un(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 l="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${i+4*o}`,l+=`L${Math.min(n,e)},${i}`}return l}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let l=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);l+=`L${i+4*o},${Math.min(8*t+4,n)}`,l+=`L${i},${Math.min(e,n)}`}return l}}function dn(n){const{width:i,height:o,totalWidth:l,totalHeight:s,margin:a,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g}=n,y=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||f||hn,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=c.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),l=r.map(t=>t.valueOf()),s=r.map((t,e)=>({value:t,pixel:c.x(t),label:n(t,e,l)})),a=s.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 fn(s,Math.max(55,a+8))},[c,d,f,i]),p=r(()=>{var t;if(!c)return[];const e=null==d?void 0:d.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||g||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return fn(c.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:c.y(t),label:n(t)})),22)},[c,d,g,o]),v=h&&c,m=u&&c;if(!v&&!m)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),b=null==d?void 0:d.find(t=>"left"===t.orient),k=m&&(!x||!1!==x.baseline),w=m&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,S=(null==b?void 0:b.jaggedBase)||!1,_="var(--semiotic-border, #ccc)";return t("svg",{width:l,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${a.left},${a.top})`,children:[v&&(()=>{var n,r;const l=cn(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),s=cn(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l},"xgrid-"+n)),p.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:_,strokeWidth:1}),A&&t("path",{d:un("bottom",i,o),fill:"none",stroke:_,strokeWidth:1}),w&&!S&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:_,strokeWidth:1}),S&&t("path",{d:un("left",i,o),fill:"none",stroke:_,strokeWidth:1})]})})}function hn(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function fn(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 gn(i){var s,a;const{width:c,height:d,totalWidth:h,totalHeight:f,margin:g,scales:y,showAxes:p,axes:v,xLabel:m,yLabel:x,yLabelRight:b,xFormat:k,yFormat:w,showGrid:A,title:S,legend:_,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:T,legendPosition:D="right",foregroundGraphics:E,marginalGraphics:L,xValues:O,yValues:$,annotations:N,svgAnnotationRules:I,xAccessor:W,yAccessor:z,annotationData:Y,pointNodes:R,curve:B,underlayRendered:j,linkedCrosshairName:H,linkedCrosshairSourceId:X,children:G}=i,V=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||k||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=y.x.ticks(Math.min(i,Math.max(2,Math.floor(c/70)))),r=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:y.x(t),label:n(t,e,r)})),s=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),a=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(s+8,55)):Math.max(55,s+8);let u=fn(l,a);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=y.x.domain()[1],e=y.x(t),i=u[u.length-1].pixel;if(Math.abs(e-i)>1){const o=n(t,u.length,r);a>e-i&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[p,y,v,k,c]),q=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||w||hn,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=fn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.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=y.y.domain()[1],e=y.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},[p,y,v,w,d]),U=r(()=>{var t;if(!p||!y)return[];const e=null==v?void 0:v.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||w||hn,i=null!==(t=e.ticks)&&void 0!==t?t:5;return fn(y.y.ticks(Math.min(i,Math.max(2,Math.floor(d/30)))).map(t=>({value:t,pixel:y.y(t),label:n(t)})),22)},[p,y,v,w,d]),K=o(new Map),Q=o(null!==(s=null==N?void 0:N.length)&&void 0!==s?s:0),J=null!==(a=null==N?void 0:N.length)&&void 0!==a?a:0;Q.current!==J&&(Q.current=J,K.current=new Map);const tt=r(()=>{if(!N||0===N.length)return null;const n=function(n,i,o){var r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_,M,P,C,T,D,E,L,O,$,N,I,W,z,Y,R,B,j,H,X,G,V,q,U,K,Q,J,tt;switch(n.type){case"label":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return Ke(r,l,o)?t(Ge,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"label",connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"callout":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return Ke(r,l,o)?t(Ge,{noteData:{x:r,y:l,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"callout-circle",subject:{radius:n.radius||12},connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"x-threshold":{const r=Ve(n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:r+4,y:a,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"y-threshold":{const r=qe(n,o);if(null==r)return null;const l=n.color||"#f97316",s=n.labelPosition||"right";let a,c;return"left"===s?(a=4,c="start"):"center"===s?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:l,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:a,y:r-4,textAnchor:c,fill:l,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"enclose":{const r=(n.coordinates||[]).map(t=>({x:Ve(Object.assign(Object.assign({},t),{type:"point"}),o),y:qe(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=F(r),s=n.padding||10;return e("g",{children:[t("circle",{cx:l.x,cy:l.y,r:l.r+s,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:l.x,y:l.y-l.r-s-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"rect-enclose":{const r=(n.coordinates||[]).map(t=>({x:Ve(Object.assign(Object.assign({},t),{type:"point"}),o),y:qe(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const l=n.padding||10,s=r.map(t=>t.x),a=r.map(t=>t.y),c=Math.min(...s)-l,u=Math.max(...s)+l,d=Math.min(...a)-l,h=Math.max(...a)+l;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"highlight":{const e=o.data||[],r="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],l={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:r.map((e,i)=>{const r=Ve(e,o),s=qe(e,o);if(null==r||null==s)return null;const a="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||l;return t("circle",Object.assign({cx:r,cy:s,r:a},c),"hl-"+i)})},"ann-"+i)}case"bracket":{const e=Ve(n,o),r=qe(n,o);return t(Ge,{noteData:{x:null!=e?e:0,y:null!=r?r:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+i)}case"trend":{const h=o.data||[];if(2>h.length)return null;const f=o.xAccessor||"x",g=o.yAccessor||"y",y=h.map(t=>[t[f],t[g]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const p=null!==(l=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==l?l:null===(s=o.scales)||void 0===s?void 0:s.time,v=null!==(c=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=o.scales)||void 0===u?void 0:u.value;if(!p||!v)return null;const m=n.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]),l=Math.max(2,Math.ceil(e*n)),s=[];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(l-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){s.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))s.push([e,h/u]);else{const t=(u*g-d*h)/y;s.push([e,(h-t*d)/u+t*e])}}return s}(y,null!==(d=n.bandwidth)&&void 0!==d?d:.3):("polynomial"===m?dt.polynomial(y,{order:n.order||2}):dt.linear(y)).points;const b=x.map(([t,e])=>`${p(t)},${v(e)}`).join(" "),k=n.color||"#6366f1";return e("g",{children:[t("polyline",{points:b,fill:"none",stroke:k,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:p(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11,children:n.label})]},"ann-"+i)}case"band":{const r=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value,l=null!==(y=null==r?void 0:r(n.y0))&&void 0!==y?y:0,s=null!==(p=null==r?void 0:r(n.y1))&&void 0!==p?p:o.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(l,s),width:o.width||0,height:Math.abs(s-l),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(l,s)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+i)}case"envelope":{const r=o.data||[];if(2>r.length)return null;const l=o.xAccessor||"x",s=null!==(m=null===(v=o.scales)||void 0===v?void 0:v.x)&&void 0!==m?m:null===(x=o.scales)||void 0===x?void 0:x.time,a=null!==(k=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==k?k:null===(w=o.scales)||void 0===w?void 0:w.value;if(!s||!a)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=r.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[l]-e[l]);if(2>h.length)return null;const f=Ze[o.curve||"linear"]||lt,g=Z().x(t=>s(t[l])).y0(t=>a(t[u])).y1(t=>a(t[c])).curve(f)(h);if(!g)return null;const y=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:y,fillOpacity:null!==(A=n.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:s(h[h.length-1][l])+4,y:a(h[h.length-1][c])-4,fill:y,fontSize:11,children:n.label})]},"ann-"+i)}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const l=o.yAccessor||"y",s=null!==(_=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==_?_:null===(M=o.scales)||void 0===M?void 0:M.time,a=null!==(C=null===(P=o.scales)||void 0===P?void 0:P.y)&&void 0!==C?C:null===(T=o.scales)||void 0===T?void 0:T.value;if(!s||!a)return null;const c=r.map(t=>t[l]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(D=n.threshold)&&void 0!==D?D:2,g=u-f*h,y=!1!==n.showBand,p=n.fill||"#6366f1",v=null!==(E=n.fillOpacity)&&void 0!==E?E:.1,m=n.anomalyColor||"#ef4444",x=null!==(L=n.anomalyRadius)&&void 0!==L?L:6,b=a(u+f*h),k=a(g),w=r.filter(t=>{const e=t[l];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[y&&t("rect",{x:0,y:Math.min(b,k),width:o.width||0,height:Math.abs(k-b),fill:p,fillOpacity:v}),w.map((e,n)=>{const i=Ve(e,o),r=qe(e,o);return null==i||null==r?null:t("circle",{cx:i,cy:r,r:x,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(b,k)-4,textAnchor:"end",fill:p,fontSize:11,children:n.label})]},"ann-"+i)}case"forecast":{const r=o.data||[];if(3>r.length)return null;const l=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==($=null===(O=o.scales)||void 0===O?void 0:O.x)&&void 0!==$?$:null===(N=o.scales)||void 0===N?void 0:N.time,c=null!==(W=null===(I=o.scales)||void 0===I?void 0:I.y)&&void 0!==W?W:null===(z=o.scales)||void 0===z?void 0:z.value;if(!a||!c)return null;const u=r.map(t=>[t[l],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>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=dt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)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 l=(t*o-e*n)/r,s=(n-l*e)/t;d=t=>s+l*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),y=u.reduce((t,e)=>t+e[0],0)/h,p=u.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),v=null!==(Y=n.confidence)&&void 0!==Y?Y:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(R=n.steps)&&void 0!==R?R:5,b=u[h-1][0],k=(b-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(p>0?Math.pow(t-y,2)/p:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${a(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${c(t.yLower)}`).join(" L")} Z`,_=A.map(t=>`${a(t.x)},${c(t.yCenter)}`).join(" "),M=`${a(b)},${c(d(b))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(B=n.fillOpacity)&&void 0!==B?B:.15,stroke:"none"}),t("polyline",{points:`${M} ${_}`,fill:"none",stroke:P,strokeWidth:null!==(j=n.strokeWidth)&&void 0!==j?j:2,strokeDasharray:null!==(H=n.strokeDasharray)&&void 0!==H?H:"6,3"}),n.label&&A.length>0&&t("text",{x:a(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+i)}case"widget":{let e=null,r=null;if(null!=n.px&&null!=n.py)e=n.px,r=n.py;else{const t=Ue(n,i,o);if(!t)return null;e=t.x,r=t.y}if(null==e||null==r)return null;if(!Ke(e,r,o))return null;const l=null!==(X=n.dx)&&void 0!==X?X:0,s=null!==(G=n.dy)&&void 0!==G?G:0,a=null!==(V=n.width)&&void 0!==V?V:32,c=null!==(q=n.height)&&void 0!==q?q:32,u=null!==(U=n.content)&&void 0!==U?U:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+l-a/2,y:r+s-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+i)}case"text":{const e=Ue(n,i,o);if(!e)return null;const{x:r,y:l}=e;return t("text",{x:r+(n.dx||0),y:l+(n.dy||0),fill:n.color||"var(--semiotic-text, #333)",fontSize:n.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label},"ann-text-"+i)}case"category-highlight":{const r=n.category;if(null==r)return null;const l=null===(K=o.scales)||void 0===K?void 0:K.o,s=null===(Q=o.scales)||void 0===Q?void 0:Q.x,a=null===(J=o.scales)||void 0===J?void 0:J.y,c=(null==l?void 0:l.bandwidth)?l:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!c)return null;const u=c(r);if(null==u)return null;const d=c.bandwidth(),h=n.color||"var(--semiotic-primary, #4589ff)",f=null!==(tt=n.opacity)&&void 0!==tt?tt:.15,g=n.label;return e("g",(o.projection?"vertical"===o.projection:c===s)?{children:[t("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&t("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[t("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&t("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+i)}default:return null}},i={scales:y?{x:y.x,y:y.y,time:y.x,value:y.y}:null,timeAxis:"x",xAccessor:W,yAccessor:z,width:c,height:d,data:Y,frameType:"xy",pointNodes:R,curve:B,stickyPositionCache:K.current};return N.map((t,e)=>{if(I){const o=I(t,e,i);return null!=o?o:n(t,e,i)}return n(t,e,i)}).filter(Boolean)},[N,I,c,d,W,z,Y,y,R,B]),et=function(t){var e;const n=u(t?rn:sn,t?on:an,t?on:an);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(H);return l(()=>{if(!(null==et?void 0:et.locked)||!H)return;const t=t=>{"Escape"===t.key&&nn(H)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==et?void 0:et.locked,H]),p||S||_||E||L||tt&&tt.length>0||A||G||et?e("svg",{role:"img",width:h,height:f,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof S?S:"XY Chart"}),t("desc",{children:"string"==typeof S?S+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[A&&y&&!j&&(()=>{var n,i;const o=cn(null===(n=null==v?void 0:v.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=cn(null===(i=null==v?void 0:v.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[V.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:d,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),q.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:c,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),p&&y&&(()=>{const i=null==v?void 0:v.find(t=>"left"===t.orient),o=null==v?void 0:v.find(t=>"bottom"===t.orient),r=!i||!1!==i.baseline,l=!o||!1!==o.baseline,s=(null==i?void 0:i.jaggedBase)||!1,a=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,h=null==i?void 0:i.landmarkTicks,f="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",k=!!(null==o?void 0:o.autoRotate)&&V.length>1&&(()=>{const t=c/Math.max(V.length-1,1),e=V.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})();return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!j&&l&&!a&&t("line",{x1:0,y1:d,x2:c,y2:d,stroke:f,strokeWidth:1}),!j&&a&&t("path",{d:un("bottom",c,d),fill:"none",stroke:f,strokeWidth:1}),V.map((n,i)=>{const o=!!u&&("function"==typeof u?u(n.value,i):ce(n.value,i>0?V[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${d})`,children:[t("line",{y2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:k?10:18,textAnchor:k?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},transform:k?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:n.label})})]},"xtick-"+i)}),m&&t("text",{x:c/2,y:d+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:m}),!j&&r&&!s&&t("line",{x1:0,y1:0,x2:0,y2:d,stroke:f,strokeWidth:1}),!j&&s&&t("path",{d:un("left",c,d),fill:"none",stroke:f,strokeWidth:1}),q.map((n,i)=>{const o=!!h&&("function"==typeof h?h(n.value,i):ce(n.value,i>0?q[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==i?void 0:i.label)||x;return e?t("text",{x:15-g.left,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-g.left}, ${d/2})`,style:{userSelect:"none"},children:e}):null})(),(()=>{const i=null==v?void 0:v.find(t=>"right"===t.orient);if(!i||0===U.length)return null;const o=i.landmarkTicks,r=i.label||b;return e(n,{children:[!1!==i.baseline&&t("line",{x1:c,y1:0,x2:c,y2:d,stroke:f,strokeWidth:1}),U.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):ce(n.value,i>0?U[i-1].value:void 0));return e("g",{transform:`translate(${c},${n.pixel})`,children:[t("line",{x2:5,stroke:f,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:y,style:{userSelect:"none"},children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:c+g.right-15,y:d/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${c+g.right-15}, ${d/2})`,style:{userSelect:"none"},children:r})]})})()]})})(),tt,L&&y&&O&&$&&e(n,{children:[L.top&&t("g",{transform:"translate(0, 0)",children:t(Ye,{orient:"top",config:ze(L.top),values:O,scale:y.x,size:g.top,length:c})}),L.bottom&&t("g",{transform:`translate(0, ${d})`,children:t(Ye,{orient:"bottom",config:ze(L.bottom),values:O,scale:y.x,size:g.bottom,length:c})}),L.left&&t("g",{transform:"translate(0, 0)",children:t(Ye,{orient:"left",config:ze(L.left),values:$,scale:y.y,size:g.left,length:d})}),L.right&&t("g",{transform:`translate(${c}, 0)`,children:t(Ye,{orient:"right",config:ze(L.right),values:$,scale:y.y,size:g.right,length:d})})]}),E,et&&et.sourceId!==X&&(null==y?void 0:y.x)&&(()=>{const e=y.x(et.xValue);if(null==e||0>e||e>c)return null;const n=et.locked;return t("line",{x1:e,y1:0,x2:e,y2:d,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"})})(),G]}),S&&t("text",{x:h/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof S?S:null}),We({legend:_,totalWidth:h,totalHeight:f,margin:g,legendPosition:D,title:S,legendHoverBehavior:M,legendClickBehavior:P,legendHighlightedCategory:C,legendIsolatedCategories:T})]}):null}function yn(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const pn="undefined"==typeof window||"undefined"==typeof document,vn=i.createContext(null);function mn(){return i.useContext(vn)}const xn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function bn(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"],l=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 l)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}function kn(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 wn=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},An={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"},Sn={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},_n={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)"},Mn={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Pn={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)"},Cn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Tn={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Dn({scene:n,chartType:o,tableId:r,chartTitle:l}){var s;const[a,c]=i.useState(!1),u=mn(),d=null!==(s=null==u?void 0:u.visible)&&void 0!==s&&s,h=a||d,f=i.useRef(null),g=l?"Data summary for "+l:r?`Data summary for ${o} ${r}`:"Data summary for "+o,y=i.useCallback(()=>{a||d||c(!0)},[a,d]),p=i.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[d]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:xn}):null;if(!h)return t("div",{id:r,tabIndex:-1,onFocus:y,style:xn,role:"region","aria-label":g,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const v=function(t){var e,n,i,o,r,l,s,a,c,u,d,h,f,g,y,p,v,m,x,b,k,w,A,S,_;const M=[];if(!Array.isArray(t))return M;for(const P of t)if(P&&"object"==typeof P)try{switch(P.type){case"point":M.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;M.push({label:"Bar",values:{category:r,value:null!=l?l:""}});break}case"heatcell":M.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":M.push({label:"Wedge",values:{category:null!==(a=null!==(l=null===(r=P.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:null===(s=P.datum)||void 0===s?void 0:s.label)&&void 0!==a?a:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":M.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(g=P.cy)&&void 0!==g?g:P.y}});break;case"arc":M.push({label:"Arc",values:{id:null!==(p=null===(y=P.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:"",x:null!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m:P.y}});break;case"candlestick":M.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":M.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(_=null===(S=P.datum)||void 0===S?void 0:S.value)&&void 0!==_?_:""}})}}catch(t){}return M}(n),m=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}(v),x=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${wn(t.min)} to ${wn(t.max)}, mean ${wn(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(" ")}(v.length,m),b=v.slice(0,5),k=new Set;for(const t of b)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return e("div",{ref:f,id:r,tabIndex:-1,onBlur:p,style:An,role:"region","aria-label":g,children:[t("button",{type:"button",onClick:()=>{d&&u&&u.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:_n,children:"×"}),t("div",{role:"note",style:Sn,children:x}),e("table",{role:"table","aria-label":"Sample data for "+o,style:Mn,children:[e("caption",{style:Tn,children:["First ",b.length," of ",v.length," data points"]}),t("thead",{children:e("tr",{children:[t("th",{style:Pn,children:"type"}),w.map(e=>t("th",{style:Pn,children:e},e))]})}),t("tbody",{children:b.map((n,i)=>e("tr",{children:[t("td",{style:Cn,children:n.label}),w.map(e=>{return t("td",{style:Cn,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":wn(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]})]})}function En({nodes:n,edges:o,chartType:r,tableId:l,chartTitle:s}){var a,c,u,d,h,f,g,y,p,v,m,x,b,k;const[w,A]=i.useState(!1),S=mn(),_=null!==(a=null==S?void 0:S.visible)&&void 0!==a&&a,M=w||_,P=s?"Data summary for "+s:l?`Data summary for ${r} ${l}`:"Data summary for "+r,C=i.useRef(null),T=i.useCallback(()=>{w||_||A(!0)},[w,_]),D=i.useCallback(t=>{var e;_||(null===(e=C.current)||void 0===e?void 0:e.contains(t.relatedTarget))||A(!1)},[_]);if(!n||0===n.length)return l?t("span",{id:l,tabIndex:-1,style:xn}):null;if(!M)return t("div",{id:l,tabIndex:-1,onFocus:T,style:xn,role:"region","aria-label":P,children:e("button",{type:"button",onClick:()=>A(!0),children:["View data summary (",n.length," nodes, ",o.length," edges)"]})});const E=Array.isArray(n)?n:[],L=Array.isArray(o)?o:[],O=new Map,$=new Map,N=new Map,I=new Map;for(const t of L){if(!t||"object"!=typeof t)continue;const e=null!==(c=t.datum)&&void 0!==c?c:t,n="object"==typeof e.source?null===(u=e.source)||void 0===u?void 0:u.id:e.source,i="object"==typeof e.target?null===(d=e.target)||void 0===d?void 0:d.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";$.set(t,(null!==(h=$.get(t))&&void 0!==h?h:0)+1),I.set(t,(null!==(f=I.get(t))&&void 0!==f?f:0)+o)}if(null!=i&&""!==i){const t=i+"";O.set(t,(null!==(g=O.get(t))&&void 0!==g?g:0)+1),N.set(t,(null!==(y=N.get(t))&&void 0!==y?y:0)+o)}}const W=[];for(let t=0;E.length>t;t++){const e=E[t];if(!e||"object"!=typeof e)continue;const n=null!==(v=null===(p=e.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:e.id,i=null!=n?n+"":"node-"+t,o=null!==(m=O.get(i))&&void 0!==m?m:0,r=null!==(x=$.get(i))&&void 0!==x?x:0,l=null!==(b=N.get(i))&&void 0!==b?b:0,s=null!==(k=I.get(i))&&void 0!==k?k:0;W.push({id:i,degree:o+r,inDeg:o,outDeg:r,wDegree:l+s,wInDeg:l,wOutDeg:s})}W.sort((t,e)=>e.degree-t.degree);let z=0,Y=0;if(W.length>0){let t=0;for(const e of W)t+=e.degree,e.degree>Y&&(Y=e.degree);z=t/W.length}const R=L.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)}),B=[`${W.length} nodes, ${L.length} edges.`];W.length>0&&B.push(`Mean degree: ${wn(z)}, max degree: ${Y}.`);const j=W.slice(0,5);return e("div",{ref:C,id:l,tabIndex:-1,onBlur:D,style:An,role:"region","aria-label":P,children:[t("button",{type:"button",onClick:()=>{_&&S&&S.setVisible(!1),A(!1)},"aria-label":"Close data summary",style:_n,children:"×"}),t("div",{role:"note",style:Sn,children:B.join(" ")}),e("table",{role:"table","aria-label":"Node degree summary for "+r,style:Mn,children:[e("caption",{style:Tn,children:["Top ",j.length," of ",W.length," nodes by degree"]}),t("thead",{children:e("tr",{children:[t("th",{style:Pn,children:"id"}),t("th",{style:Pn,children:"degree"}),t("th",{style:Pn,children:"in"}),t("th",{style:Pn,children:"out"}),R&&t("th",{style:Pn,children:"w. degree"}),R&&t("th",{style:Pn,children:"w. in"}),R&&t("th",{style:Pn,children:"w. out"})]})}),t("tbody",{children:j.map((n,i)=>e("tr",{children:[t("td",{style:Cn,children:n.id}),t("td",{style:Cn,children:n.degree}),t("td",{style:Cn,children:n.inDeg}),t("td",{style:Cn,children:n.outDeg}),R&&t("td",{style:Cn,children:wn(n.wDegree)}),R&&t("td",{style:Cn,children:wn(n.wInDeg)}),R&&t("td",{style:Cn,children:wn(n.wOutDeg)})]},i))})]})]})}function Ln({summary:e}){return e?t("div",{role:"note",style:xn,children:e}):null}function On({tableId:e}){return t("a",{href:"#"+e,style:xn,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,xn)},children:"Skip to data table"})}function $n({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("div",{"aria-live":"polite","aria-atomic":"true",style:xn,children:n})}const Nn="var(--semiotic-focus, #005fcc)";function In({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:l,height:s}){if(!e||!n)return null;const a=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=l&&null!=s){const e=Math.max(l,4),n=Math.max(s,4);u=t("rect",{x:a-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Nn,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:Nn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:Nn,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Wn({x:e,y:n,containerWidth:o,containerHeight:r,margin:l,children:s,className:a="stream-frame-tooltip",zIndex:c=1}){const u=i.useRef(null),[d,h]=i.useState(null);i.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,a,o,r]);let f;return f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,t("div",{ref:u,className:a,style:{position:"absolute",left:l.left+e,top:l.top+n,transform:f,pointerEvents:"none",zIndex:c,width:"max-content"},children:s})}const zn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Yn=new WeakMap;let Rn=0,Bn=!1,jn=null,Fn=null,Hn=null;function Xn(t,e){var n,i;if(!e)return e;const o=zn.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(Bn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Bn=!0;const t=()=>{Rn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(jn=new MutationObserver(t),jn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Fn=window.matchMedia("(prefers-color-scheme: dark)"),Hn=t,"function"==typeof Fn.addEventListener?Fn.addEventListener("change",Hn):"function"==typeof Fn.addListener&&Fn.addListener(Hn)}catch(t){}}();let l=Yn.get(r);l&&l.version===Rn||(l={version:Rn,map:new Map},Yn.set(r,l));const s=l.map.get(e);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return l.map.set(e,a),a}function Gn(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Vn(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return l(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(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=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[s,a]=function(t,e,n){const i=o(null),[r,s]=d(null);return l(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=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 o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),u=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=a[0]-u.left-u.right,f=a[1]-u.top-u.bottom,g=Gn(t.foregroundGraphics,a,u),y=Gn(t.backgroundGraphics,a,u),p=$t(t=>t.theme),{transition:v,introEnabled:m}=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),x="semiotic-table-"+i.useId(),b=o(0),k=o(()=>{}),w=c(()=>{b.current||(b.current=requestAnimationFrame(()=>k.current()))},[]);l(()=>()=>{b.current&&(cancelAnimationFrame(b.current),b.current=0)},[]);const A=o(()=>{}),S=o(()=>{}),_=o(null),M=o(0),P=c(()=>{M.current=0;const t=_.current;_.current=null,t&&A.current(t)},[]),C=c(t=>{_.current={clientX:t.clientX,clientY:t.clientY},0===M.current&&(M.current=requestAnimationFrame(P))},[P]),T=c(()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0),S.current()},[]);l(()=>()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0)},[]);const D=t.themeDirtyRef;return l(()=>{D&&(Rn++,D.current=!0,w())},[p,w,D]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:a,margin:u,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:v,introEnabled:m,tableId:x,rafRef:b,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:C,onPointerLeave:T}}function qn(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,l=e[1]*i,s=e[0]+"px",a=e[1]+"px";return t.style.width!==s&&(t.style.width=s),t.style.height!==a&&(t.style.height=a),t.width===r&&t.height===l||(t.width=r,t.height=l),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function Un(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Kn(t){switch(t){case"monotoneX":return rt;case"monotoneY":return ot;case"cardinal":return J;case"catmullRom":return Q;case"step":return it;case"stepBefore":return et;case"stepAfter":return nt;case"basis":return tt;case"natural":return ct;default:return null}}function Zn(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 Qn(t,e,n,i,o,r){if(2>e.length)return;const l=[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];l.push(l[t-1]+Math.sqrt(n*n+i*i))}const s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(l[n]+l[n+1])/2;let r=o;a>i&&(r*=i/a),a>s-i&&(r*=(s-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 Jn=(t,e,n,i)=>{var o,r;const l=e.filter(t=>"line"===t.type);for(const s of l){if(2>s.path.length)continue;const a=s._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const c=s.style.stroke||"#007bff",u=Xn(t,c)||c,d=s.style.strokeWidth||2,h=s.colorThresholds,f=s.rawValues;if(t.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(t.globalAlpha=s.style.opacity),t.lineWidth=d,t.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const v=null!==(o=s.style.opacity)&&void 0!==o?o:1;Qn(t,s.path,u,d,v,s.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=Kn(s.curve),y=h&&h.length>0&&f&&f.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!y){t.strokeStyle=u;const m=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let x=0;s.path.length-1>x;x++)t.globalAlpha=.5*(p[x]+p[x+1])*m,t.beginPath(),t.moveTo(s.path[x][0],s.path[x][1]),t.lineTo(s.path[x+1][0],s.path[x+1][1]),t.stroke()}else if(y){let b=null,k=null,w=null,A=null,S=!1;function _(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),S=!0}function M(){S&&(t.stroke(),S=!1)}for(let P=0;s.path.length>P;P++){const[C,T]=s.path[P],D=f[P],E=Zn(D,h,u);if(null!==b&&null!==A&&null!==w){if(E===A)t.lineTo(C,T);else{const L=[];for(const O of h){const $=O.value;(w>$||$>D)&&($>w||D>$)||w===$||D===$||L.push({t:($-w)/(D-w)})}L.sort((t,e)=>t.t-e.t);for(const N of L){const I=b+(C-b)*N.t,W=k+(T-k)*N.t,z=Zn(w+(D-w)*Math.min(N.t+1e-4,1),h,u);t.lineTo(I,W),M(),_(z,I,W)}t.lineTo(C,T)}b=C,k=T,w=D,A=E}else _(E,C,T),b=C,k=T,w=D,A=E}M()}else{if(t.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)t.strokeStyle=u;else{const Y=t.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const R of s.strokeGradient.colorStops)Y.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);t.strokeStyle=Y}if(g)at().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[B,j]=s.path[0];t.moveTo(B,j);for(let F=1;s.path.length>F;F++)t.lineTo(s.path[F][0],s.path[F][1])}t.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=s.style.fillOpacity,t.fillStyle=("string"==typeof s.style.fill?Xn(t,s.style.fill):s.style.fill)||s.style.fill,g&&!y)at().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(s.path);else{const[X,G]=s.path[0];t.moveTo(X,G);for(let V=1;s.path.length>V;V++)t.lineTo(s.path[V][0],s.path[V][1])}const H=s.path[0][0];t.lineTo(s.path[s.path.length-1][0],i.height),t.lineTo(H,i.height),t.closePath(),t.fill()}void 0!==a&&1>a&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ti(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 ei(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function ni(t,e,n=.3){ei(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 ii(t,e,n=.6){var i,o,r,l,s;if(!ei(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!==(s=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==s?s: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 oi(t,e,n,i=.35){ei(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ri(t){switch(t){case"monotoneX":return rt;case"monotoneY":return ot;case"cardinal":return J;case"catmullRom":return Q;case"step":return it;case"stepBefore":return et;case"stepAfter":return nt;case"basis":return tt;case"natural":return ct;default:return null}}function li(t,e){const n=ri(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=Z().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 si=(t,e,n,i)=>{var o,r,l;const s=e.filter(t=>"area"===t.type);for(const e of s){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 s=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=s;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=Xn(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 c=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(li(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]=ti(t,"string"==typeof s?s:"#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=c}else{const n=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=n*c,t.fillStyle=s}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(li(t,e),oi(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=c,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=Xn(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=ri(e.curve);if(t.beginPath(),n)at().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}},ai=(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?Xn(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?Xn(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),ii(t,e),t.globalAlpha=1}}finally{t.restore()}}};function ci(t,e,n){const i=e.fillGradient;if(!i)return null;const o=e.roundedEdge;let r=e.x,l=e.y,s=e.x,a=e.y+e.h;if("bottom"===o?(l=e.y+e.h,a=e.y):"right"===o?(r=e.x+e.w,l=e.y,s=e.x,a=e.y):"left"===o&&(r=e.x,l=e.y,s=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,l,s,a);for(const t of e)n.addColorStop(t.offset,t.color);return n}const c=t.createLinearGradient(r,l,s,a),[u,d,h]=ti(t,n);return c.addColorStop(0,`rgba(${u},${d},${h},${i.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${i.bottomOpacity})`),c}const ui=(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)di(t,e);else if(e.roundedTop&&e.roundedTop>0){const n=("string"==typeof e.style.fill?Xn(t,e.style.fill):e.style.fill)||Xn(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?ci(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:l,w:s,h:a}=e;switch(e.roundedEdge){case"right":t.moveTo(r,l),t.lineTo(r+s-o,l),t.arcTo(r+s,l,r+s,l+o,o),t.lineTo(r+s,l+a-o),t.arcTo(r+s,l+a,r+s-o,l+a,o),t.lineTo(r,l+a);break;case"left":t.moveTo(r+s,l),t.lineTo(r+o,l),t.arcTo(r,l,r,l+o,o),t.lineTo(r,l+a-o),t.arcTo(r,l+a,r+o,l+a,o),t.lineTo(r+s,l+a);break;case"bottom":t.moveTo(r,l),t.lineTo(r+s,l),t.lineTo(r+s,l+a-o),t.arcTo(r+s,l+a,r+s-o,l+a,o),t.lineTo(r+o,l+a),t.arcTo(r,l+a,r,l+a-o,o);break;default:t.moveTo(r,l+a),t.lineTo(r,l+o),t.arcTo(r,l,r+o,l,o),t.lineTo(r+s-o,l),t.arcTo(r+s,l,r+s,l+o,o),t.lineTo(r+s,l+a)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=("string"==typeof e.style.fill?Xn(t,e.style.fill):e.style.fill)||Xn(t,"var(--semiotic-primary, #007bff)"),i="string"==typeof n?ci(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=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}ni(t,e),t.globalAlpha=1}};function di(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,l=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,l,i,o,o)}else{const r=o+i,l=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,l,o,o)}t.restore()}function hi(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 fi(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 gi(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const yi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function pi(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`${yi[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${yi[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const vi={line:[si,Jn,ai],area:[si,ai],stackedarea:[si,ai],scatter:[ai],bubble:[ai],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=Xn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),ni(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):gi(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=fi(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}}],bar:[ui],swarm:[ai],waterfall:[(t,e,n,i)=>{var o,r,l;ui(t,e);const s=e.filter(t=>"rect"===t.type);if(2>s.length)return;const a=s[0].datum,c=null==a?void 0:a._connectorStroke;if(c){t.save(),t.strokeStyle=Xn(t,c)||c,t.lineWidth=null!==(o=null==a?void 0:a._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const i=s[e],o=s[e+1];if(!(null===(r=i.datum)||void 0===r?void 0:r.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.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,l;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const s=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(l=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==l?l:1);1!==s&&(t.globalAlpha=s);const a=Xn(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=Xn(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:[si,Jn,ai]},mi={top:20,right:20,bottom:30,left:40},xi={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 bi(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 ki={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 wi({hover:n}){const i=t=>Number.isInteger(t)?t+"":t.toFixed(2);return e("div",{className:"semiotic-tooltip",style:ki,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:i(n.value)}),t("div",{style:{opacity:.7,fontSize:11},children:i(n.time)})]})}const Ai=h(function(n,s){var a,u,h,g,y,p,v,m,x,b,k;const{chartType:w,runtimeMode:A,data:S,chunkThreshold:_,chunkSize:M,xAccessor:P,yAccessor:C,colorAccessor:T,sizeAccessor:D,groupAccessor:E,lineDataAccessor:L,curve:O,normalize:$,binSize:N,valueAccessor:I,arrowOfTime:W="right",windowMode:z="sliding",windowSize:Y=200,timeAccessor:R,xExtent:B,yExtent:j,extentPadding:F=.1,scalePadding:H,sizeRange:X,size:G=[500,300],responsiveWidth:V,responsiveHeight:q,margin:U,className:K,background:Z,lineStyle:Q,pointStyle:J,areaStyle:tt,barStyle:et,waterfallStyle:nt,swarmStyle:it,barColors:ot,colorScheme:rt,boundsAccessor:lt,boundsStyle:st,y0Accessor:at,gradientFill:ct,lineGradient:ut,areaGroups:dt,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,showAxes:vt=!0,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:wt,yFormat:_t,tickFormatTime:Mt,tickFormatValue:Ct,hoverAnnotation:Tt,tooltipContent:Dt,customHoverBehavior:Et,customClickBehavior:Lt,enableHover:Ot,hoverRadius:$t=30,tooltipMode:Nt,annotations:It,svgAnnotationRules:Wt,showGrid:zt,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:Vt,svgPreRenderers:qt,title:Ut,categoryAccessor:Kt,brush:Zt,onBrush:Qt,decay:Jt,pulse:te,transition:ee,animate:ne,staleness:ie,heatmapAggregation:oe,heatmapXBins:le,heatmapYBins:se,showValues:ae,heatmapValueFormat:ce,marginalGraphics:ue,pointIdAccessor:fe,xScaleType:ge,yScaleType:ye,accessibleTable:pe=!0,description:ve,summary:me,linkedCrosshairName:xe,linkedCrosshairSourceId:Se}=n,_e=o(!1),Ce=Vn({sizeProp:G,responsiveWidth:V,responsiveHeight:q,userMargin:U,marginDefault:mi,animate:ne,transitionProp:ee,themeDirtyRef:_e}),{reducedMotionRef:Te,responsiveRef:De,size:Ee,currentTheme:Le,transition:Oe,introEnabled:$e,tableId:Ne,rafRef:Ie,renderFnRef:We,scheduleRender:ze}=Ce;let Ye=Ce.margin;if(ue){const t=60,e=Object.assign({},Ce.margin);ue.top&&t>e.top&&(e.top=t),ue.bottom&&t>e.bottom&&(e.bottom=t),ue.left&&t>e.left&&(e.left=t),ue.right&&t>e.right&&(e.right=t),Ye=e}const Re="function"==typeof Gt?Gt({size:Ee,margin:Ye}):Gt,Be="function"==typeof Xt?Xt({size:Ee,margin:Ye}):Xt,je=Ee[0]-Ye.left-Ye.right,Fe=Ee[1]-Ye.top-Ye.bottom,He=null!=Tt?Tt:Ot,Xe=o(null),Ge=o(null),[Ve,qe]=d(0),[Ue,Ke]=d(null),Ze=o(null),Qe=o(null),[Je,tn]=d(null),en=o(xi.primary),[nn,on]=d(!1),[rn,ln]=d([]),[sn,an]=d([]),cn="streaming"===A||["bar","swarm","waterfall"].includes(w),un=r(()=>{var t,e,n;return{chartType:w,runtimeMode:cn?"streaming":"bounded",windowSize:Y,windowMode:z,arrowOfTime:cn?W:"right",extentPadding:F,scalePadding:H,xAccessor:cn?void 0:P,yAccessor:cn?void 0:C,timeAccessor:cn?R:void 0,valueAccessor:I,colorAccessor:T,sizeAccessor:D,groupAccessor:E||(L?"_lineGroup":void 0),categoryAccessor:Kt,lineDataAccessor:L,xScaleType:ge,yScaleType:ye,xExtent:B,yExtent:j,sizeRange:X,binSize:N,normalize:$,boundsAccessor:lt,boundsStyle:st,y0Accessor:at,gradientFill:!0===ct?{topOpacity:.8,bottomOpacity:.05}:!1===ct?void 0:ct,areaGroups:dt?new Set(dt):void 0,lineGradient:ut,openAccessor:ht,highAccessor:ft,lowAccessor:gt,closeAccessor:yt,candlestickStyle:pt,lineStyle:Q,pointStyle:J,areaStyle:tt,swarmStyle:it,waterfallStyle:nt,colorScheme:rt,barColors:ot,barStyle:et,annotations:It,decay:Jt,pulse:te,transition:Oe,introAnimation:$e,staleness:ie,heatmapAggregation:oe,heatmapXBins:le,heatmapYBins:se,showValues:ae,heatmapValueFormat:ce,pointIdAccessor:fe,curve:O,themeCategorical:null===(t=null==Le?void 0:Le.colors)||void 0===t?void 0:t.categorical,themeSemantic:Pt(Le),themeSequential:null===(e=null==Le?void 0:Le.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Le?void 0:Le.colors)||void 0===n?void 0:n.diverging}},[w,Y,z,W,F,H,P,C,R,I,ge,ye,T,D,E,Kt,L,B,j,X,N,$,lt,st,at,ct,ut,dt,ht,ft,gt,yt,pt,Q,J,tt,it,nt,et,rt,ot,It,Jt,te,null==Oe?void 0:Oe.duration,null==Oe?void 0:Oe.easing,$e,ie,oe,le,se,ae,ce,cn,fe,O,Le]),hn=o(null);hn.current||(hn.current=new re(un)),l(()=>{var t;null===(t=hn.current)||void 0===t||t.updateConfig(un),_e.current=!0,ze()},[un,ze]);const fn=o(null);fn.current||(fn.current=new St(t=>{const e=hn.current;e&&e.ingest(t)&&(_e.current=!0,ze())},{chunkThreshold:_,chunkSize:M})),l(()=>{var t;null===(t=fn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:_,chunkSize:M})},[_,M]);const vn=c(t=>{var e;null===(e=fn.current)||void 0===e||e.push(t)},[]),mn=c(t=>{var e;null===(e=fn.current)||void 0===e||e.pushMany(t)},[]),xn=c(()=>{var t,e;null===(t=fn.current)||void 0===t||t.clear(),null===(e=hn.current)||void 0===e||e.clear(),_e.current=!0,ze()},[ze]);f(s,()=>({push:vn,pushMany:mn,remove:t=>{var e,n,i;null===(e=fn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=hn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(Ze.current&&o.some(t=>{var e;return t===(null===(e=Ze.current)||void 0===e?void 0:e.data)})&&(Ze.current=null,tn(null)),_e.current=!0,ze()),o},update:(t,e)=>{var n,i,o;null===(n=fn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=hn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(_e.current=!0,ze()),r},clear:xn,getData:()=>{var t,e,n;return null===(t=fn.current)||void 0===t||t.flush(),null!==(n=null===(e=hn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=hn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=hn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[vn,mn,xn,ze]),l(()=>{var t,e;if(S){if(L&&S.length>0&&"object"==typeof S[0]&&null!==S[0]){const e="string"==typeof L?L:"coordinates";if(Array.isArray(S[0][e])){const n=[];for(const t of S){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=fn.current)||void 0===t||t.setBoundedData(n))}}null===(e=fn.current)||void 0===e||e.setBoundedData(S)}},[S,L]);const{hoverHandlerRef:kn,hoverLeaveRef:wn,onPointerMove:An,onPointerLeave:Sn}=Ce;kn.current=t=>{if(!He)return;const e=Xe.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ye.left,o=t.clientY-n.top-Ye.top;if(0>i||i>je||0>o||o>Fe)return void(Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&(Et(null),_e.current=!0),ze()));const r=hn.current;if(!r||0===r.scene.length)return;const l=de(r.scene,i,o,$t,r.quadtree,r.maxPointRadius);if(!l)return void(Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&Et(null),ze()));const s=hi(l.datum||{},l.x,l.y);if("multi"===Nt&&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=he(t.path,e,n);if(null===r)continue;const l=be(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][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=he(t.topPath,e,n);if(null===r)continue;const l=be(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][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,l.x,$t),e=r.scales.y.invert,n=r.scales.x.invert;if(t.length>0){const i=n?n(l.x):l.x;s.xValue=i,s.xPx=l.x;const o=en.current;s.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||o,datum:t.datum}))}}Ze.current=s,Qe.current=l.node,tn(s),Et&&(Et(s),_e.current=!0),ze()},wn.current=()=>{Ze.current&&(Ze.current=null,Qe.current=null,tn(null),Et&&(Et(null),_e.current=!0),ze())};const _n=o(()=>{});_n.current=t=>{if(!Lt)return;const e=Xe.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ye.left,o=t.clientY-n.top-Ye.top;if(0>i||i>je||0>o||o>Fe)return void Lt(null);const r=hn.current;if(!r||0===r.scene.length)return void Lt(null);const l=de(r.scene,i,o,$t,r.quadtree,r.maxPointRadius);Lt(l?hi(l.datum||{},l.x,l.y):null)};const Mn=c(t=>_n.current(t),[]),Pn=o(-1),Cn=o(null),Tn=o(null),En=c(t=>{const e=hn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Tn.current&&Tn.current.version===n)i=Tn.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=ke(t),Tn.current={version:n,graph:i}}const o=Pn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Pn.current=0;const e=i.flat[0];Cn.current={shape:e.shape,w:e.w,h:e.h};const n=Me(e);return Ze.current=n,tn(n),Et&&Et(n),void ze()}const r=we(i,o),l=Ae(t.key,r,i);if(null===l)return;if(t.preventDefault(),0>l)return Pn.current=-1,Cn.current=null,Ze.current=null,Qe.current=null,tn(null),Et&&Et(null),void ze();Pn.current=l;const s=i.flat[l];Cn.current={shape:s.shape,w:s.w,h:s.h};const a=Me(s);Ze.current=a,tn(a),Et&&Et(a),ze()},[Et,ze]),Nn=c(t=>{Pn.current=-1,Cn.current=null,An(t)},[An]);We.current=()=>{var t,e;Ie.current=0;const n=Xe.current,i=Ge.current;if(!n||!i)return;const o=hn.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Te.current?r+1e6:r),s=!Te.current&&l,a=_e.current||l;a&&!s&&o.computeScene({width:je,height:Fe});const c=Un(),u=function(t){if(!t)return xi;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(),l=i||e.getPropertyValue("--text-secondary").trim(),s=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return l||s||n||r?{axisStroke:a||xi.axisStroke,tickText:l||xi.tickText,crosshair:l?bi(l,"66"):xi.crosshair,hoverFill:c?bi(c,"4D"):xi.hoverFill,hoverStroke:l?bi(l,"99"):xi.hoverStroke,pointRing:c||xi.pointRing,primary:r||xi.primary}:xi}(n);en.current=u.primary;const d=null!==(t=null==ie?void 0:ie.threshold)&&void 0!==t?t:5e3,h=ie&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(a){const t=qn(n,Ee,Ye,c);if(t){if(t.clearRect(-Ye.left,-Ye.top,Ee[0],Ee[1]),h&&(t.globalAlpha=null!==(e=null==ie?void 0:ie.dimOpacity)&&void 0!==e?e:.5),"transparent"!==Z&&!Xt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=Z||(e&&"transparent"!==e?e:null);i&&(t.fillStyle=i,t.fillRect(-Ye.left,-Ye.top,Ee[0],Ee[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,je,Fe),t.clip()),Vt&&o.scales)for(const e of Vt)t.save(),e(t,o.scene,o.scales,{width:je,height:Fe}),t.restore();const i=vi[w];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:je,height:Fe});t.restore(),h&&(t.globalAlpha=1)}}{const t=qn(i,Ee,Ye,c);if(t&&(t.clearRect(-Ye.left,-Ye.top,Ee[0],Ee[1]),He&&Ze.current&&o.scales&&function(t,e,n,i,o,r,l){var s;if(!1===o.crosshair)return;const a=e.allSeries,c=a&&a.length>0,u=null!==(s=e.xPx)&&void 0!==s?s:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||l.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=l.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||l.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)||l.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,Ze.current,je,Fe,"object"==typeof He?He:{},Qe.current,u),Qe.current&&Array.isArray(Tt))){const e=Tt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const l=n.group;if(void 0!==l)for(const n of e){if("line"!==n.type)continue;if(n.group!==l)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?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,Qe.current,e,u)}}a&&n&&n.setAttribute("aria-label",bn(o.scene,w+" chart"));const f=_e.current;if(_e.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Ue||t(Ue.x.domain()[0])!==t(o.scales.x.domain()[0])||t(Ue.x.domain()[1])!==t(o.scales.x.domain()[1])||t(Ue.y.domain()[0])!==t(o.scales.y.domain()[0])||t(Ue.y.domain()[1])!==t(o.scales.y.domain()[1])||Ue.x.range()[0]!==o.scales.x.range()[0]||Ue.x.range()[1]!==o.scales.x.range()[1]||Ue.y.range()[0]!==o.scales.y.range()[0]||Ue.y.range()[1]!==o.scales.y.range()[1])&&Ke(o.scales),ue){const t=o.getData(),e="function"==typeof P?P:t=>t[P||"x"],n="function"==typeof C?C:t=>t[C||"y"];ln(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&&It&&It.length>0&&qe(t=>t+1),(null==ie?void 0:ie.showBadge)&&on(!!h),(s||null!=o.activeTransition||o.hasActivePulses)&&(Ie.current=requestAnimationFrame(()=>We.current()))},l(()=>(ze(),()=>{var t;null===(t=fn.current)||void 0===t||t.clear()}),[ze]),l(()=>{_e.current=!0,ze()},[w,je,Fe,vt,Z,Q,Vt,ze]),Pe(ie,hn,_e,ze,nn,on);const zn=r(()=>{if(wt||Mt)return;const t=hn.current;return(null==t?void 0:t.xIsDate)&&Ue?pi(Ue.x.domain()):void 0},[wt,Mt,Ue]),Yn=wt||Mt||zn,Rn=He&&Je?Dt?Dt(Je):t(wi,{hover:Je}):null,Bn=Rn?t(Wn,{x:Je.x,y:Je.y,containerWidth:je,containerHeight:Fe,margin:Ye,className:"stream-frame-tooltip",children:Rn}):null,jn=Cn.current,Fn=t(In,{active:Pn.current>=0,hoverPoint:Je,margin:Ye,size:Ee,shape:null==jn?void 0:jn.shape,width:null==jn?void 0:jn.w,height:null==jn?void 0:jn.h}),Hn=(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},Xn=Hn(P,R,"__semiotic_resolvedX","__semiotic_resolvedTime"),Gn=Hn(C,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),Kn=Xn.key,Zn=Gn.key,Qn=It&&It.length>0,Jn=t=>{if(!t||!Qn||!Xn.fn&&!Gn.fn)return t;let e=!1;const n=t.map(t=>{const n=Xn.fn&&Xn.key&&!(Xn.key in t),i=Gn.fn&&Gn.key&&!(Gn.key in t);if(!n&&!i)return t;e=!0;const o=Object.assign({},t);return n&&(o[Xn.key]=Xn.fn(t)),i&&(o[Gn.key]=Gn.fn(t)),o});return e?n:t};if(pn){const n=hn.current;n&&S&&(n.ingest({inserts:S,bounded:!0}),n.computeScene({width:je,height:Fe}));const o=null!==(a=null==n?void 0:n.scene)&&void 0!==a?a:[],r=null!==(u=null==n?void 0:n.scales)&&void 0!==u?u:null,l=Yn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return pi(r.x.domain())})();return e("div",{className:"stream-xy-frame"+(K?" "+K:""),role:"img","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:Ee[0],height:Ee[1]},children:[t(Ln,{summary:me}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${Ye.left},${Ye.top})`,children:Be}),e("g",{transform:`translate(${Ye.left},${Ye.top})`,children:[Z&&t("rect",{x:0,y:0,width:je,height:Fe,fill:Z}),qt&&r&&qt.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:je,height:Fe})},"svgpre-"+n)),o.map((n,i)=>function(n,i){var o,r,l;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const e=n;if(0===e.topPath.length)return null;const l=e.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...e.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:`M${l}L${s}Z`,fill:yn(e.style.fill),fillOpacity:null!==(r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==r?r:.7,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:yn(e.style.fill),opacity:null!==(l=e.style.opacity)&&void 0!==l?l:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:yn(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,l,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]}(o.fill),a=.299*r+.587*l+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),l=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:l,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}(n,i)).filter(Boolean)]})]}),t(gn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:r,showAxes:vt,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:l,yFormat:_t||Ct,showGrid:zt,title:Ut,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,foregroundGraphics:Re,marginalGraphics:ue,xValues:[],yValues:[],annotations:It,svgAnnotationRules:Wt,annotationFrame:0,xAccessor:Kn,yAccessor:Zn,annotationData:Jn(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,linkedCrosshairName:xe,linkedCrosshairSourceId:Se})]})}return e("div",{ref:De,className:"stream-xy-frame"+(K?" "+K:""),role:"group","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),tabIndex:0,style:{position:"relative",width:V?"100%":Ee[0],height:q?"100%":Ee[1],overflow:"visible"},onKeyDown:En,children:[pe&&t(On,{tableId:Ne}),pe&&t(Dn,{scene:null!==(g=null===(h=hn.current)||void 0===h?void 0:h.scene)&&void 0!==g?g:[],chartType:w+" chart",tableId:Ne,chartTitle:"string"==typeof Ut?Ut:void 0}),t(Ln,{summary:me}),e("div",{role:"img","aria-label":ve||("string"==typeof Ut?Ut:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:He?Nn:void 0,onMouseLeave:He?Sn:void 0,onClick:Lt?Mn:void 0,children:[Be&&t("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:t("g",{transform:`translate(${Ye.left},${Ye.top})`,children:Be})}),t(dn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:Ue,showAxes:vt,axes:mt,showGrid:zt,xFormat:Yn,yFormat:_t||Ct}),t("canvas",{ref:Xe,"aria-label":bn(null!==(p=null===(y=hn.current)||void 0===y?void 0:y.scene)&&void 0!==p?p:[],w+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:Ge,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t($n,{hoverPoint:Je}),t(gn,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,scales:Ue,showAxes:vt,axes:mt,xLabel:xt,yLabel:bt,yLabelRight:kt,xFormat:Yn,yFormat:_t||Ct,showGrid:zt,title:Ut,legend:Yt,legendHoverBehavior:Rt,legendClickBehavior:Bt,legendHighlightedCategory:jt,legendIsolatedCategories:Ft,legendPosition:Ht,foregroundGraphics:Re,marginalGraphics:ue,xValues:rn,yValues:sn,annotations:It,svgAnnotationRules:Wt,annotationFrame:Ve,xAccessor:Kn,yAccessor:Zn,annotationData:Jn(null===(v=hn.current)||void 0===v?void 0:v.getData()),pointNodes:null===(m=hn.current)||void 0===m?void 0:m.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0,linkedCrosshairName:xe,linkedCrosshairSourceId:Se}),(Zt||Qt)&&t(At,{width:je,height:Fe,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ye,dimension:null!==(x=null==Zt?void 0:Zt.dimension)&&void 0!==x?x:"xy",scales:Ue,onBrush:null!=Qt?Qt:()=>{},binSize:N,snap:null==Zt?void 0:Zt.snap,binBoundaries:null!==(b=null==Zt?void 0:Zt.binBoundaries)&&void 0!==b?b:"bar"===w?null===(k=hn.current)||void 0===k?void 0:k.getBinBoundaries():void 0,snapDuring:null==Zt?void 0:Zt.snapDuring,streaming:"streaming"===A}),(null==ie?void 0:ie.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ie.badgePosition?{top:4,left:4}:"bottom-left"===ie.badgePosition?{bottom:4,left:4}:"bottom-right"===ie.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:nn?"#dc3545":"#28a745",color:"white"}),children:nn?"STALE":"LIVE"}),Fn,Bn]})]})});Ai.displayName="StreamXYFrame";const Si={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},_i={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Mi{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 l=this.particles[r];if(!l.active)continue;const s=n[l.edgeIndex];if(!s||!s.bezier){l.active=!1,this._freeIndices.push(r);continue}const a=i&&null!==(o=i[l.edgeIndex])&&void 0!==o?o:1;l.t+=t*e*a*(s.bezier.circular?.3:1),1>l.t?Pi(s.bezier,l.t,l.offset,l):(l.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 Pi(t,e,n,i){if(t.circular&&t.segments)return void function(t,e,n,i,o){const r=t.length,l=e*r,s=Math.min(Math.floor(l),r-1),a=l-s,[c,u,d,h]=t[s];Ci(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,l,s]=t.points;Ci(o,r,l,s,e,i);const a=s.x-o.x,c=s.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 Ci(t,e,n,i,o,r){const l=1-o,s=l*l,a=s*l,c=o*o,u=c*o;r.x=a*t.x+3*s*o*e.x+3*l*c*n.x+u*i.x,r.y=a*t.y+3*s*o*e.y+3*l*c*n.y+u*i.y}function Ti(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Di(t,e){var n,i=[],o=[],r=[],l={},s=[];function a(t){r[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],r[e]&&a(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;s[t].length>e;e++)(i=s[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)a(t);else for(e=0;s[t].length>e;e++){var h=l[i=s[t][e]];h||(l[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),l=Array(e),s=Array(e),a=0;e>a;++a)n[a]=-1,i[a]=0,o[a]=!1,r[a]=0,l[a]=-1,s[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>l[y]||s[e].push(l[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(s[x]),m+=s[x].length,l[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,l=0;o.length>l;l++)for(var s=0;o[l].length>s;s++)r>o[l][s]&&(r=o[l][s],n=l);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,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];r[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return i}function Ei(t){return t.y0-t.y1>0?"up":"down"}function Li(t,e){return e(t.source)==e(t.target)}function Oi(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 $i(t){return t.target.x0-t.source.x1}function Ni(t,e){var n=Wi(t),i=$i(e)/Math.tan(n);return"up"==Ei(t)?t.y1-i:t.y1+i}function Ii(t,e){var n=Wi(t),i=$i(e)/Math.tan(n);return"up"==Ei(t)?t.y1+i:t.y1-i}function Wi(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function zi(t,e){return e(t)}function Yi(t){return Bi(t.source)}function Ri(t){return Bi(t.target)}function Bi(t){return(t.y0+t.y1)/2}function ji(t){return t.virtual?0:t.value}function Fi(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Li(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Li(t,e)?i+1:i}),n+i}function Hi(t){return t.target.depth}function Xi(t,e){return t.sourceLinks.length?t.depth:e-1}function Gi(t,e){return t.y0-e.y0}function Vi(t,e){return e.y0-t.y0}function qi(t,e){return t.y1-e.y1}function Ui(t,e){return e.y1-t.y1}function Ki(t,e){return Qi(t.source,e.source)||t.index-e.index}function Zi(t,e){return Qi(t.target,e.target)||t.index-e.index}function Qi(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ji(t,e){return to(t)==to(e)?"bottom"==t.circularLinkType?Vi(t,e):Gi(t,e):to(e)-to(t)}function to(t){return t.target.column-t.source.column}function eo(t,e){return no(t)==no(e)}function no(t){return t.y0-t.y1>0?"up":"down"}function io(t,e,n,i,o){let r=t;var l=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=W(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var a=r.links.filter(function(t){return t.circular});return a.sort(function(t,e){return e.value-t.value}),a.forEach(function(t,e){t._circularStub=e>=4}),oo(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),oo(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,Li(t,e)&&Oi(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 l=t.source.column,a=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==l&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?Vi:Gi);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}),l=t.target.column,(c=r.links.filter(function(t){return t.target.column==l&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?Ui:qi),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=s-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 oo(t,e,n){t.sort(Ji);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(Li(t,e)&&Oi(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var l=0;i.length>l;l++){var s=i[l];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ro(t,s)){var a=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;r=a>r?a:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function ro(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function lo(t){return function(){return t}}function so(t){return t.index}function ao(t){return t.nodes}function co(t){return t.links}function uo(t,e,n){var i=z(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 l=o.length;if(e)o.sort(e);else if(r>0){var s=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+=Bi(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Bi(t.target)*e,i+=e}}),i>0?o/i:NaN);s.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=s.get(t),i=s.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?Fi(e,n)-Fi(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==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Fi(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)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function ho(t,e,n,i,o,r){var l=z(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var s=1,a=r;a>0;--a)c(s*=.99,n),u();function c(e,n){var i=l.length;l.forEach(function(o){var r=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Fi(o,n)>0){var a=B(o.sourceLinks,Ri),c=B(o.targetLinks,Yi),u=a&&c?(a+c)/2:a||c;if(u){var d=(u-Bi(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==i-1&&1==r)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=B(o.sourceLinks,Ri),f=B(o.targetLinks,Yi),g=((h&&f?(h+f)/2:h||f)-Bi(o))*e;o.y0+=g,o.y1+=g}})})}function u(){l.forEach(function(n){var r,l,s,a=t.y0,c=n.length;for(n.sort(e||Qi),s=0;c>s;++s)(l=a-(r=n[s]).y0)>0&&(r.y0+=l,r.y1+=l),a=r.y1+i;if((l=a-i-t.y1)>0)for(a=r.y0-=l,r.y1-=l,s=c-2;s>=0;--s)(l=(r=n[s]).y1+o-a)>0&&(r.y0-=l,r.y1-=l),a=r.y0})}}function fo(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Zi),t.targetLinks.sort(Ki)}),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 go(){var t=0,e=0,n=1,i=1,o=24,r=8,l=null,s=so,a=Xi,c=void 0,u=32,d=2,h=ao,f=co;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.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 j(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=Ti(n,i)),"object"!=typeof o&&(o=t.target=Ti(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,s),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],l=r.source.index,s=r.target.index;i[l]||(i[l]=[]),i[s]||(i[s]=[]),-1===i[l].indexOf(s)&&i[l].push(s)}var a=Di(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++)})}(h,c),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){zi(t,e)!=zi(o.source,e)&&zi(t,e)!=zi(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),Li(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(R(t.sourceLinks,ji),R(t.targetLinks,ji)),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)})})}(h),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 l=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==s?l:l+1,s=e(t)==s?s:e(t),t.column=l})}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})}(h,c,a);var f=r;if(null!==l){var g=z(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=Y(g,function(t){return t.length});y>1&&(f=Math.max(1,(i-e)*l/(y-1)))}(function(t,e,n){var i=z(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=W(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/R(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=Y(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})})(h,f,o),uo(h,c,s),ho(h,c,s,f,f,u),fo(h),io(h,s,d,10,8),uo(h,c,s),ho(h,c,s,f,f,u),fo(h),io(h,s,d,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 zi(n.source,e)==zi(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(!eo(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Ni(e,t);return t.y1-n}if(e.target.column>t.target.column)return Ni(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,l=0;o>r;r++)l+=i[r].width;e.y0=t.y1-l-e.width/2}})})}(h,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return zi(n.target,e)==zi(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(!eo(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Ii(e,t);return t.y0-n}if(e.source.column>t.source.column)return Ii(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,l=0;o>r;r++)l+=i[r].width;e.y1=t.y1-l-e.width/2}})})}(h,s),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=W(e,function(t){return t.y0}),l=Y(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-r);function a(e){return(e-r)/(l-r)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1)}),n.forEach(function(t){t.y0=a(t.y0),t.y1=a(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=a(t.y0)-t.y0;t.y0=a(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})})}}(h),io(h,s,d,10,8)}(g),g}return g.update=function(t){return fo(t),io(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:lo(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:lo(t),g):f},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:lo(t),g):s},g.nodeAlign=function(t){return arguments.length?(a="function"==typeof t?t:lo(t),g):a},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}const yo=t=>{let e,n,i,o,r,l,s,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,l=t.target.x0,s=ht(r,l),a=s(.5),c=s(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${l}L${i},${l}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,s=ht(e,n),i=s(.5),o=s(.5),r=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${l} ${n},${l}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function po(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,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=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+s},${i-n}L${e+s},${i+n}L${e},${i+n}ZM${r},${l-n}L${r-a},${l-n}L${r-a},${l+n}L${r},${l+n}Z`}const r=o.sourceX,l=o.sourceY,s=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},${l-h*n}L${c},${l-h*n}L${c+i},${l-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${s},${a-h*n}L${s},${a+h*n}L${u+i},${a+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${l+h*n}L${r},${l+h*n}Z`}const vo=new Set,mo=new WeakMap;function xo(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=mo.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,mo.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}`;vo.has(t)||(vo.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 bo={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(Hi))-1:0},justify:Xi};function ko(t){return"string"==typeof t?t:t.id}const wo={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,l,s,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!==(l=n.iterations)&&void 0!==l?l: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=go().extent(m).links(v).nodes(p).nodeAlign(bo[h]||Xi).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,l=(null!==(a=null!==(s=i._circularWidth)&&void 0!==s?s:i.width)&&void 0!==a?a:0)/2;t>r.leftFullExtent-l&&(t=r.leftFullExtent-l),r.rightFullExtent+l>e&&(e=r.rightFullExtent+l),n>r.verticalFullExtent-l&&(n=r.verticalFullExtent-l),r.verticalFullExtent+l>o&&(o=r.verticalFullExtent+l)}const r=e-t,l=o-n,u=i[0],d=i[1];if(r>0&&l>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/l),i=-t*e+(u-r*e)/2,o=-n*e+(d-l*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=ko(t.source),n=ko(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=b.get(e),r=b.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,l,s,a,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:A,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const v=[],m=[],x=[],b=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=d?d(xo(e,"nodeStyle")):{},o={fill:i.fill||p.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};b.set(e.id,("string"==typeof o.fill?o.fill:null)||p.get(e.id)||"#4d430c"),v.push("down"===u?{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 k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){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 g?g(t)||o:"target"===g?b.get(i.id)||p.get(i.id)||o:b.get(e.id)||p.get(e.id)||o;const u=h?h(xo(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=u.fill||o;m.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!==(s=u.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),m.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!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.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?po(t):yo(t),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};m.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||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 l,s,a;"down"===u?(l=n.y0+(n.y1-n.y0)/2,s=n.x1+14,a="start"):(i[0]/2>n.x0+t/2?(l=n.x0-6,a="end"):(l=n.x1+6,a="start"),s=n.y0+o/2),x.push({x:l,y:s,text:r+"",anchor:"down"===u?"middle":a,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:x}}},Ao={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,s=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 h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=So(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=_o(t.id),r=o%360*(Math.PI/180),l=10+o%20;t.x=e/i.length+l*Math.cos(r),t.y=n/i.length+l*Math.sin(r)}else{const e=_o(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=s+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=s+t*Math.cos(o),i.y=a+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,y=Mo(n.nodeSize,n.nodeSizeRange,t),p=t=>y(t);if(g>0){const n=ft().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*l:l)}).id(t=>t.id),i=gt().force("charge",yt().strength(t=>-25*p(t))).force("center",pt(s,a).strength(.8)).force("x",vt(s).strength(.15)).force("y",mt(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)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(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 v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,l,s,a,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Mo(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:A,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],v=[],m=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xo(e,"nodeSize")),i=d?d(xo(e,"nodeStyle")):{},s={fill:i.fill||y.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};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:s,datum:e,id:e.id,label:e.id})}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),i="object"==typeof t.target?t.target:x.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=h?h(xo(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};v.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=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||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=f(xo(n,"nodeSize"));m.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}};function So(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 l=null;if(e===t?l=r:r===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function _o(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 Mo(t,e,n){var i,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],l=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===l.length)return()=>r[0];const s=null!==(i=W(l))&&void 0!==i?i:0,a=null!==(o=Y(l))&&void 0!==o?o:1;if(s===a)return()=>(r[0]+r[1])/2;const c=x().domain([s,a]).range(r).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?r[0]:c(i)}}const Po=A,Co={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:l}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);y[n][i]=o}const p=bt().padAngle(o);l&&p.sortGroups(l);const v=p(y),m=v.groups,x=st().innerRadius(a).outerRadius(s);for(const e of m){const n=t[e.index],i=x.centroid(e);n.x=i[0]+c,n.y=i[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),i=b.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.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 v){const n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,i){var o,r,l,s;const{groupWidth:a=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-a,h=i[0]/2,f=i[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Po,m=new Map;t.forEach((t,e)=>{m.set(t.id,v[e%v.length])});const x=xt().radius(d),b=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=g?g(xo(n,"nodeStyle")).fill||m.get(n.id)||v[e%v.length]:m.get(n.id)||v[e%v.length];const l=g?g(xo(n,"nodeStyle")):{},s={fill:r,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};b.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const o=To(i,h,f);let a=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999";if(y)a=y(xo(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===p&&n?a=m.get(n.id)||a:e&&(a=m.get(e.id)||a)}const u=y?y(xo(t,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||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,l=r-Math.PI/2;w.push({x:h+Math.cos(l)*i,y:f+Math.sin(l)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:b,sceneEdges:k,labels:w}}};function To(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 Do=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Eo(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 Lo(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 Oo(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 $o(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Do}function No(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 Io(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 Wo={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const l=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>{var e;return null!==(e=t[a])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},u=H(r,s);u.sum(c),u.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[d,h]=i;switch(l){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=K();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=U();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const l=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(r=e.paddingTop)&&void 0!==r?r:0,a=V().size([n,i]).tile(q).padding(l);s>0&&a.paddingTop(s),a(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;G().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;X().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:Lo(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"===l||"cluster"===l?zo(r,i,n):"treemap"===l||"partition"===l?Yo(r,i):"circlepack"===l&&Ro(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=g.get(t.parent),i=g.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 l,s,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(xo(e,"nodeStyle"));let a=r.fill||No(n);if(n.colorByDepth&&void 0!==e.depth){const t=$o(n);a=t[e.depth%t.length]}const c={fill:a,stroke:r.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.surface)||"#fff",strokeWidth:null!==(s=r.strokeWidth)&&void 0!==s?s: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,l=e.y,s=i.x,a=i.y;m&&(o+=x,l+=b,s+=x,a+=b);const f=Io(o,l,s,a,v),g=r(xo(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=Oo(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,l=n.x,s=n.y;if(m&&(l+=x,s+=b),m){const t=l-x,e=s-b,n=Math.sqrt(t*t+e*e);n>0?(i=l+t/n*10,o=s+e/n*10,r=0>t?"end":"start"):(i=l,o=s-12,r="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=l-k-6,r="end"):(i=l+k+6,r="start"),o=s):(i=l,o=s+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,l,s,a;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,l=n.y1-n.y0;if(0>=t||0>=l)continue;const s=i(xo(n,"nodeStyle"));let a=s.fill||No(e);if(e.colorByDepth&&void 0!==n.depth){const t=$o(e);a=t[n.depth%t.length]}const u={fill:a,stroke:s.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:l,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Oo(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===(l=c.data)||void 0===l?void 0:l.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(xo(c,"nodeStyle")).fill||No(e);if(e.colorByDepth&&void 0!==c.depth){const t=$o(e);g=t[c.depth%t.length]}const y="string"==typeof g?Eo(g):null!==(a=null===(s=e.themeSemantic)||void 0===s?void 0:s.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,l,s,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(xo(n,"nodeStyle"));let c=a.fill||No(e);if(e.colorByDepth&&void 0!==n.depth){const t=$o(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!==(l=a.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.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=Oo(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 l=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let s=i(xo(o,"nodeStyle")).fill||No(e);if(e.colorByDepth&&void 0!==o.depth){const t=$o(e);s=t[o.depth%t.length]}if(l){const n="string"==typeof s?Eo(s):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 zo(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 Yo(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 Ro(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 Bo(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const jo={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,l;const s=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),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=Bo(n);g.metaMap.clear(),i.length=0,o.length=0;const y=new Map;function p(t){var e;const n=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(a(t));i.push({id:b,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,l,u,d,y){const v=s(e);if(!(null==v?void 0:v.length))return;const m=v.length;let x=0,b=0,k=0;for(;m>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let m=0;x>m;m++){const b=c[Math.min(m,c.length-1)],k=v.slice(w,w+b);if(!k.length)break;const A=(m+1)/x,S={id:n,depth:d,data:e,parentId:n},_=y?u/h(S)*A:u*A,M=ut().value(t=>{var e;return(null===(e=s(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=M(k),C=f(S);for(let e=0;k.length>e;e++){const s=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(a(c)),h=r+_*Math.sin(s),f=l+_*Math.cos(s)*C;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:_,angle:s,depth:d,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,h,f,_,d+1,!0)}w+=b}}(t,b,v,m,x,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,l,s,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=Bo(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,l={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 s=o/r*Math.PI*2,a=(o+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(s),y1:e+n*Math.cos(s)*i,x2:t+n*Math.sin(a),y2:e+n*Math.cos(a)*i,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(xo(e,"nodeSize")),i=d?d(xo(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!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:null!==(s=i.opacity)&&void 0!==s?s: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(xo(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=Bo(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=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),s=(("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+s*a*l({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)},Fo={sankey:wo,force:Ao,chord:Co,tree:Wo,cluster:Wo,treemap:Wo,circlepack:Wo,partition:Wo,orbit:jo};function Ho(t){return Fo[t]}class Xo{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({},Si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new Mi(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({},Si),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new Mi(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:l="value"}=this.config,s="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 l?l:t=>{var e;return null!==(e=t[l])&&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=s(e)+"";this.nodes.set(t,Object.assign(Object.assign({},Go(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({},Go(i)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Go(o)),{data:n}));const l=`${i}\0${o}\0${t}`;this.edges.set(l,{source:i,target:o,value:r,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}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 l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,Go(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,Go(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,r=!0);const s=this.edgeKey(e,n),a=this.edges.get(s);let c=!1;return a?(a.value+=i,this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,l),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,o,r,l,s,a;const c=Ho(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 s of u)if(void 0!==s._prevX0){const a=(null!==(e=s._prevX1)&&void 0!==e?e:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(i=s._prevY1)&&void 0!==i?i:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);t.set(s.id,{x:(null!==(r=s._prevX0)&&void 0!==r?r:0)+a/2,y:(null!==(l=s._prevY0)&&void 0!==l?l:0)+c/2})}else 0===s.x&&0===s.y||t.set(s.id,{x:s.x,y:s.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===(s=this.config.transition)||void 0===s?void 0:s.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=Ho(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:l}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=l}get isAnimating(){const t=Ho(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=Ho(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=Vt(t,this.transition),n=Gt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=qt(t._prevX0,t._targetX0,n),t.x1=qt(t._prevX1,t._targetX1,n),t.y0=qt(t._prevY0,t._targetY0,n),t.y1=qt(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=qt(t._prevY0,t._targetY0,n),t.y1=qt(t._prevY1,t._targetY1,n),t.sankeyWidth=qt(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,l=ht(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,l=ht(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.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(!n)throw Error("buildCircularBezier requires 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,l=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+l/3},{x:e.x+2*r/3,y:e.y+2*l/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 l=this.config.pulse;if(!l)return;const s=null!==(e=l.duration)&&void 0!==e?e:500,a=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=l.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;s>o&&(e._pulseIntensity=1-o/s,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,l="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!i||!l)continue;const c=this.edgeTimestamps.get(`${i}\0${l}`);if(!c)continue;const u=t-c;s>u&&(e._pulseIntensity=1-u/s,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 l=o.id;if(!l)continue;const s=r.get(l);if(void 0===s)continue;const a=Ht(n,s,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",l=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const a=i.metric(s);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}),l&&(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,l=[];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){l.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 l.length>0&&this.layoutVersion++,l}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 Go(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 Vo(t,e,n,i,o=30){let r=null,l=o,s=1/0;for(const e of t){const t=qo(e,n,i,o);if(t)if("rect"===e.type){const n=e.w*e.h;s>n&&(r=t,s=n)}else l>t.distance&&(r=t,l=t.distance)}if(r)return r;for(const t of e){const e=Jo(t,n,i);e&&l>e.distance&&(r=e,l=e.distance)}return r}function qo(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,l=Math.sqrt(o*o+r*r);return l>se(t.r,i)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,i);case"rect":return function(t,e,n){const i=le(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 l=ue(Math.atan2(o,i)),s=ue(t.startAngle),a=ue(t.endAngle);if(s>a?l>=s||a>=l:l>=s&&a>=l){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 Uo=null,Ko=null;function Zo(){return Ko||(Uo=document.createElement("canvas"),Uo.width=1,Uo.height=1,Ko=Uo.getContext("2d")),Ko}function Qo(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 Jo(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;const r=Qo(t),l=Zo();if(!r||!l)return null;try{if(l.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,l="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&&l?(r.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const s=l.lineWidth;l.lineWidth=10;const a=l.isPointInStroke(r,e,n);if(l.lineWidth=s,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 l=((e-t.x1)*i+(n-t.y1)*o)/r;l=Math.max(0,Math.min(1,l));const s=t.x1+l*i,a=t.y1+l*o,c=Math.sqrt(Math.pow(e-s,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:s,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;const i=Qo(t),o=Zo();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 l=o.isPointInStroke(i,e,n);if(o.lineWidth=r,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function tr(o){const{width:r,height:l,totalWidth:s,totalHeight:a,margin:c,labels:u,title:d,legend:h,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p,legendPosition:v="right",foregroundGraphics:m,sceneNodes:x,annotations:b,svgAnnotationRules:k}=o;return e(n,{children:[e("svg",{role:"img",width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[t("title",{children:"string"==typeof d?d:"Network Chart"}),t("desc",{children:"string"==typeof d?d+" — network data visualization":"Network data visualization"}),e("g",{transform:`translate(${c.left},${c.top})`,children:[u.map((e,n)=>t("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)),b&&b.filter(t=>"widget"!==t.type).map((e,n)=>{if(k){const o=k(e,n,{width:r,height:l,sceneNodes:x});if(o)return t(i.Fragment,{children:o},"annotation-"+n)}return null}),m]}),d&&"string"==typeof d?t("text",{x:s/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:d}):d?t("foreignObject",{x:0,y:0,width:s,height:c.top,children:d}):null,We({legend:h,totalWidth:s,totalHeight:a,margin:c,legendPosition:v,title:d,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p})]}),null==b?void 0:b.filter(t=>"widget"===t.type&&t.nodeId&&x).map((e,n)=>{var i,o,r,l,s,a,u,d,h;const f=x.find(t=>{var n,i,o,r,l;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===(l=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const g=c.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=c.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!==(s=e.dx)&&void 0!==s?s:0,v=null!==(a=e.dy)&&void 0!==a?a:-16,m=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("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return t("div",{style:{position:"absolute",left:g+p-m/2,top:y+v-b/2,width:m,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}function er(t){return t._cachedPath2D&&t._cachedPath2DSource===t.pathD||(t._cachedPath2D=new Path2D(t.pathD),t._cachedPath2DSource=t.pathD),t._cachedPath2D}function nr(t,e){var n,i,o,r,l,s;if(!e.pathD)return;t.save();const a=er(e);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),r=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,s="string"==typeof e.style.fill?e.style.fill:"#999",a=Xn(t,s)||s;o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=r}else t.fillStyle="string"==typeof e.style.fill&&Xn(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=Xn(t,e.style.stroke)||e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(s=e.style.opacity)&&void 0!==s?s: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 ir(t,e){var n,i;t.save();const o=e.style.stroke||"#999";t.strokeStyle=Xn(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 or(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const l=er(e);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle="string"==typeof e.style.fill&&Xn(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(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xn(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(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function rr(t,e){var n,i;if(!e.pathD)return;t.save();const o=er(e),r=e.style.stroke||"#999";t.strokeStyle=Xn(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&&Xn(t,e.style.fill)||e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}tr.displayName="NetworkSVGOverlay";const lr={top:20,right:80,bottom:20,left:80},sr={top:40,right:40,bottom:40,left:40},ar=new Set(["chord","force","circlepack","orbit"]),cr=[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 dr({data:n}){var i,o,r,l,s,a;if("edge"===n.nodeOrEdge){const t=n.data;return t?e("div",{className:"semiotic-tooltip",style:ur,children:[e("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&e("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const c=n.data;if(!c)return null;const u=c.__hierarchyNode;if(u){const n=[];let s=u;for(;s;){const t=null!==(l=null!==(o=null===(i=s.data)||void 0===i?void 0:i.name)&&void 0!==o?o:null===(r=s.data)||void 0===r?void 0:r.id)&&void 0!==l?l:c.id;null!=t&&n.unshift(t+""),s=s.parent}n.length>1&&n.shift();const a=n.length-1;return e("div",{className:"semiotic-tooltip",style:ur,children:[t("div",{children:n.map((n,i)=>e("span",{children:[i>0&&t("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),i===a?t("strong",{children:n}):t("span",{style:{opacity:.7},children:n})]},i))}),null!=c.value&&c.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const d=((null===(s=c.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=c.targetLinks)||void 0===a?void 0:a.length)||0),h=(c.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(c.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return e("div",{className:"semiotic-tooltip",style:ur,children:[t("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),d>0&&e("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,h!==d&&` (weighted: ${h.toLocaleString()})`]})]})}const hr=h(function(n,i){var s,a,u,h,g,y,p,v,m,x,b,k,w,A,S,_,M;const{chartType:P,nodes:C,edges:T,data:D,initialEdges:E,nodeIDAccessor:L="id",sourceAccessor:O="source",targetAccessor:$="target",valueAccessor:N="value",edgeIdAccessor:I,childrenAccessor:W,hierarchySum:z,orientation:Y="horizontal",nodeAlign:R="justify",nodePaddingRatio:B=.05,nodeWidth:j=15,iterations:F=300,forceStrength:H=.1,padAngle:X=.01,groupWidth:G=20,sortGroups:V,edgeSort:q,treeOrientation:U="vertical",edgeType:K="curve",padding:Z,paddingTop:Q,tensionConfig:J,showParticles:tt=!1,particleStyle:et,nodeStyle:nt,edgeStyle:it,colorBy:ot,colorScheme:rt="category10",edgeColorBy:lt="source",edgeOpacity:at=.5,colorByDepth:ct=!1,nodeSize:ut=8,nodeSizeRange:dt=[5,20],nodeLabel:ht,showLabels:ft=!0,labelMode:gt,size:yt=cr,responsiveWidth:pt,responsiveHeight:vt,margin:mt,className:xt,background:bt,enableHover:kt=!0,tooltipContent:wt,customHoverBehavior:At,customClickBehavior:St,onObservation:_t,chartId:Mt,onTopologyChange:Ct,annotations:Tt,svgAnnotationRules:Dt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,title:Wt,foregroundGraphics:zt,backgroundGraphics:Yt,decay:Rt,pulse:Bt,transition:Ft,animate:Ht,staleness:Xt,thresholds:Gt,accessibleTable:Vt=!0,description:qt,summary:Ut,orbitMode:Kt,orbitSize:Zt,orbitSpeed:Qt,orbitRevolution:Jt,orbitRevolutionStyle:te,orbitEccentricity:ee,orbitShowRings:ne,orbitAnimated:ie}=n,oe=ar.has(P)?sr:lr,re=o(!0),le=Vn({sizeProp:yt,responsiveWidth:pt,responsiveHeight:vt,userMargin:mt,marginDefault:oe,foregroundGraphics:zt,backgroundGraphics:Yt,animate:Ht,transitionProp:Ft,themeDirtyRef:re}),{reducedMotionRef:se,responsiveRef:ae,size:ce,margin:ue,adjustedWidth:de,adjustedHeight:he,resolvedForeground:fe,resolvedBackground:ge,transition:ye,introEnabled:pe,tableId:ve,rafRef:me,renderFnRef:xe,scheduleRender:be,currentTheme:Se}=le,Me=r(()=>Object.assign(Object.assign({},Si),J),[J]),Ce=r(()=>Object.assign(Object.assign({},_i),et),[et]),Te=r(()=>{var t;return{chartType:P,nodeIDAccessor:L,sourceAccessor:O,targetAccessor:$,valueAccessor:N,edgeIdAccessor:I,childrenAccessor:W,hierarchySum:z,orientation:Y,nodeAlign:R,nodePaddingRatio:B,nodeWidth:j,iterations:F,forceStrength:H,padAngle:X,groupWidth:G,sortGroups:V,edgeSort:q,treeOrientation:U,edgeType:K,padding:Z,paddingTop:Q,tensionConfig:Me,showParticles:tt,particleStyle:Ce,nodeStyle:nt,edgeStyle:it,nodeLabel:ht,showLabels:ft,labelMode:gt,colorBy:ot,colorScheme:rt,themeCategorical:null===(t=null==Se?void 0:Se.colors)||void 0===t?void 0:t.categorical,themeSemantic:Pt(Se),edgeColorBy:lt,edgeOpacity:at,colorByDepth:ct,nodeSize:ut,nodeSizeRange:dt,decay:Rt,pulse:Bt,transition:ye,introAnimation:pe,staleness:Xt,thresholds:Gt,orbitMode:Kt,orbitSize:Zt,orbitSpeed:Qt,orbitRevolution:Jt,orbitRevolutionStyle:te,orbitEccentricity:ee,orbitShowRings:ne,orbitAnimated:ie}},[P,L,O,$,N,W,z,Y,R,B,j,F,H,X,G,V,q,U,K,Z,Q,Me,tt,Ce,nt,it,ht,ft,gt,ot,rt,lt,at,ct,ut,dt,Rt,Bt,null==ye?void 0:ye.duration,null==ye?void 0:ye.easing,pe,Xt,Gt,Kt,Zt,Qt,Jt,te,ee,ne,ie,Se]),De=o(null),Ee=o(0),Le=o(null);Le.current||(Le.current=new Xo(Te));const[Oe,$e]=d(null),[Ne,Ie]=d(0),[We,ze]=d(0),[Ye,Re]=d(!1),Be=o(null),je=o(new Map),Fe=o(0),He=c(t=>{if("function"==typeof ot)return ot(t)+"";if("string"==typeof ot&&t.data){const e=t.data[ot];if(void 0!==e){if(!je.current.has(e+"")){const t=Array.isArray(rt)?rt:jt;je.current.set(e+"",t[Fe.current++%t.length])}return je.current.get(e+"")}}if(je.current.has(t.id))return je.current.get(t.id);const e=Array.isArray(rt)?rt:jt,n=ot?e[Fe.current++%e.length]:e[0];return je.current.set(t.id,n),n},[ot,rt]),Xe=(null===(s=null==Se?void 0:Se.colors)||void 0===s?void 0:s.border)||(null===(a=null==Se?void 0:Se.colors)||void 0===a?void 0:a.secondary)||(null===(u=null==Se?void 0:Se.colors)||void 0===u?void 0:u.primary)||"#999",Ge=c(t=>{if("function"==typeof lt)return lt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===lt&&n?He(n):e?He(e):Xe},[lt,He,Xe]),Ve=c(t=>{if(!(null==et?void 0:et.colorBy))return Ge(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Ce.colorBy&&n?He(n):e?He(e):Xe},[null==et?void 0:et.colorBy,Ce.colorBy,He,Ge,Xe]),qe="sankey"===P&&tt||!!Bt||null!==(g=null===(h=Le.current)||void 0===h?void 0:h.isAnimating)&&void 0!==g&&g;l(()=>{var t;null===(t=Le.current)||void 0===t||t.updateConfig(Te),re.current=!0,be()},[Te,be]),l(()=>{var t;const e=Le.current;if(e){e.buildScene([de,he]);for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill);re.current=!0,be()}},[Se,de,he,be]);const Ue=c(()=>{var t;const e=Le.current;if(!e)return;e.runLayout([de,he]),e.buildScene([de,he]),re.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill);const n=Array.isArray(rt)?rt:jt,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];je.current.has(e.id)||je.current.set(e.id,n[t%n.length])}if(Fe.current=i.length,Ie(e.layoutVersion),Ct){const{nodes:t,edges:n}=e.getLayoutData();Ct(t,n)}},[de,he,Ct,rt]),Ke=c(t=>{const e=Le.current;e&&(e.ingestEdge(t)&&Ue(),be())},[Ue,be]),Ze=c(t=>{const e=Le.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&Ue(),be()},[Ue,be]),Qe=c(()=>{var t;null===(t=Le.current)||void 0===t||t.clear(),je.current.clear(),Fe.current=0,Ie(0),$e(null),Be.current=null,re.current=!0,be()},[be]),Je=c(()=>{const t=Le.current;t&&(t.tension+=999,Ue(),be())},[Ue,be]);f(i,()=>({push:Ke,pushMany:Ze,removeNode:t=>{var e,n,i;const o=null!==(n=null===(e=Le.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;if(o){const e=(null===(i=Be.current)||void 0===i?void 0:i.data)?"function"==typeof L?L(Be.current.data):Be.current.data[L]:void 0;Be.current&&"node"===Be.current.nodeOrEdge&&e===t&&(Be.current=null,$e(null)),je.current.delete(t),Ue(),re.current=!0,be()}return o},removeEdge:(t,e)=>{var n,i;const o=null!==(i=null===(n=Le.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==i&&i;if(o){if(Be.current&&"edge"===Be.current.nodeOrEdge){const n=Be.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:!I||!n||("function"==typeof I?I:t=>null==t?void 0:t[I])(n)===t,i&&(Be.current=null,$e(null))}Ue(),re.current=!0,be()}return o},updateNode:(t,e)=>{var n,i;const o=null!==(i=null===(n=Le.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==i?i:null;return o&&(re.current=!0,be()),o},updateEdge:(t,e,n)=>{var i,o;const r=null!==(o=null===(i=Le.current)||void 0===i?void 0:i.updateEdge(t,e,n))&&void 0!==o?o:[];return r.length>0&&(Ue(),re.current=!0,be()),r},clear:Qe,getTopology:()=>{var t,e;return null!==(e=null===(t=Le.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Le.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:Je,getTension:()=>{var t,e;return null!==(e=null===(t=Le.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ke,Ze,Qe,Je,Ue,be]);const tn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),en=tn?D||(Array.isArray(T)?void 0:T):void 0;l(()=>{var t;const e=Le.current;if(e)if(tn&&en)e.ingestHierarchy(en,[de,he]),e.buildScene([de,he]),re.current=!0,be();else{const n=C||[],i=Array.isArray(T)?T:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[de,he]),e.buildScene([de,he]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&je.current.set(n.id,n.style.fill+"");const o=Array.isArray(rt)?rt:jt,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];je.current.has(e.id)||je.current.set(e.id,o[t%o.length])}Fe.current=r.length,re.current=!0,be()}},[C,T,D,en,tn,de,he,Te,be,rt]),l(()=>{E&&E.length>0&&Ze(E)},[]);const nn=c(t=>{if(At&&At(t),_t){const e=Date.now();_t(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[At,_t,Mt]),on=c(t=>{if(St&&St(t),_t){const e=Date.now();_t(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Mt})}},[St,_t,Mt]),{hoverHandlerRef:rn,hoverLeaveRef:ln,onPointerMove:sn,onPointerLeave:an}=le;rn.current=t=>{if(!kt)return;const e=De.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ue.left,o=t.clientY-n.top-ue.top;if(0>i||i>de||0>o||o>he)return void(Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be()));const r=Le.current;if(!r)return;const l=Vo(r.sceneNodes,r.sceneEdges,i,o);if(!l)return void(Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be()));const s=hi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type});Be.current=s,$e(s),nn&&(nn(s),re.current=!0),be()},ln.current=()=>{Be.current&&(Be.current=null,$e(null),nn&&(nn(null),re.current=!0),be())};const cn=o(()=>{});cn.current=t=>{if(!St&&!_t)return;const e=De.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ue.left,o=t.clientY-n.top-ue.top;if(0>i||i>de||0>o||o>he)return;const r=Le.current;if(!r)return;const l=Vo(r.sceneNodes,r.sceneEdges,i,o);on(l?hi(l.datum||{},l.x,l.y,{nodeOrEdge:l.type}):null)};const un=c(t=>cn.current(t),[]),dn=o(-1),hn=o(null),fn=o(-1),gn=c(t=>{var e;const n=Le.current;if(!n)return;const i=function(t){var e,n,i,o,r,l;const s=[];for(const a of t)"circle"===a.type&&null!=a.cx?s.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?s.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&&s.push({x:a.cx,y:a.cy,datum:a.datum,shape:"circle",group:null!==(l=null===(r=a.datum)||void 0===r?void 0:r.id)&&void 0!==l?l:"_default"});return s.sort((t,e)=>t.x-e.x||t.y-e.y),s}(n.sceneNodes);if(0===i.length)return;const o=ke(i),r=dn.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(),dn.current=0,fn.current=-1;const e=o.flat[0];hn.current={shape:e.shape,w:e.w,h:e.h};const n=hi(e.datum||{},e.x,e.y,{nodeOrEdge:"node"});return Be.current=n,$e(n),nn&&(nn(n),re.current=!0),void be()}const l=we(o,r),s=function(t,e,n,i,o){var r,l,s;const a=n.flat[e.flatIndex];if(!a)return Ae(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!==(l=function(t,e,n){let i=null,o=1/0;for(let r=0;t.flat.length>r;r++){const l=t.flat[r];if(l===e)continue;const s=l.x-e.x,a=l.y-e.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(a);break;case"down":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"up":c=0>a&&Math.abs(a)>=Math.abs(s)}if(!c)continue;const u=s*s+a*a;o>u&&(o=u,i=r)}return i}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l: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;const i=t+"",o=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,r=_e(e.source),l=_e(e.target),s=null!=r,a=null!=l;s&&r+""===i&&a?o.push(l+""):a&&l+""===i&&s&&o.push(r+"")}return o}(c,i);if(0===t.length)return e.flatIndex;const r=null!==(s=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==s?s:-1;return 0>r?e.flatIndex:(o.current=-1,r)}default:{const i=Ae(t,e,n);return null!==i&&i!==e.flatIndex&&(o.current=-1),i}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],fn);if(null===s)return;if(t.preventDefault(),0>s)return dn.current=-1,hn.current=null,fn.current=-1,Be.current=null,$e(null),nn&&(nn(null),re.current=!0),void be();dn.current=s;const a=o.flat[s];hn.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"});Be.current=u,$e(u),nn&&(nn(u),re.current=!0),be()},[nn,be]),vn=c(t=>{dn.current=-1,hn.current=null,sn(t)},[sn]);xe.current=()=>{var t,e,n,i,o,r,l;me.current=0;const s=De.current;if(!s)return;const a=s.getContext("2d");if(!a)return;const c=Le.current;if(!c)return;const u=performance.now(),d=Ee.current?Math.min((u-Ee.current)/1e3,.1):.016;Ee.current=u;const h=c.advanceTransition(se.current?u+1e6:u),f=!se.current&&h,g=!se.current&&c.tickAnimation([de,he],d);(h||re.current||g)&&c.buildScene([de,he]);const y=Un();if(!qn(s,ce,ue,y))return;a.clearRect(-ue.left,-ue.top,ce[0],ce[1]),bt&&(a.fillStyle=bt,a.fillRect(0,0,de,he)),Rt&&c.applyDecay(),Bt&&c.applyPulse(u),Gt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Xt?void 0:Xt.threshold)&&void 0!==t?t:5e3,v=Xt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(a.globalAlpha=null!==(e=null==Xt?void 0:Xt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":nr(t,n);break;case"line":ir(t,n);break;case"ribbon":or(t,n);break;case"curved":rr(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&&Xn(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=Xn(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)),ni(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&&Xn(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=Xn(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()),ii(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&&Xn(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=Xn(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),tt&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var o,r;const l=null!==(o=i.spawnRate)&&void 0!==o?o:_i.spawnRate,s=null!==(r=i.maxPerEdge)&&void 0!==r?r:_i.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=s)continue;const r=o.value*l*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)<s;e++)t.spawn(i)}}(c.particlePool,t,d,Ce);const e=.5*(null!==(n=Ce.speedMultiplier)&&void 0!==n?n:1);let i;if(Ce.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,l;const s=null!==(r=i.radius)&&void 0!==r?r:_i.radius,a=null!==(l=i.opacity)&&void 0!==l?l:_i.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const l=e.particles[r];if(!l.active)continue;const a=n[l.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):Xn(t,"var(--semiotic-secondary, #666)")}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(l.x,l.y,s,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(a,c.particlePool,t,Ce,Ve)}}v&&(a.globalAlpha=1);const m=re.current;if(re.current=!1,m||f||g){const t=De.current;t&&t.setAttribute("aria-label",kn(null!==(o=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==o?o:0,null!==(l=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==l?l:0,"Network chart"))}(m||f||g)&&ze(t=>t+1),(qe||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(me.current=requestAnimationFrame(()=>xe.current()))},l(()=>(be(),()=>{}),[be]),l(()=>{re.current=!0,be()},[P,de,he,bt,be]),Pe(Xt,Le,re,be,Ye,Re);const mn=kt&&Oe?t(Wn,{x:Oe.x,y:Oe.y,containerWidth:de,containerHeight:he,margin:ue,className:"stream-network-tooltip",zIndex:2,children:wt?wt(Oe):t(dr,{data:Oe})}):null;if(pn){const n=Le.current;if(n){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),e=t?D||(Array.isArray(T)?void 0:T):void 0;if(t&&e)n.ingestHierarchy(e,[de,he]),n.buildScene([de,he]);else{const t=C||[],e=Array.isArray(T)?T:[];(t.length>0||e.length>0)&&(n.ingestBounded(t,e,[de,he]),n.buildScene([de,he]))}}const i=null!==(y=null==n?void 0:n.sceneNodes)&&void 0!==y?y:[],o=null!==(p=null==n?void 0:n.sceneEdges)&&void 0!==p?p:[],r=null!==(v=null==n?void 0:n.labels)&&void 0!==v?v:[];return e("div",{className:"stream-network-frame"+(xt?" "+xt:""),role:"img","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),style:{position:"relative",width:ce[0],height:ce[1]},children:[t(Ln,{summary:Ut}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:ce[0],height:ce[1],style:{position:"absolute",left:0,top:0},children:[ge&&t("g",{transform:`translate(${ue.left},${ue.top})`,children:ge}),e("g",{transform:`translate(${ue.left},${ue.top})`,children:[bt&&t("rect",{x:0,y:0,width:de,height:he,fill:bt}),o.map((e,n)=>function(e,n){switch(e.type){case"line":return t("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("path",{d:i.pathD,fill:yn(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("path",{d:i.pathD,fill:yn(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("path",{d:i.pathD,fill:yn(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),i.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:yn(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("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:yn(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=st().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)({})||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:yn(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),r.map((e,n)=>function(e,n){return t("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(tr,{width:de,height:he,totalWidth:ce[0],totalHeight:ce[1],margin:ue,labels:r,sceneNodes:i,title:Wt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,foregroundGraphics:fe,annotations:Tt,svgAnnotationRules:Dt,annotationFrame:0})]})}const xn=Le.current;return e("div",{ref:ae,className:"stream-network-frame"+(xt?" "+xt:""),role:"group","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),tabIndex:0,style:{position:"relative",width:pt?"100%":ce[0],height:vt?"100%":ce[1],overflow:"visible"},onKeyDown:gn,children:[Vt&&t(On,{tableId:ve}),Vt&&t(En,{nodes:null!==(m=null==xn?void 0:xn.sceneNodes)&&void 0!==m?m:[],edges:null!==(x=null==xn?void 0:xn.sceneEdges)&&void 0!==x?x:[],chartType:"Network chart",tableId:ve,chartTitle:"string"==typeof Wt?Wt:void 0}),t(Ln,{summary:Ut}),e("div",{role:"img","aria-label":qt||("string"==typeof Wt?Wt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:kt?vn:void 0,onMouseLeave:kt?an:void 0,onClick:St||_t?un:void 0,children:[ge&&t("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ce[0],height:ce[1],pointerEvents:"none",overflow:"visible"},children:t("g",{transform:`translate(${ue.left},${ue.top})`,children:ge})}),t("canvas",{ref:De,"aria-label":kn(null!==(k=null===(b=null==xn?void 0:xn.sceneNodes)||void 0===b?void 0:b.length)&&void 0!==k?k:0,null!==(A=null===(w=null==xn?void 0:xn.sceneEdges)||void 0===w?void 0:w.length)&&void 0!==A?A:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t($n,{hoverPoint:Oe}),t(tr,{width:de,height:he,totalWidth:ce[0],totalHeight:ce[1],margin:ue,labels:(null==xn?void 0:xn.labels)||[],sceneNodes:null==xn?void 0:xn.sceneNodes,title:Wt,legend:Et,legendPosition:Lt,legendHoverBehavior:Ot,legendClickBehavior:$t,legendHighlightedCategory:Nt,legendIsolatedCategories:It,foregroundGraphics:fe,annotations:Tt,svgAnnotationRules:Dt,annotationFrame:We}),t(In,{active:dn.current>=0,hoverPoint:Oe,margin:ue,size:ce,shape:null===(S=hn.current)||void 0===S?void 0:S.shape,width:null===(_=hn.current)||void 0===_?void 0:_.w,height:null===(M=hn.current)||void 0===M?void 0:M.h}),mn,(null==Xt?void 0:Xt.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Xt.badgePosition?{top:4,left:4}:"bottom-left"===Xt.badgePosition?{bottom:4,left:4}:"bottom-right"===Xt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ye?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Ye?"STALE":"LIVE"})]})]})});function fr(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 gr(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}hr.displayName="StreamNetworkFrame";const[yr,pr]=_t(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=gr(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=gr(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}})}})),[vr,mr]=_t(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 xr(t){const e=g(),n=t.clientId||e,{name:i}=t,o=pr(t=>t.selections.get(i)),l=pr(t=>t.setClause),s=pr(t=>t.clearClause),a=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(fr(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:c(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};l(i,{clientId:n,type:"point",fields:e})},[n,i,l]),selectInterval:c(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};l(i,{clientId:n,type:"interval",fields:e})},[n,i,l]),clear:c(()=>{s(i,n)},[s,i,n]),clientId:n}}function br(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function kr({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:s,chartId:a,onClick:u,hoverHighlight:h,colorByField:f}){const y=g(),p=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}(e,n),v=xr({name:(null==t?void 0:t.name)||"__unused__"}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:l}=xr({name:e});return{onHover:c(t=>{if(!t)return void l();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&r(e)},[n,r,l,e]),predicate:i,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||n||[]}),x=mr(t=>t.pushObservation),b=t?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=d(null),A=f||n[0],S=r(()=>{if(!h||null==k||!A)return null;const t=k,e=A;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,k,A]),_=c(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const t=null==e?void 0:e[p.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const i=Qe.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(Qe={positions:new Map(Qe.positions).set(t,{xValue:e,sourceId:n})},tn())}(p.name||"hover",Number(t),y)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&en(p.name||"hover",y),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(h&&A)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[A];w(null!=n?n+"":null)}else w(null);if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),x&&x(t)}}},[e,m,p,y,o,s,a,x,h,A]),M=c(t=>{var e,n,i,r;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[p.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const i=Qe.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(Qe.positions);return e.delete(t),Qe={positions:e},tn(),!1}Qe={positions:new Map(Qe.positions).set(t,{xValue:e,sourceId:n,locked:!0})},tn()}(p.name||"hover",Number(n),y)}if(t&&u){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),u(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(l),x&&x(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),x&&x(t)}}},[u,o,x,s,a,p,y]);return l(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{nn(t,y),en(t,y)}},[null==p?void 0:p.mode,null==p?void 0:p.name,y]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:_,customClickBehavior:M,crosshairSourceId:y}}const wr={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 Ar(t,e,n){var i,o,r,l,s,a,c;const u=wr[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!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!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:Sr(u.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:d}}function Sr(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 _r={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"},Mr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Pr(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},_r),{width:n,height:i}),children:o||"No data available"}):null}function Cr(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))),l=Math.max(6,Math.floor(i/(2.5*o))),s=Math.floor((i-(o*(r+l)-l))/2);return t("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("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Mr),{position:"absolute",top:s+i*(r+l),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:r,opacity:.5+i%2*.2})},i))})}const Tr=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:A="#007bff",strokeWidth:S=2,strokeDasharray:_,opacity:M,background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,transition:z,linkedHover:Y,selection:R,onObservation:B,chartId:j,loading:F,emptyContent:H,emphasis:X,legendPosition:G}=e,V=a.showAxes,q=a.enableHover,U=null!=d?d:a.marginDefaults,K=null!=u?u:[a.width,a.height],Z=null!=C?C:T,Q=o(null),{customHoverBehavior:J}=kr({selection:R,linkedHover:Y,unwrapData:!0,onObservation:B,chartType:"RealtimeLineChart",chartId:j}),tt=c(t=>{D&&D(t),J(t)},[D,J]);f(n,()=>({push:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Q.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Q.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const et=Cr(F,K[0],K[1]),nt=et?null:Pr(v,K[0],K[1],H),it={stroke:A,strokeWidth:S,strokeDasharray:_};return null!=M&&(it.opacity=M),et||nt||t(Ai,{ref:Q,chartType:"line",runtimeMode:"streaming",size:K,margin:U,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:it,showAxes:V,background:P,hoverAnnotation:q,tooltipContent:Z,customHoverBehavior:tt,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,transition:z,pointIdAccessor:e.pointIdAccessor,legendPosition:G})});Tr.displayName="RealtimeLineChart";const Dr=h(function(e,n){var i,l,s,a;const u=Ar(e.mode,{width:null!==(l=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==l?l:e.width,height:null!==(a=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==a?a:e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover}),{binSize:d,size:h,margin:g,className:y,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m=200,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:A,extentPadding:S,categoryAccessor:_,colors:M,fill:P,stroke:C,strokeWidth:T,opacity:D,gap:E,background:L,tooltipContent:O,tooltip:$,onHover:N,annotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:Y,linkedHover:R,selection:B,decay:j,pulse:F,staleness:H,transition:X,onObservation:G,chartId:V,loading:q,emptyContent:U,emphasis:K,legendPosition:Z,brush:Q,onBrush:J,linkedBrush:tt}=e,et=u.showAxes,nt=u.enableHover,it=null!=g?g:u.marginDefaults,ot=null!=h?h:[u.width,u.height],rt=null!=O?O:$,lt=o(null),{customHoverBehavior:st}=kr({selection:B,linkedHover:R,unwrapData:!0,onObservation:G,chartType:"RealtimeTemporalHistogram",chartId:V}),at=c(t=>{N&&N(t),st(t)},[N,st]),ct=!0===Q?{dimension:"x",snap:"bin"}:"x"===Q?{dimension:"x"}:"object"==typeof Q?Q:void 0,ut=(dt=tt)?"string"==typeof dt?{name:dt}:dt:null;var dt;const ht=function(t){const{name:e,xField:n,yField:i}=t,{predicate:o,isActive:l,selectInterval:s,clear:a}=xr({name:e}),u=n&&i?"xyBrush":n?"xBrush":"yBrush",d=c(t=>{if(!t)return void a();const e={};"xyBrush"===u&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),i&&(e[i]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&br(t)?n&&(e[n]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&br(t)&&i&&(e[i]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&s(e)},[u,n,i,s,a]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:o,isActive:l,clear:a}}(Object.assign({name:(null==ut?void 0:ut.name)||"__unused_hist_brush__",xField:(null==ut?void 0:ut.xField)||("string"==typeof b?b:"time")},(null==ut?void 0:ut.yField)?{yField:ut.yField}:{})),ft=o(ht.brushInteraction);ft.current=ht.brushInteraction;const gt=c(t=>{if(J&&J(t),G&&G(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:V}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:V}),ut){const e=ft.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)}},[J,G,V,ut]);f(n,()=>({push:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=lt.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=lt.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=lt.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=lt.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=lt.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const yt=Cr(q,ot[0],ot[1]),pt=yt?null:Pr(x,ot[0],ot[1],U),vt={};return null!=P&&(vt.fill=P),null!=C&&(vt.stroke=C),null!=T&&(vt.strokeWidth=T),null!=D&&(vt.opacity=D),null!=E&&(vt.gap=E),yt||pt||t(Ai,{ref:lt,chartType:"bar",runtimeMode:"streaming",size:ot,margin:it,className:K?`${y||""} semiotic-emphasis-${K}`.trim():y,arrowOfTime:p,windowMode:v,windowSize:m,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:A,extentPadding:S,binSize:d,categoryAccessor:_,barColors:M,barStyle:vt,showAxes:et,background:L,hoverAnnotation:nt,tooltipContent:rt,customHoverBehavior:at,annotations:I,svgAnnotationRules:W,tickFormatTime:z,tickFormatValue:Y,decay:j,pulse:F,staleness:H,transition:X,pointIdAccessor:e.pointIdAccessor,legendPosition:Z,brush:ct||(tt?{dimension:"x"}:void 0),onBrush:ct||tt?gt:void 0})});Dr.displayName="RealtimeTemporalHistogram";const Er=Dr,Lr=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:A,colors:S,radius:_,fill:M,opacity:P,stroke:C,strokeWidth:T,background:D,tooltipContent:E,tooltip:L,onHover:O,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:Y,onObservation:R,chartId:B,loading:j,emptyContent:F,emphasis:H,legendPosition:X}=e,G=a.showAxes,V=a.enableHover,q=null!=d?d:a.marginDefaults,U=null!=u?u:[a.width,a.height],K=null!=E?E:L,Z=o(null),{customHoverBehavior:Q}=kr({selection:Y,linkedHover:z,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:B}),J=c(t=>{O&&O(t),Q(t)},[O,Q]);f(n,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=Cr(j,U[0],U[1]),et=tt?null:Pr(v,U[0],U[1],F),nt={};return null!=_&&(nt.radius=_),null!=M&&(nt.fill=M),null!=P&&(nt.opacity=P),null!=C&&(nt.stroke=C),null!=T&&(nt.strokeWidth=T),tt||et||t(Ai,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:U,margin:q,className:H?`${h||""} semiotic-emphasis-${H}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:A,barColors:S,swarmStyle:nt,showAxes:G,background:D,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:e.pointIdAccessor})});Lr.displayName="RealtimeSwarmChart";const Or=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:A,negativeColor:S,connectorStroke:_,connectorWidth:M,gap:P,stroke:C,strokeWidth:T,opacity:D,background:E,tooltipContent:L,tooltip:O,onHover:$,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,linkedHover:Y,selection:R,onObservation:B,chartId:j,loading:F,emptyContent:H,emphasis:X,legendPosition:G}=e,V=a.showAxes,q=a.enableHover,U=null!=d?d:a.marginDefaults,K=null!=u?u:[a.width,a.height],Z=null!=L?L:O,Q=o(null),{customHoverBehavior:J}=kr({selection:R,linkedHover:Y,unwrapData:!0,onObservation:B,chartType:"RealtimeWaterfallChart",chartId:j}),tt=c(t=>{$&&$(t),J(t)},[$,J]);f(n,()=>({push:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Q.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Q.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Q.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const et=Cr(F,K[0],K[1]),nt=et?null:Pr(v,K[0],K[1],H),it={};return null!=A&&(it.positiveColor=A),null!=S&&(it.negativeColor=S),null!=_&&(it.connectorStroke=_),null!=M&&(it.connectorWidth=M),null!=P&&(it.gap=P),null!=C&&(it.stroke=C),null!=T&&(it.strokeWidth=T),null!=D&&(it.opacity=D),et||nt||t(Ai,{ref:Q,chartType:"waterfall",runtimeMode:"streaming",size:K,margin:U,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:it,showAxes:V,background:E,hoverAnnotation:q,tooltipContent:Z,customHoverBehavior:tt,annotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,legendPosition:G,pointIdAccessor:e.pointIdAccessor})});Or.displayName="RealtimeWaterfallChart";const $r=h(function(e,n){var i,r,l,s;const a=Ar(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(s=null===(l=e.size)||void 0===l?void 0:l[1])&&void 0!==s?s:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:y="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:A,heatmapXBins:S=20,heatmapYBins:_=20,aggregation:M="count",background:P,tooltipContent:C,tooltip:T,onHover:D,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,linkedHover:z,selection:Y,onObservation:R,chartId:B,loading:j,emptyContent:F,emphasis:H,legendPosition:X}=e,G=a.showAxes,V=a.enableHover,q=null!=d?d:a.marginDefaults,U=null!=u?u:[a.width,a.height],K=null!=C?C:T,Z=o(null),{customHoverBehavior:Q}=kr({selection:Y,linkedHover:z,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:B}),J=c(t=>{D&&D(t),Q(t)},[D,Q]);f(n,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,i;return null!==(i=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}));const tt=Cr(j,U[0],U[1]),et=tt?null:Pr(v,U[0],U[1],F);return tt||et||t(Ai,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:q,className:H?`${h||""} semiotic-emphasis-${H}`.trim():h,arrowOfTime:g,windowMode:y,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:A,heatmapXBins:S,heatmapYBins:_,heatmapAggregation:M,showAxes:G,background:P,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:E,svgAnnotationRules:L,tickFormatTime:O,tickFormatValue:$,decay:N,pulse:I,staleness:W,legendPosition:X,pointIdAccessor:e.pointIdAccessor})});$r.displayName="RealtimeHeatmap";export{It as IncrementalExtent,$r as RealtimeHeatmap,Er as RealtimeHistogram,Tr as RealtimeLineChart,Lr as RealtimeSwarmChart,Or as RealtimeWaterfallChart,Nt as RingBuffer,hr as StreamNetworkFrame,Ai as StreamXYFrame};
|