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
package/dist/xy.module.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import e,{useMemo as n,forwardRef as o,useRef as r,useState as i,useCallback as s,useEffect as a,useImperativeHandle as l,createContext as c,useContext as h,useLayoutEffect as u}from"react";import{brushX as d,brushY as f,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as m,scaleOrdinal as g}from"d3-scale";import{bin as x,sum as b}from"d3-array";import{schemeCategory10 as v,interpolatePlasma as k,interpolateViridis as E,interpolatePurples as w,interpolateOranges as M,interpolateGreens as A,interpolateReds as S,interpolateBlues as $,schemeSet3 as P,schemeTableau10 as N}from"d3-scale-chromatic";import _ from"labella";import{line as O,curveLinear as D,curveCardinal as j}from"d3-shape";import T from"regression";import{contourDensity as z}from"d3-contour";import{hexbin as C}from"d3-hexbin";const B=5e3;class W{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,B),bounded:!0,totalSize:t.length});let e=B;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const o=Math.min(e+B,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,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 F{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 L{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function Y(t,e,n,o,r){const i=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const t=r(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function I(t,e,n,o,r,i){const s=[],a=[];for(const r of t){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||(s.push([e.x(t),e.y(i)]),a.push(i))}return{type:"line",path:s,rawValues:a,style:r,datum:t,group:i}}function X(t,e,n,o,r,i,s){const a=[],l=[];for(const i of t){const t=n(i),s=o(i);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=e.x(t);a.push([c,e.y(s)]),l.push([c,e.y(r)])}return{type:"area",topPath:a,bottomPath:l,style:i,datum:t,group:s}}function R(t,e,n,o,r,i){const s=n(t),a=o(t);return null==s||null==a||Number.isNaN(s)||Number.isNaN(a)?null:{type:"point",x:e.x(s),y:e.y(a),r:r,style:i,datum:t}}function H(t,e,n,o,r,i,s){return{type:"rect",x:t,y:e,w:n,h:o,style:r,datum:i,group:s}}function V(t,e,n,o,r,i){return{type:"heatcell",x:t,y:e,w:n,h:o,fill:r,datum:i}}function G(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function q(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class J{constructor(t){this.xExtent=new L,this.yExtent=new L,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 F(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=G(t.timeAccessor||t.xAccessor,"time"),this.getY=G(t.valueAccessor||t.yAccessor,"value")):(this.getX=G(t.xAccessor,"x"),this.getY=G(t.yAccessor,"y")),this.getGroup=q(t.groupAccessor),this.getCategory=q(t.categoryAccessor),this.getSize=t.sizeAccessor?G(t.sizeAccessor,"size"):void 0,this.getColor=q(t.colorAccessor),this.getBounds=t.boundsAccessor?G(t.boundsAccessor,"bounds"):void 0,"candlestick"===t.chartType&&(this.getOpen=G(t.openAccessor,"open"),this.getHigh=G(t.highAccessor,"high"),this.getLow=G(t.lowAccessor,"low"),this.getClose=G(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new F(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,o,r,i,s;const{config:a,buffer:l}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const c=this.xExtent.extent,h=this.yExtent.extent;let u=a.xExtent?[null!==(e=a.xExtent[0])&&void 0!==e?e:c[0],null!==(n=a.xExtent[1])&&void 0!==n?n:c[1]]:c,d=a.yExtent?[null!==(o=a.yExtent[0])&&void 0!==o?o:h[0],null!==(r=a.yExtent[1])&&void 0!==r?r:h[1]]:h;const f=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!f&&l.size>0)if(a.normalize)d=[0,1+a.extentPadding];else{const t=l.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||n.set(t,(n.get(t)||0)+o)}let o=0;for(const t of n.values())t>o&&(o=t);d=[0,o+(o>0?o*a.extentPadding:1)]}else if("bar"===a.chartType&&a.binSize&&!f&&l.size>0){const[,t]=function(t,e,n,o,r){const i=Y(t,e,n,o,r);if(0===i.size)return[0,0];let s=0;for(const t of i.values())t.total>s&&(s=t.total);return[0,s]}(l,this.getX,this.getY,a.binSize,this.getCategory);d=[0,t+t*a.extentPadding]}else if("waterfall"===a.chartType&&!f&&l.size>0){const[t,e]=function(t,e){let n=0,o=0,r=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(r+=t,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(l,this.getY),n=e-t,o=n>0?n*a.extentPadding:1;d=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const t=l.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*a.extentPadding:1,n=null===(i=a.yExtent)||void 0===i?void 0:i[0],o=null===(s=a.yExtent)||void 0===s?void 0:s[1];d=[null!=n?d[0]:d[0]-e,null!=o?d[1]:d[1]+e]}if(u[0]!==1/0&&u[1]!==-1/0||(u=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==a.arrowOfTime)if("x"==("up"===(p=a.arrowOfTime)||"down"===p?"y":"x")){const e="right"===a.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:m().domain(u).range(e),y:m().domain(d).range([t.height,0])}}else{const e="down"===a.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:m().domain(d).range([0,t.width]),y:m().domain(u).range(e)}}else this.scales={x:m().domain(u).range([0,t.width]),y:m().domain(d).range([t.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=l.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,t);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,t);case"candlestick":return this.buildCandlestickScene(r,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),o=[],r=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&&o.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=I(t.data,this.scales,this.getX,this.getY,e,t.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(t){const e=this.groupData(t),n=[],o=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]);n.push(X(t.data,this.scales,this.getX,this.getY,o,e,t.key))}return n}buildStackedAreaScene(t){return function(t,e,n,o,r,i){var s;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const l=Array.from(a).sort((t,e)=>t-e),c=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||t.set(e,(t.get(e)||0)+i)}c.set(e.key,t)}let h;if(i){h=new Map;for(const e of l){let n=0;for(const o of t)n+=(null===(s=c.get(o.key))||void 0===s?void 0:s.get(e))||0;h.set(e,n||1)}}const u=[],d=new Map;for(const t of l)d.set(t,0);for(const n of t){const t=c.get(n.key),o=[],s=[];for(const n of l){let r=t.get(n)||0;const a=d.get(n);i&&(r/=h.get(n));const l=e.x(n);s.push([l,e.y(a)]),o.push([l,e.y(a+r)]),d.set(n,a+r)}u.push({type:"area",topPath:o,bottomPath:s,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return u}(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,o=this.config.sizeRange||[3,15];let r=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);r=e=>t===n?(o[0]+o[1])/2:o[0]+(e-t)/(n-t)*(o[1]-o[0])}}let i=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"];i=new Map;let o=0;for(const t of e)i.set(t,n[o%n.length]),o++}for(const o of t){let t=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=t.r||n;if(r&&this.getSize){const t=this.getSize(o);null==t||Number.isNaN(t)||(s=r(t))}if(i&&this.getColor){const e=this.getColor(o);e&&i.has(e)&&(t=Object.assign(Object.assign({},t),{fill:i.get(e)}))}const a=R(o,this.scales,this.getX,this.getY,s,t);a&&e.push(a)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const o=G(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const e of t)r.add(this.getX(e)),i.add(this.getY(e));const s=Array.from(r).sort((t,e)=>t-e),a=Array.from(i).sort((t,e)=>t-e);if(0===s.length||0===a.length)return n;const l=e.width/s.length,c=e.height/a.length,h=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;h.set(t,{val:o(e),datum:e})}let u=1/0,d=-1/0;for(const{val:t}of h.values())u>t&&(u=t),t>d&&(d=t);const f=d-u||1;for(let t=0;s.length>t;t++)for(let e=0;a.length>e;e++){const o=h.get(`${s[t]}_${a[e]}`);if(!o)continue;const r=(o.val-u)/f;n.push(V(t*l,(a.length-1-e)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(t,e){var n,o,r;const i=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=G(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return i;const[h,u]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),p=(u-h||1)/s,y=(f-d||1)/a,m=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),o=Math.min(Math.floor((t-h)/p),s-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=m.get(i);l||(l={sum:0,count:0,data:[]},m.set(i,l)),l.count++,l.sum+=c(e),l.data.push(e)}let g=1/0,x=-1/0;const b=new Map;for(const[t,e]of m){let n;switch(l){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}b.set(t,n),g>n&&(g=n),n>x&&(x=n)}const v=x-g||1,k=e.width/s,E=e.height/a;for(const[t,e]of b){const[n,o]=t.split("_"),r=+n,s=+o,l=(e-g)/v,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,h=m.get(t);i.push(V(r*k,(a-1-s)*E,k,E,c,{xi:r,yi:s,value:e,count:h.count,sum:h.sum,data:h.data}))}return i}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=Y(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=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):[],r=new Set(e),i=Array.from(t).filter(t=>!r.has(t)).sort();o=[...e.filter(e=>t.has(e)),...i]}const r=[],i=this.scales,[s,a]=i.x.domain();for(const t of n.values()){const n=Math.max(t.start,s),l=Math.min(t.end,a);if(n>=l)continue;const c=i.x(n),h=i.x(l),u=Math.min(c,h)+.5,d=Math.max(c,h)-.5-u;if(d>0)if(o&&t.categories.size>0){let n=0;for(const s of o){const o=t.categories.get(s)||0;if(0===o)continue;const a=i.y(n),l=i.y(n+o);r.push(H(u,Math.min(a,l),d,Math.abs(a-l),{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:o},s)),n+=o}}else{const e=i.y(0),n=i.y(t.total);r.push(H(u,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return r}buildSwarmScene(t){var e,n,o,r;const i=[],s=this.config.swarmStyle||{},a=null!==(e=s.radius)&&void 0!==e?e:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(o=s.opacity)&&void 0!==o?o:.7,h=s.stroke,u=s.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(t),s=this.scales.y(n);let d=l;if(this.getCategory){const t=this.getCategory(e);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[t])||d}i.push({type:"point",x:o,y:s,r:a,style:{fill:d,opacity:c,stroke:h,strokeWidth:u},datum:e})}return i}buildWaterfallScene(t,e){const n=[],o=this.scales,r=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===r.length)return n;let i=0;for(let t=0;r.length>t;t++){const s=r[t],a=this.getX(s),l=this.getY(s),c=i+l;let h;h=r.length-1>t?this.getX(r[t+1])-a:t>0?a-this.getX(r[t-1]):0;const u=o.x(a),d=0!==h?o.x(a+h):u+e.width/10,f=Math.min(u,d)+.5,p=Math.max(u,d)-.5-f;if(0>=p){i=c;continue}const y=o.y(i),m=o.y(c);n.push(H(f,Math.min(y,m),p,Math.abs(y-m),{fill:0>l?"#dc3545":"#28a745"},Object.assign(Object.assign({},s),{baseline:i,cumEnd:c,delta:l}))),i=c}return n}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",s=o.wickColor||"#333",a=o.wickWidth||1,l=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let t=1/0;for(let e=1;l.length>e;e++){const n=Math.abs(this.scales.x(l[e])-this.scales.x(l[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 o=this.getOpen(e),l=this.getHigh(e),h=this.getLow(e),u=this.getClose(e);if([o,l,h,u].some(t=>null==t||Number.isNaN(t)))continue;const d=u>=o;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(o),closeY:this.scales.y(u),highY:this.scales.y(l),lowY:this.scales.y(h),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const i=this.getBounds(e),s=this.scales.x(t);if(i&&0!==i)n.push([s,this.scales.y(r+i)]),o.push([s,this.scales.y(r-i)]);else{const t=this.scales.y(r);n.push([s,t]),o.push([s,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,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,o,r;const i=this.config.decay;if(!i||1>=e)return 1;const s=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=e-1-t;switch(i.type){case"linear":return s+(1-a/(e-1))*(1-s);case"exponential":{const t=null!==(o=i.halfLife)&&void 0!==o?o:e/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*e)>a?1:s;default:return 1}}applyDecay(t,e){var n,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const i=new Map;for(let t=0;e.length>t;t++)i.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=i.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r);if("heatcell"===e.type)e.style={opacity:s};else if("candlestick"===e.type)e._decayOpacity=s;else{const t=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*s})}}}computePulseIntensity(t,e){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=e-t;return r>i?1-i/r:0}applyPulse(t,e){var n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",i=new Map;for(let t=0;e.length>t;t++)i.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=i.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const s=this.computePulseIntensity(n,o);s>0&&(e._pulseIntensity=s,e._pulseColor=r)}}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,o=this.timestampBuffer.peek();return null!=o&&n>e-o}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,o,r,i;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!==(i=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==i?i: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,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const s=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const s=this.scene[t],l=this.getNodeIdentity(s,t);if(!l)continue;const c=this.prevPositionMap.get(l);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,a=!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!==(o=c.h)&&void 0!==o?o:s.h,a=!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!==(r=c.w)&&void 0!==r?r:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,a=!0)}}a&&(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),o="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)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*o)}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)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*o)}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)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*o)}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 o=this.config.lineStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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 K(t,e,n){const o=e-t.x,r=n-t.y,i=Math.sqrt(o*o+r*r);return i>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:i}}function Z(t,e,n){if(0===t.path.length)return null;const o=nt(t.path,e);if(0>o)return null;const[r,i]=t.path[o],s=e-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:r,y:i,distance:l}}function U(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 Q(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 tt(t,e,n){const o=t.bodyWidth/2,r=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=r+Math.max(Math.max(t.openY,t.closeY)-r,1)/2,i=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function et(t,e,n){if(0===t.topPath.length)return null;const o=nt(t.topPath,e);if(0>o)return null;const[r,i]=t.topPath[o],s=e-r,a=n-i;return{node:t,datum:t.datum,x:r,y:i,distance:Math.sqrt(s*s+a*a)}}function nt(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r][0]?n=r+1:o=r}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}const ot={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 rt(t,e,n,o){let r;return r="function"==typeof n?n(t):(0,ot[n])(o(t,e)),r}function it(e){const{legendGroups:n,customClickBehavior:o,title:r="Legend",width:i=100,height:s=20,orientation:a="vertical"}=e,l="vertical"===a?(({legendGroups:e,width:n,customClickBehavior:o})=>{let r=30;const i=[];return e.forEach((e,s)=>{r+=5,i.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:r,x2:n,y2:r})),r+=10,e.label&&(r+=20,i.push(t.createElement("text",{key:"legend-text-"+s,y:r,className:"legend-group-label"},e.label)),r+=10),i.push(t.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${r})`},((e,n)=>{const{type:o="fill",styleFn:r,items:i}=e,s=[];let a=0;return i.forEach((e,i)=>{const l=rt(e,i,o,r);s.push(t.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${a})`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},l,t.createElement("text",{y:15,x:30},e.label))),a+=25}),s})(e,o))),r+=25*e.items.length+10}),i})({legendGroups:n,width:i,customClickBehavior:o}):(({legendGroups:e,title:n,height:o,customClickBehavior:r})=>{let i=0;const s=[],a=!1===n?10:40;return e.forEach((n,l)=>{n.label&&(s.push(t.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),i+=20);const c=((e,n)=>{const{type:o="fill",styleFn:r,items:i}=e,s=[];let a=0;return i.forEach((e,i)=>{const l=rt(e,i,o,r);s.push(t.createElement("g",{key:"legend-item-"+i,transform:`translate(${a},0)`,onClick:n?()=>n(e):void 0,style:{cursor:n?"pointer":"default"}},l,t.createElement("text",{y:15,x:25},e.label))),a+=35,a+=8*e.label.length}),{items:s,offset:a}})(n,r);s.push(t.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${a})`},c.items)),i+=c.offset+5,e[l+1]&&s.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:a-10,x2:i,y2:o+a+10})),i+=15}),t.createElement("g",null,!1!==n&&t.createElement("line",{x1:0,x2:i+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:n,title:r,height:s,customClickBehavior:o});return t.createElement("g",null,void 0!==r&&t.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:i/2,textAnchor:"horizontal"===a?"start":"middle"},r),l)}function st(t){return"string"==typeof t?{type:t}:t}function at({orient:e,config:o,values:r,scale:i,size:s,length:a}){const l=function(t){var e,n,o,r,i;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!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=t.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=t.strokeWidth)&&void 0!==i?i:1}}(o),c="top"===e||"bottom"===e,h=n(()=>{if(0===r.length)return null;const n=i.domain(),o=s-8;if("boxplot"===l.type){const n=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const o=e[Math.floor(.25*n)],r=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],i+1.5*s)}}(r);if(!n)return null;const{q1:s,median:a,q3:h,whiskerLow:u,whiskerHigh:d}=n,f=Math.min(.5*o,20),p=(o-f)/2+4;if(c){const n=i(s),o=i(h),r=i(a),c=i(u),y=i(d),m="top"===e?-1:1,g=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:c,y1:g+m*(p+f/2),x2:y,y2:g+m*(p+f/2),stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:c,y1:g+m*p,x2:c,y2:g+m*(p+f),stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:y,y1:g+m*p,x2:y,y2:g+m*(p+f),stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("rect",{x:Math.min(n,o),y:"top"===e?g-p-f:g+p,width:Math.abs(o-n),height:f,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:r,y1:"top"===e?g-p-f:g+p,x2:r,y2:"top"===e?g-p:g+p+f,stroke:l.fill,strokeWidth:2}))}{const n=i(s),o=i(h),r=i(a),c=i(u),y=i(d),m="left"===e?-1:1,g=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:g+m*(p+f/2),y1:c,x2:g+m*(p+f/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:g+m*p,y1:c,x2:g+m*(p+f),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:g+m*p,y1:y,x2:g+m*(p+f),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),t.createElement("rect",{x:"left"===e?g-p-f:g+p,y:Math.min(n,o),width:f,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),t.createElement("line",{x1:"left"===e?g-p-f:g+p,y1:r,x2:"left"===e?g-p:g+p+f,y2:r,stroke:l.fill,strokeWidth:2}))}}const h=x().domain(n).thresholds(l.bins)(r);if(0===h.length)return null;const u=Math.max(...h.map(t=>t.length));if(0===u)return null;if("histogram"===l.type)return t.createElement("g",{"data-testid":"marginal-histogram-"+e},h.map((n,r)=>{if(null==n.x0||null==n.x1)return null;const s=n.length/u*o;if(c){const o=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:r,x:o,y:"top"===e?-4-s:4,width:Math.max(a,.5),height:s,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const o=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:r,x:"left"===e?-4-s:4,y:Math.min(o,o+a),width:s,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=o/2+4,r=[];for(const t of h){if(null==t.x0||null==t.x1)continue;const s=t.length/u*(o/2),a=i((t.x0+t.x1)/2);r.push(c?`${a},${"top"===e?-(n-s):n-s}`:`${"left"===e?-(n-s):n-s},${a}`)}for(let t=h.length-1;t>=0;t--){const s=h[t];if(null==s.x0||null==s.x1)continue;const a=s.length/u*(o/2),l=i((s.x0+s.x1)/2);r.push(c?`${l},${"top"===e?-(n+a):n+a}`:`${"left"===e?-(n+a):n+a},${l}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+e},t.createElement("polygon",{points:r.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const t=0,r=null!=h[0].x0?i(h[0].x0):0;n.push(`M${r},${t}`);for(const t of h){if(null==t.x0||null==t.x1)continue;const r=t.length/u*o,s=i((t.x0+t.x1)/2);n.push(`L${s},${"top"===e?-r-4:r+4}`)}const s=null!=h[h.length-1].x1?i(h[h.length-1].x1):a;n.push(`L${s},${t}`),n.push("Z")}else{const t=0,r=null!=h[0].x0?i(h[0].x0):0;n.push(`M${t},${r}`);for(const t of h){if(null==t.x0||null==t.x1)continue;const r=t.length/u*o,s=i((t.x0+t.x1)/2);n.push(`L${"left"===e?-r-4:r+4},${s}`)}const s=null!=h[h.length-1].x1?i(h[h.length-1].x1):a;n.push(`L${t},${s}`),n.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+e},t.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[r,i,l,s,a,e,c,4]);return h?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},h):null}function lt(t){return Math.round(100*t)/100+""}function ct(e){const{width:o,height:r,totalWidth:i,totalHeight:s,margin:a,scales:l,showAxes:c,xLabel:h,yLabel:u,xFormat:d,yFormat:f,showGrid:p,title:y,legend:m,foregroundGraphics:g,marginalGraphics:x,xValues:b,yValues:v,annotations:k,svgAnnotationRules:E,annotationFrame:w,children:M}=e,A=n(()=>c&&l?l.x.ticks(5).map(t=>({value:t,pixel:l.x(t),label:(d||lt)(t)})):[],[c,l,d]),S=n(()=>c&&l?l.y.ticks(5).map(t=>({value:t,pixel:l.y(t),label:(f||lt)(t)})):[],[c,l,f]),$=n(()=>k&&0!==k.length&&E?k.map((t,e)=>E(t,e,{scales:l?{time:l.x,value:l.y}:null,timeAxis:"x",width:o,height:r})).filter(Boolean):null,[k,E,o,r,w]);return c||y||m||g||x||$&&$.length>0||p||M?t.createElement("svg",{width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&l&&t.createElement("g",{className:"stream-grid"},A.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"#e0e0e0",strokeWidth:1})),S.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"#e0e0e0",strokeWidth:1}))),c&&l&&t.createElement("g",{className:"stream-axes"},t.createElement("line",{x1:0,y1:r,x2:o,y2:r,stroke:"#ccc",strokeWidth:1}),A.map((e,n)=>t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${r})`},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))),h&&t.createElement("text",{x:o/2,y:r+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},h),t.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:"#ccc",strokeWidth:1}),S.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))),u&&t.createElement("text",{x:15-a.left,y:r/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-a.left}, ${r/2})`,style:{userSelect:"none"}},u)),$,x&&l&&b&&v&&t.createElement(t.Fragment,null,x.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(at,{orient:"top",config:st(x.top),values:b,scale:l.x,size:a.top,length:o})),x.bottom&&t.createElement("g",{transform:`translate(0, ${r})`},t.createElement(at,{orient:"bottom",config:st(x.bottom),values:b,scale:l.x,size:a.bottom,length:o})),x.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(at,{orient:"left",config:st(x.left),values:v,scale:l.y,size:a.left,length:r})),x.right&&t.createElement("g",{transform:`translate(${o}, 0)`},t.createElement(at,{orient:"right",config:st(x.right),values:v,scale:l.y,size:a.right,length:r}))),g,M),y&&t.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof y?y:null),m&&t.createElement("g",{transform:`translate(${i-a.right+10}, ${a.top})`},"object"==typeof(P=m)&&null!==P&&!t.isValidElement(P)&&"legendGroups"in P?t.createElement(it,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var P}function ht(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}const ut=(t,e,n,o)=>{var r;const i=e.filter(t=>"area"===t.type);for(const e of i){if(2>e.topPath.length)continue;t.beginPath();const[n,o]=e.topPath[0];t.moveTo(n,o);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 i=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.7;if(t.globalAlpha=i,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}},dt=(t,e,n,o)=>{var r;const i=e.filter(t=>"point"===t.type);for(const e of i){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(r=e.style.opacity)&&void 0!==r?r: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}},ft=(t,e,n,o)=>{const r=e.filter(t=>"rect"===t.type);for(const e of r)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,o=e.style.iconPadding||2,r=Math.min(e.w,e.w)-o;if(0>=r)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=r+o,s=e.x+(e.w-r)/2;for(let o=e.y+e.h-r;o>=e.y-r;o-=i)t.drawImage(n,s,o,r,r)}else{const i=r+o,s=e.y+(e.h-r)/2;for(let o=e.x;e.x+e.w>o;o+=i)t.drawImage(n,o,s,r,r)}t.restore()}const yt={line:[ut,(t,e,n,o)=>{const r=e.filter(t=>"line"===t.type);for(const i of r){if(2>i.path.length)continue;const s=i.style.stroke||"#007bff",a=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(t.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(t.globalAlpha=i.style.opacity),t.lineWidth=a,l&&0!==l.length&&c&&c.length===i.path.length){let h=null,u=null,d=null,f=null,p=!1;function y(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),p=!0}function m(){p&&(t.stroke(),p=!1)}for(let g=0;i.path.length>g;g++){const[x,b]=i.path[g],v=c[g],k=ht(v,l,s);if(null!==h&&null!==f&&null!==d){if(k===f)t.lineTo(x,b);else{const E=[];for(const w of l){const M=w.value;(d>M||M>v)&&(M>d||v>M)||d===M||v===M||E.push({t:(M-d)/(v-d)})}E.sort((t,e)=>t.t-e.t);for(const A of E){const S=h+(x-h)*A.t,$=u+(b-u)*A.t,P=ht(d+(v-d)*Math.min(A.t+1e-4,1),l,s);t.lineTo(S,$),m(),y(P,S,$)}t.lineTo(x,b)}h=x,u=b,d=v,f=k}else y(k,x,b),h=x,u=b,d=v,f=k}m()}else{t.beginPath(),t.strokeStyle=s;const[N,_]=i.path[0];t.moveTo(N,_);for(let O=1;i.path.length>O;O++)t.lineTo(i.path[O][0],i.path[O][1]);t.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){t.beginPath(),t.globalAlpha=i.style.fillOpacity,t.fillStyle=i.style.fill;const[D,j]=i.path[0];t.moveTo(D,j);for(let z=1;i.path.length>z;z++)t.lineTo(i.path[z][0],i.path[z][1]);const T=i.path[0][0];t.lineTo(i.path[i.path.length-1][0],o.height),t.lineTo(T,o.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[ut],stackedarea:[ut],scatter:[dt],bubble:[dt],heatmap:[(t,e,n,o)=>{const r=e.filter(t=>"heatcell"===t.type);for(const e of r){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:[ft],swarm:[dt],waterfall:[(t,e,n,o)=>{var r,i;ft(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 o=s[e],a=s[e+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(i=a.datum)||void 0===i?void 0:i.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,h=a.x;t.beginPath(),t.moveTo(c,l),t.lineTo(h,l),t.stroke()}t.restore()}}],candlestick:[(t,e,n,o)=>{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 o=Math.min(e.openY,e.closeY),r=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor;t.fillStyle=i,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(r,1)),t.strokeStyle=i,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(r,1))}}]},mt={top:20,right:20,bottom:30,left:40},gt={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},xt={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 bt({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:xt},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}function vt({width:e,height:n,totalWidth:o,totalHeight:i,margin:s,dimension:l,scales:c,onBrush:h}){const u=r(null),m=r(null);return a(()=>{if(!u.current)return;const t=y(u.current).select(".brush-g"),o="x"===l?d():"y"===l?f():p();return o.extent([[0,0],[e,n]]),o.on("brush end",t=>{if(!c)return;if(!t.selection)return void h(null);let o,r;if("x"===l){const[e,i]=t.selection;o=[c.x.invert(e),c.x.invert(i)],r=[c.y.invert(n),c.y.invert(0)]}else if("y"===l){const[n,i]=t.selection;o=[c.x.invert(0),c.x.invert(e)],r=[c.y.invert(i),c.y.invert(n)]}else{const[[e,n],[i,s]]=t.selection;o=[c.x.invert(e),c.x.invert(i)],r=[c.y.invert(s),c.y.invert(n)]}h({x:o,y:r})}),t.call(o),m.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),m.current=null}},[e,n,l,c,h]),t.createElement("svg",{ref:u,width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const kt=o(function(e,o){var c;const{chartType:h,runtimeMode:u,data:d,xAccessor:f,yAccessor:p,colorAccessor:y,sizeAccessor:m,groupAccessor:g,lineDataAccessor:x,normalize:b,binSize:v,valueAccessor:k,arrowOfTime:E="right",windowMode:w="sliding",windowSize:M=200,timeAccessor:A,xExtent:S,yExtent:$,extentPadding:P=.1,sizeRange:N,size:_=[500,300],margin:O,className:D,background:j,lineStyle:T,pointStyle:z,areaStyle:C,swarmStyle:B,barColors:F,colorScheme:L,boundsAccessor:Y,boundsStyle:I,openAccessor:X,highAccessor:R,lowAccessor:H,closeAccessor:V,candlestickStyle:G,showAxes:q=!0,xLabel:nt,yLabel:ot,xFormat:rt,yFormat:it,tickFormatTime:st,tickFormatValue:at,hoverAnnotation:lt,tooltipContent:ht,customHoverBehavior:ut,enableHover:dt,annotations:ft,svgAnnotationRules:pt,showGrid:xt,legend:kt,backgroundGraphics:Et,foregroundGraphics:wt,title:Mt,categoryAccessor:At,brush:St,onBrush:$t,decay:Pt,pulse:Nt,transition:_t,staleness:Ot,heatmapAggregation:Dt,heatmapXBins:jt,heatmapYBins:Tt,marginalGraphics:zt}=e,Ct=Object.assign(Object.assign({},mt),O);if(zt){const t=60;zt.top&&t>Ct.top&&(Ct.top=t),zt.bottom&&t>Ct.bottom&&(Ct.bottom=t),zt.left&&t>Ct.left&&(Ct.left=t),zt.right&&t>Ct.right&&(Ct.right=t)}const Bt=_[0]-Ct.left-Ct.right,Wt=_[1]-Ct.top-Ct.bottom,Ft=null!=lt?lt:dt,Lt=r(null),Yt=r(0),It=r(!1),[Xt,Rt]=i(0),[Ht,Vt]=i(null),Gt=r(null),[qt,Jt]=i(null),[Kt,Zt]=i(!1),[Ut,Qt]=i([]),[te,ee]=i([]),ne=r(()=>{}),oe="streaming"===u||["bar","swarm","waterfall"].includes(h),re=n(()=>({chartType:h,runtimeMode:oe?"streaming":"bounded",windowSize:M,windowMode:w,arrowOfTime:oe?E:"right",extentPadding:P,xAccessor:oe?void 0:f,yAccessor:oe?void 0:p,timeAccessor:oe?A:void 0,valueAccessor:k,colorAccessor:y,sizeAccessor:m,groupAccessor:g,categoryAccessor:At,lineDataAccessor:x,xExtent:S,yExtent:$,sizeRange:N,binSize:v,normalize:b,boundsAccessor:Y,boundsStyle:I,openAccessor:X,highAccessor:R,lowAccessor:H,closeAccessor:V,candlestickStyle:G,lineStyle:T,pointStyle:z,areaStyle:C,swarmStyle:B,colorScheme:L,barColors:F,annotations:ft,decay:Pt,pulse:Nt,transition:_t,staleness:Ot,heatmapAggregation:Dt,heatmapXBins:jt,heatmapYBins:Tt}),[h,M,w,E,P,f,p,A,k,y,m,g,At,x,S,$,N,v,b,Y,I,X,R,H,V,G,T,z,C,B,L,F,ft,Pt,Nt,_t,Ot,Dt,jt,Tt,oe]),ie=r(null);ie.current||(ie.current=new J(re));const se=s(()=>{Yt.current||(Yt.current=requestAnimationFrame(()=>ne.current()))},[]);a(()=>{var t;null===(t=ie.current)||void 0===t||t.updateConfig(re),It.current=!0,se()},[re,se]);const ae=r(null);ae.current||(ae.current=new W(t=>{const e=ie.current;e&&e.ingest(t)&&(It.current=!0,se())}));const le=s(t=>{var e;null===(e=ae.current)||void 0===e||e.push(t)},[]),ce=s(t=>{var e;null===(e=ae.current)||void 0===e||e.pushMany(t)},[]),he=s(()=>{var t,e;null===(t=ae.current)||void 0===t||t.clear(),null===(e=ie.current)||void 0===e||e.clear(),It.current=!0,se()},[se]);l(o,()=>({push:le,pushMany:ce,clear:he,getData:()=>{var t,e;return null!==(e=null===(t=ie.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=ie.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=ie.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[le,ce,he]),a(()=>{var t;d&&(null===(t=ae.current)||void 0===t||t.setBoundedData(d))},[d]);const ue=r(()=>{}),de=r(()=>{});ue.current=t=>{if(!Ft)return;const e=Lt.current;if(!e)return;const n=e.getBoundingClientRect(),o=t.clientX-n.left-Ct.left,r=t.clientY-n.top-Ct.top;if(0>o||o>Bt||0>r||r>Wt)return void(Gt.current&&(Gt.current=null,Jt(null),ut&&ut(null),se()));const i=ie.current;if(!i||0===i.scene.length)return;const s=function(t,e,n,o=30){let r=null;for(const i of t){let t=null;switch(i.type){case"point":t=K(i,e,n);break;case"line":t=Z(i,e,n);break;case"rect":t=U(i,e,n);break;case"heatcell":t=Q(i,e,n);break;case"area":if(!1===i.interactive)break;t=et(i,e,n);break;case"candlestick":t=tt(i,e,n)}t&&o>t.distance&&(r&&t.distance>=r.distance||(r=t))}return r}(i.scene,o,r);if(!s)return void(Gt.current&&(Gt.current=null,Jt(null),ut&&ut(null),se()));const a={data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y};Gt.current=a,Jt(a),ut&&ut(a),se()},de.current=()=>{Gt.current&&(Gt.current=null,Jt(null),ut&&ut(null),se())};const fe=s(t=>ue.current(t),[]),pe=s(()=>de.current(),[]);ne.current=()=>{var t,e;Yt.current=0;const n=Lt.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=ie.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i);s||r.computeScene({width:Bt,height:Wt});const a="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=_[0]*a,n.height=_[1]*a,n.style.width=_[0]+"px",n.style.height=_[1]+"px",o.scale(a,a),o.translate(Ct.left,Ct.top),o.clearRect(-Ct.left,-Ct.top,_[0],_[1]);const l=function(t){if(!t)return gt;const e=getComputedStyle(t),n=e.getPropertyValue("--text-secondary").trim(),o=e.getPropertyValue("--text-primary").trim(),r=e.getPropertyValue("--surface-3").trim(),i=e.getPropertyValue("--surface-0").trim();return n||o?{axisStroke:r||gt.axisStroke,tickText:n||gt.tickText,crosshair:n?n+"66":gt.crosshair,hoverFill:i?i+"4D":gt.hoverFill,hoverStroke:n?n+"99":gt.hoverStroke,pointRing:i||gt.pointRing}:gt}(n),c=null!==(t=null==Ot?void 0:Ot.threshold)&&void 0!==t?t:5e3,u=Ot&&r.lastIngestTime>0&&i-r.lastIngestTime>c;u&&(o.globalAlpha=null!==(e=null==Ot?void 0:Ot.dimOpacity)&&void 0!==e?e:.5),j&&(o.fillStyle=j,o.fillRect(0,0,Bt,Wt));const d=yt[h];if(d&&r.scales)for(const t of d)t(o,r.scene,r.scales,{width:Bt,height:Wt});u&&(o.globalAlpha=1),Ft&&Gt.current&&r.scales&&function(t,e,n,o,r,i,s){if(!1===r.crosshair)return;t.save();const a="object"==typeof r.crosshair?r.crosshair:{};t.strokeStyle=a.stroke||s.crosshair,t.lineWidth=a.strokeWidth||1,t.setLineDash(a.strokeDasharray?a.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,o),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()}(o,Gt.current,Bt,Wt,"object"==typeof Ft?Ft:{},0,l);const y=It.current;if(It.current=!1,y&&r.scales&&(Vt(r.scales),zt)){const t=r.getData(),e="function"==typeof f?f:t=>t[f||"x"],n="function"==typeof p?p:t=>t[p||"y"];Qt(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)))}y&&ft&&ft.length>0&&pt&&Rt(t=>t+1),(null==Ot?void 0:Ot.showBadge)&&Zt(!!u),(s||r.hasActivePulses)&&(Yt.current=requestAnimationFrame(()=>ne.current()))},a(()=>(se(),()=>{Yt.current&&cancelAnimationFrame(Yt.current)}),[se]),a(()=>{It.current=!0,se()},[h,Bt,Wt,q,j,T,se]),a(()=>{if(!Ot)return;const t=setInterval(()=>{var t;const e=ie.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(t=Ot.threshold)&&void 0!==t?t:5e3,r=n-e.lastIngestTime>o;r!==Kt&&(Zt(r),It.current=!0,se())},1e3);return()=>clearInterval(t)},[Ot,Kt,se]);const ye=Ft&&qt?ht?ht(qt):t.createElement(bt,{hover:qt}):null,me=ye?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*Bt?"calc(-100% - 12px)":"12px"}, ${.3*Wt>qt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ye):null;return t.createElement("div",{className:"stream-xy-frame"+(D?" "+D:""),style:{position:"relative",width:_[0],height:_[1]},onMouseMove:Ft?fe:void 0,onMouseLeave:Ft?pe:void 0},Et&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:_[0],height:_[1],pointerEvents:"none"}},Et),t.createElement("canvas",{ref:Lt,style:{position:"absolute",left:0,top:0}}),t.createElement(ct,{width:Bt,height:Wt,totalWidth:_[0],totalHeight:_[1],margin:Ct,scales:Ht,showAxes:q,xLabel:nt,yLabel:ot,xFormat:rt||st,yFormat:it||at,showGrid:xt,title:Mt,legend:kt,foregroundGraphics:wt,marginalGraphics:zt,xValues:Ut,yValues:te,annotations:ft,svgAnnotationRules:pt,annotationFrame:Xt}),(St||$t)&&t.createElement(vt,{width:Bt,height:Wt,totalWidth:_[0],totalHeight:_[1],margin:Ct,dimension:null!==(c=null==St?void 0:St.dimension)&&void 0!==c?c:"xy",scales:Ht,onBrush:null!=$t?$t:()=>{}}),(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:Kt?"#dc3545":"#28a745",color:"white"})},Kt?"STALE":"LIVE"),me)});kt.displayName="StreamXYFrame";const Et={category10:v,tableau10:N,set3:P,blues:$,reds:S,greens:A,oranges:M,purples:w,viridis:E,plasma:k},wt=v;function Mt(t,e,n){if("function"==typeof e)return e(t);const o=t[e];return n?n(o):wt[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o+""))%wt.length]}const At="#007bff";const St={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function $t(t,e){return"function"==typeof e?e(t):t[e]}function Pt(t,e){return e?e(t):null==t?"":"number"==typeof t?t.toLocaleString():t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function Nt(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:n,title:o,format:r,style:i={},className:s=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(o){const t=$t(e,o);a=Pt(t,r)}if(n&&n.length>0)n.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=$t(e,o);l.push({label:n,value:Pt(s,i)})});else if(!o){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Pt(e[n],r);break}if(!a){const t=Object.keys(e).filter(t=>!t.startsWith("_"));t.length>0&&(a=Pt(e[t[0]],r))}}const c=Object.assign(Object.assign({},St),i);return t.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:c},a&&t.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,n)=>t.createElement("div",{key:n,style:{marginTop:0===n&&a?"4px":0}},e.label&&t.createElement("span",null,e.label,": "),e.value)))}}(e)))}function _t({componentName:e,message:n,width:o,height:r}){return t.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},t.createElement("div",{style:{textAlign:"center",maxWidth:400}},t.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),t.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}function Ot({width:e,height:n,margin:o,scales:i,brushDirection:s,extent:l,onBrush:c}){const h=r(null),u=r(null),p=r(!1),m=e+o.left+o.right,g=n+o.top+o.bottom;return a(()=>{if(!h.current||!i)return;const t=y(h.current).select(".brush-group"),o="x"===s?d().extent([[0,0],[e,n]]):f().extent([[0,0],[e,n]]);return o.on("brush end",t=>{if(p.current)return;if(!t.sourceEvent)return;const e=t.selection;if(!e)return void c(null);const n=("x"===s?i.x:i.y).invert;if(!n)return;const o=[n(e[0]),n(e[1])];c(o)}),t.call(o),u.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null)}},[i,e,n,s,c]),a(()=>{if(!u.current||!i||!h.current)return;const t=y(h.current).select(".brush-group"),e="x"===s?i.x:i.y;if(p.current=!0,l){const n=[e(l[0]),e(l[1])];t.call(u.current.move,n)}else t.call(u.current.move,null);p.current=!1},[l,i,s]),t.createElement("svg",{ref:h,width:m,height:g,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-group",transform:`translate(${o.left},${o.top})`}))}function Dt(e){var o,l;const{data:c,width:h=600,height:u=400,margin:d,className:f,title:p,xLabel:y,yLabel:m,xFormat:x,yFormat:b,xAccessor:v="x",yAccessor:k="y",lineBy:E,lineDataAccessor:w="coordinates",colorBy:M,colorScheme:A="category10",curve:S="linear",lineWidth:$=2,fillArea:P=!1,areaOpacity:N=.3,showPoints:_=!1,pointRadius:O=3,enableHover:D=!0,showGrid:j=!1,showLegend:T,tooltip:z,minimap:C={},renderBefore:B=!1,onBrush:W,brushExtent:F,frameProps:L={}}=e,Y=c||[],[I,X]=i(null),R=null!=F?F:I,H=s(t=>{F||X(t),null==W||W(t)},[F,W]),V=r(null),[G,q]=i(null);a(()=>{const t=()=>{var e,n;const o=null===(n=null===(e=V.current)||void 0===e?void 0:e.getScales)||void 0===n?void 0:n.call(e);o?q(o):requestAnimationFrame(t)};requestAnimationFrame(t)},[c]);const J=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[w]),K=n(()=>{if(J)return Y;if(E){const t=Y.reduce((t,e)=>{const n="function"==typeof E?E(e):e[E];if(!t[n]){const e={[w]:[]};"string"==typeof E&&(e[E]=n),t[n]=e}return t[n][w].push(e),t},{});return Object.values(t)}return[{[w]:Y}]},[Y,E,w,J]),Z=n(()=>J||E?K.flatMap(t=>{const e=t[w]||[];return E&&"string"==typeof E?e.map(e=>Object.assign(Object.assign({},e),{[E]:t[E]})):e}):Y,[K,w,J,E,Y]),U=function(t,e,o="category10"){return n(()=>{if(e&&"function"!=typeof e)return function(t,e,n="category10"){const o=Array.from(new Set(t.map(t=>t[e]))),r=o.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(n))return g().domain(o).range(n).unknown("#999");const i=Et[n]||Et.category10;if(r&&"function"==typeof i)return t=>i(Number(t)/Math.max(...o.map(Number)));{const t=Array.isArray(i)?i:wt;return g().domain(o).range(t).unknown("#999")}}(t,e,o)},[t,e,o])}(Y,M,A),Q=n(()=>t=>{const e={strokeWidth:$};return e.stroke=M?Mt(t,M,U):At,P&&(e.fill=e.stroke,e.fillOpacity=N),e},[M,U,$,P,N]),tt=n(()=>C.lineStyle?C.lineStyle:t=>{const e={strokeWidth:1};return e.stroke=M?Mt(t,M,U):At,e},[M,U,C.lineStyle]),et=n(()=>{if(_)return t=>{const e={r:O,fillOpacity:1};return e.fill=M?Mt(t.parentLine||t,M,U):At,e}},[_,O,M,U]),nt=void 0!==T?T:K.length>1,ot=n(()=>{if(nt&&M)return function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){return{legendGroups:[{styleFn:t=>{const e={fill:t.color,stroke:t.color};return void 0!==r&&(e.stroke=r),void 0!==i&&(e.strokeWidth=i),e},type:"fill",items:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e]))).map(r=>{const i=t.find("function"==typeof e?t=>e(t)===r:t=>t[e]===r),s=i?o(i,e,n):n?n(r):"#000000";return{label:r+"",color:s}}),label:""}]}}({data:K,colorBy:M,colorScale:U,getColor:Mt})},[nt,M,K,U]),rt=n(()=>{const t=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),d);return ot&&120>t.right&&(t.right=120),t},[d,ot]),it=C.height||60,st=n(()=>{var t,e,n,o,r,i,s,a;return{top:null!==(e=null===(t=C.margin)||void 0===t?void 0:t.top)&&void 0!==e?e:0,bottom:null!==(o=null===(n=C.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=C.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:rt.left,right:null!==(a=null===(s=C.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:rt.right}},[C.margin,rt]),at=C.brushDirection||"x",lt=function({data:t,accessors:e,requiredProps:n}){if(n)for(const[t,e]of Object.entries(n))if(null==e)return t+" is required. Provide a field name or function.";if(!t||!Array.isArray(t)||0===t.length)return"No data provided. Pass a non-empty array to the data prop.";if(e){const n=t[0];if(n&&"object"==typeof n)for(const[t,o]of Object.entries(e))if(o&&"string"==typeof o&&!(o in n))return`${t} "${o}" not found in data. Available fields: ${Object.keys(n).join(", ")}.`}return null}({componentName:"MinimapChart",data:Y,accessors:{xAccessor:v,yAccessor:k}});if(lt)return t.createElement(_t,{componentName:"MinimapChart",message:lt,width:h,height:u});const ct=P?"area":"line",ht=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ct,data:Z,xAccessor:v,yAccessor:k,groupAccessor:E||void 0,curve:S,lineStyle:Q},_&&{pointStyle:et}),{size:[h,u],margin:rt,showAxes:!0,xLabel:y,yLabel:m,xFormat:x,yFormat:b,enableHover:D,showGrid:j}),ot&&{legend:ot}),p&&{title:p}),z&&{tooltipContent:Nt(z)}),R&&{xExtent:R}),L),ut={chartType:ct,data:Z,xAccessor:v,yAccessor:k,groupAccessor:E||void 0,curve:S,lineStyle:tt,size:[h,it+st.top+st.bottom],margin:st,showAxes:null!==(l=C.showAxes)&&void 0!==l&&l,background:C.background,enableHover:!1},dt=t.createElement("div",{key:"minimap",style:{position:"relative",width:h}},t.createElement(kt,Object.assign({ref:V},ut)),t.createElement(Ot,{width:h-st.left-st.right,height:it,margin:st,scales:G,brushDirection:at,extent:R,onBrush:H})),ft=t.createElement("div",{key:"main"},t.createElement(kt,Object.assign({},ht)));return t.createElement("div",{className:"minimap-chart"+(f?" "+f:"")},B?dt:ft,B?ft:dt)}Dt.displayName="MinimapChart";const jt=({xy:e,orient:n,i:o,className:r="",jaggedBase:i})=>{let s=`M${e.x1},${e.y1}L${e.x2},${e.y2}`;return i&&0===o&&(s=((t,e)=>{let n="";const{x1:o,x2:r,y1:i,y2:s}=e;if("left"===t||"right"===t){const e=Math.abs(r-o);n=((t,e,n,o)=>{const r=t/e;let i=0,s="M0,"+n;const a="right"===o?-1:1;for(;t>=i;)s+=`L${i},${n}`,t>i&&(s+=`L${i+r/2},${n+10*a}`),i+=r;return s})(e,Math.ceil(e/40),"right"===t?0:i,t)}else{const e=Math.abs(s-i);n=((t,e,n,o)=>{const r=t/e;let i=0,s=`M${n},0`;const a="bottom"===o?-1:1;for(;t>=i;)s+=`L${n},${i}`,t>i&&(s+=`L${n+10*a},${i+r/2}`),i+=r;return s})(e,Math.ceil(e/40),o,t)}return n})(n,e)),t.createElement("path",{key:o,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:s,className:`tick-line tick ${n} ${r}`})};function Tt(t,e,n){const o=Math.abs(n.range()[1]-n.range()[0]);return t||(e||(e=Math.max(1,Math.floor(o/40))),t=n.ticks&&n.ticks(e)||n.domain()),t}function zt({t:t,o:e,w:n}){return"contour"!==t&&"boxplot"!==t||"left"!==e&&"right"!==e?0:n/2}function Ct({t:t,o:e,w:n}){return"contour"!==t&&"boxplot"!==t||"top"!==e&&"bottom"!==e?0:n/2}function Bt(t){const{translation:n,orient:o,decoratedSummaryType:r,summaryWidth:i,renderedSummary:s,points:a}=t;return e.createElement("g",{className:"marginal-graphics",transform:`translate(${n[o]})`},e.createElement("g",{transform:`translate(${zt({t:r.type,o:o,w:i})},${Ct({t:r.type,o:o,w:i})})`},s),a)}function Wt(t){const{className:n,translation:o,position:r,rotation:i,labelName:s,anchorMod:a}=t;return e.createElement("g",{className:"axis-title "+n,transform:`translate(${[o[0]+r[0],o[1]+r[1]]}) rotate(${i})`},e.isValidElement(s)?s:e.createElement("text",{textAnchor:a},s))}function Ft(t){if(null==t)return"";if("number"!=typeof t)return t+"";if(!isFinite(t))return t+"";if(0===t)return"0";const e=parseFloat(t.toPrecision(12)),n=Math.abs(e);return 1e9>n?1e6>n?1e4>n?Number.isInteger(e)?e+"":parseFloat(e.toPrecision(6))+"":parseFloat((e/1e3).toPrecision(3))+"K":parseFloat((e/1e6).toPrecision(3))+"M":parseFloat((e/1e9).toPrecision(3))+"B"}function Lt(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;function Yt(e){const{rotate:n,label:o,dynamicLabelPosition:s,orient:l="left",marginalSummaryType:c,tickFormat:h=(c?()=>"":Ft),size:u,width:d=u&&u[0]||0,height:f=u&&u[1]||0,className:p,padding:y,tickValues:m,scale:g,ticks:x,footer:b,tickSize:v,tickLineGenerator:k,baseline:E=!0,margin:w={top:0,bottom:0,left:0,right:0},center:M=!1,annotationFunction:A,glyphFunction:S,xyPoints:$}=e,[P,N]=i(0),[_,O]=i(void 0),D=r(null);a(()=>{if(!(null==o?void 0:o.position)&&s){const t=((t,e)=>{const n=t.current;if(!n)return 30;const o="left"===e||"right"===e?"width":"height";return Math.max(...[...n.querySelectorAll(".axis-label")].map(t=>t.getBBox&&t.getBBox()||{height:30,width:30}).map(t=>t[o]))+25})(D,l);t!==_&&O(t)}},[o,s]);let j,{axisParts:T,position:z=[0,0]}=e;if(T||(T=function({renderMode:t=()=>{},padding:e=5,scale:n,ticks:o,tickValues:r=Tt(void 0,o,n),orient:i="left",size:s,footer:a=!1,tickSize:l=(a?-10:["top","bottom"].find(t=>t===i)?s?s[1]:0:s?s[0]:0),jaggedBase:c}){let h,u,d,f,p,y,m=[],g=0,x=0,b="middle";switch(i){case"top":h="x1",u="x2",d="y1",f="y2",m=[0,l],p="tx",y="ty",g-=20-e;break;case"bottom":h="x1",u="x2",d="y2",f="y1",m=s?[s[1],s[1]-l]:[0,-l],p="tx",y="ty",g+=20+e;break;case"right":h="y2",u="y1",d="x2",f="x1",m=s?[s[0],s[0]-l]:[0,-l],p="ty",y="tx",g+=5+e,x+=5,b="start";break;default:h="y1",u="y2",d="x1",f="x2",m=[0,l],p="ty",y="tx",g-=5+e,x+=5,b="end"}let v=r instanceof Function?r({orient:i}):r;return c&&void 0===v.find(t=>t===n.domain()[0])&&(v=[n.domain()[0],...v]),v.map((e,o)=>{const r=n(e);return{[h]:r,[u]:r,[d]:m[0],[f]:m[1],[p]:r+x,[y]:m[0]+g,defaultAnchor:b,renderMode:t(e,o),value:e}})}({padding:y,tickValues:m,scale:g,ticks:x,orient:l,size:[d,f],footer:b,tickSize:v}),j=t.createElement("g",{className:"axis "+p},(({axisParts:e,orient:n,tickLineGenerator:o=jt,className:r,jaggedBase:i,scale:s,showOutboundTickLines:a=!1})=>{const l=e.map((t,e)=>o({xy:t,orient:n,i:e,className:r,jaggedBase:i,scale:s})),c=a?e.map((e,o)=>(({xy:e,orient:n,i:o,className:r=""})=>{let i=`M-4,${e.y1}L${e.x1},${e.y2}`;return"left"===n?i=`M${e.x1-8},${e.y1}L${e.x1},${e.y2}`:"right"===n?i=`M${e.x2},${e.y1}L${e.x2+8},${e.y2}`:"top"===n?i=`M${e.x1},${e.y1-8}L${e.x1},${e.y1}`:"bottom"===n&&(i=`M${e.x1},${e.y2}L${e.x1},${e.y2+8}`),t.createElement("path",{key:o,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:i,className:`outbound-tick-line tick ${n} ${r}`})})({xy:e,orient:n,i:o,className:r})):[];return[...l,c]})({axisParts:T,orient:l,tickLineGenerator:k,className:p,scale:g}))),0===T.length)return null;let C,B,W,F,L=50,Y=f,I=-50,X=0,R=0,H=0,V=0,G=f,q=25,J=-25,K=18,Z=d+25,U=0,Q=P,tt=0,et="y";switch(l){case"right":z=[z[0],z[1]],I=d,V=R=d,tt=w.top,Z=-d-25,J=5,C=t=>{N(t.nativeEvent.offsetY-tt)},!0===M&&(V=R=d/2);break;case"top":z=[z[0],0],L=d,Y=50,X=-50,I=0,tt=w.left,et="x",V=d,G=0,!0===M&&(G=H=f/2),C=t=>{N(t.nativeEvent.offsetX-tt)},q=P,Q=25,J=0,K=-10,Z=0,U=f+25;break;case"bottom":z=[z[0],0],L=d,Y=50,H=G=X=f,R=I=0,V=d,tt=w.left,C=t=>{N(t.nativeEvent.offsetX-tt)},q=P,Q=25,J=0,K=15,Z=0,U=-f-25,et="x",!0===M&&(G=H=f/2);break;default:z=[z[0],z[1]],tt=w.top,!0===M&&(V=R=d/2),C=t=>{N(t.nativeEvent.offsetY-tt)}}if(A){const n=function(t,e){return e.tickFormat?e.tickFormat(t):t.toString?""+t:t}(g.invert(P),e),o=S?S({lineHeight:U,lineWidth:Z,value:g.invert(P)}):t.createElement("g",null,t.isValidElement(n)?t.createElement("g",{transform:`translate(${J},${K})`},n):t.createElement("text",{x:J,y:K},n),t.createElement("circle",{r:5}),t.createElement("line",{x1:Z,y1:U,style:{stroke:"black"}})),r=P?t.createElement("g",{style:{pointerEvents:"none"},transform:`translate(${q},${Q})`},o):null;B=t.createElement("g",{className:"annotation-brush",transform:`translate(${I},${X})`},t.createElement("rect",{style:{fillOpacity:0},height:Y,width:L,onMouseMove:C,onClick:t=>A({className:"dynamic-axis-annotation",type:et,value:g.invert(P),e:t}),onMouseOut:()=>{N(void 0)}}),r)}if(c&&$){const e=Math.max(w[l]-6,5),n="string"==typeof c?{type:c}:c;void 0!==n.flip||"bottom"!==l&&"right"!==l||(n.flip=!0);const o=n.summaryStyle?()=>n.summaryStyle:()=>({fill:"black",fillOpacity:.5,stroke:"black",strokeDasharray:"0"}),r=n.renderMode?()=>n.renderMode:()=>{},i=n.summaryClass?()=>n.summaryClass:()=>"",s=n.filter||(()=>!0),a=$.filter(t=>void 0!==t.x&&void 0!==t.y&&s(t.data)).map(t=>Object.assign(Object.assign({},t),{xy:{x:"top"===l||"bottom"===l?g(t.x):0,y:"left"===l||"right"===l?g(t.y):0},piece:{scaledVerticalValue:g(t.y),scaledValue:g(t.x)},value:g("top"===l||"bottom"===l?t.y:t.x),scaledValue:g(t.x),scaledVerticalValue:g(t.y)})),h=function(e){const n=[];for(const o of e){const e=[],{elements:r,containerProps:i}=o;if(o.Mark)n.push(o.Mark);else{for(let n=0;r.length>n;n++){const o=r[n],{markType:i,style:s={}}=o,a=Lt(o,["markType","style"]),l=Object.assign({},a);void 0!==s.fill&&(l.fill=s.fill),void 0!==s.stroke&&(l.stroke=s.stroke),void 0!==s.strokeWidth&&(l.strokeWidth=s.strokeWidth),void 0!==s.opacity&&(l.opacity=s.opacity),void 0!==s.fillOpacity&&(l.fillOpacity=s.fillOpacity),void 0!==s.strokeOpacity&&(l.strokeOpacity=s.strokeOpacity);const c=Object.assign({},s);delete c.fill,delete c.stroke,delete c.strokeWidth,delete c.opacity,delete c.fillOpacity,delete c.strokeOpacity,Object.keys(c).length>0&&(l.style=c),l.key=o.key||n,i&&e.push(t.createElement(i,l))}i?n.push(t.createElement("g",Object.assign({},i),e)):n.push(...e)}}return n}((({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:i,projection:s,adjustedSize:a,margin:l,axisCreator:c})=>{if(e&&e.type)return function({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:l,margin:c,axisCreator:h}){return"function"==typeof e.type?e.type({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:l,margin:c,axisCreator:h}):(console.error(`Invalid summary type: ${e.type} - Must be a function`),{})}({data:t,type:e="string"==typeof e?{type:e}:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:"vertical"===s?a[1]:a[0],margin:l,axisCreator:c})})({data:{column:{middle:e/2,pieceData:a,width:e,xyData:a}},type:n,renderMode:r,eventListenersGenerator:n.eventListenersGenerator||(()=>({})),styleFn:o,classFn:i,projection:"top"===l||"bottom"===l?"horizontal":"vertical",adjustedSize:u,margin:{top:0,bottom:0,left:0,right:0}}).marks);let d;if(!0===n.showPoints){const o=((t,e,n)=>{const o="left"===t||"right"===t?e/2:0,r="bottom"===t||"top"===t?e/2:0;return n.map(t=>[t.xy.x+o,t.xy.y+r])})(l,e,a);d=o.map((e,o)=>t.createElement("circle",{key:"axis-summary-point-"+o,cx:e[0],cy:e[1],r:n.r||3,style:n.pointStyle||{fill:"black",fillOpacity:.1}}))}W=t.createElement(Bt,{translation:{left:[2-w.left,0],right:[u[0]+2,0],top:[0,2-w.top],bottom:[0,u[1]+2]},orient:l,decoratedSummaryType:n,summaryWidth:e,renderedSummary:h,points:d})}const nt=(({axisParts:e,tickFormat:n,rotate:o=0,center:r=!1,orient:i})=>{const s=e.map((t,e)=>({axisPart:t,i:e,formatted:n(t.value,e)})),a="left"===i||"right"===i;let l=s;if(!o&&s.length>1){const t=8,e=14,n=8,o=t=>"string"==typeof t?t:"number"==typeof t?t+"":null;if("top"===i||"bottom"===i){const e=[...s].sort((t,e)=>t.axisPart.tx-e.axisPart.tx);let r=-1/0;const i=new Set;for(const s of e){const e=o(s.formatted);if(!e){i.add(s.i);continue}const a=e.length*t/2;r+n>s.axisPart.tx-a||(i.add(s.i),r=s.axisPart.tx+a)}l=s.filter(t=>i.has(t.i))}else if(a){const t=[...s].sort((t,e)=>t.axisPart.ty-e.axisPart.ty);let o=-1/0;const r=new Set;for(const i of t)o+e+n>i.axisPart.ty||(r.add(i.i),o=i.axisPart.ty);l=s.filter(t=>r.has(t.i))}}return l.map(({axisPart:e,i:n,formatted:s})=>{("object"!=typeof s||s instanceof Date)&&(s=t.createElement("text",{textAnchor:e.defaultAnchor,className:"axis-label"},s.toString?""+s:s));let a=e.tx,l=e.ty;if(r)switch(i){case"right":a-=(e.x2-e.x1)/2;break;case"left":a+=(e.x2-e.x1)/2;break;case"top":l+=(e.y2-e.y1)/2;break;case"bottom":l-=(e.y2-e.y1)/2}return t.createElement("g",{key:n,pointerEvents:"none",transform:`translate(${a},${l}) rotate(${o})`,className:"axis-label"},s)})})({tickFormat:h,axisParts:T,orient:l,rotate:n,center:M});if(o){const e=o.name||o,n=o.position||{};let r=n.anchor||"middle";const i=o.locationDistance||_,s=n.rotation||{left:-90,right:90,top:0,bottom:0}[l],a={left:{start:[0,u[1]],middle:[0,u[1]/2],end:[0,0],inside:[i||15,0],outside:[-(i||45),0]},right:{start:[u[0]+0,u[1]],middle:[u[0]+0,u[1]/2],end:[u[0]+0,0],inside:[-(i||15),0],outside:[i||45,0]},top:{start:[0,0],middle:[0+u[0]/2,0],end:[0+u[0],0],inside:[0,i||15],outside:[0,-(i||40)]},bottom:{start:[0,u[1]],middle:[0+u[0]/2,u[1]],end:[0+u[0],u[1]],inside:[0,-(i||5)],outside:[0,i||50]}},c=a[l][r],h=a[l][n.location||"outside"];c[0]=c[0]+h[0],c[1]=c[1]+h[1],"start"===r&&"right"===l?r="end":"end"===r&&"right"===l&&(r="start"),F=t.createElement(Wt,{className:p,translation:c,position:z,rotation:s,labelName:e,anchorMod:r})}const ot=`${l} axis ${T&&T.length>0&&`from ${h(T[0].value,0)} to ${h(T[T.length-1].value,T.length-1)}`||"without ticks"}`;return t.createElement("g",{className:p,"aria-label":ot,ref:D},B,nt,j,!0===E?t.createElement("line",{key:"baseline",className:"axis-baseline "+p,stroke:"black",strokeLinecap:"square",x1:R,x2:V,y1:H,y2:G}):null,F,W)}function It(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),r=t.split(/\s+/),i=[];let s="";for(const t of r)s&&s.length+1+t.length>o?(i.push(s),s=t):s=s?`${s} ${t}`:t;return s&&i.push(s),i}function Xt(t,e,n,o){return"curly"===t?o?`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`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Rt(e){const{x:n=0,y:o=0,dx:r,dy:i,nx:s,ny:a,note:l,connector:c,subject:h,type:u,color:d,className:f,disable:p,events:y={},"data-testid":m}=e,g=new Set(Array.isArray(p)?p:[]);let x=r||0,b=i||0;null!=s&&(x=s-n),null!=a&&(b=a-o);const v="string"==typeof u?u:"label";if("bracket"===v&&h&&0===x&&0===b)if(void 0!==h.width){x=h.width/2;const t=h.depth||30;b=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;x=t+(0>t?-5:5),b=h.height/2}return t.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":m},y),!g.has("connector")&&function(e,n,o,r,i,s){const a=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==s?void 0:s.radius)){if("callout-rect"===i&&s){const t=s.width||0,o=s.height||0;if(t>0||o>0){const r=t/2,i=o/2,s=e-r,a=n-i;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),h=t/2,u=o/2,d=e*u>n*h?h/e:u/n;l=r+s*d,c=i+a*d}}}else if("bracket"===i&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(l=t/2,c=n):void 0!==e&&(l=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const o=Math.atan2(n,e);l=Math.cos(o)*t,c=Math.sin(o)*t}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(n-c,2))>.5&&(a.push(t.createElement("line",{key:"connector-line",x1:l,y1:c,x2:e,y2:n,stroke:r||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,s=Math.atan2(n-c,e-l);a.push(t.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(s+i)},${c+o*Math.sin(s+i)}L${l+o*Math.cos(s-i)},${c+o*Math.sin(s-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},a)}(x,b,c,d,v,h),!g.has("subject")&&function(e,n,o,r,i){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(e>0||r>0)&&a.push(t.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=r||0,s=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-e;a.push(t.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-s,x2:r,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-s;a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:r,x2:(n.x2||0)-e,y2:r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&a.push(t.createElement("path",{key:"bracket-path",d:Xt((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:o||"currentColor"}));break}}return t.createElement("g",{className:"annotation-subject"},a)}(v,h,d,n,o),!g.has("note")&&function(e,n,o,r){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:i,title:s,orientation:a,align:l,wrap:c=120,noWrap:h}=e;if(!i&&!s)return t.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===u?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const p=16,y=s?h?[s]:It(s,c):[],m=i?h?[i]:It(i,c):[],g="leftRight"===u?"end"===f?-4:4:0;let x=0;const b=[];y.length>0&&(b.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:f,fontWeight:"bold"},y.map((e,n)=>t.createElement("tspan",{key:n,x:g,dy:0===n?0:p},e)))),x=y.length*p),m.length>0&&b.push(t.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:f,y:x},m.map((e,n)=>t.createElement("tspan",{key:n,x:g,dy:p},e))));let v=null;if((s||i)&&(0!==n||0!==o))if("topBottom"===u){const e=Math.min(c,120);let n=0,o=e;"end"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),v=t.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"currentColor"})}else{const e=(y.length+m.length)*p+(m.length>0?p:0);let n=0,o=e;"bottom"===d?(n=-e,o=0):"middle"===d&&(n=-e/2,o=e/2),v=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"currentColor"})}const k=(y.length+m.length)*p+(m.length>0?p:0);let E=0;return"topBottom"===u?0>o&&(E=-k):"leftRight"===u&&("middle"===d?E=-k/2:("bottom"===d||0>o)&&(E=-k)),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},t.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},b),v)}(l,x,b,d))}function Ht(e){const{noteData:n}=e,{screenCoordinates:o}=n,r="string"==typeof n.type?n.type:"label",i=n.eventListeners||n.events||{};if(n.coordinates&&o){const e=n.nx||o[0][0]+n.dx,i=n.ny||o[0][1]+n.dy,s=o.map((o,s)=>{const a=Object.assign({},n,{note:0===s?n.note:{label:""},x:o[0],y:o[1],nx:e,ny:i});return t.createElement(Rt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+s},a,{type:r}))});return t.createElement("g",null,s)}const s=n.note||{title:"none",label:n.label};return t.createElement(Rt,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${n.i}`,events:i},n,{type:r}))}const Vt=(t,e,n,o)=>{const r=(t.note.label||t.note.title).length;return[Math.min(t.note.wrap||120,r*e)+2*o,Math.ceil(r*e/120)*n+2*o]};function Gt(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)}}}let[qt,Jt]=function(e){let o=c(null),r=Gt(e);return[function({children:r}){let i=n(()=>Gt(e),[]);return t.createElement(o.Provider,{value:i,children:r})},t=>{var e;let n=null!==(e=h(o))&&void 0!==e?e:r;return function(t,e){const[n,o]=i(e);return u(()=>t(()=>o(e)),[t]),n}(n.subscribe,()=>t(n.getState()))}]}(t=>({tooltip:null,changeTooltip(e){t(()=>({tooltip:e}))}}));function Kt(t,e,n){return"number"==typeof n?n:e&&e.find(e=>e.props.orient===t)?50:10}const Zt=(t,e,n)=>`${t.map(Ut).join(",")}${JSON.stringify(e)}${n.join(",")}`;function Ut(t){if(!t||!t.props||!t.props.noteData)return"";const{note:e={}}=t.props.noteData,{label:n,title:o}=e;return`${t.props.noteData.id||`${t.props.noteData.x}-${t.props.noteData.y}`}-${n}=${o}`}function Qt(t,n=8,o){const{noteWidth:r=o}=t;let i=r;"number"==typeof r&&(i=()=>r);const s=t.note&&t.note.wrap||120,a=t.note.label||t.note.label||"";return r&&i(t)||(e.isValidElement(t.note)?100:Math.min(s,a.length*n))}function te(t,n=8,o=20,r){const{noteHeight:i=r}=t;let s=i;"number"==typeof i&&(s=()=>i);const a=t.note&&t.note.wrap||120,l=t.note.label||t.note.title||"";return i&&s(t)||(e.isValidElement(t.note)?30:Math.ceil(l.length*n/a)*o+(t.note.label&&t.note.title?o:0))}const ee=(t,e)=>e.map((e,n)=>t.svgAnnotationRule(e,n,t)).filter(t=>null!=t),ne=(e,n)=>{let o=n.adjustedAnnotations,r=n.adjustedAnnotationsKey,i=n.adjustableAnnotations,s=n.fixedAnnotations,a=[],l=[];const c=n.adjustedAnnotationsKey,h=n.adjustedAnnotationsDataVersion,{annotations:u,annotationHandling:d=!1,size:f,svgAnnotationRule:p,htmlAnnotationRule:y}=e,m="object"==typeof d?d:{layout:{type:d},dataVersion:""},{dataVersion:g=""}=m;if(p){const n=ee(e,u);r=Zt(n,m,f),!1===d&&(o=i),o=o.length!==i.length||c!==r||h!==g?((e,n,o)=>{const{layout:r={type:!1,noteHeight:void 0,noteWidth:void 0}}=n;if(!1===r.type)return e;const{noteWidth:i,noteHeight:s}=r;let{margin:a={top:0,bottom:0,left:0,right:0}}=o;const{size:l,axes:c=[]}=o;if(a="number"==typeof a?{top:a,left:a,right:a,bottom:a}:a,"bump"===r.type)return function(t,e,n,o,r){const{padding:i=1,characterWidth:s=8,lineHeight:a=20,iterations:l=500,pointSizeFunction:c=o,labelSizeFunction:h=r||Vt}=e,u=t.map((t,e)=>{const n=(t.props.noteData.x[0]||t.props.noteData.x)+(void 0!==t.props.noteData.dx?t.props.noteData.dx:-10*(e%3-1)),o=(t.props.noteData.y[0]||t.props.noteData.y)+(void 0!==t.props.noteData.dy?t.props.noteData.dy:10*(e%3-1)),[r,l]=h(t.props.noteData,s,a,i);return{x:n,y:o,above:t.props.noteData.y>o,left:t.props.noteData.x>n,width:r,height:l,type:"label",name:"",originalNote:t}}),d=t.map(t=>({x:t.props.noteData.x,y:t.props.noteData.y,fx:t.props.noteData.x,fy:t.props.noteData.y,r:c&&c(t.props.noteData)||5,type:"point",originalNote:t})),f=function(){let t,e=[],n=[],o=1,r=1,i={start:t=>{},width:t=>{},height:t=>{},label:t=>{},anchor:t=>{},alt_energy:t=>{},alt_schedule:t=>{}},s=!1;const a=function(t){let o=e.length,r=0,i=e[t].x-n[t].x,s=n[t].y-e[t].y,a=Math.sqrt(i*i+s*s);a>0&&(r+=.2*a),i/=a,s/=a,r+=i>0&&s>0?0:0>i&&s>0?3:0>i&&0>s?6:9;let l,c,u,d,f,p,y,m=e[t].x,g=e[t].y-e[t].height+2,x=e[t].x+e[t].width,b=e[t].y+2;for(let i=0;o>i;i++)i!==t&&(h(n[t].x,e[t].x,n[i].x,e[i].x,n[t].y,e[t].y,n[i].y,e[i].y)&&(r+=1),l=e[i].x,u=e[i].y-e[i].height+2,c=e[i].x+e[i].width,d=e[i].y+2,f=Math.max(0,Math.min(c,x)-Math.max(l,m)),p=Math.max(0,Math.min(d,b)-Math.max(u,g)),y=f*p,r+=30*y),l=n[i].x-n[i].r,u=n[i].y-n[i].r,c=n[i].x+n[i].r,d=n[i].y+n[i].r,f=Math.max(0,Math.min(c,x)-Math.max(l,m)),p=Math.max(0,Math.min(d,b)-Math.max(u,g)),y=f*p,r+=30*y;return r},l=function(i){let l,c,h=Math.floor(Math.random()*e.length),u=e[h].x,d=e[h].y;l=s?t(h,e,n):a(h),e[h].x+=5*(Math.random()-.5),e[h].y+=5*(Math.random()-.5),e[h].x>o&&(e[h].x=u),0>e[h].x&&(e[h].x=u),e[h].y>r&&(e[h].y=d),0>e[h].y&&(e[h].y=d),c=s?t(h,e,n):a(h);let f=c-l;Math.random()<Math.exp(-f/i)||(e[h].x=u,e[h].y=d)},c=function(i){let l,c=Math.floor(Math.random()*e.length),h=e[c].x,u=e[c].y;l=s?t(c,e,n):a(c);let d=.5*(Math.random()-.5),f=Math.sin(d),p=Math.cos(d);e[c].x-=n[c].x,e[c].y-=n[c].y;let y,m=e[c].x*f+e[c].y*p;e[c].x=e[c].x*p-e[c].y*f+n[c].x,e[c].y=m+n[c].y,e[c].x>o&&(e[c].x=h),0>e[c].x&&(e[c].x=h),e[c].y>r&&(e[c].y=u),0>e[c].y&&(e[c].y=u),y=s?t(c,e,n):a(c);let g=y-l;Math.random()<Math.exp(-g/i)||(e[c].x=h,e[c].y=u)},h=function(t,e,n,o,r,i,s,a){let l,c,h,u,d;return h=(a-s)*(e-t)-(o-n)*(i-r),u=(o-n)*(r-s)-(a-s)*(t-n),d=(e-t)*(r-s)-(i-r)*(t-n),l=u/h,c=d/h,!(0>l||l>1||0>c||c>1)},u=function(t,e,n){return t-e/n};return i.start=function(t){let n=e.length,o=1;for(let e=0;t>e;e++){for(let t=0;n>t;t++).5>Math.random()?l(o):c(o);o=u(o,1,t)}},i.width=function(t){return arguments.length?(o=t,i):o},i.height=function(t){return arguments.length?(r=t,i):r},i.label=function(t){return arguments.length?(e=t,i):e},i.anchor=function(t){return arguments.length?(n=t,i):n},i.alt_energy=function(e){return arguments.length?(t=e,s=!0,i):a},i.alt_schedule=function(t){return arguments.length?i:u},i}();return f.label(u),f.anchor(d),f.width(n[0]),f.height(n[1]),f.start(l),u.forEach(t=>{if("label"===t.type){const e=function(t,e,n){return t.y>e.y?[e.x+e.width/2+n/2,e.y-e.height+n/2]:[e.x+e.width/2,e.y]}(t.originalNote.props.noteData,t,i);t.originalNote.props.noteData.nx=e[0],t.originalNote.props.noteData.ny=e[1]}}),t}(e,r,l,o.pointSizeFunction,o.labelSizeFunction);if("marginalia"===r.type){const{marginOffset:n,orient:o="nearest",characterWidth:h=8,lineHeight:u=20,padding:d=2,axisMarginOverride:f={}}=r,p="nearest"===o?["left","right","top","bottom"]:Array.isArray(o)?o:[o],y=p.find(t=>"left"===t),m=p.find(t=>"right"===t),g=p.find(t=>"top"===t),x=p.find(t=>"bottom"===t),b=[],v=[],k=[],E=[];for(const t of e){const e=t.props.noteData,n=e.x[0]||e.x,o=e.y[0]||e.y,r=y?n:1/0,i=m?l[0]-n:1/0,s=g?o:1/0,a=Math.min(r,i,s,x?l[1]-o:1/0);r===a?b.push(t):i===a?v.push(t):s===a?k.push(t):E.push(t)}const w=new _.Force({minPos:void 0!==f.top?0+f.top:0-a.top,maxPos:void 0!==f.bottom?l[1]-f.bottom:x?l[1]:l[1]+a.bottom}).nodes(b.map(t=>new _.Node(t.props.noteData.y[0]||t.props.noteData.y,te(t.props.noteData,h,u,i)+d))).compute(),M=new _.Force({minPos:void 0!==f.top?0+f.top:g?0:0-a.top,maxPos:void 0!==f.bottom?l[1]-f.bottom:l[1]+a.bottom}).nodes(v.map(t=>new _.Node(t.props.noteData.y[0]||t.props.noteData.y,te(t.props.noteData,h,u,i)+d))).compute(),A=new _.Force({minPos:void 0!==f.left?0+f.left:y?0:0-a.left,maxPos:void 0!==f.right?l[0]-f.right:l[0]+a.right}).nodes(k.map(t=>new _.Node(t.props.noteData.x[0]||t.props.noteData.x,Qt(t.props.noteData,h,s)+d))).compute(),S=new _.Force({minPos:void 0!==f.left?0+f.left:0-a.left,maxPos:void 0!==f.right?l[0]-f.right:m?l[0]:l[0]+a.right}).nodes(E.map(t=>new _.Node(t.props.noteData.x[0]||t.props.noteData.x,Qt(t.props.noteData,h,s)+d))).compute(),$=Math.max(...E.map(t=>te(t.props.noteData,h,u,i)+d)),P=Math.max(...k.map(t=>te(t.props.noteData,h,u,i)+d)),N=Math.max(...b.map(t=>Qt(t.props.noteData,h,s)+d)),O=Math.max(...v.map(t=>Qt(t.props.noteData,h,s)+d)),D=w.nodes(),j=M.nodes(),T=A.nodes(),z=S.nodes();return b.forEach((e,o)=>{const r=0-D[o].layerIndex*N-Kt("left",c,n),i=D[o].currentPos;e.props.noteData.nx=r,e.props.noteData.ny=i,e.props.noteData.note&&!t.isValidElement(e)&&(e.props.noteData.note.orientation=e.props.noteData.note.orientation||"leftRight",e.props.noteData.note.align=e.props.noteData.note.align||"right")}),v.forEach((e,o)=>{const r=l[0]+j[o].layerIndex*O+Kt("right",c,n),i=j[o].currentPos;e.props.noteData.nx=r,e.props.noteData.ny=i,e.props.noteData.note&&!t.isValidElement(e)&&(e.props.noteData.note.orientation=e.props.noteData.note.orientation||"leftRight",e.props.noteData.note.align=e.props.noteData.note.align||"left")}),k.forEach((t,e)=>{const o=T[e].currentPos,r=0-T[e].layerIndex*P-Kt("top",c,n);t.props.noteData.nx=o,t.props.noteData.ny=r}),E.forEach((t,e)=>{const o=z[e].currentPos,r=l[1]+z[e].layerIndex*$+Kt("bottom",c,n);t.props.noteData.nx=o,t.props.noteData.ny=r}),e}return e})(i,m,e):i.map((e,n)=>{const r=Object.assign(Object.assign({},o[n].props.noteData),e.props.noteData);return t.createElement(Ht,{key:e.key,noteData:r})}),a=[...o,...s]}return y&&(l=((t,e)=>e.map((e,n)=>t.htmlAnnotationRule(e,n,t)).filter(t=>null!=t))(e,u)),{svgAnnotations:a,htmlAnnotations:l,adjustedAnnotations:o,adjustedAnnotationsKey:r,adjustedAnnotationsDataVersion:g}};function oe(e){const{legendSettings:n,margin:o,size:r,annotations:s,annotationHandling:l}=e,c=Jt(t=>t.tooltip);let h=null!=c?s.concat(c):s,u=Jt(t=>t.changeTooltip);const d=Object.assign(Object.assign({},e),{annotations:h,voronoiHover:t=>{u(t)}}),f="object"==typeof l?l:{layout:{type:l},dataVersion:""},{dataVersion:p=""}=f,[y,m]=i([]),[g,x]=i([]),[b,v]=i([]),[k,E]=i(""),[w,M]=i(p),A=ee(d,h),S=A.filter(t=>t.props&&t.props.noteData&&!t.props.noteData.fixedPosition),$=Zt(S,f,r);let P;if(a(()=>{const t=A.filter(t=>!t.props||!t.props.noteData||t.props.noteData.fixedPosition),e=ne(d,{adjustedAnnotations:y,adjustedAnnotationsKey:k,adjustedAnnotationsDataVersion:w,adjustableAnnotations:S,fixedAnnotations:t});m(e.adjustedAnnotations),E(e.adjustedAnnotationsKey),M(e.adjustedAnnotationsDataVersion),x(e.svgAnnotations),v(e.htmlAnnotations)},[$,p,h.length,h.map(t=>function(t){const e=new Set;return JSON.stringify(t,(t,n)=>e.has(n)?"...":"object"==typeof n?(e.add(n),"note"===t?`${n.label}-${n.title}`:"connector"===t?`${n.end}-${n.type}`:"subject"===t?""+n.radius:"object"==typeof n.column?`${n.column.x}-${n.column.y}-${n.column.name}`:n.voronoiX||n.voronoiY||n.x||n.y||n.dx||n.dy||n.label||n.type||n.key||n.hierarchicalID||n.id||n.name?`${n.voronoiX}-${n.voronoiY}-${n.dx}-${n.dy}-${n.x}-${n.y}-${n.label}-${n.type}-${n.key}-${n.hierarchicalID}-${n.id}-${n.name}`:"..."):n)}(t)).join("-")]),n){const e={left:[15,15],right:[r[0]+15,15]},{position:o="right",title:i="Legend"}=n;P=t.createElement("g",{transform:`translate(${e[o].join(",")})`},t.createElement(it,Object.assign({},n,{title:i,position:o})))}return 0!==h.length||n?t.createElement("div",{className:"annotation-layer",style:{position:"absolute",pointerEvents:"none",background:"none"}},t.createElement("svg",{className:"annotation-layer-svg",height:r[1],width:r[0],style:{background:"none",pointerEvents:"none",position:"absolute",left:o.left+"px",top:o.top+"px",overflow:"visible"}},t.createElement("g",null,P,g)),t.createElement("div",{className:"annotation-layer-html",style:{background:"none",pointerEvents:"none",position:"absolute",height:r[1]+"px",width:r[0]+"px",left:o.left+"px",top:o.top+"px"}},b)):null}const re=t=>t.reduce((t,e)=>t.concat(Array.isArray(e)?re(e.slice().sort((t,e)=>t-e)):e),[]);function ie(t=[]){if(!Array.isArray(t))return"not-array";let e=t.slice();return Array.isArray(e[0])||(e=e.slice().sort((t,e)=>t-e)),""+re(e).map(t=>t instanceof Date&&""+t||void 0!==t&&t.toFixed&&t.toFixed(2)||"empty")}function se(e){const{extent:n,selectedExtent:o}=e,i=r(null),s=ie(n),l=ie(o);a(()=>{(null==i?void 0:i.current)&&((t,e)=>{const{svgBrush:n,selectedExtent:o}=e;if(y(t).call(n),o){let e=o;if(Array.isArray(o[0])){const t=[e[0][1],e[1][1]].sort((t,e)=>t-e);e=[[e[0][0],t[0]],[e[1][0],t[1]]]}y(t).call(n.move,e)}})(i.current,e)},[s,l,i]);const{position:c=[0,0]}=e;return t.createElement("g",{transform:`translate(${c})`,ref:i,className:"xybrush"})}const ae=t=>t instanceof Date?t.getTime():t,le=({data:t,lineDataAccessor:e,xProp:n,xPropTop:o,xPropBottom:r,yProp:i,yPropTop:s,yPropBottom:a,xAccessor:l,yAccessor:c})=>{Array.isArray(t)||(t=[t]);const h=[];return e.forEach((e,u)=>{l.forEach((l,d)=>{c.forEach((c,f)=>{t.forEach(t=>{const p=Object.assign(Object.assign({},t),{xIndex:d,yIndex:f,lineIndex:u});p.data=e(t).map((t,e)=>{const h={data:t};return h[n]=l(t,e),h[o]=h[n],h[r]=h[n],h[i]=c(t,e),h[s]=h[i],h[a]=h[i],h}),p.key=p.key||h.length,h.push(p)})})})}),h},ce=({type:t="stackedarea",data:e,xProp:n,yProp:o,yPropMiddle:r,sort:i,yPropTop:s,yPropBottom:a})=>{const l=new Map,c=e.map(()=>0);let h=0;for(const t of e){t.__lineIndex=h;for(const e of t.data){const t=ae(e[n]);c[h]+=e[o],l.has(t)||l.set(t,[]),l.get(t)[h]=e}h++}let u=(t,e)=>c[e.key]-c[t.key];"stackedpercent-invert"!==t&&"stackedarea-invert"!==t||(u=(t,e)=>c[t.key]-c[e.key]),null!==(i=void 0===i?u:i)&&(e=e.sort(i));const d=e.map(t=>t.__lineIndex);for(const[,e]of l){let n=0,i=0;const l=b(e,t=>(null==t?void 0:t[o])>0?t[o]:0),c=b(e,t=>0>(null==t?void 0:t[o])?t[o]:0);for(const h of d){const u=e[h];if(u)if(0>u[o]){if("linepercent"===t||"stackedpercent"===t||"stackedpercent-invert"===t){const e=u[o]/c;if(u.percent=e,"linepercent"===t)u[a]=u[a]=u[s]=u[r]=e;else{const t=0>c?e:0;u[a]=0===c?0:-n/c,u[s]=u[a]-t,u[r]=u[a]-t/2}}else u[a]=n,u[s]=n+u[o],u[r]=n+u[o]/2;n+=u[o]}else{if("linepercent"===t||"stackedpercent"===t||"stackedpercent-invert"===t){const e=u[o]/l;if(u.percent=e,"linepercent"===t)u[a]=u[s]=u[r]=e;else{const t=l>0?e:0;u[a]=0===l?0:i/l,u[s]=u[a]+t,u[r]=u[a]+t/2}}else u[a]=i,u[s]=i+u[o],u[r]=i+u[o]/2;i+=u[o]}}}return e},he=({data:t,y1:e,x1:n,yPropTop:o,yPropMiddle:r,yPropBottom:i,xPropTop:s,xPropMiddle:a,xPropBottom:l})=>{if(e)for(const n of t)for(const t of n.data)t[i]=e(t),t[r]=t[o];if(n)for(const e of t)for(const t of e.data)t[l]=n(t),t[a]=(t[l]+t[s])/2;return t},ue=({data:t,y1:e,yPropTop:n,yPropMiddle:o,yPropBottom:r,type:i="cumulative"})=>{for(const s of t){let t=0;const a="cumulative-reverse"===i?s.data.reverse():s.data;for(const i of a)t+=i[n],i[r]=i[n]=i[o]=t,e&&(i[r]=e(i),i[o]=i[r]+i[n]/2)}return t},de=({type:t="bumpline",data:e,xProp:n,yProp:o,yPropMiddle:r,yPropTop:i,yPropBottom:s})=>{const a=new Map;for(const t of e)for(const e of t.data){const t=ae(e[n]);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=(t,e)=>t[o]>e[o]?1:-1;"bumparea-invert"!==t&&"bumpline-invert"!==t||(l=(t,e)=>e[o]>t[o]?1:-1);for(const[,e]of a){let n=0,a=0;e.sort(l);let c=1;for(const l of e)"bumparea"===t||"bumparea-invert"===t?0>l[o]?(l[i]=n+l[o],l[r]=n+l[o]/2,l[s]=n,n+=l[o]):(l[i]=a+l[o],l[r]=a+l[o]/2,l[s]=a,a+=l[o]):(l[o]=c,l[i]=c,l[s]=c),c++}return e};function fe({pointA:t,pointB:e,currentParameters:n,parameters:o,keys:r}){const i={};return r.forEach(n=>{i[n]="number"==typeof t[n]?(t[n]+e[n])/2:void 0}),JSON.stringify(o(i))===JSON.stringify(n)?[i,e]:[t,i]}function pe({data:t,steps:e,key:n}){const o=[];return Array.isArray(t)||(t=[t]),e||(e=t.map(t=>Object.keys(t)).reduce((t,e)=>t.concat(e),[])),t.forEach((t,r)=>{const i=n?t[n]:r;e.forEach(e=>{const n={funnelKey:i,stepName:"",stepValue:0};n.stepName=e,n.stepValue=t[e]?t[e]:0,o.push(n)})}),o}function ye(e){const n=(e=>{const{parameters:n,className:o,interpolate:r=D,customAccessors:i,lineDataAccessor:s,data:a,searchIterations:l}=e,c=Lt(e,["parameters","className","interpolate","customAccessors","lineDataAccessor","data","searchIterations"]),{x:h,y:u}=i,d=le({data:a,lineDataAccessor:[s],xProp:"x",yProp:"y",xAccessor:[h],yAccessor:[u]});for(const t of d)t.data=t.data.map(t=>Object.assign(Object.assign({},t.data),t));const f=((t,e,n=10)=>{let o=t(e[0],0),r=[];const i=[{key:o,points:r}];return e.forEach((e,s)=>{const a=t(e,s);let l=a===o;const c=JSON.stringify(a),h=JSON.stringify(o);if("object"==typeof o&&(l=c===h),l)r.push(e);else{let s=r[r.length-1],l=e,h=c,u=0;for(;n>u&&c===h;){const e=fe({pointA:s,pointB:l,currentParameters:o,parameters:t,keys:Object.keys(s)});s=e[0],l=e[1],h=JSON.stringify(t(l)),u++}r.push(l),r=[l,e],i.push({key:a,points:r}),o=a}}),i})(n,d[0].data,l),p=O().curve(r).x(t=>t.x).y(t=>t.y);return f.map((e,n)=>t.createElement("path",Object.assign({},c,{className:o,key:"DividedLine-"+n,style:e.key,d:p(e.points)})))})(e);return t.createElement("g",null,n)}const me="x",ge="y",xe="yMiddle",be="yTop",ve="yBottom",ke="xMiddle",Ee="xTop",we="xBottom";function Me({preprocess:e=!0,processedData:n=!1,summaryType:o,data:r,finalXExtent:i,finalYExtent:s,size:a,xScaleType:l=m(),yScaleType:c=m(),margin:h,styleFn:u,classFn:d,renderFn:f,chartSize:p}){let y=i,g=s;if(!y){const t=r.coordinates.map(t=>t.x);y=[Math.min(...t),Math.max(...t)]}if(!g){const t=r.coordinates.map(t=>t.y);g=[Math.min(...t),Math.max(...t)]}if(n&&r)return r.coordinates;let x,b=[];x=o.type?o:{type:x};const{bins:v=.05,cellPx:k,binValue:E=t=>t.length,binMax:w,customMark:M}=x;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(t=>[t.x,t.y]));const A=Array.isArray(r)?r:[r],S=l.domain(y).range([0,a[0]]),$=c.domain(g).range([0,a[1]]),P=k&&k/2||(v>1?1/v:v)*a[0]/2,N=C().x(t=>S(t._xyfPoint[0])).y(t=>$(t._xyfPoint[1])).radius(P).size(a);let _;const O=N.centers();return A.forEach(e=>{_=0;const n=N(e._xyfCoordinates.map((t,n)=>Object.assign({_xyfPoint:t},e.coordinates[n]))),o={};n.forEach(t=>{o[`${parseInt(t.x)}-${parseInt(t.y)}`]=!0}),O.forEach(t=>{if(!o[`${parseInt(t[0])}-${parseInt(t[1])}`]){const e=[];e.x=t[0],e.y=t[1],n.push(e)}}),_=Math.max(...n.map(t=>E(t))),w&&w(_);const r=[[0,-1],[.866,-.5],[.866,.5],[0,1],[-.866,.5],[-.866,-.5]],i=S.invert(P)-y[0],s=$.invert(P)-g[0],l=r.map(t=>[t[0]*i,t[1]*s]),c=n.map(n=>{const o=E(n),i=n.x,s=n.y;n.x=S.invert(n.x),n.y=$.invert(n.y);const c=o/_;return{customMark:M&&t.createElement("g",{transform:`translate(${i},${a[1]-s})`},M({d:Object.assign(Object.assign({},n),{binItems:n,percent:c,value:o,radius:P,hexCoordinates:r.map(t=>[t[0]*P,t[1]*P])}),margin:h,styleFn:u,classFn:d,renderFn:f,chartSize:p,adjustedSize:a})),_xyfCoordinates:l.map(t=>[t[0]+n.x,t[1]+n.y]),value:o,percent:c,data:n,parentSummary:e,centroid:!0}});b=[...b,...c]}),e?(b.forEach(t=>{t.x=t.data.x,t.y=t.data.y}),{type:"hexbin",processedData:!0,coordinates:b,binMax:_}):b}const Ae=(t,e,n,o)=>[...t.map((t,o)=>[t[0],t[1]+n(e[o])]),...t.map((t,n)=>[t[0],t[1]-o(e[n])]).reverse()];function Se({preprocess:e=!0,processedData:n=!1,summaryType:o,data:r,finalXExtent:i=[Math.min(...r.coordinates.map(t=>t.x)),Math.max(...r.coordinates.map(t=>t.x))],finalYExtent:s=[Math.min(...r.coordinates.map(t=>t.y)),Math.max(...r.coordinates.map(t=>t.y))],size:a,xScaleType:l=m(),yScaleType:c=m(),margin:h,styleFn:u,classFn:d,renderFn:f,chartSize:p}){if(n&&r)return r.coordinates;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(t=>[t.x,t.y]));const y=Array.isArray(r)?r:[r];let g,x=[];g=o.type?o:{type:g};const{binValue:b=t=>t.length,xBins:v=g.yBins||.05,yBins:k=v,xCellPx:E=!g.xBins&&g.xCellPx,yCellPx:w=!g.yBins&&g.yCellPx,customMark:M,binMax:A}=g,S=1>v?v:1/v,$=1>k?k:1/k,P=l.domain(i).range([0,a[0]]),N=c.domain(s).range([a[1],0]),_=[Math.ceil((E&&E/a[0]||S)*a[0]*10)/10,Math.ceil((w&&w/a[1]||$)*a[1]*10)/10];let O=-1/0;return y.forEach(e=>{const n=[],o=[];let r,i;for(let t=0;a[0]>Math.ceil(t);t+=_[0]){const s=P.invert(t),l=P.invert(t+_[0]);i=[],n.push(i);for(let n=0;a[1]>Math.ceil(n);n+=_[1]){const a=N.invert(n),c=N.invert(n+_[1]);r={gx:t,gy:n,gw:_[0],gh:_[1],x:(s+l)/2,y:(a+c)/2,binItems:[],value:0,_xyfCoordinates:[[s,a],[l,a],[l,c],[s,c]],parentSummary:e},i.push(r),o.push(r)}i.push(r)}n.push(i),e._xyfCoordinates.forEach((t,o)=>{const r=P(t[0]),i=N(t[1]),s=Math.floor(r/_[0]),a=Math.floor(i/_[1]);n[s][a]&&n[s][a].binItems.push(e.coordinates[o])}),o.forEach(t=>{t.value=b(t.binItems),O=Math.max(O,t.value)}),o.forEach(e=>{e.percent=e.value/O,e.customMark=M&&t.createElement("g",{transform:`translate(${e.gx},${e.gy})`},M({d:e,margin:h,styleFn:u,classFn:d,renderFn:f,chartSize:p,adjustedSize:a}))}),x=[...x,...o]}),A&&A(O),e?{type:"heatmap",processedData:!0,_baseData:[],_xyfCoordinates:[],data:[],bounds:[],x:0,y:0,coordinates:x,binMax:O}:x}const $e=t=>t&&t.extent||Array.isArray(t)&&t||[],Pe=()=>!0,Ne={top:be,bottom:ve,orphan:ge},_e={top:Ee,bottom:we,orphan:me},Oe={stackedarea:ce,"stackedarea-invert":ce,stackedpercent:ce,"stackedpercent-invert":ce,linepercent:ce,difference:({data:t,yProp:e,yPropTop:n,yPropBottom:o})=>(t.forEach((r,i)=>{r.data.forEach((r,s)=>{const a=0===i?1:0;r[e]>t[a].data[s][e]?(r[o]=t[a].data[s][e],r[n]=r[e]):(r[n]=r[e],r[o]=r[e])})}),t),bumparea:de,bumpline:de,"bumparea-invert":de,line:he,area:he,cumulative:ue,"cumulative-reverse":ue};function De(t,e){const n=[];for(const t of e)n.push(Object.assign({},t));for(const e of t)e.parentSummary||n.push(e);return n}const je=({lineDataAccessor:t,xAccessor:e,yAccessor:n,summaries:o,points:r,lines:i,lineType:s,showLinePoints:a,showSummaryPoints:l,xExtent:c,yExtent:h,invertX:u,invertY:d,summaryDataAccessor:f,summaryType:p,adjustedSize:y,margin:g,summaryStyleFn:x,summaryClassFn:b,summaryRenderModeFn:v,chartSize:k,filterRenderedLines:E,filterRenderedSummaries:w,filterRenderedPoints:M,defined:A=Pe,annotations:S=[]})=>{let $=[],P=[],N=[],_=[],O=[];if(r){e.forEach((t,e)=>{n.forEach((n,o)=>{let i=0;for(const s of r){const r=t(s,i),a=n(s,i),l={x:r,y:a,data:s,xIndex:e,yIndex:o};Array.isArray(a)&&(l[ve]=Math.min(...a),l[be]=Math.max(...a),l[xe]=(l[ve]+l[be])/2),Array.isArray(r)&&(l[we]=Math.min(...r),l[Ee]=Math.max(...r),l[ke]=(l[we]+l[Ee])/2),N.push(l),i++}})});for(const t of N)$.push(Object.assign(Object.assign({},t),{[me]:t[Ee]||t[we]||t.x,[ge]:t[be]||t[ve]||t.y}))}if(i){P=le({data:i,lineDataAccessor:t,xProp:me,xPropTop:Ee,xPropBottom:we,yProp:ge,yPropTop:be,yPropBottom:ve,xAccessor:e,yAccessor:n}),_=function(t,e){return n=>Oe[Te(t.type,n)](Object.assign(Object.assign(Object.assign({},t),e),{data:n}))}(s,{xProp:me,yProp:ge,yPropMiddle:xe,yPropTop:be,yPropBottom:ve,xPropMiddle:ke,xPropTop:Ee,xPropBottom:we})(P);for(const t of _)for(let e=0;t.data.length>e;e++){const n=t.data[e];if(!A(Object.assign({},n.data,n),e))continue;const o={parentLine:t,y:n.y,x:n.x,xTop:n.xTop,xMiddle:n.xMiddle,xBottom:n.xBottom,yTop:n.yTop,yMiddle:n.yMiddle,yBottom:n.yBottom,data:n.data};n.percent&&(o.percent=n.percent),$.push(o)}if(a){const t=!0===a?ke:_e[a],e=!0===a?xe:Ne[a];_.forEach(n=>{n.data.filter((t,e)=>{if(A(Object.assign({},t.data,t))){if("orphan"===a){const t=n.data[e-1],o=n.data[e+1];return!(t&&A(Object.assign({},t.data,t))||o&&A(Object.assign({},o.data,o)))}return!0}return!1}).forEach(o=>{N.push(Object.assign(Object.assign({},o),{parentLine:n,[ge]:void 0!==o[e]?o[e]:void 0!==o[xe]?o[xe]:void 0!==o[ve]?o[ve]:o.y,[me]:void 0!==o[t]?o[t]:void 0!==o[ke]?o[ke]:void 0!==o[we]?o[we]:o.y}))})})}}o&&(O=(({data:t,summaryDataAccessor:e,xAccessor:n,yAccessor:o})=>{const r=[];return e.forEach(e=>{n.forEach(n=>{o.forEach(o=>{const i=t=>e(t).map((t,e)=>[n(t,e),o(t,e)]);t.forEach(t=>{r.push(Object.assign(Object.assign({},t),{_baseData:e(t),_xyfCoordinates:i(t)}))})})})}),r})({data:o,summaryDataAccessor:f,xAccessor:e,yAccessor:n}),O.forEach(t=>{const e=t._baseData;t._xyfCoordinates.length>0&&t._xyfCoordinates[0][0][0]?t._xyfCoordinates[0].forEach(n=>{Array.isArray(n)&&n.map((n,o)=>Object.assign({parentSummary:t},e[o],{[me]:n[0],[ge]:n[1]})).forEach(t=>{l&&N.push(Object.assign(Object.assign({x:0},t),{[ge]:t[be]||t[ve]||t[ge]})),$.push(Object.assign({x:0,y:0},t))})}):t._xyfCoordinates.length>0&&Array.isArray(t._xyfCoordinates)&&t._xyfCoordinates.map((n,o)=>Object.assign(Object.assign({parentSummary:t},e[o]),{[me]:n[0],[ge]:n[1]})).forEach(t=>{l&&N.push(Object.assign(Object.assign({x:0},t),{[ge]:t[be]||t[ve]||t[ge]})),$.push(Object.assign({x:0,y:0},t))})}));let D,C,B,W,F=[],L=[];c&&!Array.isArray(c)&&!0===c.includeAnnotations&&e.forEach(t=>{S.forEach((e,n)=>{const o=t(e,n);isFinite(o)&&F.push({[me]:o})})}),h&&!Array.isArray(h)&&!0===h.includeAnnotations&&n.forEach(t=>{S.forEach((e,n)=>{const o=t(e,n);isFinite(o)&&L.push({[ge]:o})})});for(const t of $){const e=void 0===t[we]?t[me]:Math.min(t[Ee],t[we]),n=void 0===t[Ee]?t[me]:Math.max(t[we],t[Ee]),o=void 0===t[ve]?t[ge]:Math.min(t[be],t[ve]),r=void 0===t[be]?t[ge]:Math.max(t[ve],t[be]);void 0===e||void 0!==D&&e>=D||(D=e),void 0===n||void 0!==C&&C>=n||(C=n),void 0===o||void 0!==B&&o>=B||(B=o),void 0===r||void 0!==W&&W>=r||(W=r)}for(const t of F){const e=t[me];void 0===e||void 0!==D&&e>=D||(D=e),void 0===e||void 0!==C&&C>=e||(C=e)}for(const t of L){const e=t[ge];void 0===e||void 0!==B&&e>=B||(B=e),void 0===e||void 0!==W&&W>=e||(W=e)}const Y=[D,C],I=[B,W],X=$e(c),R=$e(h);let H=[R&&void 0!==R[0]?R[0]:I[0],R&&void 0!==R[1]?R[1]:I[1]],V=[X&&void 0!==X[0]?X[0]:Y[0],X&&void 0!==X[1]?X[1]:Y[1]];if(!u||X&&2===X.length||(V=[V[1],V[0]]),"bumpline"!==s.type&&!d||R&&2===R.length||(H=[H[1],H[0]]),p.type&&"contour"===p.type)O=function({summaryType:t,data:e,finalXExtent:n,finalYExtent:o}){let r=[];t.type||(t={type:t});const{resolution:i=500,thresholds:s=10,bandwidth:a=20,neighborhood:l}=t,c=m().domain(n).rangeRound([0,i]).nice(),h=m().domain(o).rangeRound([i,0]).nice();return e.forEach(t=>{let e=z().size([i,i]).x(t=>c(t[0])).y(t=>h(t[1])).thresholds(s).bandwidth(a)(t._xyfCoordinates);l&&(e=[e[0]]);const n=Math.max(...e.map(t=>t.value));e.forEach(e=>{e.parentSummary=t,e.bounds=[],e.percent=e.value/n,e.coordinates.forEach(t=>{t.forEach((n,o)=>{t[o]=n.map(t=>[c.invert(t[0]),h.invert(t[1])]),0===o&&e.bounds.push(function(t){let e=[1/0,0],n=[-1/0,0],o=[0,1/0],r=[0,-1/0];return t.forEach(t=>{e=e[0]>t[0]?t:e,n=t[0]>n[0]?t:n,r=t[1]>r[1]?t:r,o=o[1]>t[1]?t:o}),{center:[(e[0]+n[0])/2,(o[1]+r[1])/2],top:o,left:e,right:n,bottom:r}}(t[o]))})})}),r=[...r,...e]}),r}({summaryType:p,data:O,finalXExtent:V,finalYExtent:H});else if(p.type&&"linebounds"===p.type){if(O=function({summaryType:t,data:e,defined:n}){let o=[];t.type||(t={type:t});const{boundingAccessor:r,topBoundingAccessor:i=r,bottomBoundingAccessor:s=r}=t;return e.forEach(t=>{const e=t._baseData.map(n);let r=[],a=[];const l=[{xyf:a,base:r}];e.forEach((n,o)=>{!0===n?(r.push(t._baseData[o]),a.push(t._xyfCoordinates[o])):e[o+1]&&(r=[],a=[],l.push({xyf:a,base:r}))}),l.forEach(({xyf:e,base:n})=>{const r={data:t,parentSummary:t,_xyfCoordinates:Ae(e,n,i,s)};o=[...o,r]})}),o}({summaryType:p,data:O,defined:A}),!R||2!==R.length)for(const t of O)for(const e of t._xyfCoordinates){const t=e[1];void 0!==t&&isFinite(t)&&(H[0]>t&&(H[0]=t),t>H[1]&&(H[1]=t))}}else p.type&&"hexbin"===p.type?(O=Me({summaryType:p,data:O[0],processedData:o&&!!o[0].processedData,preprocess:!1,finalXExtent:V,finalYExtent:H,size:y,margin:g,styleFn:x,classFn:b,renderFn:v,chartSize:k}),$=De($,O)):p.type&&"heatmap"===p.type?(O=Se({summaryType:p,data:O[0],processedData:o&&!!o[0].processedData,preprocess:!1,finalXExtent:V,finalYExtent:H,size:y,margin:g,styleFn:x,classFn:b,renderFn:v,chartSize:k}),$=De($,O)):p.type&&"trendline"===p.type&&(O=function({preprocess:t=!1,summaryType:e,data:n,finalXExtent:o=[Math.min(...n.coordinates.map(t=>t.x)),Math.max(...n.coordinates.map(t=>t.x))],xScaleType:r=m()}){if(t)return n[0].coordinates;let i,s=[];i=e.type?e:{type:i};const{regressionType:a="linear",order:l=2,precision:c=4,controlPoints:h=20,curve:u=j}=i;let d=a;o[0]>=0||"logarithmic"!==a&&"power"!==a&&"exponential"!==a||(console.error(`Cannot use this ${a} regressionType type with value range that goes below 0, defaulting to linear`),d="linear"),n.coordinates&&!n._xyfCoordinates&&(n._xyfCoordinates=n.coordinates.map(t=>[t.x,t.y]));const f=Array.isArray(n)?n:[n],p=r.domain([0,1]).range(o);return s=[],f.forEach(t=>{const e=T[d](t._xyfCoordinates.map(t=>{let e=t[0],n=t[1];return"number"!=typeof e&&(e=e.getTime()),"number"!=typeof n&&(n=n.getTime()),[e,n]}),{order:l,precision:c}),n=1/h;let o=[0,1];if("linear"!==d){o=[];for(let t=0;1+n>t;t+=n)o.push(t)}const r=[];o.forEach(t=>{r.push(e.predict(p(t)))}),s.push({centroid:!1,customMark:void 0,data:t,parentSummary:t,value:e.string,r2:e.r2,curve:u,_xyfCoordinates:r})}),s}({summaryType:p,data:O[0],preprocess:o&&!!o[0].processedData,finalXExtent:V}),$=De($,O));return E&&(_=_.filter(E),$=$.filter((t,e)=>!t.parentLine||E(t.parentLine,e,[]))),M&&($=$.filter(M)),w&&(O=O.filter(w),$=$.filter((t,e)=>!t.parentSummary||w(t.parentSummary,e,[]))),{xExtent:V,yExtent:H,projectedLines:_,projectedPoints:N,projectedSummaries:O,fullDataset:$,calculatedXExtent:Y,calculatedYExtent:I}},Te=(t,e)=>!Oe[t]||"difference"===t&&2!==e.length?"line":t;export{Ht as Annotation,oe as AnnotationLayer,Yt as Axis,se as Brush,ye as DividedLine,it as Legend,Dt as MinimapChart,kt as StreamXYFrame,je as calculateDataExtent,pe as funnelize,Se as heatmapping,Me as hexbinning};
|
|
1
|
+
import*as e from"react";import{useMemo as t,forwardRef as n,useRef as o,useState as i,useCallback as s,useEffect as r,useImperativeHandle as l,createContext as a,useContext as c,useLayoutEffect as h,useId as u}from"react";import{brushX as d,brushY as f,brush as g}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as m,scaleOrdinal as p,scaleSequential as v}from"d3-scale";import{bin as b}from"d3-array";import{packEnclose as x}from"d3-hierarchy";import{schemeCategory10 as w,interpolatePlasma as k,interpolateViridis as A,interpolatePurples as E,interpolateOranges as S,interpolateGreens as O,interpolateReds as M,interpolateBlues as N,schemeSet3 as L,schemeTableau10 as j}from"d3-scale-chromatic";const _=5e3;class B{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,_),bounded:!0,totalSize:e.length});let t=_;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+_,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class W{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}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 ${constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function z(e,t,n,o,i){const s=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=s.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},s.set(a,c)),c.total+=l,i){const e=i(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return s}function C(e,t,n,o,i,s){const r=[],l=[];for(const i of e){const e=n(i),s=o(i);null==e||null==s||Number.isNaN(e)||Number.isNaN(s)||(r.push([t.x(e),t.y(s)]),l.push(s))}return{type:"line",path:r,rawValues:l,style:i,datum:e,group:s}}function H(e,t,n,o,i,s,r){const l=[],a=[];for(const s of e){const e=n(s),r=o(s);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const c=t.x(e);l.push([c,t.y(r)]),a.push([c,t.y(i)])}return{type:"area",topPath:l,bottomPath:a,style:s,datum:e,group:r}}function P(e,t,n,o,i,s,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:i,style:s,datum:e};return void 0!==r&&(c.pointId=r),c}function T(e,t,n,o,i,s,r){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:s,group:r}}function F(e,t,n,o,i,s){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:s}}function I(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function D(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class G{constructor(e){this.xExtent=new $,this.yExtent=new $,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new W(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=I(e.timeAccessor||e.xAccessor,"time"),this.getY=I(e.valueAccessor||e.yAccessor,"value")):(this.getX=I(e.xAccessor,"x"),this.getY=I(e.yAccessor,"y")),this.getGroup=D(e.groupAccessor),this.getCategory=D(e.categoryAccessor),this.getSize=e.sizeAccessor?I(e.sizeAccessor,"size"):void 0,this.getColor=D(e.colorAccessor),this.getBounds=e.boundsAccessor?I(e.boundsAccessor,"bounds"):void 0,this.getPointId=D(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=I(e.openAccessor,"open"),this.getHigh=I(e.highAccessor,"high"),this.getLow=I(e.lowAccessor,"low"),this.getClose=I(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new W(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,i,s,r;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 e of a)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(a,this.getY);const c=this.xExtent.extent,h=this.yExtent.extent;let u=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:c[0],null!==(n=l.xExtent[1])&&void 0!==n?n:c[1]]:c,d=l.yExtent?[null!==(o=l.yExtent[0])&&void 0!==o?o:h[0],null!==(i=l.yExtent[1])&&void 0!==i?i:h[1]]:h;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 e=a.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);d=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&a.size>0){const[,e]=function(e,t,n,o,i){const s=z(e,t,n,o,i);if(0===s.size)return[0,0];let r=0;for(const e of s.values())e.total>r&&(r=e.total);return[0,r]}(a,this.getX,this.getY,l.binSize,this.getCategory);d=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&a.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const s of e){const e=t(s);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(a,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;d=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const e=a.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>d[1]&&(d[1]=e+n),d[0]>e-n&&(d[0]=e-n))}}const e=d[1]-d[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(r=l.yExtent)||void 0===r?void 0:r[1];d=[null!=n?d[0]:d[0]-t,null!=o?d[1]:d[1]+t]}if(u[0]!==1/0&&u[1]!==-1/0||(u=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(g=l.arrowOfTime)||"down"===g?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:m().domain(u).range(t),y:m().domain(d).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:m().domain(d).range([0,e.width]),y:m().domain(u).range(t)}}else this.scales={x:m().domain(u).range([0,e.width]),y:m().domain(d).range([e.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=a.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const i=n.toArray();switch(t.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,e);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,e);case"candlestick":return this.buildCandlestickScene(i,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],i=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=C(e.data,this.scales,this.getX,this.getY,t,e.key);i&&i.length>0&&(n.colorThresholds=i),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]);n.push(H(e.data,this.scales,this.getX,this.getY,o,t,e.key))}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,i,s){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),s=o(i);null==t||null==s||Number.isNaN(t)||Number.isNaN(s)||e.set(t,(e.get(t)||0)+s)}c.set(t.key,e)}let h;if(s){h=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;h.set(t,n||1)}}const u=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let i=e.get(n)||0;const l=d.get(n);s&&(i/=h.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+i)]),d.set(n,l+i)}u.push({type:"area",topPath:o,bottomPath:r,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return u}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let i=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let s=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];s=new Map;let o=0;for(const e of t)s.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=i(e))}if(s&&this.getColor){const t=this.getColor(o);t&&s.has(t)&&(e=Object.assign(Object.assign({},e),{fill:s.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=P(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=I(this.config.valueAccessor,"value"),i=new Set,s=new Set;for(const t of e)i.add(this.getX(t)),s.add(this.getY(t));const r=Array.from(i).sort((e,t)=>e-t),l=Array.from(s).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,h=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;h.set(e,{val:o(t),datum:t})}let u=1/0,d=-1/0;for(const{val:e}of h.values())u>e&&(u=e),e>d&&(d=e);const f=d-u||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=h.get(`${r[e]}_${l[t]}`);if(!o)continue;const i=(o.val-u)/f;n.push(F(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const s=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=I(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return s;const[h,u]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),g=(u-h||1)/r,y=(f-d||1)/l,m=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-h)/g),r-1),i=Math.min(Math.floor((n-d)/y),l-1);if(0>o||0>i)continue;const s=`${o}_${i}`;let a=m.get(s);a||(a={sum:0,count:0,data:[]},m.set(s,a)),a.count++,a.sum+=c(t),a.data.push(t)}let p=1/0,v=-1/0;const b=new Map;for(const[e,t]of m){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),p>n&&(p=n),n>v&&(v=n)}const x=v-p||1,w=t.width/r,k=t.height/l;for(const[e,t]of b){const[n,o]=e.split("_"),i=+n,r=+o,a=(t-p)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,h=m.get(e);s.push(F(i*w,(l-1-r)*k,w,k,c,{xi:i,yi:r,value:t,count:h.count,sum:h.sum,data:h.data}))}return s}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=z(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],i=new Set(t),s=Array.from(e).filter(e=>!i.has(e)).sort();o=[...t.filter(t=>e.has(t)),...s]}const i=[],s=this.scales,[r,l]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=s.x(n),h=s.x(a),u=Math.min(c,h)+.5,d=Math.max(c,h)-.5-u;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=s.y(n),a=s.y(n+o);i.push(T(u,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=s.y(0),n=s.y(e.total);i.push(T(u,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return i}buildSwarmScene(e){var t,n,o,i;const s=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,h=r.stroke,u=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:h,strokeWidth:u},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),s.push(f)}return s}buildWaterfallScene(e,t){var n,o,i;const s=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return s;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",u=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 g=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),y=g+i;let m;m=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const p=r.x(o),v=0!==m?r.x(o+m):p+t.width/10,b=Math.min(p,v)+u/2,x=Math.max(p,v)-u/2-b;if(0>=x){g=y;continue}const w=r.y(g),k=r.y(y);s.push(T(b,Math.min(w,k),x,Math.abs(w-k),{fill:0>i?h:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:g,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),g=y}return s}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},i=o.upColor||"#28a745",s=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),h=this.getLow(t),u=this.getClose(t);if([o,a,h,u].some(e=>null==e||Number.isNaN(e)))continue;const d=u>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(u),highY:this.scales.y(a),lowY:this.scales.y(h),bodyWidth:c,upColor:i,downColor:s,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const s=this.getBounds(t),r=this.scales.x(e);if(s&&0!==s)n.push([r,this.scales.y(i+s)]),o.push([r,this.scales.y(i-s)]);else{const e=this.scales.y(i);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,i;const s=this.config.decay;if(!s||1>=t)return 1;const r=null!==(n=s.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(s.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=s.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(i=s.stepThreshold)&&void 0!==i?i:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const i=null!==(n=o.duration)&&void 0!==n?n:500,s=t-e;return i>s?1-s/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=s,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,i,s;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,i,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(i=c.w)&&void 0!==i?i:r.w,r.h=null!==(s=c.h)&&void 0!==s?s:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):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(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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(e){Object.assign(this.config,e)}}function Y(e,t,n){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function R(e,t,n){if(0===e.path.length)return null;const o=Z(e.path,t);if(0>o)return null;const[i,s]=e.path[o],r=t-i,l=n-s,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function X(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function q(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function V(e,t,n){const o=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,s=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+r*r)}}return null}function U(e,t,n){if(0===e.topPath.length)return null;const o=Z(e.topPath,t);if(0>o)return null;const[i,s]=e.topPath[o],r=t-i,l=n-s;return{node:e,datum:e.datum,x:i,y:s,distance:Math.sqrt(r*r+l*l)}}function Z(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const J={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function K(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,J[n])(o(e,t)),i}function Q(t){const{legendGroups:n,customClickBehavior:o,title:i="Legend",width:s=100,height:r=20,orientation:l="vertical"}=t,a="vertical"===l?(({legendGroups:t,width:n,customClickBehavior:o})=>{let i=30;const s=[];return t.forEach((t,r)=>{i+=5,s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,t.label&&(i+=20,s.push(e.createElement("text",{key:"legend-text-"+r,y:i,className:"legend-group-label"},t.label)),i+=10),s.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(0,${i})`},((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${l})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:30},t.label))),l+=25}),r})(t,o))),i+=25*t.items.length+10}),s})({legendGroups:n,width:s,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:i})=>{let s=0;const r=[],l=!1===n?10:40;return t.forEach((n,a)=>{n.label&&(r.push(e.createElement("text",{key:"legend-text-"+a,transform:`translate(${s},${l}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),s+=20);const c=((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(${l},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:25},t.label))),l+=35,l+=8*t.label.length}),{items:r,offset:l}})(n,i);r.push(e.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${s},${l})`},c.items)),s+=c.offset+5,t[a+1]&&r.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:s,y1:l-10,x2:s,y2:o+l+10})),s+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:s+10,y1:l-10,y2:l-10,stroke:"gray",className:"title-neatline"}),r)})({legendGroups:n,title:i,height:r,customClickBehavior:o});return e.createElement("g",null,void 0!==i&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===l?0:s/2,textAnchor:"horizontal"===l?"start":"middle"},i),a)}function ee(e){return"string"==typeof e?{type:e}:e}function te({orient:n,config:o,values:i,scale:s,size:r,length:l}){const a=function(e){var t,n,o,i,s;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(s=e.strokeWidth)&&void 0!==s?s:1}}(o),c="top"===n||"bottom"===n,h=t(()=>{if(0===i.length)return null;const t=s.domain(),o=r-8;if("boxplot"===a.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],r=s-o;return{q1:o,median:i,q3:s,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],s+1.5*r)}}(i);if(!t)return null;const{q1:r,median:l,q3:h,whiskerLow:u,whiskerHigh:d}=t,f=Math.min(.5*o,20),g=(o-f)/2+4;if(c){const t=s(r),o=s(h),i=s(l),c=s(u),y=s(d),m="top"===n?-1:1,p=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+n},e.createElement("line",{x1:c,y1:p+m*(g+f/2),x2:y,y2:p+m*(g+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:c,y1:p+m*g,x2:c,y2:p+m*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:y,y1:p+m*g,x2:y,y2:p+m*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:Math.min(t,o),y:"top"===n?p-g-f:p+g,width:Math.abs(o-t),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:i,y1:"top"===n?p-g-f:p+g,x2:i,y2:"top"===n?p-g:p+g+f,stroke:a.fill,strokeWidth:2}))}{const t=s(r),o=s(h),i=s(l),c=s(u),y=s(d),m="left"===n?-1:1,p=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+n},e.createElement("line",{x1:p+m*(g+f/2),y1:c,x2:p+m*(g+f/2),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:p+m*g,y1:c,x2:p+m*(g+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:p+m*g,y1:y,x2:p+m*(g+f),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:"left"===n?p-g-f:p+g,y:Math.min(t,o),width:f,height:Math.abs(o-t),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:"left"===n?p-g-f:p+g,y1:i,x2:"left"===n?p-g:p+g+f,y2:i,stroke:a.fill,strokeWidth:2}))}}const h=b().domain(t).thresholds(a.bins)(i);if(0===h.length)return null;const u=Math.max(...h.map(e=>e.length));if(0===u)return null;if("histogram"===a.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+n},h.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*o;if(c){const o=s(t.x0),l=s(t.x1)-s(t.x0);return e.createElement("rect",{key:i,x:o,y:"top"===n?-4-r:4,width:Math.max(l,.5),height:r,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const o=s(t.x0),l=s(t.x1)-s(t.x0);return e.createElement("rect",{key:i,x:"left"===n?-4-r:4,y:Math.min(o,o+l),width:r,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const t=o/2+4,i=[];for(const e of h){if(null==e.x0||null==e.x1)continue;const r=e.length/u*(o/2),l=s((e.x0+e.x1)/2);i.push(c?`${l},${"top"===n?-(t-r):t-r}`:`${"left"===n?-(t-r):t-r},${l}`)}for(let e=h.length-1;e>=0;e--){const r=h[e];if(null==r.x0||null==r.x1)continue;const l=r.length/u*(o/2),a=s((r.x0+r.x1)/2);i.push(c?`${a},${"top"===n?-(t+l):t+l}`:`${"left"===n?-(t+l):t+l},${a}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+n},e.createElement("polygon",{points:i.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const t=[];if(c){const e=0,i=null!=h[0].x0?s(h[0].x0):0;t.push(`M${i},${e}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const i=e.length/u*o,r=s((e.x0+e.x1)/2);t.push(`L${r},${"top"===n?-i-4:i+4}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;t.push(`L${r},${e}`),t.push("Z")}else{const e=0,i=null!=h[0].x0?s(h[0].x0):0;t.push(`M${e},${i}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const i=e.length/u*o,r=s((e.x0+e.x1)/2);t.push(`L${"left"===n?-i-4:i+4},${r}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;t.push(`L${e},${r}`),t.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+n},e.createElement("path",{d:t.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[i,s,a,r,l,n,c,4]);return h?e.createElement("g",{className:"marginal-"+n,"data-testid":"marginal-"+n},h):null}function ne(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),s=[];let r="";for(const e of i)r&&r.length+1+e.length>o?(s.push(r),r=e):r=r?`${r} ${e}`:e;return r&&s.push(r),s}function oe(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function ie(t){const{x:n=0,y:o=0,dx:i,dy:s,nx:r,ny:l,note:a,connector:c,subject:h,type:u,color:d,className:f,disable:g,events:y={},"data-testid":m}=t,p=new Set(Array.isArray(g)?g:[]);let v=i||0,b=s||0;null!=r&&(v=r-n),null!=l&&(b=l-o);const x="string"==typeof u?u:"label";if("bracket"===x&&h&&0===v&&0===b)if(void 0!==h.width){v=h.width/2;const e=h.depth||30;b=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;v=e+(0>e?-5:5),b=h.height/2}return e.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":m},y),!p.has("connector")&&function(t,n,o,i,s,r){const l=[];let a=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==r?void 0:r.radius)){if("callout-rect"===s&&r){const e=r.width||0,o=r.height||0;if(e>0||o>0){const i=e/2,s=o/2,r=t-i,l=n-s;if(0!==r||0!==l){const t=Math.abs(r),n=Math.abs(l),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;a=i+r*d,c=s+l*d}}}else if("bracket"===s&&r){const e=r.width,t=r.height,n=r.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const e=(r.radius||0)+(r.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);a=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(n-c,2))>.5&&(l.push(e.createElement("line",{key:"connector-line",x1:a,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,s=16/180*Math.PI,r=Math.atan2(n-c,t-a);l.push(e.createElement("path",{key:"connector-arrow",d:`M${a},${c}L${a+o*Math.cos(r+s)},${c+o*Math.sin(r+s)}L${a+o*Math.cos(r-s)},${c+o*Math.sin(r-s)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},l)}(v,b,c,d,x,h),!p.has("subject")&&function(t,n,o,i,s){var r;const l=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&l.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&l.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"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 t=i||0,r=s||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;l.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-r,x2:i,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-r;l.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-r,x2:0,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(r=null==n?void 0:n.width)&&void 0!==r?r:null==n?void 0:n.height;void 0!==t&&l.push(e.createElement("path",{key:"bracket-path",d:oe((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},l)}(x,h,d,n,o),!p.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:s,title:r,orientation:l,align:a,wrap:c=120,noWrap:h}=t;if(!s&&!r)return e.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===u?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const g=16,y=r?h?[r]:ne(r,c):[],m=s?h?[s]:ne(s,c):[],p="leftRight"===u?"end"===f?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:f,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:p,dy:0===n?0:g},t)))),v=y.length*g),m.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:f,y:v},m.map((t,n)=>e.createElement("tspan",{key:n,x:p,dy:0===n?0:g},t))));let x=null;if((r||s)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===f?(n=-t,o=0):"middle"===f&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+m.length)*g+(m.length>0?g:0);let n=0,o=t;"bottom"===d?(n=-t,o=0):"middle"===d&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const w=Math.max(0,y.length+m.length-1)*g;let k=0;return"topBottom"===u?k=0>o?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+g+(m.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(a,v,b,d))}function se(t){var n,o;const{noteData:i}=t,{screenCoordinates:s}=i,r="string"==typeof i.type?i.type:"label",l=i.eventListeners||i.events||{};if(i.coordinates&&s){const t=i.nx||s[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),l=i.ny||s[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),a=s.map((n,o)=>{const s=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:l});return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},s,{type:r}))});return e.createElement("g",null,a)}const a=i.note||{title:"none",label:i.label};return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${i.i}`,events:l},i,{type:r}))}function re(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return s?null!=e.x?s(e.x):t.xAccessor&&null!=e[t.xAccessor]?s(e[t.xAccessor]):null:null}function le(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return s?null!=e.y?s(e.y):t.yAccessor&&null!=e[t.yAccessor]?s(e[t.yAccessor]):null:null}function ae(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ce(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,s=Math.ceil(t/8);let r="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*i}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,s=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);r+=`L${o+4*i},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function he(e){return Math.round(100*e)/100+""}function ue(n){const{width:o,height:i,totalWidth:s,totalHeight:r,margin:l,scales:a,showAxes:c,axes:h,xLabel:u,yLabel:d,xFormat:f,yFormat:g,showGrid:y,title:m,legend:p,foregroundGraphics:v,marginalGraphics:b,xValues:w,yValues:k,annotations:A,svgAnnotationRules:E,annotationFrame:S,xAccessor:O,yAccessor:M,annotationData:N,pointNodes:L,children:j}=n,_=t(()=>c&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(f||he)(e)})):[],[c,a,f]),B=t(()=>c&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(g||he)(e)})):[],[c,a,g]),W=t(()=>{if(!A||0===A.length)return null;const t=function(t,n,o){var i,s,r,l,a,c,h,u,d,f,g,y,m,p,v,b,w,k,A,E,S,O,M,N,L,j,_,B,W,$,z,C;switch(t.type){case"label":{let i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=re(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=le(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=x(i),r=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=t.padding||10,r=i.map(e=>e.x),l=i.map(e=>e.y),a=Math.min(...r)-s,c=Math.max(...r)+s,h=Math.min(...l)-s,u=Math.max(...l)+s;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:a,y:h,width:c-a,height:u-h,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(a+c)/2,y:h-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],s="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},s.map((n,i)=>{const s=re(n,o),l=le(n,o);return null==s||null==l?null:e.createElement("circle",Object.assign({key:i,cx:s,cy:l,r:t.r||6},r))}))}case"bracket":{const i=re(t,o),s=le(t,o);return e.createElement(se,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=s?s:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",f=o.yAccessor||"y",g=u.map(e=>[e[d],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const y=null!==(s=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==s?s:null===(r=o.scales)||void 0===r?void 0:r.time,m=null!==(a=null===(l=o.scales)||void 0===l?void 0:l.y)&&void 0!==a?a:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!m)return null;const p=t.method||"linear";let v;if("loess"===p)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),s=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let h=0,u=0,d=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*s[e],f+=t*i[e]*i[e],g+=t*i[e]*s[e])}if(0===h){l.push([t,s[e]]);continue}const y=h*f-u*u;if(1e-12>Math.abs(y))l.push([t,d/h]);else{const e=(h*g-u*d)/y;l.push([t,(d-e*u)/h+e*t])}}return l}(g,null!==(h=t.bandwidth)&&void 0!==h?h:.3);else{let e;try{const n=require("regression");e="polynomial"===p?n.polynomial(g,{order:t.order||2}):n.linear(g)}catch(e){return null}v=e.points}const b=v.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:y(v[v.length-1][0])+4,y:m(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(d=null===(u=o.scales)||void 0===u?void 0:u.y)&&void 0!==d?d:null===(f=o.scales)||void 0===f?void 0:f.value,s=null!==(g=null==i?void 0:i(t.y0))&&void 0!==g?g:0,r=null!==(y=null==i?void 0:i(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(s,r),width:o.width||0,height:Math.abs(r-s),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(s,r)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const s=o.yAccessor||"y",r=null!==(p=null===(m=o.scales)||void 0===m?void 0:m.x)&&void 0!==p?p:null===(v=o.scales)||void 0===v?void 0:v.time,l=null!==(w=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==w?w:null===(k=o.scales)||void 0===k?void 0:k.value;if(!r||!l)return null;const a=i.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,h=a.reduce((e,t)=>e+Math.pow(t-c,2),0)/a.length,u=Math.sqrt(h),d=null!==(A=t.threshold)&&void 0!==A?A:2,f=c-d*u,g=!1!==t.showBand,y=t.fill||"#6366f1",x=null!==(E=t.fillOpacity)&&void 0!==E?E:.1,O=t.anomalyColor||"#ef4444",M=null!==(S=t.anomalyRadius)&&void 0!==S?S:6,N=l(c+d*u),L=l(f),j=i.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*u});return e.createElement("g",{key:"ann-"+n},g&&e.createElement("rect",{x:0,y:Math.min(N,L),width:o.width||0,height:Math.abs(L-N),fill:y,fillOpacity:x}),j.map((t,n)=>{const i=re(t,o),s=le(t,o);return null==i||null==s?null:e.createElement("circle",{key:n,cx:i,cy:s,r:M,fill:O,fillOpacity:.7,stroke:O,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(N,L)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const i=o.data||[];if(3>i.length)return null;const s=o.xAccessor||"x",r=o.yAccessor||"y",l=null!==(M=null===(O=o.scales)||void 0===O?void 0:O.x)&&void 0!==M?M:null===(N=o.scales)||void 0===N?void 0:N.time,a=null!==(j=null===(L=o.scales)||void 0===L?void 0:L.y)&&void 0!==j?j:null===(_=o.scales)||void 0===_?void 0:_.value;if(!l||!a)return null;const c=i.map(e=>[e[s],e[r]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let h;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;h=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,s]of c)t+=e,n+=s,o+=e*e,i+=e*s;const s=e*o-t*t;if(1e-12>Math.abs(s))return null;const r=(e*i-t*n)/s,l=(n-r*t)/e;h=e=>l+r*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),g=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==(B=t.confidence)&&void 0!==B?B:.95,p=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,v=null!==(W=t.steps)&&void 0!==W?W:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=h(e),n=f*Math.sqrt(1+1/u+(y>0?Math.pow(e-g,2)/y:0))*p;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(h(b))}`,H=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==($=t.fillOpacity)&&void 0!==$?$:.15,stroke:"none"}),e.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:H,strokeWidth:null!==(z=t.strokeWidth)&&void 0!==z?z:2,strokeDasharray:null!==(C=t.strokeDasharray)&&void 0!==C?C:"6,3"}),t.label&&k.length>0&&e.createElement("text",{x:l(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:H,fontSize:11},t.label))}default:return null}},n={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:M,width:o,height:i,data:N,frameType:"xy",pointNodes:L};return A.map((e,o)=>{if(E){const i=E(e,o,n);return null!=i?i:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[A,E,o,i,S,O,M,N]);return c||m||p||v||b||W&&W.length>0||y||j?e.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&a&&e.createElement("g",{className:"stream-grid"},_.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),B.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:o,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&a&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),n=null==h?void 0:h.find(e=>"bottom"===e.orient),s=!t||!1!==t.baseline,r=(null==t?void 0:t.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, #666)",g="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},(!n||!1!==n.baseline)&&!a&&e.createElement("line",{x1:0,y1:i,x2:o,y2:i,stroke:c,strokeWidth:1}),a&&e.createElement("path",{d:ce("bottom",o,i),fill:"none",stroke:c,strokeWidth:1}),_.map((t,n)=>e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${i})`},e.createElement("line",{y2:5,stroke:c,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:f,style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:o/2,y:i+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"}},u),s&&!r&&e.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),r&&e.createElement("path",{d:ce("left",o,i),fill:"none",stroke:c,strokeWidth:1}),B.map((t,n)=>e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:f,style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},d))})(),W,b&&a&&w&&k&&e.createElement(e.Fragment,null,b.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"top",config:ee(b.top),values:w,scale:a.x,size:l.top,length:o})),b.bottom&&e.createElement("g",{transform:`translate(0, ${i})`},e.createElement(te,{orient:"bottom",config:ee(b.bottom),values:w,scale:a.x,size:l.bottom,length:o})),b.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"left",config:ee(b.left),values:k,scale:a.y,size:l.left,length:i})),b.right&&e.createElement("g",{transform:`translate(${o}, 0)`},e.createElement(te,{orient:"right",config:ee(b.right),values:k,scale:a.y,size:l.right,length:i}))),v,j),m&&e.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof m?m:null),p&&e.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof($=p)&&null!==$&&!e.isValidElement($)&&"legendGroups"in $?e.createElement(Q,{legendGroups:p.legendGroups,title:"",width:100}):p)):null;var $}function de(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}const fe=(e,t,n,o)=>{var i;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const s=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;if(e.globalAlpha=s,e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},ge=(e,t,n,o)=>{var i,s;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(s=t._pulseGlowRadius)&&void 0!==s?s:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},ye=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?me(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function me(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=i+o,r=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=s)e.drawImage(n,r,o,i,i)}else{const s=i+o,r=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,r,i,i)}e.restore()}const pe={line:[fe,(e,t,n,o)=>{const i=t.filter(e=>"line"===e.type);for(const s of i){if(2>s.path.length)continue;const r=s.style.stroke||"#007bff",l=s.style.strokeWidth||2,a=s.colorThresholds,c=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===s.path.length){let h=null,u=null,d=null,f=null,g=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),g=!0}function m(){g&&(e.stroke(),g=!1)}for(let p=0;s.path.length>p;p++){const[v,b]=s.path[p],x=c[p],w=de(x,a,r);if(null!==h&&null!==f&&null!==d){if(w===f)e.lineTo(v,b);else{const k=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||k.push({t:(E-d)/(x-d)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=h+(v-h)*S.t,M=u+(b-u)*S.t,N=de(d+(x-d)*Math.min(S.t+1e-4,1),a,r);e.lineTo(O,M),m(),y(N,O,M)}e.lineTo(v,b)}h=v,u=b,d=x,f=w}else y(w,v,b),h=v,u=b,d=x,f=w}m()}else{e.beginPath(),e.strokeStyle=r;const[L,j]=s.path[0];e.moveTo(L,j);for(let _=1;s.path.length>_;_++)e.lineTo(s.path[_][0],s.path[_][1]);e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill;const[B,W]=s.path[0];e.moveTo(B,W);for(let z=1;s.path.length>z;z++)e.lineTo(s.path[z][0],s.path[z][1]);const $=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo($,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[fe],stackedarea:[fe],scatter:[ge],bubble:[ge],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);for(const t of i){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[ye],swarm:[ge],waterfall:[(e,t,n,o)=>{var i,s,r;ye(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==a?void 0:a._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],i=l[t+1];if(!(null===(s=o.datum)||void 0===s?void 0:s.cumEnd)||!(null===(r=i.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,h=i.x;e.beginPath(),e.moveTo(c,a),e.lineTo(h,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1))}}]},ve={top:20,right:20,bottom:30,left:40},be={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"},xe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function we({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:xe},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function ke({width:t,height:n,totalWidth:i,totalHeight:s,margin:l,dimension:a,scales:c,onBrush:h}){const u=o(null),m=o(null);return r(()=>{if(!u.current)return;const e=y(u.current).select(".brush-g"),o="x"===a?d():"y"===a?f():g();return o.extent([[0,0],[t,n]]),o.on("brush end",e=>{if(!c)return;if(!e.selection)return void h(null);let o,i;if("x"===a){const[t,s]=e.selection;o=[c.x.invert(t),c.x.invert(s)],i=[c.y.invert(n),c.y.invert(0)]}else if("y"===a){const[n,s]=e.selection;o=[c.x.invert(0),c.x.invert(t)],i=[c.y.invert(s),c.y.invert(n)]}else{const[[t,n],[s,r]]=e.selection;o=[c.x.invert(t),c.x.invert(s)],i=[c.y.invert(r),c.y.invert(n)]}h({x:o,y:i})}),e.call(o),m.current=o,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),m.current=null}},[t,n,a,c,h]),e.createElement("svg",{ref:u,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Ae=n(function(n,a){var c,h,u;const{chartType:d,runtimeMode:f,data:g,xAccessor:y,yAccessor:m,colorAccessor:p,sizeAccessor:v,groupAccessor:b,lineDataAccessor:x,normalize:w,binSize:k,valueAccessor:A,arrowOfTime:E="right",windowMode:S="sliding",windowSize:O=200,timeAccessor:M,xExtent:N,yExtent:L,extentPadding:j=.1,sizeRange:_,size:W=[500,300],margin:$,className:z,background:C,lineStyle:H,pointStyle:P,areaStyle:T,waterfallStyle:F,swarmStyle:I,barColors:D,colorScheme:Z,boundsAccessor:J,boundsStyle:K,openAccessor:Q,highAccessor:ee,lowAccessor:te,closeAccessor:ne,candlestickStyle:oe,showAxes:ie=!0,axes:se,xLabel:re,yLabel:le,xFormat:ae,yFormat:ce,tickFormatTime:he,tickFormatValue:de,hoverAnnotation:fe,tooltipContent:ge,customHoverBehavior:ye,enableHover:me,annotations:xe,svgAnnotationRules:Ae,showGrid:Ee,legend:Se,backgroundGraphics:Oe,foregroundGraphics:Me,title:Ne,categoryAccessor:Le,brush:je,onBrush:_e,decay:Be,pulse:We,transition:$e,staleness:ze,heatmapAggregation:Ce,heatmapXBins:He,heatmapYBins:Pe,marginalGraphics:Te,pointIdAccessor:Fe}=n,Ie=Object.assign(Object.assign({},ve),$);if(Te){const e=60;Te.top&&e>Ie.top&&(Ie.top=e),Te.bottom&&e>Ie.bottom&&(Ie.bottom=e),Te.left&&e>Ie.left&&(Ie.left=e),Te.right&&e>Ie.right&&(Ie.right=e)}const De=W[0]-Ie.left-Ie.right,Ge=W[1]-Ie.top-Ie.bottom,Ye=null!=fe?fe:me,Re=o(null),Xe=o(0),qe=o(!1),[Ve,Ue]=i(0),[Ze,Je]=i(null),Ke=o(null),Qe=o(null),[et,tt]=i(null),[nt,ot]=i(!1),[it,st]=i([]),[rt,lt]=i([]),at=o(()=>{}),ct="streaming"===f||["bar","swarm","waterfall"].includes(d),ht=t(()=>({chartType:d,runtimeMode:ct?"streaming":"bounded",windowSize:O,windowMode:S,arrowOfTime:ct?E:"right",extentPadding:j,xAccessor:ct?void 0:y,yAccessor:ct?void 0:m,timeAccessor:ct?M:void 0,valueAccessor:A,colorAccessor:p,sizeAccessor:v,groupAccessor:b,categoryAccessor:Le,lineDataAccessor:x,xExtent:N,yExtent:L,sizeRange:_,binSize:k,normalize:w,boundsAccessor:J,boundsStyle:K,openAccessor:Q,highAccessor:ee,lowAccessor:te,closeAccessor:ne,candlestickStyle:oe,lineStyle:H,pointStyle:P,areaStyle:T,swarmStyle:I,waterfallStyle:F,colorScheme:Z,barColors:D,annotations:xe,decay:Be,pulse:We,transition:$e,staleness:ze,heatmapAggregation:Ce,heatmapXBins:He,heatmapYBins:Pe,pointIdAccessor:Fe}),[d,O,S,E,j,y,m,M,A,p,v,b,Le,x,N,L,_,k,w,J,K,Q,ee,te,ne,oe,H,P,T,I,F,Z,D,xe,Be,We,$e,ze,Ce,He,Pe,ct,Fe]),ut=o(null);ut.current||(ut.current=new G(ht));const dt=s(()=>{Xe.current||(Xe.current=requestAnimationFrame(()=>at.current()))},[]);r(()=>{var e;null===(e=ut.current)||void 0===e||e.updateConfig(ht),qe.current=!0,dt()},[ht,dt]);const ft=o(null);ft.current||(ft.current=new B(e=>{const t=ut.current;t&&t.ingest(e)&&(qe.current=!0,dt())}));const gt=s(e=>{var t;null===(t=ft.current)||void 0===t||t.push(e)},[]),yt=s(e=>{var t;null===(t=ft.current)||void 0===t||t.pushMany(e)},[]),mt=s(()=>{var e,t;null===(e=ft.current)||void 0===e||e.clear(),null===(t=ut.current)||void 0===t||t.clear(),qe.current=!0,dt()},[dt]);l(a,()=>({push:gt,pushMany:yt,clear:mt,getData:()=>{var e,t;return null!==(t=null===(e=ut.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ut.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=ut.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[gt,yt,mt]),r(()=>{var e;g&&(null===(e=ft.current)||void 0===e||e.setBoundedData(g))},[g]);const pt=o(()=>{}),vt=o(()=>{});pt.current=e=>{if(!Ye)return;const t=Re.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ie.left,i=e.clientY-n.top-Ie.top;if(0>o||o>De||0>i||i>Ge)return void(Ke.current&&(Ke.current=null,Qe.current=null,tt(null),ye&&ye(null),dt()));const s=ut.current;if(!s||0===s.scene.length)return;const r=function(e,t,n,o=30){let i=null;for(const s of e){let e=null;switch(s.type){case"point":e=Y(s,t,n);break;case"line":e=R(s,t,n);break;case"rect":e=X(s,t,n);break;case"heatcell":e=q(s,t,n);break;case"area":if(!1===s.interactive)break;e=U(s,t,n);break;case"candlestick":e=V(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(s.scene,o,i);if(!r)return void(Ke.current&&(Ke.current=null,Qe.current=null,tt(null),ye&&ye(null),dt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};Ke.current=l,Qe.current=r.node,tt(l),ye&&ye(l),dt()},vt.current=()=>{Ke.current&&(Ke.current=null,Qe.current=null,tt(null),ye&&ye(null),dt())};const bt=s(e=>pt.current(e),[]),xt=s(()=>vt.current(),[]);at.current=()=>{var e,t;Xe.current=0;const n=Re.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=ut.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),r=i.advanceTransition(s);r||i.computeScene({width:De,height:Ge});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=W[0]*l,n.height=W[1]*l,n.style.width=W[0]+"px",n.style.height=W[1]+"px",o.scale(l,l),o.translate(Ie.left,Ie.top),o.clearRect(-Ie.left,-Ie.top,W[0],W[1]);const a=function(e){if(!e)return be;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return s||r||n?{axisStroke:l||be.axisStroke,tickText:s||be.tickText,crosshair:s?s+"66":be.crosshair,hoverFill:a?a+"4D":be.hoverFill,hoverStroke:s?s+"99":be.hoverStroke,pointRing:a||be.pointRing}:be}(n),c=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,h=ze&&i.lastIngestTime>0&&s-i.lastIngestTime>c;h&&(o.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5);const u=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",f=C||(u&&"transparent"!==u?u:null);f&&(o.fillStyle=f,o.fillRect(-Ie.left,-Ie.top,W[0],W[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,De,Ge),o.clip());const g=pe[d];if(g&&i.scales)for(const e of g)e(o,i.scene,i.scales,{width:De,height:Ge});if(o.restore(),h&&(o.globalAlpha=1),Ye&&Ke.current&&i.scales&&function(e,t,n,o,i,s,r){if(!1===i.crosshair)return;e.save();const l="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(o,Ke.current,De,Ge,"object"==typeof Ye?Ye:{},0,a),Qe.current&&Array.isArray(fe)){const e=fe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var i;if(!n)return;const s=n.group;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(o,i.scene,Qe.current,e)}const p=qe.current;if(qe.current=!1,p&&i.scales&&(Je(i.scales),Te)){const e=i.getData(),t="function"==typeof y?y:e=>e[y||"x"],n="function"==typeof m?m:e=>e[m||"y"];st(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),lt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}p&&xe&&xe.length>0&&Ue(e=>e+1),(null==ze?void 0:ze.showBadge)&&ot(!!h),(r||i.hasActivePulses)&&(Xe.current=requestAnimationFrame(()=>at.current()))},r(()=>(dt(),()=>{Xe.current&&cancelAnimationFrame(Xe.current)}),[dt]),r(()=>{qe.current=!0,dt()},[d,De,Ge,ie,C,H,dt]),r(()=>{if(!ze)return;const e=setInterval(()=>{var e;const t=ut.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ze.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==nt&&(ot(i),qe.current=!0,dt())},1e3);return()=>clearInterval(e)},[ze,nt,dt]);const wt=Ye&&et?ge?ge(et):e.createElement(we,{hover:et}):null,kt=wt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ie.left+et.x,top:Ie.top+et.y,transform:`translate(${et.x>.7*De?"calc(-100% - 12px)":"12px"}, ${.3*Ge>et.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},wt):null;return e.createElement("div",{className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof Ne?Ne:"XY chart",style:{position:"relative",width:W[0],height:W[1]},onMouseMove:Ye?bt:void 0,onMouseLeave:Ye?xt:void 0},Oe&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:W[0],height:W[1],pointerEvents:"none"}},Oe),e.createElement("canvas",{ref:Re,style:{position:"absolute",left:0,top:0}}),e.createElement(ue,{width:De,height:Ge,totalWidth:W[0],totalHeight:W[1],margin:Ie,scales:Ze,showAxes:ie,axes:se,xLabel:re,yLabel:le,xFormat:ae||he,yFormat:ce||de,showGrid:Ee,title:Ne,legend:Se,foregroundGraphics:Me,marginalGraphics:Te,xValues:it,yValues:rt,annotations:xe,svgAnnotationRules:Ae,annotationFrame:Ve,xAccessor:"string"==typeof y?y:"string"==typeof M?M:void 0,yAccessor:"string"==typeof m?m:"string"==typeof A?A:void 0,annotationData:null===(c=ut.current)||void 0===c?void 0:c.getData(),pointNodes:null===(h=ut.current)||void 0===h?void 0:h.scene.filter(e=>"point"===e.type)}),(je||_e)&&e.createElement(ke,{width:De,height:Ge,totalWidth:W[0],totalHeight:W[1],margin:Ie,dimension:null!==(u=null==je?void 0:je.dimension)&&void 0!==u?u:"xy",scales:Ze,onBrush:null!=_e?_e:()=>{}}),(null==ze?void 0:ze.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ze.badgePosition?{top:4,left:4}:"bottom-left"===ze.badgePosition?{bottom:4,left:4}:"bottom-right"===ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:nt?"#dc3545":"#28a745",color:"white"})},nt?"STALE":"LIVE"),kt)});Ae.displayName="StreamXYFrame";const Ee={category10:w,tableau10:j,set3:L,blues:N,reds:M,greens:O,oranges:S,purples:E,viridis:A,plasma:k},Se=w;function Oe(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Se[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%Se.length]}function Me(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[s,r]=o,[l,a]=n;return r===s?(l+a)/2:l+(i-s)/(r-s)*(a-l)}function Ne(e){return e?"string"==typeof e?{name:e}:e:null}function Le(e,t,n){return t?o=>{var i,s;const r=Object.assign({},e(o));return t.isActive&&(t.predicate(o)?(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle):(r.fillOpacity=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2,r.strokeOpacity=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle))),r}:e}function je(n){const o=a(null),s=_e(n);return[function({children:i}){const s=t(()=>_e(n),[]);return e.createElement(o.Provider,{value:s,children:i})},e=>{var t;const n=null!==(t=c(o))&&void 0!==t?t:s;return function(e,t){const[n,o]=i(t);return h(()=>e(()=>o(t)),[e]),n}(n.subscribe,()=>e(n.getState()))}]}function _e(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function Be(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function We(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[$e,ze]=je(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=We(o,t),s=new Map(i.clauses);return s.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:s})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),s=new Map(o.clauses);return s.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:s})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=We(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function Ce(e){const n=u(),o=e.clientId||n,{name:i}=e,r=ze(e=>e.selections.get(i)),l=ze(e=>e.setClause),a=ze(e=>e.clearClause),c=t(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Be(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,o):()=>!0,[r,o]),isActive:c,selectPoints:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(i,{clientId:o,type:"point",fields:t})},[o,i,l]),selectInterval:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(i,{clientId:o,type:"interval",fields:t})},[o,i,l]),clear:s(()=>{a(i,o)},[a,i,o]),clientId:o}}function He(e){const{name:n,xField:o,yField:i}=e,{predicate:r,isActive:l,selectInterval:a,clear:c}=Ce({name:n}),h=o&&i?"xyBrush":o?"xBrush":"yBrush",u=s(e=>{if(!e)return void c();const t={};"xyBrush"===h&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===h&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===h&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[h,o,i,a,c]);return{brushInteraction:t(()=>({brush:h,during:u,end:u}),[h,u]),predicate:r,isActive:l,clear:c}}const[Pe,Te]=je(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),Fe="#007bff";function Ie(e){return"function"==typeof e?e:t=>t[e]}function De(e,n,o="category10"){return t(()=>{if(n&&"function"!=typeof n)return function(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return p().domain(o).range(n).unknown("#999");const s=Ee[n]||Ee.category10;if(i&&"function"==typeof s)return e=>s(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(s)?s:Se;return p().domain(o).range(e).unknown("#999")}}(e,n,o)},[e,n,o])}function Ge({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:r,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=Ce({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:r,clear:l}=Ce({name:t});return{onHover:s(e=>{if(!e)return void l();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&r(t)},[n,r,l]),predicate:o,isActive:i}}({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||[]}),u=Te(e=>e.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:s(e=>{var n,o;if(t){let t=e&&(e.data||e.datum)||e;Array.isArray(t)&&(t=t[0]),h.onHover(t)}if(i||u){const t={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},t),{type:"hover",datum:s||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,r,l,u]),customClickBehavior:s(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,r,l])}}function Ye({data:e,colorBy:n,colorScale:o,showLegend:i,userMargin:s,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=void 0!==i?i:!!n,a=t(()=>{if(l&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:s}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==s&&(t.strokeWidth=s),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),r=s?o(s,t,n):n?n(i):"#000000";return{label:i+"",color:r}}),label:""}]}}({data:e,colorBy:n,colorScale:o,getColor:Oe})},[l,n,e,o]),c=t(()=>{const e=Object.assign(Object.assign({},r),s);return a&&120>e.right&&(e.right=120),e},[r,s,a]);return{legend:a,margin:c}}const Re={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 Xe(e,t,n){var o,i,s,r,l,a;const c=Re[e||"primary"],h="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:h?void 0:t.title,xLabel:h?void 0:t.xLabel,yLabel:h?void 0:t.yLabel,categoryLabel:h?void 0:t.categoryLabel,valueLabel:h?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const qe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Ve(e,t){return"function"==typeof t?t(e):e[t]}function Ue(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ze(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:n,title:o,format:i,style:s={},className:r=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let l;const a=[];if(o){const e=Ve(t,o);l=Ue(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,s;"string"==typeof e?(n=e,o=e,s=i):(n=e.label,o=e.accessor||e.key||"",s=e.format||i);const r=Ve(t,o);a.push({label:n,value:Ue(r,s)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){l=Ue(t[n],i);break}if(!l){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(l=Ue(t[e[0]],i))}}const c=Object.assign(Object.assign({},qe),s);return e.createElement("div",{className:("semiotic-tooltip "+r).trim(),style:c},l&&e.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},l),a.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&l?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}(t)))}function Je(e){return"string"==typeof e?e:"value"}function Ke(t){return n=>{const o=n.data;return o?e.createElement("div",{className:"semiotic-tooltip",style:qe},t.map((t,n)=>{const i=function(e,t){return"function"==typeof t?t(e):e[t]}(o,t.accessor),s=null==(r=i)?"–":"number"==typeof r?r.toLocaleString():r instanceof Date?r.toLocaleDateString():r+"";var r;return e.createElement("div",{key:n,style:n>0?{marginTop:2}:void 0},e.createElement("span",{style:{opacity:.8}},t.label,": "),e.createElement("span",{style:{fontWeight:"color"===t.role||"group"===t.role?"bold":"normal"}},s))})):null}}function Qe({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}function et({data:e,accessors:t,requiredProps:n}){if(n)for(const[e,t]of Object.entries(n))if(null==t)return e+" is required. Provide a field name or function.";if(!e||!Array.isArray(e)||0===e.length)return"No data provided. Pass a non-empty array to the data prop.";if(t)for(const n of function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(e))if(n&&"object"==typeof n)for(const[e,o]of Object.entries(t))if(o&&"string"==typeof o&&!(o in n))return`${e} "${o}" not found in data. Available fields: ${Object.keys(n).join(", ")}.`;return null}function tt(n){var o,i;const s=Xe(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:r,margin:l,className:a,xFormat:c,yFormat:h,xAccessor:u="x",yAccessor:d="y",lineBy:f,lineDataAccessor:g="coordinates",colorBy:y,colorScheme:m="category10",curve:p="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:E,annotations:S,frameProps:O={},selection:M,linkedHover:N,onObservation:L,chartId:j}=n,_=s.width,B=s.height,W=s.enableHover,$=s.showGrid,z=s.showLegend,C=s.title,H=s.xLabel,P=s.yLabel,T=r||[],{activeSelectionHook:F,customHoverBehavior:I}=Ge({selection:M,linkedHover:N,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:L,chartType:"LineChart",chartId:j}),D=void 0!==(null===(o=T[0])||void 0===o?void 0:o[g]),G=t(()=>{if(D)return T;if(f){const e=T.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[g]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:T}]},[T,f,g,D]),Y=De(T,y,m),R=t(()=>e=>{const t={strokeWidth:k};return t.stroke=y?Oe(e,y,Y):Fe,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,Y,k,x,w]),X=t(()=>Le(R,F,M),[R,F,M]),q=t(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?Oe(e.parentLine||e,y,Y):Fe,t}},[v,b,y,Y]),V=x?"area":"line",{legend:U,margin:Z}=Ye({data:G,colorBy:y,colorScale:Y,showLegend:z,userMargin:l,defaults:s.marginDefaults}),J=f||y,K=t(()=>Ke([{label:H||Je(u),accessor:u,role:"x"},{label:P||Je(d),accessor:d,role:"y"},...J?[{label:Je(J),accessor:J,role:"group"}]:[]]),[u,d,H,P,J]),Q=et({componentName:"LineChart",data:D?(null===(i=T[0])||void 0===i?void 0:i[g])||[]:T,accessors:{xAccessor:u,yAccessor:d}});if(Q)return e.createElement(Qe,{componentName:"LineChart",message:Q,width:_,height:B});const ee=t(()=>D||f?G.flatMap(e=>{const t=e[g]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):T,[G,g,D,f,T]),te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:V,data:ee,xAccessor:u,yAccessor:d,groupAccessor:f||void 0,curve:p,lineStyle:X},v&&{pointStyle:q}),{size:[_,B],margin:Z,showAxes:s.showAxes,xLabel:H,yLabel:P,xFormat:c,yFormat:h,enableHover:W,showGrid:$}),U&&{legend:U}),C&&{title:C}),a&&{className:a}),{tooltipContent:A?Ze(A):K}),(N||L)&&{customHoverBehavior:I}),E&&{pointIdAccessor:E}),S&&S.length>0&&{annotations:S}),O);return e.createElement(Ae,Object.assign({},te))}function nt(n){var o;const i=Xe(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:g,colorScheme:y="category10",curve:m="monotoneX",areaOpacity:p=.7,showLine:v=!0,lineWidth:b=2,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,onObservation:S,chartId:O}=n,M=i.width,N=i.height,L=i.enableHover,j=i.showGrid,_=i.showLegend,B=i.title,W=i.xLabel,$=i.yLabel,z=s||[],{activeSelectionHook:C,customHoverBehavior:H}=Ge({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:S,chartType:"AreaChart",chartId:O}),P=void 0!==(null===(o=z[0])||void 0===o?void 0:o[f]),T=t(()=>{if(P)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:z}]},[z,d,f,P]),F=De(z,g,y),I=t(()=>e=>{const t={},n=g?Oe(e,g,F):Fe;return t.fill=n,t.fillOpacity=p,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[g,F,p,v,b]),D=t(()=>Le(I,C,A),[I,C,A]),{legend:G,margin:Y}=Ye({data:T,colorBy:g,colorScale:F,showLegend:_,userMargin:r,defaults:i.marginDefaults}),R=d||g,X=t(()=>Ke([{label:W||Je(h),accessor:h,role:"x"},{label:$||Je(u),accessor:u,role:"y"},...R?[{label:Je(R),accessor:R,role:"group"}]:[]]),[h,u,W,$,R]),q=et({componentName:"AreaChart",data:z,accessors:{xAccessor:h,yAccessor:u}});if(q)return e.createElement(Qe,{componentName:"AreaChart",message:q,width:M,height:N});const V=t(()=>P||d?T.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[T,f,P,d,z]),U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:V,xAccessor:h,yAccessor:u,groupAccessor:d||void 0,curve:m,lineStyle:D,size:[M,N],margin:Y,showAxes:i.showAxes,xLabel:W,yLabel:$,xFormat:a,yFormat:c,enableHover:L,showGrid:j},G&&{legend:G}),B&&{title:B}),l&&{className:l}),{tooltipContent:x?Ze(x):X}),(E||S)&&{customHoverBehavior:H}),w&&w.length>0&&{annotations:w}),k);return e.createElement(Ae,Object.assign({},U))}function ot(n){var o;const i=Xe(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:g,colorScheme:y="category10",curve:m="monotoneX",areaOpacity:p=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:E,linkedHover:S,onObservation:O,chartId:M}=n,N=i.width,L=i.height,j=i.enableHover,_=i.showGrid,B=i.showLegend,W=i.title,$=i.xLabel,z=i.yLabel,C=s||[],{activeSelectionHook:H,customHoverBehavior:P}=Ge({selection:E,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:M}),T=void 0!==(null===(o=C[0])||void 0===o?void 0:o[f]),F=t(()=>{if(T)return C;if(d){const e=C.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:C}]},[C,d,f,T]),I=De(C,g,y),D=t(()=>e=>{const t={},n=g?Oe(e,g,I):Fe;return t.fill=n,t.fillOpacity=p,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[g,I,p,v,b]),G=t(()=>Le(D,H,E),[D,H,E]),{legend:Y,margin:R}=Ye({data:F,colorBy:g,colorScale:I,showLegend:B,userMargin:r,defaults:i.marginDefaults}),X=d||g,q=t(()=>Ke([{label:$||Je(h),accessor:h,role:"x"},{label:z||Je(u),accessor:u,role:"y"},...X?[{label:Je(X),accessor:X,role:"group"}]:[]]),[h,u,$,z,X]),V=et({componentName:"StackedAreaChart",data:C,accessors:{xAccessor:h,yAccessor:u}});if(V)return e.createElement(Qe,{componentName:"StackedAreaChart",message:V,width:N,height:L});const U=t(()=>T||d?F.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):C,[F,f,T,d,C]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:h,yAccessor:u,groupAccessor:d||void 0,curve:m,normalize:x,lineStyle:G,size:[N,L],margin:R,showAxes:i.showAxes,xLabel:$,yLabel:z,xFormat:a,yFormat:c,enableHover:j,showGrid:_},Y&&{legend:Y}),W&&{title:W}),l&&{className:l}),{tooltipContent:w?Ze(w):q}),(S||O)&&{customHoverBehavior:P}),k&&k.length>0&&{annotations:k}),A);return e.createElement(Ae,Object.assign({},Z))}function it(n){const o=Xe(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:i,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",colorBy:u,colorScheme:d="category10",sizeBy:f,sizeRange:g=[3,15],pointRadius:y=5,pointOpacity:m=.8,tooltip:p,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=n,M=o.width,N=o.height,L=o.enableHover,j=o.showGrid,_=o.showLegend,B=o.title,W=o.xLabel,$=o.yLabel,z=i||[],{activeSelectionHook:C,customHoverBehavior:H}=Ge({selection:k,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),P=Ne(E);He({name:(null==P?void 0:P.name)||"__unused_brush__",xField:(null==P?void 0:P.xField)||("string"==typeof c?c:void 0),yField:(null==P?void 0:P.yField)||("string"==typeof h?h:void 0)});const T=De(z,u,d),F=t(()=>{if(!f||0===z.length)return;const e=z.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[z,f]),I=t(()=>e=>{const t={fillOpacity:m};return t.fill=u?Oe(e,u,T):Fe,t.r=f?Me(e,f,g,F):y,t},[u,T,f,g,F,y,m]),D=t(()=>Le(I,C,k),[I,C,k]),{legend:G,margin:Y}=Ye({data:z,colorBy:u,colorScale:T,showLegend:_,userMargin:s,defaults:o.marginDefaults}),R=t(()=>Ke([{label:W||Je(c),accessor:c,role:"x"},{label:$||Je(h),accessor:h,role:"y"},...u?[{label:Je(u),accessor:u,role:"color"}]:[],...f?[{label:Je(f),accessor:f,role:"size"}]:[]]),[c,h,W,$,u,f]),X=et({componentName:"Scatterplot",data:z,accessors:{xAccessor:c,yAccessor:h}});if(X)return e.createElement(Qe,{componentName:"Scatterplot",message:X,width:M,height:N});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:z,xAccessor:c,yAccessor:h,colorAccessor:u||void 0,sizeAccessor:f||void 0,sizeRange:g,pointStyle:D,colorScheme:d,size:[M,N],margin:Y,showAxes:o.showAxes,xLabel:W,yLabel:$,xFormat:l,yFormat:a,enableHover:L,showGrid:j},G&&{legend:G}),B&&{title:B}),r&&{className:r}),{tooltipContent:p?Ze(p):R}),(A||S)&&{customHoverBehavior:H}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return e.createElement(Ae,Object.assign({},q))}function st(n){const o=Xe(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:i,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",sizeBy:u,sizeRange:d=[5,40],colorBy:f,colorScheme:g="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:m=1,bubbleStrokeColor:p="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:M}=n,N=o.width,L=o.height,j=o.enableHover,_=o.showGrid,B=o.showLegend,W=o.title,$=o.xLabel,z=o.yLabel,C=i||[],{activeSelectionHook:H,customHoverBehavior:P}=Ge({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:O,chartType:"BubbleChart",chartId:M}),T=Ne(S);He({name:(null==T?void 0:T.name)||"__unused_brush__",xField:(null==T?void 0:T.xField)||("string"==typeof c?c:void 0),yField:(null==T?void 0:T.yField)||("string"==typeof h?h:void 0)});const F=De(C,f,g),I=t(()=>{const e=C.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[C,u]),D=t(()=>e=>{const t={fillOpacity:y,strokeWidth:m,stroke:p};return t.fill=f?Oe(e,f,F):Fe,t.r=Me(e,u,d,I),t},[f,F,u,d,I,y,m,p]),G=t(()=>Le(D,H,A),[D,H,A]),{legend:Y,margin:R}=Ye({data:C,colorBy:f,colorScale:F,showLegend:B,userMargin:s,defaults:o.marginDefaults}),X=t(()=>Ke([{label:$||Je(c),accessor:c,role:"x"},{label:z||Je(h),accessor:h,role:"y"},{label:Je(u),accessor:u,role:"size"},...f?[{label:Je(f),accessor:f,role:"color"}]:[]]),[c,h,$,z,u,f]),q=et({componentName:"BubbleChart",data:C,accessors:{xAccessor:c,yAccessor:h},requiredProps:{sizeBy:u}});if(q)return e.createElement(Qe,{componentName:"BubbleChart",message:q,width:N,height:L});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:C,xAccessor:c,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:u,sizeRange:d,pointStyle:G,colorScheme:g,size:[N,L],margin:R,showAxes:o.showAxes,xLabel:$,yLabel:z,xFormat:l,yFormat:a,enableHover:j,showGrid:_},Y&&{legend:Y}),W&&{title:W}),r&&{className:r}),{tooltipContent:v?Ze(v):X}),(E||O)&&{customHoverBehavior:P}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return e.createElement(Ae,Object.assign({},V))}function rt(n){const o=Xe(n.mode,{width:n.width,height:n.height,showGrid:void 0,enableHover:n.enableHover,showLegend:void 0,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:i,margin:s,className:r,xAccessor:l="x",yAccessor:a="y",valueAccessor:c="value",xFormat:h,yFormat:u,colorScheme:d="blues",customColorScale:f,showValues:g=!1,valueFormat:y,cellBorderColor:m="#fff",cellBorderWidth:p=1,tooltip:b,annotations:x,frameProps:w={},selection:k,linkedHover:E,onObservation:S,chartId:L}=n,j=o.width,_=o.height,B=o.enableHover,W=o.title,$=o.xLabel,z=o.yLabel,C=i||[],{margin:H}=Ye({data:C,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:s,defaults:o.marginDefaults}),{activeSelectionHook:P,customHoverBehavior:T}=Ge({selection:k,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:L}),F=t(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),I=t(()=>{const e=C.map(F);return[Math.min(...e),Math.max(...e)]},[C,F]),D=t(()=>"custom"===d&&f?f:v({blues:N,reds:M,greens:O,viridis:A}[d]||N).domain(I),[d,f,I]);t(()=>{const e=Ie(l),t=Ie(a);return{xBinCount:new Set(C.map(e)).size,yBinCount:new Set(C.map(t)).size}},[C,l,a]),t(()=>({coordinates:C}),[C]);const G=t(()=>e=>{const t=F(e);return{fill:D(t),stroke:m,strokeWidth:p}},[F,D,m,p]);t(()=>Le(G,P,k),[G,P,k]),t(()=>{if(!g)return;const t=(I[0]+I[1])/2;return(n,o)=>{const i=F(n),s=y?y(i):i+"";return e.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:F(n)>t?"#fff":"#000",fontSize:"12px"},s)}},[g,F,y,I]);const Y=t(()=>Ke([{label:$||Je(l),accessor:l,role:"x"},{label:z||Je(a),accessor:a,role:"y"},{label:Je(c),accessor:c,role:"value"}]),[l,a,$,z,c]),R=et({componentName:"Heatmap",data:C,accessors:{xAccessor:l,yAccessor:a,valueAccessor:c}});if(R)return e.createElement(Qe,{componentName:"Heatmap",message:R,width:j,height:_});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:C,xAccessor:l,yAccessor:a,valueAccessor:c,size:[j,_],margin:H,showAxes:o.showAxes,xLabel:$,yLabel:z,xFormat:h,yFormat:u,enableHover:B},W&&{title:W}),r&&{className:r}),{tooltipContent:b?Ze(b):Y}),(E||S)&&{customHoverBehavior:T}),x&&x.length>0&&{annotations:x}),w);return e.createElement(Ae,Object.assign({},X))}function lt({selections:e}){const t=ze(e=>e.setResolution);return r(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[]),null}function at({children:t,selections:n}){return e.createElement($e,null,e.createElement(Pe,null,n&&e.createElement(lt,{selections:n}),t))}tt.displayName="LineChart",nt.displayName="AreaChart",ot.displayName="StackedAreaChart",it.displayName="Scatterplot",st.displayName="BubbleChart",rt.displayName="Heatmap";const ct="__splomIdx",ht={top:4,bottom:4,left:4,right:4};function ut({frameRef:t,cellSize:n,onBrush:i}){const s=o(null),l=n-ht.left-ht.right,a=n-ht.top-ht.bottom;return r(()=>{if(!s.current)return;const e=y(s.current).select(".brush-g"),n=g().extent([[0,0],[l,a]]).on("brush end",e=>{var n;const o=null===(n=t.current)||void 0===n?void 0:n.getScales();if(!o)return;if(!e.selection)return void i(null);const[[s,r],[l,a]]=e.selection,c=[[o.x.invert(s),o.y.invert(r)],[o.x.invert(l),o.y.invert(a)]];i(c)});return e.call(n),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{n.on("brush end",null)}},[l,a,t,i]),e.createElement("svg",{ref:s,width:n,height:n,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${ht.left},${ht.top})`}))}function dt({data:t,xField:n,yField:i,cellSize:r,pointRadius:l,pointOpacity:a,colorBy:c,colorScale:h,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:f,mode:g,onPointHover:y}){const m=o(null),p=Ce({name:u,clientId:`splom-${n}-${i}`}),v=He({name:u,xField:n,yField:i}),b=Ce({name:d,clientId:"splom-hover-source"}),x=b.selectPoints,w=s(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=s(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[ct];void 0!==n&&(x({[ct]:[n]}),null==y||y(t,e.x+ht.left,e.y+ht.top))},[x,y]),A=s(e=>{const t={opacity:a,r:l};return t.fill=c?Oe(e,c,h):Fe,"hover"===g?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*l,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*a):p.isActive&&!p.predicate(e)&&(t.opacity=f),t},[c,h,a,l,g,p.isActive,p.predicate,b.isActive,b.predicate,f]);return e.createElement("div",{style:{position:"relative",width:r,height:r}},e.createElement(Ae,{ref:m,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:i,pointStyle:A,margin:ht,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.createElement(ut,{frameRef:m,cellSize:r,xField:n,yField:i,onBrush:w}))}function ft({data:n,field:o,label:i,cellSize:s,bins:r,brushSelectionName:l,hoverSelectionName:a,mode:c}){const h=Ce({name:l,clientId:"splom-diag-"+o}),u=Ce({name:a,clientId:`splom-diag-${o}-hover`}),d="hover"===c?u:h,f=d.isActive,g=d.predicate,y=t(()=>{const e=n.map(e=>e[o]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const t=Math.min(...e),i=(Math.max(...e)-t)/r||1,l=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=e[o];if(null==n||isNaN(n))continue;const s=Math.min(Math.floor((n-t)/i),r-1);l[s]++,f&&!g(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),max:c}},[n,o,r,s,f,g]);return e.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},e.createElement("text",{x:s/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},i),y.bars.map((t,n)=>e.createElement("rect",{key:"bg-"+n,x:t.x,y:s-t.h,width:Math.max(t.w,1),height:t.h,fill:"#ccc",opacity:f?.3:.6})),f&&y.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:s-t.h,width:Math.max(t.w,1),height:t.h,fill:Fe,opacity:.7})))}function gt({label:t,cellSize:n}){return e.createElement("svg",{width:n,height:n},e.createElement("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},t))}function yt(n){const{data:o,fields:r,fieldLabels:l={},colorBy:a,colorScheme:c="category10",cellSize:h=150,cellGap:u=4,pointRadius:d=2,pointOpacity:f=.5,diagonal:g="histogram",histogramBins:y=20,brushMode:m="crossfilter",hoverMode:p=!0,unselectedOpacity:v=.1,showGrid:b=!1,tooltip:x,showLegend:w,idAccessor:k,className:A,onObservation:E,chartId:S}=n,O="splom",M="splom-hover",N=p?"hover":m?"brush":"hover",L=ze(e=>e.clearSelection),[j,_]=i(null),B=s(()=>{L(M),_(null)},[L,M]),W=t(()=>(o||[]).map((e,t)=>void 0!==e[ct]?e:Object.assign(Object.assign({},e),{[ct]:t})),[o]),$=De(W,a,c),z=void 0!==w?w:!!a,C=t(()=>{if(!z||!a)return null;const e="string"==typeof a?a:null;return e?[...new Set(W.map(t=>t[e]))].map(e=>({label:e+"",color:$?$(e+""):Fe})):null},[z,a,W,$]),H=t(()=>({display:"grid",gridTemplateColumns:"40px "+r.map(()=>h+"px").join(" "),gridTemplateRows:r.map(()=>h+"px").join(" ")+" 40px",gap:u+"px",width:"fit-content"}),[r,h,u,40]);return e.createElement("div",{className:A,style:{position:"relative"}},C&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},C.map(t=>e.createElement("div",{key:t.label,style:{display:"flex",alignItems:"center",gap:4}},e.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.createElement("span",{style:{fontSize:11}},t.label)))),e.createElement("div",{style:H,onMouseLeave:"hover"===N?B:void 0},r.map((t,n)=>e.createElement(e.Fragment,{key:"row-"+t},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},l[t]||t),r.map((o,i)=>n===i?"label"===g?e.createElement(gt,{key:"diag-"+t,label:l[t]||t,cellSize:h}):e.createElement(ft,{key:"diag-"+t,data:W,field:t,label:l[t]||t,cellSize:h,bins:y,colorBy:a,colorScale:$,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,mode:N}):e.createElement(dt,{key:`cell-${t}-${o}`,data:W,xField:o,yField:t,fieldLabels:l,cellSize:h,pointRadius:d,pointOpacity:f,colorBy:a,colorScale:$,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,showGrid:b,tooltip:x,mode:N,onPointHover:"hover"===N?(e,s,r)=>{e?(_({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,px:null!=s?s:0,py:null!=r?r:0}),E&&E({type:"hover",datum:e,x:null!=s?s:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})):(_(null),E&&E({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S}))}:void 0})))),e.createElement("div",null)," ",r.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},l[t]||t))),j&&"hover"===N&&(()=>{const t=j.datum,n=l[j.xField]||j.xField,o=l[j.yField]||j.yField,i=a?"function"==typeof a?a(t):t[a]:null,s=k?"function"==typeof k?k(t):t[k]:"Row "+t[ct];return e.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(h+u)+j.px,top:j.rowIndex*(h+u)+j.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},e.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),e.createElement("div",null,n,": ",null!=t[j.xField]?Number(t[j.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[j.yField]?Number(t[j.yField]).toFixed(1):"–"),null!=i&&e.createElement("div",{style:{opacity:.8}},"string"==typeof a?a:"group",": ",i+""))})())}function mt(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,i={};return!o&&n&&(i.splom={resolution:n}),o&&(i["splom-hover"]={resolution:"union"}),e.createElement(at,{selections:i},e.createElement(yt,Object.assign({},t)))}function pt({width:t,height:n,margin:i,scales:s,brushDirection:l,extent:a,onBrush:c}){const h=o(null),u=o(null),g=o(!1),m=t+i.left+i.right,p=n+i.top+i.bottom;return r(()=>{if(!h.current||!s)return;const e=y(h.current).select(".brush-group"),o="x"===l?d().extent([[0,0],[t,n]]):f().extent([[0,0],[t,n]]);return o.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===l?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(o),u.current=o,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null)}},[s,t,n,l,c]),r(()=>{if(!u.current||!s||!h.current)return;const e=y(h.current).select(".brush-group"),t="x"===l?s.x:s.y;if(g.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(u.current.move,n)}else e.call(u.current.move,null);g.current=!1},[a,s,l]),e.createElement("svg",{ref:h,width:m,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function vt(n){var l,a;const{data:c,width:h=600,height:u=400,margin:d,className:f,title:g,xLabel:y,yLabel:m,xFormat:p,yFormat:v,xAccessor:b="x",yAccessor:x="y",lineBy:w,lineDataAccessor:k="coordinates",colorBy:A,colorScheme:E="category10",curve:S="linear",lineWidth:O=2,fillArea:M=!1,areaOpacity:N=.3,showPoints:L=!1,pointRadius:j=3,enableHover:_=!0,showGrid:B=!1,showLegend:W,tooltip:$,minimap:z={},renderBefore:C=!1,onBrush:H,brushExtent:P,frameProps:T={}}=n,F=c||[],[I,D]=i(null),G=null!=P?P:I,Y=s(e=>{P||D(e),null==H||H(e)},[P,H]),R=o(null),[X,q]=i(null);r(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=R.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[c]);const V=void 0!==(null===(l=F[0])||void 0===l?void 0:l[k]),U=t(()=>{if(V)return F;if(w){const e=F.reduce((e,t)=>{const n="function"==typeof w?w(t):t[w];if(!e[n]){const t={[k]:[]};"string"==typeof w&&(t[w]=n),e[n]=t}return e[n][k].push(t),e},{});return Object.values(e)}return[{[k]:F}]},[F,w,k,V]),Z=t(()=>V||w?U.flatMap(e=>{const t=e[k]||[];return w&&"string"==typeof w?t.map(t=>Object.assign(Object.assign({},t),{[w]:e[w]})):t}):F,[U,k,V,w,F]),J=De(F,A,E),K=t(()=>e=>{const t={strokeWidth:O};return t.stroke=A?Oe(e,A,J):Fe,M&&(t.fill=t.stroke,t.fillOpacity=N),t},[A,J,O,M,N]),Q=t(()=>z.lineStyle?z.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?Oe(e,A,J):Fe,t},[A,J,z.lineStyle]),ee=t(()=>{if(L)return e=>{const t={r:j,fillOpacity:1};return t.fill=A?Oe(e.parentLine||e,A,J):Fe,t}},[L,j,A,J]),{legend:te,margin:ne}=Ye({data:U,colorBy:A,colorScale:J,showLegend:W,userMargin:d}),oe=z.height||60,ie=t(()=>{var e,t,n,o,i,s,r,l;return{top:null!==(t=null===(e=z.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=z.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(s=null===(i=z.margin)||void 0===i?void 0:i.left)&&void 0!==s?s:ne.left,right:null!==(l=null===(r=z.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:ne.right}},[z.margin,ne]),se=z.brushDirection||"x",re=et({componentName:"MinimapChart",data:F,accessors:{xAccessor:b,yAccessor:x}});if(re)return e.createElement(Qe,{componentName:"MinimapChart",message:re,width:h,height:u});const le=M?"area":"line",ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:K},L&&{pointStyle:ee}),{size:[h,u],margin:ne,showAxes:!0,xLabel:y,yLabel:m,xFormat:p,yFormat:v,enableHover:_,showGrid:B}),te&&{legend:te}),g&&{title:g}),$&&{tooltipContent:Ze($)}),G&&{xExtent:G}),T),ce={chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:Q,size:[h,oe+ie.top+ie.bottom],margin:ie,showAxes:null!==(a=z.showAxes)&&void 0!==a&&a,background:z.background,enableHover:!1},he=e.createElement("div",{key:"minimap",style:{position:"relative",width:h,overflow:"hidden"}},e.createElement(Ae,Object.assign({ref:R},ce)),e.createElement(pt,{width:h-ie.left-ie.right,height:oe,margin:ie,scales:X,brushDirection:se,extent:G,onBrush:Y})),ue=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(Ae,Object.assign({},ae)));return e.createElement("div",{className:"minimap-chart"+(f?" "+f:"")},C?he:ue,C?ue:he)}mt.displayName="ScatterplotMatrix",vt.displayName="MinimapChart";export{nt as AreaChart,st as BubbleChart,rt as Heatmap,tt as LineChart,vt as MinimapChart,it as Scatterplot,mt as ScatterplotMatrix,ot as StackedAreaChart,Ae as StreamXYFrame};
|