semiotic 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +23 -10
- package/README.md +66 -63
- package/ai/cli.js +34 -21
- package/ai/dist/componentRegistry.js +2 -0
- package/ai/dist/mcp-server.js +54 -0
- package/ai/examples.md +75 -0
- package/ai/schema.json +71 -0
- package/ai/system-prompt.md +3 -0
- package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
- package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
- package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
- package/dist/{charts → components/charts}/index.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/CirclePack.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.d.ts +78 -0
- package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/Treemap.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
- package/dist/{charts → components/charts}/shared/hooks.d.ts +23 -1
- package/dist/components/charts/shared/stringDistance.d.ts +11 -0
- package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +1 -1
- package/dist/{charts → components/charts}/shared/types.d.ts +6 -0
- package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
- package/dist/{charts → components/charts}/xy/AreaChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/Heatmap.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/LineChart.d.ts +26 -0
- package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +8 -0
- package/dist/{export → components/export}/exportChart.d.ts +6 -1
- package/dist/components/semiotic-ai.d.ts +61 -0
- package/dist/components/semiotic-data.d.ts +7 -0
- package/dist/components/semiotic-network.d.ts +14 -0
- package/dist/components/semiotic-ordinal.d.ts +18 -0
- package/dist/components/semiotic-realtime.d.ts +22 -0
- package/dist/components/semiotic-server.d.ts +1 -0
- package/dist/components/semiotic-xy.d.ts +16 -0
- package/dist/components/semiotic.d.ts +57 -0
- package/dist/{server → components/server}/renderToStaticSVG.d.ts +7 -0
- package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +20 -0
- package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +8 -0
- package/dist/{stream → components/stream}/PipelineStore.d.ts +7 -0
- package/dist/{stream → components/stream}/SVGOverlay.d.ts +15 -0
- package/dist/components/stream/SceneToSVG.d.ts +20 -0
- package/dist/components/stream/hitTestUtils.d.ts +23 -0
- package/dist/{stream → components/stream}/networkTypes.d.ts +10 -2
- package/dist/{stream → components/stream}/ordinalTypes.d.ts +16 -10
- package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
- package/dist/{stream → components/stream}/types.d.ts +12 -0
- package/dist/components/stream/useStalenessCheck.d.ts +16 -0
- package/dist/{types → components/types}/legendTypes.d.ts +5 -0
- 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.d.ts +3 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +1 -0
- package/dist/semiotic-ordinal.d.ts +1 -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/canvasMock.d.ts +2 -0
- package/dist/test-utils/canvasMock.d.ts +20 -0
- package/dist/test-utils/frameMock.d.ts +78 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +7 -15
- package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
- /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
- /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
- /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
- /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
- /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
- /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
- /package/dist/{Legend.d.ts → components/Legend.d.ts} +0 -0
- /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
- /package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/colorUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/legendUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
- /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
- /package/dist/{data → components/data}/transforms.d.ts +0 -0
- /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
- /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
- /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/RingBuffer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/types.d.ts +0 -0
- /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
- /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
- /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
- /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
- /package/dist/{store → components/store}/createStore.d.ts +0 -0
- /package/dist/{store → components/store}/useObservation.d.ts +0 -0
- /package/dist/{store → components/store}/useSelection.d.ts +0 -0
- /package/dist/{stream → components/stream}/CanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/DataSourceAdapter.d.ts +0 -0
- /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
- /package/dist/{stream → components/stream}/SceneGraph.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/accessorUtils.d.ts +0 -0
- /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/forceLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/index.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
- /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
- /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
- /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
- /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
- /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
package/dist/realtime.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),r=require("d3-scale"),i=require("d3-array"),o=require("d3-hierarchy"),a=require("d3-interpolate"),l=require("d3-scale-chromatic"),s=require("d3-force"),c=require("d3-chord"),u=require("d3-shape");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const d=h(t),f=5e3;class y{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,f),bounded:!0,totalSize:t.length});let e=f;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+f,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)}push(t){this.callback({inserts:[t],bounded:!1})}pushMany(t){0!==t.length&&this.callback({inserts:t,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class g{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}}}toArray(){const t=[];for(const e of this)t.push(e);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}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 p{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 m(t,e,n,r,i){const o=new Map;for(const a of t){const t=e(a),l=n(a);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))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+=l,i){const t=i(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}return o}function v(t,e,n,r,i,o){const a=[],l=[];for(const i of t){const t=n(i),o=r(i);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||(a.push([e.x(t),e.y(o)]),l.push(o))}return{type:"line",path:a,rawValues:l,style:i,datum:t,group:o}}function x(t,e,n,r,i,o,a,l){const s=[],c=[];for(const o of t){const t=n(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const u=e.x(t);s.push([u,e.y(a)]);const h=l?l(o):i;c.push([u,e.y(h)])}return{type:"area",topPath:s,bottomPath:c,style:o,datum:t,group:a}}function b(t,e,n,r,i,o,a){const l=n(t),s=r(t);if(null==l||null==s||Number.isNaN(l)||Number.isNaN(s))return null;const c={type:"point",x:e.x(l),y:e.y(s),r:i,style:o,datum:t};return void 0!==a&&(c.pointId=a),c}function k(t,e,n,r,i,o,a){return{type:"rect",x:t,y:e,w:n,h:r,style:i,datum:o,group:a}}function w(t,e,n,r,i,o){return{type:"heatcell",x:t,y:e,w:n,h:r,fill:i,datum:o}}function E(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function A(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class S{constructor(t){this.xExtent=new p,this.yExtent=new p,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new g(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=E(t.timeAccessor||t.xAccessor,"time"),this.getY=E(t.valueAccessor||t.yAccessor,"value")):(this.getX=E(t.xAccessor,"x"),this.getY=E(t.yAccessor,"y")),this.getGroup=A(t.groupAccessor),this.getCategory=A(t.categoryAccessor),this.getSize=t.sizeAccessor?E(t.sizeAccessor,"size"):void 0,this.getColor=A(t.colorAccessor),this.getBounds=t.boundsAccessor?E(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?E(t.y0Accessor,"y0"):void 0,this.getPointId=A(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=E(t.openAccessor,"open"),this.getHigh=E(t.highAccessor,"high"),this.getLow=E(t.lowAccessor,"low"),this.getClose=E(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new g(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();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){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,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,a,l;const{config:s,buffer:c}=this;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.xExtent.extent,h=this.yExtent.extent;let d=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:u[0],null!==(n=s.xExtent[1])&&void 0!==n?n:u[1]]:u,f=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 y=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!y&&c.size>0)if(s.normalize)f=[0,1+s.extentPadding];else{const t=c.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);f=[0,r+(r>0?r*s.extentPadding:1)]}else if("bar"===s.chartType&&s.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,r,i){const o=m(t,e,n,r,i);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(c,this.getX,this.getY,s.binSize,this.getCategory);f=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!y&&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;f=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&f[0]!==1/0){if(this.getBounds){const t=c.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}}const t=f[1]-f[0],e=t>0?t*s.extentPadding:1,n=null===(a=s.yExtent)||void 0===a?void 0:a[0],r=null===(l=s.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-e,null!=r?f[1]:f[1]+e]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==s.arrowOfTime)if("x"==("up"===(g=s.arrowOfTime)||"down"===g?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:r.scaleLinear().domain(d).range(e),y:r.scaleLinear().domain(f).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:r.scaleLinear().domain(f).range([0,t.width]),y:r.scaleLinear().domain(d).range(e)}}else this.scales={x:r.scaleLinear().domain(d).range([0,t.width]),y:r.scaleLinear().domain(f).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:r}=this;if(!r||0===n.size)return[];const i=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,t);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,t);case"candlestick":return this.buildCandlestickScene(i,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),r=[],i=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=v(t.data,this.scales,this.getX,this.getY,e,t.key);i&&i.length>0&&(n.colorThresholds=i),r.push(n)}return r}buildAreaScene(t){const e=this.groupData(t),n=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),i=x(t.data,this.scales,this.getX,this.getY,r,e,t.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),n.push(i)}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,r,i,o){var a;const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||l.add(e)}const s=Array.from(l).sort((t,e)=>t-e),c=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)}c.set(e.key,t)}let u;if(o){u=new Map;for(const e of s){let n=0;for(const r of t)n+=(null===(a=c.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,n||1)}}const h=[],d=new Map;for(const t of s)d.set(t,0);for(const n of t){const t=c.get(n.key),r=[],a=[];for(const n of s){let i=t.get(n)||0;const l=d.get(n);o&&(i/=u.get(n));const s=e.x(n);a.push([s,e.y(l)]),r.push([s,e.y(l+i)]),d.set(n,l+i)}h.push({type:"area",topPath:r,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let i=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),n=Math.max(...e);i=e=>t===n?(r[0]+r[1])/2:r[0]+(e-t)/(n-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,n[r%n.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||n;if(i&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const l=this.getPointId?this.getPointId(r)+"":void 0,s=b(r,this.scales,this.getX,this.getY,a,t,l);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=E(this.config.valueAccessor,"value"),i=new Set,o=new Set;for(const e of t)i.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(i).sort((t,e)=>t-e),l=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===l.length)return n;const s=e.width/a.length,c=e.height/l.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,d=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>d&&(d=t);const f=d-h||1;for(let t=0;a.length>t;t++)for(let e=0;l.length>e;e++){const r=u.get(`${a[t]}_${l[e]}`);if(!r)continue;const i=(r.val-h)/f;n.push(w(t*s,(l.length-1-e)*c,s,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,r.datum))}return n}buildStreamingHeatmapScene(t,e){var n,r,i;const o=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,s=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=E(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/a,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),i=Math.min(Math.floor((n-d)/g),l-1);if(0>r||0>i)continue;const o=`${r}_${i}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),m>n&&(m=n),n>v&&(v=n)}const b=v-m||1,k=e.width/a,A=e.height/l;for(const[t,e]of x){const[n,r]=t.split("_"),i=+n,a=+r,s=(e-m)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(w(i*k,(l-1-a)*A,k,A,c,{xi:i,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=m(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],i=new Set(e),o=Array.from(t).filter(t=>!i.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const i=[],o=this.scales,[a,l]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,a),s=Math.min(t.end,l);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(r&&t.categories.size>0){let n=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=o.y(n),s=o.y(n+r);i.push(k(h,Math.min(l,s),d,Math.abs(l-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),n+=r}}else{const e=o.y(0),n=o.y(t.total);i.push(k(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return i}buildSwarmScene(t){var e,n,r,i;const o=[],a=this.config.swarmStyle||{},l=null!==(e=a.radius)&&void 0!==e?e:3,s=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const r=this.scales.x(t),a=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[t])||d}const f={type:"point",x:r,y:a,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,r,i;const o=[],a=this.scales,l=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],r=this.getX(n),i=this.getY(n),g=y+i;let p;p=s.length-1>t?this.getX(s[t+1])-r:t>0?r-this.getX(s[t-1]):0;const m=a.x(r),v=0!==p?a.x(r+p):m+e.width/10,x=Math.min(m,v)+h/2,b=Math.max(m,v)-h/2-x;if(0>=b){y=g;continue}const w=a.y(y),E=a.y(g);o.push(k(x,Math.min(w,E),b,Math.abs(w-E),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],r=this.config.candlestickStyle||{},i=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",l=r.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=r.bodyWidth||6;if(!r.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=r;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:i,downColor:o,wickColor:a,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],r=[];for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)n.push([a,this.scales.y(i+o)]),r.push([a,this.scales.y(i-o)]);else{const t=this.scales.y(i);n.push([a,t]),r.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}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){var n,r,i;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(n=o.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(o.type){case"linear":return a+(1-l/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(i=o.stepThreshold)&&void 0!==i?i:.5*e)>l?1:a;default:return 1}}applyDecay(t,e){var n,r;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,i);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var n;const r=this.config.pulse;if(!r)return 0;const i=null!==(n=r.duration)&&void 0!==n?n:500,o=e-t;return i>o?1-o/i:0}applyPulse(t,e){var n,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=l.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const r=this.computePulseIntensity(n,i);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&n>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeIdentity(e,t);n&&("point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(n,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var n,r,i,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,n,r,i,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let l=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],s=this.getNodeIdentity(a,t);if(!s)continue;const c=this.prevPositionMap.get(s);if(c)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=c.x,a.y=c.y,a.r=null!==(e=c.r)&&void 0!==e?e:a.r,l=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(r=c.h)&&void 0!==r?r:a.h,l=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(i=c.w)&&void 0!==i?i:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}if(n>=1){for(const t of this.scene)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}return this.activeTransition=null,!1}return!0}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}))}resolveLineStyle(t,e){const n=this.config.lineStyle;return"function"==typeof n?n(e||{},t):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:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],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){Object.assign(this.config,t)}}function M(t,e,n){const r=e-t.x,i=n-t.y,o=Math.sqrt(r*r+i*i);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function L(t,e,n){if(0===t.path.length)return null;const r=T(t.path,e);if(0>r)return null;const[i,o]=t.path[r],a=e-i,l=n-o,s=Math.sqrt(a*a+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:i,y:o,distance:s}}function P(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function D(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function $(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,a=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(o*o+a*a)}}return null}function _(t,e,n){if(0===t.topPath.length)return null;const r=T(t.topPath,e);if(0>r)return null;const[i,o]=t.topPath[r],a=e-i,l=n-o;return{node:t,datum:t.datum,x:i,y:o,distance:Math.sqrt(a*a+l*l)}}function T(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 W(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function N(e,n,r){const i=t.useRef(null),[o,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!r)return;const t=i.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,r]),[i,[n&&o?o.w:e[0],r&&o?o.h:e[1]]]}const C={fill:t=>d.createElement("rect",{style:t,width:20,height:20}),line:t=>d.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function O(t,e,n,r){let i;return i="function"==typeof n?n(t):(0,C[n])(r(t,e)),i}function R(t){const{legendGroups:e,customClickBehavior:n,title:r="Legend",width:i=100,height:o=20,orientation:a="vertical"}=t,l="vertical"===a?(({legendGroups:t,width:e,customClickBehavior:n})=>{let r=30;const i=[];return t.forEach((t,o)=>{r+=5,i.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:0,y1:r,x2:e,y2:r})),r+=10,t.label&&(r+=20,i.push(d.createElement("text",{key:"legend-text-"+o,y:r,className:"legend-group-label"},t.label)),r+=10),i.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(0,${r})`},((t,e)=>{const{type:n="fill",styleFn:r,items:i}=t,o=[];let a=0;return i.forEach((t,i)=>{const l=O(t,i,n,r);o.push(d.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${a})`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},l,d.createElement("text",{y:15,x:30},t.label))),a+=25}),o})(t,n))),r+=25*t.items.length+10}),i})({legendGroups:e,width:i,customClickBehavior:n}):(({legendGroups:t,title:e,height:n,customClickBehavior:r})=>{let i=0;const o=[],a=!1===e?10:40;return t.forEach((e,l)=>{e.label&&(o.push(d.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},e.label)),i+=20);const s=((t,e)=>{const{type:n="fill",styleFn:r,items:i}=t,o=[];let a=0;return i.forEach((t,i)=>{const l=O(t,i,n,r);o.push(d.createElement("g",{key:"legend-item-"+i,transform:`translate(${a},0)`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},l,d.createElement("text",{y:15,x:25},t.label))),a+=35,a+=8*t.label.length}),{items:o,offset:a}})(e,r);o.push(d.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${a})`},s.items)),i+=s.offset+5,t[l+1]&&o.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:a-10,x2:i,y2:n+a+10})),i+=15}),d.createElement("g",null,!1!==e&&d.createElement("line",{x1:0,x2:i+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),o)})({legendGroups:e,title:r,height:o,customClickBehavior:n});return d.createElement("g",null,void 0!==r&&d.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:i/2,textAnchor:"horizontal"===a?"start":"middle"},r),l)}function z(t){return"string"==typeof t?{type:t}:t}function I({orient:e,config:n,values:r,scale:o,size:a,length:l}){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}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===r.length)return null;const t=o.domain(),n=a-8;if("boxplot"===s.type){const t=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)],a=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(e[0],r-1.5*a),whiskerHigh:Math.min(e[n-1],o+1.5*a)}}(r);if(!t)return null;const{q1:i,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,f=Math.min(.5*n,20),y=(n-f)/2+4;if(c){const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="top"===e?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+e},d.createElement("line",{x1:c,y1:m+p*(y+f/2),x2:g,y2:m+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-y-f:m+y,width:Math.abs(n-t),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:r,y1:"top"===e?m-y-f:m+y,x2:r,y2:"top"===e?m-y:m+y+f,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="left"===e?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+e},d.createElement("line",{x1:m+p*(y+f/2),y1:c,x2:m+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("rect",{x:"left"===e?m-y-f:m+y,y:Math.min(t,n),width:f,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:"left"===e?m-y-f:m+y,y1:r,x2:"left"===e?m-y:m+y+f,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=i.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,r)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/h*n;if(c){const n=o(t.x0),a=o(t.x1)-o(t.x0);return d.createElement("rect",{key:r,x:n,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(t.x0),a=o(t.x1)-o(t.x0);return d.createElement("rect",{key:r,x:"left"===e?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/h*(n/2),l=o((i.x0+i.x1)/2);r.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=o((a.x0+a.x1)/2);r.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${s}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+e},d.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const t=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${a},${"top"===e?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${a},${r}`),t.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${r},${a}`),t.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+e},d.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,a,l,e,c,4]);return u?d.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function Y(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),o=[];let a="";for(const t of i)a&&a.length+1+t.length>r?(o.push(a),a=t):a=a?`${a} ${t}`:t;return a&&o.push(a),o}function B(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 F(t){const{x:e=0,y:n=0,dx:r,dy:i,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:f,disable:y,events:g={},"data-testid":p}=t,m=new Set(Array.isArray(y)?y:[]);let v=r||0,x=i||0;null!=o&&(v=o-e),null!=a&&(x=a-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===v&&0===x)if(void 0!==c.width){v=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;v=t+(0>t?-5:5),x=c.height/2}return d.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},g),!m.has("connector")&&function(t,e,n,r,i,o){const a=[];let l=0,s=0;if("callout-circle"!==i&&"label"!==i||!(null==o?void 0:o.radius)){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,a=t-i,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;l=i+a*d,s=o+c*d}}}else if("bracket"===i&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);l=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(d.createElement("line",{key:"connector-line",x1:l,y1:s,x2:t,y2:e,stroke:r||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(d.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+i)},${s+n*Math.sin(o+i)}L${l+n*Math.cos(o-i)},${s+n*Math.sin(o-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},a)}(v,x,s,h,b,c),!m.has("subject")&&function(t,e,n,r,i){var o;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.push(d.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,r=(null==e?void 0:e.height)||0;(t>0||r>0)&&a.push(d.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&a.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,o=i||0;if(void 0!==(null==e?void 0:e.x)){const r=(e.x||0)-t;a.push(d.createElement("line",{key:"threshold-line",x1:r,y1:(e.y1||0)-o,x2:r,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const r=(e.y||0)-o;a.push(d.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?a.push(d.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||a.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(d.createElement("path",{key:"bracket-path",d:B((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},a)}(b,c,h,e,n),!m.has("note")&&function(t,e,n,r){if(!t)return d.createElement("g",{className:"annotation-note"});const{label:i,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!i&&!o)return d.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===u?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>e?"end":"start";const y=16,g=o?c?[o]:Y(o,s):[],p=i?c?[i]:Y(i,s):[],m="leftRight"===u?"end"===f?-4:4:0;let v=0;const x=[];g.length>0&&(x.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:f,fontWeight:"bold"},g.map((t,e)=>d.createElement("tspan",{key:e,x:m,dy:0===e?0:y},t)))),v=g.length*y),p.length>0&&x.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:f,y:v},p.map((t,e)=>d.createElement("tspan",{key:e,x:m,dy:0===e?0:y},t))));let b=null;if((o||i)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===f?(e=-t,n=0):"middle"===f&&(e=-t/2,n=t/2),b=d.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(g.length+p.length)*y+(p.length>0?y:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,v,x,h))}function j(t){var e,n;const{noteData:r}=t,{screenCoordinates:i}=r,o="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(e=r.dx)&&void 0!==e?e:0),a=r.ny||i[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),l=i.map((e,n)=>{const i=Object.assign({},r,{note:0===n?r.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return d.createElement(F,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:o}))});return d.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return d.createElement(F,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:a},r,{type:o}))}function X(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 H(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 G(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}function q(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 a="M0,"+r;for(let t=0;o>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${r+4*i}`,a+=`L${Math.min(n,e)},${r}`}return a}{const r="bottom"===t?0:e,i="bottom"===t?1:-1,o=Math.ceil(n/8);let a=`M${r},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${r+4*i},${Math.min(8*t+4,n)}`,a+=`L${r},${Math.min(e,n)}`}return a}}function V(t){return Math.round(100*t)/100+""}function Z(e){const{width:n,height:r,totalWidth:i,totalHeight:a,margin:l,scales:s,showAxes:c,axes:u,xLabel:h,yLabel:f,xFormat:y,yFormat:g,showGrid:p,title:m,legend:v,foregroundGraphics:x,marginalGraphics:b,xValues:k,yValues:w,annotations:E,svgAnnotationRules:A,annotationFrame:S,xAccessor:M,yAccessor:L,annotationData:P,pointNodes:D,children:$}=e,_=t.useMemo(()=>c&&s?s.x.ticks(5).map(t=>({value:t,pixel:s.x(t),label:(y||V)(t)})):[],[c,s,y]),T=t.useMemo(()=>c&&s?s.y.ticks(5).map(t=>({value:t,pixel:s.y(t),label:(g||V)(t)})):[],[c,s,g]),W=t.useMemo(()=>{if(!E||0===E.length)return null;const t=function(t,e,n){var r,i,a,l,s,c,u,h,f,y,g,p,m,v,x,b,k,w,E,A,S,M,L,P,D,$,_,T,W,N,C,O,R,z,I,Y,B,F,q;switch(t.type){case"label":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=X(t,n),i=H(t,n);return null==r||null==i?null:G(r,i,n)?d.createElement(j,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=X(t,n),i=H(t,n);return null==r||null==i?null:G(r,i,n)?d.createElement(j,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=X(t,n);if(null==r)return null;const i=t.color||"#f97316";return d.createElement("g",{key:"ann-"+e},d.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=H(t,n);if(null==r)return null;const i=t.color||"#f97316";return d.createElement("g",{key:"ann-"+e},d.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(t=>({x:X(Object.assign(Object.assign({},t),{type:"point"}),n),y:H(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=o.packEnclose(r),a=t.padding||10;return d.createElement("g",{key:"ann-"+e},d.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&d.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:X(Object.assign(Object.assign({},t),{type:"point"}),n),y:H(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=t.padding||10,o=r.map(t=>t.x),a=r.map(t=>t.y),l=Math.min(...o)-i,s=Math.max(...o)+i,c=Math.min(...a)-i,u=Math.max(...a)+i;return d.createElement("g",{key:"ann-"+e},d.createElement("rect",{x:l,y:c,width:s-l,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&d.createElement("text",{x:(l+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=n.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],o=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+e},i.map((e,r)=>{const i=X(e,n),a=H(e,n);return null==i||null==a?null:d.createElement("circle",Object.assign({key:r,cx:i,cy:a,r:t.r||6},o))}))}case"bracket":{const r=X(t,n),i=H(t,n);return d.createElement(j,{key:"ann-"+e,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const o=n.data||[];if(2>o.length)return null;const h=n.xAccessor||"x",f=n.yAccessor||"y",y=o.map(t=>[t[h],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(i=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=n.scales)||void 0===a?void 0:a.time,p=null!==(s=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==s?s:null===(c=n.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const m=t.method||"linear";let v;if("loess"===m)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]),a=Math.max(2,Math.ceil(e*n)),l=[];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(a-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,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*i[t],d+=e*o[t],f+=e*i[t]*i[t],y+=e*i[t]*o[t])}if(0===u){l.push([e,o[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([e,d/u]);else{const t=(u*y-h*d)/g;l.push([e,(d-t*h)/u+t*e])}}return l}(y,null!==(u=t.bandwidth)&&void 0!==u?u:.3);else{let e;try{const n=require("regression");e="polynomial"===m?n.polynomial(y,{order:t.order||2}):n.linear(y)}catch(t){return null}v=e.points}const x=v.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=t.color||"#6366f1";return d.createElement("g",{key:"ann-"+e},d.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:g(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:b,fontSize:11},t.label))}case"band":{const r=null!==(f=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,i=null!==(g=null==r?void 0:r(t.y0))&&void 0!==g?g:0,o=null!==(p=null==r?void 0:r(t.y1))&&void 0!==p?p:n.height||0;return d.createElement("g",{key:"ann-"+e},d.createElement("rect",{x:0,y:Math.min(i,o),width:n.width||0,height:Math.abs(o-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(i,o)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const i=n.xAccessor||"x",o=null!==(v=null===(m=n.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(x=n.scales)||void 0===x?void 0:x.time,a=null!==(k=null===(b=n.scales)||void 0===b?void 0:b.y)&&void 0!==k?k:null===(w=n.scales)||void 0===w?void 0:w.value;if(!o||!a)return null;const l=t.upperAccessor||"upperBounds",s=t.lowerAccessor||"lowerBounds",c=t.filter,u=r.filter(t=>null!=t[l]&&null!=t[s]&&!(c&&!c(t))).sort((t,e)=>t[i]-e[i]);if(2>u.length)return null;const h=u.map(t=>`${o(t[i])},${a(t[l])}`).join(" L"),f=u.slice().reverse().map(t=>`${o(t[i])},${a(t[s])}`).join(" L"),y=t.fill||"#6366f1";return d.createElement("g",{key:"ann-"+e},d.createElement("path",{d:`M${h} L${f} Z`,fill:y,fillOpacity:null!==(E=t.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),t.label&&u.length>0&&d.createElement("text",{x:o(u[u.length-1][i])+4,y:a(u[u.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const i=n.yAccessor||"y",o=null!==(S=null===(A=n.scales)||void 0===A?void 0:A.x)&&void 0!==S?S:null===(M=n.scales)||void 0===M?void 0:M.time,a=null!==(P=null===(L=n.scales)||void 0===L?void 0:L.y)&&void 0!==P?P:null===(D=n.scales)||void 0===D?void 0:D.value;if(!o||!a)return null;const l=r.map(t=>t[i]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),h=null!==($=t.threshold)&&void 0!==$?$:2,f=s-h*u,y=!1!==t.showBand,g=t.fill||"#6366f1",p=null!==(_=t.fillOpacity)&&void 0!==_?_:.1,m=t.anomalyColor||"#ef4444",v=null!==(T=t.anomalyRadius)&&void 0!==T?T:6,x=a(s+h*u),b=a(f),k=r.filter(t=>{const e=t[i];return null!=e&&Math.abs(e-s)>h*u});return d.createElement("g",{key:"ann-"+e},y&&d.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((t,e)=>{const r=X(t,n),i=H(t,n);return null==r||null==i?null:d.createElement("circle",{key:e,cx:r,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},t.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(N=null===(W=n.scales)||void 0===W?void 0:W.x)&&void 0!==N?N:null===(C=n.scales)||void 0===C?void 0:C.time,l=null!==(R=null===(O=n.scales)||void 0===O?void 0:O.y)&&void 0!==R?R:null===(z=n.scales)||void 0===z?void 0:z.value;if(!a||!l)return null;const s=r.map(t=>[t[i],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}catch(t){return null}else{const t=s.length;let e=0,n=0,r=0,i=0;for(const[t,o]of s)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 a=(t*i-e*n)/o,l=(n-a*e)/t;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(u-2,1)),y=s.reduce((t,e)=>t+e[0],0)/u,g=s.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(I=t.confidence)&&void 0!==I?I:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(Y=t.steps)&&void 0!==Y?Y:5,x=s[u-1][0],b=(x-s[0][0])/Math.max(u-1,1),k=[];for(let t=1;v>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=c(t),n=f*Math.sqrt(1+1/u+(g>0?Math.pow(t-y,2)/g:0))*m;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const E=`M${w.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),S=`${a(x)},${l(c(x))}`,M=t.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+e},d.createElement("path",{d:E,fill:t.fill||"#6366f1",fillOpacity:null!==(B=t.fillOpacity)&&void 0!==B?B:.15,stroke:"none"}),d.createElement("polyline",{points:`${S} ${A}`,fill:"none",stroke:M,strokeWidth:null!==(F=t.strokeWidth)&&void 0!==F?F:2,strokeDasharray:null!==(q=t.strokeDasharray)&&void 0!==q?q:"6,3"}),t.label&&w.length>0&&d.createElement("text",{x:a(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:M,fontSize:11},t.label))}default:return null}},e={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:M,yAccessor:L,width:n,height:r,data:P,frameType:"xy",pointNodes:D};return E.map((n,r)=>{if(A){const i=A(n,r,e);return null!=i?i:t(n,r,e)}return t(n,r,e)}).filter(Boolean)},[E,A,n,r,S,M,L,P]);return c||m||v||x||b||W&&W.length>0||p||$?d.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&s&&d.createElement("g",{className:"stream-grid"},_.map((t,e)=>d.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),T.map((t,e)=>d.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&s&&(()=>{const t=null==u?void 0:u.find(t=>"left"===t.orient),e=null==u?void 0:u.find(t=>"bottom"===t.orient),i=!t||!1!==t.baseline,o=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,s="var(--semiotic-border, #ccc)",c="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},(!e||!1!==e.baseline)&&!a&&d.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:s,strokeWidth:1}),a&&d.createElement("path",{d:q("bottom",n,r),fill:"none",stroke:s,strokeWidth:1}),_.map((t,e)=>d.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${r})`},d.createElement("line",{y2:5,stroke:s,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:c,style:{userSelect:"none"}},t.label))),h&&d.createElement("text",{x:n/2,y:r+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},h),i&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:s,strokeWidth:1}),o&&d.createElement("path",{d:q("left",n,r),fill:"none",stroke:s,strokeWidth:1}),T.map((t,e)=>d.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},d.createElement("line",{x2:-5,stroke:s,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:c,style:{userSelect:"none"}},t.label))),f&&d.createElement("text",{x:15-l.left,y:r/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${r/2})`,style:{userSelect:"none"}},f))})(),W,b&&s&&k&&w&&d.createElement(d.Fragment,null,b.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(I,{orient:"top",config:z(b.top),values:k,scale:s.x,size:l.top,length:n})),b.bottom&&d.createElement("g",{transform:`translate(0, ${r})`},d.createElement(I,{orient:"bottom",config:z(b.bottom),values:k,scale:s.x,size:l.bottom,length:n})),b.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(I,{orient:"left",config:z(b.left),values:w,scale:s.y,size:l.left,length:r})),b.right&&d.createElement("g",{transform:`translate(${n}, 0)`},d.createElement(I,{orient:"right",config:z(b.right),values:w,scale:s.y,size:l.right,length:r}))),x,$),m&&d.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof m?m:null),v&&d.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},function(t){return"object"==typeof t&&null!==t&&!d.isValidElement(t)&&"legendGroups"in t}(v)?d.createElement(R,{legendGroups:v.legendGroups,title:"",width:100}):v)):null}function K(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 U(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]}const Q=(t,e,n,r)=>{var i;const o=e.filter(t=>"area"===t.type);for(const e of o){if(2>e.topPath.length)continue;t.beginPath();const[n,r]=e.topPath[0];t.moveTo(n,r);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();const o=e.style.fill||"#4e79a7";if(e.fillGradient){const n=Math.min(...e.topPath.map(t=>t[1])),r=Math.max(...e.bottomPath.map(t=>t[1])),i=t.createLinearGradient(0,n,0,r);i.addColorStop(0,o),i.addColorStop(1,o),t.fillStyle=i;const a=U(o),l=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,n,0,r);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${l})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${s})`),t.fillStyle=c,t.globalAlpha=1}else{const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.globalAlpha=n,t.fillStyle=o}if(t.fill(),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=1,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]),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]);t.stroke()}t.globalAlpha=1}},J=(t,e,n,r)=>{var i,o;const a=e.filter(t=>"point"===t.type);for(const e of a){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;if(null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.x,e.y,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},tt=(t,e,n,r)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?et(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1};function et(t,e){const n=e.style.icon,r=e.style.iconPadding||2,i=Math.min(e.w,e.w)-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,a=e.x+(e.w-i)/2;for(let r=e.y+e.h-i;r>=e.y-i;r-=o)t.drawImage(n,a,r,i,i)}else{const o=i+r,a=e.y+(e.h-i)/2;for(let r=e.x;e.x+e.w>r;r+=o)t.drawImage(n,r,a,i,i)}t.restore()}const nt={line:[Q,(t,e,n,r)=>{const i=e.filter(t=>"line"===t.type);for(const o of i){if(2>o.path.length)continue;const a=o.style.stroke||"#007bff",l=o.style.strokeWidth||2,s=o.colorThresholds,c=o.rawValues;if(t.setLineDash(o.style.strokeDasharray?o.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=o.style.opacity&&(t.globalAlpha=o.style.opacity),t.lineWidth=l,s&&0!==s.length&&c&&c.length===o.path.length){let u=null,h=null,d=null,f=null,y=!1;function g(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),y=!0}function p(){y&&(t.stroke(),y=!1)}for(let m=0;o.path.length>m;m++){const[v,x]=o.path[m],b=c[m],k=K(b,s,a);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(v,x);else{const w=[];for(const E of s){const A=E.value;(d>A||A>b)&&(A>d||b>A)||d===A||b===A||w.push({t:(A-d)/(b-d)})}w.sort((t,e)=>t.t-e.t);for(const S of w){const M=u+(v-u)*S.t,L=h+(x-h)*S.t,P=K(d+(b-d)*Math.min(S.t+1e-4,1),s,a);t.lineTo(M,L),p(),g(P,M,L)}t.lineTo(v,x)}u=v,h=x,d=b,f=k}else g(k,v,x),u=v,h=x,d=b,f=k}p()}else{t.beginPath(),t.strokeStyle=a;const[D,$]=o.path[0];t.moveTo(D,$);for(let _=1;o.path.length>_;_++)t.lineTo(o.path[_][0],o.path[_][1]);t.stroke()}if(o.style.fill&&o.style.fillOpacity&&o.style.fillOpacity>0){t.beginPath(),t.globalAlpha=o.style.fillOpacity,t.fillStyle=o.style.fill;const[T,W]=o.path[0];t.moveTo(T,W);for(let C=1;o.path.length>C;C++)t.lineTo(o.path[C][0],o.path[C][1]);const N=o.path[0][0];t.lineTo(o.path[o.path.length-1][0],r.height),t.lineTo(N,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[Q],stackedarea:[Q],scatter:[J],bubble:[J],heatmap:[(t,e,n,r)=>{const i=e.filter(t=>"heatcell"===t.type);for(const e of i){const n=e.style;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),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1}}],bar:[tt],swarm:[J],waterfall:[(t,e,n,r)=>{var i,o,a;tt(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const s=l[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;l.length-1>e;e++){const r=l[e],i=l[e+1];if(!(null===(o=r.datum)||void 0===o?void 0:o.cumEnd)||!(null===(a=i.datum)||void 0===a?void 0:a.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.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const r=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1))}}]},rt={top:20,right:20,bottom:30,left:40},it={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"},ot={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 at({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:ot},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function lt({width:r,height:i,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),f=t.useRef(null);return t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[r,i]]),o.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let e,n;if("x"===s){const[r,o]=t.selection;e=[c.x.invert(r),c.x.invert(o)],n=[c.y.invert(i),c.y.invert(0)]}else if("y"===s){const[i,o]=t.selection;e=[c.x.invert(0),c.x.invert(r)],n=[c.y.invert(o),c.y.invert(i)]}else{const[[r,i],[o,a]]=t.selection;e=[c.x.invert(r),c.x.invert(o)],n=[c.y.invert(a),c.y.invert(i)]}u({x:e,y:n})}),t.call(o),f.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),f.current=null}},[r,i,s,c,u]),d.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const st=t.forwardRef(function(e,n){var r,i,o;const{chartType:a,runtimeMode:l,data:s,xAccessor:c,yAccessor:u,colorAccessor:h,sizeAccessor:f,groupAccessor:g,lineDataAccessor:p,normalize:m,binSize:v,valueAccessor:x,arrowOfTime:b="right",windowMode:k="sliding",windowSize:w=200,timeAccessor:E,xExtent:A,yExtent:T,extentPadding:C=.1,sizeRange:O,size:R=[500,300],responsiveWidth:z,responsiveHeight:I,margin:Y,className:B,background:F,lineStyle:j,pointStyle:X,areaStyle:H,waterfallStyle:G,swarmStyle:q,barColors:V,colorScheme:K,boundsAccessor:U,boundsStyle:Q,y0Accessor:J,gradientFill:tt,openAccessor:et,highAccessor:ot,lowAccessor:st,closeAccessor:ct,candlestickStyle:ut,showAxes:ht=!0,axes:dt,xLabel:ft,yLabel:yt,xFormat:gt,yFormat:pt,tickFormatTime:mt,tickFormatValue:vt,hoverAnnotation:xt,tooltipContent:bt,customHoverBehavior:kt,enableHover:wt,annotations:Et,svgAnnotationRules:At,showGrid:St,legend:Mt,backgroundGraphics:Lt,foregroundGraphics:Pt,title:Dt,categoryAccessor:$t,brush:_t,onBrush:Tt,decay:Wt,pulse:Nt,transition:Ct,staleness:Ot,heatmapAggregation:Rt,heatmapXBins:zt,heatmapYBins:It,marginalGraphics:Yt,pointIdAccessor:Bt}=e,[Ft,jt]=N(R,z,I),Xt=Object.assign(Object.assign({},rt),Y);if(Yt){const t=60;Yt.top&&t>Xt.top&&(Xt.top=t),Yt.bottom&&t>Xt.bottom&&(Xt.bottom=t),Yt.left&&t>Xt.left&&(Xt.left=t),Yt.right&&t>Xt.right&&(Xt.right=t)}const Ht=jt[0]-Xt.left-Xt.right,Gt=jt[1]-Xt.top-Xt.bottom,qt=null!=xt?xt:wt,Vt=t.useRef(null),Zt=t.useRef(0),Kt=t.useRef(!1),[Ut,Qt]=t.useState(0),[Jt,te]=t.useState(null),ee=t.useRef(null),ne=t.useRef(null),[re,ie]=t.useState(null),[oe,ae]=t.useState(!1),[le,se]=t.useState([]),[ce,ue]=t.useState([]),he=t.useRef(()=>{}),de="streaming"===l||["bar","swarm","waterfall"].includes(a),fe=t.useMemo(()=>({chartType:a,runtimeMode:de?"streaming":"bounded",windowSize:w,windowMode:k,arrowOfTime:de?b:"right",extentPadding:C,xAccessor:de?void 0:c,yAccessor:de?void 0:u,timeAccessor:de?E:void 0,valueAccessor:x,colorAccessor:h,sizeAccessor:f,groupAccessor:g,categoryAccessor:$t,lineDataAccessor:p,xExtent:A,yExtent:T,sizeRange:O,binSize:v,normalize:m,boundsAccessor:U,boundsStyle:Q,y0Accessor:J,gradientFill:"boolean"==typeof tt?tt?{topOpacity:.8,bottomOpacity:.05}:void 0:tt,openAccessor:et,highAccessor:ot,lowAccessor:st,closeAccessor:ct,candlestickStyle:ut,lineStyle:j,pointStyle:X,areaStyle:H,swarmStyle:q,waterfallStyle:G,colorScheme:K,barColors:V,annotations:Et,decay:Wt,pulse:Nt,transition:Ct,staleness:Ot,heatmapAggregation:Rt,heatmapXBins:zt,heatmapYBins:It,pointIdAccessor:Bt}),[a,w,k,b,C,c,u,E,x,h,f,g,$t,p,A,T,O,v,m,U,Q,J,tt,et,ot,st,ct,ut,j,X,H,q,G,K,V,Et,Wt,Nt,Ct,Ot,Rt,zt,It,de,Bt]),ye=t.useRef(null);ye.current||(ye.current=new S(fe));const ge=t.useCallback(()=>{Zt.current||(Zt.current=requestAnimationFrame(()=>he.current()))},[]);t.useEffect(()=>{var t;null===(t=ye.current)||void 0===t||t.updateConfig(fe),Kt.current=!0,ge()},[fe,ge]);const pe=t.useRef(null);pe.current||(pe.current=new y(t=>{const e=ye.current;e&&e.ingest(t)&&(Kt.current=!0,ge())}));const me=t.useCallback(t=>{var e;null===(e=pe.current)||void 0===e||e.push(t)},[]),ve=t.useCallback(t=>{var e;null===(e=pe.current)||void 0===e||e.pushMany(t)},[]),xe=t.useCallback(()=>{var t,e;null===(t=pe.current)||void 0===t||t.clear(),null===(e=ye.current)||void 0===e||e.clear(),Kt.current=!0,ge()},[ge]);t.useImperativeHandle(n,()=>({push:me,pushMany:ve,clear:xe,getData:()=>{var t,e;return null!==(e=null===(t=ye.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=ye.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=ye.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[me,ve,xe]),t.useEffect(()=>{var t;s&&(null===(t=pe.current)||void 0===t||t.setBoundedData(s))},[s]);const be=t.useRef(()=>{}),ke=t.useRef(()=>{});be.current=t=>{if(!qt)return;const e=Vt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Xt.left,i=t.clientY-n.top-Xt.top;if(0>r||r>Ht||0>i||i>Gt)return void(ee.current&&(ee.current=null,ne.current=null,ie(null),kt&&(kt(null),Kt.current=!0),ge()));const o=ye.current;if(!o||0===o.scene.length)return;const a=function(t,e,n,r=30){let i=null;for(const o of t){let t=null;switch(o.type){case"point":t=M(o,e,n);break;case"line":t=L(o,e,n);break;case"rect":t=P(o,e,n);break;case"heatcell":t=D(o,e,n);break;case"area":if(!1===o.interactive)break;t=_(o,e,n);break;case"candlestick":t=$(o,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(o.scene,r,i);if(!a)return void(ee.current&&(ee.current=null,ne.current=null,ie(null),kt&&kt(null),ge()));const l={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};ee.current=l,ne.current=a.node,ie(l),kt&&(kt(l),Kt.current=!0),ge()},ke.current=()=>{ee.current&&(ee.current=null,ne.current=null,ie(null),kt&&(kt(null),Kt.current=!0),ge())},t.useCallback(t=>be.current(t),[]);const we=t.useCallback(()=>ke.current(),[]),Ee=t.useRef(-1),Ae=t.useCallback(t=>{const e=ye.current;if(!e||0===e.scene.length)return;const n=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const t=n,r=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.path.length>n&&r.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:r[n]});break}case"area":{const t=n,r=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.topPath.length>n&&r.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:r[n]});break}case"rect":case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===n.length)return;const r=0>Ee.current?-1:Ee.current,i=W(t.key,0>r?-1:r,n.length);if(null===i)return;if(t.preventDefault(),0>i)return Ee.current=-1,ee.current=null,ne.current=null,ie(null),kt&&kt(null),void ge();const o=0>r?0:i;Ee.current=o;const a={data:(l=n[o]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;ee.current=a,ie(a),kt&&kt(a),ge()},[kt,ge]),Se=t.useCallback(t=>{Ee.current=-1,be.current(t)},[]);he.current=()=>{var t,e;Zt.current=0;const n=Vt.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const i=ye.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(o);l||i.computeScene({width:Ht,height:Gt});const s="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=jt[0]*s,n.height=jt[1]*s,n.style.width=jt[0]+"px",n.style.height=jt[1]+"px",r.scale(s,s),r.translate(Xt.left,Xt.top),r.clearRect(-Xt.left,-Xt.top,jt[0],jt[1]);const h=function(t){if(!t)return it;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(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=i||e.getPropertyValue("--surface-0").trim();return o||a||n?{axisStroke:l||it.axisStroke,tickText:o||it.tickText,crosshair:o?o+"66":it.crosshair,hoverFill:s?s+"4D":it.hoverFill,hoverStroke:o?o+"99":it.hoverStroke,pointRing:s||it.pointRing}:it}(n),d=null!==(t=null==Ot?void 0:Ot.threshold)&&void 0!==t?t:5e3,f=Ot&&i.lastIngestTime>0&&o-i.lastIngestTime>d;f&&(r.globalAlpha=null!==(e=null==Ot?void 0:Ot.dimOpacity)&&void 0!==e?e:.5);const y=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=F||(y&&"transparent"!==y?y:null);g&&(r.fillStyle=g,r.fillRect(-Xt.left,-Xt.top,jt[0],jt[1])),r.save(),"function"==typeof r.rect&&(r.beginPath(),r.rect(0,0,Ht,Gt),r.clip());const p=nt[a];if(p&&i.scales)for(const t of p)t(r,i.scene,i.scales,{width:Ht,height:Gt});if(r.restore(),f&&(r.globalAlpha=1),qt&&ee.current&&i.scales&&function(t,e,n,r,i,o,a){if(!1===i.crosshair)return;t.save();const l="object"==typeof i.crosshair?i.crosshair:{};t.strokeStyle=l.stroke||a.crosshair,t.lineWidth=l.strokeWidth||1,t.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,r),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}(r,ee.current,Ht,Gt,"object"==typeof qt?qt:{},0,h),ne.current&&Array.isArray(xt)){const t=xt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);t&&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()}}(r,i.scene,ne.current,t)}const m=Kt.current;if(Kt.current=!1,m&&i.scales&&(te(i.scales),Yt)){const t=i.getData(),e="function"==typeof c?c:t=>t[c||"x"],n="function"==typeof u?u:t=>t[u||"y"];se(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),ue(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}m&&Et&&Et.length>0&&Qt(t=>t+1),(null==Ot?void 0:Ot.showBadge)&&ae(!!f),(l||i.hasActivePulses)&&(Zt.current=requestAnimationFrame(()=>he.current()))},t.useEffect(()=>(ge(),()=>{Zt.current&&(cancelAnimationFrame(Zt.current),Zt.current=0)}),[ge]),t.useEffect(()=>{Kt.current=!0,ge()},[a,Ht,Gt,ht,F,j,ge]),t.useEffect(()=>{if(!Ot)return;const t=setInterval(()=>{var t;const e=ye.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=Ot.threshold)&&void 0!==t?t:5e3,i=n-e.lastIngestTime>r;i!==oe&&(ae(i),Kt.current=!0,ge())},1e3);return()=>clearInterval(t)},[Ot,oe,ge]);const Me=qt&&re?bt?bt(re):d.createElement(at,{hover:re}):null,Le=Me?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Xt.left+re.x,top:Xt.top+re.y,transform:`translate(${re.x>.7*Ht?"calc(-100% - 12px)":"12px"}, ${.3*Gt>re.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Me):null,Pe=Ee.current>=0&&re?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:jt[0],height:jt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:re.x+Xt.left,cy:re.y+Xt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return d.createElement("div",{ref:Ft,className:"stream-xy-frame"+(B?" "+B:""),role:"img","aria-label":"string"==typeof Dt?Dt:"XY chart",tabIndex:0,style:{position:"relative",width:z?"100%":jt[0],height:I?"100%":jt[1]},onMouseMove:qt?Se:void 0,onMouseLeave:qt?we:void 0,onKeyDown:Ae},Lt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:jt[0],height:jt[1],pointerEvents:"none"}},Lt),d.createElement("canvas",{ref:Vt,style:{position:"absolute",left:0,top:0}}),d.createElement(Z,{width:Ht,height:Gt,totalWidth:jt[0],totalHeight:jt[1],margin:Xt,scales:Jt,showAxes:ht,axes:dt,xLabel:ft,yLabel:yt,xFormat:gt||mt,yFormat:pt||vt,showGrid:St,title:Dt,legend:Mt,foregroundGraphics:Pt,marginalGraphics:Yt,xValues:le,yValues:ce,annotations:Et,svgAnnotationRules:At,annotationFrame:Ut,xAccessor:"string"==typeof c?c:"string"==typeof E?E:void 0,yAccessor:"string"==typeof u?u:"string"==typeof x?x:void 0,annotationData:null===(r=ye.current)||void 0===r?void 0:r.getData(),pointNodes:null===(i=ye.current)||void 0===i?void 0:i.scene.filter(t=>"point"===t.type)}),(_t||Tt)&&d.createElement(lt,{width:Ht,height:Gt,totalWidth:jt[0],totalHeight:jt[1],margin:Xt,dimension:null!==(o=null==_t?void 0:_t.dimension)&&void 0!==o?o:"xy",scales:Jt,onBrush:null!=Tt?Tt:()=>{}}),(null==Ot?void 0:Ot.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ot.badgePosition?{top:4,left:4}:"bottom-left"===Ot.badgePosition?{bottom:4,left:4}:"bottom-right"===Ot.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:oe?"#dc3545":"#28a745",color:"white"})},oe?"STALE":"LIVE"),Pe,Le)});st.displayName="StreamXYFrame";const ct={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},ut={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ht{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var i;for(let o=0;this.capacity>o;o++){const a=this.particles[o];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=r&&null!==(i=r[a.edgeIndex])&&void 0!==i?i:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=dt(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}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}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function dt(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const i=t.length,o=e*i,a=Math.min(Math.floor(o),i-1),l=o-a,[s,c,u,h]=t[a],d=ft(s,c,u,h,l),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*r*2,d.y+=t*n*r*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,i,o,a]=t.points,l=ft(r,i,o,a,e),s=a.x-r.x,c=a.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function ft(t,e,n,r,i){const o=1-i,a=o*o,l=a*o,s=i*i,c=s*i;return{x:l*t.x+3*a*i*e.x+3*o*s*n.x+c*r.x,y:l*t.y+3*a*i*e.y+3*o*s*n.y+c*r.y}}function yt(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function gt(t,e){var n,r=[],i=[],o=[],a={},l=[];function s(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&s(e)})}function c(t){var e,r,h=!1;for(i.push(t),o[t]=!0,e=0;l[t].length>e;e++)(r=l[t][e])===n?(u(n,i),h=!0):o[r]||(h=c(r));if(h)s(t);else for(e=0;l[t].length>e;e++){var d=a[r=l[t][e]];d||(a[r]=d={}),d[r]=!0}return i.pop(),h}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function h(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),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,i[s]=!1,o[s]=0,a[s]=-1,l[s]=[];var c,u=0,h=[],d=[];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>a[g]||l[e].push(a[g])}o[e]=y}else{if(r[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(i[x]=!1,p.push(x),m.push(l[x]),v+=l[x].length,a[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[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]);d[s]=c}}return{components:h,adjacencyList:d}}(t),i=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;i.length>a;a++)for(var l=0;i[a].length>l;l++)o>i[a][l]&&(o=i[a][l],n=a);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 d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];o[+p]=!1,a[p]={}}c(n),n+=1}else n=d}return r}function pt(t){return t.y0-t.y1>0?"up":"down"}function mt(t,e){return e(t.source)==e(t.target)}function vt(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 xt(t){return t.target.x0-t.source.x1}function bt(t,e){var n=wt(t),r=xt(e)/Math.tan(n);return"up"==pt(t)?t.y1-r:t.y1+r}function kt(t,e){var n=wt(t),r=xt(e)/Math.tan(n);return"up"==pt(t)?t.y1+r:t.y1-r}function wt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Et(t,e){return e(t)}function At(t){return Mt(t.source)}function St(t){return Mt(t.target)}function Mt(t){return(t.y0+t.y1)/2}function Lt(t){return t.virtual?0:t.value}function Pt(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!mt(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!mt(t,e)?r+1:r}),n+r}function Dt(t){return t.target.depth}function $t(t,e){return t.sourceLinks.length?t.depth:e-1}function _t(t,e){return t.y0-e.y0}function Tt(t,e){return e.y0-t.y0}function Wt(t,e){return t.y1-e.y1}function Nt(t,e){return e.y1-t.y1}function Ct(t,e){return Rt(t.source,e.source)||t.index-e.index}function Ot(t,e){return Rt(t.target,e.target)||t.index-e.index}function Rt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function zt(t,e){return It(t)==It(e)?"bottom"==t.circularLinkType?Tt(t,e):_t(t,e):It(e)-It(t)}function It(t){return t.target.column-t.source.column}function Yt(t,e){return Bt(t)==Bt(e)}function Bt(t){return t.y0-t.y1>0?"up":"down"}function Ft(t,e,n,r,o){let a=t;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=i.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=a.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),jt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,n),jt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),a.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,mt(t,e)&&vt(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+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 i=t.source.column,l=t.circularLinkType,c=a.links.filter(function(t){return t.source.column==i&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Tt:_t);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}),i=t.target.column,(c=a.links.filter(function(t){return t.target.column==i&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Nt:Wt),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(a.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,r=t.target.x0,i=t.y1,o=(e+r)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(t)}),a}function jt(t,e,n){t.sort(zt);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(mt(t,e)&&vt(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var l=r[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Xt(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Xt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Ht(t){return function(){return t}}function Gt(t){return t.index}function qt(t){return t.nodes}function Vt(t){return t.links}function Zt(t,e,n){var r=i.groups(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){var o=i.length;i.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?Pt(e,n)-Pt(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==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Pt(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)/o*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+i,e.y1=e.y0+e.value*t.ky)})})}function Kt(t,e,n,r,o,a){var l=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=a;c>0;--c)u(s*=.99,n),h();function u(e,n){var r=l.length;l.forEach(function(o){var a=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Pt(o,n)>0){var c=i.mean(o.sourceLinks,St),u=i.mean(o.targetLinks,At),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-Mt(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==a)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==r-1&&1==a)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 f=i.mean(o.sourceLinks,St),y=i.mean(o.targetLinks,At),g=((f&&y?(f+y)/2:f||y)-Mt(o))*e;o.y0+=g,o.y1+=g}})})}function h(){l.forEach(function(n){var i,a,l,s=t.y0,c=n.length;for(n.sort(e||Rt),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+r;if((a=s-r-t.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+o-s)>0&&(i.y0-=a,i.y1-=a),s=i.y0})}}function Ut(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Ot),t.targetLinks.sort(Ct)}),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 Qt(){var t=0,e=0,n=1,r=1,o=24,a=8,l=null,s=Gt,c=$t,u=void 0,h=32,d=2,f=qt,y=Vt;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=r,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return i.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,i=t.target;"object"!=typeof r&&(r=t.source=yt(n,r)),"object"!=typeof i&&(i=t.target=yt(n,i)),r.sourceLinks.push(t),i.targetLinks.push(t)})}(f,s),function(t,e){var n=0;if(null==e){for(var r=[],i=0;t.links.length>i;i++){var o=t.links[i],a=o.source.index,l=o.target.index;r[a]||(r[a]=[]),r[l]||(r[l]=[]),-1===r[a].indexOf(l)&&r[a].push(l)}var s=gt(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++)})}(f,u),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){Et(t,e)!=Et(i.source,e)&&Et(t,e)!=Et(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),mt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(i.sum(t.sourceLinks,Lt),i.sum(t.targetLinks,Lt)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var r,i,o;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var a=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==l?a:a+1,l=e(t)==l?l:e(t),t.column=a})}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})}(f,u,c);var y=a;if(null!==l){var g=i.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=i.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(r-e)*l/(p-1)))}(function(t,e,n){var r=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=i.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/i.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=i.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/a),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,y,o),Zt(f,u,s),Kt(f,u,s,y,y,h),Ut(f),Ft(f,s,d,10,8),Zt(f,u,s),Kt(f,u,s,y,y,h),Ut(f),Ft(f,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 r=n.links.filter(function(n){return Et(n.source,e)==Et(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(!Yt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=bt(e,t);return t.y1-n}if(e.target.column>t.target.column)return bt(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,a=0;i>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return Et(n.target,e)==Et(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(!Yt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=kt(e,t);return t.y0-n}if(e.source.column>t.source.column)return kt(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,a=0;i>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var a=i.min(e,function(t){return t.y0}),l=i.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-a);function c(e){return(e-a)/(l-a)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),Ft(f,s,d,10,8)}(g),g}return g.update=function(t){return Ut(t),Ft(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(a=+t,g):a},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Ht(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:Ht(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:Ht(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Ht(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],r=+i[1][1],g):[[t,e],[n,r]]},g.size=function(i){return arguments.length?(t=e=0,n=+i[0],r=+i[1],g):[n-t,r-e]},g}const Jt=t=>{let e,n,r,i,o,l,s,c,u;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.y1,l=t.target.y0,s=a.interpolateNumber(o,l),c=s(.5),u=s(.5),`M${e},${o}C${e},${c} ${n},${u} ${n},${l}L${r},${l}C${r},${u} ${i},${c} ${i},${o}Z`):(e=t.source.x1,n=t.target.x0,s=a.interpolateNumber(e,n),r=s(.5),i=s(.5),o=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${i},${l} ${n},${l}L${n},${c}C${i},${c} ${r},${u} ${e},${u}Z`)};function te(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,a=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${e},${r-n}L${e+l},${r-n}L${e+l},${r+n}L${e},${r+n}ZM${o},${a-n}L${o-s},${a-n}L${o-s},${a+n}L${o},${a+n}Z`}const o=i.sourceX,a=i.sourceY,l=i.targetX,s=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,h=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${o},${a-d*n}L${c},${a-d*n}L${c+r},${a-d*n+d*f}L${c+r},${h+d*r-d*f}L${c+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${s-d*n+d*f}L${u-r+f},${s-d*n}L${l},${s-d*n}L${l},${s+d*n}L${u+r},${s+d*n}L${u+r},${h-d*r}L${c-r},${h-d*r}L${c-r},${a+d*n}L${o},${a+d*n}Z`}const ee={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(Dt))-1:0},justify:$t},ne={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var i,o,a,l,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=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!==(a=n.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=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 v;v="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Qt().extent(v).links(m).nodes(p).nodeAlign(ee[d]||$t).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 m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(s=null!==(l=r._circularWidth)&&void 0!==l?l:r.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),n>o.verticalFullExtent-a&&(n=o.verticalFullExtent-a),o.verticalFullExtent+a>i&&(i=o.verticalFullExtent+a)}const o=e-t,a=i-n,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>n||e>u||i>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,i=-n*e+(h-a*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 m)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(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){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(`${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=h;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,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:l.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],v=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=u?u(e):{},i={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({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";h?r=h(t).fill||r:"target"===f&&n?r=g.get(n.id)||r:e&&(r=g.get(e.id)||r);const i=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,l=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;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+l},${e.sourceY-n}L${e.sourceX+l},${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+l}}),m.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!==(a=i.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;if(l=t.circular&&t.circularPathData?te(t):Jt(t),!l)continue;const c={fill:i.fill||r,fillOpacity:null!==(s=i.fillOpacity)&&void 0!==s?s:d,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};m.push({type:"bezier",pathD:l,bezierCache:t.bezier,style:c,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){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 a,l,s;"down"===c?(a=n.x0+t/2,l=n.y1+14,s="middle"):(r[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+i/2),v.push({x:a,y:l,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}},re={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){var i,o;if(0===t.length)return;const a=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,u=r[1]/2;for(let e=0;t.length>e;e++){const n=t[e];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;n.x=c+t*Math.cos(r),n.y=u+t*Math.sin(r)}}const h=ie(n.nodeSize,n.nodeSizeRange,t),d=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),f=r[1]/r[0],y=s.forceSimulation().force("charge",s.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",s.forceX(r[0]/2).strength(.1*f)).force("y",s.forceY(r[1]/2).strength(.1));if(y.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}));y.force("link",d),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;a>t;++t)y.tick();const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var i,o,a;const s=n.nodeStyle,c=n.edgeStyle,u=ie(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:l.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},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};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.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=c?c(t):{},i={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.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=(m=n.nodeLabel)?"function"==typeof m?m:t=>t[m]||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=u(n);g.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ie(t,e,n){var o,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const l=e||[5,20],s=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===s.length)return()=>l[0];const c=null!==(o=i.min(s))&&void 0!==o?o:0,u=null!==(a=i.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const h=r.scaleLinear().domain([c,u]).range(l).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?l[0]:h(r)}}const oe=l.schemeCategory10,ae={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:a}=n,l=Math.min(r[0],r[1])/2,s=l-o,h=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),r=g.get(e);if(void 0===n||void 0===r)continue;const i=f(t);m[n][r]=i}const v=c.chord().padAngle(i);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=u.arc().innerRadius(s).outerRadius(l);for(const e of b){const n=t[e.index],r=k.centroid(e);n.x=r[0]+h,n.y=r[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);n&&(t.source=n),r&&(t.target=r)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,r=t[e.target.index].id,i=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);i&&(i.chordData=e)}},buildScene(t,e,n,r){var i,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(r[0],r[1])/2,u=s-a,h=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:oe,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=c.ribbon().radius(u),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let o;o=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};x.push({type:"arc",cx:h,cy:d,innerR:u,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=v(e);if(!n)continue;const r=le(n,h,d);let i="#999";if(y)i=y(t).fill||i;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?i=m.get(n.id)||i:e&&(i=m.get(e.id)||i)}const a=y?y(t):{},s={fill:i,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||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,a=o-Math.PI/2;k.push({x:h+Math.cos(a)*r,y:d+Math.sin(a)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function le(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 se={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var i;const a=n.__hierarchyRoot;if(!a)return;const l=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=o.hierarchy(a,s);h.sum(u),h.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,f]=r;switch(l){case"tree":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.tree();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.cluster();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,r){var i,a;const l=null!==(i=e.padding)&&void 0!==i?i:4,s=null!==(a=e.paddingTop)&&void 0!==a?a:0,c=o.treemap().size([n,r]).tile(o.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,r){var i;const a=null!==(i=e.padding)&&void 0!==i?i:4;o.pack().size([n,r]).padding(a)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,r){var i;o.partition().size([n,r]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const r=y[e],o={id:fe(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?ce(o,r,n):"treemap"===l||"partition"===l?ue(o,r):"circlepack"===l&&he(o,r),o.__hierarchyNode=r,t.push(o),g.set(r,o)}if("tree"===l||"cluster"===l)for(const t of y)if(t.parent){const n=g.get(t.parent),r=g.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 a,l,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=i(e);let l=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=x[e.depth%x.length]);const s={fill:l,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=null!==(l=n.edgeOpacity)&&void 0!==l?l:.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,a=n.x,l=n.y;g&&(r+=p,i+=m,a+=p,l+=m);const u=de(r,i,a,l,y),h=o(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=ye(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,i,o,a=n.x,l=n.y;if(g&&(a+=p,l+=m),g){const t=a-p,e=l-m,n=Math.sqrt(t*t+e*e);n>0?(r=a+t/n*10,i=l+e/n*10,o=0>t?"end":"start"):(r=a,i=l-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=a-v-6,o="end"):(r=a+v+6,o="start"),i=l):(r=a,i=l+v+14,o="middle");f.push({x:r,y:i,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,r,i,o);case"treemap":case"partition":return function(t,e,n,r){var i,o;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const l=r(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ye(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,i=r.y1-r.y0;if(0>=t||0>=i)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=n?n(r):r.id;a&&(30>t||16>i||l.push({x:r.x0+t/2,y:r.y0+i/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,i)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,i);case"circlepack":return function(t,e,n,r){var i,o,a,l,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=r(n);let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.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=ye(e.nodeLabel);for(const e of t){const t=null!==(l=e.__radius)&&void 0!==l?l:5,r=n?n(e):e.id;if(!r)continue;if(15>t)continue;const i=!((null===(s=e.data)||void 0===s?void 0:s.children)&&e.data.children.length>0);u.push({x:e.x,y:i?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:i?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:i?void 0:"#000",stroke:i?void 0:"#fff",strokeWidth:i?void 0:3,paintOrder:i?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ce(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 ue(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 he(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 de(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}`}}function fe(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 ye(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}const ge={sankey:ne,force:re,chord:ae,tree:se,cluster:se,treemap:se,circlepack:se,partition:se};function pe(t){return ge[t]}class me{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.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,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.config=t,this.tensionConfig=Object.assign(Object.assign({},ct),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new ht(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},ct),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new ht(2e3))}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:i="source",targetAccessor:o="target",valueAccessor:a="value"}=this.config,l="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 a?a:t=>{var e;return null!==(e=t[a])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear();for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},ve(t)),{data:e}))}for(const t of e){const e=s(t)+"",n=c(t)+"",r=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},ve(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},ve(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0,data:t})}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 a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(e)||(this.nodes.set(e,ve(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,ve(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,o=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);return s?(s.value+=r,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,o=!0),i||o||this.tension>=this.tensionConfig.threshold}runLayout(t){const e=pe(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values()),r=Array.from(this.edges.values());if(0===n.length&&!e.hierarchical)return;if(this.prepareForRelayout(),e.computeLayout(n,r,this.config,t),e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const t of n)this.nodes.set(t.id,t);for(const t of r)this.edges.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t)}this.finalizeLayout(),this.saveTargetPositions(),n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const i=new Set(this.nodes.keys()),o=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 i)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)i.has(t)||this.removedNodes.add(t);for(const t of o)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)o.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=i,this.previousEdgeKeys=o,this.layoutVersion++}buildScene(t){const e=pe(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:o,labels:a}=e.buildScene(n,r,this.config,t);this.sceneNodes=i,this.sceneEdges=o,this.labels=a}advanceTransition(t){if(!this.transition)return!1;const e=Math.min((t-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-e,3);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0+(t._targetX0-t._prevX0)*n,t.x1=t._prevX1+(t._targetX1-t._prevX1)*n,t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n);for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n,t.sankeyWidth=t._prevSankeyWidth+(t._targetSankeyWidth-t._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}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);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.y1,o=n.y0,l=a.interpolateNumber(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=a.interpolateNumber(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,a=n.y-e.y;i.push([e,{x:e.x+o/3,y:e.y+a/3},{x:e.x+2*o/3,y:e.y+2*a/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 a=this.config.pulse;if(!a)return;const l=null!==(e=a.duration)&&void 0!==e?e:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=a.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;l>i&&(e._pulseIntensity=1-i/l,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,a="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!r||!a)continue;const c=this.edgeTimestamps.get(`${r}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,r,i;const o=this.config.decay;if(!o)return;const a=null!==(t=o.minOpacity)&&void 0!==t?t:.1,l=this.nodeTimestamps.size;if(1>=l)return;const s=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]),c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const h=l-1-u;let d;switch(o.type){case"linear":d=a+(1-h/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:l/2;d=a+Math.pow(.5,h/t)*(1-a);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*l)>h?1:a;break;default:d=1}const f=null!==(i=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}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",a=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=r.metric(l);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}),a&&(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())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function ve(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 xe(t,e,n,r,i=30){let o=null,a=i,l=1/0;for(const e of t){const t=be(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(o=t,l=n)}else a>t.distance&&(o=t,a=t.distance)}if(o)return o;for(const t of e){const e=ke(t,n,r);e&&a>e.distance&&(o=e,a=e.distance)}return o}function be(t,e,n){switch(t.type){case"circle":return function(t,e,n){const r=e-t.cx,i=n-t.cy,o=Math.sqrt(r*r+i*i);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{type:"node",datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}(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;let a=Math.atan2(i,r);0>a&&(a+=2*Math.PI);let l,s=t.startAngle,c=t.endAngle;if(0>s&&(s+=2*Math.PI),0>c&&(c+=2*Math.PI),l=s>c?a>=s||c>=a:a>=s&&c>=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}}function ke(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,i;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(o,e,n)){const o="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,a="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&&a?(o.x1+a.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}}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 a=((e-t.x1)*r+(n-t.y1)*i)/o;a=Math.max(0,Math.min(1,a));const l=t.x1+a*r,s=t.y1+a*i,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0}}catch(t){}return null}(t,e,n);default:return null}}function we(t){const{width:e,height:n,totalWidth:r,totalHeight:i,margin:o,labels:a,title:l,legend:s,foregroundGraphics:c,annotations:u,svgAnnotationRules:h}=t;return d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${o.left},${o.top})`},a.map((t,e)=>d.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),u&&h&&u.map((t,r)=>{const i=h(t,r,{width:e,height:n});return i?d.createElement(d.Fragment,{key:"annotation-"+r},i):null}),c),l&&"string"==typeof l?d.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?d.createElement("foreignObject",{x:0,y:0,width:r,height:o.top},l):null,s&&"object"==typeof s&&"legendGroups"in s?d.createElement("g",{transform:`translate(${r-o.right+10},${o.top})`},s.legendGroups.map((t,e)=>{var n;return d.createElement("g",{key:"legend-group-"+e},null===(n=t.items)||void 0===n?void 0:n.map((t,e)=>d.createElement("g",{key:"legend-item-"+e,transform:`translate(0,${20*e})`},d.createElement("rect",{x:0,y:0,width:12,height:12,fill:t.color,rx:2}),d.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},t.label))))})):s?d.createElement("g",{transform:`translate(${r-o.right+10},${o.top})`},s):null)}function Ee(t,e){var n,r,i,o,a,l;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const a=e._gradient;if(a){const i=t.createLinearGradient(a.x0,0,a.x1,0),o=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,l=e.style.fill;i.addColorStop(0,1===a.from?l:"transparent"),i.addColorStop(1,1===a.to?l:"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!==(a=e.style.strokeWidth)&&void 0!==a?a:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l: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 Ae(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 Se(t,e){var n,r,i,o;if(!e.pathD)return;t.save();const a=new Path2D(e.pathD);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(a)),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(a)),t.restore()}function Me(t,e){var n,r;if(!e.pathD)return;t.save();const i=new Path2D(e.pathD);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()}we.displayName="NetworkSVGOverlay";const Le=l.schemeCategory10,Pe={top:20,right:80,bottom:20,left:80},De={top:40,right:40,bottom:40,left:40},$e=new Set(["chord","force","circlepack"]),_e=[800,600],Te={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 We({data:t}){var e,n,r,i,o,a;if("edge"===t.type){const e=t.data;return d.createElement("div",{className:"semiotic-tooltip",style:Te},d.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let o=s;for(;o;){const a=null!==(i=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(r=o.data)||void 0===r?void 0:r.id)&&void 0!==i?i:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return d.createElement("div",{className:"semiotic-tooltip",style:Te},d.createElement("div",null,t.map((t,e)=>d.createElement("span",{key:e},e>0&&d.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===a?d.createElement("strong",null,t):d.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(o=l.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return d.createElement("div",{className:"semiotic-tooltip",style:Te},d.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Ne=t.forwardRef(function(e,n){const{chartType:r,nodes:i,edges:o,data:a,initialEdges:l,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:h="value",childrenAccessor:f,hierarchySum:y,orientation:g="horizontal",nodeAlign:p="justify",nodePaddingRatio:m=.05,nodeWidth:v=15,iterations:x=300,forceStrength:b=.1,padAngle:k=.01,groupWidth:w=20,sortGroups:E,edgeSort:A,treeOrientation:S="vertical",edgeType:M="curve",padding:L,paddingTop:P,tensionConfig:D,showParticles:$=!1,particleStyle:_,nodeStyle:T,edgeStyle:C,colorBy:O,colorScheme:R="category10",edgeColorBy:z="source",edgeOpacity:I=.5,colorByDepth:Y=!1,nodeSize:B=8,nodeSizeRange:F=[5,20],nodeLabel:j,showLabels:X=!0,size:H=_e,responsiveWidth:G,responsiveHeight:q,margin:V,className:Z,background:K,enableHover:U=!0,tooltipContent:Q,customHoverBehavior:J,customClickBehavior:tt,onObservation:et,chartId:nt,onTopologyChange:rt,annotations:it,svgAnnotationRules:ot,legend:at,title:lt,foregroundGraphics:st,backgroundGraphics:ht,decay:dt,pulse:ft,staleness:yt,thresholds:gt}=e,pt=$e.has(r)?De:Pe,[mt,vt]=N(H,G,q),xt=Object.assign(Object.assign({},pt),V),bt=vt[0]-xt.left-xt.right,kt=vt[1]-xt.top-xt.bottom,wt=t.useMemo(()=>Object.assign(Object.assign({},ct),D),[D]),Et=t.useMemo(()=>Object.assign(Object.assign({},ut),_),[_]),At=t.useMemo(()=>({chartType:r,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:u,valueAccessor:h,childrenAccessor:f,hierarchySum:y,orientation:g,nodeAlign:p,nodePaddingRatio:m,nodeWidth:v,iterations:x,forceStrength:b,padAngle:k,groupWidth:w,sortGroups:E,edgeSort:A,treeOrientation:S,edgeType:M,padding:L,paddingTop:P,tensionConfig:wt,showParticles:$,particleStyle:Et,nodeStyle:T,edgeStyle:C,nodeLabel:j,showLabels:X,colorBy:O,colorScheme:R,edgeColorBy:z,edgeOpacity:I,colorByDepth:Y,nodeSize:B,nodeSizeRange:F,decay:dt,pulse:ft,staleness:yt,thresholds:gt}),[r,s,c,u,h,f,y,g,p,m,v,x,b,k,w,E,A,S,M,L,P,wt,$,Et,T,C,j,X,O,R,z,I,Y,B,F,dt,ft,yt,gt]),St=t.useRef(null),Mt=t.useRef(0),Lt=t.useRef(0),Pt=t.useRef(!0),Dt=t.useRef(()=>{}),$t=t.useRef(null);$t.current||($t.current=new me(At));const[_t,Tt]=t.useState(null),[Wt,Nt]=t.useState(0),[Ct,Ot]=t.useState(0),[Rt,zt]=t.useState(!1),It=t.useRef(null),Yt=t.useRef(new Map),Bt=t.useRef(0),Ft=t.useCallback(t=>{if("function"==typeof O)return O(t);if("string"==typeof O&&t.data){const e=t.data[O];if(void 0!==e){if(!Yt.current.has(e+"")){const t=Array.isArray(R)?R:Le;Yt.current.set(e+"",t[Bt.current++%t.length])}return Yt.current.get(e+"")}}if(!Yt.current.has(t.id)){const e=Array.isArray(R)?R:Le;Yt.current.set(t.id,e[Bt.current++%e.length])}return Yt.current.get(t.id)},[O,R]),jt=t.useCallback(t=>{if("function"==typeof z)return z(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===z&&n?Ft(n):e?Ft(e):"#999"},[z,Ft]),Xt=t.useCallback(t=>{if(!(null==_?void 0:_.colorBy))return jt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Et.colorBy&&n?Ft(n):e?Ft(e):"#999"},[null==_?void 0:_.colorBy,Et.colorBy,Ft,jt]),Ht="sankey"===r&&$||!!ft,Gt=t.useCallback(()=>{Mt.current&&!Ht||Mt.current||(Mt.current=requestAnimationFrame(()=>Dt.current()))},[Ht]);t.useEffect(()=>{var t;null===(t=$t.current)||void 0===t||t.updateConfig(At),Pt.current=!0,Gt()},[At,Gt]);const qt=t.useCallback(()=>{const t=$t.current;if(!t)return;t.runLayout([bt,kt]),t.buildScene([bt,kt]),Pt.current=!0;const e=Array.isArray(R)?R:Le,n=Array.from(t.nodes.values());for(let t=0;n.length>t;t++){const r=n[t];Yt.current.has(r.id)||Yt.current.set(r.id,e[t%e.length])}if(Bt.current=n.length,Nt(t.layoutVersion),rt){const{nodes:e,edges:n}=t.getLayoutData();rt(e,n)}},[bt,kt,rt,R]),Vt=t.useCallback(t=>{const e=$t.current;e&&(e.ingestEdge(t)&&qt(),Gt())},[qt,Gt]),Zt=t.useCallback(t=>{const e=$t.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&qt(),Gt()},[qt,Gt]),Kt=t.useCallback(()=>{var t;null===(t=$t.current)||void 0===t||t.clear(),Yt.current.clear(),Bt.current=0,Nt(0),Tt(null),It.current=null,Pt.current=!0,Gt()},[Gt]),Ut=t.useCallback(()=>{const t=$t.current;t&&(t.tension+=999,qt(),Gt())},[qt,Gt]);t.useImperativeHandle(n,()=>({push:Vt,pushMany:Zt,clear:Kt,getTopology:()=>{var t,e;return null!==(e=null===(t=$t.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=$t.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:Ut,getTension:()=>{var t,e;return null!==(e=null===(t=$t.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Vt,Zt,Kt,Ut]);const Qt=["tree","cluster","treemap","circlepack","partition"].includes(r),Jt=Qt?a||(Array.isArray(o)?void 0:o):void 0;t.useEffect(()=>{const t=$t.current;if(t)if(Qt&&Jt)t.ingestHierarchy(Jt,[bt,kt]),t.buildScene([bt,kt]),Pt.current=!0,Gt();else{const e=i||[],n=Array.isArray(o)?o:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[bt,kt]),t.buildScene([bt,kt]);const r=Array.isArray(R)?R:Le,a=Array.from(t.nodes.values());for(let t=0;a.length>t;t++){const e=a[t];Yt.current.has(e.id)||Yt.current.set(e.id,r[t%r.length])}Bt.current=a.length,Pt.current=!0,Gt()}},[i,o,a,Jt,Qt,bt,kt,At,Gt,R]),t.useEffect(()=>{l&&l.length>0&&Zt(l)},[]);const te=t.useCallback(t=>{if(J&&J(t),et){const e=Date.now();et(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:nt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:nt})}},[J,et,nt]),ee=t.useCallback(t=>{if(tt&&tt(t),et){const e=Date.now();et(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:nt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:nt})}},[tt,et,nt]),ne=t.useRef(()=>{}),re=t.useRef(()=>{});ne.current=t=>{if(!U)return;const e=St.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-xt.left,i=t.clientY-n.top-xt.top;if(0>r||r>bt||0>i||i>kt)return void(It.current&&(It.current=null,Tt(null),te&&(te(null),Pt.current=!0),Gt()));const o=$t.current;if(!o)return;const a=xe(o.sceneNodes,o.sceneEdges,r,i);if(!a)return void(It.current&&(It.current=null,Tt(null),te&&(te(null),Pt.current=!0),Gt()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};It.current=l,Tt(l),te&&(te(l),Pt.current=!0),Gt()},re.current=()=>{It.current&&(It.current=null,Tt(null),te&&(te(null),Pt.current=!0),Gt())};const ie=t.useRef(()=>{});ie.current=t=>{if(!tt&&!et)return;const e=St.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-xt.left,i=t.clientY-n.top-xt.top;if(0>r||r>bt||0>i||i>kt)return;const o=$t.current;if(!o)return;const a=xe(o.sceneNodes,o.sceneEdges,r,i);ee(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},t.useCallback(t=>ne.current(t),[]);const oe=t.useCallback(()=>re.current(),[]),ae=t.useCallback(t=>ie.current(t),[]),le=t.useRef(-1),se=t.useCallback(t=>{const e=$t.current;if(!e)return;const n=function(t){const e=[];for(const n of t)"circle"===n.type&&null!=n.cx?e.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&e.push({x:n.cx,y:n.cy,datum:n.datum});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const r=le.current,i=W(t.key,0>r?-1:r,n.length);if(null===i)return;if(t.preventDefault(),0>i)return le.current=-1,It.current=null,Tt(null),te&&(te(null),Pt.current=!0),void Gt();const o=0>r?0:i;le.current=o;const a=n[o],l={type:"node",data:a.datum,x:a.x,y:a.y};It.current=l,Tt(l),te&&(te(l),Pt.current=!0),Gt()},[te,Gt]),ce=t.useCallback(t=>{le.current=-1,ne.current(t)},[]);Dt.current=()=>{var t,e,n;Mt.current=0;const r=St.current;if(!r)return;const i=r.getContext("2d");if(!i)return;const o=$t.current;if(!o)return;const a=performance.now(),l=Lt.current?Math.min((a-Lt.current)/1e3,.1):.016;Lt.current=a;const s=o.advanceTransition(a);(s||Pt.current)&&o.buildScene([bt,kt]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;r.width=vt[0]*c,r.height=vt[1]*c,r.style.width=vt[0]+"px",r.style.height=vt[1]+"px",i.scale(c,c),i.translate(xt.left,xt.top),i.clearRect(-xt.left,-xt.top,vt[0],vt[1]),K&&(i.fillStyle=K,i.fillRect(0,0,bt,kt)),dt&&o.applyDecay(),ft&&o.applyPulse(a),gt&&o.applyThresholds(a),o.applyTopologyDiff(a);const u=null!==(t=null==yt?void 0:yt.threshold)&&void 0!==t?t:5e3,h=yt&&o.lastIngestTime>0&&a-o.lastIngestTime>u;if(h&&(i.globalAlpha=null!==(e=null==yt?void 0:yt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Ee(t,n);break;case"line":Ae(t,n);break;case"ribbon":Se(t,n);break;case"curved":Me(t,n)}}(i,o.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)),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.restore())}}(i,o.sceneNodes),function(t,e){var n,r,i,o;for(const a of e){if("circle"!==a.type)continue;const e=a;if(e.r>0){if(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()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.cx,e.cy,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.restore()}}}(i,o.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()}}(i,o.sceneNodes),$&&o.particlePool&&!h){const t=Array.from(o.edges.values());if(t.length>0){!function(t,e,n,r){var i,o;const a=null!==(i=r.spawnRate)&&void 0!==i?i:ut.spawnRate,l=null!==(o=r.maxPerEdge)&&void 0!==o?o:ut.maxPerEdge;for(let r=0;e.length>r;r++){const i=e[r];if(!i.bezier)continue;if(t.countForEdge(r)>=l)continue;const o=i.value*a*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)<l;e++)t.spawn(r)}}(o.particlePool,t,l,Et);const e=.5*(null!==(n=Et.speedMultiplier)&&void 0!==n?n:1);let r;if(Et.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)}o.particlePool.step(l,e,t,r),function(t,e,n,r,i){var o,a;const l=null!==(o=r.radius)&&void 0!==o?o:ut.radius,s=null!==(a=r.opacity)&&void 0!==a?a:ut.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const a=e.particles[o];if(!a.active)continue;const s=n[a.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(a.x,a.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(i,o.particlePool,t,Et,Xt)}}h&&(i.globalAlpha=1);const d=Pt.current;Pt.current=!1,(d||s)&&Ot(t=>t+1),(Ht||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(Mt.current=requestAnimationFrame(()=>Dt.current()))},t.useEffect(()=>(Gt(),()=>{Mt.current&&(cancelAnimationFrame(Mt.current),Mt.current=0)}),[Gt]),t.useEffect(()=>{Pt.current=!0,Gt()},[r,bt,kt,K,Gt]),t.useEffect(()=>{if(!yt)return;const t=setInterval(()=>{var t;const e=$t.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=yt.threshold)&&void 0!==t?t:5e3,i=n-e.lastIngestTime>r;i!==Rt&&(zt(i),Pt.current=!0,Gt())},1e3);return()=>clearInterval(t)},[yt,Rt,Gt]);const ue=U&&_t?d.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:xt.left+_t.x,top:xt.top+_t.y,transform:`translate(${_t.x>.6*bt?"calc(-100% - 12px)":"12px"}, ${.3*kt>_t.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},Q?Q(_t):d.createElement(We,{data:_t})):null,he=$t.current;return d.createElement("div",{ref:mt,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":"string"==typeof lt?lt:"Network chart",tabIndex:0,style:{position:"relative",width:G?"100%":vt[0],height:q?"100%":vt[1]},onMouseMove:U?ce:void 0,onMouseLeave:U?oe:void 0,onClick:tt||et?ae:void 0,onKeyDown:se},ht&&d.createElement("svg",{style:{position:"absolute",top:0,left:0,width:vt[0],height:vt[1],pointerEvents:"none"}},d.createElement("g",{transform:`translate(${xt.left},${xt.top})`},ht)),d.createElement("canvas",{ref:St,style:{position:"absolute",top:0,left:0}}),d.createElement(we,{width:bt,height:kt,totalWidth:vt[0],totalHeight:vt[1],margin:xt,labels:(null==he?void 0:he.labels)||[],title:lt,legend:at,foregroundGraphics:st,annotations:it,svgAnnotationRules:ot,annotationFrame:Ct}),ue,(null==yt?void 0:yt.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===yt.badgePosition?{top:4,left:4}:"bottom-left"===yt.badgePosition?{bottom:4,left:4}:"bottom-right"===yt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Rt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Rt?"STALE":"LIVE"))});function Ce(e){const n=t.createContext(null),r=Oe(e);return[function({children:r}){const i=t.useMemo(()=>Oe(e),[]);return d.createElement(n.Provider,{value:i,children:r})},e=>{var i;const o=null!==(i=t.useContext(n))&&void 0!==i?i:r;return function(e,n){const[r,i]=t.useState(n);return t.useLayoutEffect(()=>e(()=>i(n)),[e]),r}(o.subscribe,()=>e(o.getState()))}]}function Oe(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 Re(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 ze(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Ne.displayName="StreamNetworkFrame";const[Ie,Ye]=Ce(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),i=ze(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=ze(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}})}}));function Be(e){const n=t.useId(),r=e.clientId||n,{name:i}=e,o=Ye(t=>t.selections.get(i)),a=Ye(t=>t.setClause),l=Ye(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,i]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(Re(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:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};a(i,{clientId:r,type:"point",fields:e})},[r,i,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};a(i,{clientId:r,type:"interval",fields:e})},[r,i,a]),clear:t.useCallback(()=>{l(i,r)},[l,i,r]),clientId:r}}const[Fe,je]=Ce(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 Xe({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:i=!1,onObservation:o,chartType:a,chartId:l}){const s=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}:null}(n,r),c=Be({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:i,isActive:o,selectPoints:a,clear:l}=Be({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of r){const r=t[n];void 0!==r&&(e[n]=[r])}Object.keys(e).length>0&&a(e)},[r,a,l,n]),predicate:i,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||r||[]}),h=je(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,r;if(n)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},r),{type:"click",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},r),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const He={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 Ge(t,e,n){var r,i,o,a,l,s;const c=He[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:c.width,height:null!==(i=e.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o:c.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||c.enableHover,showLegend:null!==(l=e.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:c.marginDefaults}}const qe=t.forwardRef(function(e,n){var r,i,o,a;const l=Ge(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:S,tooltip:M,onHover:L,annotations:P,svgAnnotationRules:D,tickFormatTime:$,tickFormatValue:_,decay:T,pulse:W,staleness:N,transition:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=S?S:M,X=t.useRef(null),{customHoverBehavior:H}=Xe({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:z}),G=t.useCallback(t=>{L&&L(t),H(t)},[L,H]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),d.createElement(st,{ref:X,chartType:"line",runtimeMode:"streaming",size:F,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:{stroke:k,strokeWidth:w,strokeDasharray:E},showAxes:I,background:A,hoverAnnotation:Y,tooltipContent:j,customHoverBehavior:G,annotations:P,svgAnnotationRules:D,tickFormatTime:$,tickFormatValue:_,decay:T,pulse:W,staleness:N,transition:C})});qe.displayName="RealtimeLineChart";const Ve=t.forwardRef(function(e,n){var r,i,o,a;const l=Ge(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:f="right",windowMode:y="sliding",windowSize:g=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:S,strokeWidth:M,gap:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C,linkedHover:O,decay:R,pulse:z,staleness:I,transition:Y,onObservation:B,chartId:F}=e,j=l.showAxes,X=l.enableHover,H=null!=u?u:l.marginDefaults,G=null!=c?c:[l.width,l.height],q=null!=D?D:$,V=t.useRef(null),{customHoverBehavior:Z}=Xe({linkedHover:O,unwrapData:!0,onObservation:B,chartType:"RealtimeTemporalHistogram",chartId:F}),K=t.useCallback(t=>{_&&_(t),Z(t)},[_,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=V.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=V.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=V.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=V.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const U={};return null!=A&&(U.fill=A),null!=S&&(U.stroke=S),null!=M&&(U.strokeWidth=M),null!=L&&(U.gap=L),d.createElement(st,{ref:V,chartType:"bar",runtimeMode:"streaming",size:G,margin:H,className:h,arrowOfTime:f,windowMode:y,windowSize:g,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:U,showAxes:j,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:K,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C,decay:R,pulse:z,staleness:I,transition:Y})});Ve.displayName="RealtimeTemporalHistogram";const Ze=Ve,Ke=t.forwardRef(function(e,n){var r,i,o,a;const l=Ge(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=D?D:$,X=t.useRef(null),{customHoverBehavior:H}=Xe({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:z}),G=t.useCallback(t=>{_&&_(t),H(t)},[_,H]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const q={};return null!=E&&(q.radius=E),null!=A&&(q.fill=A),null!=S&&(q.opacity=S),null!=M&&(q.stroke=M),null!=L&&(q.strokeWidth=L),d.createElement(st,{ref:X,chartType:"swarm",runtimeMode:"streaming",size:F,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:q,showAxes:I,background:P,hoverAnnotation:Y,tooltipContent:j,customHoverBehavior:G,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C})});Ke.displayName="RealtimeSwarmChart";const Ue=t.forwardRef(function(e,n){var r,i,o,a;const l=Ge(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=D?D:$,X=t.useRef(null),{customHoverBehavior:H}=Xe({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:z}),G=t.useCallback(t=>{_&&_(t),H(t)},[_,H]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const q={};return null!=k&&(q.positiveColor=k),null!=w&&(q.negativeColor=w),null!=E&&(q.connectorStroke=E),null!=A&&(q.connectorWidth=A),null!=S&&(q.gap=S),null!=M&&(q.stroke=M),null!=L&&(q.strokeWidth=L),d.createElement(st,{ref:X,chartType:"waterfall",runtimeMode:"streaming",size:F,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:q,showAxes:I,background:P,hoverAnnotation:Y,tooltipContent:j,customHoverBehavior:G,annotations:T,svgAnnotationRules:W,tickFormatTime:N,tickFormatValue:C})});Ue.displayName="RealtimeWaterfallChart";const Qe=t.forwardRef(function(e,n){var r,i,o,a;const l=Ge(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:S,tooltipContent:M,tooltip:L,onHover:P,annotations:D,svgAnnotationRules:$,tickFormatTime:_,tickFormatValue:T,decay:W,pulse:N,staleness:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=M?M:L,X=t.useRef(null),{customHoverBehavior:H}=Xe({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:z}),G=t.useCallback(t=>{P&&P(t),H(t)},[P,H]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),d.createElement(st,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:F,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:I,background:S,hoverAnnotation:Y,tooltipContent:j,customHoverBehavior:G,annotations:D,svgAnnotationRules:$,tickFormatTime:_,tickFormatValue:T,decay:W,pulse:N,staleness:C})});Qe.displayName="RealtimeHeatmap",exports.IncrementalExtent=p,exports.RealtimeHeatmap=Qe,exports.RealtimeHistogram=Ze,exports.RealtimeLineChart=qe,exports.RealtimeSwarmChart=Ke,exports.RealtimeWaterfallChart=Ue,exports.RingBuffer=g,exports.StreamNetworkFrame=Ne,exports.StreamXYFrame=st;
|
|
1
|
+
"use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),r=require("d3-scale"),i=require("d3-array"),o=require("d3-hierarchy"),a=require("regression"),l=require("d3-shape"),s=require("d3-interpolate"),c=require("d3-scale-chromatic"),u=require("d3-force"),h=require("d3-chord");function d(t){return t&&t.__esModule?t:{default:t}}function f(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const y=f(t),g=d(a),p=5e3;class m{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,p),bounded:!0,totalSize:t.length});let e=p;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+p,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)}push(t){this.callback({inserts:[t],bounded:!1})}pushMany(t){0!==t.length&&this.callback({inserts:t,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class v{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}}}toArray(){const t=[];for(const e of this)t.push(e);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}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 x{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 b(t,e,n,r,i){const o=new Map;for(const a of t){const t=e(a),l=n(a);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))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+=l,i){const t=i(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}return o}function k(t,e,n,r,i,o){const a=[];for(const i of t){const t=n(i),o=r(i);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||a.push({px:e.x(t),py:e.y(o),rawY:o,d:i})}a.sort((t,e)=>t.px-e.px);const l=Array(a.length),s=Array(a.length),c=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];l[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:s,style:i,datum:c,group:o}}function w(t,e,n,r,i,o,a,l){const s=[];for(const o of t){const t=n(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=e.x(t),u=l?l(o):i;s.push({px:c,topY:e.y(a),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:a}}function E(t,e,n,r,i,o,a){const l=n(t),s=r(t);if(null==l||null==s||Number.isNaN(l)||Number.isNaN(s))return null;const c={type:"point",x:e.x(l),y:e.y(s),r:i,style:o,datum:t};return void 0!==a&&(c.pointId=a),c}function A(t,e,n,r,i,o,a){return{type:"rect",x:t,y:e,w:n,h:r,style:i,datum:o,group:a}}function S(t,e,n,r,i,o){return{type:"heatcell",x:t,y:e,w:n,h:r,fill:i,datum:o}}function M(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function L(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class P{constructor(t){this.xExtent=new x,this.yExtent=new x,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new v(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=M(t.timeAccessor||t.xAccessor,"time"),this.getY=M(t.valueAccessor||t.yAccessor,"value")):(this.getX=M(t.xAccessor,"x"),this.getY=M(t.yAccessor,"y")),this.getGroup=L(t.groupAccessor),this.getCategory=L(t.categoryAccessor),this.getSize=t.sizeAccessor?M(t.sizeAccessor,"size"):void 0,this.getColor=L(t.colorAccessor),this.getBounds=t.boundsAccessor?M(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?M(t.y0Accessor,"y0"):void 0,this.getPointId=L(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=M(t.openAccessor,"open"),this.getHigh=M(t.highAccessor,"high"),this.getLow=M(t.lowAccessor,"low"),this.getClose=M(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new v(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();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){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,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,a,l;const{config:s,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(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.xExtent.extent,h=this.yExtent.extent;let d=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:u[0],null!==(n=s.xExtent[1])&&void 0!==n?n:u[1]]:u,f=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 y=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!y&&c.size>0)if(s.normalize)f=[0,1+s.extentPadding];else{const t=c.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);f=[0,r+(r>0?r*s.extentPadding:1)]}else if("bar"===s.chartType&&s.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,r,i){const o=b(t,e,n,r,i);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(c,this.getX,this.getY,s.binSize,this.getCategory);f=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!y&&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;f=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&f[0]!==1/0){if(this.getBounds){const t=c.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}}const t=f[1]-f[0],e=t>0?t*s.extentPadding:1,n=null===(a=s.yExtent)||void 0===a?void 0:a[0],r=null===(l=s.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-e,null!=r?f[1]:f[1]+e]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==s.arrowOfTime)if("x"==("up"===(g=s.arrowOfTime)||"down"===g?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:r.scaleLinear().domain(d).range(e),y:r.scaleLinear().domain(f).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:r.scaleLinear().domain(f).range([0,t.width]),y:r.scaleLinear().domain(d).range(e)}}else this.scales={x:r.scaleLinear().domain(d).range([0,t.width]),y:r.scaleLinear().domain(f).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}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 i=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),l=this.scales.y.range();this.scales={x:r.scaleLinear().domain(i).range([a[0]*e,a[1]*e]),y:r.scaleLinear().domain(o).range([l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:r}=this;if(!r||0===n.size)return[];const i=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,t);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,t);case"candlestick":return this.buildCandlestickScene(i,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),r=[],i=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=k(t.data,this.scales,this.getX,this.getY,e,t.key);i&&i.length>0&&(n.colorThresholds=i),r.push(n)}return r}buildAreaScene(t){const e=this.groupData(t),n=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),i=w(t.data,this.scales,this.getX,this.getY,r,e,t.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),n.push(i)}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,r,i,o){var a;const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||l.add(e)}const s=Array.from(l).sort((t,e)=>t-e),c=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)}c.set(e.key,t)}let u;if(o){u=new Map;for(const e of s){let n=0;for(const r of t)n+=(null===(a=c.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,n||1)}}const h=[],d=new Map;for(const t of s)d.set(t,0);for(const n of t){const t=c.get(n.key),r=[],a=[];for(const n of s){let i=t.get(n)||0;const l=d.get(n);o&&(i/=u.get(n));const s=e.x(n);a.push([s,e.y(l)]),r.push([s,e.y(l+i)]),d.set(n,l+i)}h.push({type:"area",topPath:r,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let i=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),n=Math.max(...e);i=e=>t===n?(r[0]+r[1])/2:r[0]+(e-t)/(n-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,n[r%n.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||n;if(i&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const l=this.getPointId?this.getPointId(r)+"":void 0,s=E(r,this.scales,this.getX,this.getY,a,t,l);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=M(this.config.valueAccessor,"value"),i=new Set,o=new Set;for(const e of t)i.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(i).sort((t,e)=>t-e),l=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===l.length)return n;const s=e.width/a.length,c=e.height/l.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,d=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>d&&(d=t);const f=d-h||1;for(let t=0;a.length>t;t++)for(let e=0;l.length>e;e++){const r=u.get(`${a[t]}_${l[e]}`);if(!r)continue;const i=(r.val-h)/f;n.push(S(t*s,(l.length-1-e)*c,s,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,r.datum))}return n}buildStreamingHeatmapScene(t,e){var n,r,i;const o=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,s=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=M(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/a,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),i=Math.min(Math.floor((n-d)/g),l-1);if(0>r||0>i)continue;const o=`${r}_${i}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),m>n&&(m=n),n>v&&(v=n)}const b=v-m||1,k=e.width/a,w=e.height/l;for(const[t,e]of x){const[n,r]=t.split("_"),i=+n,a=+r,s=(e-m)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(S(i*k,(l-1-a)*w,k,w,c,{xi:i,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=b(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],i=new Set(e),o=Array.from(t).filter(t=>!i.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const i=[],o=this.scales,[a,l]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,a),s=Math.min(t.end,l);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(r&&t.categories.size>0){let n=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=o.y(n),s=o.y(n+r);i.push(A(h,Math.min(l,s),d,Math.abs(l-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),n+=r}}else{const e=o.y(0),n=o.y(t.total);i.push(A(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return i}buildSwarmScene(t){var e,n,r,i;const o=[],a=this.config.swarmStyle||{},l=null!==(e=a.radius)&&void 0!==e?e:3,s=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const r=this.scales.x(t),a=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[t])||d}const f={type:"point",x:r,y:a,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,r,i;const o=[],a=this.scales,l=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],r=this.getX(n),i=this.getY(n),g=y+i;let p;p=s.length-1>t?this.getX(s[t+1])-r:t>0?r-this.getX(s[t-1]):0;const m=a.x(r),v=0!==p?a.x(r+p):m+e.width/10,x=Math.min(m,v)+h/2,b=Math.max(m,v)-h/2-x;if(0>=b){y=g;continue}const k=a.y(y),w=a.y(g);o.push(A(x,Math.min(k,w),b,Math.abs(k-w),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],r=this.config.candlestickStyle||{},i=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",l=r.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=r.bodyWidth||6;if(!r.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=r;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:i,downColor:o,wickColor:a,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],r=[];for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)n.push([a,this.scales.y(i+o)]),r.push([a,this.scales.y(i-o)]);else{const t=this.scales.y(i);n.push([a,t]),r.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}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){var n,r,i;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(n=o.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(o.type){case"linear":return a+(1-l/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(i=o.stepThreshold)&&void 0!==i?i:.5*e)>l?1:a;default:return 1}}applyDecay(t,e){var n,r;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,i);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var n;const r=this.config.pulse;if(!r)return 0;const i=null!==(n=r.duration)&&void 0!==n?n:500,o=e-t;return i>o?1-o/i:0}applyPulse(t,e){var n,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let n=0;for(const e of t){const t=l.get(e);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=this.computePulseIntensity(r,i);o>n&&(n=o)}n>0&&(e._pulseIntensity=n,e._pulseColor=o);continue}const t=l.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const r=this.computePulseIntensity(n,i);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&n>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeIdentity(e,t);n&&("point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(n,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var n,r,i,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,n,r,i,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let l=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],s=this.getNodeIdentity(a,t);if(!s)continue;const c=this.prevPositionMap.get(s);if(c)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=c.x,a.y=c.y,a.r=null!==(e=c.r)&&void 0!==e?e:a.r,l=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(r=c.h)&&void 0!==r?r:a.h,l=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(i=c.w)&&void 0!==i?i:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}if(n>=1){for(const t of this.scene)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}return this.activeTransition=null,!1}return!0}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}))}resolveLineStyle(t,e){const n=this.config.lineStyle;return"function"==typeof n?n(e||{},t):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:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],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){Object.assign(this.config,t),this.needsFullRebuild=!0}}function D(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 $(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function _(t,e,n){const r=e-t.x,i=n-t.y,o=Math.sqrt(r*r+i*i);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function W(t,e,n){if(0===t.path.length)return null;const r=R(t.path,e);if(0>r)return null;const[i,o]=t.path[r],a=e-i,l=n-o,s=Math.sqrt(a*a+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:i,y:o,distance:s}}function C(t,e,n){const r=D(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function T(t,e,n){const r=D(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function N(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,a=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(o*o+a*a)}}return null}function O(t,e,n){if(0===t.topPath.length)return null;const r=R(t.topPath,e);if(0>r)return null;const[i,o]=t.topPath[r],a=e-i,l=n-o;return{node:t,datum:t.datum,x:i,y:o,distance:Math.sqrt(a*a+l*l)}}function R(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 I(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function z(e,n,r){const i=t.useRef(null),[o,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!r)return;const t=i.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,r]),[i,[n&&o?o.w:e[0],r&&o?o.h:e[1]]]}function B(e,n,r,i,o,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const l=n.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=s-l.lastIngestTime>c;u!==o&&(a(u),r.current=!0,i())},1e3);return()=>clearInterval(t)},[e,o,i])}const Y={fill:t=>y.createElement("rect",{style:t,width:20,height:20}),line:t=>y.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function F(t,e,n,r){let i;return i="function"==typeof n?n(t):(0,Y[n])(r(t,e)),i}function j(){return y.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function H(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function X(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,title:a="Legend",width:l=100,height:s=20,orientation:c="vertical"}=t,u="vertical"===c?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o})=>{let a=30;const l=[];return t.forEach((t,s)=>{a+=5,l.push(y.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:a,x2:e,y2:a})),a+=10,t.label&&(a+=20,l.push(y.createElement("text",{key:"legend-text-"+s,y:a,className:"legend-group-label"},t.label)),a+=10),l.push(y.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${a})`},((t,e,n,r,i)=>{const{type:o="fill",styleFn:a,items:l}=t,s=[];let c=0;const u=!(!e&&!n);return l.forEach((t,l)=>{const h=F(t,l,o,a),d=H(t,r,i),f=i&&i.size>0&&i.has(t.label);s.push(y.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${c})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:u?"pointer":"default",opacity:d,transition:"opacity 150ms ease",pointerEvents:"all"}},f&&y.createElement(j,null),h,y.createElement("text",{y:15,x:30},t.label))),c+=25}),s})(t,n,r,i,o))),a+=25*t.items.length+10}),l})({legendGroups:e,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o}):(({legendGroups:t,title:e,height:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:a})=>{let l=0;const s=[],c=!1===e?10:40;return t.forEach((e,u)=>{e.label&&(s.push(y.createElement("text",{key:"legend-text-"+u,transform:`translate(${l},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},e.label)),l+=20);const h=((t,e,n,r,i)=>{const{type:o="fill",styleFn:a,items:l}=t,s=[];let c=0;const u=!(!e&&!n);return l.forEach((t,l)=>{const h=F(t,l,o,a),d=H(t,r,i),f=i&&i.size>0&&i.has(t.label);s.push(y.createElement("g",{key:"legend-item-"+l,transform:`translate(${c},0)`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:u?"pointer":"default",opacity:d,transition:"opacity 150ms ease",pointerEvents:"all"}},f&&y.createElement(j,null),h,y.createElement("text",{y:15,x:25},t.label))),c+=35,c+=8*t.label.length}),{items:s,offset:c}})(e,r,i,o,a);s.push(y.createElement("g",{key:"legend-group-"+u,className:"legend-item",transform:`translate(${l},${c})`},h.items)),l+=h.offset+5,t[u+1]&&s.push(y.createElement("line",{key:"legend-top-line legend-symbol-"+u,stroke:"gray",x1:l,y1:c-10,x2:l,y2:n+c+10})),l+=15}),y.createElement("g",null,!1!==e&&y.createElement("line",{x1:0,x2:l+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:e,title:a,height:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o});return y.createElement("g",null,void 0!==a&&y.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:l/2,textAnchor:"horizontal"===c?"start":"middle"},a),u)}function G(t){return"string"==typeof t?{type:t}:t}function V({orient:e,config:n,values:r,scale:o,size:a,length:l}){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}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===r.length)return null;const t=o.domain(),n=a-8;if("boxplot"===s.type){const t=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)],a=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(e[0],r-1.5*a),whiskerHigh:Math.min(e[n-1],o+1.5*a)}}(r);if(!t)return null;const{q1:i,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),f=(n-d)/2+4;if(c){const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="top"===e?-1:1,m=0;return y.createElement("g",{"data-testid":"marginal-boxplot-"+e},y.createElement("line",{x1:c,y1:m+p*(f+d/2),x2:g,y2:m+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:g,y1:m+p*f,x2:g,y2:m+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-f-d:m+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:r,y1:"top"===e?m-f-d:m+f,x2:r,y2:"top"===e?m-f:m+f+d,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="left"===e?-1:1,m=0;return y.createElement("g",{"data-testid":"marginal-boxplot-"+e},y.createElement("line",{x1:m+p*(f+d/2),y1:c,x2:m+p*(f+d/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:m+p*f,y1:g,x2:m+p*(f+d),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),y.createElement("rect",{x:"left"===e?m-f-d:m+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),y.createElement("line",{x1:"left"===e?m-f-d:m+f,y1:r,x2:"left"===e?m-f:m+f+d,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=i.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return y.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,r)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/h*n;if(c){const n=o(t.x0),a=o(t.x1)-o(t.x0);return y.createElement("rect",{key:r,x:n,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(t.x0),a=o(t.x1)-o(t.x0);return y.createElement("rect",{key:r,x:"left"===e?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/h*(n/2),l=o((i.x0+i.x1)/2);r.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=o((a.x0+a.x1)/2);r.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${s}`)}return y.createElement("g",{"data-testid":"marginal-violin-"+e},y.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const t=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${a},${"top"===e?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${a},${r}`),t.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${r},${a}`),t.push("Z")}return y.createElement("g",{"data-testid":"marginal-ridgeline-"+e},y.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,a,l,e,c,4]);return u?y.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function q(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),o=[];let a="";for(const t of i)a&&a.length+1+t.length>r?(o.push(a),a=t):a=a?`${a} ${t}`:t;return a&&o.push(a),o}function Z(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 K(t){const{x:e=0,y:n=0,dx:r,dy:i,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:d,disable:f,events:g={},"data-testid":p}=t,m=new Set(Array.isArray(f)?f:[]);let v=r||0,x=i||0;null!=o&&(v=o-e),null!=a&&(x=a-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===v&&0===x)if(void 0!==c.width){v=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;v=t+(0>t?-5:5),x=c.height/2}return y.createElement("g",Object.assign({className:("annotation "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},g),!m.has("connector")&&function(t,e,n,r,i,o){const a=[];let l=0,s=0;if("callout-circle"!==i&&"label"!==i||!(null==o?void 0:o.radius)){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,a=t-i,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;l=i+a*d,s=o+c*d}}}else if("bracket"===i&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);l=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(y.createElement("line",{key:"connector-line",x1:l,y1:s,x2:t,y2:e,stroke:r||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(y.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+i)},${s+n*Math.sin(o+i)}L${l+n*Math.cos(o-i)},${s+n*Math.sin(o-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return y.createElement("g",{className:"annotation-connector"},a)}(v,x,s,h,b,c),!m.has("subject")&&function(t,e,n,r,i){var o;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.push(y.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,r=(null==e?void 0:e.height)||0;(t>0||r>0)&&a.push(y.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&a.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,o=i||0;if(void 0!==(null==e?void 0:e.x)){const r=(e.x||0)-t;a.push(y.createElement("line",{key:"threshold-line",x1:r,y1:(e.y1||0)-o,x2:r,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const r=(e.y||0)-o;a.push(y.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?a.push(y.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||a.push(y.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(y.createElement("path",{key:"bracket-path",d:Z((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return y.createElement("g",{className:"annotation-subject"},a)}(b,c,h,e,n),!m.has("note")&&function(t,e,n,r){if(!t)return y.createElement("g",{className:"annotation-note"});const{label:i,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!i&&!o)return y.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,g=o?c?[o]:q(o,s):[],p=i?c?[i]:q(i,s):[],m="leftRight"===u?"end"===d?-4:4:0;let v=0;const x=[];g.length>0&&(x.push(y.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:d,fontWeight:"bold"},g.map((t,e)=>y.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t)))),v=g.length*f),p.length>0&&x.push(y.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:d,y:v},p.map((t,e)=>y.createElement("tspan",{key:e,x:m,dy:0===e?0:f},t))));let b=null;if((o||i)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=y.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(g.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=y.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),y.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},y.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,v,x,h))}function U(t){var e,n;const{noteData:r}=t,{screenCoordinates:i}=r,o="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(e=r.dx)&&void 0!==e?e:0),a=r.ny||i[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),l=i.map((e,n)=>{const i=Object.assign({},r,{note:0===n?r.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return y.createElement(K,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:o}))});return y.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return y.createElement(K,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:a},r,{type:o}))}function Q(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 J(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 tt(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}function et(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 a="M0,"+r;for(let t=0;o>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${r+4*i}`,a+=`L${Math.min(n,e)},${r}`}return a}{const r="bottom"===t?0:e,i="bottom"===t?1:-1,o=Math.ceil(n/8);let a=`M${r},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${r+4*i},${Math.min(8*t+4,n)}`,a+=`L${r},${Math.min(e,n)}`}return a}}function nt(t){return Math.round(100*t)/100+""}function rt(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function it(e){const{width:n,height:r,totalWidth:i,totalHeight:a,margin:l,scales:s,showAxes:c,axes:u,xLabel:h,yLabel:d,xFormat:f,yFormat:p,showGrid:m,title:v,legend:x,legendHoverBehavior:b,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:E,foregroundGraphics:A,marginalGraphics:S,xValues:M,yValues:L,annotations:P,svgAnnotationRules:D,annotationFrame:$,xAccessor:_,yAccessor:W,annotationData:C,pointNodes:T,children:N}=e,O=t.useMemo(()=>c&&s?s.x.ticks(5).map(t=>({value:t,pixel:s.x(t),label:(f||nt)(t)})):[],[c,s,f]),R=t.useMemo(()=>c&&s?s.y.ticks(5).map(t=>({value:t,pixel:s.y(t),label:(p||nt)(t)})):[],[c,s,p]),I=t.useMemo(()=>{if(!P||0===P.length)return null;const t=function(t,e,n){var r,i,a,l,s,c,u,h,d,f,p,m,v,x,b,k,w,E,A,S,M,L,P,D,$,_,W,C,T,N,O,R,I,z,B,Y,F,j,H,X,G,V,q,Z;switch(t.type){case"label":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Q(t,n),i=J(t,n);return null==r||null==i?null:tt(r,i,n)?y.createElement(U,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Q(t,n),i=J(t,n);return null==r||null==i?null:tt(r,i,n)?y.createElement(U,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=Q(t,n);if(null==r)return null;const i=t.color||"#f97316";return y.createElement("g",{key:"ann-"+e},y.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&y.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=J(t,n);if(null==r)return null;const i=t.color||"#f97316";return y.createElement("g",{key:"ann-"+e},y.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&y.createElement("text",{x:(n.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(t=>({x:Q(Object.assign(Object.assign({},t),{type:"point"}),n),y:J(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=o.packEnclose(r),a=t.padding||10;return y.createElement("g",{key:"ann-"+e},y.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&y.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:Q(Object.assign(Object.assign({},t),{type:"point"}),n),y:J(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=t.padding||10,o=r.map(t=>t.x),a=r.map(t=>t.y),l=Math.min(...o)-i,s=Math.max(...o)+i,c=Math.min(...a)-i,u=Math.max(...a)+i;return y.createElement("g",{key:"ann-"+e},y.createElement("rect",{x:l,y:c,width:s-l,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&y.createElement("text",{x:(l+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=n.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],o=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return y.createElement("g",{key:"ann-"+e},i.map((e,r)=>{const i=Q(e,n),a=J(e,n);return null==i||null==a?null:y.createElement("circle",Object.assign({key:r,cx:i,cy:a,r:t.r||6},o))}))}case"bracket":{const r=Q(t,n),i=J(t,n);return y.createElement(U,{key:"ann-"+e,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const o=n.data||[];if(2>o.length)return null;const h=n.xAccessor||"x",d=n.yAccessor||"y",f=o.map(t=>[t[h],t[d]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>f.length)return null;const p=null!==(i=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=n.scales)||void 0===a?void 0:a.time,m=null!==(s=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==s?s:null===(c=n.scales)||void 0===c?void 0:c.value;if(!p||!m)return null;const v=t.method||"linear";let x;x="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]),a=Math.max(2,Math.ceil(e*n)),l=[];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(a-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,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*i[t],d+=e*o[t],f+=e*i[t]*i[t],y+=e*i[t]*o[t])}if(0===u){l.push([e,o[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([e,d/u]);else{const t=(u*y-h*d)/g;l.push([e,(d-t*h)/u+t*e])}}return l}(f,null!==(u=t.bandwidth)&&void 0!==u?u:.3):("polynomial"===v?g.default.polynomial(f,{order:t.order||2}):g.default.linear(f)).points;const b=x.map(([t,e])=>`${p(t)},${m(e)}`).join(" "),k=t.color||"#6366f1";return y.createElement("g",{key:"ann-"+e},y.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&y.createElement("text",{x:p(x[x.length-1][0])+4,y:m(x[x.length-1][1])-4,fill:k,fontSize:11},t.label))}case"band":{const r=null!==(d=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(f=n.scales)||void 0===f?void 0:f.value,i=null!==(p=null==r?void 0:r(t.y0))&&void 0!==p?p:0,o=null!==(m=null==r?void 0:r(t.y1))&&void 0!==m?m:n.height||0;return y.createElement("g",{key:"ann-"+e},y.createElement("rect",{x:0,y:Math.min(i,o),width:n.width||0,height:Math.abs(o-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&y.createElement("text",{x:(n.width||0)-4,y:Math.min(i,o)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const r=n.data||[];if(2>r.length)return null;const i=n.xAccessor||"x",o=null!==(x=null===(v=n.scales)||void 0===v?void 0:v.x)&&void 0!==x?x:null===(b=n.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(k=n.scales)||void 0===k?void 0:k.y)&&void 0!==w?w:null===(E=n.scales)||void 0===E?void 0:E.value;if(!o||!a)return null;const l=t.upperAccessor||"upperBounds",s=t.lowerAccessor||"lowerBounds",c=t.filter,u=r.filter(t=>null!=t[l]&&null!=t[s]&&!(c&&!c(t))).sort((t,e)=>t[i]-e[i]);if(2>u.length)return null;const h=u.map(t=>`${o(t[i])},${a(t[l])}`).join(" L"),d=u.slice().reverse().map(t=>`${o(t[i])},${a(t[s])}`).join(" L"),f=t.fill||"#6366f1";return y.createElement("g",{key:"ann-"+e},y.createElement("path",{d:`M${h} L${d} Z`,fill:f,fillOpacity:null!==(A=t.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),t.label&&u.length>0&&y.createElement("text",{x:o(u[u.length-1][i])+4,y:a(u[u.length-1][l])-4,fill:f,fontSize:11},t.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const i=n.yAccessor||"y",o=null!==(M=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==M?M:null===(L=n.scales)||void 0===L?void 0:L.time,a=null!==(D=null===(P=n.scales)||void 0===P?void 0:P.y)&&void 0!==D?D:null===($=n.scales)||void 0===$?void 0:$.value;if(!o||!a)return null;const l=r.map(t=>t[i]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),h=null!==(_=t.threshold)&&void 0!==_?_:2,d=s-h*u,f=!1!==t.showBand,g=t.fill||"#6366f1",p=null!==(W=t.fillOpacity)&&void 0!==W?W:.1,m=t.anomalyColor||"#ef4444",v=null!==(C=t.anomalyRadius)&&void 0!==C?C:6,x=a(s+h*u),b=a(d),k=r.filter(t=>{const e=t[i];return null!=e&&Math.abs(e-s)>h*u});return y.createElement("g",{key:"ann-"+e},f&&y.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((t,e)=>{const r=Q(t,n),i=J(t,n);return null==r||null==i?null:y.createElement("circle",{key:e,cx:r,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&y.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},t.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(N=null===(T=n.scales)||void 0===T?void 0:T.x)&&void 0!==N?N:null===(O=n.scales)||void 0===O?void 0:O.time,l=null!==(I=null===(R=n.scales)||void 0===R?void 0:R.y)&&void 0!==I?I:null===(z=n.scales)||void 0===z?void 0:z.value;if(!a||!l)return null;const s=r.map(t=>[t[i],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=g.default.polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}else{const t=s.length;let e=0,n=0,r=0,i=0;for(const[t,o]of s)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 a=(t*i-e*n)/o,l=(n-a*e)/t;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=s.reduce((t,e)=>t+e[0],0)/u,p=s.reduce((t,e)=>t+Math.pow(e[0]-f,2),0),m=null!==(B=t.confidence)&&void 0!==B?B:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,x=null!==(Y=t.steps)&&void 0!==Y?Y:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const E=[];for(const t of w){const e=c(t),n=d*Math.sqrt(1+1/u+(p>0?Math.pow(t-f,2)/p:0))*v;E.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const A=`M${E.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${E.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,S=E.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),M=`${a(b)},${l(c(b))}`,L=t.strokeColor||"#6366f1";return y.createElement("g",{key:"ann-"+e},y.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(F=t.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),y.createElement("polyline",{points:`${M} ${S}`,fill:"none",stroke:L,strokeWidth:null!==(j=t.strokeWidth)&&void 0!==j?j:2,strokeDasharray:null!==(H=t.strokeDasharray)&&void 0!==H?H:"6,3"}),t.label&&E.length>0&&y.createElement("text",{x:a(E[E.length-1].x)+4,y:l(E[E.length-1].yCenter)-4,fill:L,fontSize:11},t.label))}case"widget":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else null!=t.px&&null!=t.py?(r=t.px,i=t.py):(r=Q(t,n),i=J(t,n));if(null==r||null==i)return null;if(!tt(r,i,n))return null;const o=null!==(X=t.dx)&&void 0!==X?X:0,a=null!==(G=t.dy)&&void 0!==G?G:0,l=null!==(V=t.width)&&void 0!==V?V:32,s=null!==(q=t.height)&&void 0!==q?q:32,c=null!==(Z=t.content)&&void 0!==Z?Z:y.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return y.createElement("foreignObject",{key:"ann-"+e,x:r+o-l/2,y:i+a-s/2,width:l,height:s,style:{overflow:"visible",pointerEvents:"auto"}},y.createElement("div",{style:{width:l,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const r=Q(t,n),i=J(t,n);return null==r||null==i?null:y.createElement("text",{key:"ann-text-"+e,x:r+(t.dx||0),y:i+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},e={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:_,yAccessor:W,width:n,height:r,data:C,frameType:"xy",pointNodes:T};return P.map((n,r)=>{if(D){const i=D(n,r,e);return null!=i?i:t(n,r,e)}return t(n,r,e)}).filter(Boolean)},[P,D,n,r,$,_,W,C]);return c||v||x||A||S||I&&I.length>0||m||N?y.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},y.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&s&&y.createElement("g",{className:"stream-grid"},O.map((t,e)=>y.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),R.map((t,e)=>y.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&s&&(()=>{const t=null==u?void 0:u.find(t=>"left"===t.orient),e=null==u?void 0:u.find(t=>"bottom"===t.orient),i=!t||!1!==t.baseline,o=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,s=null==e?void 0:e.landmarkTicks,c=null==t?void 0:t.landmarkTicks,f="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return y.createElement("g",{className:"stream-axes"},(!e||!1!==e.baseline)&&!a&&y.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:f,strokeWidth:1}),a&&y.createElement("path",{d:et("bottom",n,r),fill:"none",stroke:f,strokeWidth:1}),O.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):rt(t.value,e>0?O[e-1].value:void 0));return y.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${r})`},y.createElement("line",{y2:5,stroke:f,strokeWidth:1}),y.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"}},t.label))}),h&&y.createElement("text",{x:n/2,y:r+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},h),i&&!o&&y.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:f,strokeWidth:1}),o&&y.createElement("path",{d:et("left",n,r),fill:"none",stroke:f,strokeWidth:1}),R.map((t,e)=>{const n=!!c&&("function"==typeof c?c(t.value,e):rt(t.value,e>0?R[e-1].value:void 0));return y.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},y.createElement("line",{x2:-5,stroke:f,strokeWidth:1}),y.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:g,style:{userSelect:"none"}},t.label))}),d&&y.createElement("text",{x:15-l.left,y:r/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-l.left}, ${r/2})`,style:{userSelect:"none"}},d))})(),I,S&&s&&M&&L&&y.createElement(y.Fragment,null,S.top&&y.createElement("g",{transform:"translate(0, 0)"},y.createElement(V,{orient:"top",config:G(S.top),values:M,scale:s.x,size:l.top,length:n})),S.bottom&&y.createElement("g",{transform:`translate(0, ${r})`},y.createElement(V,{orient:"bottom",config:G(S.bottom),values:M,scale:s.x,size:l.bottom,length:n})),S.left&&y.createElement("g",{transform:"translate(0, 0)"},y.createElement(V,{orient:"left",config:G(S.left),values:L,scale:s.y,size:l.left,length:r})),S.right&&y.createElement("g",{transform:`translate(${n}, 0)`},y.createElement(V,{orient:"right",config:G(S.right),values:L,scale:s.y,size:l.right,length:r}))),A,N),v&&y.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof v?v:null),x&&y.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},function(t){return"object"==typeof t&&null!==t&&!y.isValidElement(t)&&"legendGroups"in t}(x)?y.createElement(X,{legendGroups:x.legendGroups,title:"",width:100,customHoverBehavior:b,customClickBehavior:k,highlightedCategory:w,isolatedCategories:E}):x)):null}const ot="undefined"==typeof window||"undefined"==typeof document;function at(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 lt(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 st(t,e){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()}const ct=(t,e,n,r)=>{var i;const o=e.filter(t=>"area"===t.type);for(const e of o){if(2>e.topPath.length)continue;st(t,e);const n=e.style.fill||"#4e79a7";if(e.fillGradient){const r=Math.min(...e.topPath.map(t=>t[1])),i=Math.max(...e.bottomPath.map(t=>t[1])),o=t.createLinearGradient(0,r,0,i);o.addColorStop(0,n),o.addColorStop(1,n),t.fillStyle=o;const a=lt(n),l=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,r,0,i);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${l})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${s})`),t.fillStyle=c,t.globalAlpha=1}else{const r=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.globalAlpha=r,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(st(t,e),t.globalAlpha=.35*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill()),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=1,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]),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]);t.stroke()}t.globalAlpha=1}},ut=(t,e,n,r)=>{var i,o;const a=e.filter(t=>"point"===t.type);for(const e of a){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;if(null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.x,e.y,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},ht=(t,e,n,r)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?dt(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1};function dt(t,e){const n=e.style.icon,r=e.style.iconPadding||2,i=Math.min(e.w,e.w)-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,a=e.x+(e.w-i)/2;for(let r=e.y+e.h-i;r>=e.y-i;r-=o)t.drawImage(n,a,r,i,i)}else{const o=i+r,a=e.y+(e.h-i)/2;for(let r=e.x;e.x+e.w>r;r+=o)t.drawImage(n,r,a,i,i)}t.restore()}const ft={line:[ct,(t,e,n,r)=>{const i=e.filter(t=>"line"===t.type);for(const o of i){if(2>o.path.length)continue;const a=o.style.stroke||"#007bff",l=o.style.strokeWidth||2,s=o.colorThresholds,c=o.rawValues;if(t.setLineDash(o.style.strokeDasharray?o.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=o.style.opacity&&(t.globalAlpha=o.style.opacity),t.lineWidth=l,s&&0!==s.length&&c&&c.length===o.path.length){let u=null,h=null,d=null,f=null,y=!1;function g(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),y=!0}function p(){y&&(t.stroke(),y=!1)}for(let m=0;o.path.length>m;m++){const[v,x]=o.path[m],b=c[m],k=at(b,s,a);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(v,x);else{const w=[];for(const E of s){const A=E.value;(d>A||A>b)&&(A>d||b>A)||d===A||b===A||w.push({t:(A-d)/(b-d)})}w.sort((t,e)=>t.t-e.t);for(const S of w){const M=u+(v-u)*S.t,L=h+(x-h)*S.t,P=at(d+(b-d)*Math.min(S.t+1e-4,1),s,a);t.lineTo(M,L),p(),g(P,M,L)}t.lineTo(v,x)}u=v,h=x,d=b,f=k}else g(k,v,x),u=v,h=x,d=b,f=k}p()}else{t.beginPath(),t.strokeStyle=a;const[D,$]=o.path[0];t.moveTo(D,$);for(let _=1;o.path.length>_;_++)t.lineTo(o.path[_][0],o.path[_][1]);t.stroke()}if(o.style.fill&&o.style.fillOpacity&&o.style.fillOpacity>0){t.beginPath(),t.globalAlpha=o.style.fillOpacity,t.fillStyle=o.style.fill;const[W,C]=o.path[0];t.moveTo(W,C);for(let N=1;o.path.length>N;N++)t.lineTo(o.path[N][0],o.path[N][1]);const T=o.path[0][0];t.lineTo(o.path[o.path.length-1][0],r.height),t.lineTo(T,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[ct],stackedarea:[ct],scatter:[ut],bubble:[ut],heatmap:[(t,e,n,r)=>{const i=e.filter(t=>"heatcell"===t.type);for(const e of i){const n=e.style;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),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1}}],bar:[ht],swarm:[ut],waterfall:[(t,e,n,r)=>{var i,o,a;ht(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const s=l[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;l.length-1>e;e++){const r=l[e],i=l[e+1];if(!(null===(o=r.datum)||void 0===o?void 0:o.cumEnd)||!(null===(a=i.datum)||void 0===a?void 0:a.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.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const r=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1))}}]},yt={top:20,right:20,bottom:30,left:40},gt={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"},pt={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 mt({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return y.createElement("div",{className:"semiotic-tooltip",style:pt},y.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),y.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function vt({width:r,height:i,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),d=t.useRef(null),f=t.useRef(u);f.current=u;const g=t.useRef(c);return g.current=c,t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[r,i]]),o.on("brush end",t=>{const e=g.current;if(!e)return;if(!t.selection)return void f.current(null);let n,o;if("x"===s){const[r,a]=t.selection;n=[e.x.invert(r),e.x.invert(a)],o=[e.y.invert(i),e.y.invert(0)]}else if("y"===s){const[i,a]=t.selection;n=[e.x.invert(0),e.x.invert(r)],o=[e.y.invert(a),e.y.invert(i)]}else{const[[r,i],[a,l]]=t.selection;n=[e.x.invert(r),e.x.invert(a)],o=[e.y.invert(l),e.y.invert(i)]}f.current({x:n,y:o})}),t.call(o),d.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),d.current=null}},[r,i,s]),y.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},y.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const xt=t.forwardRef(function(e,n){var r,i,o,a,l;const{chartType:s,runtimeMode:c,data:u,xAccessor:h,yAccessor:d,colorAccessor:f,sizeAccessor:g,groupAccessor:p,lineDataAccessor:v,normalize:x,binSize:b,valueAccessor:k,arrowOfTime:w="right",windowMode:E="sliding",windowSize:A=200,timeAccessor:S,xExtent:M,yExtent:L,extentPadding:D=.1,sizeRange:$,size:R=[500,300],responsiveWidth:Y,responsiveHeight:F,margin:j,className:H,background:X,lineStyle:G,pointStyle:V,areaStyle:q,waterfallStyle:Z,swarmStyle:K,barColors:U,colorScheme:Q,boundsAccessor:J,boundsStyle:tt,y0Accessor:et,gradientFill:nt,openAccessor:rt,highAccessor:at,lowAccessor:lt,closeAccessor:st,candlestickStyle:ct,showAxes:ut=!0,axes:ht,xLabel:dt,yLabel:pt,xFormat:xt,yFormat:bt,tickFormatTime:kt,tickFormatValue:wt,hoverAnnotation:Et,tooltipContent:At,customHoverBehavior:St,enableHover:Mt,annotations:Lt,svgAnnotationRules:Pt,showGrid:Dt,legend:$t,legendHoverBehavior:_t,legendClickBehavior:Wt,legendHighlightedCategory:Ct,legendIsolatedCategories:Tt,backgroundGraphics:Nt,foregroundGraphics:Ot,title:Rt,categoryAccessor:It,brush:zt,onBrush:Bt,decay:Yt,pulse:Ft,transition:jt,staleness:Ht,heatmapAggregation:Xt,heatmapXBins:Gt,heatmapYBins:Vt,marginalGraphics:qt,pointIdAccessor:Zt}=e,[Kt,Ut]=z(R,Y,F),Qt=Object.assign(Object.assign({},yt),j);if(qt){const t=60;qt.top&&t>Qt.top&&(Qt.top=t),qt.bottom&&t>Qt.bottom&&(Qt.bottom=t),qt.left&&t>Qt.left&&(Qt.left=t),qt.right&&t>Qt.right&&(Qt.right=t)}const Jt=Ut[0]-Qt.left-Qt.right,te=Ut[1]-Qt.top-Qt.bottom,ee=null!=Et?Et:Mt,ne=t.useRef(null),re=t.useRef(null),ie=t.useRef(0),oe=t.useRef(!1),[ae,le]=t.useState(0),[se,ce]=t.useState(null),ue=t.useRef(null),he=t.useRef(null),[de,fe]=t.useState(null),[ye,ge]=t.useState(!1),[pe,me]=t.useState([]),[ve,xe]=t.useState([]),be=t.useRef(()=>{}),ke="streaming"===c||["bar","swarm","waterfall"].includes(s),we=t.useMemo(()=>({chartType:s,runtimeMode:ke?"streaming":"bounded",windowSize:A,windowMode:E,arrowOfTime:ke?w:"right",extentPadding:D,xAccessor:ke?void 0:h,yAccessor:ke?void 0:d,timeAccessor:ke?S:void 0,valueAccessor:k,colorAccessor:f,sizeAccessor:g,groupAccessor:p,categoryAccessor:It,lineDataAccessor:v,xExtent:M,yExtent:L,sizeRange:$,binSize:b,normalize:x,boundsAccessor:J,boundsStyle:tt,y0Accessor:et,gradientFill:"boolean"==typeof nt?nt?{topOpacity:.8,bottomOpacity:.05}:void 0:nt,openAccessor:rt,highAccessor:at,lowAccessor:lt,closeAccessor:st,candlestickStyle:ct,lineStyle:G,pointStyle:V,areaStyle:q,swarmStyle:K,waterfallStyle:Z,colorScheme:Q,barColors:U,annotations:Lt,decay:Yt,pulse:Ft,transition:jt,staleness:Ht,heatmapAggregation:Xt,heatmapXBins:Gt,heatmapYBins:Vt,pointIdAccessor:Zt}),[s,A,E,w,D,h,d,S,k,f,g,p,It,v,M,L,$,b,x,J,tt,et,nt,rt,at,lt,st,ct,G,V,q,K,Z,Q,U,Lt,Yt,Ft,jt,Ht,Xt,Gt,Vt,ke,Zt]),Ee=t.useRef(null);Ee.current||(Ee.current=new P(we));const Ae=t.useCallback(()=>{ie.current||(ie.current=requestAnimationFrame(()=>be.current()))},[]);t.useEffect(()=>{var t;null===(t=Ee.current)||void 0===t||t.updateConfig(we),oe.current=!0,Ae()},[we,Ae]);const Se=t.useRef(null);Se.current||(Se.current=new m(t=>{const e=Ee.current;e&&e.ingest(t)&&(oe.current=!0,Ae())}));const Me=t.useCallback(t=>{var e;null===(e=Se.current)||void 0===e||e.push(t)},[]),Le=t.useCallback(t=>{var e;null===(e=Se.current)||void 0===e||e.pushMany(t)},[]),Pe=t.useCallback(()=>{var t,e;null===(t=Se.current)||void 0===t||t.clear(),null===(e=Ee.current)||void 0===e||e.clear(),oe.current=!0,Ae()},[Ae]);t.useImperativeHandle(n,()=>({push:Me,pushMany:Le,clear:Pe,getData:()=>{var t,e;return null!==(e=null===(t=Ee.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Ee.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Ee.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Me,Le,Pe]),t.useEffect(()=>{var t;u&&(null===(t=Se.current)||void 0===t||t.setBoundedData(u))},[u]);const De=t.useRef(()=>{}),$e=t.useRef(()=>{});De.current=t=>{if(!ee)return;const e=ne.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Qt.left,i=t.clientY-n.top-Qt.top;if(0>r||r>Jt||0>i||i>te)return void(ue.current&&(ue.current=null,he.current=null,fe(null),St&&(St(null),oe.current=!0),Ae()));const o=Ee.current;if(!o||0===o.scene.length)return;const a=function(t,e,n,r=30){let i=null;for(const o of t){let t=null;switch(o.type){case"point":t=_(o,e,n);break;case"line":t=W(o,e,n);break;case"rect":t=C(o,e,n);break;case"heatcell":t=T(o,e,n);break;case"area":if(!1===o.interactive)break;t=O(o,e,n);break;case"candlestick":t=N(o,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(o.scene,r,i);if(!a)return void(ue.current&&(ue.current=null,he.current=null,fe(null),St&&St(null),Ae()));const l={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};ue.current=l,he.current=a.node,fe(l),St&&(St(l),oe.current=!0),Ae()},$e.current=()=>{ue.current&&(ue.current=null,he.current=null,fe(null),St&&(St(null),oe.current=!0),Ae())},t.useCallback(t=>De.current(t),[]);const _e=t.useCallback(()=>$e.current(),[]),We=t.useRef(-1),Ce=t.useCallback(t=>{const e=Ee.current;if(!e||0===e.scene.length)return;const n=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const t=n,r=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.path.length>n&&r.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:r[n]});break}case"area":{const t=n,r=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.topPath.length>n&&r.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:r[n]});break}case"rect":case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===n.length)return;const r=0>We.current?-1:We.current,i=I(t.key,0>r?-1:r,n.length);if(null===i)return;if(t.preventDefault(),0>i)return We.current=-1,ue.current=null,he.current=null,fe(null),St&&St(null),void Ae();const o=0>r?0:i;We.current=o;const a={data:(l=n[o]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;ue.current=a,fe(a),St&&St(a),Ae()},[St,Ae]),Te=t.useCallback(t=>{We.current=-1,De.current(t)},[]);be.current=()=>{var t,e;ie.current=0;const n=ne.current,r=re.current;if(!n||!r)return;const i=Ee.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=i.advanceTransition(o),l=oe.current||a;l&&!a&&i.computeScene({width:Jt,height:te});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return gt;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(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=i||e.getPropertyValue("--surface-0").trim();return o||a||n?{axisStroke:l||gt.axisStroke,tickText:o||gt.tickText,crosshair:o?o+"66":gt.crosshair,hoverFill:s?s+"4D":gt.hoverFill,hoverStroke:o?o+"99":gt.hoverStroke,pointRing:s||gt.pointRing}:gt}(n),f=null!==(t=null==Ht?void 0:Ht.threshold)&&void 0!==t?t:5e3,y=Ht&&i.lastIngestTime>0&&o-i.lastIngestTime>f;if(l){const t=n.getContext("2d");if(t){n.width=Ut[0]*c,n.height=Ut[1]*c,n.style.width=Ut[0]+"px",n.style.height=Ut[1]+"px",t.scale(c,c),t.translate(Qt.left,Qt.top),t.clearRect(-Qt.left,-Qt.top,Ut[0],Ut[1]),y&&(t.globalAlpha=null!==(e=null==Ht?void 0:Ht.dimOpacity)&&void 0!==e?e:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=X||(r&&"transparent"!==r?r:null);o&&(t.fillStyle=o,t.fillRect(-Qt.left,-Qt.top,Ut[0],Ut[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Jt,te),t.clip());const a=ft[s];if(a&&i.scales)for(const e of a)e(t,i.scene,i.scales,{width:Jt,height:te});t.restore(),y&&(t.globalAlpha=1)}}{const t=r.getContext("2d");if(t&&(r.width=Ut[0]*c,r.height=Ut[1]*c,r.style.width=Ut[0]+"px",r.style.height=Ut[1]+"px",t.scale(c,c),t.translate(Qt.left,Qt.top),ee&&ue.current&&i.scales&&function(t,e,n,r,i,o,a){if(!1===i.crosshair)return;t.save();const l="object"==typeof i.crosshair?i.crosshair:{};t.strokeStyle=l.stroke||a.crosshair,t.lineWidth=l.strokeWidth||1,t.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,r),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}(t,ue.current,Jt,te,"object"==typeof ee?ee:{},0,u),he.current&&Array.isArray(Et))){const e=Et.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,he.current,e)}}const g=oe.current;if(oe.current=!1,g&&i.scales&&(ce(i.scales),qt)){const t=i.getData(),e="function"==typeof h?h:t=>t[h||"x"],n="function"==typeof d?d:t=>t[d||"y"];me(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),xe(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}g&&Lt&&Lt.length>0&&le(t=>t+1),(null==Ht?void 0:Ht.showBadge)&&ge(!!y),(a||i.hasActivePulses)&&(ie.current=requestAnimationFrame(()=>be.current()))},t.useEffect(()=>(Ae(),()=>{ie.current&&(cancelAnimationFrame(ie.current),ie.current=0)}),[Ae]),t.useEffect(()=>{oe.current=!0,Ae()},[s,Jt,te,ut,X,G,Ae]),B(Ht,Ee,oe,Ae,ye,ge);const Ne=ee&&de?At?At(de):y.createElement(mt,{hover:de}):null,Oe=Ne?y.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Qt.left+de.x,top:Qt.top+de.y,transform:`translate(${de.x>.7*Jt?"calc(-100% - 12px)":"12px"}, ${.3*te>de.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Ne):null,Re=We.current>=0&&de?y.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ut[0],height:Ut[1],pointerEvents:"none",zIndex:2}},y.createElement("circle",{cx:de.x+Qt.left,cy:de.y+Qt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(ot){const t=Ee.current;t&&u&&(t.ingest({inserts:u,bounded:!0}),t.computeScene({width:Jt,height:te}));const e=null!==(r=null==t?void 0:t.scene)&&void 0!==r?r:[],n=null!==(i=null==t?void 0:t.scales)&&void 0!==i?i:null;return y.createElement("div",{className:"stream-xy-frame"+(H?" "+H:""),role:"img","aria-label":"string"==typeof Rt?Rt:"XY chart",style:{position:"relative",width:Ut[0],height:Ut[1]}},y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ut[0],height:Ut[1],style:{position:"absolute",left:0,top:0}},Nt,y.createElement("g",{transform:`translate(${Qt.left},${Qt.top})`},X&&y.createElement("rect",{x:0,y:0,width:Jt,height:te,fill:X}),e.map((t,e)=>function(t,e){var n,r,i;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const r="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return y.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const i=t;if(0===i.topPath.length)return null;const o=i.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return y.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(r=null!==(n=i.style.fillOpacity)&&void 0!==n?n:i.style.opacity)&&void 0!==r?r:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":return y.createElement("circle",{key:"point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(i=t.style.opacity)&&void 0!==i?i:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return y.createElement("rect",{key:"rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":return y.createElement("rect",{key:"heatcell-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill});case"candlestick":{const n=t,r=Math.min(n.openY,n.closeY),i=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return y.createElement("g",{key:"candle-"+e},y.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),y.createElement("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:i,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean))),y.createElement(it,{width:Jt,height:te,totalWidth:Ut[0],totalHeight:Ut[1],margin:Qt,scales:n,showAxes:ut,axes:ht,xLabel:dt,yLabel:pt,xFormat:xt||kt,yFormat:bt||wt,showGrid:Dt,title:Rt,legend:$t,legendHoverBehavior:_t,legendClickBehavior:Wt,legendHighlightedCategory:Ct,legendIsolatedCategories:Tt,foregroundGraphics:Ot,marginalGraphics:qt,xValues:[],yValues:[],annotations:Lt,svgAnnotationRules:Pt,annotationFrame:0,xAccessor:"string"==typeof h?h:"string"==typeof S?S:void 0,yAccessor:"string"==typeof d?d:"string"==typeof k?k:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type)}))}return y.createElement("div",{ref:Kt,className:"stream-xy-frame"+(H?" "+H:""),role:"img","aria-label":"string"==typeof Rt?Rt:"XY chart",tabIndex:0,style:{position:"relative",width:Y?"100%":Ut[0],height:F?"100%":Ut[1]},onMouseMove:ee?Te:void 0,onMouseLeave:ee?_e:void 0,onKeyDown:Ce},Nt&&y.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ut[0],height:Ut[1],pointerEvents:"none"}},Nt),y.createElement("canvas",{ref:ne,style:{position:"absolute",left:0,top:0}}),y.createElement("canvas",{ref:re,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),y.createElement(it,{width:Jt,height:te,totalWidth:Ut[0],totalHeight:Ut[1],margin:Qt,scales:se,showAxes:ut,axes:ht,xLabel:dt,yLabel:pt,xFormat:xt||kt,yFormat:bt||wt,showGrid:Dt,title:Rt,legend:$t,legendHoverBehavior:_t,legendClickBehavior:Wt,legendHighlightedCategory:Ct,legendIsolatedCategories:Tt,foregroundGraphics:Ot,marginalGraphics:qt,xValues:pe,yValues:ve,annotations:Lt,svgAnnotationRules:Pt,annotationFrame:ae,xAccessor:"string"==typeof h?h:"string"==typeof S?S:void 0,yAccessor:"string"==typeof d?d:"string"==typeof k?k:void 0,annotationData:null===(o=Ee.current)||void 0===o?void 0:o.getData(),pointNodes:null===(a=Ee.current)||void 0===a?void 0:a.scene.filter(t=>"point"===t.type)}),(zt||Bt)&&y.createElement(vt,{width:Jt,height:te,totalWidth:Ut[0],totalHeight:Ut[1],margin:Qt,dimension:null!==(l=null==zt?void 0:zt.dimension)&&void 0!==l?l:"xy",scales:se,onBrush:null!=Bt?Bt:()=>{}}),(null==Ht?void 0:Ht.showBadge)&&y.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ht.badgePosition?{top:4,left:4}:"bottom-left"===Ht.badgePosition?{bottom:4,left:4}:"bottom-right"===Ht.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ye?"#dc3545":"#28a745",color:"white"})},ye?"STALE":"LIVE"),Re,Oe)});xt.displayName="StreamXYFrame";const bt={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},kt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class wt{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var i;for(let o=0;this.capacity>o;o++){const a=this.particles[o];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=r&&null!==(i=r[a.edgeIndex])&&void 0!==i?i:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=Et(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}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}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function Et(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const i=t.length,o=e*i,a=Math.min(Math.floor(o),i-1),l=o-a,[s,c,u,h]=t[a],d=At(s,c,u,h,l),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*r*2,d.y+=t*n*r*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,i,o,a]=t.points,l=At(r,i,o,a,e),s=a.x-r.x,c=a.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function At(t,e,n,r,i){const o=1-i,a=o*o,l=a*o,s=i*i,c=s*i;return{x:l*t.x+3*a*i*e.x+3*o*s*n.x+c*r.x,y:l*t.y+3*a*i*e.y+3*o*s*n.y+c*r.y}}function St(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Mt(t,e){var n,r=[],i=[],o=[],a={},l=[];function s(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&s(e)})}function c(t){var e,r,h=!1;for(i.push(t),o[t]=!0,e=0;l[t].length>e;e++)(r=l[t][e])===n?(u(n,i),h=!0):o[r]||(h=c(r));if(h)s(t);else for(e=0;l[t].length>e;e++){var d=a[r=l[t][e]];d||(a[r]=d={}),d[r]=!0}return i.pop(),h}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function h(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),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,i[s]=!1,o[s]=0,a[s]=-1,l[s]=[];var c,u=0,h=[],d=[];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>a[g]||l[e].push(a[g])}o[e]=y}else{if(r[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(i[x]=!1,p.push(x),m.push(l[x]),v+=l[x].length,a[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[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]);d[s]=c}}return{components:h,adjacencyList:d}}(t),i=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;i.length>a;a++)for(var l=0;i[a].length>l;l++)o>i[a][l]&&(o=i[a][l],n=a);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 d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];o[+p]=!1,a[p]={}}c(n),n+=1}else n=d}return r}function Lt(t){return t.y0-t.y1>0?"up":"down"}function Pt(t,e){return e(t.source)==e(t.target)}function Dt(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 $t(t){return t.target.x0-t.source.x1}function _t(t,e){var n=Ct(t),r=$t(e)/Math.tan(n);return"up"==Lt(t)?t.y1-r:t.y1+r}function Wt(t,e){var n=Ct(t),r=$t(e)/Math.tan(n);return"up"==Lt(t)?t.y1+r:t.y1-r}function Ct(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Tt(t,e){return e(t)}function Nt(t){return Rt(t.source)}function Ot(t){return Rt(t.target)}function Rt(t){return(t.y0+t.y1)/2}function It(t){return t.virtual?0:t.value}function zt(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Pt(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!Pt(t,e)?r+1:r}),n+r}function Bt(t){return t.target.depth}function Yt(t,e){return t.sourceLinks.length?t.depth:e-1}function Ft(t,e){return t.y0-e.y0}function jt(t,e){return e.y0-t.y0}function Ht(t,e){return t.y1-e.y1}function Xt(t,e){return e.y1-t.y1}function Gt(t,e){return qt(t.source,e.source)||t.index-e.index}function Vt(t,e){return qt(t.target,e.target)||t.index-e.index}function qt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Zt(t,e){return Kt(t)==Kt(e)?"bottom"==t.circularLinkType?jt(t,e):Ft(t,e):Kt(e)-Kt(t)}function Kt(t){return t.target.column-t.source.column}function Ut(t,e){return Qt(t)==Qt(e)}function Qt(t){return t.y0-t.y1>0?"up":"down"}function Jt(t,e,n,r,o){let a=t;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=i.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=a.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),te(a.links.filter(function(t){return"top"==t.circularLinkType}),e,n),te(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),a.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,Pt(t,e)&&Dt(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+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 i=t.source.column,l=t.circularLinkType,c=a.links.filter(function(t){return t.source.column==i&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?jt:Ft);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}),i=t.target.column,(c=a.links.filter(function(t){return t.target.column==i&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Xt:Ht),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(a.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,r=t.target.x0,i=t.y1,o=(e+r)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(t)}),a}function te(t,e,n){t.sort(Zt);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(Pt(t,e)&&Dt(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var l=r[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&ee(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function ee(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ne(t){return function(){return t}}function re(t){return t.index}function ie(t){return t.nodes}function oe(t){return t.links}function ae(t,e,n){var r=i.groups(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){var o=i.length;i.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?zt(e,n)-zt(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==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==zt(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)/o*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+i,e.y1=e.y0+e.value*t.ky)})})}function le(t,e,n,r,o,a){var l=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=a;c>0;--c)u(s*=.99,n),h();function u(e,n){var r=l.length;l.forEach(function(o){var a=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&zt(o,n)>0){var c=i.mean(o.sourceLinks,Ot),u=i.mean(o.targetLinks,Nt),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-Rt(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==a)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==r-1&&1==a)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 f=i.mean(o.sourceLinks,Ot),y=i.mean(o.targetLinks,Nt),g=((f&&y?(f+y)/2:f||y)-Rt(o))*e;o.y0+=g,o.y1+=g}})})}function h(){l.forEach(function(n){var i,a,l,s=t.y0,c=n.length;for(n.sort(e||qt),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+r;if((a=s-r-t.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+o-s)>0&&(i.y0-=a,i.y1-=a),s=i.y0})}}function se(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Vt),t.targetLinks.sort(Gt)}),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 ce(){var t=0,e=0,n=1,r=1,o=24,a=8,l=null,s=re,c=Yt,u=void 0,h=32,d=2,f=ie,y=oe;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=r,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return i.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,i=t.target;"object"!=typeof r&&(r=t.source=St(n,r)),"object"!=typeof i&&(i=t.target=St(n,i)),r.sourceLinks.push(t),i.targetLinks.push(t)})}(f,s),function(t,e){var n=0;if(null==e){for(var r=[],i=0;t.links.length>i;i++){var o=t.links[i],a=o.source.index,l=o.target.index;r[a]||(r[a]=[]),r[l]||(r[l]=[]),-1===r[a].indexOf(l)&&r[a].push(l)}var s=Mt(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++)})}(f,u),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){Tt(t,e)!=Tt(i.source,e)&&Tt(t,e)!=Tt(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),Pt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(i.sum(t.sourceLinks,It),i.sum(t.targetLinks,It)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var r,i,o;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var a=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==l?a:a+1,l=e(t)==l?l:e(t),t.column=a})}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})}(f,u,c);var y=a;if(null!==l){var g=i.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=i.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(r-e)*l/(p-1)))}(function(t,e,n){var r=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=i.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/i.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=i.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/a),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,y,o),ae(f,u,s),le(f,u,s,y,y,h),se(f),Jt(f,s,d,10,8),ae(f,u,s),le(f,u,s,y,y,h),se(f),Jt(f,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 r=n.links.filter(function(n){return Tt(n.source,e)==Tt(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(!Ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=_t(e,t);return t.y1-n}if(e.target.column>t.target.column)return _t(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,a=0;i>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return Tt(n.target,e)==Tt(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(!Ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Wt(e,t);return t.y0-n}if(e.source.column>t.source.column)return Wt(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,a=0;i>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var a=i.min(e,function(t){return t.y0}),l=i.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-a);function c(e){return(e-a)/(l-a)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),Jt(f,s,d,10,8)}(g),g}return g.update=function(t){return se(t),Jt(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(a=+t,g):a},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ne(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:ne(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:ne(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ne(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],r=+i[1][1],g):[[t,e],[n,r]]},g.size=function(i){return arguments.length?(t=e=0,n=+i[0],r=+i[1],g):[n-t,r-e]},g}const ue=t=>{let e,n,r,i,o,a,l,c,u;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.y1,a=t.target.y0,l=s.interpolateNumber(o,a),c=l(.5),u=l(.5),`M${e},${o}C${e},${c} ${n},${u} ${n},${a}L${r},${a}C${r},${u} ${i},${c} ${i},${o}Z`):(e=t.source.x1,n=t.target.x0,l=s.interpolateNumber(e,n),r=l(.5),i=l(.5),o=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${i},${a} ${n},${a}L${n},${c}C${i},${c} ${r},${u} ${e},${u}Z`)};function he(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,a=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${e},${r-n}L${e+l},${r-n}L${e+l},${r+n}L${e},${r+n}ZM${o},${a-n}L${o-s},${a-n}L${o-s},${a+n}L${o},${a+n}Z`}const o=i.sourceX,a=i.sourceY,l=i.targetX,s=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,h=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${o},${a-d*n}L${c},${a-d*n}L${c+r},${a-d*n+d*f}L${c+r},${h+d*r-d*f}L${c+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${s-d*n+d*f}L${u-r+f},${s-d*n}L${l},${s-d*n}L${l},${s+d*n}L${u+r},${s+d*n}L${u+r},${h-d*r}L${c-r},${h-d*r}L${c-r},${a+d*n}L${o},${a+d*n}Z`}const de={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(Bt))-1:0},justify:Yt},fe={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var i,o,a,l,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=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!==(a=n.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=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 v;v="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=ce().extent(v).links(m).nodes(p).nodeAlign(de[d]||Yt).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 m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(s=null!==(l=r._circularWidth)&&void 0!==l?l:r.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),n>o.verticalFullExtent-a&&(n=o.verticalFullExtent-a),o.verticalFullExtent+a>i&&(i=o.verticalFullExtent+a)}const o=e-t,a=i-n,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>n||e>u||i>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,i=-n*e+(h-a*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 m)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(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){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(`${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=h;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,a,l;const s="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:c.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],v=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=u?u(e):{},i={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({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";h?r=h(t).fill||r:"target"===f&&n?r=g.get(n.id)||r:e&&(r=g.get(e.id)||r);const i=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,l=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;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+l},${e.sourceY-n}L${e.sourceX+l},${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+l}}),m.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!==(a=i.fillOpacity)&&void 0!==a?a: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?he(t):ue(t),!s)continue;const c={fill:i.fill||r,fillOpacity:null!==(l=i.fillOpacity)&&void 0!==l?l:d,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};m.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,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){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 a,l,c;"down"===s?(a=n.x0+t/2,l=n.y1+14,c="middle"):(r[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),v.push({x:a,y:l,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}},ye={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){var i,o;if(0===t.length)return;const a=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,s=r[0]/2,c=r[1]/2;for(let e=0;t.length>e;e++){const n=t[e];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;n.x=s+t*Math.cos(r),n.y=c+t*Math.sin(r)}}const h=ge(n.nodeSize,n.nodeSizeRange,t),d=u.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),f=r[1]/r[0],y=u.forceSimulation().force("charge",u.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",u.forceX(r[0]/2).strength(.1*f)).force("y",u.forceY(r[1]/2).strength(.1));if(y.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}));y.force("link",d),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;a>t;++t)y.tick();const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var i,o,a;const l=n.nodeStyle,s=n.edgeStyle,u=ge(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:c.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=l?l(e):{},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};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.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(t):{},i={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.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=(m=n.nodeLabel)?"function"==typeof m?m:t=>t[m]||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=u(n);g.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ge(t,e,n){var o,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const l=e||[5,20],s=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===s.length)return()=>l[0];const c=null!==(o=i.min(s))&&void 0!==o?o:0,u=null!==(a=i.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const h=r.scaleLinear().domain([c,u]).range(l).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?l[0]:h(r)}}const pe=c.schemeCategory10,me={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:a}=n,s=Math.min(r[0],r[1])/2,c=s-o,u=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),r=g.get(e);if(void 0===n||void 0===r)continue;const i=f(t);m[n][r]=i}const v=h.chord().padAngle(i);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=l.arc().innerRadius(c).outerRadius(s);for(const e of b){const n=t[e.index],r=k.centroid(e);n.x=r[0]+u,n.y=r[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);n&&(t.source=n),r&&(t.target=r)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,r=t[e.target.index].id,i=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);i&&(i.chordData=e)}},buildScene(t,e,n,r){var i,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(r[0],r[1])/2,c=s-a,u=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:pe,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=h.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let o;o=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};x.push({type:"arc",cx:u,cy:d,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:l,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=ve(n,u,d);let i="#999";if(y)i=y(t).fill||i;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?i=m.get(n.id)||i:e&&(i=m.get(e.id)||i)}const a=y?y(t):{},s={fill:i,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||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,a=o-Math.PI/2;k.push({x:u+Math.cos(a)*r,y:d+Math.sin(a)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function ve(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 xe={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var i;const a=n.__hierarchyRoot;if(!a)return;const l=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=o.hierarchy(a,s);h.sum(u),h.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,f]=r;switch(l){case"tree":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.tree();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.cluster();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,r){var i,a;const l=null!==(i=e.padding)&&void 0!==i?i:4,s=null!==(a=e.paddingTop)&&void 0!==a?a:0,c=o.treemap().size([n,r]).tile(o.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,r){var i;const a=null!==(i=e.padding)&&void 0!==i?i:4;o.pack().size([n,r]).padding(a)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,r){var i;o.partition().size([n,r]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const r=y[e],o={id:Ae(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?be(o,r,n):"treemap"===l||"partition"===l?ke(o,r):"circlepack"===l&&we(o,r),o.__hierarchyNode=r,t.push(o),g.set(r,o)}if("tree"===l||"cluster"===l)for(const t of y)if(t.parent){const n=g.get(t.parent),r=g.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 a,l,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=i(e);let l=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=x[e.depth%x.length]);const s={fill:l,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=null!==(l=n.edgeOpacity)&&void 0!==l?l:.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,a=n.x,l=n.y;g&&(r+=p,i+=m,a+=p,l+=m);const u=Ee(r,i,a,l,y),h=o(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=Se(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,i,o,a=n.x,l=n.y;if(g&&(a+=p,l+=m),g){const t=a-p,e=l-m,n=Math.sqrt(t*t+e*e);n>0?(r=a+t/n*10,i=l+e/n*10,o=0>t?"end":"start"):(r=a,i=l-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=a-v-6,o="end"):(r=a+v+6,o="start"),i=l):(r=a,i=l+v+14,o="middle");f.push({x:r,y:i,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,r,i,o);case"treemap":case"partition":return function(t,e,n,r){var i,o;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const l=r(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Se(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,i=r.y1-r.y0;if(0>=t||0>=i)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=n?n(r):r.id;a&&(30>t||16>i||l.push({x:r.x0+t/2,y:r.y0+i/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,i)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,i);case"circlepack":return function(t,e,n,r){var i,o,a,l,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=r(n);let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.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=Se(e.nodeLabel);for(const e of t){const t=null!==(l=e.__radius)&&void 0!==l?l:5,r=n?n(e):e.id;if(!r)continue;if(15>t)continue;const i=!((null===(s=e.data)||void 0===s?void 0:s.children)&&e.data.children.length>0);u.push({x:e.x,y:i?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:i?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:i?void 0:"#000",stroke:i?void 0:"#fff",strokeWidth:i?void 0:3,paintOrder:i?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function be(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 ke(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 we(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 Ee(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}`}}function Ae(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 Se(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}const Me={sankey:fe,force:ye,chord:me,tree:xe,cluster:xe,treemap:xe,circlepack:xe,partition:xe};function Le(t){return Me[t]}class Pe{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.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,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.config=t,this.tensionConfig=Object.assign(Object.assign({},bt),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new wt(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},bt),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new wt(2e3))}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:i="source",targetAccessor:o="target",valueAccessor:a="value"}=this.config,l="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 a?a:t=>{var e;return null!==(e=t[a])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear();for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},De(t)),{data:e}))}for(const t of e){const e=s(t)+"",n=c(t)+"",r=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},De(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},De(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0,data:t})}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 a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(e)||(this.nodes.set(e,De(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,De(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,o=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);return s?(s.value+=r,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,o=!0),i||o||this.tension>=this.tensionConfig.threshold}runLayout(t){const e=Le(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values()),r=Array.from(this.edges.values());if(0===n.length&&!e.hierarchical)return;if(this.prepareForRelayout(),e.computeLayout(n,r,this.config,t),e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const t of n)this.nodes.set(t.id,t);for(const t of r)this.edges.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t)}this.finalizeLayout(),this.saveTargetPositions(),n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const i=new Set(this.nodes.keys()),o=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 i)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)i.has(t)||this.removedNodes.add(t);for(const t of o)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)o.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=i,this.previousEdgeKeys=o,this.layoutVersion++}buildScene(t){const e=Le(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:o,labels:a}=e.buildScene(n,r,this.config,t);this.sceneNodes=i,this.sceneEdges=o,this.labels=a}advanceTransition(t){if(!this.transition)return!1;const e=Math.min((t-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-e,3);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0+(t._targetX0-t._prevX0)*n,t.x1=t._prevX1+(t._targetX1-t._prevX1)*n,t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n);for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n,t.sankeyWidth=t._prevSankeyWidth+(t._targetSankeyWidth-t._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}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);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.y1,o=n.y0,a=s.interpolateNumber(i,o);return{circular:!1,points:[{x:t.y0,y:i},{x:t.y0,y:a(.5)},{x:t.y1,y:a(.5)},{x:t.y1,y:o}],halfWidth:r}}const i=e.x1,o=n.x0,a=s.interpolateNumber(i,o);return{circular:!1,points:[{x:i,y:t.y0},{x:a(.5),y:t.y0},{x:a(.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,a=n.y-e.y;i.push([e,{x:e.x+o/3,y:e.y+a/3},{x:e.x+2*o/3,y:e.y+2*a/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 a=this.config.pulse;if(!a)return;const l=null!==(e=a.duration)&&void 0!==e?e:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=a.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;l>i&&(e._pulseIntensity=1-i/l,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,a="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!r||!a)continue;const c=this.edgeTimestamps.get(`${r}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,r,i;const o=this.config.decay;if(!o)return;const a=null!==(t=o.minOpacity)&&void 0!==t?t:.1,l=this.nodeTimestamps.size;if(1>=l)return;const s=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]),c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const h=l-1-u;let d;switch(o.type){case"linear":d=a+(1-h/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:l/2;d=a+Math.pow(.5,h/t)*(1-a);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*l)>h?1:a;break;default:d=1}const f=null!==(i=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}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",a=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=r.metric(l);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}),a&&(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())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function De(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 $e(t,e,n,r,i=30){let o=null,a=i,l=1/0;for(const e of t){const t=_e(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(o=t,l=n)}else a>t.distance&&(o=t,a=t.distance)}if(o)return o;for(const t of e){const e=Ne(t,n,r);e&&a>e.distance&&(o=e,a=e.distance)}return o}function _e(t,e,n){switch(t.type){case"circle":return function(t,e,n){const r=e-t.cx,i=n-t.cy,o=Math.sqrt(r*r+i*i);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){const r=D(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 a=$(Math.atan2(i,r)),l=$(t.startAngle),s=$(t.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){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 We=null,Ce=null;function Te(){return Ce||(We=document.createElement("canvas"),We.width=1,We.height=1,Ce=We.getContext("2d")),Ce}function Ne(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,i;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),a=Te();if(!a)return null;if(a.isPointInPath(o,e,n)){const o="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,a="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&&a?(o.x1+a.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}}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 a=((e-t.x1)*r+(n-t.y1)*i)/o;a=Math.max(0,Math.min(1,a));const l=t.x1+a*r,s=t.y1+a*i,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),i=Te();if(!i)return null;if(i.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0}}catch(t){}return null}(t,e,n);default:return null}}function Oe(t){const{width:e,height:n,totalWidth:r,totalHeight:i,margin:o,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,foregroundGraphics:f,sceneNodes:g,annotations:p,svgAnnotationRules:m}=t;return y.createElement(y.Fragment,null,y.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},y.createElement("g",{transform:`translate(${o.left},${o.top})`},a.map((t,e)=>y.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),p&&p.filter(t=>"widget"!==t.type).map((t,r)=>{if(m){const i=m(t,r,{width:e,height:n,sceneNodes:g});if(i)return y.createElement(y.Fragment,{key:"annotation-"+r},i)}return null}),f),l&&"string"==typeof l?y.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?y.createElement("foreignObject",{x:0,y:0,width:r,height:o.top},l):null,s&&y.createElement("g",{transform:`translate(${r-o.right+10},${o.top})`},"object"==typeof s&&!y.isValidElement(s)&&"legendGroups"in s?y.createElement(X,{legendGroups:s.legendGroups,title:"",width:100,customHoverBehavior:c,customClickBehavior:u,highlightedCategory:h,isolatedCategories:d}):s)),null==p?void 0:p.filter(t=>"widget"===t.type&&t.nodeId&&g).map((t,e)=>{var n,r,i,a,l,s,c,u,h;const d=g.find(e=>{var n,r,i,o,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(i=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)===t.nodeId||(null===(a=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===a?void 0:a.name)===t.nodeId});if(!d)return null;const f=o.left+(null!==(n=d.cx)&&void 0!==n?n:null!=d.x&&null!=d.w?d.x+d.w/2:null!==(r=d.x)&&void 0!==r?r:0),p=o.top+(null!==(i=d.cy)&&void 0!==i?i:null!=d.y&&null!=d.h?d.y+d.h/2:null!==(a=d.y)&&void 0!==a?a:0),m=null!==(l=t.dx)&&void 0!==l?l:0,v=null!==(s=t.dy)&&void 0!==s?s:-16,x=null!==(c=t.width)&&void 0!==c?c:32,b=null!==(u=t.height)&&void 0!==u?u:32,k=null!==(h=t.content)&&void 0!==h?h:y.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return y.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+m-x/2,top:p+v-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Re(t,e){var n,r,i,o,a,l;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const a=e._gradient;if(a){const i=t.createLinearGradient(a.x0,0,a.x1,0),o=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,l=e.style.fill;i.addColorStop(0,1===a.from?l:"transparent"),i.addColorStop(1,1===a.to?l:"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!==(a=e.style.strokeWidth)&&void 0!==a?a:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l: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 Ie(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 ze(t,e){var n,r,i,o;if(!e.pathD)return;t.save();const a=new Path2D(e.pathD);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(a)),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(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(a)),t.restore()}function Be(t,e){var n,r;if(!e.pathD)return;t.save();const i=new Path2D(e.pathD);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()}Oe.displayName="NetworkSVGOverlay";const Ye=c.schemeCategory10,Fe={top:20,right:80,bottom:20,left:80},je={top:40,right:40,bottom:40,left:40},He=new Set(["chord","force","circlepack"]),Xe=[800,600],Ge={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 Ve({data:t}){var e,n,r,i,o,a;if("edge"===t.type){const e=t.data;return y.createElement("div",{className:"semiotic-tooltip",style:Ge},y.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&y.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let o=s;for(;o;){const a=null!==(i=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(r=o.data)||void 0===r?void 0:r.id)&&void 0!==i?i:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return y.createElement("div",{className:"semiotic-tooltip",style:Ge},y.createElement("div",null,t.map((t,e)=>y.createElement("span",{key:e},e>0&&y.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===a?y.createElement("strong",null,t):y.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&y.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(o=l.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return y.createElement("div",{className:"semiotic-tooltip",style:Ge},y.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&y.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&y.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const qe=t.forwardRef(function(e,n){var r,i,o;const{chartType:a,nodes:s,edges:c,data:u,initialEdges:h,nodeIDAccessor:d="id",sourceAccessor:f="source",targetAccessor:g="target",valueAccessor:p="value",childrenAccessor:m,hierarchySum:v,orientation:x="horizontal",nodeAlign:b="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:E=300,forceStrength:A=.1,padAngle:S=.01,groupWidth:M=20,sortGroups:L,edgeSort:P,treeOrientation:D="vertical",edgeType:$="curve",padding:_,paddingTop:W,tensionConfig:C,showParticles:T=!1,particleStyle:N,nodeStyle:O,edgeStyle:R,colorBy:Y,colorScheme:F="category10",edgeColorBy:j="source",edgeOpacity:H=.5,colorByDepth:X=!1,nodeSize:G=8,nodeSizeRange:V=[5,20],nodeLabel:q,showLabels:Z=!0,size:K=Xe,responsiveWidth:U,responsiveHeight:Q,margin:J,className:tt,background:et,enableHover:nt=!0,tooltipContent:rt,customHoverBehavior:it,customClickBehavior:at,onObservation:lt,chartId:st,onTopologyChange:ct,annotations:ut,svgAnnotationRules:ht,legend:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:gt,legendIsolatedCategories:pt,title:mt,foregroundGraphics:vt,backgroundGraphics:xt,decay:wt,pulse:Et,staleness:At,thresholds:St}=e,Mt=He.has(a)?je:Fe,[Lt,Pt]=z(K,U,Q),Dt=Object.assign(Object.assign({},Mt),J),$t=Pt[0]-Dt.left-Dt.right,_t=Pt[1]-Dt.top-Dt.bottom,Wt=t.useMemo(()=>Object.assign(Object.assign({},bt),C),[C]),Ct=t.useMemo(()=>Object.assign(Object.assign({},kt),N),[N]),Tt=t.useMemo(()=>({chartType:a,nodeIDAccessor:d,sourceAccessor:f,targetAccessor:g,valueAccessor:p,childrenAccessor:m,hierarchySum:v,orientation:x,nodeAlign:b,nodePaddingRatio:k,nodeWidth:w,iterations:E,forceStrength:A,padAngle:S,groupWidth:M,sortGroups:L,edgeSort:P,treeOrientation:D,edgeType:$,padding:_,paddingTop:W,tensionConfig:Wt,showParticles:T,particleStyle:Ct,nodeStyle:O,edgeStyle:R,nodeLabel:q,showLabels:Z,colorBy:Y,colorScheme:F,edgeColorBy:j,edgeOpacity:H,colorByDepth:X,nodeSize:G,nodeSizeRange:V,decay:wt,pulse:Et,staleness:At,thresholds:St}),[a,d,f,g,p,m,v,x,b,k,w,E,A,S,M,L,P,D,$,_,W,Wt,T,Ct,O,R,q,Z,Y,F,j,H,X,G,V,wt,Et,At,St]),Nt=t.useRef(null),Ot=t.useRef(0),Rt=t.useRef(0),It=t.useRef(!0),zt=t.useRef(()=>{}),Bt=t.useRef(null);Bt.current||(Bt.current=new Pe(Tt));const[Yt,Ft]=t.useState(null),[jt,Ht]=t.useState(0),[Xt,Gt]=t.useState(0),[Vt,qt]=t.useState(!1),Zt=t.useRef(null),Kt=t.useRef(new Map),Ut=t.useRef(0),Qt=t.useCallback(t=>{if("function"==typeof Y)return Y(t)+"";if("string"==typeof Y&&t.data){const e=t.data[Y];if(void 0!==e){if(!Kt.current.has(e+"")){const t=Array.isArray(F)?F:Ye;Kt.current.set(e+"",t[Ut.current++%t.length])}return Kt.current.get(e+"")}}if(!Kt.current.has(t.id)){const e=Array.isArray(F)?F:Ye;Kt.current.set(t.id,e[Ut.current++%e.length])}return Kt.current.get(t.id)},[Y,F]),Jt=t.useCallback(t=>{if("function"==typeof j)return j(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===j&&n?Qt(n):e?Qt(e):"#999"},[j,Qt]),te=t.useCallback(t=>{if(!(null==N?void 0:N.colorBy))return Jt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Ct.colorBy&&n?Qt(n):e?Qt(e):"#999"},[null==N?void 0:N.colorBy,Ct.colorBy,Qt,Jt]),ee="sankey"===a&&T||!!Et,ne=t.useCallback(()=>{Ot.current&&!ee||Ot.current||(Ot.current=requestAnimationFrame(()=>zt.current()))},[ee]);t.useEffect(()=>{var t;null===(t=Bt.current)||void 0===t||t.updateConfig(Tt),It.current=!0,ne()},[Tt,ne]);const re=t.useCallback(()=>{const t=Bt.current;if(!t)return;t.runLayout([$t,_t]),t.buildScene([$t,_t]),It.current=!0;const e=Array.isArray(F)?F:Ye,n=Array.from(t.nodes.values());for(let t=0;n.length>t;t++){const r=n[t];Kt.current.has(r.id)||Kt.current.set(r.id,e[t%e.length])}if(Ut.current=n.length,Ht(t.layoutVersion),ct){const{nodes:e,edges:n}=t.getLayoutData();ct(e,n)}},[$t,_t,ct,F]),ie=t.useCallback(t=>{const e=Bt.current;e&&(e.ingestEdge(t)&&re(),ne())},[re,ne]),oe=t.useCallback(t=>{const e=Bt.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&re(),ne()},[re,ne]),ae=t.useCallback(()=>{var t;null===(t=Bt.current)||void 0===t||t.clear(),Kt.current.clear(),Ut.current=0,Ht(0),Ft(null),Zt.current=null,It.current=!0,ne()},[ne]),le=t.useCallback(()=>{const t=Bt.current;t&&(t.tension+=999,re(),ne())},[re,ne]);t.useImperativeHandle(n,()=>({push:ie,pushMany:oe,clear:ae,getTopology:()=>{var t,e;return null!==(e=null===(t=Bt.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Bt.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:le,getTension:()=>{var t,e;return null!==(e=null===(t=Bt.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[ie,oe,ae,le]);const se=["tree","cluster","treemap","circlepack","partition"].includes(a),ce=se?u||(Array.isArray(c)?void 0:c):void 0;t.useEffect(()=>{const t=Bt.current;if(t)if(se&&ce)t.ingestHierarchy(ce,[$t,_t]),t.buildScene([$t,_t]),It.current=!0,ne();else{const e=s||[],n=Array.isArray(c)?c:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[$t,_t]),t.buildScene([$t,_t]);const r=Array.isArray(F)?F:Ye,i=Array.from(t.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Kt.current.has(e.id)||Kt.current.set(e.id,r[t%r.length])}Ut.current=i.length,It.current=!0,ne()}},[s,c,u,ce,se,$t,_t,Tt,ne,F]),t.useEffect(()=>{h&&h.length>0&&oe(h)},[]);const ue=t.useCallback(t=>{if(it&&it(t),lt){const e=Date.now();lt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:st}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:st})}},[it,lt,st]),he=t.useCallback(t=>{if(at&&at(t),lt){const e=Date.now();lt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:st}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:st})}},[at,lt,st]),de=t.useRef(()=>{}),fe=t.useRef(()=>{});de.current=t=>{if(!nt)return;const e=Nt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Dt.left,i=t.clientY-n.top-Dt.top;if(0>r||r>$t||0>i||i>_t)return void(Zt.current&&(Zt.current=null,Ft(null),ue&&(ue(null),It.current=!0),ne()));const o=Bt.current;if(!o)return;const a=$e(o.sceneNodes,o.sceneEdges,r,i);if(!a)return void(Zt.current&&(Zt.current=null,Ft(null),ue&&(ue(null),It.current=!0),ne()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};Zt.current=l,Ft(l),ue&&(ue(l),It.current=!0),ne()},fe.current=()=>{Zt.current&&(Zt.current=null,Ft(null),ue&&(ue(null),It.current=!0),ne())};const ye=t.useRef(()=>{});ye.current=t=>{if(!at&&!lt)return;const e=Nt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Dt.left,i=t.clientY-n.top-Dt.top;if(0>r||r>$t||0>i||i>_t)return;const o=Bt.current;if(!o)return;const a=$e(o.sceneNodes,o.sceneEdges,r,i);he(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},t.useCallback(t=>de.current(t),[]);const ge=t.useCallback(()=>fe.current(),[]),pe=t.useCallback(t=>ye.current(t),[]),me=t.useRef(-1),ve=t.useCallback(t=>{const e=Bt.current;if(!e)return;const n=function(t){const e=[];for(const n of t)"circle"===n.type&&null!=n.cx?e.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&e.push({x:n.cx,y:n.cy,datum:n.datum});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const r=me.current,i=I(t.key,0>r?-1:r,n.length);if(null===i)return;if(t.preventDefault(),0>i)return me.current=-1,Zt.current=null,Ft(null),ue&&(ue(null),It.current=!0),void ne();const o=0>r?0:i;me.current=o;const a=n[o],l={type:"node",data:a.datum,x:a.x,y:a.y};Zt.current=l,Ft(l),ue&&(ue(l),It.current=!0),ne()},[ue,ne]),xe=t.useCallback(t=>{me.current=-1,de.current(t)},[]);zt.current=()=>{var t,e,n;Ot.current=0;const r=Nt.current;if(!r)return;const i=r.getContext("2d");if(!i)return;const o=Bt.current;if(!o)return;const a=performance.now(),l=Rt.current?Math.min((a-Rt.current)/1e3,.1):.016;Rt.current=a;const s=o.advanceTransition(a);(s||It.current)&&o.buildScene([$t,_t]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;r.width=Pt[0]*c,r.height=Pt[1]*c,r.style.width=Pt[0]+"px",r.style.height=Pt[1]+"px",i.scale(c,c),i.translate(Dt.left,Dt.top),i.clearRect(-Dt.left,-Dt.top,Pt[0],Pt[1]),et&&(i.fillStyle=et,i.fillRect(0,0,$t,_t)),wt&&o.applyDecay(),Et&&o.applyPulse(a),St&&o.applyThresholds(a),o.applyTopologyDiff(a);const u=null!==(t=null==At?void 0:At.threshold)&&void 0!==t?t:5e3,h=At&&o.lastIngestTime>0&&a-o.lastIngestTime>u;if(h&&(i.globalAlpha=null!==(e=null==At?void 0:At.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Re(t,n);break;case"line":Ie(t,n);break;case"ribbon":ze(t,n);break;case"curved":Be(t,n)}}(i,o.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)),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.restore())}}(i,o.sceneNodes),function(t,e){var n,r,i,o;for(const a of e){if("circle"!==a.type)continue;const e=a;if(e.r>0){if(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()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.cx,e.cy,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.restore()}}}(i,o.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()}}(i,o.sceneNodes),T&&o.particlePool&&!h){const t=Array.from(o.edges.values());if(t.length>0){!function(t,e,n,r){var i,o;const a=null!==(i=r.spawnRate)&&void 0!==i?i:kt.spawnRate,l=null!==(o=r.maxPerEdge)&&void 0!==o?o:kt.maxPerEdge;for(let r=0;e.length>r;r++){const i=e[r];if(!i.bezier)continue;if(t.countForEdge(r)>=l)continue;const o=i.value*a*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)<l;e++)t.spawn(r)}}(o.particlePool,t,l,Ct);const e=.5*(null!==(n=Ct.speedMultiplier)&&void 0!==n?n:1);let r;if(Ct.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)}o.particlePool.step(l,e,t,r),function(t,e,n,r,i){var o,a;const l=null!==(o=r.radius)&&void 0!==o?o:kt.radius,s=null!==(a=r.opacity)&&void 0!==a?a:kt.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const a=e.particles[o];if(!a.active)continue;const s=n[a.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(a.x,a.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(i,o.particlePool,t,Ct,te)}}h&&(i.globalAlpha=1);const d=It.current;It.current=!1,(d||s)&&Gt(t=>t+1),(ee||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(Ot.current=requestAnimationFrame(()=>zt.current()))},t.useEffect(()=>(ne(),()=>{Ot.current&&(cancelAnimationFrame(Ot.current),Ot.current=0)}),[ne]),t.useEffect(()=>{It.current=!0,ne()},[a,$t,_t,et,ne]),B(At,Bt,It,ne,Vt,qt);const be=nt&&Yt?y.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Dt.left+Yt.x,top:Dt.top+Yt.y,transform:`translate(${Yt.x>.6*$t?"calc(-100% - 12px)":"12px"}, ${.3*_t>Yt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},rt?rt(Yt):y.createElement(Ve,{data:Yt})):null;if(ot){const t=Bt.current;if(t){const e=["tree","cluster","treemap","circlepack","partition"].includes(a),n=e?u||(Array.isArray(c)?void 0:c):void 0;if(e&&n)t.ingestHierarchy(n,[$t,_t]),t.buildScene([$t,_t]);else{const e=s||[],n=Array.isArray(c)?c:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[$t,_t]),t.buildScene([$t,_t]))}}const e=null!==(r=null==t?void 0:t.sceneNodes)&&void 0!==r?r:[],n=null!==(i=null==t?void 0:t.sceneEdges)&&void 0!==i?i:[],h=null!==(o=null==t?void 0:t.labels)&&void 0!==o?o:[];return y.createElement("div",{className:"stream-network-frame"+(tt?" "+tt:""),role:"img","aria-label":"string"==typeof mt?mt:"Network chart",style:{position:"relative",width:Pt[0],height:Pt[1]}},y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Pt[0],height:Pt[1],style:{position:"absolute",left:0,top:0}},xt&&y.createElement("g",{transform:`translate(${Dt.left},${Dt.top})`},xt),y.createElement("g",{transform:`translate(${Dt.left},${Dt.top})`},et&&y.createElement("rect",{x:0,y:0,width:$t,height:_t,fill:et}),n.map((t,e)=>function(t,e){switch(t.type){case"line":return y.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return y.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return y.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,e)).filter(Boolean),e.map((t,e)=>function(t,e){switch(t.type){case"circle":return y.createElement("circle",{key:"net-circle-"+e,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return y.createElement("rect",{key:"net-rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const n=t,r=l.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return y.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),h.map((t,e)=>function(t,e){return y.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean))),y.createElement(Oe,{width:$t,height:_t,totalWidth:Pt[0],totalHeight:Pt[1],margin:Dt,labels:h,sceneNodes:e,title:mt,legend:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:gt,legendIsolatedCategories:pt,foregroundGraphics:vt,annotations:ut,svgAnnotationRules:ht,annotationFrame:0}))}const ke=Bt.current;return y.createElement("div",{ref:Lt,className:"stream-network-frame"+(tt?" "+tt:""),role:"img","aria-label":"string"==typeof mt?mt:"Network chart",tabIndex:0,style:{position:"relative",width:U?"100%":Pt[0],height:Q?"100%":Pt[1]},onMouseMove:nt?xe:void 0,onMouseLeave:nt?ge:void 0,onClick:at||lt?pe:void 0,onKeyDown:ve},xt&&y.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Pt[0],height:Pt[1],pointerEvents:"none"}},y.createElement("g",{transform:`translate(${Dt.left},${Dt.top})`},xt)),y.createElement("canvas",{ref:Nt,style:{position:"absolute",top:0,left:0}}),y.createElement(Oe,{width:$t,height:_t,totalWidth:Pt[0],totalHeight:Pt[1],margin:Dt,labels:(null==ke?void 0:ke.labels)||[],sceneNodes:null==ke?void 0:ke.sceneNodes,title:mt,legend:dt,legendHoverBehavior:ft,legendClickBehavior:yt,legendHighlightedCategory:gt,legendIsolatedCategories:pt,foregroundGraphics:vt,annotations:ut,svgAnnotationRules:ht,annotationFrame:Xt}),be,(null==At?void 0:At.showBadge)&&y.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===At.badgePosition?{top:4,left:4}:"bottom-left"===At.badgePosition?{bottom:4,left:4}:"bottom-right"===At.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Vt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Vt?"STALE":"LIVE"))});qe.displayName="StreamNetworkFrame";const Ze="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function Ke(e){const n=t.createContext(null),r=Ue(e);return[function({children:r}){const i=t.useMemo(()=>Ue(e),[]);return y.createElement(n.Provider,{value:i,children:r})},e=>{var i;const o=null!==(i=t.useContext(n))&&void 0!==i?i:r;return function(e,n){const[r,i]=t.useState(n);return Ze(()=>e(()=>i(n)),[e]),r}(o.subscribe,()=>e(o.getState()))}]}function Ue(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 Qe(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 Je(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}const[tn,en]=Ke(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),i=Je(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=Je(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}})}})),[nn,rn]=Ke(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 on(e){const n=t.useId(),r=e.clientId||n,{name:i}=e,o=en(t=>t.selections.get(i)),a=en(t=>t.setClause),l=en(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,i]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(Qe(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:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};a(i,{clientId:r,type:"point",fields:e})},[r,i,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};a(i,{clientId:r,type:"interval",fields:e})},[r,i,a]),clear:t.useCallback(()=>{l(i,r)},[l,i,r]),clientId:r}}function an({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:i=!1,onObservation:o,chartType:a,chartId:l}){const s=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}:null}(n,r),c=on({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:i,isActive:o,selectPoints:a,clear:l}=on({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of r){const r=t[n];void 0!==r&&(e[n]=[r])}Object.keys(e).length>0&&a(e)},[r,a,l,n]),predicate:i,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||r||[]}),h=rn(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,r;if(n)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},r),{type:"click",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},r),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const ln={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 sn(t,e,n){var r,i,o,a,l,s;const c=ln[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:c.width,height:null!==(i=e.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o:c.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||c.enableHover,showLegend:null!==(l=e.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:c.marginDefaults}}const cn=t.forwardRef(function(e,n){var r,i,o,a;const l=sn(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:S,tooltip:M,onHover:L,annotations:P,svgAnnotationRules:D,tickFormatTime:$,tickFormatValue:_,decay:W,pulse:C,staleness:T,transition:N,linkedHover:O,onObservation:R,chartId:I}=e,z=l.showAxes,B=l.enableHover,Y=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=S?S:M,H=t.useRef(null),{customHoverBehavior:X}=an({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:I}),G=t.useCallback(t=>{L&&L(t),X(t)},[L,X]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=H.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=H.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),y.createElement(xt,{ref:H,chartType:"line",runtimeMode:"streaming",size:F,margin:Y,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:{stroke:k,strokeWidth:w,strokeDasharray:E},showAxes:z,background:A,hoverAnnotation:B,tooltipContent:j,customHoverBehavior:G,annotations:P,svgAnnotationRules:D,tickFormatTime:$,tickFormatValue:_,decay:W,pulse:C,staleness:T,transition:N})});cn.displayName="RealtimeLineChart";const un=t.forwardRef(function(e,n){var r,i,o,a;const l=sn(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:g=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:S,strokeWidth:M,gap:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N,linkedHover:O,decay:R,pulse:I,staleness:z,transition:B,onObservation:Y,chartId:F}=e,j=l.showAxes,H=l.enableHover,X=null!=u?u:l.marginDefaults,G=null!=c?c:[l.width,l.height],V=null!=D?D:$,q=t.useRef(null),{customHoverBehavior:Z}=an({linkedHover:O,unwrapData:!0,onObservation:Y,chartType:"RealtimeTemporalHistogram",chartId:F}),K=t.useCallback(t=>{_&&_(t),Z(t)},[_,Z]);t.useImperativeHandle(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)},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:[]}}));const U={};return null!=A&&(U.fill=A),null!=S&&(U.stroke=S),null!=M&&(U.strokeWidth=M),null!=L&&(U.gap=L),y.createElement(xt,{ref:q,chartType:"bar",runtimeMode:"streaming",size:G,margin:X,className:h,arrowOfTime:d,windowMode:f,windowSize:g,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:U,showAxes:j,background:P,hoverAnnotation:H,tooltipContent:V,customHoverBehavior:K,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N,decay:R,pulse:I,staleness:z,transition:B})});un.displayName="RealtimeTemporalHistogram";const hn=un,dn=t.forwardRef(function(e,n){var r,i,o,a;const l=sn(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N,linkedHover:O,onObservation:R,chartId:I}=e,z=l.showAxes,B=l.enableHover,Y=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=D?D:$,H=t.useRef(null),{customHoverBehavior:X}=an({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:I}),G=t.useCallback(t=>{_&&_(t),X(t)},[_,X]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=H.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=H.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const V={};return null!=E&&(V.radius=E),null!=A&&(V.fill=A),null!=S&&(V.opacity=S),null!=M&&(V.stroke=M),null!=L&&(V.strokeWidth=L),y.createElement(xt,{ref:H,chartType:"swarm",runtimeMode:"streaming",size:F,margin:Y,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:V,showAxes:z,background:P,hoverAnnotation:B,tooltipContent:j,customHoverBehavior:G,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N})});dn.displayName="RealtimeSwarmChart";const fn=t.forwardRef(function(e,n){var r,i,o,a;const l=sn(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:$,onHover:_,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N,linkedHover:O,onObservation:R,chartId:I}=e,z=l.showAxes,B=l.enableHover,Y=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=D?D:$,H=t.useRef(null),{customHoverBehavior:X}=an({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:I}),G=t.useCallback(t=>{_&&_(t),X(t)},[_,X]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=H.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=H.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const V={};return null!=k&&(V.positiveColor=k),null!=w&&(V.negativeColor=w),null!=E&&(V.connectorStroke=E),null!=A&&(V.connectorWidth=A),null!=S&&(V.gap=S),null!=M&&(V.stroke=M),null!=L&&(V.strokeWidth=L),y.createElement(xt,{ref:H,chartType:"waterfall",runtimeMode:"streaming",size:F,margin:Y,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:V,showAxes:z,background:P,hoverAnnotation:B,tooltipContent:j,customHoverBehavior:G,annotations:W,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:N})});fn.displayName="RealtimeWaterfallChart";const yn=t.forwardRef(function(e,n){var r,i,o,a;const l=sn(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:S,tooltipContent:M,tooltip:L,onHover:P,annotations:D,svgAnnotationRules:$,tickFormatTime:_,tickFormatValue:W,decay:C,pulse:T,staleness:N,linkedHover:O,onObservation:R,chartId:I}=e,z=l.showAxes,B=l.enableHover,Y=null!=c?c:l.marginDefaults,F=null!=s?s:[l.width,l.height],j=null!=M?M:L,H=t.useRef(null),{customHoverBehavior:X}=an({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:I}),G=t.useCallback(t=>{P&&P(t),X(t)},[P,X]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=H.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=H.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=H.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),y.createElement(xt,{ref:H,chartType:"heatmap",runtimeMode:"streaming",size:F,margin:Y,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:z,background:S,hoverAnnotation:B,tooltipContent:j,customHoverBehavior:G,annotations:D,svgAnnotationRules:$,tickFormatTime:_,tickFormatValue:W,decay:C,pulse:T,staleness:N})});yn.displayName="RealtimeHeatmap",exports.IncrementalExtent=x,exports.RealtimeHeatmap=yn,exports.RealtimeHistogram=hn,exports.RealtimeLineChart=cn,exports.RealtimeSwarmChart=dn,exports.RealtimeWaterfallChart=fn,exports.RingBuffer=v,exports.StreamNetworkFrame=qe,exports.StreamXYFrame=xt;
|