semiotic 3.0.0-beta.2 → 3.0.0-beta.4
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 +93 -753
- package/README.md +92 -7
- package/ai/dist/componentRegistry.js +26 -0
- package/ai/dist/{ai/mcp-server.js → mcp-server.js} +1 -1
- package/ai/dist/{ai/renderHOCToSVG.js → renderHOCToSVG.js} +2 -2
- package/dist/ChartContainer.d.ts +60 -0
- package/dist/DetailsPanel.d.ts +37 -0
- package/dist/LinkedCharts.d.ts +2 -0
- package/dist/Tooltip/Tooltip.d.ts +2 -2
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/ordinal/BarChart.d.ts +1 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +1 -0
- package/dist/charts/ordinal/DonutChart.d.ts +1 -0
- package/dist/charts/ordinal/DotPlot.d.ts +1 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/Histogram.d.ts +1 -0
- package/dist/charts/ordinal/PieChart.d.ts +1 -0
- package/dist/charts/ordinal/RidgelinePlot.d.ts +1 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +1 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +1 -0
- package/dist/charts/ordinal/ViolinPlot.d.ts +1 -0
- package/dist/charts/realtime/RealtimeHeatmap.d.ts +11 -0
- package/dist/charts/realtime/RealtimeHistogram.d.ts +15 -1
- package/dist/charts/realtime/RealtimeLineChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +6 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +6 -0
- package/dist/charts/shared/annotationRules.d.ts +3 -0
- package/dist/charts/shared/colorUtils.d.ts +17 -11
- package/dist/charts/shared/hooks.d.ts +96 -1
- package/dist/charts/shared/loess.d.ts +13 -0
- package/dist/charts/shared/networkUtils.d.ts +31 -0
- package/dist/charts/shared/tooltipUtils.d.ts +16 -0
- package/dist/charts/shared/types.d.ts +17 -2
- package/dist/charts/shared/validateChartData.d.ts +2 -3
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +4 -0
- package/dist/charts/xy/BubbleChart.d.ts +6 -0
- package/dist/charts/xy/Heatmap.d.ts +4 -0
- package/dist/charts/xy/LineChart.d.ts +6 -0
- package/dist/charts/xy/Scatterplot.d.ts +4 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +4 -0
- package/dist/data/fromVegaLite.d.ts +48 -0
- package/dist/export/chartConfig.d.ts +29 -0
- package/dist/export/selectionSerializer.d.ts +20 -0
- package/dist/geometry/sankeyLinks.d.ts +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime/types.d.ts +20 -6
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +14 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +9 -19
- package/dist/semiotic-ordinal.d.ts +12 -14
- package/dist/semiotic-xy.d.ts +12 -18
- package/dist/semiotic.d.ts +16 -13
- 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/store/ObservationStore.d.ts +61 -0
- package/dist/store/SelectionStore.d.ts +9 -1
- package/dist/store/ThemeStore.d.ts +6 -1
- package/dist/store/TooltipStore.d.ts +3 -1
- package/dist/store/createStore.d.ts +4 -1
- package/dist/store/useObservation.d.ts +18 -0
- package/dist/stream/MarginalGraphics.d.ts +1 -1
- package/dist/stream/NetworkPipelineStore.d.ts +44 -0
- package/dist/stream/OrdinalCanvasHitTester.d.ts +1 -0
- package/dist/stream/OrdinalSVGOverlay.d.ts +6 -2
- package/dist/stream/ParticlePool.d.ts +2 -1
- package/dist/stream/PipelineStore.d.ts +11 -0
- package/dist/stream/SVGOverlay.d.ts +21 -2
- package/dist/stream/SceneGraph.d.ts +1 -1
- package/dist/stream/networkTypes.d.ts +58 -1
- package/dist/stream/ordinalTypes.d.ts +13 -0
- package/dist/stream/types.d.ts +14 -0
- package/dist/types/annotationTypes.d.ts +10 -0
- package/dist/types/networkTypes.d.ts +1 -2
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +30 -42
- package/ai/dist/ai/componentRegistry.js +0 -45
- package/ai/dist/src/components/Annotation.js +0 -358
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +0 -369
- package/ai/dist/src/components/Axis/Axis.js +0 -374
- package/ai/dist/src/components/Axis/axisTitle.js +0 -14
- package/ai/dist/src/components/Axis/index.js +0 -7
- package/ai/dist/src/components/Axis/summaryGraphic.js +0 -37
- package/ai/dist/src/components/Brush.js +0 -84
- package/ai/dist/src/components/ChartErrorBoundary.js +0 -91
- package/ai/dist/src/components/DividedLine.js +0 -65
- package/ai/dist/src/components/Legend.js +0 -140
- package/ai/dist/src/components/LinkedCharts.js +0 -95
- package/ai/dist/src/components/ThemeProvider.js +0 -79
- package/ai/dist/src/components/Tooltip/Tooltip.js +0 -309
- package/ai/dist/src/components/TooltipPositioner/index.js +0 -132
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +0 -73
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +0 -254
- package/ai/dist/src/components/annotationRules/baseRules.js +0 -150
- package/ai/dist/src/components/annotationRules/networkframeRules.js +0 -196
- package/ai/dist/src/components/annotationRules/xyframeRules.js +0 -297
- package/ai/dist/src/components/batchWork.js +0 -35
- package/ai/dist/src/components/charts/index.js +0 -109
- package/ai/dist/src/components/charts/network/ChordDiagram.js +0 -142
- package/ai/dist/src/components/charts/network/CirclePack.js +0 -108
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +0 -121
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +0 -155
- package/ai/dist/src/components/charts/network/TreeDiagram.js +0 -110
- package/ai/dist/src/components/charts/network/Treemap.js +0 -106
- package/ai/dist/src/components/charts/ordinal/BarChart.js +0 -156
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +0 -139
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +0 -126
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +0 -129
- package/ai/dist/src/components/charts/ordinal/Histogram.js +0 -132
- package/ai/dist/src/components/charts/ordinal/PieChart.js +0 -128
- package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +0 -130
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +0 -130
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +0 -147
- package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +0 -138
- package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +0 -79
- package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +0 -114
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +0 -93
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +0 -105
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +0 -106
- package/ai/dist/src/components/charts/shared/ChartError.js +0 -72
- package/ai/dist/src/components/charts/shared/colorUtils.js +0 -138
- package/ai/dist/src/components/charts/shared/formatUtils.js +0 -213
- package/ai/dist/src/components/charts/shared/hooks.js +0 -49
- package/ai/dist/src/components/charts/shared/legendUtils.js +0 -57
- package/ai/dist/src/components/charts/shared/selectionUtils.js +0 -67
- package/ai/dist/src/components/charts/shared/tooltipUtils.js +0 -79
- package/ai/dist/src/components/charts/shared/types.js +0 -2
- package/ai/dist/src/components/charts/shared/validateChartData.js +0 -82
- package/ai/dist/src/components/charts/shared/validateProps.js +0 -736
- package/ai/dist/src/components/charts/xy/AreaChart.js +0 -230
- package/ai/dist/src/components/charts/xy/BubbleChart.js +0 -251
- package/ai/dist/src/components/charts/xy/Heatmap.js +0 -235
- package/ai/dist/src/components/charts/xy/LineChart.js +0 -307
- package/ai/dist/src/components/charts/xy/MinimapChart.js +0 -298
- package/ai/dist/src/components/charts/xy/Scatterplot.js +0 -172
- package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +0 -426
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +0 -231
- package/ai/dist/src/components/constants/coordinateNames.js +0 -11
- package/ai/dist/src/components/constants/frame_props.js +0 -251
- package/ai/dist/src/components/data/dataFunctions.js +0 -487
- package/ai/dist/src/components/data/multiAccessorUtils.js +0 -14
- package/ai/dist/src/components/data/transforms.js +0 -143
- package/ai/dist/src/components/data/unflowedFunctions.js +0 -5
- package/ai/dist/src/components/export/exportChart.js +0 -121
- package/ai/dist/src/components/generic_utilities/functions.js +0 -5
- package/ai/dist/src/components/geometry/areaDrawing.js +0 -312
- package/ai/dist/src/components/geometry/contourLayout.js +0 -73
- package/ai/dist/src/components/geometry/hexbinLayout.js +0 -163
- package/ai/dist/src/components/geometry/lineDrawing.js +0 -356
- package/ai/dist/src/components/geometry/sankeyLinks.js +0 -331
- package/ai/dist/src/components/geometry/summaryLayouts.js +0 -136
- package/ai/dist/src/components/index.js +0 -18
- package/ai/dist/src/components/processing/InteractionItems.js +0 -223
- package/ai/dist/src/components/processing/hierarchyUtils.js +0 -104
- package/ai/dist/src/components/processing/layouts/chordLayout.js +0 -58
- package/ai/dist/src/components/processing/layouts/forceLayout.js +0 -142
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +0 -31
- package/ai/dist/src/components/processing/layouts/index.js +0 -32
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +0 -96
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +0 -34
- package/ai/dist/src/components/processing/layouts/types.js +0 -2
- package/ai/dist/src/components/processing/networkDefaults.js +0 -39
- package/ai/dist/src/components/realtime/BinAccumulator.js +0 -36
- package/ai/dist/src/components/realtime/IncrementalExtent.js +0 -55
- package/ai/dist/src/components/realtime/RingBuffer.js +0 -104
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +0 -133
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +0 -7
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +0 -164
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +0 -91
- package/ai/dist/src/components/realtime/renderers/types.js +0 -2
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +0 -163
- package/ai/dist/src/components/realtime/types.js +0 -2
- package/ai/dist/src/components/semiotic-ai.js +0 -89
- package/ai/dist/src/components/semiotic-data.js +0 -12
- package/ai/dist/src/components/semiotic-network.js +0 -38
- package/ai/dist/src/components/semiotic-ordinal.js +0 -28
- package/ai/dist/src/components/semiotic-realtime.js +0 -30
- package/ai/dist/src/components/semiotic-server.js +0 -8
- package/ai/dist/src/components/semiotic-xy.js +0 -35
- package/ai/dist/src/components/semiotic.js +0 -109
- package/ai/dist/src/components/server/renderToStaticSVG.js +0 -594
- package/ai/dist/src/components/store/SelectionStore.js +0 -91
- package/ai/dist/src/components/store/ThemeStore.js +0 -78
- package/ai/dist/src/components/store/TooltipStore.js +0 -13
- package/ai/dist/src/components/store/createStore.js +0 -81
- package/ai/dist/src/components/store/useSelection.js +0 -133
- package/ai/dist/src/components/stream/CanvasHitTester.js +0 -164
- package/ai/dist/src/components/stream/DataSourceAdapter.js +0 -99
- package/ai/dist/src/components/stream/MarginalGraphics.js +0 -266
- package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +0 -228
- package/ai/dist/src/components/stream/NetworkPipelineStore.js +0 -498
- package/ai/dist/src/components/stream/NetworkSVGOverlay.js +0 -70
- package/ai/dist/src/components/stream/NetworkSceneGraph.js +0 -38
- package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +0 -146
- package/ai/dist/src/components/stream/OrdinalPipelineStore.js +0 -786
- package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +0 -130
- package/ai/dist/src/components/stream/ParticlePool.js +0 -174
- package/ai/dist/src/components/stream/PipelineStore.js +0 -1243
- package/ai/dist/src/components/stream/SVGOverlay.js +0 -129
- package/ai/dist/src/components/stream/SceneGraph.js +0 -132
- package/ai/dist/src/components/stream/StreamNetworkFrame.js +0 -561
- package/ai/dist/src/components/stream/StreamOrdinalFrame.js +0 -492
- package/ai/dist/src/components/stream/StreamXYFrame.js +0 -590
- package/ai/dist/src/components/stream/accessorUtils.js +0 -20
- package/ai/dist/src/components/stream/index.js +0 -32
- package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +0 -352
- package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +0 -230
- package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +0 -568
- package/ai/dist/src/components/stream/layouts/index.js +0 -28
- package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +0 -245
- package/ai/dist/src/components/stream/networkTypes.js +0 -17
- package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +0 -126
- package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +0 -62
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +0 -33
- package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +0 -63
- package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +0 -278
- package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +0 -30
- package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +0 -2
- package/ai/dist/src/components/stream/ordinalTypes.js +0 -2
- package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +0 -48
- package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +0 -70
- package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +0 -75
- package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +0 -28
- package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +0 -31
- package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +0 -140
- package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +0 -37
- package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +0 -102
- package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +0 -63
- package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +0 -35
- package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +0 -10
- package/ai/dist/src/components/stream/renderers/types.js +0 -2
- package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +0 -47
- package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +0 -38
- package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +0 -33
- package/ai/dist/src/components/stream/types.js +0 -2
- package/ai/dist/src/components/types/annotationTypes.js +0 -2
- package/ai/dist/src/components/types/canvasTypes.js +0 -2
- package/ai/dist/src/components/types/generalTypes.js +0 -2
- package/ai/dist/src/components/types/interactionTypes.js +0 -2
- package/ai/dist/src/components/types/legendTypes.js +0 -2
- package/ai/dist/src/components/types/networkTypes.js +0 -2
- package/ai/dist/src/components/types/ordinalTypes.js +0 -2
- package/ai/dist/src/components/types/xyTypes.js +0 -2
- package/ai/dist/src/components/useBoundingRect.js +0 -24
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +0 -301
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +0 -435
- package/ai/dist/src/setupTests.js +0 -4
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -25
- package/dist/Axis/Axis.d.ts +0 -7
- package/dist/Axis/axisTitle.d.ts +0 -10
- package/dist/Axis/index.d.ts +0 -2
- package/dist/Axis/summaryGraphic.d.ts +0 -17
- package/dist/Brush.d.ts +0 -12
- package/dist/DividedLine.d.ts +0 -16
- package/dist/TooltipPositioner/index.d.ts +0 -7
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/annotationRules/baseRules.d.ts +0 -25
- package/dist/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/batchWork.d.ts +0 -6
- package/dist/constants/coordinateNames.d.ts +0 -8
- package/dist/constants/frame_props.d.ts +0 -13
- package/dist/data/dataFunctions.d.ts +0 -45
- package/dist/data/multiAccessorUtils.d.ts +0 -1
- package/dist/data/unflowedFunctions.d.ts +0 -1
- package/dist/generic_utilities/functions.d.ts +0 -1
- package/dist/geometry/areaDrawing.d.ts +0 -21
- package/dist/geometry/contourLayout.d.ts +0 -6
- package/dist/geometry/hexbinLayout.d.ts +0 -7
- package/dist/geometry/lineDrawing.d.ts +0 -71
- package/dist/geometry/summaryLayouts.d.ts +0 -45
- package/dist/index.d.ts +0 -1
- package/dist/network.js +0 -7495
- package/dist/network.js.map +0 -1
- package/dist/network.module.js +0 -7458
- package/dist/network.module.js.map +0 -1
- package/dist/ordinal.js +0 -6497
- package/dist/ordinal.js.map +0 -1
- package/dist/ordinal.module.js +0 -6465
- package/dist/ordinal.module.js.map +0 -1
- package/dist/processing/InteractionItems.d.ts +0 -13
- package/dist/processing/hierarchyUtils.d.ts +0 -16
- package/dist/processing/layouts/chordLayout.d.ts +0 -2
- package/dist/processing/layouts/forceLayout.d.ts +0 -3
- package/dist/processing/layouts/hierarchyLayout.d.ts +0 -10
- package/dist/processing/layouts/index.d.ts +0 -8
- package/dist/processing/layouts/sankeyLayout.d.ts +0 -8
- package/dist/processing/layouts/simpleLayouts.d.ts +0 -7
- package/dist/processing/layouts/types.d.ts +0 -17
- package/dist/processing/networkDefaults.d.ts +0 -36
- package/dist/realtime/renderers/barRenderer.d.ts +0 -2
- package/dist/realtime/renderers/candlestickRenderer.d.ts +0 -2
- package/dist/realtime/renderers/lineRenderer.d.ts +0 -2
- package/dist/realtime/renderers/swarmRenderer.d.ts +0 -2
- package/dist/realtime.js +0 -7072
- package/dist/realtime.js.map +0 -1
- package/dist/realtime.module.js +0 -7043
- package/dist/realtime.module.js.map +0 -1
- package/dist/semiotic-ai.js +0 -13323
- package/dist/semiotic-ai.js.map +0 -1
- package/dist/semiotic-ai.module.js +0 -13264
- package/dist/semiotic-ai.module.js.map +0 -1
- package/dist/semiotic-data.js +0 -141
- package/dist/semiotic-data.js.map +0 -1
- package/dist/semiotic-data.module.js +0 -136
- package/dist/semiotic-data.module.js.map +0 -1
- package/dist/semiotic.js +0 -16351
- package/dist/semiotic.js.map +0 -1
- package/dist/semiotic.module.js +0 -16265
- package/dist/semiotic.module.js.map +0 -1
- package/dist/server.js +0 -5191
- package/dist/server.js.map +0 -1
- package/dist/server.module.js +0 -5166
- package/dist/server.module.js.map +0 -1
- package/dist/stream/NetworkSceneGraph.d.ts +0 -14
- package/dist/stream/index.d.ts +0 -16
- package/dist/types/canvasTypes.d.ts +0 -9
- package/dist/types/xyTypes.d.ts +0 -24
- package/dist/useBoundingRect.d.ts +0 -2
- package/dist/visualizationLayerBehavior/axis.d.ts +0 -36
- package/dist/visualizationLayerBehavior/general.d.ts +0 -80
- package/dist/xy.js +0 -6993
- package/dist/xy.js.map +0 -1
- package/dist/xy.module.js +0 -6957
- package/dist/xy.module.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{useMemo as e,forwardRef as n,useRef as i,useState as o,useCallback as r,useEffect as s,useImperativeHandle as l,createContext as a,useContext as c,useLayoutEffect as u,useId as h}from"react";import{brushX as d,brushY as f,brush as y}from"d3-brush";import{select as g}from"d3-selection";import{scaleLinear as p}from"d3-scale";import{bin as m,min as v,max as x}from"d3-array";import{interpolateNumber as b}from"d3-interpolate";import{sankeyCircular as k,sankeyJustify as w,sankeyCenter as A,sankeyRight as E,sankeyLeft as S}from"d3-sankey-circular";import{schemeCategory10 as M}from"d3-scale-chromatic";import{line as _,curveLinearClosed as W,arc as N}from"d3-shape";import{forceLink as P,forceSimulation as z,forceManyBody as T,forceX as $,forceY as O}from"d3-force";import{ribbon as D,chord as C}from"d3-chord";import{hierarchy as Y,partition as B,pack as L,treemap as F,treemapBinary as X,cluster as R,tree as j}from"d3-hierarchy";const I=5e3;class H{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}setBoundedData(t){if(t===this.lastBoundedData)return;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,I),bounded:!0,totalSize:t.length});let e=I;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const i=Math.min(e+I,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}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 V{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 q(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),l=n(s);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const a=Math.floor(t/i)*i;let c=r.get(a);if(c||(c={start:a,end:a+i,total:0,categories:new Map},r.set(a,c)),c.total+=l,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+l)}}return r}function Z(t,e,n,i,o,r){const s=[],l=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||(s.push([e.x(t),e.y(r)]),l.push(r))}return{type:"line",path:s,rawValues:l,style:o,datum:t,group:r}}function K(t,e,n,i,o,r,s){const l=[],a=[];for(const r of t){const t=n(r),s=i(r);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=e.x(t);l.push([c,e.y(s)]),a.push([c,e.y(o)])}return{type:"area",topPath:l,bottomPath:a,style:r,datum:t,group:s}}function Q(t,e,n,i,o,r){const s=n(t),l=i(t);return null==s||null==l||Number.isNaN(s)||Number.isNaN(l)?null:{type:"point",x:e.x(s),y:e.y(l),r:o,style:r,datum:t}}function U(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function J(t,e,n,i,o,r){return{type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r}}function tt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function et(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class nt{constructor(t){this.xExtent=new V,this.yExtent=new V,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=tt(t.timeAccessor||t.xAccessor,"time"),this.getY=tt(t.valueAccessor||t.yAccessor,"value")):(this.getX=tt(t.xAccessor,"x"),this.getY=tt(t.yAccessor,"y")),this.getGroup=et(t.groupAccessor),this.getCategory=et(t.categoryAccessor),this.getSize=t.sizeAccessor?tt(t.sizeAccessor,"size"):void 0,this.getColor=et(t.colorAccessor),this.getBounds=t.boundsAccessor?tt(t.boundsAccessor,"bounds"):void 0,"candlestick"===t.chartType&&(this.getOpen=tt(t.openAccessor,"open"),this.getHigh=tt(t.highAccessor,"high"),this.getLow=tt(t.lowAccessor,"low"),this.getClose=tt(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))}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)),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,i,o,r,s;const{config:l,buffer:a}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(a,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of a)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(a,this.getY);const c=this.xExtent.extent,u=this.yExtent.extent;let h=l.xExtent?[null!==(e=l.xExtent[0])&&void 0!==e?e:c[0],null!==(n=l.xExtent[1])&&void 0!==n?n:c[1]]:c,d=l.yExtent?[null!==(i=l.yExtent[0])&&void 0!==i?i:u[0],null!==(o=l.yExtent[1])&&void 0!==o?o:u[1]]:u;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&a.size>0)if(l.normalize)d=[0,1+l.extentPadding];else{const t=a.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||n.set(t,(n.get(t)||0)+i)}let i=0;for(const t of n.values())t>i&&(i=t);d=[0,i+(i>0?i*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&a.size>0){const[,t]=function(t,e,n,i,o){const r=q(t,e,n,i,o);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(a,this.getX,this.getY,l.binSize,this.getCategory);d=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&a.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(a,this.getY),n=e-t,i=n>0?n*l.extentPadding:1;d=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const t=a.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>d[1]&&(d[1]=t+n),d[0]>t-n&&(d[0]=t-n))}}const t=d[1]-d[0],e=t>0?t*l.extentPadding:1,n=null===(r=l.yExtent)||void 0===r?void 0:r[0],i=null===(s=l.yExtent)||void 0===s?void 0:s[1];d=[null!=n?d[0]:d[0]-e,null!=i?d[1]:d[1]+e]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(y=l.arrowOfTime)||"down"===y?"y":"x")){const e="right"===l.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:p().domain(h).range(e),y:p().domain(d).range([t.height,0])}}else{const e="down"===l.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:p().domain(d).range([0,t.width]),y:p().domain(h).range(e)}}else this.scales={x:p().domain(h).range([0,t.width]),y:p().domain(d).range([t.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const g=a.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,g),this.config.pulse&&this.applyPulse(this.scene,g),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:i}=this;if(!i||0===n.size)return[];const o=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(o);case"area":return this.buildAreaScene(o);case"stackedarea":return this.buildStackedAreaScene(o);case"scatter":case"bubble":return this.buildPointScene(o);case"heatmap":return this.buildHeatmapScene(o,t);case"bar":return this.buildBarScene(o);case"swarm":return this.buildSwarmScene(o);case"waterfall":return this.buildWaterfallScene(o,t);case"candlestick":return this.buildCandlestickScene(o,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),i=[],o=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&&i.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=Z(t.data,this.scales,this.getX,this.getY,e,t.key);o&&o.length>0&&(n.colorThresholds=o),i.push(n)}return i}buildAreaScene(t){const e=this.groupData(t),n=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]);n.push(K(t.data,this.scales,this.getX,this.getY,i,e,t.key))}return n}buildStackedAreaScene(t){return function(t,e,n,i,o,r){var s;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 a=Array.from(l).sort((t,e)=>t-e),c=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||t.set(e,(t.get(e)||0)+r)}c.set(e.key,t)}let u;if(r){u=new Map;for(const e of a){let n=0;for(const i of t)n+=(null===(s=c.get(i.key))||void 0===s?void 0:s.get(e))||0;u.set(e,n||1)}}const h=[],d=new Map;for(const t of a)d.set(t,0);for(const n of t){const t=c.get(n.key),i=[],s=[];for(const n of a){let o=t.get(n)||0;const l=d.get(n);r&&(o/=u.get(n));const a=e.x(n);s.push([a,e.y(l)]),i.push([a,e.y(l+o)]),d.set(n,l+o)}h.push({type:"area",topPath:i,bottomPath:s,style:o(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(this.groupData(t),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,i=this.config.sizeRange||[3,15];let o=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);o=e=>t===n?(i[0]+i[1])/2:i[0]+(e-t)/(n-t)*(i[1]-i[0])}}let r=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"];r=new Map;let i=0;for(const t of e)r.set(t,n[i%n.length]),i++}for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},s=t.r||n;if(o&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(s=o(t))}if(r&&this.getColor){const e=this.getColor(i);e&&r.has(e)&&(t=Object.assign(Object.assign({},t),{fill:r.get(e)}))}const l=Q(i,this.scales,this.getX,this.getY,s,t);l&&e.push(l)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const i=tt(this.config.valueAccessor,"value"),o=new Set,r=new Set;for(const e of t)o.add(this.getX(e)),r.add(this.getY(e));const s=Array.from(o).sort((t,e)=>t-e),l=Array.from(r).sort((t,e)=>t-e);if(0===s.length||0===l.length)return n;const a=e.width/s.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:i(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;s.length>t;t++)for(let e=0;l.length>e;e++){const i=u.get(`${s[t]}_${l[e]}`);if(!i)continue;const o=(i.val-h)/f;n.push(J(t*a,(l.length-1-e)*c,a,c,`rgb(${Math.round(220-180*o)},${Math.round(220-100*o)},${Math.round(255-50*o)})`,i.datum))}return n}buildStreamingHeatmapScene(t,e){var n,i,o;const r=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,a=null!==(o=this.config.heatmapAggregation)&&void 0!==o?o:"count",c=tt(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return r;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/s,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),i=Math.min(Math.floor((t-u)/y),s-1),o=Math.min(Math.floor((n-d)/g),l-1);if(0>i||0>o)continue;const r=`${i}_${o}`;let a=p.get(r);a||(a={sum:0,count:0,data:[]},p.set(r,a)),a.count++,a.sum+=c(e),a.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(a){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/s,w=e.height/l;for(const[t,e]of x){const[n,i]=t.split("_"),o=+n,s=+i,a=(e-m)/b,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,u=p.get(t);r.push(J(o*k,(l-1-s)*w,k,w,c,{xi:o,yi:s,value:e,count:u.count,sum:u.sum,data:u.data}))}return r}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=q(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let i=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):[],o=new Set(e),r=Array.from(t).filter(t=>!o.has(t)).sort();i=[...e.filter(e=>t.has(e)),...r]}const o=[],r=this.scales,[s,l]=r.x.domain();for(const t of n.values()){const n=Math.max(t.start,s),a=Math.min(t.end,l);if(n>=a)continue;const c=r.x(n),u=r.x(a),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(i&&t.categories.size>0){let n=0;for(const s of i){const i=t.categories.get(s)||0;if(0===i)continue;const l=r.y(n),a=r.y(n+i);o.push(U(h,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[s])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:i},s)),n+=i}}else{const e=r.y(0),n=r.y(t.total);o.push(U(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return o}buildSwarmScene(t){var e,n,i,o;const r=[],s=this.config.swarmStyle||{},l=null!==(e=s.radius)&&void 0!==e?e:3,a=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(i=s.opacity)&&void 0!==i?i:.7,u=s.stroke,h=s.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const i=this.scales.x(t),s=this.scales.y(n);let d=a;if(this.getCategory){const t=this.getCategory(e);d=(null===(o=this.config.barColors)||void 0===o?void 0:o[t])||d}r.push({type:"point",x:i,y:s,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e})}return r}buildWaterfallScene(t,e){const n=[],i=this.scales,o=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===o.length)return n;let r=0;for(let t=0;o.length>t;t++){const s=o[t],l=this.getX(s),a=this.getY(s),c=r+a;let u;u=o.length-1>t?this.getX(o[t+1])-l:t>0?l-this.getX(o[t-1]):0;const h=i.x(l),d=0!==u?i.x(l+u):h+e.width/10,f=Math.min(h,d)+.5,y=Math.max(h,d)-.5-f;if(0>=y){r=c;continue}const g=i.y(r),p=i.y(c);n.push(U(f,Math.min(g,p),y,Math.abs(g-p),{fill:0>a?"#dc3545":"#28a745"},Object.assign(Object.assign({},s),{baseline:r,cumEnd:c,delta:a}))),r=c}return n}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],i=this.config.candlestickStyle||{},o=i.upColor||"#28a745",r=i.downColor||"#dc3545",s=i.wickColor||"#333",l=i.wickWidth||1,a=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=i.bodyWidth||6;if(!i.bodyWidth&&a.length>1){let t=1/0;for(let e=1;a.length>e;e++){const n=Math.abs(this.scales.x(a[e])-this.scales.x(a[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 i=this.getOpen(e),a=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,a,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=i;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(a),lowY:this.scales.y(u),bodyWidth:c,upColor:o,downColor:r,wickColor:s,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],i=[];for(const e of t){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const r=this.getBounds(e),s=this.scales.x(t);if(r&&0!==r)n.push([s,this.scales.y(o+r)]),i.push([s,this.scales.y(o-r)]);else{const t=this.scales.y(o);n.push([s,t]),i.push([s,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,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,i,o;const r=this.config.decay;if(!r||1>=e)return 1;const s=null!==(n=r.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(r.type){case"linear":return s+(1-l/(e-1))*(1-s);case"exponential":{const t=null!==(i=r.halfLife)&&void 0!==i?i:e/2;return s+Math.pow(.5,l/t)*(1-s)}case"step":return(null!==(o=r.stepThreshold)&&void 0!==o?o:.5*e)>l?1:s;default:return 1}}applyDecay(t,e){var n,i;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const r=new Map;for(let t=0;e.length>t;t++)r.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,o);if("heatcell"===e.type)e.style={opacity:s};else if("candlestick"===e.type)e._decayOpacity=s;else{const t=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*s})}}}computePulseIntensity(t,e){var n;const i=this.config.pulse;if(!i)return 0;const o=null!==(n=i.duration)&&void 0!==n?n:500,r=e-t;return o>r?1-r/o:0}applyPulse(t,e){var n;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)",r=new Map;for(let t=0;e.length>t;t++)r.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const s=this.computePulseIntensity(n,i);s>0&&(e._pulseIntensity=s,e._pulseColor=o)}}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,i=this.timestampBuffer.peek();return null!=i&&n>e-i}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,i,o,r;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!==(r=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(o=t.datum)||void 0===o?void 0:o.category)&&void 0!==r?r: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,i,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const s=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let l=!1;for(let t=0;this.scene.length>t;t++){const s=this.scene[t],a=this.getNodeIdentity(s,t);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===s.type){const t={x:s.x,y:s.y,r:s.r};c.x===t.x&&c.y===t.y||(s._targetX=t.x,s._targetY=t.y,s._targetR=t.r,s.x=c.x,s.y=c.y,s.r=null!==(e=c.r)&&void 0!==e?e:s.r,l=!0)}else if("rect"===s.type){const t={x:s.x,y:s.y,w:s.w,h:s.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(s._targetX=t.x,s._targetY=t.y,s._targetW=t.w,s._targetH=t.h,s.x=c.x,s.y=c.y,s.w=null!==(n=c.w)&&void 0!==n?n:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,l=!0)}else if("heatcell"===s.type){const t={x:s.x,y:s.y,w:s.w,h:s.h};c.x===t.x&&c.y===t.y||(s._targetX=t.x,s._targetY=t.y,s._targetW=t.w,s._targetH=t.h,s.x=c.x,s.y=c.y,s.w=null!==(o=c.w)&&void 0!==o?o:s.w,s.h=null!==(r=c.h)&&void 0!==r?r:s.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:s})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),i="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)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*i)}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)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*i),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*i)}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)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*i),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*i)}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 i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.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 it(t,e,n){const i=e-t.x,o=n-t.y,r=Math.sqrt(i*i+o*o);return r>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:r}}function ot(t,e,n){if(0===t.path.length)return null;const i=ct(t.path,e);if(0>i)return null;const[o,r]=t.path[i],s=e-o,l=n-r,a=Math.sqrt(s*s+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:a}}function rt(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 st(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 lt(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function at(t,e,n){if(0===t.topPath.length)return null;const i=ct(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,l=n-r;return{node:t,datum:t.datum,x:o,y:r,distance:Math.sqrt(s*s+l*l)}}function ct(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}const ut={fill:e=>t.createElement("rect",{style:e,width:20,height:20}),line:e=>t.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function ht(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,ut[n])(i(t,e)),o}function dt(e){const{legendGroups:n,customClickBehavior:i,title:o="Legend",width:r=100,height:s=20,orientation:l="vertical"}=e,a="vertical"===l?(({legendGroups:e,width:n,customClickBehavior:i})=>{let o=30;const r=[];return e.forEach((e,s)=>{o+=5,r.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:o,x2:n,y2:o})),o+=10,e.label&&(o+=20,r.push(t.createElement("text",{key:"legend-text-"+s,y:o,className:"legend-group-label"},e.label)),o+=10),r.push(t.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${o})`},((e,n)=>{const{type:i="fill",styleFn:o,items:r}=e,s=[];let l=0;return r.forEach((e,r)=>{const a=ht(e,r,i,o);s.push(t.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${l})`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},a,t.createElement("text",{y:15,x:30},e.label))),l+=25}),s})(e,i))),o+=25*e.items.length+10}),r})({legendGroups:n,width:r,customClickBehavior:i}):(({legendGroups:e,title:n,height:i,customClickBehavior:o})=>{let r=0;const s=[],l=!1===n?10:40;return e.forEach((n,a)=>{n.label&&(s.push(t.createElement("text",{key:"legend-text-"+a,transform:`translate(${r},${l}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),r+=20);const c=((e,n)=>{const{type:i="fill",styleFn:o,items:r}=e,s=[];let l=0;return r.forEach((e,r)=>{const a=ht(e,r,i,o);s.push(t.createElement("g",{key:"legend-item-"+r,transform:`translate(${l},0)`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},a,t.createElement("text",{y:15,x:25},e.label))),l+=35,l+=8*e.label.length}),{items:s,offset:l}})(n,o);s.push(t.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${r},${l})`},c.items)),r+=c.offset+5,e[a+1]&&s.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:r,y1:l-10,x2:r,y2:i+l+10})),r+=15}),t.createElement("g",null,!1!==n&&t.createElement("line",{x1:0,x2:r+10,y1:l-10,y2:l-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:n,title:o,height:s,customClickBehavior:i});return t.createElement("g",null,void 0!==o&&t.createElement("text",{className:"legend-title",y:20,x:"horizontal"===l?0:r/2,textAnchor:"horizontal"===l?"start":"middle"},o),a)}function ft(t){return"string"==typeof t?{type:t}:t}function yt({orient:n,config:i,values:o,scale:r,size:s,length:l}){const a=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),c="top"===n||"bottom"===n,u=e(()=>{if(0===o.length)return null;const e=r.domain(),i=s-8;if("boxplot"===a.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!e)return null;const{q1:s,median:l,q3:u,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*i,20),y=(i-f)/2+4;if(c){const e=r(s),i=r(u),o=r(l),c=r(h),g=r(d),p="top"===n?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+n},t.createElement("line",{x1:c,y1:m+p*(y+f/2),x2:g,y2:m+p*(y+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+f),stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+f),stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("rect",{x:Math.min(e,i),y:"top"===n?m-y-f:m+y,width:Math.abs(i-e),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:o,y1:"top"===n?m-y-f:m+y,x2:o,y2:"top"===n?m-y:m+y+f,stroke:a.fill,strokeWidth:2}))}{const e=r(s),i=r(u),o=r(l),c=r(h),g=r(d),p="left"===n?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+n},t.createElement("line",{x1:m+p*(y+f/2),y1:c,x2:m+p*(y+f/2),y2:g,stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+f),y2:g,stroke:a.fill,strokeWidth:a.strokeWidth}),t.createElement("rect",{x:"left"===n?m-y-f:m+y,y:Math.min(e,i),width:f,height:Math.abs(i-e),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),t.createElement("line",{x1:"left"===n?m-y-f:m+y,y1:o,x2:"left"===n?m-y:m+y+f,y2:o,stroke:a.fill,strokeWidth:2}))}}const u=m().domain(e).thresholds(a.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===a.type)return t.createElement("g",{"data-testid":"marginal-histogram-"+n},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*i;if(c){const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.createElement("rect",{key:o,x:i,y:"top"===n?-4-s:4,width:Math.max(l,.5),height:s,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const i=r(e.x0),l=r(e.x1)-r(e.x0);return t.createElement("rect",{key:o,x:"left"===n?-4-s:4,y:Math.min(i,i+l),width:s,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const e=i/2+4,o=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const s=t.length/h*(i/2),l=r((t.x0+t.x1)/2);o.push(c?`${l},${"top"===n?-(e-s):e-s}`:`${"left"===n?-(e-s):e-s},${l}`)}for(let t=u.length-1;t>=0;t--){const s=u[t];if(null==s.x0||null==s.x1)continue;const l=s.length/h*(i/2),a=r((s.x0+s.x1)/2);o.push(c?`${a},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${a}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+n},t.createElement("polygon",{points:o.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const e=[];if(c){const t=0,o=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${s},${"top"===n?-o-4:o+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;e.push(`L${s},${t}`),e.push("Z")}else{const t=0,o=null!=u[0].x0?r(u[0].x0):0;e.push(`M${t},${o}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/h*i,s=r((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;e.push(`L${t},${s}`),e.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+n},t.createElement("path",{d:e.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,r,a,s,l,n,c,4]);return u?t.createElement("g",{className:"marginal-"+n,"data-testid":"marginal-"+n},u):null}function gt(t){return Math.round(100*t)/100+""}function pt(n){const{width:i,height:o,totalWidth:r,totalHeight:s,margin:l,scales:a,showAxes:c,xLabel:u,yLabel:h,xFormat:d,yFormat:f,showGrid:y,title:g,legend:p,foregroundGraphics:m,marginalGraphics:v,xValues:x,yValues:b,annotations:k,svgAnnotationRules:w,annotationFrame:A,children:E}=n,S=e(()=>c&&a?a.x.ticks(5).map(t=>({value:t,pixel:a.x(t),label:(d||gt)(t)})):[],[c,a,d]),M=e(()=>c&&a?a.y.ticks(5).map(t=>({value:t,pixel:a.y(t),label:(f||gt)(t)})):[],[c,a,f]),_=e(()=>k&&0!==k.length&&w?k.map((t,e)=>w(t,e,{scales:a?{time:a.x,value:a.y}:null,timeAxis:"x",width:i,height:o})).filter(Boolean):null,[k,w,i,o,A]);return c||g||p||m||v||_&&_.length>0||y||E?t.createElement("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&a&&t.createElement("g",{className:"stream-grid"},S.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"#e0e0e0",strokeWidth:1})),M.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"#e0e0e0",strokeWidth:1}))),c&&a&&t.createElement("g",{className:"stream-axes"},t.createElement("line",{x1:0,y1:o,x2:i,y2:o,stroke:"#ccc",strokeWidth:1}),S.map((e,n)=>t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${o})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),u&&t.createElement("text",{x:i/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},u),t.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"#ccc",strokeWidth:1}),M.map((e,n)=>t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),h&&t.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},h)),_,v&&a&&x&&b&&t.createElement(t.Fragment,null,v.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(yt,{orient:"top",config:ft(v.top),values:x,scale:a.x,size:l.top,length:i})),v.bottom&&t.createElement("g",{transform:`translate(0, ${o})`},t.createElement(yt,{orient:"bottom",config:ft(v.bottom),values:x,scale:a.x,size:l.bottom,length:i})),v.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(yt,{orient:"left",config:ft(v.left),values:b,scale:a.y,size:l.left,length:o})),v.right&&t.createElement("g",{transform:`translate(${i}, 0)`},t.createElement(yt,{orient:"right",config:ft(v.right),values:b,scale:a.y,size:l.right,length:o}))),m,E),g&&t.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof g?g:null),p&&t.createElement("g",{transform:`translate(${r-l.right+10}, ${l.top})`},"object"==typeof(W=p)&&null!==W&&!t.isValidElement(W)&&"legendGroups"in W?t.createElement(dt,{legendGroups:p.legendGroups,title:"",width:100}):p)):null;var W}function mt(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}const vt=(t,e,n,i)=>{var o;const r=e.filter(t=>"area"===t.type);for(const e of r){if(2>e.topPath.length)continue;t.beginPath();const[n,i]=e.topPath[0];t.moveTo(n,i);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 r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;if(t.globalAlpha=r,t.fillStyle=e.style.fill||"#4e79a7",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}},xt=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;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=4;t.beginPath(),t.arc(e.x,e.y,e.r+n*e._pulseIntensity,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.5*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},bt=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?kt(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 kt(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.w)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}const wt={line:[vt,(t,e,n,i)=>{const o=e.filter(t=>"line"===t.type);for(const r of o){if(2>r.path.length)continue;const s=r.style.stroke||"#007bff",l=r.style.strokeWidth||2,a=r.colorThresholds,c=r.rawValues;if(t.setLineDash(r.style.strokeDasharray?r.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=r.style.opacity&&(t.globalAlpha=r.style.opacity),t.lineWidth=l,a&&0!==a.length&&c&&c.length===r.path.length){let u=null,h=null,d=null,f=null,y=!1;function g(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),y=!0}function p(){y&&(t.stroke(),y=!1)}for(let m=0;r.path.length>m;m++){const[v,x]=r.path[m],b=c[m],k=mt(b,a,s);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(v,x);else{const w=[];for(const A of a){const E=A.value;(d>E||E>b)&&(E>d||b>E)||d===E||b===E||w.push({t:(E-d)/(b-d)})}w.sort((t,e)=>t.t-e.t);for(const S of w){const M=u+(v-u)*S.t,_=h+(x-h)*S.t,W=mt(d+(b-d)*Math.min(S.t+1e-4,1),a,s);t.lineTo(M,_),p(),g(W,M,_)}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=s;const[N,P]=r.path[0];t.moveTo(N,P);for(let z=1;r.path.length>z;z++)t.lineTo(r.path[z][0],r.path[z][1]);t.stroke()}if(r.style.fill&&r.style.fillOpacity&&r.style.fillOpacity>0){t.beginPath(),t.globalAlpha=r.style.fillOpacity,t.fillStyle=r.style.fill;const[T,$]=r.path[0];t.moveTo(T,$);for(let D=1;r.path.length>D;D++)t.lineTo(r.path[D][0],r.path[D][1]);const O=r.path[0][0];t.lineTo(r.path[r.path.length-1][0],i.height),t.lineTo(O,i.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[vt],stackedarea:[vt],scatter:[xt],bubble:[xt],heatmap:[(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);for(const e of o){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:[bt],swarm:[xt],waterfall:[(t,e,n,i)=>{var o,r;bt(t,e);const s=e.filter(t=>"rect"===t.type);if(s.length>=2){t.save(),t.strokeStyle="#999",t.lineWidth=1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const i=s[e],l=s[e+1];if(!(null===(o=i.datum)||void 0===o?void 0:o.cumEnd)||!(null===(r=l.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(i.datum.cumEnd),c=i.x+i.w,u=l.x;t.beginPath(),t.moveTo(c,a),t.lineTo(u,a),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{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 i=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),r=e.isUp?e.upColor:e.downColor;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1))}}]},At={top:20,right:20,bottom:30,left:40},Et={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"},St={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:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:St},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}function _t({width:e,height:n,totalWidth:o,totalHeight:r,margin:l,dimension:a,scales:c,onBrush:u}){const h=i(null),p=i(null);return s(()=>{if(!h.current)return;const t=g(h.current).select(".brush-g"),i="x"===a?d():"y"===a?f():y();return i.extent([[0,0],[e,n]]),i.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let i,o;if("x"===a){const[e,r]=t.selection;i=[c.x.invert(e),c.x.invert(r)],o=[c.y.invert(n),c.y.invert(0)]}else if("y"===a){const[n,r]=t.selection;i=[c.x.invert(0),c.x.invert(e)],o=[c.y.invert(r),c.y.invert(n)]}else{const[[e,n],[r,s]]=t.selection;i=[c.x.invert(e),c.x.invert(r)],o=[c.y.invert(s),c.y.invert(n)]}u({x:i,y:o})}),t.call(i),p.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),p.current=null}},[e,n,a,c,u]),t.createElement("svg",{ref:h,width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Wt=n(function(n,a){var c;const{chartType:u,runtimeMode:h,data:d,xAccessor:f,yAccessor:y,colorAccessor:g,sizeAccessor:p,groupAccessor:m,lineDataAccessor:v,normalize:x,binSize:b,valueAccessor:k,arrowOfTime:w="right",windowMode:A="sliding",windowSize:E=200,timeAccessor:S,xExtent:M,yExtent:_,extentPadding:W=.1,sizeRange:N,size:P=[500,300],margin:z,className:T,background:$,lineStyle:O,pointStyle:D,areaStyle:C,swarmStyle:Y,barColors:B,colorScheme:L,boundsAccessor:F,boundsStyle:X,openAccessor:R,highAccessor:j,lowAccessor:I,closeAccessor:G,candlestickStyle:V,showAxes:q=!0,xLabel:Z,yLabel:K,xFormat:Q,yFormat:U,tickFormatTime:J,tickFormatValue:tt,hoverAnnotation:et,tooltipContent:ct,customHoverBehavior:ut,enableHover:ht,annotations:dt,svgAnnotationRules:ft,showGrid:yt,legend:gt,backgroundGraphics:mt,foregroundGraphics:vt,title:xt,categoryAccessor:bt,brush:kt,onBrush:St,decay:Wt,pulse:Nt,transition:Pt,staleness:zt,heatmapAggregation:Tt,heatmapXBins:$t,heatmapYBins:Ot,marginalGraphics:Dt}=n,Ct=Object.assign(Object.assign({},At),z);if(Dt){const t=60;Dt.top&&t>Ct.top&&(Ct.top=t),Dt.bottom&&t>Ct.bottom&&(Ct.bottom=t),Dt.left&&t>Ct.left&&(Ct.left=t),Dt.right&&t>Ct.right&&(Ct.right=t)}const Yt=P[0]-Ct.left-Ct.right,Bt=P[1]-Ct.top-Ct.bottom,Lt=null!=et?et:ht,Ft=i(null),Xt=i(0),Rt=i(!1),[jt,It]=o(0),[Ht,Gt]=o(null),Vt=i(null),[qt,Zt]=o(null),[Kt,Qt]=o(!1),[Ut,Jt]=o([]),[te,ee]=o([]),ne=i(()=>{}),ie="streaming"===h||["bar","swarm","waterfall"].includes(u),oe=e(()=>({chartType:u,runtimeMode:ie?"streaming":"bounded",windowSize:E,windowMode:A,arrowOfTime:ie?w:"right",extentPadding:W,xAccessor:ie?void 0:f,yAccessor:ie?void 0:y,timeAccessor:ie?S:void 0,valueAccessor:k,colorAccessor:g,sizeAccessor:p,groupAccessor:m,categoryAccessor:bt,lineDataAccessor:v,xExtent:M,yExtent:_,sizeRange:N,binSize:b,normalize:x,boundsAccessor:F,boundsStyle:X,openAccessor:R,highAccessor:j,lowAccessor:I,closeAccessor:G,candlestickStyle:V,lineStyle:O,pointStyle:D,areaStyle:C,swarmStyle:Y,colorScheme:L,barColors:B,annotations:dt,decay:Wt,pulse:Nt,transition:Pt,staleness:zt,heatmapAggregation:Tt,heatmapXBins:$t,heatmapYBins:Ot}),[u,E,A,w,W,f,y,S,k,g,p,m,bt,v,M,_,N,b,x,F,X,R,j,I,G,V,O,D,C,Y,L,B,dt,Wt,Nt,Pt,zt,Tt,$t,Ot,ie]),re=i(null);re.current||(re.current=new nt(oe));const se=r(()=>{Xt.current||(Xt.current=requestAnimationFrame(()=>ne.current()))},[]);s(()=>{var t;null===(t=re.current)||void 0===t||t.updateConfig(oe),Rt.current=!0,se()},[oe,se]);const le=i(null);le.current||(le.current=new H(t=>{const e=re.current;e&&e.ingest(t)&&(Rt.current=!0,se())}));const ae=r(t=>{var e;null===(e=le.current)||void 0===e||e.push(t)},[]),ce=r(t=>{var e;null===(e=le.current)||void 0===e||e.pushMany(t)},[]),ue=r(()=>{var t,e;null===(t=le.current)||void 0===t||t.clear(),null===(e=re.current)||void 0===e||e.clear(),Rt.current=!0,se()},[se]);l(a,()=>({push:ae,pushMany:ce,clear:ue,getData:()=>{var t,e;return null!==(e=null===(t=re.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=re.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=re.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[ae,ce,ue]),s(()=>{var t;d&&(null===(t=le.current)||void 0===t||t.setBoundedData(d))},[d]);const he=i(()=>{}),de=i(()=>{});he.current=t=>{if(!Lt)return;const e=Ft.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ct.left,o=t.clientY-n.top-Ct.top;if(0>i||i>Yt||0>o||o>Bt)return void(Vt.current&&(Vt.current=null,Zt(null),ut&&ut(null),se()));const r=re.current;if(!r||0===r.scene.length)return;const s=function(t,e,n,i=30){let o=null;for(const r of t){let t=null;switch(r.type){case"point":t=it(r,e,n);break;case"line":t=ot(r,e,n);break;case"rect":t=rt(r,e,n);break;case"heatcell":t=st(r,e,n);break;case"area":if(!1===r.interactive)break;t=at(r,e,n);break;case"candlestick":t=lt(r,e,n)}t&&i>t.distance&&(o&&t.distance>=o.distance||(o=t))}return o}(r.scene,i,o);if(!s)return void(Vt.current&&(Vt.current=null,Zt(null),ut&&ut(null),se()));const l={data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y};Vt.current=l,Zt(l),ut&&ut(l),se()},de.current=()=>{Vt.current&&(Vt.current=null,Zt(null),ut&&ut(null),se())};const fe=r(t=>he.current(t),[]),ye=r(()=>de.current(),[]);ne.current=()=>{var t,e;Xt.current=0;const n=Ft.current;if(!n)return;const i=n.getContext("2d");if(!i)return;const o=re.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(r);s||o.computeScene({width:Yt,height:Bt});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=P[0]*l,n.height=P[1]*l,n.style.width=P[0]+"px",n.style.height=P[1]+"px",i.scale(l,l),i.translate(Ct.left,Ct.top),i.clearRect(-Ct.left,-Ct.top,P[0],P[1]);const a=function(t){if(!t)return Et;const e=getComputedStyle(t),n=e.getPropertyValue("--text-secondary").trim(),i=e.getPropertyValue("--text-primary").trim(),o=e.getPropertyValue("--surface-3").trim(),r=e.getPropertyValue("--surface-0").trim();return n||i?{axisStroke:o||Et.axisStroke,tickText:n||Et.tickText,crosshair:n?n+"66":Et.crosshair,hoverFill:r?r+"4D":Et.hoverFill,hoverStroke:n?n+"99":Et.hoverStroke,pointRing:r||Et.pointRing}:Et}(n),c=null!==(t=null==zt?void 0:zt.threshold)&&void 0!==t?t:5e3,h=zt&&o.lastIngestTime>0&&r-o.lastIngestTime>c;h&&(i.globalAlpha=null!==(e=null==zt?void 0:zt.dimOpacity)&&void 0!==e?e:.5),$&&(i.fillStyle=$,i.fillRect(0,0,Yt,Bt));const d=wt[u];if(d&&o.scales)for(const t of d)t(i,o.scene,o.scales,{width:Yt,height:Bt});h&&(i.globalAlpha=1),Lt&&Vt.current&&o.scales&&function(t,e,n,i,o,r,s){if(!1===o.crosshair)return;t.save();const l="object"==typeof o.crosshair?o.crosshair:{};t.strokeStyle=l.stroke||s.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,i),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=s.pointRing,t.lineWidth=2,t.stroke()}(i,Vt.current,Yt,Bt,"object"==typeof Lt?Lt:{},0,a);const g=Rt.current;if(Rt.current=!1,g&&o.scales&&(Gt(o.scales),Dt)){const t=o.getData(),e="function"==typeof f?f:t=>t[f||"x"],n="function"==typeof y?y:t=>t[y||"y"];Jt(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),ee(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}g&&dt&&dt.length>0&&ft&&It(t=>t+1),(null==zt?void 0:zt.showBadge)&&Qt(!!h),(s||o.hasActivePulses)&&(Xt.current=requestAnimationFrame(()=>ne.current()))},s(()=>(se(),()=>{Xt.current&&cancelAnimationFrame(Xt.current)}),[se]),s(()=>{Rt.current=!0,se()},[u,Yt,Bt,q,$,O,se]),s(()=>{if(!zt)return;const t=setInterval(()=>{var t;const e=re.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=zt.threshold)&&void 0!==t?t:5e3,o=n-e.lastIngestTime>i;o!==Kt&&(Qt(o),Rt.current=!0,se())},1e3);return()=>clearInterval(t)},[zt,Kt,se]);const ge=Lt&&qt?ct?ct(qt):t.createElement(Mt,{hover:qt}):null,pe=ge?t.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ct.left+qt.x,top:Ct.top+qt.y,transform:`translate(${qt.x>.7*Yt?"calc(-100% - 12px)":"12px"}, ${.3*Bt>qt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ge):null;return t.createElement("div",{className:"stream-xy-frame"+(T?" "+T:""),style:{position:"relative",width:P[0],height:P[1]},onMouseMove:Lt?fe:void 0,onMouseLeave:Lt?ye:void 0},mt&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:P[0],height:P[1],pointerEvents:"none"}},mt),t.createElement("canvas",{ref:Ft,style:{position:"absolute",left:0,top:0}}),t.createElement(pt,{width:Yt,height:Bt,totalWidth:P[0],totalHeight:P[1],margin:Ct,scales:Ht,showAxes:q,xLabel:Z,yLabel:K,xFormat:Q||J,yFormat:U||tt,showGrid:yt,title:xt,legend:gt,foregroundGraphics:vt,marginalGraphics:Dt,xValues:Ut,yValues:te,annotations:dt,svgAnnotationRules:ft,annotationFrame:jt}),(kt||St)&&t.createElement(_t,{width:Yt,height:Bt,totalWidth:P[0],totalHeight:P[1],margin:Ct,dimension:null!==(c=null==kt?void 0:kt.dimension)&&void 0!==c?c:"xy",scales:Ht,onBrush:null!=St?St:()=>{}}),(null==zt?void 0:zt.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===zt.badgePosition?{top:4,left:4}:"bottom-left"===zt.badgePosition?{bottom:4,left:4}:"bottom-right"===zt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Kt?"#dc3545":"#28a745",color:"white"})},Kt?"STALE":"LIVE"),pe)});Wt.displayName="StreamXYFrame";const Nt={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Pt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class zt{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){for(let i=0;this.capacity>i;i++){const o=this.particles[i];if(!o.active)continue;const r=n[o.edgeIndex];if(!r||!r.bezier){o.active=!1;continue}if(o.t+=t*e,o.t>=1){o.active=!1;continue}const s=Tt(r.bezier,o.t,o.offset);o.x=s.x,o.y=s.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 Tt(t,e,n){if(t.circular&&t.segments)return function(t,e,n,i){const o=t.length,r=e*o,s=Math.min(Math.floor(r),o-1),l=r-s,[a,c,u,h]=t[s],d=$t(a,c,u,h,l),f=h.x-a.x,y=h.y-a.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*i*2,d.y+=t*n*i*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[i,o,r,s]=t.points,l=$t(i,o,r,s,e),a=s.x-i.x,c=s.y-i.y,u=Math.sqrt(a*a+c*c);if(u>.001){const e=a/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function $t(t,e,n,i,o){const r=1-o,s=r*r,l=s*r,a=o*o,c=a*o;return{x:l*t.x+3*s*o*e.x+3*r*a*n.x+c*i.x,y:l*t.y+3*s*o*e.y+3*r*a*n.y+c*i.y}}const Ot=(t=1)=>(e,n)=>{const i=e[e.length-1];return i&&Math.round(i.x/t)===Math.round(n.x/t)&&Math.round(i.y/t)===Math.round(n.y/t)||e.push(n),e},Dt=t=>{let e,n,i,o,r,s,l,a,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.y1,s=t.target.y0,l=b(r,s),a=l(.5),c=l(.5),`M${e},${r}C${e},${a} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${a} ${o},${r}Z`):(e=t.source.x1,n=t.target.x0,l=b(e,n),i=l(.5),o=l(.5),r=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,a=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${r}C${i},${r} ${o},${s} ${n},${s}L${n},${a}C${o},${a} ${i},${c} ${e},${c}Z`)};function Ct(t){const e=function(){const t=_();let e=function(t){return t.x},n=function(t){return t.y},i=function(t){return t.r},o=W;function r(r){if(r.multiple){const s=i,a=r.multiple.reduce((t,e)=>t+e.weight,0);i=()=>a;let c=l(r.points).filter(t=>"forward"===t.direction).reduce(Ot(),[]);const u=[];return r.multiple.forEach((t,e)=>{i=()=>t.weight;const n=l(c);u.push(n);const o=r.multiple[e+1];if(o){const t=n.reverse().filter(t=>"back"===t.direction).reduce(Ot(),[]);i=()=>o.weight;const e=l(t);c=e.reverse().filter(t=>"back"===t.direction).reduce(Ot(),[])}}),i=s,u.map(i=>t.x(e).y(n).curve(o)(i))}const s=l(r).reduce(Ot(),[]);return t.x(e).y(n).curve(o)(s)}return r.x=function(t){return arguments.length?(e=t,r):e},r.y=function(t){return arguments.length?(n=t,r):n},r.r=function(t){return arguments.length?(i=t,r):i},r.interpolate=function(t){return arguments.length?(o=t,r):o},r;function s(t){const o=n(t.target)-n(t.source),r=e(t.target)-e(t.source),s=Math.atan2(r,o)+Math.PI/2,l=s+.5*Math.PI,a=s+.5*Math.PI;return{x1:e(t.source)+i(t.source)*Math.cos(l),y1:n(t.source)-i(t.source)*Math.sin(l),x2:e(t.target)+i(t.target)*Math.cos(a),y2:n(t.target)-i(t.target)*Math.sin(a)}}function l(t){const e=[];let n=0,i={x1:0,y1:0,x2:0,y2:0};for(;t.length>n;){if(n!==t.length-1&&(i=s({source:t[n],target:t[n+1]}),e.push({x:i.x1,y:i.y1,direction:"forward"},{x:i.x2,y:i.y2,direction:"forward"}),e.length>3)){const t=e.length-1,n={a:e[t-3],b:e[t-2]},i={a:e[t-1],b:e[t]},o=a(n.a.x,n.a.y,n.b.x,n.b.y,i.a.x,i.a.y,i.b.x,i.b.y);!0===o.found&&(n.b.x=o.x,n.b.y=o.y,i.a.x=o.x,i.a.y=o.y)}n++}for(n--;n>=0;){if(0!==n&&(i=s({source:t[n],target:t[n-1]}),e.push({x:i.x1,y:i.y1,direction:"back"},{x:i.x2,y:i.y2,direction:"back"}),e.length>3)){const t=e.length-1,n={a:e[t-3],b:e[t-2]},i={a:e[t-1],b:e[t]},o=a(n.a.x,n.a.y,n.b.x,n.b.y,i.a.x,i.a.y,i.b.x,i.b.y);!0===o.found&&(n.b.x=o.x,n.b.y=o.y,i.a.x=o.x,i.a.y=o.y)}n--}return e}function a(t,e,n,i,o,r,s,l){let a,c;const u={x:null,y:null,found:!1},h=(l-r)*(n-t)-(s-o)*(i-e);if(0===h)return u;a=e-r,c=t-o;const d=(n-t)*a-(i-e)*c;return a=((s-o)*a-(l-r)*c)/h,c=d/h,u.x=t+a*(n-t),u.y=e+a*(i-e),a>0&&1>a&&c>0&&1>c&&(u.found=!0),u}}();return e.x(t=>t.x),e.y(t=>t.y),e.r(()=>t.sankeyWidth/2),e("down"===t.direction?[{x:t.circularPathData.sourceY,y:t.circularPathData.sourceX},{x:t.circularPathData.sourceY,y:t.circularPathData.leftFullExtent},{x:t.circularPathData.verticalFullExtent,y:t.circularPathData.leftFullExtent},{x:t.circularPathData.verticalFullExtent,y:t.circularPathData.rightFullExtent},{x:t.circularPathData.targetY,y:t.circularPathData.rightFullExtent},{x:t.circularPathData.targetY,y:t.circularPathData.targetX}]:[{x:t.circularPathData.sourceX,y:t.circularPathData.sourceY},{x:t.circularPathData.leftFullExtent,y:t.circularPathData.sourceY},{x:t.circularPathData.leftFullExtent,y:t.circularPathData.verticalFullExtent},{x:t.circularPathData.rightFullExtent,y:t.circularPathData.verticalFullExtent},{x:t.circularPathData.rightFullExtent,y:t.circularPathData.targetY},{x:t.circularPathData.targetX,y:t.circularPathData.targetY}])}const Yt={left:S,right:E,center:A,justify:w},Bt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,l;if(0===t.length)return;const a="vertical"===n.orientation?"down":"right",c=n.nodeAlign||"justify",u=null!==(o=n.nodeWidth)&&void 0!==o?o:15,h=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,d=null!==(s=n.iterations)&&void 0!==s?s:100,f=t.map(t=>Object.assign({},t)),y=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}));let g;g="down"===a?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const p=k().extent(g).links(y).nodes(f).nodeAlign(Yt[c]||w).nodeId(t=>t.id).nodeWidth(u).iterations(d);p.nodePaddingRatio&&p.nodePaddingRatio(h),p();for(const e of f){const n=t.find(t=>t.id===e.id);n&&(n.x0=e.x0,n.x1=e.x1,n.y0=e.y0,n.y1=e.y1,n.value=e.value,n.depth=e.depth,n.sourceLinks=e.sourceLinks,n.targetLinks=e.targetLinks,n.width=e.x1-e.x0,n.height=e.y1-e.y0,n.x=e.x0+(e.x1-e.x0)/2,n.y=e.y0+(e.y1-e.y0)/2)}for(const n of y){const i=n.source,o=n.target,r="object"==typeof i&&null!==i?i.id:i+"",s="object"==typeof o&&null!==o?o.id:o+"",c=e.find(t=>("string"==typeof t.source?t.source:t.source.id)===r&&("string"==typeof t.target?t.target:t.target.id)===s);if(c){c.y0=n.y0,c.y1=n.y1,c.sankeyWidth=null!==(l=n.width)&&void 0!==l?l:0,c.circular=!!n.circular,c.circularPathData=n.circularPathData,c.direction=a;const e=t.find(t=>t.id===r),i=t.find(t=>t.id===s);e&&(c.source=e),i&&(c.target=i)}}},buildScene(t,e,n,i){var o,r;const s="vertical"===n.orientation?"down":"right",l=n.nodeStyle,a=n.edgeStyle,c=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,u=n.edgeColorBy||"source",h=Array.isArray(n.colorScheme)?n.colorScheme:M,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=l?l(e):{},o={fill:i.fill||d.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};f.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const p=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of p){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 i;i=t.circular&&t.circularPathData?Ct(t):Dt(t);let o="#999";a?o=a(t).fill||o:"target"===u&&n?o=d.get(n.id)||o:e&&(o=d.get(e.id)||o);const s=a?a(t):{},l={fill:o,fillOpacity:null!==(r=s.fillOpacity)&&void 0!==r?r:c,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};y.push({type:"bezier",pathD:i,bezierCache:t.bezier,style:l,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){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let l,a,c;"down"===s?(l=n.x0+t/2,a=n.y1+14,c="middle"):(i[0]/2>n.x0+t/2?(l=n.x0-6,c="end"):(l=n.x1+6,c="start"),a=n.y0+o/2),g.push({x:l,y:a,text:r+"",anchor:c,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}},Lt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),l=null!==(r=n.forceStrength)&&void 0!==r?r:.1,a=i[0]/2,c=i[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),i=2.399963229728653*e;n.x=a+t*Math.cos(i),n.y=c+t*Math.sin(i)}}const u=Xt(n.nodeSize,n.nodeSizeRange,t),h=P().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),d=i[1]/i[0],f=z().force("charge",T().strength(t=>-25*(t=>u(t))(t))).force("x",$(i[0]/2).strength(.1*d)).force("y",O(i[1]/2).strength(.1));if(f.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}));f.force("link",h),f.force("link").links(t)}.1>f.alpha()&&f.alpha(1),f.stop();for(let t=0;s>t;++t)f.tick();for(const n of e){if("string"==typeof n.source){const e=t.find(t=>t.id===n.source);e&&(n.source=e)}if("string"==typeof n.target){const e=t.find(t=>t.id===n.target);e&&(n.target=e)}}},buildScene(t,e,n,i){var o,r,s;const l=n.nodeStyle,a=n.edgeStyle,c=Xt(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:M,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const d=[],f=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=c(e),n=l?l(e):{},i={fill:n.fill||h.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}for(const n of e){const e="object"==typeof n.source?n.source:Ft(t,n.source),i="object"==typeof n.target?n.target:Ft(t,n.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=a?a(n):{},l={stroke:o.stroke||"#999",strokeWidth:null!==(r=o.strokeWidth)&&void 0!==r?r:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:l,datum:n})}if(!1!==n.showLabels){const e=(g=n.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=c(n);y.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var g;return{sceneNodes:d,sceneEdges:f,labels:y}}};function Ft(t,e){return t.find(t=>t.id===e)}function Xt(t,e,n){var i,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],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()=>r[0];const l=null!==(i=v(s))&&void 0!==i?i:0,a=null!==(o=x(s))&&void 0!==o?o:1;if(l===a)return()=>(r[0]+r[1])/2;const c=p().domain([l,a]).range(r).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?r[0]:c(i)}}const Rt=M,jt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,l=Math.min(i[0],i[1])/2,a=l-r,c=i[0]/2,u=i[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=h(t);g[n][i]=o}const p=C().padAngle(o);s&&p.sortGroups(s);const m=p(g),v=m.groups,x=N().innerRadius(a).outerRadius(l);for(const e of v){const n=t[e.index],i=x.centroid(e);n.x=i[0]+c,n.y=i[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}for(const n of e){const e="string"==typeof n.source?n.source:n.source.id,i="string"==typeof n.target?n.target:n.target.id,o=t.find(t=>t.id===e),r=t.find(t=>t.id===i);o&&(n.source=o),r&&(n.target=r)}for(const n of m){const i=t[n.source.index].id,o=t[n.target.index].id,r=e.find(t=>{const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id;return e===i&&n===o||e===o&&n===i});r&&(r.chordData=n)}},buildScene(t,e,n,i){var o,r;const{groupWidth:s=20,edgeOpacity:l=.5}=n,a=Math.min(i[0],i[1])/2,c=a-s,u=i[0]/2,h=i[1]/2,d=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:Rt,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const m=D().radius(c),v=[],x=[],b=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=d?d(n).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const s=d?d(n):{},l={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};v.push({type:"arc",cx:u,cy:h,innerR:c,outerR:a,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=m({source:Object.assign(Object.assign({},e.source),{startAngle:e.source.startAngle-Math.PI/2,endAngle:e.source.endAngle-Math.PI/2}),target:Object.assign(Object.assign({},e.target),{startAngle:e.target.startAngle-Math.PI/2,endAngle:e.target.endAngle-Math.PI/2})});if(!n)continue;const i=It(n,u,h);let o="#999";if(f)o=f(t).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?o=p.get(n.id)||o:e&&(o=p.get(e.id)||o)}const s=f?f(t):{},a={fill:o,fillOpacity:null!==(r=s.fillOpacity)&&void 0!==r?r:l,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};x.push({type:"ribbon",pathD:i,style:a,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,i=a+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;b.push({x:u+Math.cos(s)*i,y:h+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:x,labels:b}}};function It(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const Ht={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,l=(a=n.childrenAccessor)?"function"==typeof a?a:t=>t[a]:void 0;var a;const c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=Y(r,l);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,d]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=j();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,h,d);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=R();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,h,d);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,l=null!==(r=e.paddingTop)&&void 0!==r?r:0,a=F().size([n,i]).tile(X).padding(s);l>0&&a.paddingTop(l),a(t)}(u,n,h,d);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;L().size([n,i]).padding(r)(t)}(u,n,h,d);break;case"partition":!function(t,e,n,i){var o;B().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,h,d)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:Kt(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Gt(r,i,n):"treemap"===s||"partition"===s?Vt(r,i):"circlepack"===s&&qt(r,i),r.__hierarchyNode=i,t.push(r),y.set(i,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,l,a,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,m=i[1]/2,v="number"==typeof(x=n.nodeSize)?x:5;var x;for(const e of t){let t=e.x,n=e.y;g&&(t+=p,n+=m);const i=o(e),r={fill:i.fill||"#4d430c",stroke:i.stroke||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:i.opacity};h.push({type:"circle",cx:t,cy:n,r:v,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=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 i=e.x,o=e.y,s=n.x,l=n.y;g&&(i+=p,o+=m,s+=p,l+=m);const u=Zt(i,o,s,l,y),h=r(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(a=h.strokeWidth)&&void 0!==a?a:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:b};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=Qt(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,l=n.y;if(g&&(s+=p,l+=m),g){const t=s-p,e=l-m,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=l+e/n*10,r=0>t?"end":"start"):(i=s,o=l-12,r="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(i=s-v-6,r="end"):(i=s+v+6,r="start"),o=l):(i=s,o=l+v+14,r="middle");f.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r;const s=[],l=[],a=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const l=i(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=a[n.depth%a.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};s.push({type:"rect",x:n.x0,y:n.y0,w:t,h:r,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Qt(e.nodeLabel);for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;if((null===(r=i.data)||void 0===r?void 0:r.children)&&i.data.children.length>0&&"partition"!==e.chartType)continue;const s=n?n(i):i.id;s&&(30>t||16>o||l.push({x:i.x0+t/2,y:i.y0+o/2,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,o)/6))}))}}return{sceneNodes:s,sceneEdges:[],labels:l}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,l,a;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const l=i(n);let a=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(a=h[n.depth%h.length]);const u={fill:a,stroke:l.stroke||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:null!==(s=l.opacity)&&void 0!==s?s:.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=Qt(e.nodeLabel);for(const e of t){const t=null!==(l=e.__radius)&&void 0!==l?l:5,i=n?n(e):e.id;if(!i)continue;if(15>t)continue;const o=!((null===(a=e.data)||void 0===a?void 0:a.children)&&e.data.children.length>0);u.push({x:e.x,y:o?e.y:e.y-t+14,text:i+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Gt(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Vt(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 qt(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Zt(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}function Kt(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Qt(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 Ut={sankey:Bt,force:Lt,chord:jt,tree:Ht,cluster:Ht,treemap:Ht,circlepack:Ht,partition:Ht};function Jt(t){return Ut[t]}class te{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.config=t,this.tensionConfig=Object.assign(Object.assign({},Nt),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new zt(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},Nt),t.tensionConfig),"sankey"===t.chartType&&t.showParticles?this.particlePool||(this.particlePool=new zt(2e3)):this.particlePool=null}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,l="function"==typeof i?i:t=>t[i],a="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear();for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},ee(t)),{data:e}))}for(const t of e){const e=a(t)+"",n=c(t)+"",i=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},ee(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},ee(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:i,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:i}=t,o=0===this.nodes.size;let r=!1;this.nodes.has(e)||(this.nodes.set(e,ee(e)),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,ee(n)),this.tension+=this.tensionConfig.newNode,r=!0);const s=this.edgeKey(e,n),l=this.edges.get(s);return l?(l.value+=i,this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||this.tension>=this.tensionConfig.threshold}runLayout(t){const e=Jt(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());if(0!==n.length||e.hierarchical){if(this.prepareForRelayout(),e.computeLayout(n,i,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 i)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}),this.layoutVersion++}}buildScene(t){const e=Jt(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:s}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=s}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 i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.y1,r=n.y0,s=b(o,r);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:s(.5)},{x:t.y1,y:s(.5)},{x:t.y1,y:r}],halfWidth:i}}const o=e.x1,r=n.x0,s=b(o,r);return{circular:!1,points:[{x:o,y:t.y0},{x:s(.5),y:t.y0},{x:s(.5),y:t.y1},{x:r,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t.sankeyWidth||1)/2,n=t.circularPathData;let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.targetY,y:n.rightFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.leftFullExtent,y:n.sourceY},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}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.particlePool&&this.particlePool.clear()}}function ee(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 ne(t,e,n){switch(t.type){case"circle":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);return r>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:r}}(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 i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;let s=Math.atan2(o,i);0>s&&(s+=2*Math.PI);let l,a=t.startAngle,c=t.endAngle;if(0>a&&(a+=2*Math.PI),0>c&&(c+=2*Math.PI),l=a>c?s>=a||c>=s:s>=a&&c>=s,l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}function ie(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;try{const r=new Path2D(t.pathD),s=document.createElement("canvas").getContext("2d");if(!s)return null;if(s.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,s="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&s?(r.x1+s.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const l=t.x1+s*i,a=t.y1+s*o,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-a,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:a,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const i=new Path2D(t.pathD),o=document.createElement("canvas").getContext("2d");if(!o)return null;if(o.isPointInPath(i,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(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,labels:l,title:a,legend:c,foregroundGraphics:u,annotations:h,svgAnnotationRules:d}=e;return t.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${s.left},${s.top})`},l.map((e,n)=>t.createElement("text",{key:"label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),h&&d&&h.map((e,o)=>{const r=d(e,o,{width:n,height:i});return r?t.createElement(t.Fragment,{key:"annotation-"+o},r):null}),u),a&&"string"==typeof a?t.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?t.createElement("foreignObject",{x:0,y:0,width:o,height:s.top},a):null,c&&"object"==typeof c&&"legendGroups"in c?t.createElement("g",{transform:`translate(${o-s.right+10},${s.top})`},c.legendGroups.map((e,n)=>{var i;return t.createElement("g",{key:"legend-group-"+n},null===(i=e.items)||void 0===i?void 0:i.map((e,n)=>t.createElement("g",{key:"legend-item-"+n,transform:`translate(0,${20*n})`},t.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),t.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):c?t.createElement("g",{transform:`translate(${o-s.right+10},${s.top})`},c):null)}function re(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.5*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),t.restore()}function se(t,e){var n;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(),t.restore()}function le(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),t.restore()}function ae(t,e){var n,i;if(!e.pathD)return;t.save();const o=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(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}oe.displayName="NetworkSVGOverlay";const ce=M,ue={top:20,right:80,bottom:20,left:80},he={top:40,right:40,bottom:40,left:40},de=new Set(["chord","force","circlepack"]),fe=[800,600],ye={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 ge({data:e}){var n,i,o,r,s,l;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:ye},t.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const a=e.data,c=null==a?void 0:a.__hierarchyNode;if(c){const e=[];let s=c;for(;s;){const t=null!==(r=null!==(i=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(o=s.data)||void 0===o?void 0:o.id)&&void 0!==r?r:a.id;null!=t&&e.unshift(t+""),s=s.parent}e.length>1&&e.shift();const l=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:ye},t.createElement("div",null,e.map((e,n)=>t.createElement("span",{key:n},n>0&&t.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===l?t.createElement("strong",null,e):t.createElement("span",{style:{opacity:.7}},e)))),null!=a.value&&a.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const u=((null===(s=a.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(l=a.targetLinks)||void 0===l?void 0:l.length)||0),h=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.createElement("div",{className:"semiotic-tooltip",style:ye},t.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),u>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,h!==u&&` (weighted: ${h.toLocaleString()})`))}const pe=n(function(n,a){const{chartType:c,nodes:u,edges:h,data:d,initialEdges:f,nodeIDAccessor:y="id",sourceAccessor:g="source",targetAccessor:p="target",valueAccessor:m="value",childrenAccessor:v,hierarchySum:x,orientation:b="horizontal",nodeAlign:k="justify",nodePaddingRatio:w=.05,nodeWidth:A=15,iterations:E=300,forceStrength:S=.1,padAngle:M=.01,groupWidth:_=20,sortGroups:W,edgeSort:N,treeOrientation:P="vertical",edgeType:z="curve",padding:T,paddingTop:$,tensionConfig:O,showParticles:D=!1,particleStyle:C,nodeStyle:Y,edgeStyle:B,colorBy:L,colorScheme:F="category10",edgeColorBy:X="source",edgeOpacity:R=.5,colorByDepth:j=!1,nodeSize:I=8,nodeSizeRange:H=[5,20],nodeLabel:G,showLabels:V=!0,size:q=fe,margin:Z,className:K,background:Q,enableHover:U=!0,tooltipContent:J,onTopologyChange:tt,annotations:et,svgAnnotationRules:nt,legend:it,title:ot,foregroundGraphics:rt,backgroundGraphics:st}=n,lt=de.has(c)?he:ue,at=Object.assign(Object.assign({},lt),Z),ct=q[0]-at.left-at.right,ut=q[1]-at.top-at.bottom,ht=e(()=>Object.assign(Object.assign({},Nt),O),[O]),dt=e(()=>Object.assign(Object.assign({},Pt),C),[C]),ft=e(()=>({chartType:c,nodeIDAccessor:y,sourceAccessor:g,targetAccessor:p,valueAccessor:m,childrenAccessor:v,hierarchySum:x,orientation:b,nodeAlign:k,nodePaddingRatio:w,nodeWidth:A,iterations:E,forceStrength:S,padAngle:M,groupWidth:_,sortGroups:W,edgeSort:N,treeOrientation:P,edgeType:z,padding:T,paddingTop:$,tensionConfig:ht,showParticles:D,particleStyle:dt,nodeStyle:Y,edgeStyle:B,nodeLabel:G,showLabels:V,colorBy:L,colorScheme:F,edgeColorBy:X,edgeOpacity:R,colorByDepth:j,nodeSize:I,nodeSizeRange:H}),[c,y,g,p,m,v,x,b,k,w,A,E,S,M,_,W,N,P,z,T,$,ht,D,dt,Y,B,G,V,L,F,X,R,j,I,H]),yt=i(null),gt=i(0),pt=i(0),mt=i(!0),vt=i(()=>{}),xt=i(null);xt.current||(xt.current=new te(ft));const[bt,kt]=o(null),[wt,At]=o(0),[Et,St]=o(0),Mt=i(null),_t=i(new Map),Wt=i(0),zt=r(t=>{if("function"==typeof L)return L(t);if("string"==typeof L&&t.data){const e=t.data[L];if(void 0!==e){if(!_t.current.has(e+"")){const t=Array.isArray(F)?F:ce;_t.current.set(e+"",t[Wt.current++%t.length])}return _t.current.get(e+"")}}if(!_t.current.has(t.id)){const e=Array.isArray(F)?F:ce;_t.current.set(t.id,e[Wt.current++%e.length])}return _t.current.get(t.id)},[L,F]);r(t=>{if("function"==typeof X)return X(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===X&&n?zt(n):e?zt(e):"#999"},[X,zt]);const Tt=r(t=>{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===(dt.colorBy||"source")&&n?zt(n):e?zt(e):"#999"},[dt.colorBy,zt]),$t="sankey"===c&&D,Ot=r(()=>{gt.current&&!$t||gt.current||(gt.current=requestAnimationFrame(()=>vt.current()))},[$t]);s(()=>{var t;null===(t=xt.current)||void 0===t||t.updateConfig(ft),mt.current=!0,Ot()},[ft,Ot]);const Dt=r(()=>{const t=xt.current;if(t&&(t.runLayout([ct,ut]),t.buildScene([ct,ut]),mt.current=!0,At(t.layoutVersion),tt)){const{nodes:e,edges:n}=t.getLayoutData();tt(e,n)}},[ct,ut,tt]),Ct=r(t=>{const e=xt.current;e&&(e.ingestEdge(t)&&Dt(),Ot())},[Dt,Ot]),Yt=r(t=>{const e=xt.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&Dt(),Ot()},[Dt,Ot]),Bt=r(()=>{var t;null===(t=xt.current)||void 0===t||t.clear(),_t.current.clear(),Wt.current=0,At(0),kt(null),Mt.current=null,mt.current=!0,Ot()},[Ot]),Lt=r(()=>{const t=xt.current;t&&(t.tension+=999,Dt(),Ot())},[Dt,Ot]);l(a,()=>({push:Ct,pushMany:Yt,clear:Bt,getTopology:()=>{var t,e;return null!==(e=null===(t=xt.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},relayout:Lt,getTension:()=>{var t,e;return null!==(e=null===(t=xt.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ct,Yt,Bt,Lt]);const Ft=["tree","cluster","treemap","circlepack","partition"].includes(c),Xt=Ft?d||(Array.isArray(h)?void 0:h):void 0;s(()=>{const t=xt.current;if(t)if(Ft&&Xt)t.ingestHierarchy(Xt,[ct,ut]),t.buildScene([ct,ut]),mt.current=!0,Ot();else{const e=u||[],n=Array.isArray(h)?h:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[ct,ut]),t.buildScene([ct,ut]),mt.current=!0,Ot()}},[u,h,d,Xt,Ft,ct,ut,ft,Ot]),s(()=>{f&&f.length>0&&Yt(f)},[]);const Rt=i(()=>{}),jt=i(()=>{});Rt.current=t=>{if(!U)return;const e=yt.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-at.left,o=t.clientY-n.top-at.top;if(0>i||i>ct||0>o||o>ut)return void(Mt.current&&(Mt.current=null,kt(null),Ot()));const r=xt.current;if(!r)return;const s=function(t,e,n,i,o=30){let r=null,s=o,l=1/0;for(const e of t){const t=ne(e,n,i);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(r=t,l=n)}else s>t.distance&&(r=t,s=t.distance)}if(r)return r;for(const t of e){const e=ie(t,n,i);e&&s>e.distance&&(r=e,s=e.distance)}return r}(r.sceneNodes,r.sceneEdges,i,o);if(!s)return void(Mt.current&&(Mt.current=null,kt(null),Ot()));const l={type:s.type,data:s.datum,x:s.x,y:s.y};Mt.current=l,kt(l),Ot()},jt.current=()=>{Mt.current&&(Mt.current=null,kt(null),Ot())};const It=r(t=>Rt.current(t),[]),Ht=r(()=>jt.current(),[]);vt.current=()=>{var t;gt.current=0;const e=yt.current;if(!e)return;const n=e.getContext("2d");if(!n)return;const i=xt.current;if(!i)return;const o=performance.now(),r=pt.current?Math.min((o-pt.current)/1e3,.1):.016;pt.current=o;const s=i.advanceTransition(o);(s||mt.current)&&i.buildScene([ct,ut]);const l="undefined"!=typeof window&&window.devicePixelRatio||1;if(e.width=q[0]*l,e.height=q[1]*l,e.style.width=q[0]+"px",e.style.height=q[1]+"px",n.scale(l,l),n.translate(at.left,at.top),n.clearRect(-at.left,-at.top,q[0],q[1]),Q&&(n.fillStyle=Q,n.fillRect(0,0,ct,ut)),function(t,e){for(const n of e)switch(n.type){case"bezier":re(t,n);break;case"line":se(t,n);break;case"ribbon":le(t,n);break;case"curved":ae(t,n)}}(n,i.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),t.restore())}}(n,i.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore())}}(n,i.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(n,i.sceneNodes),D&&i.particlePool){const e=Array.from(i.edges.values());if(e.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:Pt.spawnRate,l=null!==(r=i.maxPerEdge)&&void 0!==r?r:Pt.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=l)continue;const r=o.value*s*n,a=Math.floor(r),c=r-a;let u=a;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(i.particlePool,e,r,dt);const o=.5*(null!==(t=dt.speedMultiplier)&&void 0!==t?t:1);i.particlePool.step(r,o,e),function(t,e,n,i,o){var r,s;const l=null!==(r=i.radius)&&void 0!==r?r:Pt.radius,a=null!==(s=i.opacity)&&void 0!==s?s:Pt.opacity;t.globalAlpha=a;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(a){if("function"==typeof i.color){const e="object"==typeof a.source?a.source:null;t.fillStyle=e?i.color(a,e):"#666"}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(a);t.beginPath(),t.arc(s.x,s.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(n,i.particlePool,e,dt,Tt)}}const a=mt.current;mt.current=!1,(a||s)&&St(t=>t+1),($t||s)&&(gt.current=requestAnimationFrame(()=>vt.current()))},s(()=>(Ot(),()=>{gt.current&&cancelAnimationFrame(gt.current)}),[Ot]),s(()=>{mt.current=!0,Ot()},[c,ct,ut,Q,Ot]);const Gt=U&&bt?t.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:at.left+bt.x,top:at.top+bt.y,transform:`translate(${bt.x>.6*ct?"calc(-100% - 12px)":"12px"}, ${.3*ut>bt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},J?J(bt):t.createElement(ge,{data:bt})):null,Vt=xt.current;return t.createElement("div",{className:"stream-network-frame"+(K?" "+K:""),style:{position:"relative",width:q[0],height:q[1]},onMouseMove:U?It:void 0,onMouseLeave:U?Ht:void 0},st&&t.createElement("svg",{style:{position:"absolute",top:0,left:0,width:q[0],height:q[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${at.left},${at.top})`},st)),t.createElement("canvas",{ref:yt,style:{position:"absolute",top:0,left:0}}),t.createElement(oe,{width:ct,height:ut,totalWidth:q[0],totalHeight:q[1],margin:at,labels:(null==Vt?void 0:Vt.labels)||[],title:ot,legend:it,foregroundGraphics:rt,annotations:et,svgAnnotationRules:nt,annotationFrame:Et}),Gt)});function me(t,e){return t?!0===t?{name:"hover",fields:[]}:"string"==typeof t?{name:t,fields:[]}:{name:t.name||"hover",fields:t.fields}:null}function ve(t){let e=new EventTarget,n=t(function(t){n=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 xe(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function be(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}pe.displayName="StreamNetworkFrame";const[ke,we]=function(n){let i=a(null),r=ve(n);return[function({children:o}){let r=e(()=>ve(n),[]);return t.createElement(i.Provider,{value:r,children:o})},t=>{var e;let n=null!==(e=c(i))&&void 0!==e?e:r;return function(t,e){const[n,i]=o(e);return u(()=>t(()=>i(e)),[t]),n}(n.subscribe,()=>t(n.getState()))}]}(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=be(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=be(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}}));function Ae(t){const n=t.name||"hover",{fields:i}=t,{predicate:o,isActive:s,selectPoints:l,clear:a}=function(t){const n=h(),i=t.clientId||n,{name:o}=t,s=we(t=>t.selections.get(o)),l=we(t=>t.setClause),a=we(t=>t.clearClause),c=e(()=>!!s&&s.clauses.size>0,[s]);return{predicate:e(()=>s&&0!==s.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(xe(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(s,i):()=>!0,[s,i]),isActive:c,selectPoints:r(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};l(o,{clientId:i,type:"point",fields:e})},[i,o,l]),selectInterval:r(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};l(o,{clientId:i,type:"interval",fields:e})},[i,o,l]),clear:r(()=>{a(o,i)},[a,o,i]),clientId:i}}({name:n});return{onHover:r(t=>{if(!t)return void a();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&l(e)},[i,l,a]),predicate:o,isActive:s}}const Ee=n(function(e,n){const{size:o,width:s,height:a,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:g,valueAccessor:p,timeExtent:m,valueExtent:v,extentPadding:x,stroke:b="#007bff",strokeWidth:k=2,strokeDasharray:w,showAxes:A=!0,background:E,enableHover:S,tooltipContent:M,tooltip:_,onHover:W,annotations:N,svgAnnotationRules:P,tickFormatTime:z,tickFormatValue:T,decay:$,pulse:O,staleness:D,transition:C,linkedHover:Y}=e,B=null!=s&&null!=a?[s,a]:o||[500,300],L=null!=M?M:_,F=i(null),X=me(Y),R=Ae({name:(null==X?void 0:X.name)||"hover",fields:(null==X?void 0:X.fields)||[]}),j=r(t=>{W&&W(t),Y&&R.onHover(t?t.data||t:null)},[W,Y,R]);return l(n,()=>({push:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=F.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=F.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),t.createElement(Wt,{ref:F,chartType:"line",runtimeMode:"streaming",size:B,margin:c,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:g,valueAccessor:p,xExtent:m,yExtent:v,extentPadding:x,lineStyle:{stroke:b,strokeWidth:k,strokeDasharray:w},showAxes:A,background:E,hoverAnnotation:S,tooltipContent:L,customHoverBehavior:j,annotations:N,svgAnnotationRules:P,tickFormatTime:z,tickFormatValue:T,decay:$,pulse:O,staleness:D,transition:C})});Ee.displayName="RealtimeLineChart";const Se=n(function(e,n){const{binSize:o,size:s,width:a,height:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,fill:A,stroke:E,strokeWidth:S,gap:M,showAxes:_=!0,background:W,enableHover:N,tooltipContent:P,tooltip:z,onHover:T,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C,linkedHover:Y}=e,B=null!=a&&null!=c?[a,c]:s||[500,300],L=null!=P?P:z,F=i(null),X=me(Y),R=Ae({name:(null==X?void 0:X.name)||"hover",fields:(null==X?void 0:X.fields)||[]}),j=r(t=>{T&&T(t),Y&&R.onHover(t?t.data||t:null)},[T,Y,R]);l(n,()=>({push:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=F.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=F.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const I={};return null!=A&&(I.fill=A),null!=E&&(I.stroke=E),null!=S&&(I.strokeWidth=S),null!=M&&(I.gap=M),t.createElement(Wt,{ref:F,chartType:"bar",runtimeMode:"streaming",size:B,margin:u,className:h,arrowOfTime:d,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,binSize:o,categoryAccessor:k,barColors:w,barStyle:I,showAxes:_,background:W,hoverAnnotation:N,tooltipContent:L,customHoverBehavior:j,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C})});Se.displayName="RealtimeTemporalHistogram";const Me=Se,_e=n(function(e,n){const{size:o,width:s,height:a,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:g,valueAccessor:p,timeExtent:m,valueExtent:v,extentPadding:x,categoryAccessor:b,colors:k,radius:w,fill:A,opacity:E,stroke:S,strokeWidth:M,showAxes:_=!0,background:W,enableHover:N,tooltipContent:P,tooltip:z,onHover:T,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C,linkedHover:Y}=e,B=null!=s&&null!=a?[s,a]:o||[500,300],L=null!=P?P:z,F=i(null),X=me(Y),R=Ae({name:(null==X?void 0:X.name)||"hover",fields:(null==X?void 0:X.fields)||[]}),j=r(t=>{T&&T(t),Y&&R.onHover(t?t.data||t:null)},[T,Y,R]);l(n,()=>({push:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=F.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=F.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const I={};return null!=w&&(I.radius=w),null!=A&&(I.fill=A),null!=E&&(I.opacity=E),null!=S&&(I.stroke=S),null!=M&&(I.strokeWidth=M),t.createElement(Wt,{ref:F,chartType:"swarm",runtimeMode:"streaming",size:B,margin:c,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:g,valueAccessor:p,xExtent:m,yExtent:v,extentPadding:x,categoryAccessor:b,barColors:k,swarmStyle:I,showAxes:_,background:W,hoverAnnotation:N,tooltipContent:L,customHoverBehavior:j,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C})});_e.displayName="RealtimeSwarmChart";const We=n(function(e,n){const{size:o,width:s,height:a,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:g,valueAccessor:p,timeExtent:m,valueExtent:v,extentPadding:x,positiveColor:b,negativeColor:k,connectorStroke:w,connectorWidth:A,gap:E,stroke:S,strokeWidth:M,showAxes:_=!0,background:W,enableHover:N,tooltipContent:P,tooltip:z,onHover:T,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C,linkedHover:Y}=e,B=null!=s&&null!=a?[s,a]:o||[500,300],L=null!=P?P:z,F=i(null),X=me(Y),R=Ae({name:(null==X?void 0:X.name)||"hover",fields:(null==X?void 0:X.fields)||[]}),j=r(t=>{T&&T(t),Y&&R.onHover(t?t.data||t:null)},[T,Y,R]);l(n,()=>({push:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=F.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=F.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=F.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const I={};return null!=b&&(I.positiveColor=b),null!=k&&(I.negativeColor=k),null!=w&&(I.connectorStroke=w),null!=A&&(I.connectorWidth=A),null!=E&&(I.gap=E),null!=S&&(I.stroke=S),null!=M&&(I.strokeWidth=M),t.createElement(Wt,{ref:F,chartType:"waterfall",runtimeMode:"streaming",size:B,margin:c,className:u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:g,valueAccessor:p,xExtent:m,yExtent:v,extentPadding:x,waterfallStyle:I,showAxes:_,background:W,hoverAnnotation:N,tooltipContent:L,customHoverBehavior:j,annotations:$,svgAnnotationRules:O,tickFormatTime:D,tickFormatValue:C})});We.displayName="RealtimeWaterfallChart";const Ne=n(function(e,n){const{size:o,width:r,height:s,margin:a,className:c,arrowOfTime:u="right",windowMode:h="sliding",windowSize:d=200,data:f,timeAccessor:y,valueAccessor:g,categoryAccessor:p,timeExtent:m,valueExtent:v,extentPadding:x,heatmapXBins:b=20,heatmapYBins:k=20,aggregation:w="count",showAxes:A=!0,background:E,enableHover:S,tooltipContent:M,tooltip:_,onHover:W,annotations:N,svgAnnotationRules:P,tickFormatTime:z,tickFormatValue:T,decay:$,pulse:O,staleness:D}=e,C=null!=r&&null!=s?[r,s]:o||[500,300],Y=null!=M?M:_,B=i(null);return l(n,()=>({push:t=>{var e;return null===(e=B.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=B.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=B.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=B.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),t.createElement(Wt,{ref:B,chartType:"heatmap",runtimeMode:"streaming",size:C,margin:a,className:c,arrowOfTime:u,windowMode:h,windowSize:d,data:f,timeAccessor:y,valueAccessor:g,categoryAccessor:p,xExtent:m,yExtent:v,extentPadding:x,heatmapXBins:b,heatmapYBins:k,heatmapAggregation:w,showAxes:A,background:E,hoverAnnotation:S,tooltipContent:Y,customHoverBehavior:W,annotations:N,svgAnnotationRules:P,tickFormatTime:z,tickFormatValue:T,decay:$,pulse:O,staleness:D})});Ne.displayName="RealtimeHeatmap";export{V as IncrementalExtent,Ne as RealtimeHeatmap,Me as RealtimeHistogram,Ee as RealtimeLineChart,_e as RealtimeSwarmChart,We as RealtimeWaterfallChart,G as RingBuffer,pe as StreamNetworkFrame,Wt as StreamXYFrame};
|
|
1
|
+
import*as t from"react";import{useMemo as e,forwardRef as n,useRef as r,useState as i,useCallback as o,useEffect as a,useImperativeHandle as l,createContext as s,useContext as c,useLayoutEffect as u,useId as h}from"react";import{brushX as d,brushY as f,brush as y}from"d3-brush";import{select as g}from"d3-selection";import{scaleLinear as p}from"d3-scale";import{bin as m,min as v,groups as x,max as b,sum as k,mean as w,group as E}from"d3-array";import{packEnclose as A,hierarchy as M,partition as S,pack as P,treemap as L,treemapBinary as D,cluster as _,tree as $}from"d3-hierarchy";import{interpolateNumber as T}from"d3-interpolate";import{schemeCategory10 as W}from"d3-scale-chromatic";import{forceLink as N,forceSimulation as O,forceManyBody as z,forceX as I,forceY as C}from"d3-force";import{ribbon as R,chord as Y}from"d3-chord";import{arc as B}from"d3-shape";const j=5e3;class F{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}setBoundedData(t){if(t===this.lastBoundedData)return;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,j),bounded:!0,totalSize:t.length});let e=j;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+j,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 X{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 H{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 G(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 q(t,e,n,r,i,o,a){const l=[],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);l.push([c,e.y(a)]),s.push([c,e.y(i)])}return{type:"area",topPath:l,bottomPath:s,style:o,datum:t,group:a}}function Z(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 U(t,e,n,r,i,o){return{type:"heatcell",x:t,y:e,w:n,h:r,fill:i,datum:o}}function Q(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function J(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class tt{constructor(t){this.xExtent=new H,this.yExtent=new H,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 X(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Q(t.timeAccessor||t.xAccessor,"time"),this.getY=Q(t.valueAccessor||t.yAccessor,"value")):(this.getX=Q(t.xAccessor,"x"),this.getY=Q(t.yAccessor,"y")),this.getGroup=J(t.groupAccessor),this.getCategory=J(t.categoryAccessor),this.getSize=t.sizeAccessor?Q(t.sizeAccessor,"size"):void 0,this.getColor=J(t.colorAccessor),this.getBounds=t.boundsAccessor?Q(t.boundsAccessor,"bounds"):void 0,this.getPointId=J(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=Q(t.openAccessor,"open"),this.getHigh=Q(t.highAccessor,"high"),this.getLow=Q(t.lowAccessor,"low"),this.getClose=Q(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new X(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))}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)),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,r,i,o,a;const{config:l,buffer:s}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(s,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of s)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(s,this.getY);const c=this.xExtent.extent,u=this.yExtent.extent;let h=l.xExtent?[null!==(e=l.xExtent[0])&&void 0!==e?e:c[0],null!==(n=l.xExtent[1])&&void 0!==n?n:c[1]]:c,d=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:u[0],null!==(i=l.yExtent[1])&&void 0!==i?i:u[1]]:u;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&s.size>0)if(l.normalize)d=[0,1+l.extentPadding];else{const t=s.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);d=[0,r+(r>0?r*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&s.size>0){const[,t]=function(t,e,n,r,i){const o=G(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]}(s,this.getX,this.getY,l.binSize,this.getCategory);d=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&s.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]}(s,this.getY),n=e-t,r=n>0?n*l.extentPadding:1;d=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const t=s.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>d[1]&&(d[1]=t+n),d[0]>t-n&&(d[0]=t-n))}}const t=d[1]-d[0],e=t>0?t*l.extentPadding:1,n=null===(o=l.yExtent)||void 0===o?void 0:o[0],r=null===(a=l.yExtent)||void 0===a?void 0:a[1];d=[null!=n?d[0]:d[0]-e,null!=r?d[1]:d[1]+e]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(y=l.arrowOfTime)||"down"===y?"y":"x")){const e="right"===l.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:p().domain(h).range(e),y:p().domain(d).range([t.height,0])}}else{const e="down"===l.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:p().domain(d).range([0,t.width]),y:p().domain(h).range(e)}}else this.scales={x:p().domain(h).range([0,t.width]),y:p().domain(d).range([t.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const g=s.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,g),this.config.pulse&&this.applyPulse(this.scene,g),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]);n.push(q(t.data,this.scales,this.getX,this.getY,r,e,t.key))}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=Z(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=Q(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(U(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=Q(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(U(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=G(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 k=a.y(y),w=a.y(g);o.push(K(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||"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 et(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 nt(t,e,n){if(0===t.path.length)return null;const r=lt(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 rt(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 it(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 ot(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 at(t,e,n){if(0===t.topPath.length)return null;const r=lt(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 lt(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}const st={fill:e=>t.createElement("rect",{style:e,width:20,height:20}),line:e=>t.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function ct(t,e,n,r){let i;return i="function"==typeof n?n(t):(0,st[n])(r(t,e)),i}function ut(e){const{legendGroups:n,customClickBehavior:r,title:i="Legend",width:o=100,height:a=20,orientation:l="vertical"}=e,s="vertical"===l?(({legendGroups:e,width:n,customClickBehavior:r})=>{let i=30;const o=[];return e.forEach((e,a)=>{i+=5,o.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,e.label&&(i+=20,o.push(t.createElement("text",{key:"legend-text-"+a,y:i,className:"legend-group-label"},e.label)),i+=10),o.push(t.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${i})`},((e,n)=>{const{type:r="fill",styleFn:i,items:o}=e,a=[];let l=0;return o.forEach((e,o)=>{const s=ct(e,o,r,i);a.push(t.createElement("g",{key:"legend-item-"+o,transform:`translate(0,${l})`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},s,t.createElement("text",{y:15,x:30},e.label))),l+=25}),a})(e,r))),i+=25*e.items.length+10}),o})({legendGroups:n,width:o,customClickBehavior:r}):(({legendGroups:e,title:n,height:r,customClickBehavior:i})=>{let o=0;const a=[],l=!1===n?10:40;return e.forEach((n,s)=>{n.label&&(a.push(t.createElement("text",{key:"legend-text-"+s,transform:`translate(${o},${l}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),o+=20);const c=((e,n)=>{const{type:r="fill",styleFn:i,items:o}=e,a=[];let l=0;return o.forEach((e,o)=>{const s=ct(e,o,r,i);a.push(t.createElement("g",{key:"legend-item-"+o,transform:`translate(${l},0)`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},s,t.createElement("text",{y:15,x:25},e.label))),l+=35,l+=8*e.label.length}),{items:a,offset:l}})(n,i);a.push(t.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(${o},${l})`},c.items)),o+=c.offset+5,e[s+1]&&a.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:o,y1:l-10,x2:o,y2:r+l+10})),o+=15}),t.createElement("g",null,!1!==n&&t.createElement("line",{x1:0,x2:o+10,y1:l-10,y2:l-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:n,title:i,height:a,customClickBehavior:r});return t.createElement("g",null,void 0!==i&&t.createElement("text",{className:"legend-title",y:20,x:"horizontal"===l?0:o/2,textAnchor:"horizontal"===l?"start":"middle"},i),s)}function ht(t){return"string"==typeof t?{type:t}:t}function dt({orient:n,config:r,values:i,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}}(r),c="top"===n||"bottom"===n,u=e(()=>{if(0===i.length)return null;const e=o.domain(),r=a-8;if("boxplot"===s.type){const e=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)}}(i);if(!e)return null;const{q1:a,median:l,q3:u,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*r,20),y=(r-f)/2+4;if(c){const e=o(a),r=o(u),i=o(l),c=o(h),g=o(d),p="top"===n?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+n},t.createElement("line",{x1:c,y1:m+p*(y+f/2),x2:g,y2:m+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:Math.min(e,r),y:"top"===n?m-y-f:m+y,width:Math.abs(r-e),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:i,y1:"top"===n?m-y-f:m+y,x2:i,y2:"top"===n?m-y:m+y+f,stroke:s.fill,strokeWidth:2}))}{const e=o(a),r=o(u),i=o(l),c=o(h),g=o(d),p="left"===n?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+n},t.createElement("line",{x1:m+p*(y+f/2),y1:c,x2:m+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:"left"===n?m-y-f:m+y,y:Math.min(e,r),width:f,height:Math.abs(r-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:"left"===n?m-y-f:m+y,y1:i,x2:"left"===n?m-y:m+y+f,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=m().domain(e).thresholds(s.bins)(i);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 t.createElement("g",{"data-testid":"marginal-histogram-"+n},u.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const a=e.length/h*r;if(c){const r=o(e.x0),l=o(e.x1)-o(e.x0);return t.createElement("rect",{key:i,x:r,y:"top"===n?-4-a:4,width:Math.max(l,.5),height:a,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const r=o(e.x0),l=o(e.x1)-o(e.x0);return t.createElement("rect",{key:i,x:"left"===n?-4-a:4,y:Math.min(r,r+l),width:a,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const e=r/2+4,i=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const a=t.length/h*(r/2),l=o((t.x0+t.x1)/2);i.push(c?`${l},${"top"===n?-(e-a):e-a}`:`${"left"===n?-(e-a):e-a},${l}`)}for(let t=u.length-1;t>=0;t--){const a=u[t];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(r/2),s=o((a.x0+a.x1)/2);i.push(c?`${s},${"top"===n?-(e+l):e+l}`:`${"left"===n?-(e+l):e+l},${s}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+n},t.createElement("polygon",{points:i.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const e=[];if(c){const t=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${i},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,a=o((t.x0+t.x1)/2);e.push(`L${a},${"top"===n?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;e.push(`L${a},${t}`),e.push("Z")}else{const t=0,i=null!=u[0].x0?o(u[0].x0):0;e.push(`M${t},${i}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,a=o((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;e.push(`L${t},${a}`),e.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+n},t.createElement("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[i,o,s,a,l,n,c,4]);return u?t.createElement("g",{className:"marginal-"+n,"data-testid":"marginal-"+n},u):null}function ft(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 yt(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 gt(e){const{x:n=0,y:r=0,dx:i,dy:o,nx:a,ny:l,note:s,connector:c,subject:u,type:h,color:d,className:f,disable:y,events:g={},"data-testid":p}=e,m=new Set(Array.isArray(y)?y:[]);let v=i||0,x=o||0;null!=a&&(v=a-n),null!=l&&(x=l-r);const b="string"==typeof h?h:"label";if("bracket"===b&&u&&0===v&&0===x)if(void 0!==u.width){v=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;v=t+(0>t?-5:5),x=u.height/2}return t.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${r})`,"data-testid":p},g),!m.has("connector")&&function(e,n,r,i,o,a){const l=[];let s=0,c=0;if("callout-circle"!==o&&"label"!==o||!(null==a?void 0:a.radius)){if("callout-rect"===o&&a){const t=a.width||0,r=a.height||0;if(t>0||r>0){const i=t/2,o=r/2,a=e-i,l=n-o;if(0!==a||0!==l){const e=Math.abs(a),n=Math.abs(l),u=t/2,h=r/2,d=e*h>n*u?u/e:h/n;s=i+a*d,c=o+l*d}}}else if("bracket"===o&&a){const t=a.width,e=a.height,n=a.depth||30;void 0!==t?(s=t/2,c=n):void 0!==e&&(s=n,c=e/2)}}else{const t=(a.radius||0)+(a.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const r=Math.atan2(n,e);s=Math.cos(r)*t,c=Math.sin(r)*t}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(n-c,2))>.5&&(l.push(t.createElement("line",{key:"connector-line",x1:s,y1:c,x2:e,y2:n,stroke:i||"currentColor"})),"arrow"===(null==r?void 0:r.end))){const r=10,o=16/180*Math.PI,a=Math.atan2(n-c,e-s);l.push(t.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+r*Math.cos(a+o)},${c+r*Math.sin(a+o)}L${s+r*Math.cos(a-o)},${c+r*Math.sin(a-o)}Z`,fill:i||"currentColor",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},l)}(v,x,c,d,b,u),!m.has("subject")&&function(e,n,r,i,o){var a;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:r||"currentColor"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&l.push(t.createElement("rect",{key:"subject-rect",width:e,height:i,fill:"none",stroke:r||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,a=o||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;l.push(t.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-a,x2:i,y2:(n.y2||0)-a,stroke:r||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-a;l.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:r||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:r||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:r||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==e&&l.push(t.createElement("path",{key:"bracket-path",d:yt((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:r||"currentColor"}));break}}return t.createElement("g",{className:"annotation-subject"},l)}(b,u,d,n,r),!m.has("note")&&function(e,n,r,i){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:o,title:a,orientation:l,align:s,wrap:c=120,noWrap:u}=e;if(!o&&!a)return t.createElement("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(n)>Math.abs(r)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===h?0>n?"right":"left":0>r?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const y=16,g=a?u?[a]:ft(a,c):[],p=o?u?[o]:ft(o,c):[],m="leftRight"===h?"end"===f?-4:4:0;let v=0;const x=[];g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:f,fontWeight:"bold"},g.map((e,n)=>t.createElement("tspan",{key:n,x:m,dy:0===n?0:y},e)))),v=g.length*y),p.length>0&&x.push(t.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:f,y:v},p.map((e,n)=>t.createElement("tspan",{key:n,x:m,dy:0===n?0:y},e))));let b=null;if((a||o)&&(0!==n||0!==r))if("topBottom"===h){const e=Math.min(c,120);let n=0,r=e;"end"===f?(n=-e,r=0):"middle"===f&&(n=-e/2,r=e/2),b=t.createElement("line",{className:"note-line",x1:n,x2:r,y1:0,y2:0,stroke:i||"currentColor"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,r=e;"bottom"===d?(n=-e,r=0):"middle"===d&&(n=-e/2,r=e/2),b=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:r,stroke:i||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===h?w=0>r?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>r?-(k+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${r})`},t.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(s,v,x,d))}function pt(e){var n,r;const{noteData:i}=e,{screenCoordinates:o}=i,a="string"==typeof i.type?i.type:"label",l=i.eventListeners||i.events||{};if(i.coordinates&&o){const e=i.nx||o[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),l=i.ny||o[0][1]+(null!==(r=i.dy)&&void 0!==r?r:0),s=o.map((n,r)=>{const o=Object.assign({},i,{note:0===r?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t.createElement(gt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+r},o,{type:a}))});return t.createElement("g",null,s)}const s=i.note||{title:"none",label:i.label};return t.createElement(gt,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${i.i}`,events:l},i,{type:a}))}function mt(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 vt(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 xt(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}function bt(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 kt(t){return Math.round(100*t)/100+""}function wt(n){const{width:r,height:i,totalWidth:o,totalHeight:a,margin:l,scales:s,showAxes:c,axes:u,xLabel:h,yLabel:d,xFormat:f,yFormat:y,showGrid:g,title:p,legend:m,foregroundGraphics:v,marginalGraphics:x,xValues:b,yValues:k,annotations:w,svgAnnotationRules:E,annotationFrame:M,xAccessor:S,yAccessor:P,annotationData:L,pointNodes:D,children:_}=n,$=e(()=>c&&s?s.x.ticks(5).map(t=>({value:t,pixel:s.x(t),label:(f||kt)(t)})):[],[c,s,f]),T=e(()=>c&&s?s.y.ticks(5).map(t=>({value:t,pixel:s.y(t),label:(y||kt)(t)})):[],[c,s,y]),W=e(()=>{if(!w||0===w.length)return null;const e=function(e,n,r){var i,o,a,l,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,M,S,P,L,D,_,$,T,W,N,O,z;switch(e.type){case"label":{let i=null,o=null;if(null!=e.pointId&&r.pointNodes){const t=r.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;i=t.x,o=t.y}else i=mt(e,r),o=vt(e,r);return null==i||null==o?null:xt(i,o,r)?t.createElement(pt,{key:"ann-"+n,noteData:{x:i,y:o,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let i=null,o=null;if(null!=e.pointId&&r.pointNodes){const t=r.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;i=t.x,o=t.y}else i=mt(e,r),o=vt(e,r);return null==i||null==o?null:xt(i,o,r)?t.createElement(pt,{key:"ann-"+n,noteData:{x:i,y:o,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const i=mt(e,r);if(null==i)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:i,y1:0,x2:i,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:i+4,y:12,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const i=vt(e,r);if(null==i)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:i,x2:r.width||0,y2:i,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:i-4,textAnchor:"end",fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const i=(e.coordinates||[]).map(t=>({x:mt(Object.assign(Object.assign({},t),{type:"point"}),r),y:vt(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=A(i),a=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:o.x,cy:o.y,r:o.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:o.x,y:o.y-o.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const i=(e.coordinates||[]).map(t=>({x:mt(Object.assign(Object.assign({},t),{type:"point"}),r),y:vt(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const o=e.padding||10,a=i.map(t=>t.x),l=i.map(t=>t.y),s=Math.min(...a)-o,c=Math.max(...a)+o,u=Math.min(...l)-o,h=Math.max(...l)+o;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:s,y:u,width:c-s,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const i=r.data||[],o="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],a=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},o.map((n,i)=>{const o=mt(n,r),l=vt(n,r);return null==o||null==l?null:t.createElement("circle",Object.assign({key:i,cx:o,cy:l,r:e.r||6},a))}))}case"bracket":{const i=mt(e,r),o=vt(e,r);return t.createElement(pt,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const h=r.data||[];if(2>h.length)return null;const d=r.xAccessor||"x",f=r.yAccessor||"y",y=h.map(t=>[t[d],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(o=null===(i=r.scales)||void 0===i?void 0:i.x)&&void 0!==o?o:null===(a=r.scales)||void 0===a?void 0:a.time,p=null!==(s=null===(l=r.scales)||void 0===l?void 0:l.y)&&void 0!==s?s:null===(c=r.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const m=e.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=e.bandwidth)&&void 0!==u?u:.3);else{let t;try{const n=require("regression");t="polynomial"===m?n.polynomial(y,{order:e.order||2}):n.linear(y)}catch(t){return null}v=t.points}const x=v.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=e.color||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:g(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:b,fontSize:11},e.label))}case"band":{const i=null!==(d=null===(h=r.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(f=r.scales)||void 0===f?void 0:f.value,o=null!==(y=null==i?void 0:i(e.y0))&&void 0!==y?y:0,a=null!==(g=null==i?void 0:i(e.y1))&&void 0!==g?g:r.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(o,a),width:r.width||0,height:Math.abs(a-o),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(o,a)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"anomaly-band":{const i=r.data||[];if(2>i.length)return null;const o=r.yAccessor||"y",a=null!==(m=null===(p=r.scales)||void 0===p?void 0:p.x)&&void 0!==m?m:null===(v=r.scales)||void 0===v?void 0:v.time,l=null!==(b=null===(x=r.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=r.scales)||void 0===k?void 0:k.value;if(!a||!l)return null;const s=i.map(t=>t[o]).filter(t=>null!=t&&isFinite(t));if(2>s.length)return null;const c=s.reduce((t,e)=>t+e,0)/s.length,u=s.reduce((t,e)=>t+Math.pow(e-c,2),0)/s.length,h=Math.sqrt(u),d=null!==(w=e.threshold)&&void 0!==w?w:2,f=c-d*h,y=!1!==e.showBand,g=e.fill||"#6366f1",A=null!==(E=e.fillOpacity)&&void 0!==E?E:.1,S=e.anomalyColor||"#ef4444",P=null!==(M=e.anomalyRadius)&&void 0!==M?M:6,L=l(c+d*h),D=l(f),_=i.filter(t=>{const e=t[o];return null!=e&&Math.abs(e-c)>d*h});return t.createElement("g",{key:"ann-"+n},y&&t.createElement("rect",{x:0,y:Math.min(L,D),width:r.width||0,height:Math.abs(D-L),fill:g,fillOpacity:A}),_.map((e,n)=>{const i=mt(e,r),o=vt(e,r);return null==i||null==o?null:t.createElement("circle",{key:n,cx:i,cy:o,r:P,fill:S,fillOpacity:.7,stroke:S,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(L,D)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const i=r.data||[];if(3>i.length)return null;const o=r.xAccessor||"x",a=r.yAccessor||"y",l=null!==(P=null===(S=r.scales)||void 0===S?void 0:S.x)&&void 0!==P?P:null===(L=r.scales)||void 0===L?void 0:L.time,s=null!==(_=null===(D=r.scales)||void 0===D?void 0:D.y)&&void 0!==_?_:null===($=r.scales)||void 0===$?void 0:$.value;if(!l||!s)return null;const c=i.map(t=>[t[o],t[a]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}catch(t){return null}else{const t=c.length;let e=0,n=0,r=0,i=0;for(const[t,o]of c)e+=t,n+=o,r+=t*t,i+=t*o;const o=t*r-e*e;if(1e-12>Math.abs(o))return null;const a=(t*i-e*n)/o,l=(n-a*e)/t;u=t=>l+a*t}const h=c.length,d=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(d/Math.max(h-2,1)),y=c.reduce((t,e)=>t+e[0],0)/h,g=c.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(T=e.confidence)&&void 0!==T?T:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(W=e.steps)&&void 0!==W?W:5,x=c[h-1][0],b=(x-c[0][0])/Math.max(h-1,1),k=[];for(let t=1;v>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=u(t),n=f*Math.sqrt(1+1/h+(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=>`${l(t.x)},${s(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${l(t.x)},${s(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${l(t.x)},${s(t.yCenter)}`).join(" "),M=`${l(x)},${s(u(x))}`,I=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(N=e.fillOpacity)&&void 0!==N?N:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:I,strokeWidth:null!==(O=e.strokeWidth)&&void 0!==O?O:2,strokeDasharray:null!==(z=e.strokeDasharray)&&void 0!==z?z:"6,3"}),e.label&&w.length>0&&t.createElement("text",{x:l(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:I,fontSize:11},e.label))}default:return null}},n={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:S,yAccessor:P,width:r,height:i,data:L,frameType:"xy",pointNodes:D};return w.map((t,r)=>{if(E){const i=E(t,r,n);return null!=i?i:e(t,r,n)}return e(t,r,n)}).filter(Boolean)},[w,E,r,i,M,S,P,L]);return c||p||m||v||x||W&&W.length>0||g||_?t.createElement("svg",{width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${l.left},${l.top})`},g&&s&&t.createElement("g",{className:"stream-grid"},$.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),T.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&s&&(()=>{const e=null==u?void 0:u.find(t=>"left"===t.orient),n=null==u?void 0:u.find(t=>"bottom"===t.orient),o=!e||!1!==e.baseline,a=(null==e?void 0:e.jaggedBase)||!1,s=(null==n?void 0:n.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return t.createElement("g",{className:"stream-axes"},(!n||!1!==n.baseline)&&!s&&t.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:c,strokeWidth:1}),s&&t.createElement("path",{d:bt("bottom",r,i),fill:"none",stroke:c,strokeWidth:1}),$.map((e,n)=>t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${i})`},t.createElement("line",{y2:5,stroke:c,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:f,style:{userSelect:"none"}},e.label))),h&&t.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},h),o&&!a&&t.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),a&&t.createElement("path",{d:bt("left",r,i),fill:"none",stroke:c,strokeWidth:1}),T.map((e,n)=>t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:f,style:{userSelect:"none"}},e.label))),d&&t.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},d))})(),W,x&&s&&b&&k&&t.createElement(t.Fragment,null,x.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(dt,{orient:"top",config:ht(x.top),values:b,scale:s.x,size:l.top,length:r})),x.bottom&&t.createElement("g",{transform:`translate(0, ${i})`},t.createElement(dt,{orient:"bottom",config:ht(x.bottom),values:b,scale:s.x,size:l.bottom,length:r})),x.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(dt,{orient:"left",config:ht(x.left),values:k,scale:s.y,size:l.left,length:i})),x.right&&t.createElement("g",{transform:`translate(${r}, 0)`},t.createElement(dt,{orient:"right",config:ht(x.right),values:k,scale:s.y,size:l.right,length:i}))),v,_),p&&t.createElement("text",{x:o/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),m&&t.createElement("g",{transform:`translate(${o-l.right+10}, ${l.top})`},function(e){return"object"==typeof e&&null!==e&&!t.isValidElement(e)&&"legendGroups"in e}(m)?t.createElement(ut,{legendGroups:m.legendGroups,title:"",width:100}):m)):null}function Et(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}const At=(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=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;if(t.globalAlpha=o,t.fillStyle=e.style.fill||"#4e79a7",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}},Mt=(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}},St=(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?Pt(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 Pt(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 Lt={line:[At,(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=Et(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 M of w){const S=u+(v-u)*M.t,P=h+(x-h)*M.t,L=Et(d+(b-d)*Math.min(M.t+1e-4,1),s,a);t.lineTo(S,P),p(),g(L,S,P)}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 O=1;o.path.length>O;O++)t.lineTo(o.path[O][0],o.path[O][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:[At],stackedarea:[At],scatter:[Mt],bubble:[Mt],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:[St],swarm:[Mt],waterfall:[(t,e,n,r)=>{var i,o,a;St(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))}}]},Dt={top:20,right:20,bottom:30,left:40},_t={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"},$t={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 Tt({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:$t},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}function Wt({width:e,height:n,totalWidth:i,totalHeight:o,margin:l,dimension:s,scales:c,onBrush:u}){const h=r(null),p=r(null);return a(()=>{if(!h.current)return;const t=g(h.current).select(".brush-g"),r="x"===s?d():"y"===s?f():y();return r.extent([[0,0],[e,n]]),r.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let r,i;if("x"===s){const[e,o]=t.selection;r=[c.x.invert(e),c.x.invert(o)],i=[c.y.invert(n),c.y.invert(0)]}else if("y"===s){const[n,o]=t.selection;r=[c.x.invert(0),c.x.invert(e)],i=[c.y.invert(o),c.y.invert(n)]}else{const[[e,n],[o,a]]=t.selection;r=[c.x.invert(e),c.x.invert(o)],i=[c.y.invert(a),c.y.invert(n)]}u({x:r,y:i})}),t.call(r),p.current=r,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),p.current=null}},[e,n,s,c,u]),t.createElement("svg",{ref:h,width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Nt=n(function(n,s){var c,u,h;const{chartType:d,runtimeMode:f,data:y,xAccessor:g,yAccessor:p,colorAccessor:m,sizeAccessor:v,groupAccessor:x,lineDataAccessor:b,normalize:k,binSize:w,valueAccessor:E,arrowOfTime:A="right",windowMode:M="sliding",windowSize:S=200,timeAccessor:P,xExtent:L,yExtent:D,extentPadding:_=.1,sizeRange:$,size:T=[500,300],margin:W,className:N,background:O,lineStyle:z,pointStyle:I,areaStyle:C,waterfallStyle:R,swarmStyle:Y,barColors:B,colorScheme:j,boundsAccessor:X,boundsStyle:H,openAccessor:G,highAccessor:V,lowAccessor:q,closeAccessor:Z,candlestickStyle:K,showAxes:U=!0,axes:Q,xLabel:J,yLabel:lt,xFormat:st,yFormat:ct,tickFormatTime:ut,tickFormatValue:ht,hoverAnnotation:dt,tooltipContent:ft,customHoverBehavior:yt,enableHover:gt,annotations:pt,svgAnnotationRules:mt,showGrid:vt,legend:xt,backgroundGraphics:bt,foregroundGraphics:kt,title:Et,categoryAccessor:At,brush:Mt,onBrush:St,decay:Pt,pulse:$t,transition:Nt,staleness:Ot,heatmapAggregation:zt,heatmapXBins:It,heatmapYBins:Ct,marginalGraphics:Rt,pointIdAccessor:Yt}=n,Bt=Object.assign(Object.assign({},Dt),W);if(Rt){const t=60;Rt.top&&t>Bt.top&&(Bt.top=t),Rt.bottom&&t>Bt.bottom&&(Bt.bottom=t),Rt.left&&t>Bt.left&&(Bt.left=t),Rt.right&&t>Bt.right&&(Bt.right=t)}const jt=T[0]-Bt.left-Bt.right,Ft=T[1]-Bt.top-Bt.bottom,Xt=null!=dt?dt:gt,Ht=r(null),Gt=r(0),Vt=r(!1),[qt,Zt]=i(0),[Kt,Ut]=i(null),Qt=r(null),Jt=r(null),[te,ee]=i(null),[ne,re]=i(!1),[ie,oe]=i([]),[ae,le]=i([]),se=r(()=>{}),ce="streaming"===f||["bar","swarm","waterfall"].includes(d),ue=e(()=>({chartType:d,runtimeMode:ce?"streaming":"bounded",windowSize:S,windowMode:M,arrowOfTime:ce?A:"right",extentPadding:_,xAccessor:ce?void 0:g,yAccessor:ce?void 0:p,timeAccessor:ce?P:void 0,valueAccessor:E,colorAccessor:m,sizeAccessor:v,groupAccessor:x,categoryAccessor:At,lineDataAccessor:b,xExtent:L,yExtent:D,sizeRange:$,binSize:w,normalize:k,boundsAccessor:X,boundsStyle:H,openAccessor:G,highAccessor:V,lowAccessor:q,closeAccessor:Z,candlestickStyle:K,lineStyle:z,pointStyle:I,areaStyle:C,swarmStyle:Y,waterfallStyle:R,colorScheme:j,barColors:B,annotations:pt,decay:Pt,pulse:$t,transition:Nt,staleness:Ot,heatmapAggregation:zt,heatmapXBins:It,heatmapYBins:Ct,pointIdAccessor:Yt}),[d,S,M,A,_,g,p,P,E,m,v,x,At,b,L,D,$,w,k,X,H,G,V,q,Z,K,z,I,C,Y,R,j,B,pt,Pt,$t,Nt,Ot,zt,It,Ct,ce,Yt]),he=r(null);he.current||(he.current=new tt(ue));const de=o(()=>{Gt.current||(Gt.current=requestAnimationFrame(()=>se.current()))},[]);a(()=>{var t;null===(t=he.current)||void 0===t||t.updateConfig(ue),Vt.current=!0,de()},[ue,de]);const fe=r(null);fe.current||(fe.current=new F(t=>{const e=he.current;e&&e.ingest(t)&&(Vt.current=!0,de())}));const ye=o(t=>{var e;null===(e=fe.current)||void 0===e||e.push(t)},[]),ge=o(t=>{var e;null===(e=fe.current)||void 0===e||e.pushMany(t)},[]),pe=o(()=>{var t,e;null===(t=fe.current)||void 0===t||t.clear(),null===(e=he.current)||void 0===e||e.clear(),Vt.current=!0,de()},[de]);l(s,()=>({push:ye,pushMany:ge,clear:pe,getData:()=>{var t,e;return null!==(e=null===(t=he.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=he.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=he.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[ye,ge,pe]),a(()=>{var t;y&&(null===(t=fe.current)||void 0===t||t.setBoundedData(y))},[y]);const me=r(()=>{}),ve=r(()=>{});me.current=t=>{if(!Xt)return;const e=Ht.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Bt.left,i=t.clientY-n.top-Bt.top;if(0>r||r>jt||0>i||i>Ft)return void(Qt.current&&(Qt.current=null,Jt.current=null,ee(null),yt&&yt(null),de()));const o=he.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=et(o,e,n);break;case"line":t=nt(o,e,n);break;case"rect":t=rt(o,e,n);break;case"heatcell":t=it(o,e,n);break;case"area":if(!1===o.interactive)break;t=at(o,e,n);break;case"candlestick":t=ot(o,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(o.scene,r,i);if(!a)return void(Qt.current&&(Qt.current=null,Jt.current=null,ee(null),yt&&yt(null),de()));const l={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};Qt.current=l,Jt.current=a.node,ee(l),yt&&yt(l),de()},ve.current=()=>{Qt.current&&(Qt.current=null,Jt.current=null,ee(null),yt&&yt(null),de())};const xe=o(t=>me.current(t),[]),be=o(()=>ve.current(),[]);se.current=()=>{var t,e;Gt.current=0;const n=Ht.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const i=he.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=i.advanceTransition(o);a||i.computeScene({width:jt,height:Ft});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=T[0]*l,n.height=T[1]*l,n.style.width=T[0]+"px",n.style.height=T[1]+"px",r.scale(l,l),r.translate(Bt.left,Bt.top),r.clearRect(-Bt.left,-Bt.top,T[0],T[1]);const s=function(t){if(!t)return _t;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||_t.axisStroke,tickText:o||_t.tickText,crosshair:o?o+"66":_t.crosshair,hoverFill:s?s+"4D":_t.hoverFill,hoverStroke:o?o+"99":_t.hoverStroke,pointRing:s||_t.pointRing}:_t}(n),c=null!==(t=null==Ot?void 0:Ot.threshold)&&void 0!==t?t:5e3,u=Ot&&i.lastIngestTime>0&&o-i.lastIngestTime>c;u&&(r.globalAlpha=null!==(e=null==Ot?void 0:Ot.dimOpacity)&&void 0!==e?e:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",f=O||(h&&"transparent"!==h?h:null);f&&(r.fillStyle=f,r.fillRect(-Bt.left,-Bt.top,T[0],T[1])),r.save(),"function"==typeof r.rect&&(r.beginPath(),r.rect(0,0,jt,Ft),r.clip());const y=Lt[d];if(y&&i.scales)for(const t of y)t(r,i.scene,i.scales,{width:jt,height:Ft});if(r.restore(),u&&(r.globalAlpha=1),Xt&&Qt.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,Qt.current,jt,Ft,"object"==typeof Xt?Xt:{},0,s),Jt.current&&Array.isArray(dt)){const t=dt.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,Jt.current,t)}const m=Vt.current;if(Vt.current=!1,m&&i.scales&&(Ut(i.scales),Rt)){const t=i.getData(),e="function"==typeof g?g:t=>t[g||"x"],n="function"==typeof p?p:t=>t[p||"y"];oe(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),le(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}m&&pt&&pt.length>0&&Zt(t=>t+1),(null==Ot?void 0:Ot.showBadge)&&re(!!u),(a||i.hasActivePulses)&&(Gt.current=requestAnimationFrame(()=>se.current()))},a(()=>(de(),()=>{Gt.current&&cancelAnimationFrame(Gt.current)}),[de]),a(()=>{Vt.current=!0,de()},[d,jt,Ft,U,O,z,de]),a(()=>{if(!Ot)return;const t=setInterval(()=>{var t;const e=he.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!==ne&&(re(i),Vt.current=!0,de())},1e3);return()=>clearInterval(t)},[Ot,ne,de]);const ke=Xt&&te?ft?ft(te):t.createElement(Tt,{hover:te}):null,we=ke?t.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Bt.left+te.x,top:Bt.top+te.y,transform:`translate(${te.x>.7*jt?"calc(-100% - 12px)":"12px"}, ${.3*Ft>te.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ke):null;return t.createElement("div",{className:"stream-xy-frame"+(N?" "+N:""),role:"img","aria-label":"string"==typeof Et?Et:"XY chart",style:{position:"relative",width:T[0],height:T[1]},onMouseMove:Xt?xe:void 0,onMouseLeave:Xt?be:void 0},bt&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:T[0],height:T[1],pointerEvents:"none"}},bt),t.createElement("canvas",{ref:Ht,style:{position:"absolute",left:0,top:0}}),t.createElement(wt,{width:jt,height:Ft,totalWidth:T[0],totalHeight:T[1],margin:Bt,scales:Kt,showAxes:U,axes:Q,xLabel:J,yLabel:lt,xFormat:st||ut,yFormat:ct||ht,showGrid:vt,title:Et,legend:xt,foregroundGraphics:kt,marginalGraphics:Rt,xValues:ie,yValues:ae,annotations:pt,svgAnnotationRules:mt,annotationFrame:qt,xAccessor:"string"==typeof g?g:"string"==typeof P?P:void 0,yAccessor:"string"==typeof p?p:"string"==typeof E?E:void 0,annotationData:null===(c=he.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=he.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type)}),(Mt||St)&&t.createElement(Wt,{width:jt,height:Ft,totalWidth:T[0],totalHeight:T[1],margin:Bt,dimension:null!==(h=null==Mt?void 0:Mt.dimension)&&void 0!==h?h:"xy",scales:Kt,onBrush:null!=St?St:()=>{}}),(null==Ot?void 0:Ot.showBadge)&&t.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:ne?"#dc3545":"#28a745",color:"white"})},ne?"STALE":"LIVE"),we)});Nt.displayName="StreamXYFrame";const Ot={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},zt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class It{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=Ct(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 Ct(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=Rt(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=Rt(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 Rt(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 Bt(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 jt(t){return t.y0-t.y1>0?"up":"down"}function Ft(t,e){return e(t.source)==e(t.target)}function Xt(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 Ht(t){return t.target.x0-t.source.x1}function Gt(t,e){var n=qt(t),r=Ht(e)/Math.tan(n);return"up"==jt(t)?t.y1-r:t.y1+r}function Vt(t,e){var n=qt(t),r=Ht(e)/Math.tan(n);return"up"==jt(t)?t.y1+r:t.y1-r}function qt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Zt(t,e){return e(t)}function Kt(t){return Qt(t.source)}function Ut(t){return Qt(t.target)}function Qt(t){return(t.y0+t.y1)/2}function Jt(t){return t.virtual?0:t.value}function te(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Ft(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!Ft(t,e)?r+1:r}),n+r}function ee(t){return t.target.depth}function ne(t,e){return t.sourceLinks.length?t.depth:e-1}function re(t,e){return t.y0-e.y0}function ie(t,e){return e.y0-t.y0}function oe(t,e){return t.y1-e.y1}function ae(t,e){return e.y1-t.y1}function le(t,e){return ce(t.source,e.source)||t.index-e.index}function se(t,e){return ce(t.target,e.target)||t.index-e.index}function ce(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ue(t,e){return he(t)==he(e)?"bottom"==t.circularLinkType?ie(t,e):re(t,e):he(e)-he(t)}function he(t){return t.target.column-t.source.column}function de(t,e){return fe(t)==fe(e)}function fe(t){return t.y0-t.y1>0?"up":"down"}function ye(t,e,n,r,i){let o=t;var a=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var l=v(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=o.links.filter(function(t){return t.circular});return s.sort(function(t,e){return e.value-t.value}),s.forEach(function(t,e){t._circularStub=e>=4}),ge(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),ge(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Ft(t,e)&&Xt(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var a=t.source.column,s=t.circularLinkType,c=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?ie:re);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}),a=t.target.column,(c=o.links.filter(function(t){return t.target.column==a&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?ae:oe),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=l-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,i=t.y1,o=(e+r)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(t)}),o}function ge(t,e,n){t.sort(ue);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(Ft(t,e)&&Xt(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&&pe(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 pe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function me(t){return function(){return t}}function ve(t){return t.index}function xe(t){return t.nodes}function be(t){return t.links}function ke(t,e,n){var r=x(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?te(e,n)-te(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==te(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 we(t,e,n,r,i,o){var a=x(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var l=1,s=o;s>0;--s)c(l*=.99,n),u();function c(e,n){var r=a.length;a.forEach(function(i){var o=i.length,a=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&te(i,n)>0){var s=w(i.sourceLinks,Ut),c=w(i.targetLinks,Kt),u=s&&c?(s+c)/2:s||c;if(u){var h=(u-Qt(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==o)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(a==r-1&&1==o)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var d=w(i.sourceLinks,Ut),f=w(i.targetLinks,Kt),y=((d&&f?(d+f)/2:d||f)-Qt(i))*e;i.y0+=y,i.y1+=y}})})}function u(){a.forEach(function(n){var o,a,l,s=t.y0,c=n.length;for(n.sort(e||ce),l=0;c>l;++l)(a=s-(o=n[l]).y0)>0&&(o.y0+=a,o.y1+=a),s=o.y1+r;if((a=s-r-t.y1)>0)for(s=o.y0-=a,o.y1-=a,l=c-2;l>=0;--l)(a=(o=n[l]).y1+i-s)>0&&(o.y0-=a,o.y1-=a),s=o.y0})}}function Ee(t){t.nodes.forEach(function(t){t.sourceLinks.sort(se),t.targetLinks.sort(le)}),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 Ae(){var t=0,e=0,n=1,r=1,i=24,o=8,a=null,l=ve,s=ne,c=void 0,u=32,h=2,d=xe,f=be;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=n,d.y1=r,d.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 E(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)})}(d,l),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=Bt(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++)})}(d,c),function(t,e){var n=0,r=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:r>n?"top":"bottom","top"==i.circularLinkType?n++:r++,t.nodes.forEach(function(t){Zt(t,e)!=Zt(i.source,e)&&Zt(t,e)!=Zt(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),Ft(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(k(t.sourceLinks,Jt),k(t.targetLinks,Jt)),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)})})}(d),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})}(d,c,s);var f=o;if(null!==a){var y=x(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=b(y,function(t){return t.length});g>1&&(f=Math.max(1,(r-e)*a/(g-1)))}(function(t,e,n){var r=x(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=v(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/k(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var o=b(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/o),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,i),ke(d,c,l),we(d,c,l,f,f,u),Ee(d),ye(d,l,h,10,8),ke(d,c,l),we(d,c,l,f,f,u),Ee(d),ye(d,l,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return Zt(n.source,e)==Zt(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(!de(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Gt(e,t);return t.y1-n}if(e.target.column>t.target.column)return Gt(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}})})}(d,l),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return Zt(n.target,e)==Zt(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(!de(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Vt(e,t);return t.y0-n}if(e.source.column>t.source.column)return Vt(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}})})}(d,l),function(t){var e=t.nodes,n=t.links,r=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==r||0==i){var o=v(e,function(t){return t.y0}),a=b(e,function(t){return t.y1}),l=(t.y1-t.y0)/(a-o);function s(e){return(e-o)/(a-o)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1)}),n.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,n=s(t.y0)-t.y0;t.y0=s(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(d),ye(d,l,h,10,8)}(y),y}return y.update=function(t){return Ee(t),ye(t,l,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(i=+t,y):i},y.nodePadding=function(t){return arguments.length?(o=+t,y):o},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:me(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:me(t),y):f},y.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:me(t),y):l},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:me(t),y):s},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],r=+i[1][1],y):[[t,e],[n,r]]},y.size=function(i){return arguments.length?(t=e=0,n=+i[0],r=+i[1],y):[n-t,r-e]},y}const Me=t=>{let e,n,r,i,o,a,l,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,o=t.source.y1,a=t.target.y0,l=T(o,a),s=l(.5),c=l(.5),`M${e},${o}C${e},${s} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${i},${s} ${i},${o}Z`):(e=t.source.x1,n=t.target.x0,l=T(e,n),r=l(.5),i=l(.5),o=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${i},${a} ${n},${a}L${n},${s}C${i},${s} ${r},${c} ${e},${c}Z`)};function Se(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},${s+d*n}L${u},${h-d*r}L${c},${h-d*r}L${c},${a+d*n}L${o},${a+d*n}Z`}const Pe={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(ee))-1:0},justify:ne},Le={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=Ae().extent(v).links(m).nodes(p).nodeAlign(Pe[d]||ne).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",c=n.nodeStyle,u=n.edgeStyle,h=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:W,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const g=[],p=[],m=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=c?c(e):{},i={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const v=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of v){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";u?r=u(t).fill||r:"target"===d&&n?r=y.get(n.id)||r:e&&(r=y.get(e.id)||r);const i=u?u(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;p.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:h,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+l}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:h,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?Se(t):Me(t),!s)continue;const c={fill:i.fill||r,fillOpacity:null!==(l=i.fillOpacity)&&void 0!==l?l:h,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};p.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||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),m.push({x:a,y:l,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:g,sceneEdges:p,labels:m}}},De={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 u=_e(n.nodeSize,n.nodeSizeRange,t),h=N().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),d=r[1]/r[0],f=O().force("charge",z().strength(t=>-25*(t=>u(t))(t))).force("x",I(r[0]/2).strength(.1*d)).force("y",C(r[1]/2).strength(.1));if(f.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}));f.force("link",h),f.force("link").links(t)}.1>f.alpha()&&f.alpha(1),f.stop();for(let t=0;a>t;++t)f.tick();const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=y.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=y.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var i,o,a;const l=n.nodeStyle,s=n.edgeStyle,c=_e(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:W,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const d=[],f=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=c(e),n=l?l(e):{},r={fill:n.fill||h.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:2,opacity:n.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=s?s(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};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:i,datum:t})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=c(n);y.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:f,labels:y}}};function _e(t,e,n){var r,i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],a=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===a.length)return()=>o[0];const l=null!==(r=v(a))&&void 0!==r?r:0,s=null!==(i=b(a))&&void 0!==i?i:1;if(l===s)return()=>(o[0]+o[1])/2;const c=p().domain([l,s]).range(o).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?o[0]:c(r)}}const $e=W,Te={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,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),r=f.get(e);if(void 0===n||void 0===r)continue;const i=h(t);g[n][r]=i}const p=Y().padAngle(i);a&&p.sortGroups(a);const m=p(g),v=m.groups,x=B().innerRadius(s).outerRadius(l);for(const e of v){const n=t[e.index],r=x.centroid(e);n.x=r[0]+c,n.y=r[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,r=t[e.target.index].id,i=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);i&&(i.chordData=e)}},buildScene(t,e,n,r){var i,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(r[0],r[1])/2,c=s-a,u=r[0]/2,h=r[1]/2,d=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:$e,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const m=R().radius(c),v=[],x=[],b=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let o;o=d?d(n).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const a=d?d(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};v.push({type:"arc",cx:u,cy:h,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=m(e);if(!n)continue;const r=We(n,u,h);let i="#999";if(f)i=f(t).fill||i;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?i=p.get(n.id)||i:e&&(i=p.get(e.id)||i)}const a=f?f(t):{},s={fill:i,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:u+Math.cos(a)*r,y:h+Math.sin(a)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:x,labels:b}}};function We(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 Ne={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var i;const o=n.__hierarchyRoot;if(!o)return;const a=n.chartType,l=(s=n.childrenAccessor)?"function"==typeof s?s:t=>t[s]:void 0;var s;const c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=M(o,l);u.sum(c),u.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,d]=r;switch(a){case"tree":!function(t,e,n,r){const i=e.treeOrientation||"vertical",o=$();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(t)}(u,n,h,d);break;case"cluster":!function(t,e,n,r){const i=e.treeOrientation||"vertical",o=_();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(t)}(u,n,h,d);break;case"treemap":!function(t,e,n,r){var i,o;const a=null!==(i=e.padding)&&void 0!==i?i:4,l=null!==(o=e.paddingTop)&&void 0!==o?o:0,s=L().size([n,r]).tile(D).padding(a);l>0&&s.paddingTop(l),s(t)}(u,n,h,d);break;case"circlepack":!function(t,e,n,r){var i;const o=null!==(i=e.padding)&&void 0!==i?i:4;P().size([n,r]).padding(o)(t)}(u,n,h,d);break;case"partition":!function(t,e,n,r){var i;S().size([n,r]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(u,n,h,d)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const r=f[e],o={id:Re(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"===a||"cluster"===a?Oe(o,r,n):"treemap"===a||"partition"===a?ze(o,r):"circlepack"===a&&Ie(o,r),o.__hierarchyNode=r,t.push(o),y.set(r,o)}if("tree"===a||"cluster"===a)for(const t of f)if(t.parent){const n=y.get(t.parent),r=y.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,i,o){var 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=Ce(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 Oe(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 ze(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 Ie(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 Ce(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 Re(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 Be={sankey:Le,force:De,chord:Te,tree:Ne,cluster:Ne,treemap:Ne,circlepack:Ne,partition:Ne};function je(t){return Be[t]}class Fe{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({},Ot),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new It(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},Ot),t.tensionConfig),"sankey"===t.chartType&&t.showParticles?this.particlePool||(this.particlePool=new It(2e3)):this.particlePool=null}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({},Xe(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({},Xe(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Xe(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,Xe(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,Xe(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=je(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=je(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=T(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=T(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 Xe(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 He(t,e,n,r,i=30){let o=null,a=i,l=1/0;for(const e of t){const t=Ge(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=Ve(t,n,r);e&&a>e.distance&&(o=e,a=e.distance)}return o}function Ge(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 Ve(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 qe(e){const{width:n,height:r,totalWidth:i,totalHeight:o,margin:a,labels:l,title:s,legend:c,foregroundGraphics:u,annotations:h,svgAnnotationRules:d}=e;return t.createElement("svg",{width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${a.left},${a.top})`},l.map((e,n)=>t.createElement("text",{key:"label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),h&&d&&h.map((e,i)=>{const o=d(e,i,{width:n,height:r});return o?t.createElement(t.Fragment,{key:"annotation-"+i},o):null}),u),s&&"string"==typeof s?t.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:i,height:a.top},s):null,c&&"object"==typeof c&&"legendGroups"in c?t.createElement("g",{transform:`translate(${i-a.right+10},${a.top})`},c.legendGroups.map((e,n)=>{var r;return t.createElement("g",{key:"legend-group-"+n},null===(r=e.items)||void 0===r?void 0:r.map((e,n)=>t.createElement("g",{key:"legend-item-"+n,transform:`translate(0,${20*n})`},t.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),t.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):c?t.createElement("g",{transform:`translate(${i-a.right+10},${a.top})`},c):null)}function Ze(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 Ke(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 Ue(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 Qe(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()}qe.displayName="NetworkSVGOverlay";const Je=W,tn={top:20,right:80,bottom:20,left:80},en={top:40,right:40,bottom:40,left:40},nn=new Set(["chord","force","circlepack"]),rn=[800,600],on={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 an({data:e}){var n,r,i,o,a,l;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:on},t.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let a=c;for(;a;){const t=null!==(o=null!==(r=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==r?r:null===(i=a.data)||void 0===i?void 0:i.id)&&void 0!==o?o:s.id;null!=t&&e.unshift(t+""),a=a.parent}e.length>1&&e.shift();const l=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:on},t.createElement("div",null,e.map((e,n)=>t.createElement("span",{key:n},n>0&&t.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===l?t.createElement("strong",null,e):t.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const u=((null===(a=s.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(l=s.targetLinks)||void 0===l?void 0:l.length)||0),h=(s.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(s.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.createElement("div",{className:"semiotic-tooltip",style:on},t.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),u>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,h!==u&&` (weighted: ${h.toLocaleString()})`))}const ln=n(function(n,s){const{chartType:c,nodes:u,edges:h,data:d,initialEdges:f,nodeIDAccessor:y="id",sourceAccessor:g="source",targetAccessor:p="target",valueAccessor:m="value",childrenAccessor:v,hierarchySum:x,orientation:b="horizontal",nodeAlign:k="justify",nodePaddingRatio:w=.05,nodeWidth:E=15,iterations:A=300,forceStrength:M=.1,padAngle:S=.01,groupWidth:P=20,sortGroups:L,edgeSort:D,treeOrientation:_="vertical",edgeType:$="curve",padding:T,paddingTop:W,tensionConfig:N,showParticles:O=!1,particleStyle:z,nodeStyle:I,edgeStyle:C,colorBy:R,colorScheme:Y="category10",edgeColorBy:B="source",edgeOpacity:j=.5,colorByDepth:F=!1,nodeSize:X=8,nodeSizeRange:H=[5,20],nodeLabel:G,showLabels:V=!0,size:q=rn,margin:Z,className:K,background:U,enableHover:Q=!0,tooltipContent:J,customHoverBehavior:tt,customClickBehavior:et,onObservation:nt,chartId:rt,onTopologyChange:it,annotations:ot,svgAnnotationRules:at,legend:lt,title:st,foregroundGraphics:ct,backgroundGraphics:ut,decay:ht,pulse:dt,staleness:ft,thresholds:yt}=n,gt=nn.has(c)?en:tn,pt=Object.assign(Object.assign({},gt),Z),mt=q[0]-pt.left-pt.right,vt=q[1]-pt.top-pt.bottom,xt=e(()=>Object.assign(Object.assign({},Ot),N),[N]),bt=e(()=>Object.assign(Object.assign({},zt),z),[z]),kt=e(()=>({chartType:c,nodeIDAccessor:y,sourceAccessor:g,targetAccessor:p,valueAccessor:m,childrenAccessor:v,hierarchySum:x,orientation:b,nodeAlign:k,nodePaddingRatio:w,nodeWidth:E,iterations:A,forceStrength:M,padAngle:S,groupWidth:P,sortGroups:L,edgeSort:D,treeOrientation:_,edgeType:$,padding:T,paddingTop:W,tensionConfig:xt,showParticles:O,particleStyle:bt,nodeStyle:I,edgeStyle:C,nodeLabel:G,showLabels:V,colorBy:R,colorScheme:Y,edgeColorBy:B,edgeOpacity:j,colorByDepth:F,nodeSize:X,nodeSizeRange:H,decay:ht,pulse:dt,staleness:ft,thresholds:yt}),[c,y,g,p,m,v,x,b,k,w,E,A,M,S,P,L,D,_,$,T,W,xt,O,bt,I,C,G,V,R,Y,B,j,F,X,H,ht,dt,ft,yt]),wt=r(null),Et=r(0),At=r(0),Mt=r(!0),St=r(()=>{}),Pt=r(null);Pt.current||(Pt.current=new Fe(kt));const[Lt,Dt]=i(null),[_t,$t]=i(0),[Tt,Wt]=i(0),[Nt,It]=i(!1),Ct=r(null),Rt=r(new Map),Yt=r(0),Bt=o(t=>{if("function"==typeof R)return R(t);if("string"==typeof R&&t.data){const e=t.data[R];if(void 0!==e){if(!Rt.current.has(e+"")){const t=Array.isArray(Y)?Y:Je;Rt.current.set(e+"",t[Yt.current++%t.length])}return Rt.current.get(e+"")}}if(!Rt.current.has(t.id)){const e=Array.isArray(Y)?Y:Je;Rt.current.set(t.id,e[Yt.current++%e.length])}return Rt.current.get(t.id)},[R,Y]),jt=o(t=>{if("function"==typeof B)return B(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===B&&n?Bt(n):e?Bt(e):"#999"},[B,Bt]),Ft=o(t=>{if(!(null==z?void 0:z.colorBy))return jt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===bt.colorBy&&n?Bt(n):e?Bt(e):"#999"},[null==z?void 0:z.colorBy,bt.colorBy,Bt,jt]),Xt="sankey"===c&&O||!!dt,Ht=o(()=>{Et.current&&!Xt||Et.current||(Et.current=requestAnimationFrame(()=>St.current()))},[Xt]);a(()=>{var t;null===(t=Pt.current)||void 0===t||t.updateConfig(kt),Mt.current=!0,Ht()},[kt,Ht]);const Gt=o(()=>{const t=Pt.current;if(!t)return;t.runLayout([mt,vt]),t.buildScene([mt,vt]),Mt.current=!0;const e=Array.isArray(Y)?Y:Je,n=Array.from(t.nodes.values());for(let t=0;n.length>t;t++){const r=n[t];Rt.current.has(r.id)||Rt.current.set(r.id,e[t%e.length])}if(Yt.current=n.length,$t(t.layoutVersion),it){const{nodes:e,edges:n}=t.getLayoutData();it(e,n)}},[mt,vt,it,Y]),Vt=o(t=>{const e=Pt.current;e&&(e.ingestEdge(t)&&Gt(),Ht())},[Gt,Ht]),qt=o(t=>{const e=Pt.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Gt(),Ht()},[Gt,Ht]),Zt=o(()=>{var t;null===(t=Pt.current)||void 0===t||t.clear(),Rt.current.clear(),Yt.current=0,$t(0),Dt(null),Ct.current=null,Mt.current=!0,Ht()},[Ht]),Kt=o(()=>{const t=Pt.current;t&&(t.tension+=999,Gt(),Ht())},[Gt,Ht]);l(s,()=>({push:Vt,pushMany:qt,clear:Zt,getTopology:()=>{var t,e;return null!==(e=null===(t=Pt.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=Pt.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:Kt,getTension:()=>{var t,e;return null!==(e=null===(t=Pt.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Vt,qt,Zt,Kt]);const Ut=["tree","cluster","treemap","circlepack","partition"].includes(c),Qt=Ut?d||(Array.isArray(h)?void 0:h):void 0;a(()=>{const t=Pt.current;if(t)if(Ut&&Qt)t.ingestHierarchy(Qt,[mt,vt]),t.buildScene([mt,vt]),Mt.current=!0,Ht();else{const e=u||[],n=Array.isArray(h)?h:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[mt,vt]),t.buildScene([mt,vt]);const r=Array.isArray(Y)?Y:Je,i=Array.from(t.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Rt.current.has(e.id)||Rt.current.set(e.id,r[t%r.length])}Yt.current=i.length,Mt.current=!0,Ht()}},[u,h,d,Qt,Ut,mt,vt,kt,Ht,Y]),a(()=>{f&&f.length>0&&qt(f)},[]);const Jt=o(t=>{if(tt&&tt(t),nt){const e=Date.now();nt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:rt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:rt})}},[tt,nt,rt]),te=o(t=>{if(et&&et(t),nt){const e=Date.now();nt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:rt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:rt})}},[et,nt,rt]),ee=r(()=>{}),ne=r(()=>{});ee.current=t=>{if(!Q)return;const e=wt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-pt.left,i=t.clientY-n.top-pt.top;if(0>r||r>mt||0>i||i>vt)return void(Ct.current&&(Ct.current=null,Dt(null),Jt&&Jt(null),Ht()));const o=Pt.current;if(!o)return;const a=He(o.sceneNodes,o.sceneEdges,r,i);if(!a)return void(Ct.current&&(Ct.current=null,Dt(null),Jt&&Jt(null),Ht()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};Ct.current=l,Dt(l),Jt&&Jt(l),Ht()},ne.current=()=>{Ct.current&&(Ct.current=null,Dt(null),Jt&&Jt(null),Ht())};const re=r(()=>{});re.current=t=>{if(!et&&!nt)return;const e=wt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-pt.left,i=t.clientY-n.top-pt.top;if(0>r||r>mt||0>i||i>vt)return;const o=Pt.current;if(!o)return;const a=He(o.sceneNodes,o.sceneEdges,r,i);te(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)};const ie=o(t=>ee.current(t),[]),oe=o(()=>ne.current(),[]),ae=o(t=>re.current(t),[]);St.current=()=>{var t,e,n;Et.current=0;const r=wt.current;if(!r)return;const i=r.getContext("2d");if(!i)return;const o=Pt.current;if(!o)return;const a=performance.now(),l=At.current?Math.min((a-At.current)/1e3,.1):.016;At.current=a;const s=o.advanceTransition(a);(s||Mt.current)&&o.buildScene([mt,vt]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;r.width=q[0]*c,r.height=q[1]*c,r.style.width=q[0]+"px",r.style.height=q[1]+"px",i.scale(c,c),i.translate(pt.left,pt.top),i.clearRect(-pt.left,-pt.top,q[0],q[1]),U&&(i.fillStyle=U,i.fillRect(0,0,mt,vt)),ht&&o.applyDecay(),dt&&o.applyPulse(a),yt&&o.applyThresholds(a),o.applyTopologyDiff(a);const u=null!==(t=null==ft?void 0:ft.threshold)&&void 0!==t?t:5e3,h=ft&&o.lastIngestTime>0&&a-o.lastIngestTime>u;if(h&&(i.globalAlpha=null!==(e=null==ft?void 0:ft.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":Ze(t,n);break;case"line":Ke(t,n);break;case"ribbon":Ue(t,n);break;case"curved":Qe(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&&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:zt.spawnRate,l=null!==(o=r.maxPerEdge)&&void 0!==o?o:zt.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,bt);const e=.5*(null!==(n=bt.speedMultiplier)&&void 0!==n?n:1);let r;if(bt.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:zt.radius,s=null!==(a=r.opacity)&&void 0!==a?a:zt.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,bt,Ft)}}h&&(i.globalAlpha=1);const d=Mt.current;Mt.current=!1,(d||s)&&Wt(t=>t+1),(Xt||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(Et.current=requestAnimationFrame(()=>St.current()))},a(()=>(Ht(),()=>{Et.current&&cancelAnimationFrame(Et.current)}),[Ht]),a(()=>{Mt.current=!0,Ht()},[c,mt,vt,U,Ht]),a(()=>{if(!ft)return;const t=setInterval(()=>{var t;const e=Pt.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=ft.threshold)&&void 0!==t?t:5e3,i=n-e.lastIngestTime>r;i!==Nt&&(It(i),Mt.current=!0,Ht())},1e3);return()=>clearInterval(t)},[ft,Nt,Ht]);const le=Q&&Lt?t.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:pt.left+Lt.x,top:pt.top+Lt.y,transform:`translate(${Lt.x>.6*mt?"calc(-100% - 12px)":"12px"}, ${.3*vt>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},J?J(Lt):t.createElement(an,{data:Lt})):null,se=Pt.current;return t.createElement("div",{className:"stream-network-frame"+(K?" "+K:""),role:"img","aria-label":"string"==typeof st?st:"Network chart",style:{position:"relative",width:q[0],height:q[1]},onMouseMove:Q?ie:void 0,onMouseLeave:Q?oe:void 0,onClick:et||nt?ae:void 0},ut&&t.createElement("svg",{style:{position:"absolute",top:0,left:0,width:q[0],height:q[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${pt.left},${pt.top})`},ut)),t.createElement("canvas",{ref:wt,style:{position:"absolute",top:0,left:0}}),t.createElement(qe,{width:mt,height:vt,totalWidth:q[0],totalHeight:q[1],margin:pt,labels:(null==se?void 0:se.labels)||[],title:st,legend:lt,foregroundGraphics:ct,annotations:ot,svgAnnotationRules:at,annotationFrame:Tt}),le,(null==ft?void 0:ft.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ft.badgePosition?{top:4,left:4}:"bottom-left"===ft.badgePosition?{bottom:4,left:4}:"bottom-right"===ft.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Nt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Nt?"STALE":"LIVE"))});function sn(n){const r=s(null),o=cn(n);return[function({children:i}){const o=e(()=>cn(n),[]);return t.createElement(r.Provider,{value:o,children:i})},t=>{var e;const n=null!==(e=c(r))&&void 0!==e?e:o;return function(t,e){const[n,r]=i(e);return u(()=>t(()=>r(e)),[t]),n}(n.subscribe,()=>t(n.getState()))}]}function cn(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 un(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 hn(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}ln.displayName="StreamNetworkFrame";const[dn,fn]=sn(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),i=hn(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=hn(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 yn(t){const n=h(),r=t.clientId||n,{name:i}=t,a=fn(t=>t.selections.get(i)),l=fn(t=>t.setClause),s=fn(t=>t.clearClause),c=e(()=>!!a&&a.clauses.size>0,[a]);return{predicate:e(()=>a&&0!==a.clauses.size?function(t,e){const n=[];for(const[r,i]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(un(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(a,r):()=>!0,[a,r]),isActive:c,selectPoints:o(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};l(i,{clientId:r,type:"point",fields:e})},[r,i,l]),selectInterval:o(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};l(i,{clientId:r,type:"interval",fields:e})},[r,i,l]),clear:o(()=>{s(i,r)},[s,i,r]),clientId:r}}const[gn,pn]=sn(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 mn({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:r=!1,onObservation:i,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}(e,n),c=yn({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:i,selectPoints:a,clear:l}=yn({name:e});return{onHover:o(t=>{if(!t)return void l();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}Object.keys(e).length>0&&a(e)},[n,a,l]),predicate:r,isActive:i}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||[]}),h=pn(t=>t.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:o(t=>{var n,r;if(e){let e=t&&(t.data||t.datum)||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}if(i||h){const e={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},e),{type:"hover",datum:o||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0});i&&i(a),h&&h(a)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});i&&i(t),h&&h(t)}}},[e,u,i,a,l,h]),customClickBehavior:o(t=>{var e,n;if(i||h){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"click",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});i&&i(a),h&&h(a)}else{const t=Object.assign(Object.assign({},r),{type:"click-end"});i&&i(t),h&&h(t)}}},[i,h,a,l])}}const vn={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 xn(t,e,n){var r,i,o,a,l,s;const c=vn[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 bn=n(function(e,n){var i,a,s,c;const u=xn(e.mode,{width:null!==(a=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==a?a:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:S,tooltipContent:P,tooltip:L,onHover:D,annotations:_,svgAnnotationRules:$,tickFormatTime:T,tickFormatValue:W,decay:N,pulse:O,staleness:z,transition:I,linkedHover:C,onObservation:R,chartId:Y}=e,B=u.showAxes,j=u.enableHover,F=null!=d?d:u.marginDefaults,X=null!=h?h:[u.width,u.height],H=null!=P?P:L,G=r(null),{customHoverBehavior:V}=mn({linkedHover:C,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:Y}),q=o(t=>{D&&D(t),V(t)},[D,V]);return l(n,()=>({push:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=G.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=G.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),t.createElement(Nt,{ref:G,chartType:"line",runtimeMode:"streaming",size:X,margin:F,className:f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:{stroke:E,strokeWidth:A,strokeDasharray:M},showAxes:B,background:S,hoverAnnotation:j,tooltipContent:H,customHoverBehavior:q,annotations:_,svgAnnotationRules:$,tickFormatTime:T,tickFormatValue:W,decay:N,pulse:O,staleness:z,transition:I})});bn.displayName="RealtimeLineChart";const kn=n(function(e,n){var i,a,s,c;const u=xn(e.mode,{width:null!==(a=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==a?a:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:h,size:d,margin:f,className:y,arrowOfTime:g="right",windowMode:p="sliding",windowSize:m=200,data:v,timeAccessor:x,valueAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,categoryAccessor:A,colors:M,fill:S,stroke:P,strokeWidth:L,gap:D,background:_,tooltipContent:$,tooltip:T,onHover:W,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I,linkedHover:C,decay:R,pulse:Y,staleness:B,transition:j,onObservation:F,chartId:X}=e,H=u.showAxes,G=u.enableHover,V=null!=f?f:u.marginDefaults,q=null!=d?d:[u.width,u.height],Z=null!=$?$:T,K=r(null),{customHoverBehavior:U}=mn({linkedHover:C,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:X}),Q=o(t=>{W&&W(t),U(t)},[W,U]);l(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const J={};return null!=S&&(J.fill=S),null!=P&&(J.stroke=P),null!=L&&(J.strokeWidth=L),null!=D&&(J.gap=D),t.createElement(Nt,{ref:K,chartType:"bar",runtimeMode:"streaming",size:q,margin:V,className:y,arrowOfTime:g,windowMode:p,windowSize:m,data:v,timeAccessor:x,valueAccessor:b,xExtent:k,yExtent:w,extentPadding:E,binSize:h,categoryAccessor:A,barColors:M,barStyle:J,showAxes:H,background:_,hoverAnnotation:G,tooltipContent:Z,customHoverBehavior:Q,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I,decay:R,pulse:Y,staleness:B,transition:j})});kn.displayName="RealtimeTemporalHistogram";const wn=kn,En=n(function(e,n){var i,a,s,c;const u=xn(e.mode,{width:null!==(a=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==a?a:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:S,opacity:P,stroke:L,strokeWidth:D,background:_,tooltipContent:$,tooltip:T,onHover:W,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I,linkedHover:C,onObservation:R,chartId:Y}=e,B=u.showAxes,j=u.enableHover,F=null!=d?d:u.marginDefaults,X=null!=h?h:[u.width,u.height],H=null!=$?$:T,G=r(null),{customHoverBehavior:V}=mn({linkedHover:C,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:Y}),q=o(t=>{W&&W(t),V(t)},[W,V]);l(n,()=>({push:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=G.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=G.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Z={};return null!=M&&(Z.radius=M),null!=S&&(Z.fill=S),null!=P&&(Z.opacity=P),null!=L&&(Z.stroke=L),null!=D&&(Z.strokeWidth=D),t.createElement(Nt,{ref:G,chartType:"swarm",runtimeMode:"streaming",size:X,margin:F,className:f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:E,barColors:A,swarmStyle:Z,showAxes:B,background:_,hoverAnnotation:j,tooltipContent:H,customHoverBehavior:q,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I})});En.displayName="RealtimeSwarmChart";const An=n(function(e,n){var i,a,s,c;const u=xn(e.mode,{width:null!==(a=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==a?a:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:S,gap:P,stroke:L,strokeWidth:D,background:_,tooltipContent:$,tooltip:T,onHover:W,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I,linkedHover:C,onObservation:R,chartId:Y}=e,B=u.showAxes,j=u.enableHover,F=null!=d?d:u.marginDefaults,X=null!=h?h:[u.width,u.height],H=null!=$?$:T,G=r(null),{customHoverBehavior:V}=mn({linkedHover:C,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:Y}),q=o(t=>{W&&W(t),V(t)},[W,V]);l(n,()=>({push:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=G.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=G.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Z={};return null!=E&&(Z.positiveColor=E),null!=A&&(Z.negativeColor=A),null!=M&&(Z.connectorStroke=M),null!=S&&(Z.connectorWidth=S),null!=P&&(Z.gap=P),null!=L&&(Z.stroke=L),null!=D&&(Z.strokeWidth=D),t.createElement(Nt,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:X,margin:F,className:f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:Z,showAxes:B,background:_,hoverAnnotation:j,tooltipContent:H,customHoverBehavior:q,annotations:N,svgAnnotationRules:O,tickFormatTime:z,tickFormatValue:I})});An.displayName="RealtimeWaterfallChart";const Mn=n(function(e,n){var i,a,s,c;const u=xn(e.mode,{width:null!==(a=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==a?a:e.width,height:null!==(c=null===(s=e.size)||void 0===s?void 0:s[1])&&void 0!==c?c:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:S="count",background:P,tooltipContent:L,tooltip:D,onHover:_,annotations:$,svgAnnotationRules:T,tickFormatTime:W,tickFormatValue:N,decay:O,pulse:z,staleness:I,linkedHover:C,onObservation:R,chartId:Y}=e,B=u.showAxes,j=u.enableHover,F=null!=d?d:u.marginDefaults,X=null!=h?h:[u.width,u.height],H=null!=L?L:D,G=r(null),{customHoverBehavior:V}=mn({linkedHover:C,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:Y}),q=o(t=>{_&&_(t),V(t)},[_,V]);return l(n,()=>({push:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=G.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=G.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=G.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),t.createElement(Nt,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:F,className:f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:E,heatmapXBins:A,heatmapYBins:M,heatmapAggregation:S,showAxes:B,background:P,hoverAnnotation:j,tooltipContent:H,customHoverBehavior:q,annotations:$,svgAnnotationRules:T,tickFormatTime:W,tickFormatValue:N,decay:O,pulse:z,staleness:I})});Mn.displayName="RealtimeHeatmap";export{H as IncrementalExtent,Mn as RealtimeHeatmap,wn as RealtimeHistogram,bn as RealtimeLineChart,En as RealtimeSwarmChart,An as RealtimeWaterfallChart,X as RingBuffer,ln as StreamNetworkFrame,Nt as StreamXYFrame};
|