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/network.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-interpolate"),n=require("d3-sankey-circular"),o=require("d3-scale-chromatic"),r=require("d3-shape"),a=require("d3-force"),i=require("d3-scale"),s=require("d3-array"),l=require("d3-chord"),c=require("d3-hierarchy"),d=require("labella"),u=require("regression"),y=require("d3-contour"),p=require("d3-hexbin");function h(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const g=f(e),m=h(d),x=h(u),v={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},b={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class k{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n){for(let o=0;this.capacity>o;o++){const r=this.particles[o];if(!r.active)continue;const a=n[r.edgeIndex];if(!a||!a.bezier){r.active=!1;continue}if(r.t+=e*t,r.t>=1){r.active=!1;continue}const i=E(a.bezier,r.t,r.offset);r.x=i.x,r.y=i.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function E(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,a=t*r,i=Math.min(Math.floor(a),r-1),s=a-i,[l,c,d,u]=e[i],y=M(l,c,d,u,s),p=u.x-l.x,h=u.y-l.y,f=Math.sqrt(p*p+h*h);if(f>.001){const e=p/f;y.x+=-h/f*n*o*2,y.y+=e*n*o*2}return y}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,a,i]=e.points,s=M(o,r,a,i,t),l=i.x-o.x,c=i.y-o.y,d=Math.sqrt(l*l+c*c);if(d>.001){const t=l/d;s.x+=-c/d*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function M(e,t,n,o,r){const a=1-r,i=a*a,s=i*a,l=r*r,c=l*r;return{x:s*e.x+3*i*r*t.x+3*a*l*n.x+c*o.x,y:s*e.y+3*i*r*t.y+3*a*l*n.y+c*o.y}}const A=(e=1)=>(t,n)=>{const o=t[t.length-1];return o&&Math.round(o.x/e)===Math.round(n.x/e)&&Math.round(o.y/e)===Math.round(n.y/e)||t.push(n),t},S=e=>{let n,o,r,a,i,s,l,c,d;return"down"===e.direction?(n=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,a=e.y0+e.sankeyWidth/2,i=e.source.y1,s=e.target.y0,l=t.interpolateNumber(i,s),c=l(.5),d=l(.5),`M${n},${i}C${n},${c} ${o},${d} ${o},${s}L${r},${s}C${r},${d} ${a},${c} ${a},${i}Z`):(n=e.source.x1,o=e.target.x0,l=t.interpolateNumber(n,o),r=l(.5),a=l(.5),i=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,d=e.y0+e.sankeyWidth/2,`M${n},${i}C${r},${i} ${a},${s} ${o},${s}L${o},${c}C${a},${c} ${r},${d} ${n},${d}Z`)};function $(e){const t=function(){const e=r.line();let t=function(e){return e.x},n=function(e){return e.y},o=function(e){return e.r},a=r.curveLinearClosed;function i(r){if(r.multiple){const i=o,s=r.multiple.reduce((e,t)=>e+t.weight,0);o=()=>s;let c=l(r.points).filter(e=>"forward"===e.direction).reduce(A(),[]);const d=[];return r.multiple.forEach((e,t)=>{o=()=>e.weight;const n=l(c);d.push(n);const a=r.multiple[t+1];if(a){const e=n.reverse().filter(e=>"back"===e.direction).reduce(A(),[]);o=()=>a.weight;const t=l(e);c=t.reverse().filter(e=>"back"===e.direction).reduce(A(),[])}}),o=i,d.map(o=>e.x(t).y(n).curve(a)(o))}const i=l(r).reduce(A(),[]);return e.x(t).y(n).curve(a)(i)}return i.x=function(e){return arguments.length?(t=e,i):t},i.y=function(e){return arguments.length?(n=e,i):n},i.r=function(e){return arguments.length?(o=e,i):o},i.interpolate=function(e){return arguments.length?(a=e,i):a},i;function s(e){const r=n(e.target)-n(e.source),a=t(e.target)-t(e.source),i=Math.atan2(a,r)+Math.PI/2,s=i+.5*Math.PI,l=i+.5*Math.PI;return{x1:t(e.source)+o(e.source)*Math.cos(s),y1:n(e.source)-o(e.source)*Math.sin(s),x2:t(e.target)+o(e.target)*Math.cos(l),y2:n(e.target)-o(e.target)*Math.sin(l)}}function l(e){const t=[];let n=0,o={x1:0,y1:0,x2:0,y2:0};for(;e.length>n;){if(n!==e.length-1&&(o=s({source:e[n],target:e[n+1]}),t.push({x:o.x1,y:o.y1,direction:"forward"},{x:o.x2,y:o.y2,direction:"forward"}),t.length>3)){const e=t.length-1,n={a:t[e-3],b:t[e-2]},o={a:t[e-1],b:t[e]},r=c(n.a.x,n.a.y,n.b.x,n.b.y,o.a.x,o.a.y,o.b.x,o.b.y);!0===r.found&&(n.b.x=r.x,n.b.y=r.y,o.a.x=r.x,o.a.y=r.y)}n++}for(n--;n>=0;){if(0!==n&&(o=s({source:e[n],target:e[n-1]}),t.push({x:o.x1,y:o.y1,direction:"back"},{x:o.x2,y:o.y2,direction:"back"}),t.length>3)){const e=t.length-1,n={a:t[e-3],b:t[e-2]},o={a:t[e-1],b:t[e]},r=c(n.a.x,n.a.y,n.b.x,n.b.y,o.a.x,o.a.y,o.b.x,o.b.y);!0===r.found&&(n.b.x=r.x,n.b.y=r.y,o.a.x=r.x,o.a.y=r.y)}n--}return t}function c(e,t,n,o,r,a,i,s){let l,c;const d={x:null,y:null,found:!1},u=(s-a)*(n-e)-(i-r)*(o-t);if(0===u)return d;l=t-a,c=e-r;const y=(n-e)*l-(o-t)*c;return l=((i-r)*l-(s-a)*c)/u,c=y/u,d.x=e+l*(n-e),d.y=t+l*(o-t),l>0&&1>l&&c>0&&1>c&&(d.found=!0),d}}();return t.x(e=>e.x),t.y(e=>e.y),t.r(()=>e.sankeyWidth/2),t("down"===e.direction?[{x:e.circularPathData.sourceY,y:e.circularPathData.sourceX},{x:e.circularPathData.sourceY,y:e.circularPathData.leftFullExtent},{x:e.circularPathData.verticalFullExtent,y:e.circularPathData.leftFullExtent},{x:e.circularPathData.verticalFullExtent,y:e.circularPathData.rightFullExtent},{x:e.circularPathData.targetY,y:e.circularPathData.rightFullExtent},{x:e.circularPathData.targetY,y:e.circularPathData.targetX}]:[{x:e.circularPathData.sourceX,y:e.circularPathData.sourceY},{x:e.circularPathData.leftFullExtent,y:e.circularPathData.sourceY},{x:e.circularPathData.leftFullExtent,y:e.circularPathData.verticalFullExtent},{x:e.circularPathData.rightFullExtent,y:e.circularPathData.verticalFullExtent},{x:e.circularPathData.rightFullExtent,y:e.circularPathData.targetY},{x:e.circularPathData.targetX,y:e.circularPathData.targetY}])}const w={left:n.sankeyLeft,right:n.sankeyRight,center:n.sankeyCenter,justify:n.sankeyJustify},P={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,r){var a,i,s,l;if(0===e.length)return;const c="vertical"===o.orientation?"down":"right",d=o.nodeAlign||"justify",u=null!==(a=o.nodeWidth)&&void 0!==a?a:15,y=null!==(i=o.nodePaddingRatio)&&void 0!==i?i:.05,p=null!==(s=o.iterations)&&void 0!==s?s:100,h=e.map(e=>Object.assign({},e)),f=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));let g;g="down"===c?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const m=n.sankeyCircular().extent(g).links(f).nodes(h).nodeAlign(w[d]||n.sankeyJustify).nodeId(e=>e.id).nodeWidth(u).iterations(p);m.nodePaddingRatio&&m.nodePaddingRatio(y),m();for(const t of h){const n=e.find(e=>e.id===t.id);n&&(n.x0=t.x0,n.x1=t.x1,n.y0=t.y0,n.y1=t.y1,n.value=t.value,n.depth=t.depth,n.sourceLinks=t.sourceLinks,n.targetLinks=t.targetLinks,n.width=t.x1-t.x0,n.height=t.y1-t.y0,n.x=t.x0+(t.x1-t.x0)/2,n.y=t.y0+(t.y1-t.y0)/2)}for(const n of f){const o=n.source,r=n.target,a="object"==typeof o&&null!==o?o.id:o+"",i="object"==typeof r&&null!==r?r.id:r+"",s=t.find(e=>("string"==typeof e.source?e.source:e.source.id)===a&&("string"==typeof e.target?e.target:e.target.id)===i);if(s){s.y0=n.y0,s.y1=n.y1,s.sankeyWidth=null!==(l=n.width)&&void 0!==l?l:0,s.circular=!!n.circular,s.circularPathData=n.circularPathData,s.direction=c;const t=e.find(e=>e.id===a),o=e.find(e=>e.id===i);t&&(s.source=t),o&&(s.target=o)}}},buildScene(e,t,n,r){var a,i;const s="vertical"===n.orientation?"down":"right",l=n.nodeStyle,c=n.edgeStyle,d=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5,u=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:o.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const h=[],f=[],g=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=l?l(t):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};h.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const m=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of m){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o;o=e.circular&&e.circularPathData?$(e):S(e);let r="#999";c?r=c(e).fill||r:"target"===u&&n?r=p.get(n.id)||r:t&&(r=p.get(t.id)||r);const a=c?c(e):{},s={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:d,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};f.push({type:"bezier",pathD:o,bezierCache:e.bezier,style:s,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const a=t?t(n):n.id;if(!a)continue;let i,l,c;"down"===s?(i=n.x0+e/2,l=n.y1+14,c="middle"):(r[0]/2>n.x0+e/2?(i=n.x0-6,c="end"):(i=n.x1+6,c="start"),l=n.y0+o/2),g.push({x:i,y:l,text:a+"",anchor:c,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:h,sceneEdges:f,labels:g}}},D={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const s=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),l=null!==(i=n.forceStrength)&&void 0!==i?i:.1,c=o[0]/2,d=o[1]/2;for(let t=0;e.length>t;t++){const n=e[t];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(t+.5),o=2.399963229728653*t;n.x=c+e*Math.cos(o),n.y=d+e*Math.sin(o)}}const u=N(n.nodeSize,n.nodeSizeRange,e),y=a.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),p=o[1]/o[0],h=a.forceSimulation().force("charge",a.forceManyBody().strength(e=>-25*(e=>u(e))(e))).force("x",a.forceX(o[0]/2).strength(.1*p)).force("y",a.forceY(o[1]/2).strength(.1));if(h.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));h.force("link",y),h.force("link").links(e)}.1>h.alpha()&&h.alpha(1),h.stop();for(let e=0;s>e;++e)h.tick();for(const n of t){if("string"==typeof n.source){const t=e.find(e=>e.id===n.source);t&&(n.source=t)}if("string"==typeof n.target){const t=e.find(e=>e.id===n.target);t&&(n.target=t)}}},buildScene(e,t,n,r){var a,i,s;const l=n.nodeStyle,c=n.edgeStyle,d=N(n.nodeSize,n.nodeSizeRange,e),u=Array.isArray(n.colorScheme)?n.colorScheme:o.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,u[t%u.length])});const p=[],h=[],f=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),n=l?l(t):{},o={fill:n.fill||y.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:2,opacity:n.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}for(const n of t){const t="object"==typeof n.source?n.source:j(e,n.source),o="object"==typeof n.target?n.target:j(e,n.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=c?c(n):{},a={stroke:r.stroke||"#999",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:1,opacity:null!==(s=r.opacity)&&void 0!==s?s:.6};h.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:a,datum:n})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=d(n);f.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var g;return{sceneNodes:p,sceneEdges:h,labels:f}}};function j(e,t){return e.find(e=>e.id===t)}function N(e,t,n){var o,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const a=t||[5,20],l=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>a[0];const c=null!==(o=s.min(l))&&void 0!==o?o:0,d=null!==(r=s.max(l))&&void 0!==r?r:1;if(c===d)return()=>(a[0]+a[1])/2;const u=i.scaleLinear().domain([c,d]).range(a).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?a[0]:u(o)}}const O=o.schemeCategory10,C={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:a=.01,groupWidth:i=20,sortGroups:s}=n,c=Math.min(o[0],o[1])/2,d=c-i,u=o[0]/2,y=o[1]/2,p=(h=n.valueAccessor)?"function"==typeof h?h:e=>{var t;return null!==(t=e[h])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,m=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),o=f.get(t);if(void 0===n||void 0===o)continue;const r=p(e);m[n][o]=r}const x=l.chord().padAngle(a);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=r.arc().innerRadius(d).outerRadius(c);for(const t of b){const n=e[t.index],o=k.centroid(t);n.x=o[0]+u,n.y=o[1]+y,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}for(const n of t){const t="string"==typeof n.source?n.source:n.source.id,o="string"==typeof n.target?n.target:n.target.id,r=e.find(e=>e.id===t),a=e.find(e=>e.id===o);r&&(n.source=r),a&&(n.target=a)}for(const n of v){const o=e[n.source.index].id,r=e[n.target.index].id,a=t.find(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;return t===o&&n===r||t===r&&n===o});a&&(a.chordData=n)}},buildScene(e,t,n,o){var r,a;const{groupWidth:i=20,edgeOpacity:s=.5}=n,c=Math.min(o[0],o[1])/2,d=c-i,u=o[0]/2,y=o[1]/2,p=n.nodeStyle,h=n.edgeStyle,f=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:O,m=new Map;e.forEach((e,t)=>{m.set(e.id,g[t%g.length])});const x=l.ribbon().radius(d),v=[],b=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let a;a=p?p(n).fill||m.get(n.id)||g[t%g.length]:m.get(n.id)||g[t%g.length];const i=p?p(n):{},s={fill:a,stroke:i.stroke||"black",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:1,opacity:i.opacity};v.push({type:"arc",cx:u,cy:y,innerR:d,outerR:c,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=x({source:Object.assign(Object.assign({},t.source),{startAngle:t.source.startAngle-Math.PI/2,endAngle:t.source.endAngle-Math.PI/2}),target:Object.assign(Object.assign({},t.target),{startAngle:t.target.startAngle-Math.PI/2,endAngle:t.target.endAngle-Math.PI/2})});if(!n)continue;const o=W(n,u,y);let r="#999";if(h)r=h(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===f&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const i=h?h(e):{},l={fill:r,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};b.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(E=n.nodeLabel)?"function"==typeof E?E:e=>e[E]||e.id:null,o=c+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const a=(e.startAngle+e.endAngle)/2,i=a-Math.PI/2;k.push({x:u+Math.cos(i)*o,y:y+Math.sin(i)*o,text:r+"",anchor:a>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var E;return{sceneNodes:v,sceneEdges:b,labels:k}}};function W(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let a=0;for(;o.length>a;){const e=o[a];if("M"===e||"L"===e)for(r.push(e),a++;o.length>a&&!isNaN(Number(o[a]));)r.push(Number(o[a])+t+""),a++,o.length>a&&!isNaN(Number(o[a]))&&(r.push(Number(o[a])+n+""),a++);else if("C"===e)for(r.push(e),a++;o.length>a&&!isNaN(Number(o[a]));)for(let e=0;3>e&&o.length>a&&!isNaN(Number(o[a]));e++)r.push(Number(o[a])+t+""),a++,o.length>a&&!isNaN(Number(o[a]))&&(r.push(Number(o[a])+n+""),a++);else if("Q"===e)for(r.push(e),a++;o.length>a&&!isNaN(Number(o[a]));)for(let e=0;2>e&&o.length>a&&!isNaN(Number(o[a]));e++)r.push(Number(o[a])+t+""),a++,o.length>a&&!isNaN(Number(o[a]))&&(r.push(Number(o[a])+n+""),a++);else if("A"===e)for(r.push(e),a++;o.length>a&&!isNaN(Number(o[a]));)r.push(o[a++]),o.length>a&&r.push(o[a++]),o.length>a&&r.push(o[a++]),o.length>a&&r.push(o[a++]),o.length>a&&r.push(o[a++]),o.length>a&&(r.push(Number(o[a])+t+""),a++),o.length>a&&(r.push(Number(o[a])+n+""),a++);else"Z"===e||"z"===e?(r.push(e),a++):(r.push(o[a]),a++)}return r.join(" ")}const L={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const a=n.__hierarchyRoot;if(!a)return;const i=n.chartType,s=(l=n.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const d=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=c.hierarchy(a,s);u.sum(d),u.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[y,p]=o;switch(i){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=c.tree();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(u,n,y,p);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=c.cluster();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(u,n,y,p);break;case"treemap":!function(e,t,n,o){var r,a;const i=null!==(r=t.padding)&&void 0!==r?r:4,s=null!==(a=t.paddingTop)&&void 0!==a?a:0,l=c.treemap().size([n,o]).tile(c.treemapBinary).padding(i);s>0&&l.paddingTop(s),l(e)}(u,n,y,p);break;case"circlepack":!function(e,t,n,o){var r;const a=null!==(r=t.padding)&&void 0!==r?r:4;c.pack().size([n,o]).padding(a)(e)}(u,n,y,p);break;case"partition":!function(e,t,n,o){var r;c.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,n,y,p)}const h=u.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const o=h[t],a={id:B(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===i||"cluster"===i?_(a,o,n):"treemap"===i||"partition"===i?z(a,o):"circlepack"===i&&F(a,o),a.__hierarchyNode=o,e.push(a),f.set(o,a)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),o=f.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),a=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,a){var i,s,l,c,d;const u=[],y=[],p=[],h=n.treeOrientation||"vertical",f="radial"===h,g=o[0]/2,m=o[1]/2,x="number"==typeof(v=n.nodeSize)?v:5;var v;for(const t of e){let e=t.x,n=t.y;f&&(e+=g,n+=m);const o=r(t),a={fill:o.fill||"#4d430c",stroke:o.stroke||"#fff",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:o.opacity};u.push({type:"circle",cx:e,cy:n,r:x,style:a,datum:t,id:t.id,label:t.id,depth:t.depth})}const b=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,i=n.x,s=n.y;f&&(o+=g,r+=m,i+=g,s+=m);const d=T(o,r,i,s,h),u=a(e),p={fill:"none",stroke:u.stroke||"#999",strokeWidth:null!==(l=u.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=u.opacity)&&void 0!==c?c:b};y.push({type:"curved",pathD:d,style:p,datum:e})}if(!1!==n.showLabels){const t=R(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,a,i=n.x,s=n.y;if(f&&(i+=g,s+=m),f){const e=i-g,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=i+e/n*10,r=s+t/n*10,a=0>e?"end":"start"):(o=i,r=s-12,a="middle")}else"horizontal"===h?((null===(d=n.data)||void 0===d?void 0:d.children)&&0!==n.data.children.length?(o=i-x-6,a="end"):(o=i+x+6,a="start"),r=s):(o=i,r=s+x+14,a="middle");p.push({x:o,y:r,text:e+"",anchor:a,baseline:"middle",fontSize:11})}}return{sceneNodes:u,sceneEdges:y,labels:p}}(e,t,n,o,r,a);case"treemap":case"partition":return function(e,t,n,o){var r,a;const i=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const d={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};i.push({type:"rect",x:n.x0,y:n.y0,w:e,h:a,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=R(t.nodeLabel);for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;if((null===(a=o.data)||void 0===a?void 0:a.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const i=n?n(o):o.id;i&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:i,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,a,i,s,l;const c=[],d=[],u=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(n);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=u[n.depth%u.length]);const d={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(a=s.strokeWidth)&&void 0!==a?a:1,opacity:null!==(i=s.opacity)&&void 0!==i?i:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=R(t.nodeLabel);for(const t of e){const e=null!==(s=t.__radius)&&void 0!==s?s:5,o=n?n(t):t.id;if(!o)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);d.push({x:t.x,y:r?t.y:t.y-e+14,text:o+"",anchor:"middle",baseline:r?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:r?void 0:"#000",stroke:r?void 0:"#fff",strokeWidth:r?void 0:3,paintOrder:r?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:d}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function _(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function z(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function F(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function T(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}function B(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function R(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}const I={sankey:P,force:D,chord:C,tree:L,cluster:L,treemap:L,circlepack:L,partition:L};function Y(e){return I[e]}class X{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},v),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new k(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},v),e.tensionConfig),"sankey"===e.chartType&&e.showParticles?this.particlePool||(this.particlePool=new k(2e3)):this.particlePool=null}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:a="target",valueAccessor:i="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof a?a:e=>e[a],d="function"==typeof i?i:e=>{var t;return null!==(t=e[i])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},q(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(d(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},q(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},q(n)),{data:e})),this.edges.set(`${t}\0${n}`,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let a=!1;this.nodes.has(t)||(this.nodes.set(t,q(t)),this.tension+=this.tensionConfig.newNode,a=!0),this.nodes.has(n)||(this.nodes.set(n,q(n)),this.tension+=this.tensionConfig.newNode,a=!0);const i=this.edgeKey(t,n),s=this.edges.get(i);return s?(s.value+=o,this.tension+=this.tensionConfig.weightChange):(this.edges.set(i,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.tension+=this.tensionConfig.newEdge,a=!0),r||a||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Y(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());if(0!==n.length||t.hierarchical){if(this.prepareForRelayout(),t.computeLayout(n,o,this.config,e),t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const e of n)this.nodes.set(e.id,e);for(const e of o)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration}),this.layoutVersion++}}buildScene(e){const t=Y(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:a,labels:i}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=a,this.labels=i}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*n,e.x1=e._prevX1+(e._targetX1-e._prevX1)*n,e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,n,o){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const a=n.y1,i=o.y0,s=t.interpolateNumber(a,i);return{circular:!1,points:[{x:e.y0,y:a},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:i}],halfWidth:r}}const a=n.x1,i=o.x0,s=t.interpolateNumber(a,i);return{circular:!1,points:[{x:a,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}buildCircularBezier(e){const t=(e.sankeyWidth||1)/2,n=e.circularPathData;let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.targetY,y:n.rightFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.leftFullExtent,y:n.sourceY},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],a=n.x-t.x,i=n.y-t.y;r.push([t,{x:t.x+a/3,y:t.y+i/3},{x:t.x+2*a/3,y:t.y+2*i/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.particlePool&&this.particlePool.clear()}}function q(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function G(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,a=Math.sqrt(o*o+r*r);return a>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n);case"rect":return function(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,a=Math.sqrt(o*o+r*r);if(e.innerR-2>a||a>e.outerR+2)return null;let i=Math.atan2(r,o);0>i&&(i+=2*Math.PI);let s,l=e.startAngle,c=e.endAngle;if(0>l&&(l+=2*Math.PI),0>c&&(c+=2*Math.PI),s=l>c?i>=l||c>=i:i>=l&&c>=i,s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}function V(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const a=new Path2D(e.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(a,t,n)){const a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,i="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:a&&i?(a.x1+i.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,a=o*o+r*r;if(0===a)return null;let i=((t-e.x1)*o+(n-e.y1)*r)/a;i=Math.max(0,Math.min(1,i));const s=e.x1+i*o,l=e.y1+i*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=document.createElement("canvas").getContext("2d");if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0}}catch(e){}return null}(e,t,n);default:return null}}function H(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:a,labels:i,title:s,legend:l,foregroundGraphics:c,annotations:d,svgAnnotationRules:u}=e;return g.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${a.left},${a.top})`},i.map((e,t)=>g.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),d&&u&&d.map((e,o)=>{const r=u(e,o,{width:t,height:n});return r?g.createElement(g.Fragment,{key:"annotation-"+o},r):null}),c),s&&"string"==typeof s?g.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?g.createElement("foreignObject",{x:0,y:0,width:o,height:a.top},s):null,l&&"object"==typeof l&&"legendGroups"in l?g.createElement("g",{transform:`translate(${o-a.right+10},${a.top})`},l.legendGroups.map((e,t)=>{var n;return g.createElement("g",{key:"legend-group-"+t},null===(n=e.items)||void 0===n?void 0:n.map((e,t)=>g.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},g.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),g.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):l?g.createElement("g",{transform:`translate(${o-a.right+10},${a.top})`},l):null)}function K(e,t){var n,o,r,a;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(i)),e.restore()}function J(e,t){var n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),e.restore()}function Z(e,t){var n,o,r,a;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(i)),e.restore()}function Q(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}H.displayName="NetworkSVGOverlay";const U={category10:o.schemeCategory10,tableau10:o.schemeTableau10,set3:o.schemeSet3,blues:o.interpolateBlues,reds:o.interpolateReds,greens:o.interpolateGreens,oranges:o.interpolateOranges,purples:o.interpolatePurples,viridis:o.interpolateViridis,plasma:o.interpolatePlasma},ee=o.schemeCategory10;function te(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):ee[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+""))%ee.length]}function ne(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return i.scaleOrdinal().domain(o).range(n).unknown("#999");const a=U[n]||U.category10;if(r&&"function"==typeof a)return e=>a(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(a)?a:ee;return i.scaleOrdinal().domain(o).range(e).unknown("#999")}}const oe={top:20,right:80,bottom:20,left:80},re={top:40,right:40,bottom:40,left:40},ae=new Set(["chord","force","circlepack"]),ie=[800,600],se={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 le({data:e}){var t,n,o,r,a,i;if("edge"===e.type){const t=e.data;return g.createElement("div",{className:"semiotic-tooltip",style:se},g.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,l=null==s?void 0:s.__hierarchyNode;if(l){const e=[];let a=l;for(;a;){const i=null!==(r=null!==(n=null===(t=a.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=i&&e.unshift(i+""),a=a.parent}e.length>1&&e.shift();const i=e.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:se},g.createElement("div",null,e.map((e,t)=>g.createElement("span",{key:t},t>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===i?g.createElement("strong",null,e):g.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(a=s.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(i=s.targetLinks)||void 0===i?void 0:i.length)||0),d=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:se},g.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,d!==c&&` (weighted: ${d.toLocaleString()})`))}const ce=e.forwardRef(function(t,n){const{chartType:o,nodes:r,edges:a,data:i,initialEdges:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:d="target",valueAccessor:u="value",childrenAccessor:y,hierarchySum:p,orientation:h="horizontal",nodeAlign:f="justify",nodePaddingRatio:m=.05,nodeWidth:x=15,iterations:k=300,forceStrength:E=.1,padAngle:M=.01,groupWidth:A=20,sortGroups:S,edgeSort:$,treeOrientation:w="vertical",edgeType:P="curve",padding:D,paddingTop:j,tensionConfig:N,showParticles:O=!1,particleStyle:C,nodeStyle:W,edgeStyle:L,colorBy:_,colorScheme:z="category10",edgeColorBy:F="source",edgeOpacity:T=.5,colorByDepth:B=!1,nodeSize:R=8,nodeSizeRange:I=[5,20],nodeLabel:Y,showLabels:q=!0,size:U=ie,margin:te,className:ne,background:se,enableHover:ce=!0,tooltipContent:de,onTopologyChange:ue,annotations:ye,svgAnnotationRules:pe,legend:he,title:fe,foregroundGraphics:ge,backgroundGraphics:me}=t,xe=ae.has(o)?re:oe,ve=Object.assign(Object.assign({},xe),te),be=U[0]-ve.left-ve.right,ke=U[1]-ve.top-ve.bottom,Ee=e.useMemo(()=>Object.assign(Object.assign({},v),N),[N]),Me=e.useMemo(()=>Object.assign(Object.assign({},b),C),[C]),Ae=e.useMemo(()=>({chartType:o,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:d,valueAccessor:u,childrenAccessor:y,hierarchySum:p,orientation:h,nodeAlign:f,nodePaddingRatio:m,nodeWidth:x,iterations:k,forceStrength:E,padAngle:M,groupWidth:A,sortGroups:S,edgeSort:$,treeOrientation:w,edgeType:P,padding:D,paddingTop:j,tensionConfig:Ee,showParticles:O,particleStyle:Me,nodeStyle:W,edgeStyle:L,nodeLabel:Y,showLabels:q,colorBy:_,colorScheme:z,edgeColorBy:F,edgeOpacity:T,colorByDepth:B,nodeSize:R,nodeSizeRange:I}),[o,l,c,d,u,y,p,h,f,m,x,k,E,M,A,S,$,w,P,D,j,Ee,O,Me,W,L,Y,q,_,z,F,T,B,R,I]),Se=e.useRef(null),$e=e.useRef(0),we=e.useRef(0),Pe=e.useRef(!0),De=e.useRef(()=>{}),je=e.useRef(null);je.current||(je.current=new X(Ae));const[Ne,Oe]=e.useState(null),[Ce,We]=e.useState(0),[Le,_e]=e.useState(0),ze=e.useRef(null),Fe=e.useRef(new Map),Te=e.useRef(0),Be=e.useCallback(e=>{if("function"==typeof _)return _(e);if("string"==typeof _&&e.data){const t=e.data[_];if(void 0!==t){if(!Fe.current.has(t+"")){const e=Array.isArray(z)?z:ee;Fe.current.set(t+"",e[Te.current++%e.length])}return Fe.current.get(t+"")}}if(!Fe.current.has(e.id)){const t=Array.isArray(z)?z:ee;Fe.current.set(e.id,t[Te.current++%t.length])}return Fe.current.get(e.id)},[_,z]);e.useCallback(e=>{if("function"==typeof F)return F(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===F&&n?Be(n):t?Be(t):"#999"},[F,Be]);const Re=e.useCallback(e=>{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===(Me.colorBy||"source")&&n?Be(n):t?Be(t):"#999"},[Me.colorBy,Be]),Ie="sankey"===o&&O,Ye=e.useCallback(()=>{$e.current&&!Ie||$e.current||($e.current=requestAnimationFrame(()=>De.current()))},[Ie]);e.useEffect(()=>{var e;null===(e=je.current)||void 0===e||e.updateConfig(Ae),Pe.current=!0,Ye()},[Ae,Ye]);const Xe=e.useCallback(()=>{const e=je.current;if(e&&(e.runLayout([be,ke]),e.buildScene([be,ke]),Pe.current=!0,We(e.layoutVersion),ue)){const{nodes:t,edges:n}=e.getLayoutData();ue(t,n)}},[be,ke,ue]),qe=e.useCallback(e=>{const t=je.current;t&&(t.ingestEdge(e)&&Xe(),Ye())},[Xe,Ye]),Ge=e.useCallback(e=>{const t=je.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&Xe(),Ye()},[Xe,Ye]),Ve=e.useCallback(()=>{var e;null===(e=je.current)||void 0===e||e.clear(),Fe.current.clear(),Te.current=0,We(0),Oe(null),ze.current=null,Pe.current=!0,Ye()},[Ye]),He=e.useCallback(()=>{const e=je.current;e&&(e.tension+=999,Xe(),Ye())},[Xe,Ye]);e.useImperativeHandle(n,()=>({push:qe,pushMany:Ge,clear:Ve,getTopology:()=>{var e,t;return null!==(t=null===(e=je.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},relayout:He,getTension:()=>{var e,t;return null!==(t=null===(e=je.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[qe,Ge,Ve,He]);const Ke=["tree","cluster","treemap","circlepack","partition"].includes(o),Je=Ke?i||(Array.isArray(a)?void 0:a):void 0;e.useEffect(()=>{const e=je.current;if(e)if(Ke&&Je)e.ingestHierarchy(Je,[be,ke]),e.buildScene([be,ke]),Pe.current=!0,Ye();else{const t=r||[],n=Array.isArray(a)?a:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[be,ke]),e.buildScene([be,ke]),Pe.current=!0,Ye()}},[r,a,i,Je,Ke,be,ke,Ae,Ye]),e.useEffect(()=>{s&&s.length>0&&Ge(s)},[]);const Ze=e.useRef(()=>{}),Qe=e.useRef(()=>{});Ze.current=e=>{if(!ce)return;const t=Se.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-ve.left,r=e.clientY-n.top-ve.top;if(0>o||o>be||0>r||r>ke)return void(ze.current&&(ze.current=null,Oe(null),Ye()));const a=je.current;if(!a)return;const i=function(e,t,n,o,r=30){let a=null,i=r,s=1/0;for(const t of e){const e=G(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(a=e,s=n)}else i>e.distance&&(a=e,i=e.distance)}if(a)return a;for(const e of t){const t=V(e,n,o);t&&i>t.distance&&(a=t,i=t.distance)}return a}(a.sceneNodes,a.sceneEdges,o,r);if(!i)return void(ze.current&&(ze.current=null,Oe(null),Ye()));const s={type:i.type,data:i.datum,x:i.x,y:i.y};ze.current=s,Oe(s),Ye()},Qe.current=()=>{ze.current&&(ze.current=null,Oe(null),Ye())};const Ue=e.useCallback(e=>Ze.current(e),[]),et=e.useCallback(()=>Qe.current(),[]);De.current=()=>{var e;$e.current=0;const t=Se.current;if(!t)return;const n=t.getContext("2d");if(!n)return;const o=je.current;if(!o)return;const r=performance.now(),a=we.current?Math.min((r-we.current)/1e3,.1):.016;we.current=r;const i=o.advanceTransition(r);(i||Pe.current)&&o.buildScene([be,ke]);const s="undefined"!=typeof window&&window.devicePixelRatio||1;if(t.width=U[0]*s,t.height=U[1]*s,t.style.width=U[0]+"px",t.style.height=U[1]+"px",n.scale(s,s),n.translate(ve.left,ve.top),n.clearRect(-ve.left,-ve.top,U[0],U[1]),se&&(n.fillStyle=se,n.fillRect(0,0,be,ke)),function(e,t){for(const n of t)switch(n.type){case"bezier":K(e,n);break;case"line":J(e,n);break;case"ribbon":Z(e,n);break;case"curved":Q(e,n)}}(n,o.sceneEdges),function(e,t){var n,o,r;for(const a of t){if("rect"!==a.type)continue;const t=a;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),e.restore())}}(n,o.sceneNodes),function(e,t){var n,o,r;for(const a of t){if("circle"!==a.type)continue;const t=a;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore())}}(n,o.sceneNodes),function(e,t){var n,o,r;for(const a of t){if("arc"!==a.type)continue;const t=a;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(n,o.sceneNodes),O&&o.particlePool){const t=Array.from(o.edges.values());if(t.length>0){!function(e,t,n,o){var r,a;const i=null!==(r=o.spawnRate)&&void 0!==r?r:b.spawnRate,s=null!==(a=o.maxPerEdge)&&void 0!==a?a:b.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const a=r.value*i*n,l=Math.floor(a),c=a-l;let d=l;Math.random()<c&&d++;for(let t=0;d>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(o.particlePool,t,a,Me);const r=.5*(null!==(e=Me.speedMultiplier)&&void 0!==e?e:1);o.particlePool.step(a,r,t),function(e,t,n,o,r){var a,i;const s=null!==(a=o.radius)&&void 0!==a?a:b.radius,l=null!==(i=o.opacity)&&void 0!==i?i:b.opacity;e.globalAlpha=l;for(let a=0;t.particles.length>a;a++){const i=t.particles[a];if(!i.active)continue;const l=n[i.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(i.x,i.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(n,o.particlePool,t,Me,Re)}}const l=Pe.current;Pe.current=!1,(l||i)&&_e(e=>e+1),(Ie||i)&&($e.current=requestAnimationFrame(()=>De.current()))},e.useEffect(()=>(Ye(),()=>{$e.current&&cancelAnimationFrame($e.current)}),[Ye]),e.useEffect(()=>{Pe.current=!0,Ye()},[o,be,ke,se,Ye]);const tt=ce&&Ne?g.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ve.left+Ne.x,top:ve.top+Ne.y,transform:`translate(${Ne.x>.6*be?"calc(-100% - 12px)":"12px"}, ${.3*ke>Ne.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},de?de(Ne):g.createElement(le,{data:Ne})):null,nt=je.current;return g.createElement("div",{className:"stream-network-frame"+(ne?" "+ne:""),style:{position:"relative",width:U[0],height:U[1]},onMouseMove:ce?Ue:void 0,onMouseLeave:ce?et:void 0},me&&g.createElement("svg",{style:{position:"absolute",top:0,left:0,width:U[0],height:U[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${ve.left},${ve.top})`},me)),g.createElement("canvas",{ref:Se,style:{position:"absolute",top:0,left:0}}),g.createElement(H,{width:be,height:ke,totalWidth:U[0],totalHeight:U[1],margin:ve,labels:(null==nt?void 0:nt.labels)||[],title:fe,legend:he,foregroundGraphics:ge,annotations:ye,svgAnnotationRules:pe,annotationFrame:Le}),tt)});ce.displayName="StreamNetworkFrame";const de=({xy:e,orient:t,i:n,className:o="",jaggedBase:r})=>{let a=`M${e.x1},${e.y1}L${e.x2},${e.y2}`;return r&&0===n&&(a=((e,t)=>{let n="";const{x1:o,x2:r,y1:a,y2:i}=t;if("left"===e||"right"===e){const t=Math.abs(r-o);n=((e,t,n,o)=>{const r=e/t;let a=0,i="M0,"+n;const s="right"===o?-1:1;for(;e>=a;)i+=`L${a},${n}`,e>a&&(i+=`L${a+r/2},${n+10*s}`),a+=r;return i})(t,Math.ceil(t/40),"right"===e?0:a,e)}else{const t=Math.abs(i-a);n=((e,t,n,o)=>{const r=e/t;let a=0,i=`M${n},0`;const s="bottom"===o?-1:1;for(;e>=a;)i+=`L${n},${a}`,e>a&&(i+=`L${n+10*s},${a+r/2}`),a+=r;return i})(t,Math.ceil(t/40),o,e)}return n})(t,e)),g.createElement("path",{key:n,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:a,className:`tick-line tick ${t} ${o}`})};function ue(e,t,n){const o=Math.abs(n.range()[1]-n.range()[0]);return e||(t||(t=Math.max(1,Math.floor(o/40))),e=n.ticks&&n.ticks(t)||n.domain()),e}function ye({t:e,o:t,w:n}){return"contour"!==e&&"boxplot"!==e||"left"!==t&&"right"!==t?0:n/2}function pe({t:e,o:t,w:n}){return"contour"!==e&&"boxplot"!==e||"top"!==t&&"bottom"!==t?0:n/2}function he(e){const{translation:t,orient:n,decoratedSummaryType:o,summaryWidth:r,renderedSummary:a,points:i}=e;return g.default.createElement("g",{className:"marginal-graphics",transform:`translate(${t[n]})`},g.default.createElement("g",{transform:`translate(${ye({t:o.type,o:n,w:r})},${pe({t:o.type,o:n,w:r})})`},a),i)}function fe(e){const{className:t,translation:n,position:o,rotation:r,labelName:a,anchorMod:i}=e;return g.default.createElement("g",{className:"axis-title "+t,transform:`translate(${[n[0]+o[0],n[1]+o[1]]}) rotate(${r})`},g.default.isValidElement(a)?a:g.default.createElement("text",{textAnchor:i},a))}function ge(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),n=Math.abs(t);return 1e9>n?1e6>n?1e4>n?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}function me(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const xe={fill:e=>g.createElement("rect",{style:e,width:20,height:20}),line:e=>g.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function ve(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,xe[n])(o(e,t)),r}function be(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:r=100,height:a=20,orientation:i="vertical"}=e,s="vertical"===i?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const r=[];return e.forEach((e,a)=>{o+=5,r.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,r.push(g.createElement("text",{key:"legend-text-"+a,y:o,className:"legend-group-label"},e.label)),o+=10),r.push(g.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:r}=e,a=[];let i=0;return r.forEach((e,r)=>{const s=ve(e,r,n,o);a.push(g.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${i})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,g.createElement("text",{y:15,x:30},e.label))),i+=25}),a})(e,n))),o+=25*e.items.length+10}),r})({legendGroups:t,width:r,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let r=0;const a=[],i=!1===t?10:40;return e.forEach((t,s)=>{t.label&&(a.push(g.createElement("text",{key:"legend-text-"+s,transform:`translate(${r},${i}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),r+=20);const l=((e,t)=>{const{type:n="fill",styleFn:o,items:r}=e,a=[];let i=0;return r.forEach((e,r)=>{const s=ve(e,r,n,o);a.push(g.createElement("g",{key:"legend-item-"+r,transform:`translate(${i},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,g.createElement("text",{y:15,x:25},e.label))),i+=35,i+=8*e.label.length}),{items:a,offset:i}})(t,o);a.push(g.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(${r},${i})`},l.items)),r+=l.offset+5,e[s+1]&&a.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:r,y1:i-10,x2:r,y2:n+i+10})),r+=15}),g.createElement("g",null,!1!==t&&g.createElement("line",{x1:0,x2:r+10,y1:i-10,y2:i-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:t,title:o,height:a,customClickBehavior:n});return g.createElement("g",null,void 0!==o&&g.createElement("text",{className:"legend-title",y:20,x:"horizontal"===i?0:r/2,textAnchor:"horizontal"===i?"start":"middle"},o),s)}function ke(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),a=[];let i="";for(const e of r)i&&i.length+1+e.length>o?(a.push(i),i=e):i=i?`${i} ${e}`:e;return i&&a.push(i),a}function Ee(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 Me(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:a,ny:i,note:s,connector:l,subject:c,type:d,color:u,className:y,disable:p,events:h={},"data-testid":f}=e,m=new Set(Array.isArray(p)?p:[]);let x=o||0,v=r||0;null!=a&&(x=a-t),null!=i&&(v=i-n);const b="string"==typeof d?d:"label";if("bracket"===b&&c&&0===x&&0===v)if(void 0!==c.width){x=c.width/2;const e=c.depth||30;v=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;x=e+(0>e?-5:5),v=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(y||"")).trim(),transform:`translate(${t},${n})`,"data-testid":f},h),!m.has("connector")&&function(e,t,n,o,r,a){const i=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==a?void 0:a.radius)){if("callout-rect"===r&&a){const n=a.width||0,o=a.height||0;if(n>0||o>0){const r=n/2,a=o/2,i=e-r,c=t-a;if(0!==i||0!==c){const e=Math.abs(i),t=Math.abs(c),d=n/2,u=o/2,y=e*u>t*d?d/e:u/t;s=r+i*y,l=a+c*y}}}else if("bracket"===r&&a){const e=a.width,t=a.height,n=a.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(a.radius||0)+(a.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-l,2))>.5&&(i.push(g.createElement("line",{key:"connector-line",x1:s,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,a=Math.atan2(t-l,e-s);i.push(g.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(a+r)},${l+n*Math.sin(a+r)}L${s+n*Math.cos(a-r)},${l+n*Math.sin(a-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},i)}(x,v,l,u,b,c),!m.has("subject")&&function(e,t,n,o,r){var a;const i=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&i.push(g.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&i.push(g.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,a=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;i.push(g.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-a,x2:o,y2:(t.y2||0)-a,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-a;i.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?i.push(g.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||i.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(a=null==t?void 0:t.width)&&void 0!==a?a:null==t?void 0:t.height;void 0!==e&&i.push(g.createElement("path",{key:"bracket-path",d:Ee((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return g.createElement("g",{className:"annotation-subject"},i)}(b,c,u,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return g.createElement("g",{className:"annotation-note"});const{label:r,title:a,orientation:i,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!a)return g.createElement("g",{className:"annotation-note"});let d=i;d||(d=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let u=s;u&&"dynamic"!==u||(u="topBottom"===d?0>t?"right":"left":0>n?"bottom":"top");let y="start";"topBottom"===d?"right"===u?y="end":"middle"===u&&(y="middle"):y=0>t?"end":"start";const p=16,h=a?c?[a]:ke(a,l):[],f=r?c?[r]:ke(r,l):[],m="leftRight"===d?"end"===y?-4:4:0;let x=0;const v=[];h.length>0&&(v.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:y,fontWeight:"bold"},h.map((e,t)=>g.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),x=h.length*p),f.length>0&&v.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:y,y:x},f.map((e,t)=>g.createElement("tspan",{key:t,x:m,dy:p},e))));let b=null;if((a||r)&&(0!==t||0!==n))if("topBottom"===d){const e=Math.min(l,120);let t=0,n=e;"end"===y?(t=-e,n=0):"middle"===y&&(t=-e/2,n=e/2),b=g.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(h.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===u?(t=-e,n=0):"middle"===u&&(t=-e/2,n=e/2),b=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=(h.length+f.length)*p+(f.length>0?p:0);let E=0;return"topBottom"===d?0>n&&(E=-k):"leftRight"===d&&("middle"===u?E=-k/2:("bottom"===u||0>n)&&(E=-k)),g.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},v),b)}(s,x,v,u))}function Ae(e){const{noteData:t}=e,{screenCoordinates:n}=t,o="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+t.dx,r=t.ny||n[0][1]+t.dy,a=n.map((n,a)=>{const i=Object.assign({},t,{note:0===a?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+a},i,{type:o}))});return g.createElement("g",null,a)}const a=t.note||{title:"none",label:t.label};return g.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${t.i}`,events:r},t,{type:o}))}const Se=(e,t,n,o)=>{const r=(e.note.label||e.note.title).length;return[Math.min(e.note.wrap||120,r*t)+2*o,Math.ceil(r*t/120)*n+2*o]};function $e(e){let t=new EventTarget,n=e(function(e){n=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)}}}let[we,Pe]=function(t){let n=e.createContext(null),o=$e(t);return[function({children:o}){let r=e.useMemo(()=>$e(t),[]);return g.createElement(n.Provider,{value:r,children:o})},t=>{var r;let a=null!==(r=e.useContext(n))&&void 0!==r?r:o;return function(t,n){const[o,r]=e.useState(n);return e.useLayoutEffect(()=>t(()=>r(n)),[t]),o}(a.subscribe,()=>t(a.getState()))}]}(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function De(e,t,n){return"number"==typeof n?n:t&&t.find(t=>t.props.orient===e)?50:10}const je=(e,t,n)=>`${e.map(Ne).join(",")}${JSON.stringify(t)}${n.join(",")}`;function Ne(e){if(!e||!e.props||!e.props.noteData)return"";const{note:t={}}=e.props.noteData,{label:n,title:o}=t;return`${e.props.noteData.id||`${e.props.noteData.x}-${e.props.noteData.y}`}-${n}=${o}`}function Oe(e,t=8,n){const{noteWidth:o=n}=e;let r=o;"number"==typeof o&&(r=()=>o);const a=e.note&&e.note.wrap||120,i=e.note.label||e.note.label||"";return o&&r(e)||(g.default.isValidElement(e.note)?100:Math.min(a,i.length*t))}function Ce(e,t=8,n=20,o){const{noteHeight:r=o}=e;let a=r;"number"==typeof r&&(a=()=>r);const i=e.note&&e.note.wrap||120,s=e.note.label||e.note.title||"";return r&&a(e)||(g.default.isValidElement(e.note)?30:Math.ceil(s.length*t/i)*n+(e.note.label&&e.note.title?n:0))}const We=(e,t)=>t.map((t,n)=>e.svgAnnotationRule(t,n,e)).filter(e=>null!=e),Le=(e,t)=>{let n=t.adjustedAnnotations,o=t.adjustedAnnotationsKey,r=t.adjustableAnnotations,a=t.fixedAnnotations,i=[],s=[];const l=t.adjustedAnnotationsKey,c=t.adjustedAnnotationsDataVersion,{annotations:d,annotationHandling:u=!1,size:y,svgAnnotationRule:p,htmlAnnotationRule:h}=e,f="object"==typeof u?u:{layout:{type:u},dataVersion:""},{dataVersion:x=""}=f;if(p){const t=We(e,d);o=je(t,f,y),!1===u&&(n=r),n=n.length!==r.length||l!==o||c!==x?((e,t,n)=>{const{layout:o={type:!1,noteHeight:void 0,noteWidth:void 0}}=t;if(!1===o.type)return e;const{noteWidth:r,noteHeight:a}=o;let{margin:i={top:0,bottom:0,left:0,right:0}}=n;const{size:s,axes:l=[]}=n;if(i="number"==typeof i?{top:i,left:i,right:i,bottom:i}:i,"bump"===o.type)return function(e,t,n,o,r){const{padding:a=1,characterWidth:i=8,lineHeight:s=20,iterations:l=500,pointSizeFunction:c=o,labelSizeFunction:d=r||Se}=t,u=e.map((e,t)=>{const n=(e.props.noteData.x[0]||e.props.noteData.x)+(void 0!==e.props.noteData.dx?e.props.noteData.dx:-10*(t%3-1)),o=(e.props.noteData.y[0]||e.props.noteData.y)+(void 0!==e.props.noteData.dy?e.props.noteData.dy:10*(t%3-1)),[r,l]=d(e.props.noteData,i,s,a);return{x:n,y:o,above:e.props.noteData.y>o,left:e.props.noteData.x>n,width:r,height:l,type:"label",name:"",originalNote:e}}),y=e.map(e=>({x:e.props.noteData.x,y:e.props.noteData.y,fx:e.props.noteData.x,fy:e.props.noteData.y,r:c&&c(e.props.noteData)||5,type:"point",originalNote:e})),p=function(){let e,t=[],n=[],o=1,r=1,a={start:e=>{},width:e=>{},height:e=>{},label:e=>{},anchor:e=>{},alt_energy:e=>{},alt_schedule:e=>{}},i=!1;const s=function(e){let o=t.length,r=0,a=t[e].x-n[e].x,i=n[e].y-t[e].y,s=Math.sqrt(a*a+i*i);s>0&&(r+=.2*s),a/=s,i/=s,r+=a>0&&i>0?0:0>a&&i>0?3:0>a&&0>i?6:9;let l,c,u,y,p,h,f,g=t[e].x,m=t[e].y-t[e].height+2,x=t[e].x+t[e].width,v=t[e].y+2;for(let a=0;o>a;a++)a!==e&&(d(n[e].x,t[e].x,n[a].x,t[a].x,n[e].y,t[e].y,n[a].y,t[a].y)&&(r+=1),l=t[a].x,u=t[a].y-t[a].height+2,c=t[a].x+t[a].width,y=t[a].y+2,p=Math.max(0,Math.min(c,x)-Math.max(l,g)),h=Math.max(0,Math.min(y,v)-Math.max(u,m)),f=p*h,r+=30*f),l=n[a].x-n[a].r,u=n[a].y-n[a].r,c=n[a].x+n[a].r,y=n[a].y+n[a].r,p=Math.max(0,Math.min(c,x)-Math.max(l,g)),h=Math.max(0,Math.min(y,v)-Math.max(u,m)),f=p*h,r+=30*f;return r},l=function(a){let l,c,d=Math.floor(Math.random()*t.length),u=t[d].x,y=t[d].y;l=i?e(d,t,n):s(d),t[d].x+=5*(Math.random()-.5),t[d].y+=5*(Math.random()-.5),t[d].x>o&&(t[d].x=u),0>t[d].x&&(t[d].x=u),t[d].y>r&&(t[d].y=y),0>t[d].y&&(t[d].y=y),c=i?e(d,t,n):s(d);let p=c-l;Math.random()<Math.exp(-p/a)||(t[d].x=u,t[d].y=y)},c=function(a){let l,c=Math.floor(Math.random()*t.length),d=t[c].x,u=t[c].y;l=i?e(c,t,n):s(c);let y=.5*(Math.random()-.5),p=Math.sin(y),h=Math.cos(y);t[c].x-=n[c].x,t[c].y-=n[c].y;let f,g=t[c].x*p+t[c].y*h;t[c].x=t[c].x*h-t[c].y*p+n[c].x,t[c].y=g+n[c].y,t[c].x>o&&(t[c].x=d),0>t[c].x&&(t[c].x=d),t[c].y>r&&(t[c].y=u),0>t[c].y&&(t[c].y=u),f=i?e(c,t,n):s(c);let m=f-l;Math.random()<Math.exp(-m/a)||(t[c].x=d,t[c].y=u)},d=function(e,t,n,o,r,a,i,s){let l,c,d,u,y;return d=(s-i)*(t-e)-(o-n)*(a-r),u=(o-n)*(r-i)-(s-i)*(e-n),y=(t-e)*(r-i)-(a-r)*(e-n),l=u/d,c=y/d,!(0>l||l>1||0>c||c>1)},u=function(e,t,n){return e-t/n};return a.start=function(e){let n=t.length,o=1;for(let t=0;e>t;t++){for(let e=0;n>e;e++).5>Math.random()?l(o):c(o);o=u(o,1,e)}},a.width=function(e){return arguments.length?(o=e,a):o},a.height=function(e){return arguments.length?(r=e,a):r},a.label=function(e){return arguments.length?(t=e,a):t},a.anchor=function(e){return arguments.length?(n=e,a):n},a.alt_energy=function(t){return arguments.length?(e=t,i=!0,a):s},a.alt_schedule=function(e){return arguments.length?a:u},a}();return p.label(u),p.anchor(y),p.width(n[0]),p.height(n[1]),p.start(l),u.forEach(e=>{if("label"===e.type){const t=function(e,t,n){return e.y>t.y?[t.x+t.width/2+n/2,t.y-t.height+n/2]:[t.x+t.width/2,t.y]}(e.originalNote.props.noteData,e,a);e.originalNote.props.noteData.nx=t[0],e.originalNote.props.noteData.ny=t[1]}}),e}(e,o,s,n.pointSizeFunction,n.labelSizeFunction);if("marginalia"===o.type){const{marginOffset:t,orient:n="nearest",characterWidth:c=8,lineHeight:d=20,padding:u=2,axisMarginOverride:y={}}=o,p="nearest"===n?["left","right","top","bottom"]:Array.isArray(n)?n:[n],h=p.find(e=>"left"===e),f=p.find(e=>"right"===e),x=p.find(e=>"top"===e),v=p.find(e=>"bottom"===e),b=[],k=[],E=[],M=[];for(const t of e){const e=t.props.noteData,n=e.x[0]||e.x,o=e.y[0]||e.y,r=h?n:1/0,a=f?s[0]-n:1/0,i=x?o:1/0,l=Math.min(r,a,i,v?s[1]-o:1/0);r===l?b.push(t):a===l?k.push(t):i===l?E.push(t):M.push(t)}const A=new m.default.Force({minPos:void 0!==y.top?0+y.top:0-i.top,maxPos:void 0!==y.bottom?s[1]-y.bottom:v?s[1]:s[1]+i.bottom}).nodes(b.map(e=>new m.default.Node(e.props.noteData.y[0]||e.props.noteData.y,Ce(e.props.noteData,c,d,r)+u))).compute(),S=new m.default.Force({minPos:void 0!==y.top?0+y.top:x?0:0-i.top,maxPos:void 0!==y.bottom?s[1]-y.bottom:s[1]+i.bottom}).nodes(k.map(e=>new m.default.Node(e.props.noteData.y[0]||e.props.noteData.y,Ce(e.props.noteData,c,d,r)+u))).compute(),$=new m.default.Force({minPos:void 0!==y.left?0+y.left:h?0:0-i.left,maxPos:void 0!==y.right?s[0]-y.right:s[0]+i.right}).nodes(E.map(e=>new m.default.Node(e.props.noteData.x[0]||e.props.noteData.x,Oe(e.props.noteData,c,a)+u))).compute(),w=new m.default.Force({minPos:void 0!==y.left?0+y.left:0-i.left,maxPos:void 0!==y.right?s[0]-y.right:f?s[0]:s[0]+i.right}).nodes(M.map(e=>new m.default.Node(e.props.noteData.x[0]||e.props.noteData.x,Oe(e.props.noteData,c,a)+u))).compute(),P=Math.max(...M.map(e=>Ce(e.props.noteData,c,d,r)+u)),D=Math.max(...E.map(e=>Ce(e.props.noteData,c,d,r)+u)),j=Math.max(...b.map(e=>Oe(e.props.noteData,c,a)+u)),N=Math.max(...k.map(e=>Oe(e.props.noteData,c,a)+u)),O=A.nodes(),C=S.nodes(),W=$.nodes(),L=w.nodes();return b.forEach((e,n)=>{const o=0-O[n].layerIndex*j-De("left",l,t),r=O[n].currentPos;e.props.noteData.nx=o,e.props.noteData.ny=r,e.props.noteData.note&&!g.isValidElement(e)&&(e.props.noteData.note.orientation=e.props.noteData.note.orientation||"leftRight",e.props.noteData.note.align=e.props.noteData.note.align||"right")}),k.forEach((e,n)=>{const o=s[0]+C[n].layerIndex*N+De("right",l,t),r=C[n].currentPos;e.props.noteData.nx=o,e.props.noteData.ny=r,e.props.noteData.note&&!g.isValidElement(e)&&(e.props.noteData.note.orientation=e.props.noteData.note.orientation||"leftRight",e.props.noteData.note.align=e.props.noteData.note.align||"left")}),E.forEach((e,n)=>{const o=W[n].currentPos,r=0-W[n].layerIndex*D-De("top",l,t);e.props.noteData.nx=o,e.props.noteData.ny=r}),M.forEach((e,n)=>{const o=L[n].currentPos,r=s[1]+L[n].layerIndex*P+De("bottom",l,t);e.props.noteData.nx=o,e.props.noteData.ny=r}),e}return e})(r,f,e):r.map((e,t)=>{const o=Object.assign(Object.assign({},n[t].props.noteData),e.props.noteData);return g.createElement(Ae,{key:e.key,noteData:o})}),i=[...n,...a]}return h&&(s=((e,t)=>t.map((t,n)=>e.htmlAnnotationRule(t,n,e)).filter(e=>null!=e))(e,d)),{svgAnnotations:i,htmlAnnotations:s,adjustedAnnotations:n,adjustedAnnotationsKey:o,adjustedAnnotationsDataVersion:x}},_e=e=>e instanceof Date?e.getTime():e,ze=({type:e="stackedarea",data:t,xProp:n,yProp:o,yPropMiddle:r,sort:a,yPropTop:i,yPropBottom:l})=>{const c=new Map,d=t.map(()=>0);let u=0;for(const e of t){e.__lineIndex=u;for(const t of e.data){const e=_e(t[n]);d[u]+=t[o],c.has(e)||c.set(e,[]),c.get(e)[u]=t}u++}let y=(e,t)=>d[t.key]-d[e.key];"stackedpercent-invert"!==e&&"stackedarea-invert"!==e||(y=(e,t)=>d[e.key]-d[t.key]),null!==(a=void 0===a?y:a)&&(t=t.sort(a));const p=t.map(e=>e.__lineIndex);for(const[,t]of c){let n=0,a=0;const c=s.sum(t,e=>(null==e?void 0:e[o])>0?e[o]:0),d=s.sum(t,e=>0>(null==e?void 0:e[o])?e[o]:0);for(const s of p){const u=t[s];if(u)if(0>u[o]){if("linepercent"===e||"stackedpercent"===e||"stackedpercent-invert"===e){const t=u[o]/d;if(u.percent=t,"linepercent"===e)u[l]=u[l]=u[i]=u[r]=t;else{const e=0>d?t:0;u[l]=0===d?0:-n/d,u[i]=u[l]-e,u[r]=u[l]-e/2}}else u[l]=n,u[i]=n+u[o],u[r]=n+u[o]/2;n+=u[o]}else{if("linepercent"===e||"stackedpercent"===e||"stackedpercent-invert"===e){const t=u[o]/c;if(u.percent=t,"linepercent"===e)u[l]=u[i]=u[r]=t;else{const e=c>0?t:0;u[l]=0===c?0:a/c,u[i]=u[l]+e,u[r]=u[l]+e/2}}else u[l]=a,u[i]=a+u[o],u[r]=a+u[o]/2;a+=u[o]}}}return t},Fe=({data:e,y1:t,x1:n,yPropTop:o,yPropMiddle:r,yPropBottom:a,xPropTop:i,xPropMiddle:s,xPropBottom:l})=>{if(t)for(const n of e)for(const e of n.data)e[a]=t(e),e[r]=e[o];if(n)for(const t of e)for(const e of t.data)e[l]=n(e),e[s]=(e[l]+e[i])/2;return e},Te=({data:e,y1:t,yPropTop:n,yPropMiddle:o,yPropBottom:r,type:a="cumulative"})=>{for(const i of e){let e=0;const s="cumulative-reverse"===a?i.data.reverse():i.data;for(const a of s)e+=a[n],a[r]=a[n]=a[o]=e,t&&(a[r]=t(a),a[o]=a[r]+a[n]/2)}return e},Be=({type:e="bumpline",data:t,xProp:n,yProp:o,yPropMiddle:r,yPropTop:a,yPropBottom:i})=>{const s=new Map;for(const e of t)for(const t of e.data){const e=_e(t[n]);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=(e,t)=>e[o]>t[o]?1:-1;"bumparea-invert"!==e&&"bumpline-invert"!==e||(l=(e,t)=>t[o]>e[o]?1:-1);for(const[,t]of s){let n=0,s=0;t.sort(l);let c=1;for(const l of t)"bumparea"===e||"bumparea-invert"===e?0>l[o]?(l[a]=n+l[o],l[r]=n+l[o]/2,l[i]=n,n+=l[o]):(l[a]=s+l[o],l[r]=s+l[o]/2,l[i]=s,s+=l[o]):(l[o]=c,l[a]=c,l[i]=c),c++}return t},Re="x",Ie="y",Ye="yMiddle",Xe="yTop",qe="yBottom",Ge="xMiddle",Ve="xTop",He="xBottom",Ke=(e,t,n,o)=>[...e.map((e,o)=>[e[0],e[1]+n(t[o])]),...e.map((e,n)=>[e[0],e[1]-o(t[n])]).reverse()],Je=e=>e&&e.extent||Array.isArray(e)&&e||[],Ze=()=>!0,Qe={top:Xe,bottom:qe,orphan:Ie},Ue={top:Ve,bottom:He,orphan:Re},et={stackedarea:ze,"stackedarea-invert":ze,stackedpercent:ze,"stackedpercent-invert":ze,linepercent:ze,difference:({data:e,yProp:t,yPropTop:n,yPropBottom:o})=>(e.forEach((r,a)=>{r.data.forEach((r,i)=>{const s=0===a?1:0;r[t]>e[s].data[i][t]?(r[o]=e[s].data[i][t],r[n]=r[t]):(r[n]=r[t],r[o]=r[t])})}),e),bumparea:Be,bumpline:Be,"bumparea-invert":Be,line:Fe,area:Fe,cumulative:Te,"cumulative-reverse":Te};function tt(e,t){const n=[];for(const e of t)n.push(Object.assign({},e));for(const t of e)t.parentSummary||n.push(t);return n}function nt(e,t,n){return t.parent&&(n=`${n}-${nt(e,Object.assign(Object.assign({},t.parent),t.parent.data),n)}`),`${n}-${e(Object.assign(Object.assign({},t),t.data))}`}const ot=e=>e.id||e.descendantIndex,rt={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 at(e,t){return"function"==typeof t?t(e):e[t]}function it(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 st(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:t,title:n,format:o,style:r={},className:a=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const s=[];if(n){const t=at(e,n);i=it(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,a;"string"==typeof t?(n=t,r=t,a=o):(n=t.label,r=t.accessor||t.key||"",a=t.format||o);const i=at(e,r);s.push({label:n,value:it(i,a)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){i=it(e[n],o);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=it(e[t[0]],o))}}const l=Object.assign(Object.assign({},rt),r);return g.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:l},i&&g.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},i),s.map((e,t)=>g.createElement("div",{key:t,style:{marginTop:0===t&&i?"4px":0}},e.label&&g.createElement("span",null,e.label,": "),e.value)))}}(e)))}const lt="#007bff";function ct(t,n,o="category10"){return e.useMemo(()=>{if(n&&"function"!=typeof n)return ne(t,n,o)},[t,n,o])}function dt({componentName:e,message:t,width:n,height:o}){return g.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,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"}},g.createElement("div",{style:{textAlign:"center",maxWidth:400}},g.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),g.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function ut({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function yt({nodes:e,edges:t,nodesRequired:n=!1,edgesRequired:o=!0,accessors:r}){if(o&&(!t||!Array.isArray(t)||0===t.length))return"No edges provided. Pass a non-empty array to the edges prop.";if(n&&(!e||!Array.isArray(e)||0===e.length))return"No nodes provided. Pass a non-empty array to the nodes prop.";if(r&&e&&e.length>0){const t=e[0];if(t&&"object"==typeof t)for(const[e,n]of Object.entries(r))if(n&&"string"==typeof n&&!(n in t))return`${e} "${n}" not found in node data. Available fields: ${Object.keys(t).join(", ")}.`}return null}function pt(t){const{nodes:n,edges:o,width:r=600,height:a=600,margin:i,className:s,title:l,nodeIDAccessor:c="id",sourceAccessor:d="source",targetAccessor:u="target",nodeLabel:y,colorBy:p,colorScheme:h="category10",nodeSize:f=8,nodeSizeRange:m=[5,20],edgeWidth:x=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:k=300,forceStrength:E=.1,showLabels:M=!1,enableHover:A=!0,showLegend:S,tooltip:$,frameProps:w={}}=t,P=n||[],D=o||[],j=ct(P,p,h),N=e.useMemo(()=>e=>{const t={};return t.fill=p?te(e.data||e,p,j):lt,"number"==typeof f&&(t.r=f),t},[p,j,f]),O=e.useMemo(()=>e=>({stroke:v,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:b}),[x,v,b]),C=e.useMemo(()=>{if(M&&y)return"function"==typeof y?y:e=>e[y]},[M,y]),W=void 0!==S?S:!!p,L=e.useMemo(()=>{if(W&&p)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:a}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==a&&(t.strokeWidth=a),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),i=a?o(a,t,n):n?n(r):"#000000";return{label:r+"",color:i}}),label:""}]}}({data:P,colorBy:p,colorScale:j,getColor:te})},[W,p,P,j]),_=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:20,bottom:20,left:20,right:20}),i);return L&&120>e.right&&(e.right=120),e},[i,L]),z=yt({componentName:"ForceDirectedGraph",nodes:n,edges:o,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:c}});return z?g.createElement(dt,{componentName:"ForceDirectedGraph",message:z,width:r,height:a}):g.createElement(ce,Object.assign({chartType:"force",nodes:P,edges:D,size:[r,a],margin:_,nodeIDAccessor:c,sourceAccessor:d,targetAccessor:u,iterations:k,forceStrength:E,nodeStyle:N,edgeStyle:O,colorBy:p,colorScheme:h,nodeSize:f,nodeSizeRange:m,nodeLabel:C,showLabels:M,enableHover:A,tooltipContent:$?e=>st($)(e.data):void 0,legend:L,className:s,title:l},w))}function ht(t){const{nodes:n,edges:o,width:r=800,height:a=600,margin:i={top:50,bottom:50,left:50,right:50},className:s,title:l,sourceAccessor:c="source",targetAccessor:d="target",valueAccessor:u="value",nodeIdAccessor:y="id",colorBy:p,colorScheme:h="category10",edgeColorBy:f="source",orientation:m="horizontal",nodeAlign:x="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:k,showLabels:E=!0,enableHover:M=!0,edgeOpacity:A=.5,edgeSort:S,tooltip:$,frameProps:w={}}=t,P=o||[],D=e.useMemo(()=>{if(n&&n.length>0)return n;const e=new Set;return P.forEach(t=>{const n="function"==typeof c?c(t):t[c],o="function"==typeof d?d(t):t[d];e.add(n),e.add(o)}),Array.from(e).map(e=>({id:e}))},[n,P,c,d]),j=ct(D,p,h),N=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?te(e.data||e,p,j):"#4d430c",t},[p,j]),O=e.useMemo(()=>e=>{const t={stroke:"none",strokeWidth:0,fillOpacity:A};if("function"==typeof f)t.fill=f(e);else if("source"===f){const n="object"==typeof e.source?e.source:null;p&&n?t.fill=te(n.data||n,p,j):n&&(t.fill=N(n).fill)}else if("target"===f){const n="object"==typeof e.target?e.target:null;p&&n?t.fill=te(n.data||n,p,j):n&&(t.fill=N(n).fill)}else"gradient"===f&&(t.fill="#999",t.fillOpacity=.7*A);return t},[f,p,j,N,A]),C=e.useMemo(()=>{if(!E)return;const e=k||y;return"function"==typeof e?e:t=>t[e]},[E,k,y]),W=e.useMemo(()=>{if("function"==typeof $)return $},[$]),L=yt({componentName:"SankeyDiagram",edges:o,edgesRequired:!0});return L?g.createElement(dt,{componentName:"SankeyDiagram",message:L,width:r,height:a}):g.createElement(ce,Object.assign({chartType:"sankey",nodes:D,edges:P,size:[r,a],margin:i,nodeIDAccessor:y,sourceAccessor:c,targetAccessor:d,valueAccessor:u,orientation:m,nodeAlign:x,nodePaddingRatio:v,nodeWidth:b,nodeStyle:N,edgeStyle:O,colorBy:p,colorScheme:h,edgeColorBy:f,edgeOpacity:A,edgeSort:S,nodeLabel:C,showLabels:E,enableHover:M,tooltipContent:W?e=>W(e.data):void 0,className:s,title:l},w))}function ft(t){const{nodes:n,edges:o,width:r=600,height:a=600,margin:i={top:50,bottom:50,left:50,right:50},className:s,title:l,sourceAccessor:c="source",targetAccessor:d="target",valueAccessor:u="value",nodeIdAccessor:y="id",colorBy:p,colorScheme:h="category10",edgeColorBy:f="source",padAngle:m=.01,groupWidth:x=20,sortGroups:v,nodeLabel:b,showLabels:k=!0,enableHover:E=!0,edgeOpacity:M=.5,tooltip:A,frameProps:S={}}=t,$=o||[],w=e.useMemo(()=>{if(n&&n.length>0)return n;const e=new Set;return $.forEach(t=>{const n="function"==typeof c?c(t):t[c],o="function"==typeof d?d(t):t[d];e.add(n),e.add(o)}),Array.from(e).map(e=>({id:e}))},[n,$,c,d]),P=ct(w,p,h),D=e.useMemo(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(p)r.fill=te(e.data||e,p,P);else{const a=Array.isArray(h)?h:U[h]||ee,i=Array.isArray(a)?a:ee,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=i[s%i.length]}return r},[p,P,h]),j=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:.5,fillOpacity:M,strokeOpacity:M};if("function"==typeof f)t.fill=f(e);else if("source"===f){const n="object"==typeof e.source?e.source:null;p&&n?t.fill=te(n.data||n,p,P):n&&(t.fill=D(n,n.index).fill)}else if("target"===f){const n="object"==typeof e.target?e.target:null;p&&n?t.fill=te(n.data||n,p,P):n&&(t.fill=D(n,n.index).fill)}return t},[f,p,P,D,M]),N=e.useMemo(()=>{if(!k)return;const e=b||y;return"function"==typeof e?e:t=>t[e]},[k,b,y]),O=yt({componentName:"ChordDiagram",edges:o,edgesRequired:!0});return O?g.createElement(dt,{componentName:"ChordDiagram",message:O,width:r,height:a}):g.createElement(ce,Object.assign({chartType:"chord",nodes:w,edges:$,size:[r,a],margin:i,nodeIDAccessor:y,sourceAccessor:c,targetAccessor:d,valueAccessor:u,padAngle:m,groupWidth:x,sortGroups:v,nodeStyle:D,edgeStyle:j,colorBy:p,colorScheme:h,edgeColorBy:f,edgeOpacity:M,nodeLabel:N,showLabels:k,enableHover:E,tooltipContent:A?e=>st(A)(e.data):void 0,className:s,title:l},S))}function gt(t){const{data:n,width:o=600,height:r=600,margin:a={top:50,bottom:50,left:50,right:50},className:i,title:s,layout:l="tree",orientation:c="vertical",childrenAccessor:d="children",valueAccessor:u="value",nodeIdAccessor:y="name",colorBy:p,colorScheme:h="category10",colorByDepth:f=!1,edgeStyle:m="curve",nodeLabel:x,showLabels:v=!0,nodeSize:b=5,enableHover:k=!0,tooltip:E,frameProps:M={}}=t,A=e.useMemo(()=>{if(!n)return[];const e=[],t=n=>{e.push(n);const o="function"==typeof d?d(n):n[d];o&&Array.isArray(o)&&o.forEach(t)};return t(n),e},[n,d]),S=e.useMemo(()=>f?ne(A.map((e,t)=>({depth:t%5})),"depth",h):p&&"function"!=typeof p?ne(A,p,h):void 0,[A,p,f,h]),$=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?te({depth:e.depth||0},"depth",S):p?te(e.data||e,p,S):lt,t},[p,f,S]),w=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),P=e.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return"function"==typeof u?u:e=>e[u]||1},[l,u]),D=ut({componentName:"TreeDiagram",data:n});return D?g.createElement(dt,{componentName:"TreeDiagram",message:D,width:o,height:r}):g.createElement(ce,Object.assign({chartType:l,data:n,size:[o,r],margin:a,nodeIDAccessor:y,childrenAccessor:d,hierarchySum:P,treeOrientation:c,edgeType:m,nodeStyle:$,edgeStyle:w,colorBy:p,colorScheme:h,colorByDepth:f,nodeSize:b,nodeLabel:v?x||y:void 0,showLabels:v,enableHover:k,tooltipContent:E?e=>st(E)(e.data):void 0,className:i,title:s},M))}function mt(t){const{data:n,width:o=600,height:r=600,margin:a={top:10,bottom:10,left:10,right:10},className:i,title:s,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:d="name",colorBy:u,colorScheme:y="category10",colorByDepth:p=!1,showLabels:h=!0,labelMode:f="leaf",nodeLabel:m,padding:x=4,paddingTop:v,enableHover:b=!0,tooltip:k,frameProps:E={}}=t,M=e.useMemo(()=>{if(!n)return[];const e=[],t=n=>{e.push(n);const o="function"==typeof l?l(n):n[l];o&&Array.isArray(o)&&o.forEach(t)};return t(n),e},[n,l]),A=e.useMemo(()=>{if(!p&&u&&"function"!=typeof u)return ne(M,u,y)},[M,u,p,y]),S=e.useMemo(()=>{const e=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];return t=>{const n={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return n.fill=p?e[(t.depth||0)%e.length]:u?te(t.data||t,u,A):lt,n}},[u,p,A]),$=e.useMemo(()=>"function"==typeof c?c:e=>e[c]||1,[c]),w=void 0!==v?v:h&&"parent"===f?18:void 0,P=ut({componentName:"Treemap",data:n});return P?g.createElement(dt,{componentName:"Treemap",message:P,width:o,height:r}):g.createElement(ce,Object.assign({chartType:"treemap",data:n,size:[o,r],margin:a,nodeIDAccessor:d,childrenAccessor:l,hierarchySum:$,padding:x,paddingTop:w,nodeStyle:S,colorBy:u,colorScheme:y,colorByDepth:p,nodeLabel:h?m||d:void 0,showLabels:h,enableHover:b,tooltipContent:k?e=>st(k)(e.data):void 0,className:i,title:s},E))}function xt(t){const{data:n,width:o=600,height:r=600,margin:a={top:10,bottom:10,left:10,right:10},className:i,title:s,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:d="name",colorBy:u,colorScheme:y="category10",colorByDepth:p=!1,showLabels:h=!0,nodeLabel:f,circleOpacity:m=.7,padding:x=4,enableHover:v=!0,tooltip:b,frameProps:k={}}=t,E=e.useMemo(()=>{if(!n)return[];const e=[],t=n=>{e.push(n);const o="function"==typeof l?l(n):n[l];o&&Array.isArray(o)&&o.forEach(t)};return t(n),e},[n,l]),M=e.useMemo(()=>{if(!p&&u&&"function"!=typeof u)return ne(E,u,y)},[E,u,p,y]),A=e.useMemo(()=>{const e=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];return t=>{const n={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:m};return n.fill=p?e[(t.depth||0)%e.length]:u?te(t.data||t,u,M):lt,n}},[u,p,M,m]),S=e.useMemo(()=>"function"==typeof c?c:e=>e[c]||1,[c]),$=ut({componentName:"CirclePack",data:n});return $?g.createElement(dt,{componentName:"CirclePack",message:$,width:o,height:r}):g.createElement(ce,Object.assign({chartType:"circlepack",data:n,size:[o,r],margin:a,nodeIDAccessor:d,childrenAccessor:l,hierarchySum:S,padding:x,nodeStyle:A,colorBy:u,colorScheme:y,colorByDepth:p,nodeLabel:h?f||d:void 0,showLabels:h,enableHover:v,tooltipContent:b?e=>st(b)(e.data):void 0,className:i,title:s},k))}pt.displayName="ForceDirectedGraph",ht.displayName="SankeyDiagram",ft.displayName="ChordDiagram",gt.displayName="TreeDiagram",mt.displayName="Treemap",xt.displayName="CirclePack",exports.Annotation=Ae,exports.AnnotationLayer=function(t){const{legendSettings:n,margin:o,size:r,annotations:a,annotationHandling:i}=t,s=Pe(e=>e.tooltip);let l=null!=s?a.concat(s):a,c=Pe(e=>e.changeTooltip);const d=Object.assign(Object.assign({},t),{annotations:l,voronoiHover:e=>{c(e)}}),u="object"==typeof i?i:{layout:{type:i},dataVersion:""},{dataVersion:y=""}=u,[p,h]=e.useState([]),[f,m]=e.useState([]),[x,v]=e.useState([]),[b,k]=e.useState(""),[E,M]=e.useState(y),A=We(d,l),S=A.filter(e=>e.props&&e.props.noteData&&!e.props.noteData.fixedPosition),$=je(S,u,r);let w;if(e.useEffect(()=>{const e=A.filter(e=>!e.props||!e.props.noteData||e.props.noteData.fixedPosition),t=Le(d,{adjustedAnnotations:p,adjustedAnnotationsKey:b,adjustedAnnotationsDataVersion:E,adjustableAnnotations:S,fixedAnnotations:e});h(t.adjustedAnnotations),k(t.adjustedAnnotationsKey),M(t.adjustedAnnotationsDataVersion),m(t.svgAnnotations),v(t.htmlAnnotations)},[$,y,l.length,l.map(e=>function(e){const t=new Set;return JSON.stringify(e,(e,n)=>t.has(n)?"...":"object"==typeof n?(t.add(n),"note"===e?`${n.label}-${n.title}`:"connector"===e?`${n.end}-${n.type}`:"subject"===e?""+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)}(e)).join("-")]),n){const e={left:[15,15],right:[r[0]+15,15]},{position:t="right",title:o="Legend"}=n;w=g.createElement("g",{transform:`translate(${e[t].join(",")})`},g.createElement(be,Object.assign({},n,{title:o,position:t})))}return 0!==l.length||n?g.createElement("div",{className:"annotation-layer",style:{position:"absolute",pointerEvents:"none",background:"none"}},g.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"}},g.createElement("g",null,w,f)),g.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"}},x)):null},exports.Axis=function(t){const{rotate:n,label:o,dynamicLabelPosition:r,orient:a="left",marginalSummaryType:i,tickFormat:s=(i?()=>"":ge),size:l,width:c=l&&l[0]||0,height:d=l&&l[1]||0,className:u,padding:y,tickValues:p,scale:h,ticks:f,footer:m,tickSize:x,tickLineGenerator:v,baseline:b=!0,margin:k={top:0,bottom:0,left:0,right:0},center:E=!1,annotationFunction:M,glyphFunction:A,xyPoints:S}=t,[$,w]=e.useState(0),[P,D]=e.useState(void 0),j=e.useRef(null);e.useEffect(()=>{if(!(null==o?void 0:o.position)&&r){const e=((e,t)=>{const n=e.current;if(!n)return 30;const o="left"===t||"right"===t?"width":"height";return Math.max(...[...n.querySelectorAll(".axis-label")].map(e=>e.getBBox&&e.getBBox()||{height:30,width:30}).map(e=>e[o]))+25})(j,a);e!==P&&D(e)}},[o,r]);let N,{axisParts:O,position:C=[0,0]}=t;if(O||(O=function({renderMode:e=()=>{},padding:t=5,scale:n,ticks:o,tickValues:r=ue(void 0,o,n),orient:a="left",size:i,footer:s=!1,tickSize:l=(s?-10:["top","bottom"].find(e=>e===a)?i?i[1]:0:i?i[0]:0),jaggedBase:c}){let d,u,y,p,h,f,g=[],m=0,x=0,v="middle";switch(a){case"top":d="x1",u="x2",y="y1",p="y2",g=[0,l],h="tx",f="ty",m-=20-t;break;case"bottom":d="x1",u="x2",y="y2",p="y1",g=i?[i[1],i[1]-l]:[0,-l],h="tx",f="ty",m+=20+t;break;case"right":d="y2",u="y1",y="x2",p="x1",g=i?[i[0],i[0]-l]:[0,-l],h="ty",f="tx",m+=5+t,x+=5,v="start";break;default:d="y1",u="y2",y="x1",p="x2",g=[0,l],h="ty",f="tx",m-=5+t,x+=5,v="end"}let b=r instanceof Function?r({orient:a}):r;return c&&void 0===b.find(e=>e===n.domain()[0])&&(b=[n.domain()[0],...b]),b.map((t,o)=>{const r=n(t);return{[d]:r,[u]:r,[y]:g[0],[p]:g[1],[h]:r+x,[f]:g[0]+m,defaultAnchor:v,renderMode:e(t,o),value:t}})}({padding:y,tickValues:p,scale:h,ticks:f,orient:a,size:[c,d],footer:m,tickSize:x}),N=g.createElement("g",{className:"axis "+u},(({axisParts:e,orient:t,tickLineGenerator:n=de,className:o,jaggedBase:r,scale:a,showOutboundTickLines:i=!1})=>{const s=e.map((e,i)=>n({xy:e,orient:t,i:i,className:o,jaggedBase:r,scale:a})),l=i?e.map((e,n)=>(({xy:e,orient:t,i:n,className:o=""})=>{let r=`M-4,${e.y1}L${e.x1},${e.y2}`;return"left"===t?r=`M${e.x1-8},${e.y1}L${e.x1},${e.y2}`:"right"===t?r=`M${e.x2},${e.y1}L${e.x2+8},${e.y2}`:"top"===t?r=`M${e.x1},${e.y1-8}L${e.x1},${e.y1}`:"bottom"===t&&(r=`M${e.x1},${e.y2}L${e.x1},${e.y2+8}`),g.createElement("path",{key:n,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:r,className:`outbound-tick-line tick ${t} ${o}`})})({xy:e,orient:t,i:n,className:o})):[];return[...s,l]})({axisParts:O,orient:a,tickLineGenerator:v,className:u,scale:h}))),0===O.length)return null;let W,L,_,z,F=50,T=d,B=-50,R=0,I=0,Y=0,X=0,q=d,G=25,V=-25,H=18,K=c+25,J=0,Z=$,Q=0,U="y";switch(a){case"right":C=[C[0],C[1]],B=c,X=I=c,Q=k.top,K=-c-25,V=5,W=e=>{w(e.nativeEvent.offsetY-Q)},!0===E&&(X=I=c/2);break;case"top":C=[C[0],0],F=c,T=50,R=-50,B=0,Q=k.left,U="x",X=c,q=0,!0===E&&(q=Y=d/2),W=e=>{w(e.nativeEvent.offsetX-Q)},G=$,Z=25,V=0,H=-10,K=0,J=d+25;break;case"bottom":C=[C[0],0],F=c,T=50,Y=q=R=d,I=B=0,X=c,Q=k.left,W=e=>{w(e.nativeEvent.offsetX-Q)},G=$,Z=25,V=0,H=15,K=0,J=-d-25,U="x",!0===E&&(q=Y=d/2);break;default:C=[C[0],C[1]],Q=k.top,!0===E&&(X=I=c/2),W=e=>{w(e.nativeEvent.offsetY-Q)}}if(M){const e=function(e,t){return t.tickFormat?t.tickFormat(e):e.toString?""+e:e}(h.invert($),t),n=A?A({lineHeight:J,lineWidth:K,value:h.invert($)}):g.createElement("g",null,g.isValidElement(e)?g.createElement("g",{transform:`translate(${V},${H})`},e):g.createElement("text",{x:V,y:H},e),g.createElement("circle",{r:5}),g.createElement("line",{x1:K,y1:J,style:{stroke:"black"}})),o=$?g.createElement("g",{style:{pointerEvents:"none"},transform:`translate(${G},${Z})`},n):null;L=g.createElement("g",{className:"annotation-brush",transform:`translate(${B},${R})`},g.createElement("rect",{style:{fillOpacity:0},height:T,width:F,onMouseMove:W,onClick:e=>M({className:"dynamic-axis-annotation",type:U,value:h.invert($),e:e}),onMouseOut:()=>{w(void 0)}}),o)}if(i&&S){const e=Math.max(k[a]-6,5),t="string"==typeof i?{type:i}:i;void 0!==t.flip||"bottom"!==a&&"right"!==a||(t.flip=!0);const n=t.summaryStyle?()=>t.summaryStyle:()=>({fill:"black",fillOpacity:.5,stroke:"black",strokeDasharray:"0"}),o=t.renderMode?()=>t.renderMode:()=>{},r=t.summaryClass?()=>t.summaryClass:()=>"",s=t.filter||(()=>!0),c=S.filter(e=>void 0!==e.x&&void 0!==e.y&&s(e.data)).map(e=>Object.assign(Object.assign({},e),{xy:{x:"top"===a||"bottom"===a?h(e.x):0,y:"left"===a||"right"===a?h(e.y):0},piece:{scaledVerticalValue:h(e.y),scaledValue:h(e.x)},value:h("top"===a||"bottom"===a?e.y:e.x),scaledValue:h(e.x),scaledVerticalValue:h(e.y)})),d=function(e){const t=[];for(const n of e){const e=[],{elements:o,containerProps:r}=n;if(n.Mark)t.push(n.Mark);else{for(let t=0;o.length>t;t++){const n=o[t],{markType:r,style:a={}}=n,i=me(n,["markType","style"]),s=Object.assign({},i);void 0!==a.fill&&(s.fill=a.fill),void 0!==a.stroke&&(s.stroke=a.stroke),void 0!==a.strokeWidth&&(s.strokeWidth=a.strokeWidth),void 0!==a.opacity&&(s.opacity=a.opacity),void 0!==a.fillOpacity&&(s.fillOpacity=a.fillOpacity),void 0!==a.strokeOpacity&&(s.strokeOpacity=a.strokeOpacity);const l=Object.assign({},a);delete l.fill,delete l.stroke,delete l.strokeWidth,delete l.opacity,delete l.fillOpacity,delete l.strokeOpacity,Object.keys(l).length>0&&(s.style=l),s.key=n.key||t,r&&e.push(g.createElement(r,s))}r?t.push(g.createElement("g",Object.assign({},r),e)):t.push(...e)}}return t}((({data:e,type:t,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:a,projection:i,adjustedSize:s,margin:l,axisCreator:c})=>{if(t&&t.type)return function({data:e,type:t,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:a,projection:i,adjustedSize:s,chartSize:l,margin:c,axisCreator:d}){return"function"==typeof t.type?t.type({data:e,type:t,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:a,projection:i,adjustedSize:s,chartSize:l,margin:c,axisCreator:d}):(console.error(`Invalid summary type: ${t.type} - Must be a function`),{})}({data:e,type:t="string"==typeof t?{type:t}:t,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:a,projection:i,adjustedSize:s,chartSize:"vertical"===i?s[1]:s[0],margin:l,axisCreator:c})})({data:{column:{middle:e/2,pieceData:c,width:e,xyData:c}},type:t,renderMode:o,eventListenersGenerator:t.eventListenersGenerator||(()=>({})),styleFn:n,classFn:r,projection:"top"===a||"bottom"===a?"horizontal":"vertical",adjustedSize:l,margin:{top:0,bottom:0,left:0,right:0}}).marks);let u;if(!0===t.showPoints){const n=((e,t,n)=>{const o="left"===e||"right"===e?t/2:0,r="bottom"===e||"top"===e?t/2:0;return n.map(e=>[e.xy.x+o,e.xy.y+r])})(a,e,c);u=n.map((e,n)=>g.createElement("circle",{key:"axis-summary-point-"+n,cx:e[0],cy:e[1],r:t.r||3,style:t.pointStyle||{fill:"black",fillOpacity:.1}}))}_=g.createElement(he,{translation:{left:[2-k.left,0],right:[l[0]+2,0],top:[0,2-k.top],bottom:[0,l[1]+2]},orient:a,decoratedSummaryType:t,summaryWidth:e,renderedSummary:d,points:u})}const ee=(({axisParts:e,tickFormat:t,rotate:n=0,center:o=!1,orient:r})=>{const a=e.map((e,n)=>({axisPart:e,i:n,formatted:t(e.value,n)})),i="left"===r||"right"===r;let s=a;if(!n&&a.length>1){const e=8,t=14,n=8,o=e=>"string"==typeof e?e:"number"==typeof e?e+"":null;if("top"===r||"bottom"===r){const t=[...a].sort((e,t)=>e.axisPart.tx-t.axisPart.tx);let r=-1/0;const i=new Set;for(const a of t){const t=o(a.formatted);if(!t){i.add(a.i);continue}const s=t.length*e/2;r+n>a.axisPart.tx-s||(i.add(a.i),r=a.axisPart.tx+s)}s=a.filter(e=>i.has(e.i))}else if(i){const e=[...a].sort((e,t)=>e.axisPart.ty-t.axisPart.ty);let o=-1/0;const r=new Set;for(const a of e)o+t+n>a.axisPart.ty||(r.add(a.i),o=a.axisPart.ty);s=a.filter(e=>r.has(e.i))}}return s.map(({axisPart:e,i:t,formatted:a})=>{("object"!=typeof a||a instanceof Date)&&(a=g.createElement("text",{textAnchor:e.defaultAnchor,className:"axis-label"},a.toString?""+a:a));let i=e.tx,s=e.ty;if(o)switch(r){case"right":i-=(e.x2-e.x1)/2;break;case"left":i+=(e.x2-e.x1)/2;break;case"top":s+=(e.y2-e.y1)/2;break;case"bottom":s-=(e.y2-e.y1)/2}return g.createElement("g",{key:t,pointerEvents:"none",transform:`translate(${i},${s}) rotate(${n})`,className:"axis-label"},a)})})({tickFormat:s,axisParts:O,orient:a,rotate:n,center:E});if(o){const e=o.name||o,t=o.position||{};let n=t.anchor||"middle";const r=o.locationDistance||P,i=t.rotation||{left:-90,right:90,top:0,bottom:0}[a],s={left:{start:[0,l[1]],middle:[0,l[1]/2],end:[0,0],inside:[r||15,0],outside:[-(r||45),0]},right:{start:[l[0]+0,l[1]],middle:[l[0]+0,l[1]/2],end:[l[0]+0,0],inside:[-(r||15),0],outside:[r||45,0]},top:{start:[0,0],middle:[0+l[0]/2,0],end:[0+l[0],0],inside:[0,r||15],outside:[0,-(r||40)]},bottom:{start:[0,l[1]],middle:[0+l[0]/2,l[1]],end:[0+l[0],l[1]],inside:[0,-(r||5)],outside:[0,r||50]}},c=s[a][n],d=s[a][t.location||"outside"];c[0]=c[0]+d[0],c[1]=c[1]+d[1],"start"===n&&"right"===a?n="end":"end"===n&&"right"===a&&(n="start"),z=g.createElement(fe,{className:u,translation:c,position:C,rotation:i,labelName:e,anchorMod:n})}const te=`${a} axis ${O&&O.length>0&&`from ${s(O[0].value,0)} to ${s(O[O.length-1].value,O.length-1)}`||"without ticks"}`;return g.createElement("g",{className:u,"aria-label":te,ref:j},L,ee,N,!0===b?g.createElement("line",{key:"baseline",className:"axis-baseline "+u,stroke:"black",strokeLinecap:"square",x1:I,x2:X,y1:Y,y2:q}):null,z,_)},exports.ChordDiagram=ft,exports.CirclePack=xt,exports.ForceDirectedGraph=pt,exports.Legend=be,exports.SankeyDiagram=ht,exports.StreamNetworkFrame=ce,exports.TreeDiagram=gt,exports.Treemap=mt,exports.calculateDataExtent=({lineDataAccessor:e,xAccessor:t,yAccessor:n,summaries:o,points:a,lines:s,lineType:l,showLinePoints:c,showSummaryPoints:d,xExtent:u,yExtent:h,invertX:f,invertY:m,summaryDataAccessor:v,summaryType:b,adjustedSize:k,margin:E,summaryStyleFn:M,summaryClassFn:A,summaryRenderModeFn:S,chartSize:$,filterRenderedLines:w,filterRenderedSummaries:P,filterRenderedPoints:D,defined:j=Ze,annotations:N=[]})=>{let O=[],C=[],W=[],L=[],_=[];if(a){t.forEach((e,t)=>{n.forEach((n,o)=>{let r=0;for(const i of a){const a=e(i,r),s=n(i,r),l={x:a,y:s,data:i,xIndex:t,yIndex:o};Array.isArray(s)&&(l[qe]=Math.min(...s),l[Xe]=Math.max(...s),l[Ye]=(l[qe]+l[Xe])/2),Array.isArray(a)&&(l[He]=Math.min(...a),l[Ve]=Math.max(...a),l[Ge]=(l[He]+l[Ve])/2),W.push(l),r++}})});for(const e of W)O.push(Object.assign(Object.assign({},e),{[Re]:e[Ve]||e[He]||e.x,[Ie]:e[Xe]||e[qe]||e.y}))}if(s){C=(({data:e,lineDataAccessor:t,xProp:n,xPropTop:o,xPropBottom:r,yProp:a,yPropTop:i,yPropBottom:s,xAccessor:l,yAccessor:c})=>{Array.isArray(e)||(e=[e]);const d=[];return t.forEach((t,u)=>{l.forEach((l,y)=>{c.forEach((c,p)=>{e.forEach(e=>{const h=Object.assign(Object.assign({},e),{xIndex:y,yIndex:p,lineIndex:u});h.data=t(e).map((e,t)=>{const d={data:e};return d[n]=l(e,t),d[o]=d[n],d[r]=d[n],d[a]=c(e,t),d[i]=d[a],d[s]=d[a],d}),h.key=h.key||d.length,d.push(h)})})})}),d})({data:s,lineDataAccessor:e,xProp:Re,xPropTop:Ve,xPropBottom:He,yProp:Ie,yPropTop:Xe,yPropBottom:qe,xAccessor:t,yAccessor:n}),L=function(e,t){return n=>et[((e,t)=>!et[e]||"difference"===e&&2!==t.length?"line":e)(e.type,n)](Object.assign(Object.assign(Object.assign({},e),t),{data:n}))}(l,{xProp:Re,yProp:Ie,yPropMiddle:Ye,yPropTop:Xe,yPropBottom:qe,xPropMiddle:Ge,xPropTop:Ve,xPropBottom:He})(C);for(const e of L)for(let t=0;e.data.length>t;t++){const n=e.data[t];if(!j(Object.assign({},n.data,n),t))continue;const o={parentLine:e,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),O.push(o)}if(c){const e=!0===c?Ge:Ue[c],t=!0===c?Ye:Qe[c];L.forEach(n=>{n.data.filter((e,t)=>{if(j(Object.assign({},e.data,e))){if("orphan"===c){const e=n.data[t-1],o=n.data[t+1];return!(e&&j(Object.assign({},e.data,e))||o&&j(Object.assign({},o.data,o)))}return!0}return!1}).forEach(o=>{W.push(Object.assign(Object.assign({},o),{parentLine:n,[Ie]:void 0!==o[t]?o[t]:void 0!==o[Ye]?o[Ye]:void 0!==o[qe]?o[qe]:o.y,[Re]:void 0!==o[e]?o[e]:void 0!==o[Ge]?o[Ge]:void 0!==o[He]?o[He]:o.y}))})})}}o&&(_=(({data:e,summaryDataAccessor:t,xAccessor:n,yAccessor:o})=>{const r=[];return t.forEach(t=>{n.forEach(n=>{o.forEach(o=>{const a=e=>t(e).map((e,t)=>[n(e,t),o(e,t)]);e.forEach(e=>{r.push(Object.assign(Object.assign({},e),{_baseData:t(e),_xyfCoordinates:a(e)}))})})})}),r})({data:o,summaryDataAccessor:v,xAccessor:t,yAccessor:n}),_.forEach(e=>{const t=e._baseData;e._xyfCoordinates.length>0&&e._xyfCoordinates[0][0][0]?e._xyfCoordinates[0].forEach(n=>{Array.isArray(n)&&n.map((n,o)=>Object.assign({parentSummary:e},t[o],{[Re]:n[0],[Ie]:n[1]})).forEach(e=>{d&&W.push(Object.assign(Object.assign({x:0},e),{[Ie]:e[Xe]||e[qe]||e[Ie]})),O.push(Object.assign({x:0,y:0},e))})}):e._xyfCoordinates.length>0&&Array.isArray(e._xyfCoordinates)&&e._xyfCoordinates.map((n,o)=>Object.assign(Object.assign({parentSummary:e},t[o]),{[Re]:n[0],[Ie]:n[1]})).forEach(e=>{d&&W.push(Object.assign(Object.assign({x:0},e),{[Ie]:e[Xe]||e[qe]||e[Ie]})),O.push(Object.assign({x:0,y:0},e))})}));let z,F,T,B,R=[],I=[];u&&!Array.isArray(u)&&!0===u.includeAnnotations&&t.forEach(e=>{N.forEach((t,n)=>{const o=e(t,n);isFinite(o)&&R.push({[Re]:o})})}),h&&!Array.isArray(h)&&!0===h.includeAnnotations&&n.forEach(e=>{N.forEach((t,n)=>{const o=e(t,n);isFinite(o)&&I.push({[Ie]:o})})});for(const e of O){const t=void 0===e[He]?e[Re]:Math.min(e[Ve],e[He]),n=void 0===e[Ve]?e[Re]:Math.max(e[He],e[Ve]),o=void 0===e[qe]?e[Ie]:Math.min(e[Xe],e[qe]),r=void 0===e[Xe]?e[Ie]:Math.max(e[qe],e[Xe]);void 0===t||void 0!==z&&t>=z||(z=t),void 0===n||void 0!==F&&F>=n||(F=n),void 0===o||void 0!==T&&o>=T||(T=o),void 0===r||void 0!==B&&B>=r||(B=r)}for(const e of R){const t=e[Re];void 0===t||void 0!==z&&t>=z||(z=t),void 0===t||void 0!==F&&F>=t||(F=t)}for(const e of I){const t=e[Ie];void 0===t||void 0!==T&&t>=T||(T=t),void 0===t||void 0!==B&&B>=t||(B=t)}const Y=[z,F],X=[T,B],q=Je(u),G=Je(h);let V=[G&&void 0!==G[0]?G[0]:X[0],G&&void 0!==G[1]?G[1]:X[1]],H=[q&&void 0!==q[0]?q[0]:Y[0],q&&void 0!==q[1]?q[1]:Y[1]];if(!f||q&&2===q.length||(H=[H[1],H[0]]),"bumpline"!==l.type&&!m||G&&2===G.length||(V=[V[1],V[0]]),b.type&&"contour"===b.type)_=function({summaryType:e,data:t,finalXExtent:n,finalYExtent:o}){let r=[];e.type||(e={type:e});const{resolution:a=500,thresholds:s=10,bandwidth:l=20,neighborhood:c}=e,d=i.scaleLinear().domain(n).rangeRound([0,a]).nice(),u=i.scaleLinear().domain(o).rangeRound([a,0]).nice();return t.forEach(e=>{let t=y.contourDensity().size([a,a]).x(e=>d(e[0])).y(e=>u(e[1])).thresholds(s).bandwidth(l)(e._xyfCoordinates);c&&(t=[t[0]]);const n=Math.max(...t.map(e=>e.value));t.forEach(t=>{t.parentSummary=e,t.bounds=[],t.percent=t.value/n,t.coordinates.forEach(e=>{e.forEach((n,o)=>{e[o]=n.map(e=>[d.invert(e[0]),u.invert(e[1])]),0===o&&t.bounds.push(function(e){let t=[1/0,0],n=[-1/0,0],o=[0,1/0],r=[0,-1/0];return e.forEach(e=>{t=t[0]>e[0]?e:t,n=e[0]>n[0]?e:n,r=e[1]>r[1]?e:r,o=o[1]>e[1]?e:o}),{center:[(t[0]+n[0])/2,(o[1]+r[1])/2],top:o,left:t,right:n,bottom:r}}(e[o]))})})}),r=[...r,...t]}),r}({summaryType:b,data:_,finalXExtent:H,finalYExtent:V});else if(b.type&&"linebounds"===b.type){if(_=function({summaryType:e,data:t,defined:n}){let o=[];e.type||(e={type:e});const{boundingAccessor:r,topBoundingAccessor:a=r,bottomBoundingAccessor:i=r}=e;return t.forEach(e=>{const t=e._baseData.map(n);let r=[],s=[];const l=[{xyf:s,base:r}];t.forEach((n,o)=>{!0===n?(r.push(e._baseData[o]),s.push(e._xyfCoordinates[o])):t[o+1]&&(r=[],s=[],l.push({xyf:s,base:r}))}),l.forEach(({xyf:t,base:n})=>{const r={data:e,parentSummary:e,_xyfCoordinates:Ke(t,n,a,i)};o=[...o,r]})}),o}({summaryType:b,data:_,defined:j}),!G||2!==G.length)for(const e of _)for(const t of e._xyfCoordinates){const e=t[1];void 0!==e&&isFinite(e)&&(V[0]>e&&(V[0]=e),e>V[1]&&(V[1]=e))}}else b.type&&"hexbin"===b.type?(_=function({preprocess:e=!0,processedData:t=!1,summaryType:n,data:o,finalXExtent:r,finalYExtent:a,size:s,xScaleType:l=i.scaleLinear(),yScaleType:c=i.scaleLinear(),margin:d,styleFn:u,classFn:y,renderFn:h,chartSize:f}){let m=r,x=a;if(!m){const e=o.coordinates.map(e=>e.x);m=[Math.min(...e),Math.max(...e)]}if(!x){const e=o.coordinates.map(e=>e.y);x=[Math.min(...e),Math.max(...e)]}if(t&&o)return o.coordinates;let v,b=[];v=n.type?n:{type:v};const{bins:k=.05,cellPx:E,binValue:M=e=>e.length,binMax:A,customMark:S}=v;o.coordinates&&!o._xyfCoordinates&&(o._xyfCoordinates=o.coordinates.map(e=>[e.x,e.y]));const $=Array.isArray(o)?o:[o],w=l.domain(m).range([0,s[0]]),P=c.domain(x).range([0,s[1]]),D=E&&E/2||(k>1?1/k:k)*s[0]/2,j=p.hexbin().x(e=>w(e._xyfPoint[0])).y(e=>P(e._xyfPoint[1])).radius(D).size(s);let N;const O=j.centers();return $.forEach(e=>{N=0;const t=j(e._xyfCoordinates.map((t,n)=>Object.assign({_xyfPoint:t},e.coordinates[n]))),n={};t.forEach(e=>{n[`${parseInt(e.x)}-${parseInt(e.y)}`]=!0}),O.forEach(e=>{if(!n[`${parseInt(e[0])}-${parseInt(e[1])}`]){const n=[];n.x=e[0],n.y=e[1],t.push(n)}}),N=Math.max(...t.map(e=>M(e))),A&&A(N);const o=[[0,-1],[.866,-.5],[.866,.5],[0,1],[-.866,.5],[-.866,-.5]],r=w.invert(D)-m[0],a=P.invert(D)-x[0],i=o.map(e=>[e[0]*r,e[1]*a]),l=t.map(t=>{const n=M(t),r=t.x,a=t.y;t.x=w.invert(t.x),t.y=P.invert(t.y);const l=n/N;return{customMark:S&&g.createElement("g",{transform:`translate(${r},${s[1]-a})`},S({d:Object.assign(Object.assign({},t),{binItems:t,percent:l,value:n,radius:D,hexCoordinates:o.map(e=>[e[0]*D,e[1]*D])}),margin:d,styleFn:u,classFn:y,renderFn:h,chartSize:f,adjustedSize:s})),_xyfCoordinates:i.map(e=>[e[0]+t.x,e[1]+t.y]),value:n,percent:l,data:t,parentSummary:e,centroid:!0}});b=[...b,...l]}),e?(b.forEach(e=>{e.x=e.data.x,e.y=e.data.y}),{type:"hexbin",processedData:!0,coordinates:b,binMax:N}):b}({summaryType:b,data:_[0],processedData:o&&!!o[0].processedData,preprocess:!1,finalXExtent:H,finalYExtent:V,size:k,margin:E,styleFn:M,classFn:A,renderFn:S,chartSize:$}),O=tt(O,_)):b.type&&"heatmap"===b.type?(_=function({preprocess:e=!0,processedData:t=!1,summaryType:n,data:o,finalXExtent:r=[Math.min(...o.coordinates.map(e=>e.x)),Math.max(...o.coordinates.map(e=>e.x))],finalYExtent:a=[Math.min(...o.coordinates.map(e=>e.y)),Math.max(...o.coordinates.map(e=>e.y))],size:s,xScaleType:l=i.scaleLinear(),yScaleType:c=i.scaleLinear(),margin:d,styleFn:u,classFn:y,renderFn:p,chartSize:h}){if(t&&o)return o.coordinates;o.coordinates&&!o._xyfCoordinates&&(o._xyfCoordinates=o.coordinates.map(e=>[e.x,e.y]));const f=Array.isArray(o)?o:[o];let m,x=[];m=n.type?n:{type:m};const{binValue:v=e=>e.length,xBins:b=m.yBins||.05,yBins:k=b,xCellPx:E=!m.xBins&&m.xCellPx,yCellPx:M=!m.yBins&&m.yCellPx,customMark:A,binMax:S}=m,$=1>b?b:1/b,w=1>k?k:1/k,P=l.domain(r).range([0,s[0]]),D=c.domain(a).range([s[1],0]),j=[Math.ceil((E&&E/s[0]||$)*s[0]*10)/10,Math.ceil((M&&M/s[1]||w)*s[1]*10)/10];let N=-1/0;return f.forEach(e=>{const t=[],n=[];let o,r;for(let a=0;s[0]>Math.ceil(a);a+=j[0]){const i=P.invert(a),l=P.invert(a+j[0]);r=[],t.push(r);for(let t=0;s[1]>Math.ceil(t);t+=j[1]){const s=D.invert(t),c=D.invert(t+j[1]);o={gx:a,gy:t,gw:j[0],gh:j[1],x:(i+l)/2,y:(s+c)/2,binItems:[],value:0,_xyfCoordinates:[[i,s],[l,s],[l,c],[i,c]],parentSummary:e},r.push(o),n.push(o)}r.push(o)}t.push(r),e._xyfCoordinates.forEach((n,o)=>{const r=P(n[0]),a=D(n[1]),i=Math.floor(r/j[0]),s=Math.floor(a/j[1]);t[i][s]&&t[i][s].binItems.push(e.coordinates[o])}),n.forEach(e=>{e.value=v(e.binItems),N=Math.max(N,e.value)}),n.forEach(e=>{e.percent=e.value/N,e.customMark=A&&g.createElement("g",{transform:`translate(${e.gx},${e.gy})`},A({d:e,margin:d,styleFn:u,classFn:y,renderFn:p,chartSize:h,adjustedSize:s}))}),x=[...x,...n]}),S&&S(N),e?{type:"heatmap",processedData:!0,_baseData:[],_xyfCoordinates:[],data:[],bounds:[],x:0,y:0,coordinates:x,binMax:N}:x}({summaryType:b,data:_[0],processedData:o&&!!o[0].processedData,preprocess:!1,finalXExtent:H,finalYExtent:V,size:k,margin:E,styleFn:M,classFn:A,renderFn:S,chartSize:$}),O=tt(O,_)):b.type&&"trendline"===b.type&&(_=function({preprocess:e=!1,summaryType:t,data:n,finalXExtent:o=[Math.min(...n.coordinates.map(e=>e.x)),Math.max(...n.coordinates.map(e=>e.x))],xScaleType:a=i.scaleLinear()}){if(e)return n[0].coordinates;let s,l=[];s=t.type?t:{type:s};const{regressionType:c="linear",order:d=2,precision:u=4,controlPoints:y=20,curve:p=r.curveCardinal}=s;let h=c;o[0]>=0||"logarithmic"!==c&&"power"!==c&&"exponential"!==c||(console.error(`Cannot use this ${c} regressionType type with value range that goes below 0, defaulting to linear`),h="linear"),n.coordinates&&!n._xyfCoordinates&&(n._xyfCoordinates=n.coordinates.map(e=>[e.x,e.y]));const f=Array.isArray(n)?n:[n],g=a.domain([0,1]).range(o);return l=[],f.forEach(e=>{const t=x.default[h](e._xyfCoordinates.map(e=>{let t=e[0],n=e[1];return"number"!=typeof t&&(t=t.getTime()),"number"!=typeof n&&(n=n.getTime()),[t,n]}),{order:d,precision:u}),n=1/y;let o=[0,1];if("linear"!==h){o=[];for(let e=0;1+n>e;e+=n)o.push(e)}const r=[];o.forEach(e=>{r.push(t.predict(g(e)))}),l.push({centroid:!1,customMark:void 0,data:e,parentSummary:e,value:t.string,r2:t.r2,curve:p,_xyfCoordinates:r})}),l}({summaryType:b,data:_[0],preprocess:o&&!!o[0].processedData,finalXExtent:H}),O=tt(O,_));return w&&(L=L.filter(w),O=O.filter((e,t)=>!e.parentLine||w(e.parentLine,t,[]))),D&&(O=O.filter(D)),P&&(_=_.filter(P),O=O.filter((e,t)=>!e.parentSummary||P(e.parentSummary,t,[]))),{xExtent:H,yExtent:V,projectedLines:L,projectedPoints:W,projectedSummaries:_,fullDataset:O,calculatedXExtent:Y,calculatedYExtent:X}},exports.nodesEdgesFromHierarchy=(e,t=ot)=>{var n,o;const r=[],a=[],i=(e.descendants?e:c.hierarchy(e)).descendants();let s=0;for(const e of i)e.descendantIndex=s,s++;for(const e of i){const i=`${null!==(n=t(Object.assign(Object.assign({},e),e.data)))&&void 0!==n?n:ot(e)}-${e.parent?null!==(o=nt(t,Object.assign(Object.assign({},e.parent),e.parent.data),""))&&void 0!==o?o:e.parent.name:"root"}`,s=Object.assign(e,e.data||{},{hierarchicalID:i});if(a.push(s),null!==e.parent){const t=Object.assign(e.parent,e.parent.data||{});r.push({source:t,target:s,depth:e.depth,weight:1,value:1,_NWFEdgeKey:i})}}return{edges:r,nodes:a}};
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),a=require("d3-force"),o=require("d3-scale"),i=require("d3-chord"),c=require("d3-shape"),s=require("d3-hierarchy");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=l(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var a;for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const c=r[i.edgeIndex];if(!c||!c.bezier){i.active=!1;continue}const s=n&&null!==(a=n[i.edgeIndex])&&void 0!==a?a:1;if(i.t+=e*t*s*(c.bezier.circular?.3:1),i.t>=1){i.active=!1;continue}const l=y(c.bezier,i.t,i.offset);i.x=l.x,i.y=l.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const a=e.length,o=t*a,i=Math.min(Math.floor(o),a-1),c=o-i,[s,l,u,d]=e[i],h=g(s,l,u,d,c),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,a,o,i]=e.points,c=g(n,a,o,i,t),s=i.x-n.x,l=i.y-n.y,u=Math.sqrt(s*s+l*l);if(u>.001){const t=s/u;c.x+=-l/u*r*e.halfWidth*2,c.y+=t*r*e.halfWidth*2}return c}function g(e,t,r,n,a){const o=1-a,i=o*o,c=i*o,s=a*a,l=s*a;return{x:c*e.x+3*i*a*t.x+3*o*s*r.x+l*n.x,y:c*e.y+3*i*a*t.y+3*o*s*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],a=[],o=[],i={},c=[];function s(e){o[e]=!1,i.hasOwnProperty(e)&&Object.keys(i[e]).forEach(function(t){delete i[e][t],o[t]&&s(t)})}function l(e){var t,n,d=!1;for(a.push(e),o[e]=!0,t=0;c[e].length>t;t++)(n=c[e][t])===r?(u(r,a),d=!0):o[n]||(d=l(n));if(d)s(e);else for(t=0;c[e].length>t;t++){var h=i[n=c[e][t]];h||(i[n]=h={}),h[n]=!0}return a.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),a=Array(t),o=Array(t),i=Array(t),c=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,a[s]=!1,o[s]=0,i[s]=-1,c[s]=[];var l,u=0,d=[],h=[];function f(t){var s=[t],l=[t];for(r[t]=n[t]=u,a[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var y=o[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,a[g]=!0,u+=1,s.push(g),l.push(g);break}a[g]&&(n[t]=0|Math.min(n[t],n[g])),0>i[g]||c[t].push(i[g])}o[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(a[b]=!1,p.push(b),v.push(c[b]),m+=c[b].length,i[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}l.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);h[s]=l}}return{components:d,adjacencyList:h}}(e),a=n.components.filter(function(e){return e.length>1}),o=1/0,i=0;a.length>i;i++)for(var c=0;a[i].length>c;c++)o>a[i][c]&&(o=a[i][c],r=i);var s=a[r];if(!s)return!1;var l=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:o,adjList:l}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,c=f.adjList){for(var y=0;c.length>y;y++)for(var g=0;c[y].length>g;g++){var p=c[y][g];o[+p]=!1,i[p]={}}l(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function L(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function E(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function D(e,t){return t(e)}function A(e){return P(e.source)}function S(e){return P(e.target)}function P(e){return(e.y0+e.y1)/2}function T(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function O(e){return e.target.depth}function _(e,t){return e.sourceLinks.length?e.depth:t-1}function $(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function I(e,t){return e.y1-t.y1}function W(e,t){return t.y1-e.y1}function C(e,t){return R(e.source,t.source)||e.index-t.index}function j(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function B(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?N(e,t):$(e,t):z(t)-z(e)}function z(e){return e.target.column-e.source.column}function F(e,t){return Y(e)==Y(t)}function Y(e){return e.y0-e.y1>0?"up":"down"}function X(e,t,n,a,o){let i=e;var c=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,c))});var s=r.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),H(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),H(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+a,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==r&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?N:$);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=a+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(l=i.links.filter(function(e){return e.target.column==r&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?W:I),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=a+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=a+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,a=e.y1,o=(t+n)/2;return"M"+t+","+r+"C"+o+","+r+" "+o+","+a+" "+n+","+a}(e)}),i}function H(e,t,r){e.sort(B);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,a){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var i=0;n.length>i;i++){var c=n[i];if(c!==e&&c.circularPathData&&void 0!==c.circularPathData.verticalBuffer&&G(e,c)){var s=c.circularPathData.verticalBuffer+(c._circularWidth||c.width)/2+r;o=s>o?s:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var a=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});a.forEach(function(r){var o=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==a.length-1&&1==o||0==t.depth&&1==o?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/o*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-o/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,a,o,i){var c=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,l=i;l>0;--l)u(s*=.99,n),d();function u(t,n){var a=c.length;c.forEach(function(o){var i=o.length,c=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&M(o,n)>0){var l=r.mean(o.sourceLinks,S),u=r.mean(o.targetLinks,A),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-P(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==c&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(c==a-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=r.mean(o.sourceLinks,S),y=r.mean(o.targetLinks,A),g=((f&&y?(f+y)/2:f||y)-P(o))*t;o.y0+=g,o.y1+=g}})})}function d(){c.forEach(function(r){var n,i,c,s=e.y0,l=r.length;for(r.sort(t||R),c=0;l>c;++c)(i=s-(n=r[c]).y0)>0&&(n.y0+=i,n.y1+=i),s=n.y1+a;if((i=s-a-e.y1)>0)for(s=n.y0-=i,n.y1-=i,c=l-2;c>=0;--c)(i=(n=r[c]).y1+o-s)>0&&(n.y0-=i,n.y1-=i),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(j),e.targetLinks.sort(C)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,a=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=a-e.width/2,a-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,a=1,o=24,i=8,c=null,s=V,l=_,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=a,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,a=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof a&&(a=e.target=p(n,a)),r.sourceLinks.push(e),a.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],a=0;e.links.length>a;a++){var o=e.links[a],i=o.source.index,c=o.target.index;n[i]||(n[i]=[]),n[c]||(n[c]=[]),-1===n[i].indexOf(c)&&n[i].push(c)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var l={};for(a=0;s.length>a;a++){var u=s[a].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(a){a.circular&&(a.circularLinkType=a.source.circularLinkType||a.target.circularLinkType?a.source.circularLinkType?a.source.circularLinkType:a.target.circularLinkType:n>r?"top":"bottom","top"==a.circularLinkType?r++:n++,e.nodes.forEach(function(e){D(e,t)!=D(a.source,t)&&D(e,t)!=D(a.target,t)||(e.circularLinkType=a.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,T),r.sum(e.targetLinks,T)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,a,o;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var i=0,c=t(e.nodes[0]);e.nodes.forEach(function(e){i=t(e)==c?i:i+1,c=t(e)==c?c:t(e),e.column=i})}for(n=e.nodes,a=[],o=0;n.length;++o,n=a,a=[])n.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>a.indexOf(e.target)&&!e.circular&&a.push(e.target)})});for(n=e.nodes,a=[],o=0;n.length;++o,n=a,a=[])n.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>a.indexOf(e.source)&&!e.circular&&a.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,o):e.column})}(f,u,l);var y=i;if(null!==c){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(a-t)*c/(m-1)))}(function(e,t,n){var a=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=r.min(a,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,o),Q(f,u,s),J(f,u,s,y,y,d),U(f),X(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),X(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return D(r.source,t)==D(e,t)}),a=n.length;a>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!F(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;n.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var o=r+1,i=0;a>o;o++)i+=n[o].width;t.y0=e.y1-i-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return D(r.target,t)==D(e,t)}),a=n.length;a>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!F(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=L(t,e);return e.y0-r}if(t.source.column>e.source.column)return L(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;n.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var o=r+1,i=0;a>o;o++)i+=n[o].width;t.y1=e.y1-i-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,a=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?a=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==a||0==o){var i=r.min(t,function(e){return e.y0}),c=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(c-i);function l(t){return(t-i)/(c-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),X(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),X(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(c=+e,g):c},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:q(e),g):l},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],a=+r[1][1],g):[[e,t],[n,a]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],a=+r[1],g):[n-e,a-t]},g}const te=e=>{let r,n,a,o,i,c,s,l,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,a=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.y1,c=e.target.y0,s=t.interpolateNumber(i,c),l=s(.5),u=s(.5),`M${r},${i}C${r},${l} ${n},${u} ${n},${c}L${a},${c}C${a},${u} ${o},${l} ${o},${i}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),a=s(.5),o=s(.5),i=e.y0-e.sankeyWidth/2,c=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${i}C${a},${i} ${o},${c} ${n},${c}L${n},${l}C${o},${l} ${a},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,a=e.circularPathData;if(!a)return null;if("down"===e.direction)return null;if(e._circularStub){const t=a.sourceX,n=a.sourceY,o=a.targetX,i=a.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const c=Math.max(15,Math.min(40,.33*(a.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(o-a.leftFullExtent)));return`M${t},${n-r}L${t+c},${n-r}L${t+c},${n+r}L${t},${n+r}ZM${o},${i-r}L${o-s},${i-r}L${o-s},${i+r}L${o},${i+r}Z`}const o=a.sourceX,i=a.sourceY,c=a.targetX,s=a.targetY,l=a.rightFullExtent,u=a.leftFullExtent,d=a.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${o},${i-h*r}L${l},${i-h*r}L${l+n},${i-h*r+h*f}L${l+n},${d+h*n-h*f}L${l+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${c},${s-h*r}L${c},${s+h*r}L${u},${s+h*r}L${u},${d-h*n}L${l},${d-h*n}L${l},${i+h*r}L${o},${i+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(O))-1:0},justify:_},ae={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var a,o,i,c,s,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(a=r.nodeWidth)&&void 0!==a?a:15,y=null!==(o=r.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(i=r.iterations)&&void 0!==i?i:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||_).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,a=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>a&&(a=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const o=n.circularPathData,i=(null!==(s=null!==(c=n._circularWidth)&&void 0!==c?c:n.width)&&void 0!==s?s:0)/2;e>o.leftFullExtent-i&&(e=o.leftFullExtent-i),o.rightFullExtent+i>t&&(t=o.rightFullExtent+i),r>o.verticalFullExtent-i&&(r=o.verticalFullExtent-i),o.verticalFullExtent+i>a&&(a=o.verticalFullExtent+i)}const o=t-e,i=a-r,u=n[0],d=n[1];if(o>0&&i>0&&(0>e||0>r||t>u||a>d)){const t=Math.min(u/o,d/i),n=-e*t+(u-o*t)/2,a=-r*t+(d-i*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+a,e.y1=e.y1*t+a;for(const e of v)if(e.y0=e.y0*t+a,e.y1=e.y1*t+a,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+a,r.targetY=r.targetY*t+a,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+a,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+a,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+a,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",a="object"==typeof r&&null!==r?r.id:r+"",o=k.get(`${n}\0${a}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=d;const t=x.get(n),r=x.get(a);t&&(o.source=t),r&&(o.target=r)}}},buildScene(e,t,r,a){var o,i,c,s;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},a={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:a,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const a=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=a.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+o},${t.sourceY-r}L${t.sourceX+o},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:a.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(c=a.fillOpacity)&&void 0!==c?c:h,stroke:"none",opacity:a.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let o;if(o=e.circular&&e.circularPathData?re(e):te(e),!o)continue;const l={fill:a.fill||n,fillOpacity:null!==(s=a.fillOpacity)&&void 0!==s?s:h,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};v.push({type:"bezier",pathD:o,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const o=t?t(r):r.id;if(!o)continue;let i,c,s;"down"===l?(i=r.x0+e/2,c=r.y1+14,s="middle"):(a[0]/2>r.x0+e/2?(i=r.x0-6,s="end"):(i=r.x1+6,s="start"),c=r.y0+n/2),m.push({x:i,y:c,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},oe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var o,i;if(0===e.length)return;const c=null!==(o=r.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=l+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ie(r.nodeSize,r.nodeSizeRange,e),h=a.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=a.forceSimulation().force("charge",a.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",a.forceX(n[0]/2).strength(.1*f)).force("y",a.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;c>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,a){var o,i,c;const s=r.nodeStyle,l=r.edgeStyle,u=ie(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(e):{},a={stroke:n.stroke||"#999",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(c=n.opacity)&&void 0!==c?c:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:a,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ie(e,t,n){var a,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const c=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>c[0];const l=null!==(a=r.min(s))&&void 0!==a?a:0,u=null!==(i=r.max(s))&&void 0!==i?i:1;if(l===u)return()=>(c[0]+c[1])/2;const d=o.scaleLinear().domain([l,u]).range(c).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?c[0]:d(n)}}const ce=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:a=.01,groupWidth:o=20,sortGroups:s}=r,l=Math.min(n[0],n[1])/2,u=l-o,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const a=f(e);v[r][n]=a}const m=i.chord().padAngle(a);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const L=new Map;for(const e of t)L.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,a=L.get(`${r}\0${n}`)||L.get(`${n}\0${r}`);a&&(a.chordData=t)}},buildScene(e,t,r,n){var a,o;const{groupWidth:c=20,edgeOpacity:s=.5}=r,l=Math.min(n[0],n[1])/2,u=l-c,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:ce,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=i.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let o;o=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const i=f?f(r):{},c={fill:o,stroke:i.stroke||"black",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:c,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=le(r,d,h);let a="#999";if(y)a=y(e).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?a=v.get(r.id)||a:t&&(a=v.get(t.id)||a)}const i=y?y(e):{},c={fill:a,fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};x.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=l+12;for(const r of e){const e=r.arcData;if(!e)continue;const a=t?t(r):r.id;if(!a)continue;const o=(e.startAngle+e.endAngle)/2,i=o-Math.PI/2;k.push({x:d+Math.cos(i)*n,y:h+Math.sin(i)*n,text:a+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function le(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const a=[];let o=0;for(;n.length>o;){const e=n[o];if("M"===e||"L"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("C"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)for(let e=0;3>e&&n.length>o&&!isNaN(Number(n[o]));e++)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("Q"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)for(let e=0;2>e&&n.length>o&&!isNaN(Number(n[o]));e++)a.push(Number(n[o])+t+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(a.push(Number(n[o])+r+""),o++);else if("A"===e)for(a.push(e),o++;n.length>o&&!isNaN(Number(n[o]));)a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&a.push(n[o++]),n.length>o&&(a.push(Number(n[o])+t+""),o++),n.length>o&&(a.push(Number(n[o])+r+""),o++);else"Z"===e||"z"===e?(a.push(e),o++):(a.push(n[o]),o++)}return a.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var a;const o=r.__hierarchyRoot;if(!o)return;const i=r.chartType,c=(l=r.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(o,c);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(i){case"tree":!function(e,t,r,n){const a=t.treeOrientation||"vertical",o=s.tree();o.size("horizontal"===a?[n,r]:"radial"===a?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const a=t.treeOrientation||"vertical",o=s.cluster();o.size("horizontal"===a?[n,r]:"radial"===a?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var a,o;const i=null!==(a=t.padding)&&void 0!==a?a:4,c=null!==(o=t.paddingTop)&&void 0!==o?o:0,l=s.treemap().size([r,n]).tile(s.treemapBinary).padding(i);c>0&&l.paddingTop(c),l(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var a;const o=null!==(a=t.padding)&&void 0!==a?a:4;s.pack().size([r,n]).padding(o)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var a;s.partition().size([r,n]).padding(null!==(a=t.padding)&&void 0!==a?a:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],o={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(a=n.value)&&void 0!==a?a:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?de(o,n,r):"treemap"===i||"partition"===i?he(o,n):"circlepack"===i&&fe(o,n),o.__hierarchyNode=n,e.push(o),g.set(n,o)}if("tree"===i||"cluster"===i)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const a=r.nodeStyle||(()=>({})),o=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,a,o){var i,c,s,l,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const o=a(t);let c=o.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(c=b[t.depth%b.length]);const s={fill:c,stroke:o.stroke||"#fff",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:o.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(c=r.edgeOpacity)&&void 0!==c?c:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,a=t.y,i=r.x,c=r.y;g&&(n+=p,a+=v,i+=p,c+=v);const u=ye(n,a,i,c,y),d=o(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,a,o,i=r.x,c=r.y;if(g&&(i+=p,c+=v),g){const e=i-p,t=c-v,r=Math.sqrt(e*e+t*t);r>0?(n=i+e/r*10,a=c+t/r*10,o=0>e?"end":"start"):(n=i,a=c-12,o="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=i-m-6,o="end"):(n=i+m+6,o="start"),a=c):(n=i,a=c+m+14,o="middle");f.push({x:n,y:a,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,a,o);case"treemap":case"partition":return function(e,t,r,n){var a,o;const i=[],c=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,o=r.y1-r.y0;if(0>=e||0>=o)continue;const c=n(r);let l=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=s[r.depth%s.length]);const u={fill:l,stroke:c.stroke||"#fff",strokeWidth:null!==(a=c.strokeWidth)&&void 0!==a?a:1,opacity:c.opacity};i.push({type:"rect",x:r.x0,y:r.y0,w:e,h:o,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;if((null===(o=n.data)||void 0===o?void 0:o.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const i=r?r(n):n.id;i&&(30>e||16>a||c.push({x:n.x0+e/2,y:n.y0+a/2,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,a)/6))}))}}return{sceneNodes:i,sceneEdges:[],labels:c}}(e,r,0,a);case"circlepack":return function(e,t,r,n){var a,o,i,c,s;const l=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(a=r.__radius)&&void 0!==a?a:5;if(0>=e)continue;const c=n(r);let s=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:c.stroke||"#fff",strokeWidth:null!==(o=c.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=c.opacity)&&void 0!==i?i:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(c=t.__radius)&&void 0!==c?c:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const a=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:a?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:a?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:a?void 0:"#000",stroke:a?void 0:"#fff",strokeWidth:a?void 0:3,paintOrder:a?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,a);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,a){if("horizontal"===a){const a=(e+r)/2;return`M ${e},${t} C ${a},${t} ${a},${n} ${r},${n}`}if("radial"===a){const a=(e+r)/2;return`M ${e},${t} Q ${a},${t} ${a},${(t+n)/2} T ${r},${n}`}{const a=(t+n)/2;return`M ${e},${t} C ${e},${a} ${r},${a} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:ae,force:oe,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles?this.particlePool||(this.particlePool=new f(2e3)):this.particlePool=null}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:a="source",targetAccessor:o="target",valueAccessor:i="value"}=this.config,c="function"==typeof n?n:e=>e[n],s="function"==typeof a?a:e=>e[a],l="function"==typeof o?o:e=>e[o],u="function"==typeof i?i:e=>{var t;return null!==(t=e[i])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=c(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=l(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,a=0===this.nodes.size;let o=!1;const i="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=i,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,i),this.tension+=this.tensionConfig.newNode,o=!0);const c=this.edgeKey(t,r),s=this.edges.get(c);return s?(s.value+=n,this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.weightChange):(this.edges.set(c,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.newEdge,o=!0),a||o||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const a=new Set(this.nodes.keys()),o=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of a)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)a.has(e)||this.removedNodes.add(e);for(const e of o)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)o.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=a,this.previousEdgeKeys=o,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:a,sceneEdges:o,labels:i}=t.buildScene(r,n,this.config,e);this.sceneNodes=a,this.sceneEdges=o,this.labels=i}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const a=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=r.y1,i=n.y0,c=t.interpolateNumber(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:c(.5)},{x:e.y1,y:c(.5)},{x:e.y1,y:i}],halfWidth:a}}const o=r.x1,i=n.x0,c=t.interpolateNumber(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:c(.5),y:e.y0},{x:c(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:a}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const a=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],o=r.x-t.x,i=r.y-t.y;a.push([t,{x:t.x+o/3,y:t.y+i/3},{x:t.x+2*o/3,y:t.y+2*i/3},r])}return{circular:!0,segments:a,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,a,o;const i=this.config.pulse;if(!i)return;const c=null!==(t=i.duration)&&void 0!==t?t:500,s=null!==(r=i.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=i.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const a=e-n;c>a&&(t._pulseIntensity=1-a/c,t._pulseColor=s,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(a=r.source)||void 0===a?void 0:a.id:r.source,i="object"==typeof r.target?null===(o=r.target)||void 0===o?void 0:o.id:r.target;if(!n||!i)continue;const l=this.edgeTimestamps.get(`${n}\0${i}`);if(!l)continue;const u=e-l;c>u&&(t._pulseIntensity=1-u/c,t._pulseColor=s)}}applyDecay(){var e,t,r,n,a;const o=this.config.decay;if(!o)return;const i=null!==(e=o.minOpacity)&&void 0!==e?e:.1,c=this.nodeTimestamps.size;if(1>=c)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),l=new Map;for(let e=0;s.length>e;e++)l.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=l.get(s);if(void 0===u)continue;const d=c-1-u;let h;switch(o.type){case"linear":h=i+(1-d/(c-1))*(1-i);break;case"exponential":{const e=null!==(t=o.halfLife)&&void 0!==t?t:c/2;h=i+Math.pow(.5,d/e)*(1-i);break}case"step":h=(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*c)>d?1:i;break;default:h=1}const f=null!==(a=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==a?a:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const a=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",o=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",i=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const c=this.nodes.get(r);if(!c)continue;const s=n.metric(c);let l=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(l=a):l=o,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),i&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e,t,r,n,a=30){let o=null,i=a,c=1/0;for(const t of e){const e=we(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;c>r&&(o=e,c=r)}else i>e.distance&&(o=e,i=e.distance)}if(o)return o;for(const e of t){const t=Le(e,r,n);t&&i>t.distance&&(o=t,i=t.distance)}return o}function we(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,a=r-e.cy,o=Math.sqrt(n*n+a*a);return o>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:o}}(e,t,r);case"rect":return function(e,t,r){return e.x>t||t>e.x+e.w||e.y>r||r>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,a=r-e.cy,o=Math.sqrt(n*n+a*a);if(e.innerR-2>o||o>e.outerR+2)return null;let i=Math.atan2(a,n);0>i&&(i+=2*Math.PI);let c,s=e.startAngle,l=e.endAngle;if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),c=s>l?i>=s||l>=i:i>=s&&l>=i,c){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}function Le(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,a;if(!e.pathD)return null;try{const o=new Path2D(e.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(o,t,r)){const o="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,i="object"==typeof(null===(a=e.datum)||void 0===a?void 0:a.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:o&&i?(o.x1+i.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,a=e.y2-e.y1,o=n*n+a*a;if(0===o)return null;let i=((t-e.x1)*n+(r-e.y1)*a)/o;i=Math.max(0,Math.min(1,i));const c=e.x1+i*n,s=e.y1+i*a,l=Math.sqrt(Math.pow(t-c,2)+Math.pow(r-s,2));return l>5?null:{type:"edge",datum:e.datum,x:c,y:s,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}function Ee(e){const{width:t,height:r,totalWidth:n,totalHeight:a,margin:o,labels:i,title:c,legend:s,foregroundGraphics:l,annotations:d,svgAnnotationRules:h}=e;return u.createElement("svg",{width:n,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${o.left},${o.top})`},i.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),d&&h&&d.map((e,n)=>{const a=h(e,n,{width:t,height:r});return a?u.createElement(u.Fragment,{key:"annotation-"+n},a):null}),l),c&&"string"==typeof c?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?u.createElement("foreignObject",{x:0,y:0,width:n,height:o.top},c):null,s&&"object"==typeof s&&"legendGroups"in s?u.createElement("g",{transform:`translate(${n-o.right+10},${o.top})`},s.legendGroups.map((e,t)=>{var r;return u.createElement("g",{key:"legend-group-"+t},null===(r=e.items)||void 0===r?void 0:r.map((e,t)=>u.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},u.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),u.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):s?u.createElement("g",{transform:`translate(${n-o.right+10},${o.top})`},s):null)}function De(e,t){var r,n,a,o,i,c;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const i=t._gradient;if(i){const a=e.createLinearGradient(i.x0,0,i.x1,0),o=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,c=t.style.fill;a.addColorStop(0,1===i.from?c:"transparent"),a.addColorStop(1,1===i.to?c:"transparent"),e.fillStyle=a,e.globalAlpha=o}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:t.style.opacity)&&void 0!==o?o:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.5*(null!==(c=t.style.opacity)&&void 0!==c?c:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Ae(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Se(e,t){var r,n,a,o;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.3*(null!==(o=t.style.opacity)&&void 0!==o?o:1),e.stroke(i)),e.restore()}function Pe(e,t){var r,n;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(a),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(a)),e.restore()}Ee.displayName="NetworkSVGOverlay";const Te={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Me=n.schemeCategory10,Oe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function _e(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):Me[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Me.length]}function $e(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),a=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return o.scaleOrdinal().domain(n).range(r).unknown("#999");const i=Te[r]||Te.category10;if(a&&"function"==typeof i)return e=>i(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(i)?i:Me;return o.scaleOrdinal().domain(n).range(e).unknown("#999")}}const Ne={top:20,right:80,bottom:20,left:80},Ie={top:40,right:40,bottom:40,left:40},We=new Set(["chord","force","circlepack"]),Ce=[800,600],je={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 Re({data:e}){var t,r,n,a,o,i;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const c=e.data,s=null==c?void 0:c.__hierarchyNode;if(s){const e=[];let o=s;for(;o;){const i=null!==(a=null!==(r=null===(t=o.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=o.data)||void 0===n?void 0:n.id)&&void 0!==a?a:c.id;null!=i&&e.unshift(i+""),o=o.parent}e.length>1&&e.shift();const i=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===i?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const l=((null===(o=c.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(i=c.targetLinks)||void 0===i?void 0:i.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:je},u.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const Be=e.forwardRef(function(t,r){const{chartType:n,nodes:a,edges:o,data:i,initialEdges:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:f="target",valueAccessor:y="value",childrenAccessor:g,hierarchySum:p,orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,iterations:k=300,forceStrength:w=.1,padAngle:L=.01,groupWidth:E=20,sortGroups:D,edgeSort:A,treeOrientation:S="vertical",edgeType:P="curve",padding:T,paddingTop:M,tensionConfig:O,showParticles:_=!1,particleStyle:$,nodeStyle:N,edgeStyle:I,colorBy:W,colorScheme:C="category10",edgeColorBy:j="source",edgeOpacity:R=.5,colorByDepth:B=!1,nodeSize:z=8,nodeSizeRange:F=[5,20],nodeLabel:Y,showLabels:X=!0,size:H=Ce,margin:G,className:q,background:V,enableHover:Z=!0,tooltipContent:K,customHoverBehavior:Q,customClickBehavior:J,onObservation:U,chartId:ee,onTopologyChange:te,annotations:re,svgAnnotationRules:ne,legend:ae,title:oe,foregroundGraphics:ie,backgroundGraphics:ce,decay:se,pulse:le,staleness:ue,thresholds:de}=t,he=We.has(n)?Ie:Ne,fe=Object.assign(Object.assign({},he),G),ye=H[0]-fe.left-fe.right,ge=H[1]-fe.top-fe.bottom,pe=e.useMemo(()=>Object.assign(Object.assign({},d),O),[O]),ve=e.useMemo(()=>Object.assign(Object.assign({},h),$),[$]),me=e.useMemo(()=>({chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:f,valueAccessor:y,childrenAccessor:g,hierarchySum:p,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,iterations:k,forceStrength:w,padAngle:L,groupWidth:E,sortGroups:D,edgeSort:A,treeOrientation:S,edgeType:P,padding:T,paddingTop:M,tensionConfig:pe,showParticles:_,particleStyle:ve,nodeStyle:N,edgeStyle:I,nodeLabel:Y,showLabels:X,colorBy:W,colorScheme:C,edgeColorBy:j,edgeOpacity:R,colorByDepth:B,nodeSize:z,nodeSizeRange:F,decay:se,pulse:le,staleness:ue,thresholds:de}),[n,s,l,f,y,g,p,v,m,b,x,k,w,L,E,D,A,S,P,T,M,pe,_,ve,N,I,Y,X,W,C,j,R,B,z,F,se,le,ue,de]),xe=e.useRef(null),we=e.useRef(0),Le=e.useRef(0),Te=e.useRef(!0),Oe=e.useRef(()=>{}),_e=e.useRef(null);_e.current||(_e.current=new be(me));const[$e,je]=e.useState(null),[Be,ze]=e.useState(0),[Fe,Ye]=e.useState(0),[Xe,He]=e.useState(!1),Ge=e.useRef(null),qe=e.useRef(new Map),Ve=e.useRef(0),Ze=e.useCallback(e=>{if("function"==typeof W)return W(e);if("string"==typeof W&&e.data){const t=e.data[W];if(void 0!==t){if(!qe.current.has(t+"")){const e=Array.isArray(C)?C:Me;qe.current.set(t+"",e[Ve.current++%e.length])}return qe.current.get(t+"")}}if(!qe.current.has(e.id)){const t=Array.isArray(C)?C:Me;qe.current.set(e.id,t[Ve.current++%t.length])}return qe.current.get(e.id)},[W,C]),Ke=e.useCallback(e=>{if("function"==typeof j)return j(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===j&&r?Ze(r):t?Ze(t):"#999"},[j,Ze]),Qe=e.useCallback(e=>{if(!(null==$?void 0:$.colorBy))return Ke(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===ve.colorBy&&r?Ze(r):t?Ze(t):"#999"},[null==$?void 0:$.colorBy,ve.colorBy,Ze,Ke]),Je="sankey"===n&&_||!!le,Ue=e.useCallback(()=>{we.current&&!Je||we.current||(we.current=requestAnimationFrame(()=>Oe.current()))},[Je]);e.useEffect(()=>{var e;null===(e=_e.current)||void 0===e||e.updateConfig(me),Te.current=!0,Ue()},[me,Ue]);const et=e.useCallback(()=>{const e=_e.current;if(!e)return;e.runLayout([ye,ge]),e.buildScene([ye,ge]),Te.current=!0;const t=Array.isArray(C)?C:Me,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];qe.current.has(n.id)||qe.current.set(n.id,t[e%t.length])}if(Ve.current=r.length,ze(e.layoutVersion),te){const{nodes:t,edges:r}=e.getLayoutData();te(t,r)}},[ye,ge,te,C]),tt=e.useCallback(e=>{const t=_e.current;t&&(t.ingestEdge(e)&&et(),Ue())},[et,Ue]),rt=e.useCallback(e=>{const t=_e.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&et(),Ue()},[et,Ue]),nt=e.useCallback(()=>{var e;null===(e=_e.current)||void 0===e||e.clear(),qe.current.clear(),Ve.current=0,ze(0),je(null),Ge.current=null,Te.current=!0,Ue()},[Ue]),at=e.useCallback(()=>{const e=_e.current;e&&(e.tension+=999,et(),Ue())},[et,Ue]);e.useImperativeHandle(r,()=>({push:tt,pushMany:rt,clear:nt,getTopology:()=>{var e,t;return null!==(t=null===(e=_e.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=_e.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:at,getTension:()=>{var e,t;return null!==(t=null===(e=_e.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[tt,rt,nt,at]);const ot=["tree","cluster","treemap","circlepack","partition"].includes(n),it=ot?i||(Array.isArray(o)?void 0:o):void 0;e.useEffect(()=>{const e=_e.current;if(e)if(ot&&it)e.ingestHierarchy(it,[ye,ge]),e.buildScene([ye,ge]),Te.current=!0,Ue();else{const t=a||[],r=Array.isArray(o)?o:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[ye,ge]),e.buildScene([ye,ge]);const n=Array.isArray(C)?C:Me,i=Array.from(e.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];qe.current.has(t.id)||qe.current.set(t.id,n[e%n.length])}Ve.current=i.length,Te.current=!0,Ue()}},[a,o,i,it,ot,ye,ge,me,Ue,C]),e.useEffect(()=>{c&&c.length>0&&rt(c)},[]);const ct=e.useCallback(e=>{if(Q&&Q(e),U){const t=Date.now();U(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ee}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ee})}},[Q,U,ee]),st=e.useCallback(e=>{if(J&&J(e),U){const t=Date.now();U(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ee}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ee})}},[J,U,ee]),lt=e.useRef(()=>{}),ut=e.useRef(()=>{});lt.current=e=>{if(!Z)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-fe.left,a=e.clientY-r.top-fe.top;if(0>n||n>ye||0>a||a>ge)return void(Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue()));const o=_e.current;if(!o)return;const i=ke(o.sceneNodes,o.sceneEdges,n,a);if(!i)return void(Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue()));const c={type:i.type,data:i.datum,x:i.x,y:i.y};Ge.current=c,je(c),ct&&ct(c),Ue()},ut.current=()=>{Ge.current&&(Ge.current=null,je(null),ct&&ct(null),Ue())};const dt=e.useRef(()=>{});dt.current=e=>{if(!J&&!U)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-fe.left,a=e.clientY-r.top-fe.top;if(0>n||n>ye||0>a||a>ge)return;const o=_e.current;if(!o)return;const i=ke(o.sceneNodes,o.sceneEdges,n,a);st(i?{type:i.type,data:i.datum,x:i.x,y:i.y}:null)};const ht=e.useCallback(e=>lt.current(e),[]),ft=e.useCallback(()=>ut.current(),[]),yt=e.useCallback(e=>dt.current(e),[]);Oe.current=()=>{var e,t,r;we.current=0;const n=xe.current;if(!n)return;const a=n.getContext("2d");if(!a)return;const o=_e.current;if(!o)return;const i=performance.now(),c=Le.current?Math.min((i-Le.current)/1e3,.1):.016;Le.current=i;const s=o.advanceTransition(i);(s||Te.current)&&o.buildScene([ye,ge]);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=H[0]*l,n.height=H[1]*l,n.style.width=H[0]+"px",n.style.height=H[1]+"px",a.scale(l,l),a.translate(fe.left,fe.top),a.clearRect(-fe.left,-fe.top,H[0],H[1]),V&&(a.fillStyle=V,a.fillRect(0,0,ye,ge)),se&&o.applyDecay(),le&&o.applyPulse(i),de&&o.applyThresholds(i),o.applyTopologyDiff(i);const u=null!==(e=null==ue?void 0:ue.threshold)&&void 0!==e?e:5e3,d=ue&&o.lastIngestTime>0&&i-o.lastIngestTime>u;if(d&&(a.globalAlpha=null!==(t=null==ue?void 0:ue.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":De(e,r);break;case"line":Ae(e,r);break;case"ribbon":Se(e,r);break;case"curved":Pe(e,r)}}(a,o.sceneEdges),function(e,t){var r,n,a;for(const o of t){if("rect"!==o.type)continue;const t=o;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a: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.restore())}}(a,o.sceneNodes),function(e,t){var r,n,a,o;for(const i of t){if("circle"!==i.type)continue;const t=i;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,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.restore()}}}(a,o.sceneNodes),function(e,t){var r,n,a;for(const o of t){if("arc"!==o.type)continue;const t=o;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(a=t.style.opacity)&&void 0!==a?a:1,e.stroke()),e.restore()}}(a,o.sceneNodes),_&&o.particlePool&&!d){const e=Array.from(o.edges.values());if(e.length>0){!function(e,t,r,n){var a,o;const i=null!==(a=n.spawnRate)&&void 0!==a?a:h.spawnRate,c=null!==(o=n.maxPerEdge)&&void 0!==o?o:h.maxPerEdge;for(let n=0;t.length>n;n++){const a=t[n];if(!a.bezier)continue;if(e.countForEdge(n)>=c)continue;const o=a.value*i*r*(a.bezier.circular?.3:1),s=Math.floor(o),l=o-s;let u=s;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<c;t++)e.spawn(n)}}(o.particlePool,e,c,ve);const t=.5*(null!==(r=ve.speedMultiplier)&&void 0!==r?r:1);let n;if(ve.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}o.particlePool.step(c,t,e,n),function(e,t,r,n,a){var o,i;const c=null!==(o=n.radius)&&void 0!==o?o:h.radius,s=null!==(i=n.opacity)&&void 0!==i?i:h.opacity;e.globalAlpha=s;for(let o=0;t.particles.length>o;o++){const i=t.particles[o];if(!i.active)continue;const s=r[i.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:a(s);e.beginPath(),e.arc(i.x,i.y,c,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(a,o.particlePool,e,ve,Qe)}}d&&(a.globalAlpha=1);const f=Te.current;Te.current=!1,(f||s)&&Ye(e=>e+1),(Je||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(we.current=requestAnimationFrame(()=>Oe.current()))},e.useEffect(()=>(Ue(),()=>{we.current&&cancelAnimationFrame(we.current)}),[Ue]),e.useEffect(()=>{Te.current=!0,Ue()},[n,ye,ge,V,Ue]),e.useEffect(()=>{if(!ue)return;const e=setInterval(()=>{var e;const t=_e.current;if(!t||0===t.lastIngestTime)return;const r="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=ue.threshold)&&void 0!==e?e:5e3,a=r-t.lastIngestTime>n;a!==Xe&&(He(a),Te.current=!0,Ue())},1e3);return()=>clearInterval(e)},[ue,Xe,Ue]);const gt=Z&&$e?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:fe.left+$e.x,top:fe.top+$e.y,transform:`translate(${$e.x>.6*ye?"calc(-100% - 12px)":"12px"}, ${.3*ge>$e.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},K?K($e):u.createElement(Re,{data:$e})):null,pt=_e.current;return u.createElement("div",{className:"stream-network-frame"+(q?" "+q:""),role:"img","aria-label":"string"==typeof oe?oe:"Network chart",style:{position:"relative",width:H[0],height:H[1]},onMouseMove:Z?ht:void 0,onMouseLeave:Z?ft:void 0,onClick:J||U?yt:void 0},ce&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:H[0],height:H[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${fe.left},${fe.top})`},ce)),u.createElement("canvas",{ref:xe,style:{position:"absolute",top:0,left:0}}),u.createElement(Ee,{width:ye,height:ge,totalWidth:H[0],totalHeight:H[1],margin:fe,labels:(null==pt?void 0:pt.labels)||[],title:oe,legend:ae,foregroundGraphics:ie,annotations:re,svgAnnotationRules:ne,annotationFrame:Fe}),gt,(null==ue?void 0:ue.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ue.badgePosition?{top:4,left:4}:"bottom-left"===ue.badgePosition?{bottom:4,left:4}:"bottom-right"===ue.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Xe?"STALE":"LIVE"))});Be.displayName="StreamNetworkFrame";const ze={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 Fe(e,t){return"function"==typeof t?t(e):e[t]}function Ye(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 Xe(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:t,title:r,format:n,style:a={},className:o=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const c=[];if(r){const t=Fe(e,r);i=Ye(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,a,o;"string"==typeof t?(r=t,a=t,o=n):(r=t.label,a=t.accessor||t.key||"",o=t.format||n);const i=Fe(e,a);c.push({label:r,value:Ye(i,o)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){i=Ye(e[r],n);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=Ye(e[t[0]],n))}}const s=Object.assign(Object.assign({},ze),a);return u.createElement("div",{className:("semiotic-tooltip "+o).trim(),style:s},i&&u.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},i),c.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&i?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}(e)))}function He(t){const r=e.createContext(null),n=Ge(t);return[function({children:n}){const a=e.useMemo(()=>Ge(t),[]);return u.createElement(r.Provider,{value:a,children:n})},t=>{var a;const o=null!==(a=e.useContext(r))&&void 0!==a?a:n;return function(t,r){const[n,a]=e.useState(r);return e.useLayoutEffect(()=>t(()=>a(r)),[t]),n}(o.subscribe,()=>t(o.getState()))}]}function Ge(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function qe(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,a]=n.range;t.push(t=>{const n=t[r];return n>=e&&a>=n})}return e=>t.every(t=>t(e))}function Ve(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Ze,Ke]=He(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),a=Ve(n,t),o=new Map(a.clauses);return o.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},a),{clauses:o})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const a=new Map(e.selections),o=new Map(n.clauses);return o.delete(r),a.set(t,Object.assign(Object.assign({},n),{clauses:o})),{selections:a}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),a=Ve(n,t);return n.set(t,Object.assign(Object.assign({},a),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}}));function Qe(t){const r=e.useId(),n=t.clientId||r,{name:a}=t,o=Ke(e=>e.selections.get(a)),i=Ke(e=>e.setClause),c=Ke(e=>e.clearClause),s=e.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:e.useMemo(()=>o&&0!==o.clauses.size?function(e,t){const r=[];for(const[n,a]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(qe(a));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};i(a,{clientId:n,type:"point",fields:t})},[n,a,i]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};i(a,{clientId:n,type:"interval",fields:t})},[n,a,i]),clear:e.useCallback(()=>{c(a,n)},[c,a,n]),clientId:n}}const[Je,Ue]=He(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),et="#007bff";function tt(t,r,n="category10"){return e.useMemo(()=>{if(r&&"function"!=typeof r)return $e(t,r,n)},[t,r,n])}const rt={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 nt(e,t,r){var n,a,o,i,c,s;const l=rt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?l.width:r.width,height:null!==(a=t.height)&&void 0!==a?a:e&&"primary"!==e||!(null==r?void 0:r.height)?l.height:r.height,showAxes:l.showAxes,showGrid:null!==(o=t.showGrid)&&void 0!==o?o:l.showGrid,enableHover:null!==(i=t.enableHover)&&void 0!==i?i:!!t.linkedHover||l.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:l.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:l.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:l.marginDefaults}}function at({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,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"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function ot({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function it({nodes:e,edges:t,nodesRequired:r=!1,edgesRequired:n=!0,accessors:a}){if(n&&(!t||!Array.isArray(t)||0===t.length))return"No edges provided. Pass a non-empty array to the edges prop.";if(r&&(!e||!Array.isArray(e)||0===e.length))return"No nodes provided. Pass a non-empty array to the nodes prop.";if(a&&e&&e.length>0)for(const t of(o=e).length>3?[o[0],o[Math.floor(o.length/2)],o[o.length-1]]:o)if(t&&"object"==typeof t)for(const[e,r]of Object.entries(a))if(r&&"string"==typeof r&&!(r in t))return`${e} "${r}" not found in node data. Available fields: ${Object.keys(t).join(", ")}.`;var o;return null}function ct(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:o,margin:i,className:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:L={},onObservation:E,chartId:D}=t,A=n.width,S=n.height,P=n.enableHover,T=n.showLegend,M=null!==(r=n.showLabels)&&void 0!==r&&r,O=n.title,_=a||[],$=o||[],N=tt(_,f,y),I=e.useMemo(()=>e=>{const t={};return t.fill=f?_e(e.data||e,f,N):et,"number"==typeof g&&(t.r=g),t},[f,N,g]),W=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),C=e.useMemo(()=>{if(M&&h)return"function"==typeof h?h:e=>e[h]},[M,h]),{legend:j,margin:R}=function({data:t,colorBy:r,colorScale:n,showLegend:a,userMargin:o,defaults:i={top:50,bottom:60,left:70,right:40}}){const c=void 0!==a?a:!!r,s=e.useMemo(()=>{if(c&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:a,strokeWidth:o}){const i=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(a=>{const o=e.find("function"==typeof t?e=>t(e)===a:e=>e[t]===a),i=o?n(o,t,r):r?r(a):"#000000";return{label:a+"",color:i}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==a&&(t.stroke=a),void 0!==o&&(t.strokeWidth=o),t},type:"fill",items:i,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:_e})},[c,r,t,n]),l=e.useMemo(()=>{const e=Object.assign(Object.assign({},i),o);return s&&120>e.right&&(e.right=120),e},[i,o,s]);return{legend:s,margin:l}}({data:_,colorBy:f,colorScale:N,showLegend:T,userMargin:i,defaults:n.marginDefaults}),B=e.useCallback(e=>{if(!E)return;const t=Date.now();E(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ForceDirectedGraph",chartId:D}:{type:"hover-end",timestamp:t,chartType:"ForceDirectedGraph",chartId:D})},[E,D]),z=it({componentName:"ForceDirectedGraph",nodes:a,edges:o,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return z?u.createElement(at,{componentName:"ForceDirectedGraph",message:z,width:A,height:S}):u.createElement(Be,Object.assign({chartType:"force",nodes:_,edges:$,size:[A,S],margin:R,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:I,edgeStyle:W,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:C,showLabels:M,enableHover:P,tooltipContent:w?e=>Xe(w)(e.data):void 0,customHoverBehavior:E?B:void 0,legend:j,className:c,title:O},L))}function st(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const a="function"==typeof t?t(e):e[t];a&&Array.isArray(a)&&a.forEach(n)};return n(e),r}function lt(e,t,r,n){if(e&&e.length>0)return e;const a=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],o="function"==typeof n?n(e):e[n];a.add(t),a.add(o)}),Array.from(a).map(e=>({id:e}))}function ut(e){return"function"==typeof e?e:t=>t[e]||1}function dt({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:a,baseStyle:o={}}){return i=>{const c=Object.assign({fillOpacity:a},o);if("function"==typeof e)c.fill=e(i);else if("source"===e){const e="object"==typeof i.source?i.source:null;t&&e?c.fill=_e(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof i.target?i.target:null;t&&e?c.fill=_e(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else"gradient"===e&&(c.fill="#999",c.fillOpacity=.7*a);return c}}function ht(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:o,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:L,frameProps:E={},onObservation:D,chartId:A}=t,S=n.width,P=n.height,T=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,O=n.title,_=o||[],$=e.useMemo(()=>lt(a,_,s,l),[a,_,s,l]),N=tt($,f,y),I=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?_e(e.data||e,f,N):"#4d430c",t},[f,N]),W=e.useMemo(()=>dt({edgeColorBy:g,colorBy:f,colorScale:N,nodeStyleFn:I,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,N,I,k]),C=e.useMemo(()=>{if(!M)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[M,x,h]),j=Object.assign(Object.assign({},n.marginDefaults),i),R=Ue(e=>e.pushObservation),B=e.useCallback(e=>{const t=Date.now();if(e){const r={type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(r),R&&R(r)}else{const e={type:"hover-end",timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(e),R&&R(e)}},[D,A,R]),z=e.useCallback(e=>{const t=Date.now();if(e){const r={type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(r),R&&R(r)}else{const e={type:"click-end",timestamp:t,chartType:"SankeyDiagram",chartId:A};D&&D(e),R&&R(e)}},[D,A,R]),F=it({componentName:"SankeyDiagram",edges:o,edgesRequired:!0});return F?u.createElement(at,{componentName:"SankeyDiagram",message:F,width:S,height:P}):u.createElement(Be,Object.assign({chartType:"sankey",nodes:$,edges:_,size:[S,P],margin:j,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:I,edgeStyle:W,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:C,showLabels:M,enableHover:T,tooltipContent:L?e=>Xe(L)(e.data):void 0,customHoverBehavior:D?B:void 0,customClickBehavior:D?z:void 0,className:c,title:O},E))}function ft(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:o,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:L,chartId:E}=t,D=n.width,A=n.height,S=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,T=n.title,M=o||[],O=e.useMemo(()=>lt(a,M,s,l),[a,M,s,l]),_=tt(O,f,y),$=e.useMemo(()=>(e,t)=>{var r,n;const a={stroke:"black",strokeWidth:1};if(f)a.fill=_e(e.data||e,f,_);else{const o=Array.isArray(y)?y:Te[y]||Me,i=Array.isArray(o)?o:Me,c=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;a.fill=i[c%i.length]}return a},[f,_,y]),N=e.useMemo(()=>dt({edgeColorBy:g,colorBy:f,colorScale:_,nodeStyleFn:$,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,_,$,x]),I=e.useMemo(()=>{if(!P)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[P,b,h]),W=Object.assign(Object.assign({},n.marginDefaults),i),C=e.useCallback(e=>{if(!L)return;const t=Date.now();L(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ChordDiagram",chartId:E}:{type:"hover-end",timestamp:t,chartType:"ChordDiagram",chartId:E})},[L,E]),j=it({componentName:"ChordDiagram",edges:o,edgesRequired:!0});return j?u.createElement(at,{componentName:"ChordDiagram",message:j,width:D,height:A}):u.createElement(Be,Object.assign({chartType:"chord",nodes:O,edges:M,size:[D,A],margin:W,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:$,edgeStyle:N,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:I,showLabels:P,enableHover:S,tooltipContent:k?e=>Xe(k)(e.data):void 0,customHoverBehavior:L?C:void 0,className:c,title:T},w))}function yt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:a,margin:o,className:i,layout:c="tree",orientation:s="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w}=t,L=n.width,E=n.height,D=n.enableHover,A=null===(r=n.showLabels)||void 0===r||r,S=n.title,P=e.useMemo(()=>st(a,l),[a,l]),T=e.useMemo(()=>{if(!g&&f&&"function"!=typeof f)return $e(P,f,y)},[P,f,g,y]),M=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Oe[(e.depth||0)%Oe.length]:f?_e(e.data||e,f,T):et,t},[f,g,T]),O=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),_=e.useMemo(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return ut(d)},[c,d]),$=Object.assign(Object.assign({},n.marginDefaults),o),N=e.useCallback(e=>{if(!k)return;const t=Date.now();k(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"TreeDiagram",chartId:w}:{type:"hover-end",timestamp:t,chartType:"TreeDiagram",chartId:w})},[k,w]),I=ot({componentName:"TreeDiagram",data:a});return I?u.createElement(at,{componentName:"TreeDiagram",message:I,width:L,height:E}):u.createElement(Be,Object.assign({chartType:c,data:a,size:[L,E],margin:$,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:_,treeOrientation:s,edgeType:p,nodeStyle:M,edgeStyle:O,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:A?v||h:void 0,showLabels:A,enableHover:D,tooltipContent:b?e=>Xe(b)(e.data):void 0,customHoverBehavior:k?N:void 0,className:i,title:S},x))}function gt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:a,margin:o,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:L}=t,E=n.width,D=n.height,A=n.enableHover,S=null===(r=n.showLabels)||void 0===r||r,P=n.title,{activeSelectionHook:T,customHoverBehavior:M}=function({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:a=!1,onObservation:o,chartType:i,chartId:c}){const s=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}(r,n),l=Qe({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:a,isActive:o,selectPoints:i,clear:c}=Qe({name:r});return{onHover:e.useCallback(e=>{if(!e)return void c();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&i(t)},[n,i,c]),predicate:a,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||[]}),d=Ue(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:l.isActive,predicate:l.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r){let t=e&&(e.data||e.datum)||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}if(o||d){const r={timestamp:Date.now(),chartType:i,chartId:c};if(e){let a=e.data||e.datum||e;Array.isArray(a)&&(a=a[0]);const i=Object.assign(Object.assign({},r),{type:"hover",datum:a||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});o&&o(i),d&&d(i)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});o&&o(e),d&&d(e)}}},[r,u,o,i,c,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(o||d){const n={timestamp:Date.now(),chartType:i,chartId:c};if(e){let a=e.data||e.datum||e;Array.isArray(a)&&(a=a[0]);const i=Object.assign(Object.assign({},n),{type:"click",datum:a||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(i),d&&d(i)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});o&&o(e),d&&d(e)}}},[o,d,i,c])}}({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:L}),O=e.useCallback(e=>{if(!e)return M(null);const t=e.data||e;M({data:(null==t?void 0:t.data)||t})},[M]),_=e.useMemo(()=>st(a,c),[a,c]),$=e.useMemo(()=>{if(f)return;if(!d||"function"==typeof d)return;const e=d;return $e(_.filter(t=>null!=t[e]),e,h)},[_,d,f,h]),N=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?_e(e.data||e,d,$):et,t},[d,f,$]),I=e.useMemo(()=>T?e=>{var t,r;const n=Object.assign({},N(e));return T.isActive&&(T.predicate(e.data||e)?(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle):(n.fillOpacity=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2,n.strokeOpacity=null!==(r=null==x?void 0:x.unselectedOpacity)&&void 0!==r?r:.2,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle))),n}:N,[N,T,x]),W=e.useMemo(()=>ut(s),[s]),C=void 0!==v?v:S&&"parent"===y?18:void 0,j=Object.assign(Object.assign({},n.marginDefaults),o),R=ot({componentName:"Treemap",data:a});return R?u.createElement(at,{componentName:"Treemap",message:R,width:E,height:D}):u.createElement(Be,Object.assign({chartType:"treemap",data:a,size:[E,D],margin:j,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:W,padding:p,paddingTop:C,nodeStyle:I,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:S?g||l:void 0,showLabels:S,enableHover:A,tooltipContent:m?e=>Xe(m)(e.data):void 0},(k||w)&&{customHoverBehavior:O},{className:i,title:P},b))}function pt(t){var r;const n=nt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:a,margin:o,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x}=t,k=n.width,w=n.height,L=n.enableHover,E=null===(r=n.showLabels)||void 0===r||r,D=n.title,A=e.useMemo(()=>st(a,c),[a,c]),S=e.useMemo(()=>{if(!f&&d&&"function"!=typeof d)return $e(A,d,h)},[A,d,f,h]),P=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?_e(e.data||e,d,S):et,t},[d,f,S,g]),T=e.useMemo(()=>ut(s),[s]),M=Object.assign(Object.assign({},n.marginDefaults),o),O=e.useCallback(e=>{if(!b)return;const t=Date.now();b(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"CirclePack",chartId:x}:{type:"hover-end",timestamp:t,chartType:"CirclePack",chartId:x})},[b,x]),_=ot({componentName:"CirclePack",data:a});return _?u.createElement(at,{componentName:"CirclePack",message:_,width:k,height:w}):u.createElement(Be,Object.assign({chartType:"circlepack",data:a,size:[k,w],margin:M,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:T,padding:p,nodeStyle:P,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:E?y||l:void 0,showLabels:E,enableHover:L,tooltipContent:v?e=>Xe(v)(e.data):void 0,customHoverBehavior:b?O:void 0,className:i,title:D},m))}ct.displayName="ForceDirectedGraph",ht.displayName="SankeyDiagram",ft.displayName="ChordDiagram",yt.displayName="TreeDiagram",gt.displayName="Treemap",pt.displayName="CirclePack",exports.ChordDiagram=ft,exports.CirclePack=pt,exports.ForceDirectedGraph=ct,exports.SankeyDiagram=ht,exports.StreamNetworkFrame=Be,exports.TreeDiagram=yt,exports.Treemap=gt;
|