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.
Files changed (342) hide show
  1. package/CLAUDE.md +93 -753
  2. package/README.md +92 -7
  3. package/ai/dist/componentRegistry.js +26 -0
  4. package/ai/dist/{ai/mcp-server.js → mcp-server.js} +1 -1
  5. package/ai/dist/{ai/renderHOCToSVG.js → renderHOCToSVG.js} +2 -2
  6. package/dist/ChartContainer.d.ts +60 -0
  7. package/dist/DetailsPanel.d.ts +37 -0
  8. package/dist/LinkedCharts.d.ts +2 -0
  9. package/dist/Tooltip/Tooltip.d.ts +2 -2
  10. package/dist/charts/index.d.ts +1 -1
  11. package/dist/charts/ordinal/BarChart.d.ts +1 -0
  12. package/dist/charts/ordinal/BoxPlot.d.ts +1 -0
  13. package/dist/charts/ordinal/DonutChart.d.ts +1 -0
  14. package/dist/charts/ordinal/DotPlot.d.ts +1 -0
  15. package/dist/charts/ordinal/GroupedBarChart.d.ts +1 -0
  16. package/dist/charts/ordinal/Histogram.d.ts +1 -0
  17. package/dist/charts/ordinal/PieChart.d.ts +1 -0
  18. package/dist/charts/ordinal/RidgelinePlot.d.ts +1 -0
  19. package/dist/charts/ordinal/StackedBarChart.d.ts +1 -0
  20. package/dist/charts/ordinal/SwarmPlot.d.ts +1 -0
  21. package/dist/charts/ordinal/ViolinPlot.d.ts +1 -0
  22. package/dist/charts/realtime/RealtimeHeatmap.d.ts +11 -0
  23. package/dist/charts/realtime/RealtimeHistogram.d.ts +15 -1
  24. package/dist/charts/realtime/RealtimeLineChart.d.ts +6 -0
  25. package/dist/charts/realtime/RealtimeSwarmChart.d.ts +6 -0
  26. package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +6 -0
  27. package/dist/charts/shared/annotationRules.d.ts +3 -0
  28. package/dist/charts/shared/colorUtils.d.ts +17 -11
  29. package/dist/charts/shared/hooks.d.ts +96 -1
  30. package/dist/charts/shared/loess.d.ts +13 -0
  31. package/dist/charts/shared/networkUtils.d.ts +31 -0
  32. package/dist/charts/shared/tooltipUtils.d.ts +16 -0
  33. package/dist/charts/shared/types.d.ts +17 -2
  34. package/dist/charts/shared/validateChartData.d.ts +2 -3
  35. package/dist/charts/shared/validateProps.d.ts +18 -0
  36. package/dist/charts/xy/AreaChart.d.ts +4 -0
  37. package/dist/charts/xy/BubbleChart.d.ts +6 -0
  38. package/dist/charts/xy/Heatmap.d.ts +4 -0
  39. package/dist/charts/xy/LineChart.d.ts +6 -0
  40. package/dist/charts/xy/Scatterplot.d.ts +4 -0
  41. package/dist/charts/xy/StackedAreaChart.d.ts +4 -0
  42. package/dist/data/fromVegaLite.d.ts +48 -0
  43. package/dist/export/chartConfig.d.ts +29 -0
  44. package/dist/export/selectionSerializer.d.ts +20 -0
  45. package/dist/geometry/sankeyLinks.d.ts +1 -1
  46. package/dist/network.min.js +1 -1
  47. package/dist/network.module.min.js +1 -1
  48. package/dist/ordinal.min.js +1 -1
  49. package/dist/ordinal.module.min.js +1 -1
  50. package/dist/realtime/types.d.ts +20 -6
  51. package/dist/realtime.min.js +1 -1
  52. package/dist/realtime.module.min.js +1 -1
  53. package/dist/semiotic-ai.d.ts +14 -0
  54. package/dist/semiotic-ai.min.js +1 -1
  55. package/dist/semiotic-ai.module.min.js +1 -1
  56. package/dist/semiotic-data.d.ts +2 -0
  57. package/dist/semiotic-data.min.js +1 -1
  58. package/dist/semiotic-data.module.min.js +1 -1
  59. package/dist/semiotic-network.d.ts +9 -19
  60. package/dist/semiotic-ordinal.d.ts +12 -14
  61. package/dist/semiotic-xy.d.ts +12 -18
  62. package/dist/semiotic.d.ts +16 -13
  63. package/dist/semiotic.min.js +1 -1
  64. package/dist/semiotic.module.min.js +1 -1
  65. package/dist/server.min.js +1 -1
  66. package/dist/server.module.min.js +1 -1
  67. package/dist/store/ObservationStore.d.ts +61 -0
  68. package/dist/store/SelectionStore.d.ts +9 -1
  69. package/dist/store/ThemeStore.d.ts +6 -1
  70. package/dist/store/TooltipStore.d.ts +3 -1
  71. package/dist/store/createStore.d.ts +4 -1
  72. package/dist/store/useObservation.d.ts +18 -0
  73. package/dist/stream/MarginalGraphics.d.ts +1 -1
  74. package/dist/stream/NetworkPipelineStore.d.ts +44 -0
  75. package/dist/stream/OrdinalCanvasHitTester.d.ts +1 -0
  76. package/dist/stream/OrdinalSVGOverlay.d.ts +6 -2
  77. package/dist/stream/ParticlePool.d.ts +2 -1
  78. package/dist/stream/PipelineStore.d.ts +11 -0
  79. package/dist/stream/SVGOverlay.d.ts +21 -2
  80. package/dist/stream/SceneGraph.d.ts +1 -1
  81. package/dist/stream/networkTypes.d.ts +58 -1
  82. package/dist/stream/ordinalTypes.d.ts +13 -0
  83. package/dist/stream/types.d.ts +14 -0
  84. package/dist/types/annotationTypes.d.ts +10 -0
  85. package/dist/types/networkTypes.d.ts +1 -2
  86. package/dist/xy.min.js +1 -1
  87. package/dist/xy.module.min.js +1 -1
  88. package/package.json +30 -42
  89. package/ai/dist/ai/componentRegistry.js +0 -45
  90. package/ai/dist/src/components/Annotation.js +0 -358
  91. package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +0 -369
  92. package/ai/dist/src/components/Axis/Axis.js +0 -374
  93. package/ai/dist/src/components/Axis/axisTitle.js +0 -14
  94. package/ai/dist/src/components/Axis/index.js +0 -7
  95. package/ai/dist/src/components/Axis/summaryGraphic.js +0 -37
  96. package/ai/dist/src/components/Brush.js +0 -84
  97. package/ai/dist/src/components/ChartErrorBoundary.js +0 -91
  98. package/ai/dist/src/components/DividedLine.js +0 -65
  99. package/ai/dist/src/components/Legend.js +0 -140
  100. package/ai/dist/src/components/LinkedCharts.js +0 -95
  101. package/ai/dist/src/components/ThemeProvider.js +0 -79
  102. package/ai/dist/src/components/Tooltip/Tooltip.js +0 -309
  103. package/ai/dist/src/components/TooltipPositioner/index.js +0 -132
  104. package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +0 -73
  105. package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +0 -254
  106. package/ai/dist/src/components/annotationRules/baseRules.js +0 -150
  107. package/ai/dist/src/components/annotationRules/networkframeRules.js +0 -196
  108. package/ai/dist/src/components/annotationRules/xyframeRules.js +0 -297
  109. package/ai/dist/src/components/batchWork.js +0 -35
  110. package/ai/dist/src/components/charts/index.js +0 -109
  111. package/ai/dist/src/components/charts/network/ChordDiagram.js +0 -142
  112. package/ai/dist/src/components/charts/network/CirclePack.js +0 -108
  113. package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +0 -121
  114. package/ai/dist/src/components/charts/network/SankeyDiagram.js +0 -155
  115. package/ai/dist/src/components/charts/network/TreeDiagram.js +0 -110
  116. package/ai/dist/src/components/charts/network/Treemap.js +0 -106
  117. package/ai/dist/src/components/charts/ordinal/BarChart.js +0 -156
  118. package/ai/dist/src/components/charts/ordinal/BoxPlot.js +0 -139
  119. package/ai/dist/src/components/charts/ordinal/DonutChart.js +0 -130
  120. package/ai/dist/src/components/charts/ordinal/DotPlot.js +0 -126
  121. package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +0 -129
  122. package/ai/dist/src/components/charts/ordinal/Histogram.js +0 -132
  123. package/ai/dist/src/components/charts/ordinal/PieChart.js +0 -128
  124. package/ai/dist/src/components/charts/ordinal/RidgelinePlot.js +0 -130
  125. package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +0 -130
  126. package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +0 -147
  127. package/ai/dist/src/components/charts/ordinal/ViolinPlot.js +0 -138
  128. package/ai/dist/src/components/charts/realtime/RealtimeHeatmap.js +0 -79
  129. package/ai/dist/src/components/charts/realtime/RealtimeHistogram.js +0 -114
  130. package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +0 -93
  131. package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +0 -105
  132. package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +0 -106
  133. package/ai/dist/src/components/charts/shared/ChartError.js +0 -72
  134. package/ai/dist/src/components/charts/shared/colorUtils.js +0 -138
  135. package/ai/dist/src/components/charts/shared/formatUtils.js +0 -213
  136. package/ai/dist/src/components/charts/shared/hooks.js +0 -49
  137. package/ai/dist/src/components/charts/shared/legendUtils.js +0 -57
  138. package/ai/dist/src/components/charts/shared/selectionUtils.js +0 -67
  139. package/ai/dist/src/components/charts/shared/tooltipUtils.js +0 -79
  140. package/ai/dist/src/components/charts/shared/types.js +0 -2
  141. package/ai/dist/src/components/charts/shared/validateChartData.js +0 -82
  142. package/ai/dist/src/components/charts/shared/validateProps.js +0 -736
  143. package/ai/dist/src/components/charts/xy/AreaChart.js +0 -230
  144. package/ai/dist/src/components/charts/xy/BubbleChart.js +0 -251
  145. package/ai/dist/src/components/charts/xy/Heatmap.js +0 -235
  146. package/ai/dist/src/components/charts/xy/LineChart.js +0 -307
  147. package/ai/dist/src/components/charts/xy/MinimapChart.js +0 -298
  148. package/ai/dist/src/components/charts/xy/Scatterplot.js +0 -172
  149. package/ai/dist/src/components/charts/xy/ScatterplotMatrix.js +0 -426
  150. package/ai/dist/src/components/charts/xy/StackedAreaChart.js +0 -231
  151. package/ai/dist/src/components/constants/coordinateNames.js +0 -11
  152. package/ai/dist/src/components/constants/frame_props.js +0 -251
  153. package/ai/dist/src/components/data/dataFunctions.js +0 -487
  154. package/ai/dist/src/components/data/multiAccessorUtils.js +0 -14
  155. package/ai/dist/src/components/data/transforms.js +0 -143
  156. package/ai/dist/src/components/data/unflowedFunctions.js +0 -5
  157. package/ai/dist/src/components/export/exportChart.js +0 -121
  158. package/ai/dist/src/components/generic_utilities/functions.js +0 -5
  159. package/ai/dist/src/components/geometry/areaDrawing.js +0 -312
  160. package/ai/dist/src/components/geometry/contourLayout.js +0 -73
  161. package/ai/dist/src/components/geometry/hexbinLayout.js +0 -163
  162. package/ai/dist/src/components/geometry/lineDrawing.js +0 -356
  163. package/ai/dist/src/components/geometry/sankeyLinks.js +0 -331
  164. package/ai/dist/src/components/geometry/summaryLayouts.js +0 -136
  165. package/ai/dist/src/components/index.js +0 -18
  166. package/ai/dist/src/components/processing/InteractionItems.js +0 -223
  167. package/ai/dist/src/components/processing/hierarchyUtils.js +0 -104
  168. package/ai/dist/src/components/processing/layouts/chordLayout.js +0 -58
  169. package/ai/dist/src/components/processing/layouts/forceLayout.js +0 -142
  170. package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +0 -31
  171. package/ai/dist/src/components/processing/layouts/index.js +0 -32
  172. package/ai/dist/src/components/processing/layouts/sankeyLayout.js +0 -96
  173. package/ai/dist/src/components/processing/layouts/simpleLayouts.js +0 -34
  174. package/ai/dist/src/components/processing/layouts/types.js +0 -2
  175. package/ai/dist/src/components/processing/networkDefaults.js +0 -39
  176. package/ai/dist/src/components/realtime/BinAccumulator.js +0 -36
  177. package/ai/dist/src/components/realtime/IncrementalExtent.js +0 -55
  178. package/ai/dist/src/components/realtime/RingBuffer.js +0 -104
  179. package/ai/dist/src/components/realtime/renderers/barRenderer.js +0 -133
  180. package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +0 -7
  181. package/ai/dist/src/components/realtime/renderers/lineRenderer.js +0 -164
  182. package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +0 -91
  183. package/ai/dist/src/components/realtime/renderers/types.js +0 -2
  184. package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +0 -163
  185. package/ai/dist/src/components/realtime/types.js +0 -2
  186. package/ai/dist/src/components/semiotic-ai.js +0 -89
  187. package/ai/dist/src/components/semiotic-data.js +0 -12
  188. package/ai/dist/src/components/semiotic-network.js +0 -38
  189. package/ai/dist/src/components/semiotic-ordinal.js +0 -28
  190. package/ai/dist/src/components/semiotic-realtime.js +0 -30
  191. package/ai/dist/src/components/semiotic-server.js +0 -8
  192. package/ai/dist/src/components/semiotic-xy.js +0 -35
  193. package/ai/dist/src/components/semiotic.js +0 -109
  194. package/ai/dist/src/components/server/renderToStaticSVG.js +0 -594
  195. package/ai/dist/src/components/store/SelectionStore.js +0 -91
  196. package/ai/dist/src/components/store/ThemeStore.js +0 -78
  197. package/ai/dist/src/components/store/TooltipStore.js +0 -13
  198. package/ai/dist/src/components/store/createStore.js +0 -81
  199. package/ai/dist/src/components/store/useSelection.js +0 -133
  200. package/ai/dist/src/components/stream/CanvasHitTester.js +0 -164
  201. package/ai/dist/src/components/stream/DataSourceAdapter.js +0 -99
  202. package/ai/dist/src/components/stream/MarginalGraphics.js +0 -266
  203. package/ai/dist/src/components/stream/NetworkCanvasHitTester.js +0 -228
  204. package/ai/dist/src/components/stream/NetworkPipelineStore.js +0 -498
  205. package/ai/dist/src/components/stream/NetworkSVGOverlay.js +0 -70
  206. package/ai/dist/src/components/stream/NetworkSceneGraph.js +0 -38
  207. package/ai/dist/src/components/stream/OrdinalCanvasHitTester.js +0 -146
  208. package/ai/dist/src/components/stream/OrdinalPipelineStore.js +0 -786
  209. package/ai/dist/src/components/stream/OrdinalSVGOverlay.js +0 -130
  210. package/ai/dist/src/components/stream/ParticlePool.js +0 -174
  211. package/ai/dist/src/components/stream/PipelineStore.js +0 -1243
  212. package/ai/dist/src/components/stream/SVGOverlay.js +0 -129
  213. package/ai/dist/src/components/stream/SceneGraph.js +0 -132
  214. package/ai/dist/src/components/stream/StreamNetworkFrame.js +0 -561
  215. package/ai/dist/src/components/stream/StreamOrdinalFrame.js +0 -492
  216. package/ai/dist/src/components/stream/StreamXYFrame.js +0 -590
  217. package/ai/dist/src/components/stream/accessorUtils.js +0 -20
  218. package/ai/dist/src/components/stream/index.js +0 -32
  219. package/ai/dist/src/components/stream/layouts/chordLayoutPlugin.js +0 -352
  220. package/ai/dist/src/components/stream/layouts/forceLayoutPlugin.js +0 -230
  221. package/ai/dist/src/components/stream/layouts/hierarchyLayoutPlugin.js +0 -568
  222. package/ai/dist/src/components/stream/layouts/index.js +0 -28
  223. package/ai/dist/src/components/stream/layouts/sankeyLayoutPlugin.js +0 -245
  224. package/ai/dist/src/components/stream/networkTypes.js +0 -17
  225. package/ai/dist/src/components/stream/ordinalSceneBuilders/barScene.js +0 -126
  226. package/ai/dist/src/components/stream/ordinalSceneBuilders/connectorScene.js +0 -62
  227. package/ai/dist/src/components/stream/ordinalSceneBuilders/pieScene.js +0 -33
  228. package/ai/dist/src/components/stream/ordinalSceneBuilders/pointScene.js +0 -63
  229. package/ai/dist/src/components/stream/ordinalSceneBuilders/statisticalScene.js +0 -278
  230. package/ai/dist/src/components/stream/ordinalSceneBuilders/timelineScene.js +0 -30
  231. package/ai/dist/src/components/stream/ordinalSceneBuilders/types.js +0 -2
  232. package/ai/dist/src/components/stream/ordinalTypes.js +0 -2
  233. package/ai/dist/src/components/stream/renderers/areaCanvasRenderer.js +0 -48
  234. package/ai/dist/src/components/stream/renderers/barCanvasRenderer.js +0 -70
  235. package/ai/dist/src/components/stream/renderers/boxplotCanvasRenderer.js +0 -75
  236. package/ai/dist/src/components/stream/renderers/candlestickCanvasRenderer.js +0 -28
  237. package/ai/dist/src/components/stream/renderers/connectorCanvasRenderer.js +0 -47
  238. package/ai/dist/src/components/stream/renderers/heatmapCanvasRenderer.js +0 -31
  239. package/ai/dist/src/components/stream/renderers/lineCanvasRenderer.js +0 -140
  240. package/ai/dist/src/components/stream/renderers/networkArcRenderer.js +0 -38
  241. package/ai/dist/src/components/stream/renderers/networkCircleRenderer.js +0 -37
  242. package/ai/dist/src/components/stream/renderers/networkEdgeRenderer.js +0 -102
  243. package/ai/dist/src/components/stream/renderers/networkParticleRenderer.js +0 -63
  244. package/ai/dist/src/components/stream/renderers/networkRectRenderer.js +0 -35
  245. package/ai/dist/src/components/stream/renderers/pointCanvasRenderer.js +0 -38
  246. package/ai/dist/src/components/stream/renderers/swarmCanvasRenderer.js +0 -10
  247. package/ai/dist/src/components/stream/renderers/types.js +0 -2
  248. package/ai/dist/src/components/stream/renderers/violinCanvasRenderer.js +0 -47
  249. package/ai/dist/src/components/stream/renderers/waterfallCanvasRenderer.js +0 -38
  250. package/ai/dist/src/components/stream/renderers/wedgeCanvasRenderer.js +0 -33
  251. package/ai/dist/src/components/stream/types.js +0 -2
  252. package/ai/dist/src/components/types/annotationTypes.js +0 -2
  253. package/ai/dist/src/components/types/canvasTypes.js +0 -2
  254. package/ai/dist/src/components/types/generalTypes.js +0 -2
  255. package/ai/dist/src/components/types/interactionTypes.js +0 -2
  256. package/ai/dist/src/components/types/legendTypes.js +0 -2
  257. package/ai/dist/src/components/types/networkTypes.js +0 -2
  258. package/ai/dist/src/components/types/ordinalTypes.js +0 -2
  259. package/ai/dist/src/components/types/xyTypes.js +0 -2
  260. package/ai/dist/src/components/useBoundingRect.js +0 -24
  261. package/ai/dist/src/components/visualizationLayerBehavior/axis.js +0 -301
  262. package/ai/dist/src/components/visualizationLayerBehavior/general.js +0 -435
  263. package/ai/dist/src/setupTests.js +0 -4
  264. package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -25
  265. package/dist/Axis/Axis.d.ts +0 -7
  266. package/dist/Axis/axisTitle.d.ts +0 -10
  267. package/dist/Axis/index.d.ts +0 -2
  268. package/dist/Axis/summaryGraphic.d.ts +0 -17
  269. package/dist/Brush.d.ts +0 -12
  270. package/dist/DividedLine.d.ts +0 -16
  271. package/dist/TooltipPositioner/index.d.ts +0 -7
  272. package/dist/annotationLayerBehavior/annotationHandling.d.ts +0 -19
  273. package/dist/annotationLayerBehavior/d3labeler.d.ts +0 -9
  274. package/dist/annotationRules/baseRules.d.ts +0 -25
  275. package/dist/annotationRules/networkframeRules.d.ts +0 -48
  276. package/dist/annotationRules/xyframeRules.d.ts +0 -117
  277. package/dist/batchWork.d.ts +0 -6
  278. package/dist/constants/coordinateNames.d.ts +0 -8
  279. package/dist/constants/frame_props.d.ts +0 -13
  280. package/dist/data/dataFunctions.d.ts +0 -45
  281. package/dist/data/multiAccessorUtils.d.ts +0 -1
  282. package/dist/data/unflowedFunctions.d.ts +0 -1
  283. package/dist/generic_utilities/functions.d.ts +0 -1
  284. package/dist/geometry/areaDrawing.d.ts +0 -21
  285. package/dist/geometry/contourLayout.d.ts +0 -6
  286. package/dist/geometry/hexbinLayout.d.ts +0 -7
  287. package/dist/geometry/lineDrawing.d.ts +0 -71
  288. package/dist/geometry/summaryLayouts.d.ts +0 -45
  289. package/dist/index.d.ts +0 -1
  290. package/dist/network.js +0 -7495
  291. package/dist/network.js.map +0 -1
  292. package/dist/network.module.js +0 -7458
  293. package/dist/network.module.js.map +0 -1
  294. package/dist/ordinal.js +0 -6497
  295. package/dist/ordinal.js.map +0 -1
  296. package/dist/ordinal.module.js +0 -6465
  297. package/dist/ordinal.module.js.map +0 -1
  298. package/dist/processing/InteractionItems.d.ts +0 -13
  299. package/dist/processing/hierarchyUtils.d.ts +0 -16
  300. package/dist/processing/layouts/chordLayout.d.ts +0 -2
  301. package/dist/processing/layouts/forceLayout.d.ts +0 -3
  302. package/dist/processing/layouts/hierarchyLayout.d.ts +0 -10
  303. package/dist/processing/layouts/index.d.ts +0 -8
  304. package/dist/processing/layouts/sankeyLayout.d.ts +0 -8
  305. package/dist/processing/layouts/simpleLayouts.d.ts +0 -7
  306. package/dist/processing/layouts/types.d.ts +0 -17
  307. package/dist/processing/networkDefaults.d.ts +0 -36
  308. package/dist/realtime/renderers/barRenderer.d.ts +0 -2
  309. package/dist/realtime/renderers/candlestickRenderer.d.ts +0 -2
  310. package/dist/realtime/renderers/lineRenderer.d.ts +0 -2
  311. package/dist/realtime/renderers/swarmRenderer.d.ts +0 -2
  312. package/dist/realtime.js +0 -7072
  313. package/dist/realtime.js.map +0 -1
  314. package/dist/realtime.module.js +0 -7043
  315. package/dist/realtime.module.js.map +0 -1
  316. package/dist/semiotic-ai.js +0 -13323
  317. package/dist/semiotic-ai.js.map +0 -1
  318. package/dist/semiotic-ai.module.js +0 -13264
  319. package/dist/semiotic-ai.module.js.map +0 -1
  320. package/dist/semiotic-data.js +0 -141
  321. package/dist/semiotic-data.js.map +0 -1
  322. package/dist/semiotic-data.module.js +0 -136
  323. package/dist/semiotic-data.module.js.map +0 -1
  324. package/dist/semiotic.js +0 -16351
  325. package/dist/semiotic.js.map +0 -1
  326. package/dist/semiotic.module.js +0 -16265
  327. package/dist/semiotic.module.js.map +0 -1
  328. package/dist/server.js +0 -5191
  329. package/dist/server.js.map +0 -1
  330. package/dist/server.module.js +0 -5166
  331. package/dist/server.module.js.map +0 -1
  332. package/dist/stream/NetworkSceneGraph.d.ts +0 -14
  333. package/dist/stream/index.d.ts +0 -16
  334. package/dist/types/canvasTypes.d.ts +0 -9
  335. package/dist/types/xyTypes.d.ts +0 -24
  336. package/dist/useBoundingRect.d.ts +0 -2
  337. package/dist/visualizationLayerBehavior/axis.d.ts +0 -36
  338. package/dist/visualizationLayerBehavior/general.d.ts +0 -80
  339. package/dist/xy.js +0 -6993
  340. package/dist/xy.js.map +0 -1
  341. package/dist/xy.module.js +0 -6957
  342. package/dist/xy.module.js.map +0 -1
@@ -1 +1 @@
1
- "use strict";const e=require("react"),t=require("d3-brush"),o=require("d3-selection"),n=require("d3-scale"),r=require("d3-array"),i=require("d3-interpolate"),s=require("d3-sankey-circular"),a=require("d3-scale-chromatic"),l=require("d3-shape"),c=require("d3-force"),u=require("d3-chord"),d=require("d3-hierarchy"),h=require("labella"),f=require("regression"),p=require("d3-contour"),m=require("d3-hexbin");function y(e){return e&&e.__esModule?e:{default:e}}function g(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}const v=g(e),b=y(h),x=y(f),k=5e3;class w{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,k),bounded:!0,totalSize:e.length});let t=k;const o=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const n=Math.min(t+k,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class A{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const o of e){const e=this.push(o);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),o=[];for(;t.length>e;)o.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return o}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class E{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function M(e,t,o,n,r){const i=new Map;for(const s of e){const e=t(s),a=o(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/n)*n;let c=i.get(l);if(c||(c={start:l,end:l+n,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function S(e,t,o,n,r,i){const s=[],a=[];for(const r of e){const e=o(r),i=n(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(s.push([t.x(e),t.y(i)]),a.push(i))}return{type:"line",path:s,rawValues:a,style:r,datum:e,group:i}}function O(e,t,o,n,r,i,s){const a=[],l=[];for(const i of e){const e=o(i),s=n(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e);a.push([c,t.y(s)]),l.push([c,t.y(r)])}return{type:"area",topPath:a,bottomPath:l,style:i,datum:e,group:s}}function P(e,t,o,n,r,i){const s=o(e),a=n(e);return null==s||null==a||Number.isNaN(s)||Number.isNaN(a)?null:{type:"point",x:t.x(s),y:t.y(a),r:r,style:i,datum:e}}function j(e,t,o,n,r,i,s){return{type:"rect",x:e,y:t,w:o,h:n,style:r,datum:i,group:s}}function N(e,t,o,n,r,i){return{type:"heatcell",x:e,y:t,w:o,h:n,fill:r,datum:i}}function _(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function C(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class z{constructor(e){this.xExtent=new E,this.yExtent=new E,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new A(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=_(e.timeAccessor||e.xAccessor,"time"),this.getY=_(e.valueAccessor||e.yAccessor,"value")):(this.getX=_(e.xAccessor,"x"),this.getY=_(e.yAccessor,"y")),this.getGroup=C(e.groupAccessor),this.getCategory=C(e.categoryAccessor),this.getSize=e.sizeAccessor?_(e.sizeAccessor,"size"):void 0,this.getColor=C(e.colorAccessor),this.getBounds=e.boundsAccessor?_(e.boundsAccessor,"bounds"):void 0,"candlestick"===e.chartType&&(this.getOpen=_(e.openAccessor,"open"),this.getHigh=_(e.highAccessor,"high"),this.getLow=_(e.lowAccessor,"low"),this.getClose=_(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new A(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):this.yExtent.push(this.getY(o))}else for(const o of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):this.yExtent.push(this.getY(o)),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,o,r,i,s,a;const{config:l,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,d=this.yExtent.extent;let h=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:u[0],null!==(o=l.xExtent[1])&&void 0!==o?o:u[1]]:u,f=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&c.size>0)if(l.normalize)f=[0,1+l.extentPadding];else{const e=c.toArray(),t=this.groupData(e),o=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),n=this.getY(t);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||o.set(e,(o.get(e)||0)+n)}let n=0;for(const e of o.values())e>n&&(n=e);f=[0,n+(n>0?n*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!p&&c.size>0){const[,e]=function(e,t,o,n,r){const i=M(e,t,o,n,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(c,this.getX,this.getY,l.binSize,this.getCategory);f=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!p&&c.size>0){const[e,t]=function(e,t){let o=0,n=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,o>r&&(o=r),r>n&&(n=r))}return[o,n]}(c,this.getY),o=t-e,n=o>0?o*l.extentPadding:1;f=[Math.min(0,e-Math.abs(n)),Math.max(0,t+Math.abs(n))]}else if(!p&&f[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),o=this.getBounds(t);null!=e&&!Number.isNaN(e)&&o&&(e+o>f[1]&&(f[1]=e+o),f[0]>e-o&&(f[0]=e-o))}}const e=f[1]-f[0],t=e>0?e*l.extentPadding:1,o=null===(s=l.yExtent)||void 0===s?void 0:s[0],n=null===(a=l.yExtent)||void 0===a?void 0:a[1];f=[null!=o?f[0]:f[0]-t,null!=n?f[1]:f[1]+t]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(m=l.arrowOfTime)||"down"===m?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:n.scaleLinear().domain(h).range(t),y:n.scaleLinear().domain(f).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:n.scaleLinear().domain(f).range([0,e.width]),y:n.scaleLinear().domain(h).range(t)}}else this.scales={x:n.scaleLinear().domain(h).range([0,e.width]),y:n.scaleLinear().domain(f).range([e.height,0])};var m;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:o,scales:n}=this;if(!n||0===o.size)return[];const r=o.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const o=this.groupData(e),n=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of o){const t=this.buildBoundsForGroup(e.data,e.key);t&&n.push(t)}for(const e of o){const t=this.resolveLineStyle(e.key,e.data[0]),o=S(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(o.colorThresholds=r),n.push(o)}return n}buildAreaScene(e){const t=this.groupData(e),o=[],n=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]);o.push(O(e.data,this.scales,this.getX,this.getY,n,t,e.key))}return o}buildStackedAreaScene(e){return function(e,t,o,n,r,i){var s;const a=new Set;for(const t of e)for(const e of t.data){const t=o(e);null==t||Number.isNaN(t)||a.add(t)}const l=Array.from(a).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=o(r),i=n(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let o=0;for(const n of e)o+=(null===(s=c.get(n.key))||void 0===s?void 0:s.get(t))||0;u.set(t,o||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const o of e){const e=c.get(o.key),n=[],s=[];for(const o of l){let r=e.get(o)||0;const a=h.get(o);i&&(r/=u.get(o));const l=t.x(o);s.push([l,t.y(a)]),n.push([l,t.y(a+r)]),h.set(o,a+r)}d.push({type:"area",topPath:n,bottomPath:s,style:r(o.key,o.data[0]),datum:o.data,group:o.key})}return d}(this.groupData(e),this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],o="bubble"===this.config.chartType?10:5,n=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),o=Math.max(...t);r=t=>e===o?(n[0]+n[1])/2:n[0]+(t-e)/(o-e)*(n[1]-n[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const o of e){const e=this.getColor(o);e&&t.add(e)}const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let n=0;for(const e of t)i.set(e,o[n%o.length]),n++}for(const n of e){let e=this.config.pointStyle?this.config.pointStyle(n):{fill:"#4e79a7",opacity:.8},s=e.r||o;if(r&&this.getSize){const e=this.getSize(n);null==e||Number.isNaN(e)||(s=r(e))}if(i&&this.getColor){const t=this.getColor(n);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const a=P(n,this.scales,this.getX,this.getY,s,e);a&&t.push(a)}return t}buildHeatmapScene(e,t){const o=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const n=_(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const s=Array.from(r).sort((e,t)=>e-t),a=Array.from(i).sort((e,t)=>e-t);if(0===s.length||0===a.length)return o;const l=t.width/s.length,c=t.height/a.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:n(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const f=h-d||1;for(let e=0;s.length>e;e++)for(let t=0;a.length>t;t++){const n=u.get(`${s[e]}_${a[t]}`);if(!n)continue;const r=(n.val-d)/f;o.push(N(e*l,(a.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,n.datum))}return o}buildStreamingHeatmapScene(e,t){var o,n,r;const i=[],s=null!==(o=this.config.heatmapXBins)&&void 0!==o?o:20,a=null!==(n=this.config.heatmapYBins)&&void 0!==n?n:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=_(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,f]=this.scales.y.domain(),p=(d-u||1)/s,m=(f-h||1)/a,y=new Map;for(const t of e){const e=this.getX(t),o=this.getY(t),n=Math.min(Math.floor((e-u)/p),s-1),r=Math.min(Math.floor((o-h)/m),a-1);if(0>n||0>r)continue;const i=`${n}_${r}`;let l=y.get(i);l||(l={sum:0,count:0,data:[]},y.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let g=1/0,v=-1/0;const b=new Map;for(const[e,t]of y){let o;switch(l){case"sum":o=t.sum;break;case"mean":o=t.count>0?t.sum/t.count:0;break;default:o=t.count}b.set(e,o),g>o&&(g=o),o>v&&(v=o)}const x=v-g||1,k=t.width/s,w=t.height/a;for(const[e,t]of b){const[o,n]=e.split("_"),r=+o,s=+n,l=(t-g)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=y.get(e);i.push(N(r*k,(a-1-s)*w,k,w,c,{xi:r,yi:s,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const o=M(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===o.size)return[];let n=null;if(this.getCategory){const e=new Set;for(const t of o.values())for(const o of t.categories.keys())e.add(o);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();n=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[s,a]=i.x.domain();for(const e of o.values()){const o=Math.max(e.start,s),l=Math.min(e.end,a);if(o>=l)continue;const c=i.x(o),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(n&&e.categories.size>0){let o=0;for(const s of n){const n=e.categories.get(s)||0;if(0===n)continue;const a=i.y(o),l=i.y(o+n);r.push(j(d,Math.min(a,l),h,Math.abs(a-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:n},s)),o+=n}}else{const t=i.y(0),o=i.y(e.total);r.push(j(d,Math.min(t,o),h,Math.abs(t-o),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,o,n,r;const i=[],s=this.config.swarmStyle||{},a=null!==(t=s.radius)&&void 0!==t?t:3,l=null!==(o=s.fill)&&void 0!==o?o:"#007bff",c=null!==(n=s.opacity)&&void 0!==n?n:.7,u=s.stroke,d=s.strokeWidth;for(const t of e){const e=this.getX(t),o=this.getY(t);if(null==o||Number.isNaN(o))continue;const n=this.scales.x(e),s=this.scales.y(o);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}i.push({type:"point",x:n,y:s,r:a,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t})}return i}buildWaterfallScene(e,t){const o=[],n=this.scales,r=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===r.length)return o;let i=0;for(let e=0;r.length>e;e++){const s=r[e],a=this.getX(s),l=this.getY(s),c=i+l;let u;u=r.length-1>e?this.getX(r[e+1])-a:e>0?a-this.getX(r[e-1]):0;const d=n.x(a),h=0!==u?n.x(a+u):d+t.width/10,f=Math.min(d,h)+.5,p=Math.max(d,h)-.5-f;if(0>=p){i=c;continue}const m=n.y(i),y=n.y(c);o.push(j(f,Math.min(m,y),p,Math.abs(m-y),{fill:0>l?"#dc3545":"#28a745"},Object.assign(Object.assign({},s),{baseline:i,cumEnd:c,delta:l}))),i=c}return o}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const o=[],n=this.config.candlestickStyle||{},r=n.upColor||"#28a745",i=n.downColor||"#dc3545",s=n.wickColor||"#333",a=n.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=n.bodyWidth||6;if(!n.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const o=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));o>0&&e>o&&(e=o)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const n=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([n,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=n;o.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(n),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,isUp:h,datum:t})}return o}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const o=[],n=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),s=this.scales.x(e);if(i&&0!==i)o.push([s,this.scales.y(r+i)]),n.push([s,this.scales.y(r-i)]);else{const e=this.scales.y(r);o.push([s,e]),n.push([s,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:n,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const o=this.config.boundsStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var o,n,r;const i=this.config.decay;if(!i||1>=t)return 1;const s=null!==(o=i.minOpacity)&&void 0!==o?o:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(n=i.halfLife)&&void 0!==n?n:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;default:return 1}}applyDecay(e,t){var o,n;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:s};else if("candlestick"===t.type)t._decayOpacity=s;else{const e=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*s})}}}computePulseIntensity(e,t){var o;const n=this.config.pulse;if(!n)return 0;const r=null!==(o=n.duration)&&void 0!==o?o:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var o;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const s=this.computePulseIntensity(o,n);s>0&&(t._pulseIntensity=s,t._pulseColor=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],o=this.getNodeIdentity(t,e);o&&("point"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(o,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var o,n,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(n=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==n?n:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,o,n,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const s=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],l=this.getNodeIdentity(s,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===s.type){const e={x:s.x,y:s.y,r:s.r};c.x===e.x&&c.y===e.y||(s._targetX=e.x,s._targetY=e.y,s._targetR=e.r,s.x=c.x,s.y=c.y,s.r=null!==(t=c.r)&&void 0!==t?t:s.r,a=!0)}else if("rect"===s.type){const e={x:s.x,y:s.y,w:s.w,h:s.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(s._targetX=e.x,s._targetY=e.y,s._targetW=e.w,s._targetH=e.h,s.x=c.x,s.y=c.y,s.w=null!==(o=c.w)&&void 0!==o?o:s.w,s.h=null!==(n=c.h)&&void 0!==n?n:s.h,a=!0)}else if("heatcell"===s.type){const e={x:s.x,y:s.y,w:s.w,h:s.h};c.x===e.x&&c.y===e.y||(s._targetX=e.x,s._targetY=e.y,s._targetW=e.w,s._targetH=e.h,s.x=c.x,s.y=c.y,s.w=null!==(r=c.w)&&void 0!==r?r:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,a=!0)}}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:s})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const o=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),n="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?o:1-Math.pow(1-o,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=o.x+(e._targetX-o.x)*n,e.y=o.y+(e._targetY-o.y)*n,void 0!==e._targetR&&void 0!==o.r&&(e.r=o.r+(e._targetR-o.r)*n)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=o.x+(e._targetX-o.x)*n,e.y=o.y+(e._targetY-o.y)*n,void 0!==o.w&&(e.w=o.w+(e._targetW-o.w)*n),void 0!==o.h&&(e.h=o.h+(e._targetH-o.h)*n)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=o.x+(e._targetX-o.x)*n,e.y=o.y+(e._targetY-o.y)*n,void 0!==o.w&&(e.w=o.w+(e._targetW-o.w)*n),void 0!==o.h&&(e.h=o.h+(e._targetH-o.h)*n)}if(o>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const o of e){const e=this.getGroup(o);t.has(e)||t.set(e,[]),t.get(e).push(o)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{stroke:o.stroke||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var o;if(this.config.areaStyle)return this.config.areaStyle(t||{});const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{fill:n.fill||n.stroke||"#4e79a7",fillOpacity:null!==(o=n.fillOpacity)&&void 0!==o?o:.7,stroke:n.stroke||"#4e79a7",strokeWidth:n.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function $(e,t,o){const n=t-e.x,r=o-e.y,i=Math.sqrt(n*n+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function B(e,t,o){if(0===e.path.length)return null;const n=R(e.path,t);if(0>n)return null;const[r,i]=e.path[n],s=t-r,a=o-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:r,y:i,distance:l}}function L(e,t,o){return e.x>t||t>e.x+e.w||e.y>o||o>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function D(e,t,o){return e.x>t||t>e.x+e.w||e.y>o||o>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function T(e,t,o){const n=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-n-3>t||t>e.x+n+3||e.highY-3>o||o>e.lowY+3)){const n=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=o-n;return{node:e,datum:e.datum,x:e.x,y:n,distance:Math.sqrt(i*i+s*s)}}return null}function W(e,t,o){if(0===e.topPath.length)return null;const n=R(e.topPath,t);if(0>n)return null;const[r,i]=e.topPath[n],s=t-r,a=o-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(s*s+a*a)}}function R(e,t){if(0===e.length)return-1;let o=0,n=e.length-1;for(;n>o;){const r=o+n>>1;t>e[r][0]?o=r+1:n=r}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}const F={fill:e=>v.createElement("rect",{style:e,width:20,height:20}),line:e=>v.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function H(e,t,o,n){let r;return r="function"==typeof o?o(e):(0,F[o])(n(e,t)),r}function I(e){const{legendGroups:t,customClickBehavior:o,title:n="Legend",width:r=100,height:i=20,orientation:s="vertical"}=e,a="vertical"===s?(({legendGroups:e,width:t,customClickBehavior:o})=>{let n=30;const r=[];return e.forEach((e,i)=>{n+=5,r.push(v.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:n,x2:t,y2:n})),n+=10,e.label&&(n+=20,r.push(v.createElement("text",{key:"legend-text-"+i,y:n,className:"legend-group-label"},e.label)),n+=10),r.push(v.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${n})`},((e,t)=>{const{type:o="fill",styleFn:n,items:r}=e,i=[];let s=0;return r.forEach((e,r)=>{const a=H(e,r,o,n);i.push(v.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${s})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},a,v.createElement("text",{y:15,x:30},e.label))),s+=25}),i})(e,o))),n+=25*e.items.length+10}),r})({legendGroups:t,width:r,customClickBehavior:o}):(({legendGroups:e,title:t,height:o,customClickBehavior:n})=>{let r=0;const i=[],s=!1===t?10:40;return e.forEach((t,a)=>{t.label&&(i.push(v.createElement("text",{key:"legend-text-"+a,transform:`translate(${r},${s}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),r+=20);const l=((e,t)=>{const{type:o="fill",styleFn:n,items:r}=e,i=[];let s=0;return r.forEach((e,r)=>{const a=H(e,r,o,n);i.push(v.createElement("g",{key:"legend-item-"+r,transform:`translate(${s},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},a,v.createElement("text",{y:15,x:25},e.label))),s+=35,s+=8*e.label.length}),{items:i,offset:s}})(t,n);i.push(v.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${r},${s})`},l.items)),r+=l.offset+5,e[a+1]&&i.push(v.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:r,y1:s-10,x2:r,y2:o+s+10})),r+=15}),v.createElement("g",null,!1!==t&&v.createElement("line",{x1:0,x2:r+10,y1:s-10,y2:s-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:n,height:i,customClickBehavior:o});return v.createElement("g",null,void 0!==n&&v.createElement("text",{className:"legend-title",y:20,x:"horizontal"===s?0:r/2,textAnchor:"horizontal"===s?"start":"middle"},n),a)}function Y(e){return"string"==typeof e?{type:e}:e}function X({orient:t,config:o,values:n,scale:i,size:s,length:a}){const l=function(e){var t,o,n,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(o=e.fill)&&void 0!==o?o:"#4e79a7",fillOpacity:null!==(n=e.fillOpacity)&&void 0!==n?n:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(o),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===n.length)return null;const e=i.domain(),o=s-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const n=t[Math.floor(.25*o)],r=t[Math.floor(.5*o)],i=t[Math.floor(.75*o)],s=i-n;return{q1:n,median:r,q3:i,whiskerLow:Math.max(t[0],n-1.5*s),whiskerHigh:Math.min(t[o-1],i+1.5*s)}}(n);if(!e)return null;const{q1:r,median:s,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*o,20),f=(o-h)/2+4;if(c){const e=i(r),o=i(a),n=i(s),c=i(u),p=i(d),m="top"===t?-1:1,y=0;return v.createElement("g",{"data-testid":"marginal-boxplot-"+t},v.createElement("line",{x1:c,y1:y+m*(f+h/2),x2:p,y2:y+m*(f+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:c,y1:y+m*f,x2:c,y2:y+m*(f+h),stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:p,y1:y+m*f,x2:p,y2:y+m*(f+h),stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("rect",{x:Math.min(e,o),y:"top"===t?y-f-h:y+f,width:Math.abs(o-e),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:n,y1:"top"===t?y-f-h:y+f,x2:n,y2:"top"===t?y-f:y+f+h,stroke:l.fill,strokeWidth:2}))}{const e=i(r),o=i(a),n=i(s),c=i(u),p=i(d),m="left"===t?-1:1,y=0;return v.createElement("g",{"data-testid":"marginal-boxplot-"+t},v.createElement("line",{x1:y+m*(f+h/2),y1:c,x2:y+m*(f+h/2),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:y+m*f,y1:c,x2:y+m*(f+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:y+m*f,y1:p,x2:y+m*(f+h),y2:p,stroke:l.fill,strokeWidth:l.strokeWidth}),v.createElement("rect",{x:"left"===t?y-f-h:y+f,y:Math.min(e,o),width:h,height:Math.abs(o-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),v.createElement("line",{x1:"left"===t?y-f-h:y+f,y1:n,x2:"left"===t?y-f:y+f+h,y2:n,stroke:l.fill,strokeWidth:2}))}}const u=r.bin().domain(e).thresholds(l.bins)(n);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return v.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/d*o;if(c){const o=i(e.x0),s=i(e.x1)-i(e.x0);return v.createElement("rect",{key:n,x:o,y:"top"===t?-4-r:4,width:Math.max(s,.5),height:r,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const o=i(e.x0),s=i(e.x1)-i(e.x0);return v.createElement("rect",{key:n,x:"left"===t?-4-r:4,y:Math.min(o,o+s),width:r,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=o/2+4,n=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const s=r.length/d*(o/2),a=i((r.x0+r.x1)/2);n.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let r=u.length-1;r>=0;r--){const s=u[r];if(null==s.x0||null==s.x1)continue;const a=s.length/d*(o/2),l=i((s.x0+s.x1)/2);n.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return v.createElement("g",{"data-testid":"marginal-violin-"+t},v.createElement("polygon",{points:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const n=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${n}`);for(const n of u){if(null==n.x0||null==n.x1)continue;const r=n.length/d*o,s=i((n.x0+n.x1)/2);e.push(`L${s},${"top"===t?-r-4:r+4}`)}const s=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;e.push(`L${s},${n}`),e.push("Z")}else{const n=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${n},${r}`);for(const n of u){if(null==n.x0||null==n.x1)continue;const r=n.length/d*o,s=i((n.x0+n.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${s}`)}const s=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;e.push(`L${n},${s}`),e.push("Z")}return v.createElement("g",{"data-testid":"marginal-ridgeline-"+t},v.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[n,i,l,s,a,t,c,4]);return u?v.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function G(e){return Math.round(100*e)/100+""}function q(t){const{width:o,height:n,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,xLabel:c,yLabel:u,xFormat:d,yFormat:h,showGrid:f,title:p,legend:m,foregroundGraphics:y,marginalGraphics:g,xValues:b,yValues:x,annotations:k,svgAnnotationRules:w,annotationFrame:A,children:E}=t,M=e.useMemo(()=>l&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(d||G)(e)})):[],[l,a,d]),S=e.useMemo(()=>l&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(h||G)(e)})):[],[l,a,h]),O=e.useMemo(()=>k&&0!==k.length&&w?k.map((e,t)=>w(e,t,{scales:a?{time:a.x,value:a.y}:null,timeAxis:"x",width:o,height:n})).filter(Boolean):null,[k,w,o,n,A]);return l||p||m||y||g||O&&O.length>0||f||E?v.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},v.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&a&&v.createElement("g",{className:"stream-grid"},M.map((e,t)=>v.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"#e0e0e0",strokeWidth:1})),S.map((e,t)=>v.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"#e0e0e0",strokeWidth:1}))),l&&a&&v.createElement("g",{className:"stream-axes"},v.createElement("line",{x1:0,y1:n,x2:o,y2:n,stroke:"#ccc",strokeWidth:1}),M.map((e,t)=>v.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${n})`},v.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),c&&v.createElement("text",{x:o/2,y:n+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},c),v.createElement("line",{x1:0,y1:0,x2:0,y2:n,stroke:"#ccc",strokeWidth:1}),S.map((e,t)=>v.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},v.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),u&&v.createElement("text",{x:15-s.left,y:n/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-s.left}, ${n/2})`,style:{userSelect:"none"}},u)),O,g&&a&&b&&x&&v.createElement(v.Fragment,null,g.top&&v.createElement("g",{transform:"translate(0, 0)"},v.createElement(X,{orient:"top",config:Y(g.top),values:b,scale:a.x,size:s.top,length:o})),g.bottom&&v.createElement("g",{transform:`translate(0, ${n})`},v.createElement(X,{orient:"bottom",config:Y(g.bottom),values:b,scale:a.x,size:s.bottom,length:o})),g.left&&v.createElement("g",{transform:"translate(0, 0)"},v.createElement(X,{orient:"left",config:Y(g.left),values:x,scale:a.y,size:s.left,length:n})),g.right&&v.createElement("g",{transform:`translate(${o}, 0)`},v.createElement(X,{orient:"right",config:Y(g.right),values:x,scale:a.y,size:s.right,length:n}))),y,E),p&&v.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof p?p:null),m&&v.createElement("g",{transform:`translate(${r-s.right+10}, ${s.top})`},"object"==typeof(P=m)&&null!==P&&!v.isValidElement(P)&&"legendGroups"in P?v.createElement(I,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var P}function V(e,t,o){let n=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(n=o.color):e>o.value&&(n=o.color);return n}const U=(e,t,o,n)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[o,n]=t.topPath[0];e.moveTo(o,n);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath();const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;if(e.globalAlpha=i,e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);e.stroke()}e.globalAlpha=1}},K=(e,t,o,n)=>{var r;const i=t.filter(e=>"point"===e.type);for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=o&&(e.globalAlpha=o),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const o=4;e.beginPath(),e.arc(t.x,t.y,t.r+o*t._pulseIntensity,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.5*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},Z=(e,t,o,n)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?J(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function J(e,t){const o=t.style.icon,n=t.style.iconPadding||2,r=Math.min(t.w,t.w)-n;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+n,s=t.x+(t.w-r)/2;for(let n=t.y+t.h-r;n>=t.y-r;n-=i)e.drawImage(o,s,n,r,r)}else{const i=r+n,s=t.y+(t.h-r)/2;for(let n=t.x;t.x+t.w>n;n+=i)e.drawImage(o,n,s,r,r)}e.restore()}const Q={line:[U,(e,t,o,n)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const s=i.style.stroke||"#007bff",a=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=a,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,f=null,p=!1;function m(t,o,n){e.beginPath(),e.strokeStyle=t,e.moveTo(o,n),p=!0}function y(){p&&(e.stroke(),p=!1)}for(let g=0;i.path.length>g;g++){const[v,b]=i.path[g],x=c[g],k=V(x,l,s);if(null!==u&&null!==f&&null!==h){if(k===f)e.lineTo(v,b);else{const w=[];for(const A of l){const E=A.value;(h>E||E>x)&&(E>h||x>E)||h===E||x===E||w.push({t:(E-h)/(x-h)})}w.sort((e,t)=>e.t-t.t);for(const M of w){const S=u+(v-u)*M.t,O=d+(b-d)*M.t,P=V(h+(x-h)*Math.min(M.t+1e-4,1),l,s);e.lineTo(S,O),y(),m(P,S,O)}e.lineTo(v,b)}u=v,d=b,h=x,f=k}else m(k,v,b),u=v,d=b,h=x,f=k}y()}else{e.beginPath(),e.strokeStyle=s;const[j,N]=i.path[0];e.moveTo(j,N);for(let _=1;i.path.length>_;_++)e.lineTo(i.path[_][0],i.path[_][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[C,z]=i.path[0];e.moveTo(C,z);for(let B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const $=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],n.height),e.lineTo($,n.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[U],stackedarea:[U],scatter:[K],bubble:[K],heatmap:[(e,t,o,n)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const o=t.style;null!=(null==o?void 0:o.opacity)&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[Z],swarm:[K],waterfall:[(e,t,o,n)=>{var r,i;Z(e,t);const s=t.filter(e=>"rect"===e.type);if(s.length>=2){e.save(),e.strokeStyle="#999",e.lineWidth=1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const n=s[t],a=s[t+1];if(!(null===(r=n.datum)||void 0===r?void 0:r.cumEnd)||!(null===(i=a.datum)||void 0===i?void 0:i.baseline))continue;const l=o.y(n.datum.cumEnd),c=n.x+n.w,u=a.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,o,n)=>{for(const o of t){if("candlestick"!==o.type)continue;const t=o;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}}]},ee={top:20,right:20,bottom:30,left:40},te={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},oe={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 ne({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return v.createElement("div",{className:"semiotic-tooltip",style:oe},v.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),v.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function re({width:n,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const d=e.useRef(null),h=e.useRef(null);return e.useEffect(()=>{if(!d.current)return;const e=o.select(d.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[n,r]]),i.on("brush end",e=>{if(!c)return;if(!e.selection)return void u(null);let t,o;if("x"===l){const[n,i]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,i]=e.selection;t=[c.x.invert(0),c.x.invert(n)],o=[c.y.invert(i),c.y.invert(r)]}else{const[[n,r],[i,s]]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(s),c.y.invert(r)]}u({x:t,y:o})}),e.call(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),h.current=null}},[n,r,l,c,u]),v.createElement("svg",{ref:d,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},v.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const ie=e.forwardRef(function(t,o){var n;const{chartType:r,runtimeMode:i,data:s,xAccessor:a,yAccessor:l,colorAccessor:c,sizeAccessor:u,groupAccessor:d,lineDataAccessor:h,normalize:f,binSize:p,valueAccessor:m,arrowOfTime:y="right",windowMode:g="sliding",windowSize:b=200,timeAccessor:x,xExtent:k,yExtent:A,extentPadding:E=.1,sizeRange:M,size:S=[500,300],margin:O,className:P,background:j,lineStyle:N,pointStyle:_,areaStyle:C,swarmStyle:R,barColors:F,colorScheme:H,boundsAccessor:I,boundsStyle:Y,openAccessor:X,highAccessor:G,lowAccessor:V,closeAccessor:U,candlestickStyle:K,showAxes:Z=!0,xLabel:J,yLabel:oe,xFormat:ie,yFormat:se,tickFormatTime:ae,tickFormatValue:le,hoverAnnotation:ce,tooltipContent:ue,customHoverBehavior:de,enableHover:he,annotations:fe,svgAnnotationRules:pe,showGrid:me,legend:ye,backgroundGraphics:ge,foregroundGraphics:ve,title:be,categoryAccessor:xe,brush:ke,onBrush:we,decay:Ae,pulse:Ee,transition:Me,staleness:Se,heatmapAggregation:Oe,heatmapXBins:Pe,heatmapYBins:je,marginalGraphics:Ne}=t,_e=Object.assign(Object.assign({},ee),O);if(Ne){const e=60;Ne.top&&e>_e.top&&(_e.top=e),Ne.bottom&&e>_e.bottom&&(_e.bottom=e),Ne.left&&e>_e.left&&(_e.left=e),Ne.right&&e>_e.right&&(_e.right=e)}const Ce=S[0]-_e.left-_e.right,ze=S[1]-_e.top-_e.bottom,$e=null!=ce?ce:he,Be=e.useRef(null),Le=e.useRef(0),De=e.useRef(!1),[Te,We]=e.useState(0),[Re,Fe]=e.useState(null),He=e.useRef(null),[Ie,Ye]=e.useState(null),[Xe,Ge]=e.useState(!1),[qe,Ve]=e.useState([]),[Ue,Ke]=e.useState([]),Ze=e.useRef(()=>{}),Je="streaming"===i||["bar","swarm","waterfall"].includes(r),Qe=e.useMemo(()=>({chartType:r,runtimeMode:Je?"streaming":"bounded",windowSize:b,windowMode:g,arrowOfTime:Je?y:"right",extentPadding:E,xAccessor:Je?void 0:a,yAccessor:Je?void 0:l,timeAccessor:Je?x:void 0,valueAccessor:m,colorAccessor:c,sizeAccessor:u,groupAccessor:d,categoryAccessor:xe,lineDataAccessor:h,xExtent:k,yExtent:A,sizeRange:M,binSize:p,normalize:f,boundsAccessor:I,boundsStyle:Y,openAccessor:X,highAccessor:G,lowAccessor:V,closeAccessor:U,candlestickStyle:K,lineStyle:N,pointStyle:_,areaStyle:C,swarmStyle:R,colorScheme:H,barColors:F,annotations:fe,decay:Ae,pulse:Ee,transition:Me,staleness:Se,heatmapAggregation:Oe,heatmapXBins:Pe,heatmapYBins:je}),[r,b,g,y,E,a,l,x,m,c,u,d,xe,h,k,A,M,p,f,I,Y,X,G,V,U,K,N,_,C,R,H,F,fe,Ae,Ee,Me,Se,Oe,Pe,je,Je]),et=e.useRef(null);et.current||(et.current=new z(Qe));const tt=e.useCallback(()=>{Le.current||(Le.current=requestAnimationFrame(()=>Ze.current()))},[]);e.useEffect(()=>{var e;null===(e=et.current)||void 0===e||e.updateConfig(Qe),De.current=!0,tt()},[Qe,tt]);const ot=e.useRef(null);ot.current||(ot.current=new w(e=>{const t=et.current;t&&t.ingest(e)&&(De.current=!0,tt())}));const nt=e.useCallback(e=>{var t;null===(t=ot.current)||void 0===t||t.push(e)},[]),rt=e.useCallback(e=>{var t;null===(t=ot.current)||void 0===t||t.pushMany(e)},[]),it=e.useCallback(()=>{var e,t;null===(e=ot.current)||void 0===e||e.clear(),null===(t=et.current)||void 0===t||t.clear(),De.current=!0,tt()},[tt]);e.useImperativeHandle(o,()=>({push:nt,pushMany:rt,clear:it,getData:()=>{var e,t;return null!==(t=null===(e=et.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=et.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=et.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[nt,rt,it]),e.useEffect(()=>{var e;s&&(null===(e=ot.current)||void 0===e||e.setBoundedData(s))},[s]);const st=e.useRef(()=>{}),at=e.useRef(()=>{});st.current=e=>{if(!$e)return;const t=Be.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-_e.left,r=e.clientY-o.top-_e.top;if(0>n||n>Ce||0>r||r>ze)return void(He.current&&(He.current=null,Ye(null),de&&de(null),tt()));const i=et.current;if(!i||0===i.scene.length)return;const s=function(e,t,o,n=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=$(i,t,o);break;case"line":e=B(i,t,o);break;case"rect":e=L(i,t,o);break;case"heatcell":e=D(i,t,o);break;case"area":if(!1===i.interactive)break;e=W(i,t,o);break;case"candlestick":e=T(i,t,o)}e&&n>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,n,r);if(!s)return void(He.current&&(He.current=null,Ye(null),de&&de(null),tt()));const a={data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y};He.current=a,Ye(a),de&&de(a),tt()},at.current=()=>{He.current&&(He.current=null,Ye(null),de&&de(null),tt())};const lt=e.useCallback(e=>st.current(e),[]),ct=e.useCallback(()=>at.current(),[]);Ze.current=()=>{var e,t;Le.current=0;const o=Be.current;if(!o)return;const n=o.getContext("2d");if(!n)return;const i=et.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=i.advanceTransition(s);c||i.computeScene({width:Ce,height:ze});const u="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=S[0]*u,o.height=S[1]*u,o.style.width=S[0]+"px",o.style.height=S[1]+"px",n.scale(u,u),n.translate(_e.left,_e.top),n.clearRect(-_e.left,-_e.top,S[0],S[1]);const d=function(e){if(!e)return te;const t=getComputedStyle(e),o=t.getPropertyValue("--text-secondary").trim(),n=t.getPropertyValue("--text-primary").trim(),r=t.getPropertyValue("--surface-3").trim(),i=t.getPropertyValue("--surface-0").trim();return o||n?{axisStroke:r||te.axisStroke,tickText:o||te.tickText,crosshair:o?o+"66":te.crosshair,hoverFill:i?i+"4D":te.hoverFill,hoverStroke:o?o+"99":te.hoverStroke,pointRing:i||te.pointRing}:te}(o),h=null!==(e=null==Se?void 0:Se.threshold)&&void 0!==e?e:5e3,f=Se&&i.lastIngestTime>0&&s-i.lastIngestTime>h;f&&(n.globalAlpha=null!==(t=null==Se?void 0:Se.dimOpacity)&&void 0!==t?t:.5),j&&(n.fillStyle=j,n.fillRect(0,0,Ce,ze));const p=Q[r];if(p&&i.scales)for(const e of p)e(n,i.scene,i.scales,{width:Ce,height:ze});f&&(n.globalAlpha=1),$e&&He.current&&i.scales&&function(e,t,o,n,r,i,s){if(!1===r.crosshair)return;e.save();const a="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=a.stroke||s.crosshair,e.lineWidth=a.strokeWidth||1,e.setLineDash(a.strokeDasharray?a.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,n),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}(n,He.current,Ce,ze,"object"==typeof $e?$e:{},0,d);const m=De.current;if(De.current=!1,m&&i.scales&&(Fe(i.scales),Ne)){const e=i.getData(),t="function"==typeof a?a:e=>e[a||"x"],o="function"==typeof l?l:e=>e[l||"y"];Ve(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Ke(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}m&&fe&&fe.length>0&&pe&&We(e=>e+1),(null==Se?void 0:Se.showBadge)&&Ge(!!f),(c||i.hasActivePulses)&&(Le.current=requestAnimationFrame(()=>Ze.current()))},e.useEffect(()=>(tt(),()=>{Le.current&&cancelAnimationFrame(Le.current)}),[tt]),e.useEffect(()=>{De.current=!0,tt()},[r,Ce,ze,Z,j,N,tt]),e.useEffect(()=>{if(!Se)return;const e=setInterval(()=>{var e;const t=et.current;if(!t||0===t.lastIngestTime)return;const o="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=Se.threshold)&&void 0!==e?e:5e3,r=o-t.lastIngestTime>n;r!==Xe&&(Ge(r),De.current=!0,tt())},1e3);return()=>clearInterval(e)},[Se,Xe,tt]);const ut=$e&&Ie?ue?ue(Ie):v.createElement(ne,{hover:Ie}):null,dt=ut?v.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:_e.left+Ie.x,top:_e.top+Ie.y,transform:`translate(${Ie.x>.7*Ce?"calc(-100% - 12px)":"12px"}, ${.3*ze>Ie.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ut):null;return v.createElement("div",{className:"stream-xy-frame"+(P?" "+P:""),style:{position:"relative",width:S[0],height:S[1]},onMouseMove:$e?lt:void 0,onMouseLeave:$e?ct:void 0},ge&&v.createElement("svg",{style:{position:"absolute",left:0,top:0,width:S[0],height:S[1],pointerEvents:"none"}},ge),v.createElement("canvas",{ref:Be,style:{position:"absolute",left:0,top:0}}),v.createElement(q,{width:Ce,height:ze,totalWidth:S[0],totalHeight:S[1],margin:_e,scales:Re,showAxes:Z,xLabel:J,yLabel:oe,xFormat:ie||ae,yFormat:se||le,showGrid:me,title:be,legend:ye,foregroundGraphics:ve,marginalGraphics:Ne,xValues:qe,yValues:Ue,annotations:fe,svgAnnotationRules:pe,annotationFrame:Te}),(ke||we)&&v.createElement(re,{width:Ce,height:ze,totalWidth:S[0],totalHeight:S[1],margin:_e,dimension:null!==(n=null==ke?void 0:ke.dimension)&&void 0!==n?n:"xy",scales:Re,onBrush:null!=we?we:()=>{}}),(null==Se?void 0:Se.showBadge)&&v.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Se.badgePosition?{top:4,left:4}:"bottom-left"===Se.badgePosition?{bottom:4,left:4}:"bottom-right"===Se.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Xe?"#dc3545":"#28a745",color:"white"})},Xe?"STALE":"LIVE"),dt)});function se(e,t){const{columns:o,config:n,resolvePieceStyle:r}=e,i=[],s=Math.min(t.width,t.height)/2-4,a="donut"===n.chartType?n.innerRadius||60:0,l=-Math.PI/2+(n.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(o)){const t=l+e.pctStart*c,o=l+(e.pctStart+e.pct)*c,n=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:t,endAngle:o,style:n,datum:e.pieceData,category:e.name})}return i}ie.displayName="StreamXYFrame";const ae={bar:function(e,t){const{scales:o,columns:n,config:r,getR:i,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h="horizontal"===c,f=r.normalize;for(const e of Object.values(n)){const t=new Map;for(const o of e.pieceData){const e=s?s(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=i(o),n.pieces.push(o)}let o=0;if(f)for(const e of t.values())o+=Math.abs(e.total);let n=0,r=0;for(const[i,c]of t){let t=c.total;f&&o>0&&(t/=o);const p=a(c.pieces[0],s?i:e.name),m=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const o=l(0>t?r:n+t),s=0>t?l(r+t)-l(r):l(n)-l(n+t);u.push(j(e.x,o,e.width,Math.abs(s),p,m,i)),0>t?r+=t:n+=t}else if(h){const o=l(0>t?r+t:n),s=0>t?l(r)-l(r+t):l(n+t)-l(n);u.push(j(o,e.x,Math.abs(s),e.width,p,m,i)),0>t?r+=t:n+=t}}}return u},clusterbar:function(e,t){const{scales:o,columns:n,getR:r,getGroup:i,resolvePieceStyle:s}=e,{r:a,projection:l}=o,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const f=d.length||1;for(const e of Object.values(n)){const t=e.width/f,o=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let n=0;d.length>n;n++){const i=o.get(d[n])||[];for(const o of i){const i=r(o),l=s(o,e.name);if(u){const r=e.x+n*t,s=a(0),u=a(i);c.push(j(r,Math.min(s,u),t,Math.abs(s-u),l,o,d[n]))}else{const r=e.x+n*t,s=a(0),u=a(i);c.push(j(Math.min(s,u),r,Math.abs(u-s),t,l,o,d[n]))}}}}return c},point:function(e,t){var o,n;const{scales:r,columns:i,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,f="radial"===u,p=a.length>0,m=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(o=t.__rIndex)&&void 0!==o?o:0,i=null!==(n=t.__rValue)&&void 0!==n?n:s(t),u=p&&a[r]||c,g=l(t,e.name),v=g.r||5;let b,x;if(f){const t=y+(e.pctStart+e.pct/2)*m,o=u(i);b=Math.cos(t)*o,x=Math.sin(t)*o}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:g,datum:t})}return d},swarm:function(e,t){const{scales:o,columns:n,getR:r,resolvePieceStyle:i}=e,{r:s,projection:a}=o,l=[],c="vertical"===a;for(const e of Object.values(n)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const n=e.pieceData[o],a=r(n),u=i(n,e.name),d=u.r||4,h=(7919*o%100/100-.5)*t*.8,f=c?e.middle+h:s(a),p=c?s(a):e.middle+h;l.push({type:"point",x:f,y:p,r:d,style:u,datum:n})}}return l},pie:se,donut:se,boxplot:function(e,t){var o,n,i,s,a;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:f,projection:p}=l,m=[],y="vertical"===p,g=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(o=r.quantile(t,.25))&&void 0!==o?o:l,p=null!==(n=r.quantile(t,.5))&&void 0!==n?n:(l+c)/2,v=null!==(i=r.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,k=v+1.5*b,w=null!==(s=t.find(e=>e>=x))&&void 0!==s?s:l,A=null!==(a=[...t].reverse().find(e=>k>=e))&&void 0!==a?a:c,E=h(e.pieceData[0],e.name),M=[];if(g)for(const t of e.pieceData){const o=d(t);if(x>o||o>k){const n=y?e.middle:f(o),r=y?f(o):e.middle;M.push({px:n,py:r,value:o,datum:t})}}if(m.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(w),q1Pos:f(u),medianPos:f(p),q3Pos:f(v),maxPos:f(A),stats:{min:w,q1:u,median:p,q3:v,max:A},style:E,datum:e.pieceData,category:e.name,outliers:M}),g)for(const e of M)m.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return m},violin:function(e,t){var o,n,i;const{scales:s,columns:a,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=s,f=[],p="vertical"===h,m=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(a)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const s=t[0],a=t[t.length-1],l=(a-s)/m||1,h=Array(m).fill(0);for(const e of t)h[Math.min(Math.floor((e-s)/l),m-1)]++;const g=Math.max(...h,1),v=e.width/2*.9;let b="";if(p){for(let t=0;m>t;t++){const o=d(s+(t+.5)*l),n=h[t]/g*v;b+=0===t?`M ${e.middle+n} ${o}`:` L ${e.middle+n} ${o}`}for(let t=m-1;t>=0;t--){const o=d(s+(t+.5)*l);b+=` L ${e.middle-h[t]/g*v} ${o}`}b+=" Z"}else{for(let t=0;m>t;t++){const o=d(s+(t+.5)*l),n=h[t]/g*v;b+=0===t?`M ${o} ${e.middle-n}`:` L ${o} ${e.middle-n}`}for(let t=m-1;t>=0;t--)b+=` L ${d(s+(t+.5)*l)} ${e.middle+h[t]/g*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const e=null!==(o=r.quantile(t,.25))&&void 0!==o?o:s,l=null!==(n=r.quantile(t,.5))&&void 0!==n?n:(s+a)/2,c=null!==(i=r.quantile(t,.75))&&void 0!==i?i:a;k={q1Pos:d(e),medianPos:d(l),q3Pos:d(c)}}const w=p?{x:e.x,y:Math.min(d(a),d(s)),width:e.width,height:Math.abs(d(a)-d(s))}:{x:Math.min(d(s),d(a)),y:e.x,width:Math.abs(d(a)-d(s)),height:e.width};f.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,style:x,datum:e.pieceData,category:e.name})}return f},histogram:function(e,t){const{scales:o,columns:n,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a}=o,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(n)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const o=Math.min(...t),n=(Math.max(...t)-o)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-o)/n),c-1)]++;const d=t.length,h=Math.max(...r,1),f=s(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,s=a(o+t*n),c=a(o+(t+1)*n);l.push(j(Math.min(s,c),e.x+e.width-i,Math.abs(c-s),i,f,{bin:t,count:r[t],range:[o+t*n,o+(t+1)*n],category:e.name},e.name))}}return l},ridgeline:function(e,t){var o;const{scales:n,columns:r,config:i,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=n,u=[],d=i.bins||20,h="horizontal"===c,f=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],r=t[t.length-1],i=(r-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/i),d-1)]++;const p=Math.max(...c,1),m=a(e.pieceData[0],e.name),y=e.width*f;let g="";if(h){const t=e.x+e.width;g=`M ${l(n)} ${t}`;for(let e=0;d>e;e++)g+=` L ${l(n+(e+.5)*i)} ${t-c[e]/p*y}`;g+=` L ${l(r)} ${t} Z`}else{const t=e.x;g=`M ${t} ${l(n)}`;for(let e=0;d>e;e++){const o=l(n+(e+.5)*i);g+=` L ${t+c[e]/p*y} ${o}`}g+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(n),l(r)),y:e.x,width:Math.abs(l(r)-l(n)),height:e.width}:{x:e.x,y:Math.min(l(r),l(n)),width:e.width,height:Math.abs(l(r)-l(n))};u.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:v,style:Object.assign(Object.assign({},m),{fillOpacity:null!==(o=m.fillOpacity)&&void 0!==o?o:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:o,columns:n,getRawRange:r,resolvePieceStyle:i}=e,{r:s,projection:a}=o,l=[],c="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const o=r(t);if(!o)continue;const[n,a]=o,u=i(t,e.name);if(c){const o=s(Math.min(n,a)),r=s(Math.max(n,a));l.push(j(o,e.x,r-o,e.width,u,t,e.name))}else{const o=s(Math.max(n,a)),r=s(Math.min(n,a));l.push(j(e.x,o,e.width,r-o,u,t,e.name))}}return l}};class le{constructor(e){this.rExtent=new E,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new A(e.windowSize),this.getO=C(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,o=e.rAccessor;Array.isArray(o)?(this.rAccessors=o.map(e=>_(e,"value")),this.getR=this.rAccessors[0],this.rExtents=o.map(()=>new E)):(this.getR=_(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||o,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=C(e.stackBy),this.getGroup=C(e.groupBy),this.getColor=C(e.colorAccessor),this.getConnector=C(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new A(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else for(const o of e.inserts){const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const r=o.toArray(),i=t.projection||"vertical",s=t.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=n.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=n.scaleLinear().domain(a).range([r,o])}else l?(u=n.scaleBand().domain(s).range([0,e.height]).padding(c),d=n.scaleLinear().domain(a).range([0,e.width])):(u=n.scaleBand().domain(s).range([0,e.width]).padding(c),d=n.scaleLinear().domain(a).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{const s=this.rExtents[i];s.dirty&&s.recalculate(o,r);let[a,c]=s.extent;a===1/0&&(a=0,c=1);const u=c-a,d=u>0?u*(t.extentPadding||.05):1;return a-=d,c+=d,a>0&&(a=0),l?n.scaleLinear().domain([a,c]).range([0,e.width]):n.scaleLinear().domain([a,c]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.flatMap(e=>this.rAccessors.map((t,o)=>Object.assign(Object.assign({},e),{__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(h,s,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),o=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===o)return t;if(!1===o)return t;if("function"==typeof o)return t.sort(o);const n=new Map;for(const t of e){const e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===o?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){var o,n;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let s=0,a=0;if("bar"===r&&this.getStack){const t=new Map,o=new Map;for(const n of e){const e=this.getO(n),r=this.getR(n);0>r?o.set(e,(o.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>a&&(a=e);for(const e of o.values())s>e&&(s=e)}else if("bar"===r){const t=new Map;for(const o of e){const e=this.getO(o),n=this.getR(o);t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>a&&(a=e),s>e&&(s=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>a&&(a=e),s>e&&(s=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(s=e),t!==-1/0&&(a=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(s=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(a=this.config.rExtent[1]));const l=a-s,c=l>0?l*i:1;return(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])||(s-=c),(null===(n=this.config.rExtent)||void 0===n?void 0:n[1])||(a+=c),"bar"!==r&&"clusterbar"!==r||(s>0&&(s=0),0>a&&(a=0)),[s,a]}buildColumns(e,t,o,n,r){var i;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===n)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==n){u=new Map;let e=0;for(const o of t){const t=a.get(o)||[];let n;n="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(o,n),e+=n}const i=("horizontal"===n?r.height:r.width)-o.padding()*o.step()*t.length;if(e>0)for(const[t,o]of u)u.set(t,o/e*i)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?n/l:0;let c,f;u?(c=h,f=u.get(e)||o.bandwidth(),h+=f+o.padding()*o.step()):(c=null!==(i=o(e))&&void 0!==i?i:0,f=o.bandwidth()),s[e]={name:e,x:c,y:0,width:f,middle:c+f/2,padding:o.padding()*o.step(),pieceData:t,pct:r,pctStart:d},d+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const o=this.getSceneContext(),n=ae[this.config.chartType];let r=n?n(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:n,getConnector:r,getO:i}=e;if(!r||!o)return[];const s=[],{projection:a}=o,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=r(t);if(!o)continue;let n,s;"point"===e.type?(n=e.x,s=e.y):(n=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),l.has(o)||l.set(o,[]),l.get(o).push({x:n,y:s,datum:t,category:i(t)})}const c=o.o.domain(),u=n.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let o=0;t.length-1>o;o++){const n=t[o],r=t[o+1],i="function"==typeof u?u(n.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:i,datum:n.datum,group:e})}}return s}(o,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],n=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,n),n}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var o,n,r;const i=this.config.decay;if(!i||1>=t)return 1;const s=null!==(o=i.minOpacity)&&void 0!==o?o:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(n=i.halfLife)&&void 0!==n?n:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;default:return 1}}applyDecay(e,t){var o,n;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,r),a=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var o,n;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(o=this.config.pulse.duration)&&void 0!==o?o:500,s=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=new Map;for(let e=0;t.length>e;e++)a.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=a.get(t.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const n=r-o;i>n&&(t._pulseIntensity=1-n/i,t._pulseColor=s)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let o=0;this.scene.length>o;o++){const n=this.scene[o];if("point"===n.type)this.prevPositionMap.set("p:"+o,{x:n.x,y:n.y,r:n.r});else if("rect"===n.type){const r=`r:${n.group||""}:${null!==(t=null===(e=n.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:o}`;this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h})}}}startTransition(){var e,t,o,n,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let a=null;if("point"===i.type?a="p:"+e:"rect"===i.type&&(a=`r:${i.group||""}:${null!==(o=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==o?o:e}`),!a)continue;const l=this.prevPositionMap.get(a);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,s=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(n=l.w)&&void 0!==n?n:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,s=!0)))}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,o,n;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(n=null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==n?n:0}`,r=this.prevPositionMap.get(t);if(!r)continue;e.x=r.x+(e._targetX-r.x)*i,e.y=r.y+(e._targetY-r.y)*i,void 0!==r.w&&(e.w=r.w+(e._targetW-r.w)*i,e.h=r.h+(e._targetH-r.h)*i)}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function ce(e,t,o){return e.x>t||t>e.x+e.w||e.y>o||o>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function ue(e,t,o){const n=t-e.x,r=o-e.y,i=Math.sqrt(n*n+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function de(e,t,o){const n=t-e.cx,r=o-e.cy,i=Math.sqrt(n*n+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;let s=Math.atan2(r,n);0>s&&(s+=2*Math.PI);let a=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>a&&(a+=2*Math.PI),0>l&&(l+=2*Math.PI),!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function he(e,t,o){const n=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-n>t||t>e.x+n||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category}}else{const r=e.y-n,i=e.y+n;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>o||o>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category}}return null}function fe(e,t,o){if(!e.bounds)return null;const{x:n,y:r,width:i,height:s}=e.bounds;return n>t||t>n+i||r>o||o>r+s?null:{datum:e.datum,x:n+i/2,y:r+s/2,distance:0,category:e.category}}function pe(e){return Math.round(100*e)/100+""}function me(t){const{width:o,height:n,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,oLabel:c,rLabel:u,oFormat:d,rFormat:h,showGrid:f,title:p,legend:m,foregroundGraphics:y,annotations:g,svgAnnotationRules:b,annotationFrame:x,children:k}=t,w="radial"===(null==a?void 0:a.projection),A="horizontal"===(null==a?void 0:a.projection),E=e.useMemo(()=>l&&a&&!w?a.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=a.o(e))&&void 0!==t?t:0)+a.o.bandwidth()/2,label:d?d(e):e}}):[],[l,a,d,w]),M=e.useMemo(()=>l&&a&&!w?a.r.ticks(5).map(e=>({value:e,pixel:a.r(e),label:(h||pe)(e)})):[],[l,a,h,w]),S=e.useMemo(()=>g&&0!==g.length&&b?g.map((e,t)=>b(e,t,{scales:a?{time:a.r,value:a.r}:null,timeAxis:"x",width:o,height:n})).filter(Boolean):null,[g,b,o,n,x]);return l||p||m||y||S&&S.length>0||f||k?v.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},v.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&a&&!w&&v.createElement("g",{className:"ordinal-grid"},M.map((e,t)=>v.createElement("line",{key:"grid-"+t,x1:A?e.pixel:0,y1:A?0:e.pixel,x2:A?e.pixel:o,y2:A?n:e.pixel,stroke:"#e0e0e0",strokeWidth:1}))),l&&a&&!w&&v.createElement("g",{className:"ordinal-axes"},A?v.createElement(v.Fragment,null,v.createElement("line",{x1:0,y1:0,x2:0,y2:n,stroke:"#ccc",strokeWidth:1}),E.map((e,t)=>v.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},v.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),c&&v.createElement("text",{x:15-s.left,y:n/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-s.left}, ${n/2})`,style:{userSelect:"none"}},c),v.createElement("line",{x1:0,y1:n,x2:o,y2:n,stroke:"#ccc",strokeWidth:1}),M.map((e,t)=>v.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${n})`},v.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),u&&v.createElement("text",{x:o/2,y:n+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},u)):v.createElement(v.Fragment,null,v.createElement("line",{x1:0,y1:n,x2:o,y2:n,stroke:"#ccc",strokeWidth:1}),E.map((e,t)=>v.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${n})`},v.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),c&&v.createElement("text",{x:o/2,y:n+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},c),v.createElement("line",{x1:0,y1:0,x2:0,y2:n,stroke:"#ccc",strokeWidth:1}),M.map((e,t)=>v.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},v.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),v.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},e.label))),u&&v.createElement("text",{x:15-s.left,y:n/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-s.left}, ${n/2})`,style:{userSelect:"none"}},u))),S,y,k),p&&v.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof p?p:null),m&&v.createElement("g",{transform:`translate(${r-s.right+10}, ${s.top})`},"object"==typeof(O=m)&&null!==O&&!v.isValidElement(O)&&"legendGroups"in O?v.createElement(I,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var O}const ye=(e,t,o,n)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},ge=(e,t,o,n)=>{var r,i;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine&&(e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8,e.beginPath(),e.moveTo(0,t.iqrLine.q1Pos),e.lineTo(0,t.iqrLine.q3Pos),e.stroke(),e.beginPath(),e.arc(0,t.iqrLine.medianPos,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1),e.restore()}},ve=(e,t,o,n)=>{var r,i,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=o.fillOpacity)&&void 0!==r?r:o.opacity)&&void 0!==i?i:.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=o.style.stroke||o.style.fill||"#999",e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=null!==(s=o.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},be=e=>[ve,...e],xe={bar:be([Z]),clusterbar:be([Z]),point:be([K]),swarm:be([K]),pie:[ye],donut:[ye],boxplot:be([(e,t,o,n)=>{var r,i;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const o=t.columnWidth/2,n="vertical"===t.projection,s=t.style.fill||"#007bff",a=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),n?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),n?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=c,e.fillStyle=s,n){const n=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,n,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-o,n,t.columnWidth,r)}else{const n=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(n,t.y-o,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(n,t.y-o,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),n?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},K]),violin:be([ge]),histogram:be([Z]),ridgeline:be([ge]),timeline:be([Z])},ke={top:50,right:40,bottom:60,left:70},we={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ae({hover:e}){var t,o,n,r;const i=e.data||{};if(Array.isArray(i)){const e=(null===(t=i[0])||void 0===t?void 0:t.category)||"",o=i.length;return v.createElement("div",{className:"semiotic-tooltip",style:we},e&&v.createElement("div",{style:{fontWeight:"bold"}},e+""),v.createElement("div",null,o," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return v.createElement("div",{className:"semiotic-tooltip",style:we},i.category&&v.createElement("div",{style:{fontWeight:"bold"}},i.category+""),v.createElement("div",null,"Count: ",i.count),2===e.length&&v.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const s=i.category||i.name||i.group||i.__rName||"",a=null!==(r=null!==(n=null!==(o=i.value)&&void 0!==o?o:i.__rValue)&&void 0!==n?n:i.pct)&&void 0!==r?r:"";if(!s&&""===a){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return v.createElement("div",{className:"semiotic-tooltip",style:we},e.map(([e,t])=>v.createElement("div",{key:e},v.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return v.createElement("div",{className:"semiotic-tooltip",style:we},s&&v.createElement("div",{style:{fontWeight:"bold"}},s+""),""!==a&&v.createElement("div",null,"number"==typeof a?a.toLocaleString():a+""))}const Ee=e.forwardRef(function(t,o){const{chartType:n,runtimeMode:r,data:i,oAccessor:s="category",rAccessor:a="value",colorAccessor:l,stackBy:c,groupBy:u,multiAxis:d,timeAccessor:h,valueAccessor:f,categoryAccessor:p,projection:m="vertical",size:y=[600,400],margin:g,barPadding:b,innerRadius:x,normalize:k,startAngle:A,dynamicColumnWidth:E,bins:M,showOutliers:S,showIQR:O,amplitude:P,connectorAccessor:j,connectorStyle:N,rExtent:_,oExtent:C,extentPadding:z=.05,oSort:$,windowMode:B="sliding",windowSize:L=200,pieceStyle:D,summaryStyle:T,colorScheme:W,barColors:R,showAxes:F=!0,oLabel:H,rLabel:I,oFormat:Y,rFormat:X,enableHover:G=!0,hoverAnnotation:q,tooltipContent:V,customHoverBehavior:U,annotations:K,svgAnnotationRules:Z,showGrid:J=!1,legend:Q,backgroundGraphics:ee,foregroundGraphics:te,title:oe,className:ne,background:re,centerContent:ie,decay:se,pulse:ae,transition:pe,staleness:ye}=t,ge=e.useMemo(()=>Object.assign(Object.assign({},ke),g),[g]),ve=y[0]-ge.left-ge.right,be=y[1]-ge.top-ge.bottom,we=e.useRef(null),Ee=e.useRef(!0),Me=e.useRef(0),Se=e.useRef(null),Oe=e.useRef(()=>{}),[Pe,je]=e.useState(null),[Ne,_e]=e.useState(null),[Ce,ze]=e.useState(0),[$e,Be]=e.useState(!1),Le=G||q,De="streaming"===r,Te=e.useMemo(()=>({chartType:n,runtimeMode:De?"streaming":"bounded",windowSize:L,windowMode:B,extentPadding:z,projection:m,oAccessor:De?void 0:s,rAccessor:De?void 0:a,colorAccessor:l,stackBy:c,groupBy:u,multiAxis:d,timeAccessor:De?h:void 0,valueAccessor:De?f||("string"==typeof a||"function"==typeof a?a:void 0):void 0,categoryAccessor:De?p||s:void 0,rExtent:_,oExtent:C,barPadding:b,innerRadius:x,normalize:k,startAngle:A,dynamicColumnWidth:E,bins:M,showOutliers:S,showIQR:O,amplitude:P,connectorAccessor:j,connectorStyle:N,oSort:$,pieceStyle:D,summaryStyle:T,colorScheme:W,barColors:R,decay:se,pulse:ae,transition:pe,staleness:ye}),[n,L,B,z,m,s,a,l,c,u,d,h,f,p,_,C,b,x,k,A,E,M,S,O,P,j,N,$,D,T,W,R,se,ae,pe,ye,De]),We=e.useRef(null);We.current||(We.current=new le(Te));const Re=e.useCallback(()=>{Me.current||(Me.current=requestAnimationFrame(()=>Oe.current()))},[]);e.useEffect(()=>{var e;null===(e=We.current)||void 0===e||e.updateConfig(Te),Ee.current=!0,Re()},[Te,Re]);const Fe=e.useRef(null);Fe.current||(Fe.current=new w(e=>{const t=We.current;t&&t.ingest(e)&&(Ee.current=!0,Re())}));const He=e.useCallback(e=>{var t;null===(t=Fe.current)||void 0===t||t.push(e)},[]),Ie=e.useCallback(e=>{var t;null===(t=Fe.current)||void 0===t||t.pushMany(e)},[]),Ye=e.useCallback(()=>{var e,t;null===(e=Fe.current)||void 0===e||e.clear(),null===(t=We.current)||void 0===t||t.clear(),Ee.current=!0,Re()},[Re]);e.useImperativeHandle(o,()=>({push:He,pushMany:Ie,clear:Ye,getData:()=>{var e,t;return null!==(t=null===(e=We.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=We.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[He,Ie,Ye]),e.useEffect(()=>{var e;i&&(null===(e=Fe.current)||void 0===e||e.setBoundedData(i))},[i]);const Xe=e.useRef(()=>{}),Ge=e.useRef(()=>{});Xe.current=e=>{if(!Le)return;const t=we.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ge.left,r=e.clientY-o.top-ge.top;if(0>n||n>ve||0>r||r>be)return void(Se.current&&(Se.current=null,je(null),U&&U(null),Re()));const i=We.current;if(!i||0===i.scene.length)return;const s="radial"===m,a=function(e,t,o,n=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=ce(i,t,o);break;case"point":e=ue(i,t,o);break;case"wedge":e=de(i,t,o);break;case"boxplot":e=he(i,t,o);break;case"violin":e=fe(i,t,o)}e&&n>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,s?n-ve/2:n,s?r-be/2:r);if(!a)return void(Se.current&&(Se.current=null,je(null),U&&U(null),Re()));const l={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};Se.current=l,je(l),U&&U(l),Re()},Ge.current=()=>{Se.current&&(Se.current=null,je(null),U&&U(null),Re())};const qe=e.useCallback(e=>Xe.current(e),[]),Ve=e.useCallback(()=>Ge.current(),[]);Oe.current=()=>{var e,t;Me.current=0;const o=we.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=We.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),a=i.advanceTransition(s),l=Ee.current;l&&!a&&(i.computeScene({width:ve,height:be}),Ee.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=y[0]*c,o.height=y[1]*c,o.style.width=y[0]+"px",o.style.height=y[1]+"px",r.scale(c,c),r.clearRect(0,0,y[0],y[1]);const u=null!==(e=null==ye?void 0:ye.threshold)&&void 0!==e?e:5e3,d=ye&&i.lastIngestTime>0&&s-i.lastIngestTime>u;d&&(r.globalAlpha=null!==(t=null==ye?void 0:ye.dimOpacity)&&void 0!==t?t:.5),re&&(r.fillStyle=re,r.fillRect(0,0,y[0],y[1]));const h="radial"===m;h?(r.save(),r.translate(ge.left+ve/2,ge.top+be/2)):r.translate(ge.left,ge.top);const f=xe[n]||[],p={width:ve,height:be};for(const e of f)e(r,i.scene,i.scales,p);h&&r.restore(),d&&(r.globalAlpha=1),l&&i.scales&&(_e(i.scales),ze(e=>e+1)),(null==ye?void 0:ye.showBadge)&&Be(!!d),(a||i.hasActivePulses)&&(Me.current=requestAnimationFrame(()=>Oe.current()))},e.useEffect(()=>(Re(),()=>{Me.current&&cancelAnimationFrame(Me.current)}),[Re]),e.useEffect(()=>{Ee.current=!0,Re()},[n,ve,be,F,re,Re]),e.useEffect(()=>{if(!ye)return;const e=setInterval(()=>{var e;const t=We.current;if(!t||0===t.lastIngestTime)return;const o="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=ye.threshold)&&void 0!==e?e:5e3,r=o-t.lastIngestTime>n;r!==$e&&(Be(r),Ee.current=!0,Re())},1e3);return()=>clearInterval(e)},[ye,$e,Re]);const Ue=Le&&Pe?V?V(Pe):v.createElement(Ae,{hover:Pe}):null,Ke="radial"===m,Ze=Pe?Ke?Pe.x+ve/2:Pe.x:0,Je=Pe?Ke?Pe.y+be/2:Pe.y:0,Qe=Ue?v.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:ge.left+Ze,top:ge.top+Je,transform:`translate(${Ze>.7*ve?"calc(-100% - 12px)":"12px"}, ${.3*be>Je?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Ue):null;return v.createElement("div",{className:"stream-ordinal-frame"+(ne?" "+ne:""),style:{position:"relative",width:y[0],height:y[1]},onMouseMove:Le?qe:void 0,onMouseLeave:Le?Ve:void 0},ee&&v.createElement("svg",{style:{position:"absolute",top:0,left:0,width:y[0],height:y[1],pointerEvents:"none"}},v.createElement("g",{transform:`translate(${ge.left},${ge.top})`},ee)),v.createElement("canvas",{ref:we,style:{position:"absolute",top:0,left:0,width:y[0],height:y[1]}}),v.createElement(me,{width:ve,height:be,totalWidth:y[0],totalHeight:y[1],margin:ge,scales:Ne,showAxes:F,oLabel:H,rLabel:I,oFormat:Y,rFormat:X,showGrid:J,title:oe,legend:Q,foregroundGraphics:te,annotations:K,svgAnnotationRules:Z,annotationFrame:Ce}),ie&&"radial"===m&&v.createElement("div",{style:{position:"absolute",left:ge.left+ve/2,top:ge.top+be/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ie),(null==ye?void 0:ye.showBadge)&&v.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ye.badgePosition?{top:4,left:4}:"bottom-left"===ye.badgePosition?{bottom:4,left:4}:"bottom-right"===ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:$e?"#dc3545":"#28a745",color:"white"})},$e?"STALE":"LIVE"),Qe)});Ee.displayName="StreamOrdinalFrame";const Me={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Se={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Oe{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 o=this.particles[t];if(!o.active)return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}return null}step(e,t,o){for(let n=0;this.capacity>n;n++){const r=this.particles[n];if(!r.active)continue;const i=o[r.edgeIndex];if(!i||!i.bezier){r.active=!1;continue}if(r.t+=e*t,r.t>=1){r.active=!1;continue}const s=Pe(i.bezier,r.t,r.offset);r.x=s.x,r.y=s.y}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].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 o=0;e>o;o++)this.particles[o]=t.length>o?t[o]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function Pe(e,t,o){if(e.circular&&e.segments)return function(e,t,o,n){const r=e.length,i=t*r,s=Math.min(Math.floor(i),r-1),a=i-s,[l,c,u,d]=e[s],h=je(l,c,u,d,a),f=d.x-l.x,p=d.y-l.y,m=Math.sqrt(f*f+p*p);if(m>.001){const e=f/m;h.x+=-p/m*o*n*2,h.y+=e*o*n*2}return h}(e.segments,t,o,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,r,i,s]=e.points,a=je(n,r,i,s,t),l=s.x-n.x,c=s.y-n.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;a.x+=-c/u*o*e.halfWidth*2,a.y+=t*o*e.halfWidth*2}return a}function je(e,t,o,n,r){const i=1-r,s=i*i,a=s*i,l=r*r,c=l*r;return{x:a*e.x+3*s*r*t.x+3*i*l*o.x+c*n.x,y:a*e.y+3*s*r*t.y+3*i*l*o.y+c*n.y}}const Ne=(e=1)=>(t,o)=>{const n=t[t.length-1];return n&&Math.round(n.x/e)===Math.round(o.x/e)&&Math.round(n.y/e)===Math.round(o.y/e)||t.push(o),t},_e=e=>{let t,o,n,r,s,a,l,c,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,s=e.source.y1,a=e.target.y0,l=i.interpolateNumber(s,a),c=l(.5),u=l(.5),`M${t},${s}C${t},${c} ${o},${u} ${o},${a}L${n},${a}C${n},${u} ${r},${c} ${r},${s}Z`):(t=e.source.x1,o=e.target.x0,l=i.interpolateNumber(t,o),n=l(.5),r=l(.5),s=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${s}C${n},${s} ${r},${a} ${o},${a}L${o},${c}C${r},${c} ${n},${u} ${t},${u}Z`)};function Ce(e){const t=function(){const e=l.line();let t=function(e){return e.x},o=function(e){return e.y},n=function(e){return e.r},r=l.curveLinearClosed;function i(i){if(i.multiple){const s=n,l=i.multiple.reduce((e,t)=>e+t.weight,0);n=()=>l;let c=a(i.points).filter(e=>"forward"===e.direction).reduce(Ne(),[]);const u=[];return i.multiple.forEach((e,t)=>{n=()=>e.weight;const o=a(c);u.push(o);const r=i.multiple[t+1];if(r){const e=o.reverse().filter(e=>"back"===e.direction).reduce(Ne(),[]);n=()=>r.weight;const t=a(e);c=t.reverse().filter(e=>"back"===e.direction).reduce(Ne(),[])}}),n=s,u.map(n=>e.x(t).y(o).curve(r)(n))}const s=a(i).reduce(Ne(),[]);return e.x(t).y(o).curve(r)(s)}return i.x=function(e){return arguments.length?(t=e,i):t},i.y=function(e){return arguments.length?(o=e,i):o},i.r=function(e){return arguments.length?(n=e,i):n},i.interpolate=function(e){return arguments.length?(r=e,i):r},i;function s(e){const r=o(e.target)-o(e.source),i=t(e.target)-t(e.source),s=Math.atan2(i,r)+Math.PI/2,a=s+.5*Math.PI,l=s+.5*Math.PI;return{x1:t(e.source)+n(e.source)*Math.cos(a),y1:o(e.source)-n(e.source)*Math.sin(a),x2:t(e.target)+n(e.target)*Math.cos(l),y2:o(e.target)-n(e.target)*Math.sin(l)}}function a(e){const t=[];let o=0,n={x1:0,y1:0,x2:0,y2:0};for(;e.length>o;){if(o!==e.length-1&&(n=s({source:e[o],target:e[o+1]}),t.push({x:n.x1,y:n.y1,direction:"forward"},{x:n.x2,y:n.y2,direction:"forward"}),t.length>3)){const e=t.length-1,o={a:t[e-3],b:t[e-2]},n={a:t[e-1],b:t[e]},r=c(o.a.x,o.a.y,o.b.x,o.b.y,n.a.x,n.a.y,n.b.x,n.b.y);!0===r.found&&(o.b.x=r.x,o.b.y=r.y,n.a.x=r.x,n.a.y=r.y)}o++}for(o--;o>=0;){if(0!==o&&(n=s({source:e[o],target:e[o-1]}),t.push({x:n.x1,y:n.y1,direction:"back"},{x:n.x2,y:n.y2,direction:"back"}),t.length>3)){const e=t.length-1,o={a:t[e-3],b:t[e-2]},n={a:t[e-1],b:t[e]},r=c(o.a.x,o.a.y,o.b.x,o.b.y,n.a.x,n.a.y,n.b.x,n.b.y);!0===r.found&&(o.b.x=r.x,o.b.y=r.y,n.a.x=r.x,n.a.y=r.y)}o--}return t}function c(e,t,o,n,r,i,s,a){let l,c;const u={x:null,y:null,found:!1},d=(a-i)*(o-e)-(s-r)*(n-t);if(0===d)return u;l=t-i,c=e-r;const h=(o-e)*l-(n-t)*c;return l=((s-r)*l-(a-i)*c)/d,c=h/d,u.x=e+l*(o-e),u.y=t+l*(n-t),l>0&&1>l&&c>0&&1>c&&(u.found=!0),u}}();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 ze={left:s.sankeyLeft,right:s.sankeyRight,center:s.sankeyCenter,justify:s.sankeyJustify},$e={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var r,i,a,l;if(0===e.length)return;const c="vertical"===o.orientation?"down":"right",u=o.nodeAlign||"justify",d=null!==(r=o.nodeWidth)&&void 0!==r?r:15,h=null!==(i=o.nodePaddingRatio)&&void 0!==i?i:.05,f=null!==(a=o.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=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 y;y="down"===c?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const g=s.sankeyCircular().extent(y).links(m).nodes(p).nodeAlign(ze[u]||s.sankeyJustify).nodeId(e=>e.id).nodeWidth(d).iterations(f);g.nodePaddingRatio&&g.nodePaddingRatio(h),g();for(const t of p){const o=e.find(e=>e.id===t.id);o&&(o.x0=t.x0,o.x1=t.x1,o.y0=t.y0,o.y1=t.y1,o.value=t.value,o.depth=t.depth,o.sourceLinks=t.sourceLinks,o.targetLinks=t.targetLinks,o.width=t.x1-t.x0,o.height=t.y1-t.y0,o.x=t.x0+(t.x1-t.x0)/2,o.y=t.y0+(t.y1-t.y0)/2)}for(const o of m){const n=o.source,r=o.target,i="object"==typeof n&&null!==n?n.id:n+"",s="object"==typeof r&&null!==r?r.id:r+"",a=t.find(e=>("string"==typeof e.source?e.source:e.source.id)===i&&("string"==typeof e.target?e.target:e.target.id)===s);if(a){a.y0=o.y0,a.y1=o.y1,a.sankeyWidth=null!==(l=o.width)&&void 0!==l?l:0,a.circular=!!o.circular,a.circularPathData=o.circularPathData,a.direction=c;const t=e.find(e=>e.id===i),n=e.find(e=>e.id===s);t&&(a.source=t),n&&(a.target=n)}}},buildScene(e,t,o,n){var r,i;const s="vertical"===o.orientation?"down":"right",l=o.nodeStyle,c=o.edgeStyle,u=null!==(r=o.edgeOpacity)&&void 0!==r?r:.5,d=o.edgeColorBy||"source",h=Array.isArray(o.colorScheme)?o.colorScheme:a.schemeCategory10,f=new Map;e.forEach((e,t)=>{f.set(e.id,h[t%h.length])});const p=[],m=[],y=[];for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const n=l?l(t):{},r={fill:n.fill||f.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:o,style:r,datum:t,id:t.id,label:t.id})}const g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of g){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let n;n=e.circular&&e.circularPathData?Ce(e):_e(e);let r="#999";c?r=c(e).fill||r:"target"===d&&o?r=f.get(o.id)||r:t&&(r=f.get(t.id)||r);const s=c?c(e):{},a={fill:r,fillOpacity:null!==(i=s.fillOpacity)&&void 0!==i?i:u,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};m.push({type:"bezier",pathD:n,bezierCache:e.bezier,style:a,datum:e})}if(!1!==o.showLabels){const t=(v=o.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;const i=t?t(o):o.id;if(!i)continue;let a,l,c;"down"===s?(a=o.x0+e/2,l=o.y1+14,c="middle"):(n[0]/2>o.x0+e/2?(a=o.x0-6,c="end"):(a=o.x1+6,c="start"),l=o.y0+r/2),y.push({x:a,y:l,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var v;return{sceneNodes:p,sceneEdges:m,labels:y}}},Be={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){var r,i;if(0===e.length)return;const s=null!==(r=o.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),a=null!==(i=o.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const o=e[t];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;o.x=l+e*Math.cos(n),o.y=u+e*Math.sin(n)}}const d=De(o.nodeSize,o.nodeSizeRange,e),h=c.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*a:a)).id(e=>e.id),f=n[1]/n[0],p=c.forceSimulation().force("charge",c.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",c.forceX(n[0]/2).strength(.1*f)).force("y",c.forceY(n[1]/2).strength(.1));if(p.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}));p.force("link",h),p.force("link").links(e)}.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;s>e;++e)p.tick();for(const o of t){if("string"==typeof o.source){const t=e.find(e=>e.id===o.source);t&&(o.source=t)}if("string"==typeof o.target){const t=e.find(e=>e.id===o.target);t&&(o.target=t)}}},buildScene(e,t,o,n){var r,i,s;const l=o.nodeStyle,c=o.edgeStyle,u=De(o.nodeSize,o.nodeSizeRange,e),d=Array.isArray(o.colorScheme)?o.colorScheme:a.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],p=[],m=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),o=l?l(t):{},n={fill:o.fill||h.get(t.id)||"#007bff",stroke:o.stroke||"#fff",strokeWidth:null!==(r=o.strokeWidth)&&void 0!==r?r:2,opacity:o.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}for(const o of t){const t="object"==typeof o.source?o.source:Le(e,o.source),n="object"==typeof o.target?o.target:Le(e,o.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(o):{},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};p.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:a,datum:o})}if(!1!==o.showLabels){const t=(y=o.nodeLabel)?"function"==typeof y?y:e=>e[y]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=u(o);m.push({x:o.x,y:o.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var y;return{sceneNodes:f,sceneEdges:p,labels:m}}};function Le(e,t){return e.find(e=>e.id===t)}function De(e,t,o){var i,s;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=o.map(t=>{var o;return null===(o=t.data)||void 0===o?void 0:o[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>a[0];const c=null!==(i=r.min(l))&&void 0!==i?i:0,u=null!==(s=r.max(l))&&void 0!==s?s:1;if(c===u)return()=>(a[0]+a[1])/2;const d=n.scaleLinear().domain([c,u]).range(a).clamp(!0);return t=>{var o;const n=null===(o=t.data)||void 0===o?void 0:o[e];return null==n||"number"!=typeof n?a[0]:d(n)}}const Te=a.schemeCategory10,We={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:s}=o,a=Math.min(n[0],n[1])/2,c=a-i,d=n[0]/2,h=n[1]/2,f=(p=o.valueAccessor)?"function"==typeof p?p:e=>{var t;return null!==(t=e[p])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var p;const m=new Map;for(let t=0;e.length>t;t++)m.set(e[t].id,t);const y=e.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=m.get("string"==typeof e.source?e.source:e.source.id),n=m.get(t);if(void 0===o||void 0===n)continue;const r=f(e);g[o][n]=r}const v=u.chord().padAngle(r);s&&v.sortGroups(s);const b=v(g),x=b.groups,k=l.arc().innerRadius(c).outerRadius(a);for(const t of x){const o=e[t.index],n=k.centroid(t);o.x=n[0]+d,o.y=n[1]+h,o.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,n="string"==typeof o.target?o.target:o.target.id,r=e.find(e=>e.id===t),i=e.find(e=>e.id===n);r&&(o.source=r),i&&(o.target=i)}for(const o of b){const n=e[o.source.index].id,r=e[o.target.index].id,i=t.find(e=>{const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id;return t===n&&o===r||t===r&&o===n});i&&(i.chordData=o)}},buildScene(e,t,o,n){var r,i;const{groupWidth:s=20,edgeOpacity:a=.5}=o,l=Math.min(n[0],n[1])/2,c=l-s,d=n[0]/2,h=n[1]/2,f=o.nodeStyle,p=o.edgeStyle,m=o.edgeColorBy||"source",y=Array.isArray(o.colorScheme)?o.colorScheme:Te,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const v=u.ribbon().radius(c),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const o=e[t],n=o.arcData;if(!n)continue;let i;i=f?f(o).fill||g.get(o.id)||y[t%y.length]:g.get(o.id)||y[t%y.length];const s=f?f(o):{},a={fill:i,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};b.push({type:"arc",cx:d,cy:h,innerR:c,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.chordData;if(!t)continue;const o=v({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(!o)continue;const n=Re(o,d,h);let r="#999";if(p)r=p(e).fill||r;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===m&&o?r=g.get(o.id)||r:t&&(r=g.get(t.id)||r)}const s=p?p(e):{},l={fill:r,fillOpacity:null!==(i=s.fillOpacity)&&void 0!==i?i:a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};x.push({type:"ribbon",pathD:n,style:l,datum:e})}if(!1!==o.showLabels){const t=(w=o.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=l+12;for(const o of e){const e=o.arcData;if(!e)continue;const r=t?t(o):o.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;k.push({x:d+Math.cos(s)*n,y:h+Math.sin(s)*n,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function Re(e,t,o){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const r=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(r.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)r.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(r.push(Number(n[i])+o+""),i++);else if("C"===e)for(r.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)r.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(r.push(Number(n[i])+o+""),i++);else if("Q"===e)for(r.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)r.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(r.push(Number(n[i])+o+""),i++);else if("A"===e)for(r.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)r.push(n[i++]),n.length>i&&r.push(n[i++]),n.length>i&&r.push(n[i++]),n.length>i&&r.push(n[i++]),n.length>i&&r.push(n[i++]),n.length>i&&(r.push(Number(n[i])+t+""),i++),n.length>i&&(r.push(Number(n[i])+o+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(n[i]),i++)}return r.join(" ")}const Fe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,n){var r;const i=o.__hierarchyRoot;if(!i)return;const s=o.chartType,a=(l=o.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const c=o.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=d.hierarchy(i,a);u.sum(c),u.sort((e,t)=>{var o,n;return(null!==(o=t.value)&&void 0!==o?o:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(s){case"tree":!function(e,t,o,n){const r=t.treeOrientation||"vertical",i=d.tree();i.size("horizontal"===r?[n,o]:"radial"===r?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),i(e)}(u,o,h,f);break;case"cluster":!function(e,t,o,n){const r=t.treeOrientation||"vertical",i=d.cluster();i.size("horizontal"===r?[n,o]:"radial"===r?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),i(e)}(u,o,h,f);break;case"treemap":!function(e,t,o,n){var r,i;const s=null!==(r=t.padding)&&void 0!==r?r:4,a=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=d.treemap().size([o,n]).tile(d.treemapBinary).padding(s);a>0&&l.paddingTop(a),l(e)}(u,o,h,f);break;case"circlepack":!function(e,t,o,n){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;d.pack().size([o,n]).padding(i)(e)}(u,o,h,f);break;case"partition":!function(e,t,o,n){var r;d.partition().size([o,n]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,o,h,f)}const p=u.descendants();e.length=0,t.length=0;const m=new Map;for(let t=0;p.length>t;t++){const n=p[t],i={id:Ge(n,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=n.value)&&void 0!==r?r:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?He(i,n,o):"treemap"===s||"partition"===s?Ie(i,n):"circlepack"===s&&Ye(i,n),i.__hierarchyNode=n,e.push(i),m.set(n,i)}if("tree"===s||"cluster"===s)for(const e of p)if(e.parent){const o=m.get(e.parent),n=m.get(e);o&&n&&t.push({source:o,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,n){const r=o.nodeStyle||(()=>({})),i=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,n,r,i){var s,a,l,c,u;const d=[],h=[],f=[],p=o.treeOrientation||"vertical",m="radial"===p,y=n[0]/2,g=n[1]/2,v="number"==typeof(b=o.nodeSize)?b:5;var b;for(const t of e){let e=t.x,o=t.y;m&&(e+=y,o+=g);const n=r(t),i={fill:n.fill||"#4d430c",stroke:n.stroke||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:n.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:i,datum:t,id:t.id,label:t.id,depth:t.depth})}const x=null!==(a=o.edgeOpacity)&&void 0!==a?a:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let n=t.x,r=t.y,s=o.x,a=o.y;m&&(n+=y,r+=g,s+=y,a+=g);const u=Xe(n,r,s,a,p),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:x};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==o.showLabels){const t=qe(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let n,r,i,s=o.x,a=o.y;if(m&&(s+=y,a+=g),m){const e=s-y,t=a-g,o=Math.sqrt(e*e+t*t);o>0?(n=s+e/o*10,r=a+t/o*10,i=0>e?"end":"start"):(n=s,r=a-12,i="middle")}else"horizontal"===p?((null===(u=o.data)||void 0===u?void 0:u.children)&&0!==o.data.children.length?(n=s-v-6,i="end"):(n=s+v+6,i="start"),r=a):(n=s,r=a+v+14,i="middle");f.push({x:n,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,o,n,r,i);case"treemap":case"partition":return function(e,t,o,n){var r,i;const s=[],a=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const a=n(o);let c=a.fill||"#4d430c";t.colorByDepth&&void 0!==o.depth&&(c=l[o.depth%l.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};s.push({type:"rect",x:o.x0,y:o.y0,w:e,h:i,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=qe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;if((null===(i=n.data)||void 0===i?void 0:i.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const s=o?o(n):n.id;s&&(30>e||16>r||a.push({x:n.x0+e/2,y:n.y0+r/2,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:s,sceneEdges:[],labels:a}}(e,o,0,r);case"circlepack":return function(e,t,o,n){var r,i,s,a,l;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const o of e){const e=null!==(r=o.__radius)&&void 0!==r?r:5;if(0>=e)continue;const a=n(o);let l=a.fill||"#4d430c";t.colorByDepth&&void 0!==o.depth&&(l=d[o.depth%d.length]);const u={fill:l,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};c.push({type:"circle",cx:o.x,cy:o.y,r:e,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=qe(t.nodeLabel);for(const t of e){const e=null!==(a=t.__radius)&&void 0!==a?a:5,n=o?o(t):t.id;if(!n)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);u.push({x:t.x,y:r?t.y:t.y-e+14,text:n+"",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:u}}(e,o,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function He(e,t,o){const n=o.treeOrientation||"vertical";if("radial"===n){const o=t.x,n=t.y;e.x=n*Math.cos(o-Math.PI/2),e.y=n*Math.sin(o-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 Ie(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 Ye(e,t){var o;const n=null!==(o=t.r)&&void 0!==o?o: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 Xe(e,t,o,n,r){if("horizontal"===r){const r=(e+o)/2;return`M ${e},${t} C ${r},${t} ${r},${n} ${o},${n}`}if("radial"===r){const r=(e+o)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+n)/2} T ${o},${n}`}{const r=(t+n)/2;return`M ${e},${t} C ${e},${r} ${o},${r} ${o},${n}`}}function Ge(e,t,o){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-"+o}function qe(e){return e?"function"==typeof e?e:t=>{var o;return(null===(o=t.data)||void 0===o?void 0:o[e])||t[e]||t.id}:null}const Ve={sankey:$e,force:Be,chord:We,tree:Fe,cluster:Fe,treemap:Fe,circlepack:Fe,partition:Fe};function Ue(e){return Ve[e]}class Ke{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({},Me),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Oe(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},Me),e.tensionConfig),"sankey"===e.chartType&&e.showParticles?this.particlePool||(this.particlePool=new Oe(2e3)):this.particlePool=null}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,o){const{nodeIDAccessor:n="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:s="value"}=this.config,a="function"==typeof n?n:e=>e[n],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Ze(e)),{data:t}))}for(const e of t){const t=l(e)+"",o=c(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Ze(t)),{data:e})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Ze(o)),{data:e})),this.edges.set(`${t}\0${o}`,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(o)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:n}=e,r=0===this.nodes.size;let i=!1;this.nodes.has(t)||(this.nodes.set(t,Ze(t)),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(o)||(this.nodes.set(o,Ze(o)),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,o),a=this.edges.get(s);return a?(a.value+=n,this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0}),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Ue(this.config.chartType);if(!t)return;let o=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0!==o.length||t.hierarchical){if(this.prepareForRelayout(),t.computeLayout(o,n,this.config,e),t.hierarchical&&o.length>0){this.nodes.clear(),this.edges.clear();for(const e of o)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(),o.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=Ue(this.config.chartType);if(!t)return;const o=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:s}=t.buildScene(o,n,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=s}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),o=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)*o,e.x1=e._prevX1+(e._targetX1-e._prevX1)*o,e.y0=e._prevY0+(e._targetY0-e._prevY0)*o,e.y1=e._prevY1+(e._targetY1-e._prevY1)*o);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)*o,e.y1=e._prevY1+(e._targetY1-e._prevY1)*o,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*o);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,o="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&o&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,o))}buildStandardBezier(e,t,o){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,s=o.y0,a=i.interpolateNumber(r,s);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:s}],halfWidth:n}}const r=t.x1,s=o.x0,a=i.interpolateNumber(r,s);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:s,y:e.y1}],halfWidth:n}}buildCircularBezier(e){const t=(e.sankeyWidth||1)/2,o=e.circularPathData;let n;n="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.leftFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.targetY,y:o.rightFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.leftFullExtent,y:o.sourceY},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.rightFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const r=[];for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1],i=o.x-t.x,s=o.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},o])}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 Ze(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 Je(e,t,o){switch(e.type){case"circle":return function(e,t,o){const n=t-e.cx,r=o-e.cy,i=Math.sqrt(n*n+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,o);case"rect":return function(e,t,o){return e.x>t||t>e.x+e.w||e.y>o||o>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,o);case"arc":return function(e,t,o){const n=t-e.cx,r=o-e.cy,i=Math.sqrt(n*n+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;let s=Math.atan2(r,n);0>s&&(s+=2*Math.PI);let a,l=e.startAngle,c=e.endAngle;if(0>l&&(l+=2*Math.PI),0>c&&(c+=2*Math.PI),a=l>c?s>=l||c>=s:s>=l&&c>=s,a){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);default:return null}}function Qe(e,t,o){switch(e.type){case"bezier":return function(e,t,o){var n,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),s=document.createElement("canvas").getContext("2d");if(!s)return null;if(s.isPointInPath(i,t,o)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,s="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&s?(i.x1+s.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:o,distance:0}}}catch(e){}return null}(e,t,o);case"line":return function(e,t,o){const n=e.x2-e.x1,r=e.y2-e.y1,i=n*n+r*r;if(0===i)return null;let s=((t-e.x1)*n+(o-e.y1)*r)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*n,l=e.y1+s*r,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(o-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),r=document.createElement("canvas").getContext("2d");if(!r)return null;if(r.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0}}catch(e){}return null}(e,t,o);default:return null}}function et(e){const{width:t,height:o,totalWidth:n,totalHeight:r,margin:i,labels:s,title:a,legend:l,foregroundGraphics:c,annotations:u,svgAnnotationRules:d}=e;return v.createElement("svg",{width:n,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},v.createElement("g",{transform:`translate(${i.left},${i.top})`},s.map((e,t)=>v.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)),u&&d&&u.map((e,n)=>{const r=d(e,n,{width:t,height:o});return r?v.createElement(v.Fragment,{key:"annotation-"+n},r):null}),c),a&&"string"==typeof a?v.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?v.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},a):null,l&&"object"==typeof l&&"legendGroups"in l?v.createElement("g",{transform:`translate(${n-i.right+10},${i.top})`},l.legendGroups.map((e,t)=>{var o;return v.createElement("g",{key:"legend-group-"+t},null===(o=e.items)||void 0===o?void 0:o.map((e,t)=>v.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},v.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),v.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):l?v.createElement("g",{transform:`translate(${n-i.right+10},${i.top})`},l):null)}function tt(e,t){var o,n,r,i;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),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!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(s)),e.restore()}function ot(e,t){var o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o: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 nt(e,t){var o,n,r,i;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),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!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(s)),e.restore()}function rt(e,t){var o,n;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o: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!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(r)),e.restore()}et.displayName="NetworkSVGOverlay";const it={category10:a.schemeCategory10,tableau10:a.schemeTableau10,set3:a.schemeSet3,blues:a.interpolateBlues,reds:a.interpolateReds,greens:a.interpolateGreens,oranges:a.interpolateOranges,purples:a.interpolatePurples,viridis:a.interpolateViridis,plasma:a.interpolatePlasma},st=a.schemeCategory10;function at(e,t,o){if("function"==typeof t)return t(e);const n=e[t];return o?o(n):st[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(n+""))%st.length]}function lt(e,t,o="category10"){const r=Array.from(new Set(e.map(e=>e[t]))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(o))return n.scaleOrdinal().domain(r).range(o).unknown("#999");const s=it[o]||it.category10;if(i&&"function"==typeof s)return e=>s(Number(e)/Math.max(...r.map(Number)));{const e=Array.isArray(s)?s:st;return n.scaleOrdinal().domain(r).range(e).unknown("#999")}}function ct(e,t,o=[3,20],n){let r;if(r="function"==typeof t?t(e):e[t],!n)return r;const[i,s]=n,[a,l]=o;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}const ut={top:20,right:80,bottom:20,left:80},dt={top:40,right:40,bottom:40,left:40},ht=new Set(["chord","force","circlepack"]),ft=[800,600],pt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function mt({data:e}){var t,o,n,r,i,s;if("edge"===e.type){const t=e.data;return v.createElement("div",{className:"semiotic-tooltip",style:pt},v.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&&v.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const a=e.data,l=null==a?void 0:a.__hierarchyNode;if(l){const e=[];let i=l;for(;i;){const s=null!==(r=null!==(o=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==o?o:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==r?r:a.id;null!=s&&e.unshift(s+""),i=i.parent}e.length>1&&e.shift();const s=e.length-1;return v.createElement("div",{className:"semiotic-tooltip",style:pt},v.createElement("div",null,e.map((e,t)=>v.createElement("span",{key:t},t>0&&v.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===s?v.createElement("strong",null,e):v.createElement("span",{style:{opacity:.7}},e)))),null!=a.value&&a.value>0&&v.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(i=a.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(s=a.targetLinks)||void 0===s?void 0:s.length)||0),u=(a.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(a.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return v.createElement("div",{className:"semiotic-tooltip",style:pt},v.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&v.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&v.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const yt=e.forwardRef(function(t,o){const{chartType:n,nodes:r,edges:i,data:s,initialEdges:a,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",childrenAccessor:h,hierarchySum:f,orientation:p="horizontal",nodeAlign:m="justify",nodePaddingRatio:y=.05,nodeWidth:g=15,iterations:b=300,forceStrength:x=.1,padAngle:k=.01,groupWidth:w=20,sortGroups:A,edgeSort:E,treeOrientation:M="vertical",edgeType:S="curve",padding:O,paddingTop:P,tensionConfig:j,showParticles:N=!1,particleStyle:_,nodeStyle:C,edgeStyle:z,colorBy:$,colorScheme:B="category10",edgeColorBy:L="source",edgeOpacity:D=.5,colorByDepth:T=!1,nodeSize:W=8,nodeSizeRange:R=[5,20],nodeLabel:F,showLabels:H=!0,size:I=ft,margin:Y,className:X,background:G,enableHover:q=!0,tooltipContent:V,onTopologyChange:U,annotations:K,svgAnnotationRules:Z,legend:J,title:Q,foregroundGraphics:ee,backgroundGraphics:te}=t,oe=ht.has(n)?dt:ut,ne=Object.assign(Object.assign({},oe),Y),re=I[0]-ne.left-ne.right,ie=I[1]-ne.top-ne.bottom,se=e.useMemo(()=>Object.assign(Object.assign({},Me),j),[j]),ae=e.useMemo(()=>Object.assign(Object.assign({},Se),_),[_]),le=e.useMemo(()=>({chartType:n,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,valueAccessor:d,childrenAccessor:h,hierarchySum:f,orientation:p,nodeAlign:m,nodePaddingRatio:y,nodeWidth:g,iterations:b,forceStrength:x,padAngle:k,groupWidth:w,sortGroups:A,edgeSort:E,treeOrientation:M,edgeType:S,padding:O,paddingTop:P,tensionConfig:se,showParticles:N,particleStyle:ae,nodeStyle:C,edgeStyle:z,nodeLabel:F,showLabels:H,colorBy:$,colorScheme:B,edgeColorBy:L,edgeOpacity:D,colorByDepth:T,nodeSize:W,nodeSizeRange:R}),[n,l,c,u,d,h,f,p,m,y,g,b,x,k,w,A,E,M,S,O,P,se,N,ae,C,z,F,H,$,B,L,D,T,W,R]),ce=e.useRef(null),ue=e.useRef(0),de=e.useRef(0),he=e.useRef(!0),fe=e.useRef(()=>{}),pe=e.useRef(null);pe.current||(pe.current=new Ke(le));const[me,ye]=e.useState(null),[ge,ve]=e.useState(0),[be,xe]=e.useState(0),ke=e.useRef(null),we=e.useRef(new Map),Ae=e.useRef(0),Ee=e.useCallback(e=>{if("function"==typeof $)return $(e);if("string"==typeof $&&e.data){const t=e.data[$];if(void 0!==t){if(!we.current.has(t+"")){const e=Array.isArray(B)?B:st;we.current.set(t+"",e[Ae.current++%e.length])}return we.current.get(t+"")}}if(!we.current.has(e.id)){const t=Array.isArray(B)?B:st;we.current.set(e.id,t[Ae.current++%t.length])}return we.current.get(e.id)},[$,B]);e.useCallback(e=>{if("function"==typeof L)return L(e);const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===L&&o?Ee(o):t?Ee(t):"#999"},[L,Ee]);const Oe=e.useCallback(e=>{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===(ae.colorBy||"source")&&o?Ee(o):t?Ee(t):"#999"},[ae.colorBy,Ee]),Pe="sankey"===n&&N,je=e.useCallback(()=>{ue.current&&!Pe||ue.current||(ue.current=requestAnimationFrame(()=>fe.current()))},[Pe]);e.useEffect(()=>{var e;null===(e=pe.current)||void 0===e||e.updateConfig(le),he.current=!0,je()},[le,je]);const Ne=e.useCallback(()=>{const e=pe.current;if(e&&(e.runLayout([re,ie]),e.buildScene([re,ie]),he.current=!0,ve(e.layoutVersion),U)){const{nodes:t,edges:o}=e.getLayoutData();U(t,o)}},[re,ie,U]),_e=e.useCallback(e=>{const t=pe.current;t&&(t.ingestEdge(e)&&Ne(),je())},[Ne,je]),Ce=e.useCallback(e=>{const t=pe.current;if(!t)return;let o=!1;for(const n of e)t.ingestEdge(n)&&(o=!0);o&&Ne(),je()},[Ne,je]),ze=e.useCallback(()=>{var e;null===(e=pe.current)||void 0===e||e.clear(),we.current.clear(),Ae.current=0,ve(0),ye(null),ke.current=null,he.current=!0,je()},[je]),$e=e.useCallback(()=>{const e=pe.current;e&&(e.tension+=999,Ne(),je())},[Ne,je]);e.useImperativeHandle(o,()=>({push:_e,pushMany:Ce,clear:ze,getTopology:()=>{var e,t;return null!==(t=null===(e=pe.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},relayout:$e,getTension:()=>{var e,t;return null!==(t=null===(e=pe.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[_e,Ce,ze,$e]);const Be=["tree","cluster","treemap","circlepack","partition"].includes(n),Le=Be?s||(Array.isArray(i)?void 0:i):void 0;e.useEffect(()=>{const e=pe.current;if(e)if(Be&&Le)e.ingestHierarchy(Le,[re,ie]),e.buildScene([re,ie]),he.current=!0,je();else{const t=r||[],o=Array.isArray(i)?i:[];if(0===t.length&&0===o.length)return;e.ingestBounded(t,o,[re,ie]),e.buildScene([re,ie]),he.current=!0,je()}},[r,i,s,Le,Be,re,ie,le,je]),e.useEffect(()=>{a&&a.length>0&&Ce(a)},[]);const De=e.useRef(()=>{}),Te=e.useRef(()=>{});De.current=e=>{if(!q)return;const t=ce.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ne.left,r=e.clientY-o.top-ne.top;if(0>n||n>re||0>r||r>ie)return void(ke.current&&(ke.current=null,ye(null),je()));const i=pe.current;if(!i)return;const s=function(e,t,o,n,r=30){let i=null,s=r,a=1/0;for(const t of e){const e=Je(t,o,n);if(e)if("rect"===t.type){const o=t.w*t.h;a>o&&(i=e,a=o)}else s>e.distance&&(i=e,s=e.distance)}if(i)return i;for(const e of t){const t=Qe(e,o,n);t&&s>t.distance&&(i=t,s=t.distance)}return i}(i.sceneNodes,i.sceneEdges,n,r);if(!s)return void(ke.current&&(ke.current=null,ye(null),je()));const a={type:s.type,data:s.datum,x:s.x,y:s.y};ke.current=a,ye(a),je()},Te.current=()=>{ke.current&&(ke.current=null,ye(null),je())};const We=e.useCallback(e=>De.current(e),[]),Re=e.useCallback(()=>Te.current(),[]);fe.current=()=>{var e;ue.current=0;const t=ce.current;if(!t)return;const o=t.getContext("2d");if(!o)return;const n=pe.current;if(!n)return;const r=performance.now(),i=de.current?Math.min((r-de.current)/1e3,.1):.016;de.current=r;const s=n.advanceTransition(r);(s||he.current)&&n.buildScene([re,ie]);const a="undefined"!=typeof window&&window.devicePixelRatio||1;if(t.width=I[0]*a,t.height=I[1]*a,t.style.width=I[0]+"px",t.style.height=I[1]+"px",o.scale(a,a),o.translate(ne.left,ne.top),o.clearRect(-ne.left,-ne.top,I[0],I[1]),G&&(o.fillStyle=G,o.fillRect(0,0,re,ie)),function(e,t){for(const o of t)switch(o.type){case"bezier":tt(e,o);break;case"line":ot(e,o);break;case"ribbon":nt(e,o);break;case"curved":rt(e,o)}}(o,n.sceneEdges),function(e,t){var o,n,r;for(const i of t){if("rect"!==i.type)continue;const t=i;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!==(o=t.style.opacity)&&void 0!==o?o: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!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),e.restore())}}(o,n.sceneNodes),function(e,t){var o,n,r;for(const i of t){if("circle"!==i.type)continue;const t=i;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!==(o=t.style.opacity)&&void 0!==o?o: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!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore())}}(o,n.sceneNodes),function(e,t){var o,n,r;for(const i of t){if("arc"!==i.type)continue;const t=i;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!==(o=t.style.opacity)&&void 0!==o?o: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!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(o,n.sceneNodes),N&&n.particlePool){const t=Array.from(n.edges.values());if(t.length>0){!function(e,t,o,n){var r,i;const s=null!==(r=n.spawnRate)&&void 0!==r?r:Se.spawnRate,a=null!==(i=n.maxPerEdge)&&void 0!==i?i:Se.maxPerEdge;for(let n=0;t.length>n;n++){const r=t[n];if(!r.bezier)continue;if(e.countForEdge(n)>=a)continue;const i=r.value*s*o,l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<a;t++)e.spawn(n)}}(n.particlePool,t,i,ae);const r=.5*(null!==(e=ae.speedMultiplier)&&void 0!==e?e:1);n.particlePool.step(i,r,t),function(e,t,o,n,r){var i,s;const a=null!==(i=n.radius)&&void 0!==i?i:Se.radius,l=null!==(s=n.opacity)&&void 0!==s?s:Se.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const s=t.particles[i];if(!s.active)continue;const l=o[s.edgeIndex];if(l){if("function"==typeof n.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?n.color(l,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:r(l);e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,n.particlePool,t,ae,Oe)}}const l=he.current;he.current=!1,(l||s)&&xe(e=>e+1),(Pe||s)&&(ue.current=requestAnimationFrame(()=>fe.current()))},e.useEffect(()=>(je(),()=>{ue.current&&cancelAnimationFrame(ue.current)}),[je]),e.useEffect(()=>{he.current=!0,je()},[n,re,ie,G,je]);const Fe=q&&me?v.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ne.left+me.x,top:ne.top+me.y,transform:`translate(${me.x>.6*re?"calc(-100% - 12px)":"12px"}, ${.3*ie>me.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},V?V(me):v.createElement(mt,{data:me})):null,He=pe.current;return v.createElement("div",{className:"stream-network-frame"+(X?" "+X:""),style:{position:"relative",width:I[0],height:I[1]},onMouseMove:q?We:void 0,onMouseLeave:q?Re:void 0},te&&v.createElement("svg",{style:{position:"absolute",top:0,left:0,width:I[0],height:I[1],pointerEvents:"none"}},v.createElement("g",{transform:`translate(${ne.left},${ne.top})`},te)),v.createElement("canvas",{ref:ce,style:{position:"absolute",top:0,left:0}}),v.createElement(et,{width:re,height:ie,totalWidth:I[0],totalHeight:I[1],margin:ne,labels:(null==He?void 0:He.labels)||[],title:Q,legend:J,foregroundGraphics:ee,annotations:K,svgAnnotationRules:Z,annotationFrame:be}),Fe)});yt.displayName="StreamNetworkFrame";const gt=(e,t,o,n)=>{const r=(e.note.label||e.note.title).length;return[Math.min(e.note.wrap||120,r*t)+2*n,Math.ceil(r*t/120)*o+2*n]};function vt(e,t=120,o=8){if(!e)return[];const n=Math.max(1,Math.floor(t/o)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>n?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function bt(e,t,o,n){return"curly"===e?n?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:n?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function xt(e){const{x:t=0,y:o=0,dx:n,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:d,className:h,disable:f,events:p={},"data-testid":m}=e,y=new Set(Array.isArray(f)?f:[]);let g=n||0,b=r||0;null!=i&&(g=i-t),null!=s&&(b=s-o);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===g&&0===b)if(void 0!==c.width){g=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;g=e+(0>e?-5:5),b=c.height/2}return v.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${o})`,"data-testid":m},p),!y.has("connector")&&function(e,t,o,n,r,i){const s=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const o=i.width||0,n=i.height||0;if(o>0||n>0){const r=o/2,i=n/2,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=o/2,d=n/2,h=e*d>t*u?u/e:d/t;a=r+s*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,o=i.depth||30;void 0!==e?(a=e/2,l=o):void 0!==t&&(a=o,l=t/2)}}else{const o=(i.radius||0)+(i.radiusPadding||0);if(o>0&&(0!==e||0!==t)){const n=Math.atan2(t,e);a=Math.cos(n)*o,l=Math.sin(n)*o}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(v.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:n||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-a);s.push(v.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+o*Math.cos(i+r)},${l+o*Math.sin(i+r)}L${a+o*Math.cos(i-r)},${l+o*Math.sin(i-r)}Z`,fill:n||"currentColor",stroke:"none"}))}return v.createElement("g",{className:"annotation-connector"},s)}(g,b,l,d,x,c),!y.has("subject")&&function(e,t,o,n,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(v.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,n=(null==t?void 0:t.height)||0;(e>0||n>0)&&s.push(v.createElement("rect",{key:"subject-rect",width:e,height:n,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=n||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const n=(t.x||0)-e;s.push(v.createElement("line",{key:"threshold-line",x1:n,y1:(t.y1||0)-i,x2:n,y2:(t.y2||0)-i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const n=(t.y||0)-i;s.push(v.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:n,x2:(t.x2||0)-e,y2:n,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(v.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(v.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&s.push(v.createElement("path",{key:"bracket-path",d:bt((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:o||"currentColor"}));break}}return v.createElement("g",{className:"annotation-subject"},s)}(x,c,d,t,o),!y.has("note")&&function(e,t,o,n){if(!e)return v.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return v.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(o)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>o?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=i?c?[i]:vt(i,l):[],m=r?c?[r]:vt(r,l):[],y="leftRight"===u?"end"===h?-4:4:0;let g=0;const b=[];p.length>0&&(b.push(v.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:n||void 0,textAnchor:h,fontWeight:"bold"},p.map((e,t)=>v.createElement("tspan",{key:t,x:y,dy:0===t?0:f},e)))),g=p.length*f),m.length>0&&b.push(v.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:n||void 0,textAnchor:h,y:g},m.map((e,t)=>v.createElement("tspan",{key:t,x:y,dy:f},e))));let x=null;if((i||r)&&(0!==t||0!==o))if("topBottom"===u){const e=Math.min(l,120);let t=0,o=e;"end"===h?(t=-e,o=0):"middle"===h&&(t=-e/2,o=e/2),x=v.createElement("line",{className:"note-line",x1:t,x2:o,y1:0,y2:0,stroke:n||"currentColor"})}else{const e=(p.length+m.length)*f+(m.length>0?f:0);let t=0,o=e;"bottom"===d?(t=-e,o=0):"middle"===d&&(t=-e/2,o=e/2),x=v.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:o,stroke:n||"currentColor"})}const k=(p.length+m.length)*f+(m.length>0?f:0);let w=0;return"topBottom"===u?0>o&&(w=-k):"leftRight"===u&&("middle"===d?w=-k/2:("bottom"===d||0>o)&&(w=-k)),v.createElement("g",{className:"annotation-note",transform:`translate(${t},${o})`},v.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(a,g,b,d))}function kt(e){const{noteData:t}=e,{screenCoordinates:o}=t,n="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&o){const e=t.nx||o[0][0]+t.dx,r=t.ny||o[0][1]+t.dy,i=o.map((o,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:o[0],y:o[1],nx:e,ny:r});return v.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+i},s,{type:n}))});return v.createElement("g",null,i)}const i=t.note||{title:"none",label:t.label};return v.createElement(xt,Object.assign({"data-testid":"semiotic-annotation",key:`${i.label}-${i.title}-${t.i}`,events:r},t,{type:n}))}function wt(t){let o=e.createContext(null),n=At(t);return[function({children:n}){let r=e.useMemo(()=>At(t),[]);return v.createElement(o.Provider,{value:r,children:n})},t=>{var r;let i=null!==(r=e.useContext(o))&&void 0!==r?r:n;return function(t,o){const[n,r]=e.useState(o);return e.useLayoutEffect(()=>t(()=>r(o)),[t]),n}(i.subscribe,()=>t(i.getState()))}]}function At(e){let t=new EventTarget,o=e(function(e){o=Object.assign(o,e(o)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>o,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}let[Et,Mt]=wt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function St(e,t,o){return"number"==typeof o?o:t&&t.find(t=>t.props.orient===e)?50:10}const Ot=(e,t,o)=>`${e.map(Pt).join(",")}${JSON.stringify(t)}${o.join(",")}`;function Pt(e){if(!e||!e.props||!e.props.noteData)return"";const{note:t={}}=e.props.noteData,{label:o,title:n}=t;return`${e.props.noteData.id||`${e.props.noteData.x}-${e.props.noteData.y}`}-${o}=${n}`}function jt(e,t=8,o){const{noteWidth:n=o}=e;let r=n;"number"==typeof n&&(r=()=>n);const i=e.note&&e.note.wrap||120,s=e.note.label||e.note.label||"";return n&&r(e)||(v.default.isValidElement(e.note)?100:Math.min(i,s.length*t))}function Nt(e,t=8,o=20,n){const{noteHeight:r=n}=e;let i=r;"number"==typeof r&&(i=()=>r);const s=e.note&&e.note.wrap||120,a=e.note.label||e.note.title||"";return r&&i(e)||(v.default.isValidElement(e.note)?30:Math.ceil(a.length*t/s)*o+(e.note.label&&e.note.title?o:0))}const _t=(e,t)=>t.map((t,o)=>e.svgAnnotationRule(t,o,e)).filter(e=>null!=e),Ct=(e,t)=>{let o=t.adjustedAnnotations,n=t.adjustedAnnotationsKey,r=t.adjustableAnnotations,i=t.fixedAnnotations,s=[],a=[];const l=t.adjustedAnnotationsKey,c=t.adjustedAnnotationsDataVersion,{annotations:u,annotationHandling:d=!1,size:h,svgAnnotationRule:f,htmlAnnotationRule:p}=e,m="object"==typeof d?d:{layout:{type:d},dataVersion:""},{dataVersion:y=""}=m;if(f){const t=_t(e,u);n=Ot(t,m,h),!1===d&&(o=r),o=o.length!==r.length||l!==n||c!==y?((e,t,o)=>{const{layout:n={type:!1,noteHeight:void 0,noteWidth:void 0}}=t;if(!1===n.type)return e;const{noteWidth:r,noteHeight:i}=n;let{margin:s={top:0,bottom:0,left:0,right:0}}=o;const{size:a,axes:l=[]}=o;if(s="number"==typeof s?{top:s,left:s,right:s,bottom:s}:s,"bump"===n.type)return function(e,t,o,n,r){const{padding:i=1,characterWidth:s=8,lineHeight:a=20,iterations:l=500,pointSizeFunction:c=n,labelSizeFunction:u=r||gt}=t,d=e.map((e,t)=>{const o=(e.props.noteData.x[0]||e.props.noteData.x)+(void 0!==e.props.noteData.dx?e.props.noteData.dx:-10*(t%3-1)),n=(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]=u(e.props.noteData,s,a,i);return{x:o,y:n,above:e.props.noteData.y>n,left:e.props.noteData.x>o,width:r,height:l,type:"label",name:"",originalNote:e}}),h=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})),f=function(){let e,t=[],o=[],n=1,r=1,i={start:e=>{},width:e=>{},height:e=>{},label:e=>{},anchor:e=>{},alt_energy:e=>{},alt_schedule:e=>{}},s=!1;const a=function(e){let n=t.length,r=0,i=t[e].x-o[e].x,s=o[e].y-t[e].y,a=Math.sqrt(i*i+s*s);a>0&&(r+=.2*a),i/=a,s/=a,r+=i>0&&s>0?0:0>i&&s>0?3:0>i&&0>s?6:9;let l,c,d,h,f,p,m,y=t[e].x,g=t[e].y-t[e].height+2,v=t[e].x+t[e].width,b=t[e].y+2;for(let i=0;n>i;i++)i!==e&&(u(o[e].x,t[e].x,o[i].x,t[i].x,o[e].y,t[e].y,o[i].y,t[i].y)&&(r+=1),l=t[i].x,d=t[i].y-t[i].height+2,c=t[i].x+t[i].width,h=t[i].y+2,f=Math.max(0,Math.min(c,v)-Math.max(l,y)),p=Math.max(0,Math.min(h,b)-Math.max(d,g)),m=f*p,r+=30*m),l=o[i].x-o[i].r,d=o[i].y-o[i].r,c=o[i].x+o[i].r,h=o[i].y+o[i].r,f=Math.max(0,Math.min(c,v)-Math.max(l,y)),p=Math.max(0,Math.min(h,b)-Math.max(d,g)),m=f*p,r+=30*m;return r},l=function(i){let l,c,u=Math.floor(Math.random()*t.length),d=t[u].x,h=t[u].y;l=s?e(u,t,o):a(u),t[u].x+=5*(Math.random()-.5),t[u].y+=5*(Math.random()-.5),t[u].x>n&&(t[u].x=d),0>t[u].x&&(t[u].x=d),t[u].y>r&&(t[u].y=h),0>t[u].y&&(t[u].y=h),c=s?e(u,t,o):a(u);let f=c-l;Math.random()<Math.exp(-f/i)||(t[u].x=d,t[u].y=h)},c=function(i){let l,c=Math.floor(Math.random()*t.length),u=t[c].x,d=t[c].y;l=s?e(c,t,o):a(c);let h=.5*(Math.random()-.5),f=Math.sin(h),p=Math.cos(h);t[c].x-=o[c].x,t[c].y-=o[c].y;let m,y=t[c].x*f+t[c].y*p;t[c].x=t[c].x*p-t[c].y*f+o[c].x,t[c].y=y+o[c].y,t[c].x>n&&(t[c].x=u),0>t[c].x&&(t[c].x=u),t[c].y>r&&(t[c].y=d),0>t[c].y&&(t[c].y=d),m=s?e(c,t,o):a(c);let g=m-l;Math.random()<Math.exp(-g/i)||(t[c].x=u,t[c].y=d)},u=function(e,t,o,n,r,i,s,a){let l,c,u,d,h;return u=(a-s)*(t-e)-(n-o)*(i-r),d=(n-o)*(r-s)-(a-s)*(e-o),h=(t-e)*(r-s)-(i-r)*(e-o),l=d/u,c=h/u,!(0>l||l>1||0>c||c>1)},d=function(e,t,o){return e-t/o};return i.start=function(e){let o=t.length,n=1;for(let t=0;e>t;t++){for(let e=0;o>e;e++).5>Math.random()?l(n):c(n);n=d(n,1,e)}},i.width=function(e){return arguments.length?(n=e,i):n},i.height=function(e){return arguments.length?(r=e,i):r},i.label=function(e){return arguments.length?(t=e,i):t},i.anchor=function(e){return arguments.length?(o=e,i):o},i.alt_energy=function(t){return arguments.length?(e=t,s=!0,i):a},i.alt_schedule=function(e){return arguments.length?i:d},i}();return f.label(d),f.anchor(h),f.width(o[0]),f.height(o[1]),f.start(l),d.forEach(e=>{if("label"===e.type){const t=function(e,t,o){return e.y>t.y?[t.x+t.width/2+o/2,t.y-t.height+o/2]:[t.x+t.width/2,t.y]}(e.originalNote.props.noteData,e,i);e.originalNote.props.noteData.nx=t[0],e.originalNote.props.noteData.ny=t[1]}}),e}(e,n,a,o.pointSizeFunction,o.labelSizeFunction);if("marginalia"===n.type){const{marginOffset:t,orient:o="nearest",characterWidth:c=8,lineHeight:u=20,padding:d=2,axisMarginOverride:h={}}=n,f="nearest"===o?["left","right","top","bottom"]:Array.isArray(o)?o:[o],p=f.find(e=>"left"===e),m=f.find(e=>"right"===e),y=f.find(e=>"top"===e),g=f.find(e=>"bottom"===e),x=[],k=[],w=[],A=[];for(const t of e){const e=t.props.noteData,o=e.x[0]||e.x,n=e.y[0]||e.y,r=p?o:1/0,i=m?a[0]-o:1/0,s=y?n:1/0,l=Math.min(r,i,s,g?a[1]-n:1/0);r===l?x.push(t):i===l?k.push(t):s===l?w.push(t):A.push(t)}const E=new b.default.Force({minPos:void 0!==h.top?0+h.top:0-s.top,maxPos:void 0!==h.bottom?a[1]-h.bottom:g?a[1]:a[1]+s.bottom}).nodes(x.map(e=>new b.default.Node(e.props.noteData.y[0]||e.props.noteData.y,Nt(e.props.noteData,c,u,r)+d))).compute(),M=new b.default.Force({minPos:void 0!==h.top?0+h.top:y?0:0-s.top,maxPos:void 0!==h.bottom?a[1]-h.bottom:a[1]+s.bottom}).nodes(k.map(e=>new b.default.Node(e.props.noteData.y[0]||e.props.noteData.y,Nt(e.props.noteData,c,u,r)+d))).compute(),S=new b.default.Force({minPos:void 0!==h.left?0+h.left:p?0:0-s.left,maxPos:void 0!==h.right?a[0]-h.right:a[0]+s.right}).nodes(w.map(e=>new b.default.Node(e.props.noteData.x[0]||e.props.noteData.x,jt(e.props.noteData,c,i)+d))).compute(),O=new b.default.Force({minPos:void 0!==h.left?0+h.left:0-s.left,maxPos:void 0!==h.right?a[0]-h.right:m?a[0]:a[0]+s.right}).nodes(A.map(e=>new b.default.Node(e.props.noteData.x[0]||e.props.noteData.x,jt(e.props.noteData,c,i)+d))).compute(),P=Math.max(...A.map(e=>Nt(e.props.noteData,c,u,r)+d)),j=Math.max(...w.map(e=>Nt(e.props.noteData,c,u,r)+d)),N=Math.max(...x.map(e=>jt(e.props.noteData,c,i)+d)),_=Math.max(...k.map(e=>jt(e.props.noteData,c,i)+d)),C=E.nodes(),z=M.nodes(),$=S.nodes(),B=O.nodes();return x.forEach((e,o)=>{const n=0-C[o].layerIndex*N-St("left",l,t),r=C[o].currentPos;e.props.noteData.nx=n,e.props.noteData.ny=r,e.props.noteData.note&&!v.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,o)=>{const n=a[0]+z[o].layerIndex*_+St("right",l,t),r=z[o].currentPos;e.props.noteData.nx=n,e.props.noteData.ny=r,e.props.noteData.note&&!v.isValidElement(e)&&(e.props.noteData.note.orientation=e.props.noteData.note.orientation||"leftRight",e.props.noteData.note.align=e.props.noteData.note.align||"left")}),w.forEach((e,o)=>{const n=$[o].currentPos,r=0-$[o].layerIndex*j-St("top",l,t);e.props.noteData.nx=n,e.props.noteData.ny=r}),A.forEach((e,o)=>{const n=B[o].currentPos,r=a[1]+B[o].layerIndex*P+St("bottom",l,t);e.props.noteData.nx=n,e.props.noteData.ny=r}),e}return e})(r,m,e):r.map((e,t)=>{const n=Object.assign(Object.assign({},o[t].props.noteData),e.props.noteData);return v.createElement(kt,{key:e.key,noteData:n})}),s=[...o,...i]}return p&&(a=((e,t)=>t.map((t,o)=>e.htmlAnnotationRule(t,o,e)).filter(e=>null!=e))(e,u)),{svgAnnotations:s,htmlAnnotations:a,adjustedAnnotations:o,adjustedAnnotationsKey:n,adjustedAnnotationsDataVersion:y}};function zt(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);n.length>r;r++)0>t.indexOf(n[r])&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}"function"==typeof SuppressedError&&SuppressedError;const $t=e=>e instanceof Date?e.getTime():e,Bt=({data:e,lineDataAccessor:t,xProp:o,xPropTop:n,xPropBottom:r,yProp:i,yPropTop:s,yPropBottom:a,xAccessor:l,yAccessor:c})=>{Array.isArray(e)||(e=[e]);const u=[];return t.forEach((t,d)=>{l.forEach((l,h)=>{c.forEach((c,f)=>{e.forEach(e=>{const p=Object.assign(Object.assign({},e),{xIndex:h,yIndex:f,lineIndex:d});p.data=t(e).map((e,t)=>{const u={data:e};return u[o]=l(e,t),u[n]=u[o],u[r]=u[o],u[i]=c(e,t),u[s]=u[i],u[a]=u[i],u}),p.key=p.key||u.length,u.push(p)})})})}),u},Lt=({type:e="stackedarea",data:t,xProp:o,yProp:n,yPropMiddle:i,sort:s,yPropTop:a,yPropBottom:l})=>{const c=new Map,u=t.map(()=>0);let d=0;for(const e of t){e.__lineIndex=d;for(const t of e.data){const e=$t(t[o]);u[d]+=t[n],c.has(e)||c.set(e,[]),c.get(e)[d]=t}d++}let h=(e,t)=>u[t.key]-u[e.key];"stackedpercent-invert"!==e&&"stackedarea-invert"!==e||(h=(e,t)=>u[e.key]-u[t.key]),null!==(s=void 0===s?h:s)&&(t=t.sort(s));const f=t.map(e=>e.__lineIndex);for(const[,t]of c){let o=0,s=0;const c=r.sum(t,e=>(null==e?void 0:e[n])>0?e[n]:0),u=r.sum(t,e=>0>(null==e?void 0:e[n])?e[n]:0);for(const r of f){const d=t[r];if(d)if(0>d[n]){if("linepercent"===e||"stackedpercent"===e||"stackedpercent-invert"===e){const t=d[n]/u;if(d.percent=t,"linepercent"===e)d[l]=d[l]=d[a]=d[i]=t;else{const e=0>u?t:0;d[l]=0===u?0:-o/u,d[a]=d[l]-e,d[i]=d[l]-e/2}}else d[l]=o,d[a]=o+d[n],d[i]=o+d[n]/2;o+=d[n]}else{if("linepercent"===e||"stackedpercent"===e||"stackedpercent-invert"===e){const t=d[n]/c;if(d.percent=t,"linepercent"===e)d[l]=d[a]=d[i]=t;else{const e=c>0?t:0;d[l]=0===c?0:s/c,d[a]=d[l]+e,d[i]=d[l]+e/2}}else d[l]=s,d[a]=s+d[n],d[i]=s+d[n]/2;s+=d[n]}}}return t},Dt=({data:e,y1:t,x1:o,yPropTop:n,yPropMiddle:r,yPropBottom:i,xPropTop:s,xPropMiddle:a,xPropBottom:l})=>{if(t)for(const o of e)for(const e of o.data)e[i]=t(e),e[r]=e[n];if(o)for(const t of e)for(const e of t.data)e[l]=o(e),e[a]=(e[l]+e[s])/2;return e},Tt=({data:e,y1:t,yPropTop:o,yPropMiddle:n,yPropBottom:r,type:i="cumulative"})=>{for(const s of e){let e=0;const a="cumulative-reverse"===i?s.data.reverse():s.data;for(const i of a)e+=i[o],i[r]=i[o]=i[n]=e,t&&(i[r]=t(i),i[n]=i[r]+i[o]/2)}return e},Wt=({type:e="bumpline",data:t,xProp:o,yProp:n,yPropMiddle:r,yPropTop:i,yPropBottom:s})=>{const a=new Map;for(const e of t)for(const t of e.data){const e=$t(t[o]);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=(e,t)=>e[n]>t[n]?1:-1;"bumparea-invert"!==e&&"bumpline-invert"!==e||(l=(e,t)=>t[n]>e[n]?1:-1);for(const[,t]of a){let o=0,a=0;t.sort(l);let c=1;for(const l of t)"bumparea"===e||"bumparea-invert"===e?0>l[n]?(l[i]=o+l[n],l[r]=o+l[n]/2,l[s]=o,o+=l[n]):(l[i]=a+l[n],l[r]=a+l[n]/2,l[s]=a,a+=l[n]):(l[n]=c,l[i]=c,l[s]=c),c++}return t};function Rt({pointA:e,pointB:t,currentParameters:o,parameters:n,keys:r}){const i={};return r.forEach(o=>{i[o]="number"==typeof e[o]?(e[o]+t[o])/2:void 0}),JSON.stringify(n(i))===JSON.stringify(o)?[i,t]:[e,i]}const Ft=({xy:e,orient:t,i:o,className:n="",jaggedBase:r})=>{let i=`M${e.x1},${e.y1}L${e.x2},${e.y2}`;return r&&0===o&&(i=((e,t)=>{let o="";const{x1:n,x2:r,y1:i,y2:s}=t;if("left"===e||"right"===e){const t=Math.abs(r-n);o=((e,t,o,n)=>{const r=e/t;let i=0,s="M0,"+o;const a="right"===n?-1:1;for(;e>=i;)s+=`L${i},${o}`,e>i&&(s+=`L${i+r/2},${o+10*a}`),i+=r;return s})(t,Math.ceil(t/40),"right"===e?0:i,e)}else{const t=Math.abs(s-i);o=((e,t,o,n)=>{const r=e/t;let i=0,s=`M${o},0`;const a="bottom"===n?-1:1;for(;e>=i;)s+=`L${o},${i}`,e>i&&(s+=`L${o+10*a},${i+r/2}`),i+=r;return s})(t,Math.ceil(t/40),n,e)}return o})(t,e)),v.createElement("path",{key:o,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:i,className:`tick-line tick ${t} ${n}`})};function Ht(e,t,o){const n=Math.abs(o.range()[1]-o.range()[0]);return e||(t||(t=Math.max(1,Math.floor(n/40))),e=o.ticks&&o.ticks(t)||o.domain()),e}function It({t:e,o:t,w:o}){return"contour"!==e&&"boxplot"!==e||"left"!==t&&"right"!==t?0:o/2}function Yt({t:e,o:t,w:o}){return"contour"!==e&&"boxplot"!==e||"top"!==t&&"bottom"!==t?0:o/2}function Xt(e){const{translation:t,orient:o,decoratedSummaryType:n,summaryWidth:r,renderedSummary:i,points:s}=e;return v.default.createElement("g",{className:"marginal-graphics",transform:`translate(${t[o]})`},v.default.createElement("g",{transform:`translate(${It({t:n.type,o:o,w:r})},${Yt({t:n.type,o:o,w:r})})`},i),s)}function Gt(e){const{className:t,translation:o,position:n,rotation:r,labelName:i,anchorMod:s}=e;return v.default.createElement("g",{className:"axis-title "+t,transform:`translate(${[o[0]+n[0],o[1]+n[1]]}) rotate(${r})`},v.default.isValidElement(i)?i:v.default.createElement("text",{textAnchor:s},i))}function qt(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)),o=Math.abs(t);return 1e9>o?1e6>o?1e4>o?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"}const Vt=e=>e.reduce((e,t)=>e.concat(Array.isArray(t)?Vt(t.slice().sort((e,t)=>e-t)):t),[]);function Ut(e=[]){if(!Array.isArray(e))return"not-array";let t=e.slice();return Array.isArray(t[0])||(t=t.slice().sort((e,t)=>e-t)),""+Vt(t).map(e=>e instanceof Date&&""+e||void 0!==e&&e.toFixed&&e.toFixed(2)||"empty")}const Kt="x",Zt="y",Jt="yMiddle",Qt="yTop",eo="yBottom",to="xMiddle",oo="xTop",no="xBottom";function ro({preprocess:e=!0,processedData:t=!1,summaryType:o,data:r,finalXExtent:i,finalYExtent:s,size:a,xScaleType:l=n.scaleLinear(),yScaleType:c=n.scaleLinear(),margin:u,styleFn:d,classFn:h,renderFn:f,chartSize:p}){let y=i,g=s;if(!y){const e=r.coordinates.map(e=>e.x);y=[Math.min(...e),Math.max(...e)]}if(!g){const e=r.coordinates.map(e=>e.y);g=[Math.min(...e),Math.max(...e)]}if(t&&r)return r.coordinates;let b,x=[];b=o.type?o:{type:b};const{bins:k=.05,cellPx:w,binValue:A=e=>e.length,binMax:E,customMark:M}=b;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(e=>[e.x,e.y]));const S=Array.isArray(r)?r:[r],O=l.domain(y).range([0,a[0]]),P=c.domain(g).range([0,a[1]]),j=w&&w/2||(k>1?1/k:k)*a[0]/2,N=m.hexbin().x(e=>O(e._xyfPoint[0])).y(e=>P(e._xyfPoint[1])).radius(j).size(a);let _;const C=N.centers();return S.forEach(e=>{_=0;const t=N(e._xyfCoordinates.map((t,o)=>Object.assign({_xyfPoint:t},e.coordinates[o]))),o={};t.forEach(e=>{o[`${parseInt(e.x)}-${parseInt(e.y)}`]=!0}),C.forEach(e=>{if(!o[`${parseInt(e[0])}-${parseInt(e[1])}`]){const o=[];o.x=e[0],o.y=e[1],t.push(o)}}),_=Math.max(...t.map(e=>A(e))),E&&E(_);const n=[[0,-1],[.866,-.5],[.866,.5],[0,1],[-.866,.5],[-.866,-.5]],r=O.invert(j)-y[0],i=P.invert(j)-g[0],s=n.map(e=>[e[0]*r,e[1]*i]),l=t.map(t=>{const o=A(t),r=t.x,i=t.y;t.x=O.invert(t.x),t.y=P.invert(t.y);const l=o/_;return{customMark:M&&v.createElement("g",{transform:`translate(${r},${a[1]-i})`},M({d:Object.assign(Object.assign({},t),{binItems:t,percent:l,value:o,radius:j,hexCoordinates:n.map(e=>[e[0]*j,e[1]*j])}),margin:u,styleFn:d,classFn:h,renderFn:f,chartSize:p,adjustedSize:a})),_xyfCoordinates:s.map(e=>[e[0]+t.x,e[1]+t.y]),value:o,percent:l,data:t,parentSummary:e,centroid:!0}});x=[...x,...l]}),e?(x.forEach(e=>{e.x=e.data.x,e.y=e.data.y}),{type:"hexbin",processedData:!0,coordinates:x,binMax:_}):x}const io=(e,t,o,n)=>[...e.map((e,n)=>[e[0],e[1]+o(t[n])]),...e.map((e,o)=>[e[0],e[1]-n(t[o])]).reverse()];function so({preprocess:e=!0,processedData:t=!1,summaryType:o,data:r,finalXExtent:i=[Math.min(...r.coordinates.map(e=>e.x)),Math.max(...r.coordinates.map(e=>e.x))],finalYExtent:s=[Math.min(...r.coordinates.map(e=>e.y)),Math.max(...r.coordinates.map(e=>e.y))],size:a,xScaleType:l=n.scaleLinear(),yScaleType:c=n.scaleLinear(),margin:u,styleFn:d,classFn:h,renderFn:f,chartSize:p}){if(t&&r)return r.coordinates;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(e=>[e.x,e.y]));const m=Array.isArray(r)?r:[r];let y,g=[];y=o.type?o:{type:y};const{binValue:b=e=>e.length,xBins:x=y.yBins||.05,yBins:k=x,xCellPx:w=!y.xBins&&y.xCellPx,yCellPx:A=!y.yBins&&y.yCellPx,customMark:E,binMax:M}=y,S=1>x?x:1/x,O=1>k?k:1/k,P=l.domain(i).range([0,a[0]]),j=c.domain(s).range([a[1],0]),N=[Math.ceil((w&&w/a[0]||S)*a[0]*10)/10,Math.ceil((A&&A/a[1]||O)*a[1]*10)/10];let _=-1/0;return m.forEach(e=>{const t=[],o=[];let n,r;for(let i=0;a[0]>Math.ceil(i);i+=N[0]){const s=P.invert(i),l=P.invert(i+N[0]);r=[],t.push(r);for(let t=0;a[1]>Math.ceil(t);t+=N[1]){const a=j.invert(t),c=j.invert(t+N[1]);n={gx:i,gy:t,gw:N[0],gh:N[1],x:(s+l)/2,y:(a+c)/2,binItems:[],value:0,_xyfCoordinates:[[s,a],[l,a],[l,c],[s,c]],parentSummary:e},r.push(n),o.push(n)}r.push(n)}t.push(r),e._xyfCoordinates.forEach((o,n)=>{const r=P(o[0]),i=j(o[1]),s=Math.floor(r/N[0]),a=Math.floor(i/N[1]);t[s][a]&&t[s][a].binItems.push(e.coordinates[n])}),o.forEach(e=>{e.value=b(e.binItems),_=Math.max(_,e.value)}),o.forEach(e=>{e.percent=e.value/_,e.customMark=E&&v.createElement("g",{transform:`translate(${e.gx},${e.gy})`},E({d:e,margin:u,styleFn:d,classFn:h,renderFn:f,chartSize:p,adjustedSize:a}))}),g=[...g,...o]}),M&&M(_),e?{type:"heatmap",processedData:!0,_baseData:[],_xyfCoordinates:[],data:[],bounds:[],x:0,y:0,coordinates:g,binMax:_}:g}const ao=e=>e&&e.extent||Array.isArray(e)&&e||[],lo=()=>!0,co={top:Qt,bottom:eo,orphan:Zt},uo={top:oo,bottom:no,orphan:Kt},ho={stackedarea:Lt,"stackedarea-invert":Lt,stackedpercent:Lt,"stackedpercent-invert":Lt,linepercent:Lt,difference:({data:e,yProp:t,yPropTop:o,yPropBottom:n})=>(e.forEach((r,i)=>{r.data.forEach((r,s)=>{const a=0===i?1:0;r[t]>e[a].data[s][t]?(r[n]=e[a].data[s][t],r[o]=r[t]):(r[o]=r[t],r[n]=r[t])})}),e),bumparea:Wt,bumpline:Wt,"bumparea-invert":Wt,line:Dt,area:Dt,cumulative:Tt,"cumulative-reverse":Tt};function fo(e,t){const o=[];for(const e of t)o.push(Object.assign({},e));for(const t of e)t.parentSummary||o.push(t);return o}function po(e,t,o){return t.parent&&(o=`${o}-${po(e,Object.assign(Object.assign({},t.parent),t.parent.data),o)}`),`${o}-${e(Object.assign(Object.assign({},t),t.data))}`}const mo=e=>e.id||e.descendantIndex;function yo({data:e,colorBy:t,colorScale:o,getColor:n,strokeColor:r,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=i?n(i,t,o):o?o(r):"#000000";return{label:r+"",color:s}}),label:""}]}}const go={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 vo(e,t){return"function"==typeof t?t(e):e[t]}function bo(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 xo(e={}){const{fields:t,title:o,format:n,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(o){const t=vo(e,o);s=bo(t,n)}if(t&&t.length>0)t.forEach(t=>{let o,r,i;"string"==typeof t?(o=t,r=t,i=n):(o=t.label,r=t.accessor||t.key||"",i=t.format||n);const s=vo(e,r);a.push({label:o,value:bo(s,i)})});else if(!o){const t=["value","y","name","id","label"];for(const o of t)if(void 0!==e[o]){s=bo(e[o],n);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=bo(e[t[0]],n))}}const l=Object.assign(Object.assign({},go),r);return v.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&v.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>v.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&v.createElement("span",null,e.label,": "),e.value)))}}function ko(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||xo(e)))}function wo(e){return"string"==typeof e?e:"value"}function Ao(e){return t=>{const o=t.data;return o?v.createElement("div",{className:"semiotic-tooltip",style:go},e.map((e,t)=>{const n=function(e,t){return"function"==typeof t?t(e):e[t]}(o,e.accessor),r=null==(i=n)?"–":"number"==typeof i?i.toLocaleString():i instanceof Date?i.toLocaleDateString():i+"";var i;return v.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},v.createElement("span",{style:{opacity:.8}},e.label,": "),v.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},r))})):null}}const Eo="#007bff";function Mo(e){return"function"==typeof e?e:t=>t[e]}function So(t,o,n="category10"){return e.useMemo(()=>{if(o&&"function"!=typeof o)return lt(t,o,n)},[t,o,n])}function Oo(t,o,n){return e.useMemo(()=>{if(!o)return t;const e=[...t];if("function"==typeof o)return e.sort(o);const r=Mo(n);return e.sort("asc"===o?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,o,n])}function Po({componentName:e,message:t,width:o,height:n}){return v.createElement("div",{role:"alert",style:{width:o,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"}},v.createElement("div",{style:{textAlign:"center",maxWidth:400}},v.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),v.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function jo({data:e,accessors:t,requiredProps:o}){if(o)for(const[e,t]of Object.entries(o))if(null==t)return e+" is required. Provide a field name or function.";if(!e||!Array.isArray(e)||0===e.length)return"No data provided. Pass a non-empty array to the data prop.";if(t){const o=e[0];if(o&&"object"==typeof o)for(const[e,n]of Object.entries(t))if(n&&"string"==typeof n&&!(n in o))return`${e} "${n}" not found in data. Available fields: ${Object.keys(o).join(", ")}.`}return null}function No({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function _o({nodes:e,edges:t,nodesRequired:o=!1,edgesRequired:n=!0,accessors:r}){if(n&&(!t||!Array.isArray(t)||0===t.length))return"No edges provided. Pass a non-empty array to the edges prop.";if(o&&(!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,o]of Object.entries(r))if(o&&"string"==typeof o&&!(o in t))return`${e} "${o}" not found in node data. Available fields: ${Object.keys(t).join(", ")}.`}return null}function Co(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}function zo(e){return e?"string"==typeof e?{name:e}:e:null}function $o(e,t,o){return t?n=>{var r,i;const s=Object.assign({},e(n));return t.isActive&&(t.predicate(n)?(null==o?void 0:o.selectedStyle)&&Object.assign(s,o.selectedStyle):(s.fillOpacity=null!==(r=null==o?void 0:o.unselectedOpacity)&&void 0!==r?r:.2,s.strokeOpacity=null!==(i=null==o?void 0:o.unselectedOpacity)&&void 0!==i?i:.2,(null==o?void 0:o.unselectedStyle)&&Object.assign(s,o.unselectedStyle))),s}:e}function Bo(e){const t=[];for(const[o,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[o]));else{const[e,r]=n.range;t.push(t=>{const n=t[o];return n>=e&&r>=n})}return e=>t.every(t=>t(e))}function Lo(e,t){const o=[];for(const[n,r]of e.clauses)"crossfilter"===e.resolution&&n===t||o.push(Bo(r));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function Do(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}const[To,Wo]=wt(e=>({selections:new Map,setClause(t,o){e(e=>{const n=new Map(e.selections),r=Do(n,t),i=new Map(r.clauses);return i.set(o.clientId,o),n.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:n}})},clearClause(t,o){e(e=>{const n=e.selections.get(t);if(!n)return{};const r=new Map(e.selections),i=new Map(n.clauses);return i.delete(o),r.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:r}})},setResolution(t,o){e(e=>{const n=new Map(e.selections),r=Do(n,t);return n.set(t,Object.assign(Object.assign({},r),{resolution:o})),{selections:n}})},clearSelection(t){e(e=>{const o=new Map(e.selections),n=o.get(t);return n&&o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}}));function Ro(t){const o=e.useId(),n=t.clientId||o,{name:r}=t,i=Wo(e=>e.selections.get(r)),s=Wo(e=>e.setClause),a=Wo(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?Lo(i,n):()=>!0,[i,n]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"point",values:new Set(n)};s(r,{clientId:n,type:"point",fields:t})},[n,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"interval",range:n};s(r,{clientId:n,type:"interval",fields:t})},[n,r,s]),clear:e.useCallback(()=>{a(r,n)},[a,r,n]),clientId:n}}function Fo(t){const o=t.name||"hover",{fields:n}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=Ro({name:o});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,a]),predicate:r,isActive:i}}function Ho(t){const{name:o,xField:n,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=Ro({name:o}),c=n&&r?"xyBrush":n?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,n,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}function Io(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,xLabel:l,yLabel:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:f="y",colorBy:p,colorScheme:m="category10",sizeBy:y,sizeRange:g=[3,15],pointRadius:b=5,pointOpacity:x=.8,enableHover:k=!0,showGrid:w=!1,showLegend:A,tooltip:E,marginalGraphics:M,frameProps:S={},selection:O,linkedHover:P,linkedBrush:j}=t,N=o||[],_=Co(P,p?["string"==typeof p?p:""]:[]),C=zo(j),z=Ro({name:(null==O?void 0:O.name)||"__unused__"}),$=Fo({name:(null==_?void 0:_.name)||"hover",fields:(null==_?void 0:_.fields)||[]});Ho({name:(null==C?void 0:C.name)||"__unused_brush__",xField:(null==C?void 0:C.xField)||("string"==typeof h?h:void 0),yField:(null==C?void 0:C.yField)||("string"==typeof f?f:void 0)});const B=O?{isActive:z.isActive,predicate:z.predicate}:null,L=So(N,p,m),D=e.useMemo(()=>{if(!y||0===N.length)return;const e=N.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[N,y]),T=e.useMemo(()=>e=>{const t={fillOpacity:x};return t.fill=p?at(e,p,L):Eo,t.r=y?ct(e,y,g,D):b,t},[p,L,y,g,D,b,x]),W=e.useMemo(()=>$o(T,B,O),[T,B,O]),R=void 0!==A?A:!!p,F=e.useMemo(()=>{if(R&&p)return yo({data:N,colorBy:p,colorScale:L,getColor:at})},[R,p,N,L]),H=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return F&&120>e.right&&(e.right=120),e},[i,F]),I=e.useCallback(e=>{P&&$.onHover(e)},[P,$]),Y=e.useMemo(()=>Ao([{label:l||wo(h),accessor:h,role:"x"},{label:c||wo(f),accessor:f,role:"y"},...p?[{label:wo(p),accessor:p,role:"color"}]:[],...y?[{label:wo(y),accessor:y,role:"size"}]:[]]),[h,f,l,c,p,y]),X=jo({componentName:"Scatterplot",data:N,accessors:{xAccessor:h,yAccessor:f}});if(X)return v.createElement(Po,{componentName:"Scatterplot",message:X,width:n,height:r});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:N,xAccessor:h,yAccessor:f,colorAccessor:p||void 0,sizeAccessor:y||void 0,sizeRange:g,pointStyle:W,colorScheme:m,size:[n,r],margin:H,showAxes:!0,xLabel:l,yLabel:c,xFormat:u,yFormat:d,enableHover:k,showGrid:w},F&&{legend:F}),a&&{title:a}),s&&{className:s}),{tooltipContent:E?ko(E):Y}),P&&{customHoverBehavior:I}),M&&{marginalGraphics:M}),S);return v.createElement(ie,Object.assign({},G))}function Yo(t){var o;const{data:n,width:r=600,height:i=400,margin:s,className:a,title:l,xLabel:c,yLabel:u,xFormat:d,yFormat:h,xAccessor:f="x",yAccessor:p="y",lineBy:m,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b="category10",curve:x="linear",showPoints:k=!1,pointRadius:w=3,fillArea:A=!1,areaOpacity:E=.3,lineWidth:M=2,enableHover:S=!0,showGrid:O=!1,showLegend:P,tooltip:j,frameProps:N={},selection:_,linkedHover:C}=t,z=n||[],$=Co(C,g?["string"==typeof g?g:""]:[]),B=Ro({name:(null==_?void 0:_.name)||"__unused__"}),L=Fo({name:(null==$?void 0:$.name)||"hover",fields:(null==$?void 0:$.fields)||[]}),D=_?{isActive:B.isActive,predicate:B.predicate}:null,T=void 0!==(null===(o=z[0])||void 0===o?void 0:o[y]),W=e.useMemo(()=>{if(T)return z;if(m){const e=z.reduce((e,t)=>{const o="function"==typeof m?m(t):t[m];if(!e[o]){const t={[y]:[]};"string"==typeof m&&(t[m]=o),e[o]=t}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:z}]},[z,m,y,T]),R=So(z,g,b),F=e.useMemo(()=>e=>{const t={strokeWidth:M};return t.stroke=g?at(e,g,R):Eo,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[g,R,M,A,E]),H=e.useMemo(()=>$o(F,D,_),[F,D,_]),I=e.useMemo(()=>{if(k)return e=>{const t={r:w,fillOpacity:1};return t.fill=g?at(e.parentLine||e,g,R):Eo,t}},[k,w,g,R]),Y=A?"area":"line",X=void 0!==P?P:W.length>1,G=e.useMemo(()=>{if(X&&g)return yo({data:W,colorBy:g,colorScale:R,getColor:at})},[X,g,W,R]),q=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),s);return G&&120>e.right&&(e.right=120),e},[s,G]),V=e.useCallback(e=>{C&&L.onHover(e)},[C,L]),U=m||g,K=e.useMemo(()=>Ao([{label:c||wo(f),accessor:f,role:"x"},{label:u||wo(p),accessor:p,role:"y"},...U?[{label:wo(U),accessor:U,role:"group"}]:[]]),[f,p,c,u,U]),Z=jo({componentName:"LineChart",data:z,accessors:{xAccessor:f,yAccessor:p}});if(Z)return v.createElement(Po,{componentName:"LineChart",message:Z,width:r,height:i});const J=e.useMemo(()=>T||m?W.flatMap(e=>{const t=e[y]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):z,[W,y,T,m,z]),Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Y,data:J,xAccessor:f,yAccessor:p,groupAccessor:m||void 0,curve:x,lineStyle:H},k&&{pointStyle:I}),{size:[r,i],margin:q,showAxes:!0,xLabel:c,yLabel:u,xFormat:d,yFormat:h,enableHover:S,showGrid:O}),G&&{legend:G}),l&&{title:l}),a&&{className:a}),{tooltipContent:j?ko(j):K}),C&&{customHoverBehavior:V}),N);return v.createElement(ie,Object.assign({},Q))}function Xo(t){var o;const{data:n,width:r=600,height:i=400,margin:s,className:a,title:l,xLabel:c,yLabel:u,xFormat:d,yFormat:h,xAccessor:f="x",yAccessor:p="y",areaBy:m,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,enableHover:E=!0,showGrid:M=!1,showLegend:S,tooltip:O,frameProps:P={},selection:j,linkedHover:N}=t,_=n||[],C=Co(N,g?["string"==typeof g?g:""]:[]),z=Ro({name:(null==j?void 0:j.name)||"__unused__"}),$=Fo({name:(null==C?void 0:C.name)||"hover",fields:(null==C?void 0:C.fields)||[]}),B=j?{isActive:z.isActive,predicate:z.predicate}:null,L=void 0!==(null===(o=_[0])||void 0===o?void 0:o[y]),D=e.useMemo(()=>{if(L)return _;if(m){const e=_.reduce((e,t)=>{const o="function"==typeof m?m(t):t[m];if(!e[o]){const t={[y]:[]};"string"==typeof m&&(t[m]=o),e[o]=t}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:_}]},[_,m,y,L]),T=So(_,g,b),W=e.useMemo(()=>e=>{const t={},o=g?at(e,g,T):Eo;return t.fill=o,t.fillOpacity=k,w?(t.stroke=o,t.strokeWidth=A):t.stroke="none",t},[g,T,k,w,A]),R=e.useMemo(()=>$o(W,B,j),[W,B,j]),F=void 0!==S?S:D.length>1,H=e.useMemo(()=>{if(F&&g)return yo({data:D,colorBy:g,colorScale:T,getColor:at})},[F,g,D,T]),I=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),s);return H&&120>e.right&&(e.right=120),e},[s,H]),Y=e.useCallback(e=>{N&&$.onHover(e)},[N,$]),X=m||g,G=e.useMemo(()=>Ao([{label:c||wo(f),accessor:f,role:"x"},{label:u||wo(p),accessor:p,role:"y"},...X?[{label:wo(X),accessor:X,role:"group"}]:[]]),[f,p,c,u,X]),q=jo({componentName:"AreaChart",data:_,accessors:{xAccessor:f,yAccessor:p}});if(q)return v.createElement(Po,{componentName:"AreaChart",message:q,width:r,height:i});const V=e.useMemo(()=>L||m?D.flatMap(e=>{const t=e[y]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):_,[D,y,L,m,_]),U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:V,xAccessor:f,yAccessor:p,groupAccessor:m||void 0,curve:x,lineStyle:R,size:[r,i],margin:I,showAxes:!0,xLabel:c,yLabel:u,xFormat:d,yFormat:h,enableHover:E,showGrid:M},H&&{legend:H}),l&&{title:l}),a&&{className:a}),{tooltipContent:O?ko(O):G}),N&&{customHoverBehavior:Y}),P);return v.createElement(ie,Object.assign({},U))}function Go(t){var o;const{data:n,width:r=600,height:i=400,margin:s,className:a,title:l,xLabel:c,yLabel:u,xFormat:d,yFormat:h,xAccessor:f="x",yAccessor:p="y",areaBy:m,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,normalize:E=!1,enableHover:M=!0,showGrid:S=!1,showLegend:O,tooltip:P,frameProps:j={},selection:N,linkedHover:_}=t,C=n||[],z=Co(_,g?["string"==typeof g?g:""]:[]),$=Ro({name:(null==N?void 0:N.name)||"__unused__"}),B=Fo({name:(null==z?void 0:z.name)||"hover",fields:(null==z?void 0:z.fields)||[]}),L=N?{isActive:$.isActive,predicate:$.predicate}:null,D=void 0!==(null===(o=C[0])||void 0===o?void 0:o[y]),T=e.useMemo(()=>{if(D)return C;if(m){const e=C.reduce((e,t)=>{const o="function"==typeof m?m(t):t[m];if(!e[o]){const t={[y]:[]};"string"==typeof m&&(t[m]=o),e[o]=t}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:C}]},[C,m,y,D]),W=So(C,g,b),R=e.useMemo(()=>e=>{const t={},o=g?at(e,g,W):Eo;return t.fill=o,t.fillOpacity=k,w?(t.stroke=o,t.strokeWidth=A):t.stroke="none",t},[g,W,k,w,A]),F=e.useMemo(()=>$o(R,L,N),[R,L,N]),H=void 0!==O?O:T.length>1,I=e.useMemo(()=>{if(H&&g)return yo({data:T,colorBy:g,colorScale:W,getColor:at})},[H,g,T,W]),Y=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),s);return I&&120>e.right&&(e.right=120),e},[s,I]),X=e.useCallback(e=>{_&&B.onHover(e)},[_,B]),G=m||g,q=e.useMemo(()=>Ao([{label:c||wo(f),accessor:f,role:"x"},{label:u||wo(p),accessor:p,role:"y"},...G?[{label:wo(G),accessor:G,role:"group"}]:[]]),[f,p,c,u,G]),V=jo({componentName:"StackedAreaChart",data:C,accessors:{xAccessor:f,yAccessor:p}});if(V)return v.createElement(Po,{componentName:"StackedAreaChart",message:V,width:r,height:i});const U=e.useMemo(()=>D||m?T.flatMap(e=>{const t=e[y]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):C,[T,y,D,m,C]),K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:f,yAccessor:p,groupAccessor:m||void 0,curve:x,normalize:E,lineStyle:F,size:[r,i],margin:Y,showAxes:!0,xLabel:c,yLabel:u,xFormat:d,yFormat:h,enableHover:M,showGrid:S},I&&{legend:I}),l&&{title:l}),a&&{className:a}),{tooltipContent:P?ko(P):q}),_&&{customHoverBehavior:X}),j);return v.createElement(ie,Object.assign({},K))}function qo(t){const{data:o,width:r=600,height:i=400,margin:s={top:50,bottom:60,left:70,right:80},className:l,title:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:h="value",xLabel:f,yLabel:p,xFormat:m,yFormat:y,colorScheme:g="blues",customColorScale:b,showValues:x=!1,valueFormat:k,cellBorderColor:w="#fff",cellBorderWidth:A=1,enableHover:E=!0,tooltip:M,frameProps:S={},selection:O,linkedHover:P}=t,j=o||[],N=Co(P,[]),_=Ro({name:(null==O?void 0:O.name)||"__unused__"}),C=Fo({name:(null==N?void 0:N.name)||"hover",fields:(null==N?void 0:N.fields)||[]}),z=O?{isActive:_.isActive,predicate:_.predicate}:null,$=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),B=e.useMemo(()=>{const e=j.map($);return[Math.min(...e),Math.max(...e)]},[j,$]),L=e.useMemo(()=>"custom"===g&&b?b:n.scaleSequential({blues:a.interpolateBlues,reds:a.interpolateReds,greens:a.interpolateGreens,viridis:a.interpolateViridis}[g]||a.interpolateBlues).domain(B),[g,b,B]);e.useMemo(()=>{const e=Mo(u),t=Mo(d);return{xBinCount:new Set(j.map(e)).size,yBinCount:new Set(j.map(t)).size}},[j,u,d]),e.useMemo(()=>({coordinates:j}),[j]);const D=e.useMemo(()=>e=>{const t=$(e);return{fill:L(t),stroke:w,strokeWidth:A}},[$,L,w,A]);e.useMemo(()=>$o(D,z,O),[D,z,O]),e.useMemo(()=>{if(!x)return;const e=(B[0]+B[1])/2;return(t,o)=>{const n=$(t),r=k?k(n):n+"";return v.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:$(t)>e?"#fff":"#000",fontSize:"12px"},r)}},[x,$,k,B]);const T=e.useCallback(e=>{P&&C.onHover(e)},[P,C]),W=e.useMemo(()=>Ao([{label:f||wo(u),accessor:u,role:"x"},{label:p||wo(d),accessor:d,role:"y"},{label:wo(h),accessor:h,role:"value"}]),[u,d,f,p,h]),R=jo({componentName:"Heatmap",data:j,accessors:{xAccessor:u,yAccessor:d,valueAccessor:h}});if(R)return v.createElement(Po,{componentName:"Heatmap",message:R,width:r,height:i});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:j,xAccessor:u,yAccessor:d,valueAccessor:h,size:[r,i],margin:s,showAxes:!0,xLabel:f,yLabel:p,xFormat:m,yFormat:y,enableHover:E},c&&{title:c}),l&&{className:l}),{tooltipContent:M?ko(M):W}),P&&{customHoverBehavior:T}),S);return v.createElement(ie,Object.assign({},F))}function Vo(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,xLabel:l,yLabel:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:f="y",sizeBy:p,sizeRange:m=[5,40],colorBy:y,colorScheme:g="category10",bubbleOpacity:b=.6,bubbleStrokeWidth:x=1,bubbleStrokeColor:k="white",enableHover:w=!0,showGrid:A=!1,showLegend:E,tooltip:M,marginalGraphics:S,frameProps:O={},selection:P,linkedHover:j,linkedBrush:N}=t,_=o||[],C=Co(j,y?["string"==typeof y?y:""]:[]),z=zo(N),$=Ro({name:(null==P?void 0:P.name)||"__unused__"}),B=Fo({name:(null==C?void 0:C.name)||"hover",fields:(null==C?void 0:C.fields)||[]});Ho({name:(null==z?void 0:z.name)||"__unused_brush__",xField:(null==z?void 0:z.xField)||("string"==typeof h?h:void 0),yField:(null==z?void 0:z.yField)||("string"==typeof f?f:void 0)});const L=P?{isActive:$.isActive,predicate:$.predicate}:null,D=So(_,y,g),T=e.useMemo(()=>{const e=_.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[_,p]),W=e.useMemo(()=>e=>{const t={fillOpacity:b,strokeWidth:x,stroke:k};return t.fill=y?at(e,y,D):Eo,t.r=ct(e,p,m,T),t},[y,D,p,m,T,b,x,k]),R=e.useMemo(()=>$o(W,L,P),[W,L,P]),F=void 0!==E?E:!!y,H=e.useMemo(()=>{if(F&&y)return yo({data:_,colorBy:y,colorScale:D,getColor:at,strokeColor:k,strokeWidth:x})},[F,y,_,D,k,x]),I=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),i);return H&&120>e.right&&(e.right=120),e},[i,H]),Y=e.useCallback(e=>{j&&B.onHover(e)},[j,B]),X=e.useMemo(()=>Ao([{label:l||wo(h),accessor:h,role:"x"},{label:c||wo(f),accessor:f,role:"y"},{label:wo(p),accessor:p,role:"size"},...y?[{label:wo(y),accessor:y,role:"color"}]:[]]),[h,f,l,c,p,y]),G=jo({componentName:"BubbleChart",data:_,accessors:{xAccessor:h,yAccessor:f},requiredProps:{sizeBy:p}});if(G)return v.createElement(Po,{componentName:"BubbleChart",message:G,width:n,height:r});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:_,xAccessor:h,yAccessor:f,colorAccessor:y||void 0,sizeAccessor:p,sizeRange:m,pointStyle:R,colorScheme:g,size:[n,r],margin:I,showAxes:!0,xLabel:l,yLabel:c,xFormat:u,yFormat:d,enableHover:w,showGrid:A},H&&{legend:H}),a&&{title:a}),s&&{className:s}),{tooltipContent:M?ko(M):X}),j&&{customHoverBehavior:Y}),S&&{marginalGraphics:S}),O);return v.createElement(ie,Object.assign({},q))}function Uo({selections:t}){const o=Wo(e=>e.setResolution);return e.useEffect(()=>{for(const[e,n]of Object.entries(t))n.resolution&&o(e,n.resolution)},[]),null}function Ko({children:e,selections:t}){return v.createElement(To,null,t&&v.createElement(Uo,{selections:t}),e)}Io.displayName="Scatterplot",Yo.displayName="LineChart",Xo.displayName="AreaChart",Go.displayName="StackedAreaChart",qo.displayName="Heatmap",Vo.displayName="BubbleChart";const Zo="__splomIdx",Jo={top:4,bottom:4,left:4,right:4};function Qo({frameRef:n,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-Jo.left-Jo.right,l=r-Jo.top-Jo.bottom;return e.useEffect(()=>{if(!s.current)return;const e=o.select(s.current).select(".brush-g"),r=t.brush().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const o=null===(t=n.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[o.x.invert(r),o.y.invert(s)],[o.x.invert(a),o.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[a,l,n,i]),v.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},v.createElement("g",{className:"brush-g",transform:`translate(${Jo.left},${Jo.top})`}))}function en({data:t,xField:o,yField:n,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:h,onPointHover:f}){const p=e.useRef(null),m=Ro({name:c,clientId:`splom-${o}-${n}`}),y=Ho({name:c,xField:o,yField:n}),g=Ro({name:u,clientId:"splom-hover-source"}),b=g.selectPoints,x=e.useCallback(e=>{e?y.brushInteraction.during(e):y.brushInteraction.end(null)},[y.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==f||f(null));const t=e.data,o=null==t?void 0:t[Zo];void 0!==o&&(b({[Zo]:[o]}),null==f||f(t,e.x+Jo.left,e.y+Jo.top))},[b,f]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?at(e,a,l):Eo,"hover"===h?g.isActive&&g.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):g.isActive&&(t.opacity=.6*s):m.isActive&&!m.predicate(e)&&(t.opacity=d),t},[a,l,s,i,h,m.isActive,m.predicate,g.isActive,g.predicate,d]);return v.createElement("div",{style:{position:"relative",width:r,height:r}},v.createElement(ie,{ref:p,chartType:"scatter",data:t,size:[r,r],xAccessor:o,yAccessor:n,pointStyle:w,margin:Jo,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&v.createElement(Qo,{frameRef:p,cellSize:r,xField:o,yField:n,onBrush:x}))}function tn({data:t,field:o,label:n,cellSize:r,bins:i,brushSelectionName:s,hoverSelectionName:a,mode:l}){const c=Ro({name:s,clientId:"splom-diag-"+o}),u=Ro({name:a,clientId:`splom-diag-${o}-hover`}),d="hover"===l?u:c,h=d.isActive,f=d.predicate,p=e.useMemo(()=>{const e=t.map(e=>e[o]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const n=Math.min(...e),s=(Math.max(...e)-n)/i||1,a=Array(i).fill(0),l=Array(i).fill(0);for(const e of t){const t=e[o];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-n)/s),i-1);a[r]++,h&&!f(e)||l[r]++}const c=Math.max(...a,1);return{bars:a.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),selectedBars:l.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),max:c}},[t,o,i,r,h,f]);return v.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},v.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},n),p.bars.map((e,t)=>v.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:h?.3:.6})),h&&p.selectedBars.map((e,t)=>v.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Eo,opacity:.7})))}function on({label:e,cellSize:t}){return v.createElement("svg",{width:t,height:t},v.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function nn(t){const{data:o,fields:n,fieldLabels:r={},colorBy:i,colorScheme:s="category10",cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:h=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:m=.1,showGrid:y=!1,tooltip:g,showLegend:b,idAccessor:x,className:k}=t,w="splom",A="splom-hover",E=p?"hover":f?"brush":"hover",M=Wo(e=>e.clearSelection),[S,O]=e.useState(null),P=e.useCallback(()=>{M(A),O(null)},[M,A]),j=e.useMemo(()=>(o||[]).map((e,t)=>void 0!==e[Zo]?e:Object.assign(Object.assign({},e),{[Zo]:t})),[o]),N=So(j,i,s),_=void 0!==b?b:!!i,C=e.useMemo(()=>{if(!_||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(j.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):Eo})):null},[_,i,j,N]),z=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+n.map(()=>a+"px").join(" "),gridTemplateRows:n.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[n,a,l,40]);return v.createElement("div",{className:k,style:{position:"relative"}},C&&v.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},C.map(e=>v.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},v.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),v.createElement("span",{style:{fontSize:11}},e.label)))),v.createElement("div",{style:z,onMouseLeave:"hover"===E?P:void 0},n.map((e,t)=>v.createElement(v.Fragment,{key:"row-"+e},v.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),n.map((o,n)=>t===n?"label"===d?v.createElement(on,{key:"diag-"+e,label:r[e]||e,cellSize:a}):v.createElement(tn,{key:"diag-"+e,data:j,field:e,label:r[e]||e,cellSize:a,bins:h,colorBy:i,colorScale:N,brushSelectionName:w,hoverSelectionName:A,unselectedOpacity:m,mode:E}):v.createElement(en,{key:`cell-${e}-${o}`,data:j,xField:o,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:N,brushSelectionName:w,hoverSelectionName:A,unselectedOpacity:m,showGrid:y,tooltip:g,mode:E,onPointHover:"hover"===E?(r,i,s)=>{O(r?{datum:r,xField:o,yField:e,colIndex:n,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}:null)}:void 0})))),v.createElement("div",null)," ",n.map(e=>v.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),S&&"hover"===E&&(()=>{const e=S.datum,t=r[S.xField]||S.xField,o=r[S.yField]||S.yField,n=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[Zo];return v.createElement("div",{style:{position:"absolute",left:40+S.colIndex*(a+l)+S.px,top:S.rowIndex*(a+l)+S.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},v.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),v.createElement("div",null,t,": ",null!=e[S.xField]?Number(e[S.xField]).toFixed(1):"–"),v.createElement("div",null,o,": ",null!=e[S.yField]?Number(e[S.yField]).toFixed(1):"–"),null!=n&&v.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",n+""))})())}function rn(e){const{brushMode:t="crossfilter",hoverMode:o=!0}=e,n={};return!o&&t&&(n.splom={resolution:t}),o&&(n["splom-hover"]={resolution:"union"}),v.createElement(Ko,{selections:n},v.createElement(nn,Object.assign({},e)))}function sn({width:n,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),h=e.useRef(!1),f=n+i.left+i.right,p=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=o.select(u.current).select(".brush-group"),i="x"===a?t.brushX().extent([[0,0],[n,r]]):t.brushY().extent([[0,0],[n,r]]);return i.on("brush end",e=>{if(h.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const o=("x"===a?s.x:s.y).invert;if(!o)return;const n=[o(t[0]),o(t[1])];c(n)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,n,r,a,c]),e.useEffect(()=>{if(!d.current||!s||!u.current)return;const e=o.select(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(h.current=!0,l){const o=[t(l[0]),t(l[1])];e.call(d.current.move,o)}else e.call(d.current.move,null);h.current=!1},[l,s,a]),v.createElement("svg",{ref:u,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},v.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function an(t){var o,n;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,xLabel:u,yLabel:d,xFormat:h,yFormat:f,xAccessor:p="x",yAccessor:m="y",lineBy:y,lineDataAccessor:g="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:M=!1,pointRadius:S=3,enableHover:O=!0,showGrid:P=!1,showLegend:j,tooltip:N,minimap:_={},renderBefore:C=!1,onBrush:z,brushExtent:$,frameProps:B={}}=t,L=r||[],[D,T]=e.useState(null),W=null!=$?$:D,R=e.useCallback(e=>{$||T(e),null==z||z(e)},[$,z]),F=e.useRef(null),[H,I]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,o;const n=null===(o=null===(t=F.current)||void 0===t?void 0:t.getScales)||void 0===o?void 0:o.call(t);n?I(n):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const Y=void 0!==(null===(o=L[0])||void 0===o?void 0:o[g]),X=e.useMemo(()=>{if(Y)return L;if(y){const e=L.reduce((e,t)=>{const o="function"==typeof y?y(t):t[y];if(!e[o]){const t={[g]:[]};"string"==typeof y&&(t[y]=o),e[o]=t}return e[o][g].push(t),e},{});return Object.values(e)}return[{[g]:L}]},[L,y,g,Y]),G=e.useMemo(()=>Y||y?X.flatMap(e=>{const t=e[g]||[];return y&&"string"==typeof y?t.map(t=>Object.assign(Object.assign({},t),{[y]:e[y]})):t}):L,[X,g,Y,y,L]),q=So(L,b,x),V=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?at(e,b,q):Eo,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[b,q,w,A,E]),U=e.useMemo(()=>_.lineStyle?_.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?at(e,b,q):Eo,t},[b,q,_.lineStyle]),K=e.useMemo(()=>{if(M)return e=>{const t={r:S,fillOpacity:1};return t.fill=b?at(e.parentLine||e,b,q):Eo,t}},[M,S,b,q]),Z=void 0!==j?j:X.length>1,J=e.useMemo(()=>{if(Z&&b)return yo({data:X,colorBy:b,colorScale:q,getColor:at})},[Z,b,X,q]),Q=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),a);return J&&120>e.right&&(e.right=120),e},[a,J]),ee=_.height||60,te=e.useMemo(()=>{var e,t,o,n,r,i,s,a;return{top:null!==(t=null===(e=_.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=_.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(i=null===(r=_.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:Q.left,right:null!==(a=null===(s=_.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:Q.right}},[_.margin,Q]),oe=_.brushDirection||"x",ne=jo({componentName:"MinimapChart",data:L,accessors:{xAccessor:p,yAccessor:m}});if(ne)return v.createElement(Po,{componentName:"MinimapChart",message:ne,width:i,height:s});const re=A?"area":"line",se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:re,data:G,xAccessor:p,yAccessor:m,groupAccessor:y||void 0,curve:k,lineStyle:V},M&&{pointStyle:K}),{size:[i,s],margin:Q,showAxes:!0,xLabel:u,yLabel:d,xFormat:h,yFormat:f,enableHover:O,showGrid:P}),J&&{legend:J}),c&&{title:c}),N&&{tooltipContent:ko(N)}),W&&{xExtent:W}),B),ae={chartType:re,data:G,xAccessor:p,yAccessor:m,groupAccessor:y||void 0,curve:k,lineStyle:U,size:[i,ee+te.top+te.bottom],margin:te,showAxes:null!==(n=_.showAxes)&&void 0!==n&&n,background:_.background,enableHover:!1},le=v.createElement("div",{key:"minimap",style:{position:"relative",width:i}},v.createElement(ie,Object.assign({ref:F},ae)),v.createElement(sn,{width:i-te.left-te.right,height:ee,margin:te,scales:H,brushDirection:oe,extent:W,onBrush:R})),ce=v.createElement("div",{key:"main"},v.createElement(ie,Object.assign({},se)));return v.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},C?le:ce,C?ce:le)}function ln(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",categoryLabel:d,valueLabel:h,valueFormat:f,colorBy:p,colorScheme:m="category10",sort:y=!1,barPadding:g=5,enableHover:b=!0,showGrid:x=!1,showLegend:k,tooltip:w,frameProps:A={},selection:E,linkedHover:M}=t,S=o||[],O=Co(M,p?["string"==typeof p?p:""]:[]),P=Ro({name:(null==E?void 0:E.name)||"__unused__"}),j=Fo({name:(null==O?void 0:O.name)||"hover",fields:(null==O?void 0:O.fields)||[]}),N=E?{isActive:P.isActive,predicate:P.predicate}:null,_=Oo(S,y,c),C=So(S,p,m),z=e.useMemo(()=>e=>{const t={};return t.fill=p?at(e,p,C):Eo,t},[p,C]),$=e.useMemo(()=>$o(z,N,E),[z,N,E]),B=void 0!==k?k:!!p,L=e.useMemo(()=>{if(B&&p)return yo({data:_,colorBy:p,colorScale:C,getColor:at})},[B,p,_,C]),D=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return L&&120>e.right&&(e.right=120),e},[i,L]),T=e.useCallback(e=>{M&&j.onHover(e?e.data||e:null)},[M,j]),W=e.useMemo(()=>{const e=p&&p!==l;return t=>{const o=t.data||t,n="function"==typeof l?l(o):o[l],r="function"==typeof c?c(o):o[c],i=e?"function"==typeof p?p(o):o[p]:null;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},n+""),v.createElement("div",{style:{marginTop:"4px"}},"number"==typeof r?r.toLocaleString():r+""),null!=i&&v.createElement("div",{style:{marginTop:"2px",opacity:.8}},"string"==typeof p?p:"group",": ",i+""))}},[l,c,p]),R=jo({componentName:"BarChart",data:S,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return v.createElement(Po,{componentName:"BarChart",message:R,width:n,height:r});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:_,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:$,size:[n,r],margin:D,barPadding:g,enableHover:b,showAxes:!0,oLabel:d,rLabel:h,rFormat:f,showGrid:x,oSort:y},L&&{legend:L}),a&&{title:a}),s&&{className:s}),{tooltipContent:w?ko(w):W}),M&&{customHoverBehavior:T}),A);return v.createElement(Ee,Object.assign({},F))}function cn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",stackBy:c,valueAccessor:u="value",orientation:d="vertical",categoryLabel:h,valueLabel:f,valueFormat:p,colorBy:m,colorScheme:y="category10",normalize:g=!1,barPadding:b=5,enableHover:x=!0,showGrid:k=!1,showLegend:w=!0,tooltip:A,frameProps:E={},selection:M,linkedHover:S}=t,O=o||[],P=m||c,j=Co(S,P?["string"==typeof P?P:""]:[]),N=Ro({name:(null==M?void 0:M.name)||"__unused__"}),_=Fo({name:(null==j?void 0:j.name)||"hover",fields:(null==j?void 0:j.fields)||[]}),C=M?{isActive:N.isActive,predicate:N.predicate}:null,z=So(O,P,y),$=e.useMemo(()=>e=>P?{fill:at(e,P,z)}:{fill:Eo},[P,z]),B=e.useMemo(()=>$o($,C,M),[$,C,M]),L=e.useMemo(()=>{if(w)return yo({data:O,colorBy:P,colorScale:z,getColor:at})},[w,O,P,z]),D=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:120},i);return L&&120>e.right&&(e.right=120),e},[i,L]),T=e.useCallback(e=>{S&&_.onHover(e)},[S,_]),W=e.useMemo(()=>{const e=Mo(c),t=Mo(l),o=Mo(u);return n=>{const r=n.data||n;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},e(r)+""),v.createElement("div",{style:{marginTop:"4px"}},t(r)+""," · ",Number(o(r)).toLocaleString()))}},[c,l,u]),R=jo({componentName:"StackedBarChart",data:O,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{stackBy:c}});if(R)return v.createElement(Po,{componentName:"StackedBarChart",message:R,width:n,height:r});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:O,oAccessor:l,rAccessor:u,stackBy:c,normalize:g,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:B,size:[n,r],margin:D,barPadding:b,enableHover:x,showAxes:!0,oLabel:h,rLabel:f,rFormat:p,showGrid:k},L&&{legend:L}),a&&{title:a}),s&&{className:s}),{tooltipContent:A?ko(A):W}),S&&{customHoverBehavior:T}),E);return v.createElement(Ee,Object.assign({},F))}function un(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",categoryLabel:d,valueLabel:h,valueFormat:f,colorBy:p,colorScheme:m="category10",sizeBy:y,sizeRange:g=[3,8],pointRadius:b=4,pointOpacity:x=.7,categoryPadding:k=20,enableHover:w=!0,showGrid:A=!1,showLegend:E,tooltip:M,frameProps:S={},selection:O,linkedHover:P}=t,j=o||[],N=Co(P,p?["string"==typeof p?p:""]:["string"==typeof l?l:""]),_=Ro({name:(null==O?void 0:O.name)||"__unused__"}),C=Fo({name:(null==N?void 0:N.name)||"hover",fields:(null==N?void 0:N.fields)||[]}),z=O?{isActive:_.isActive,predicate:_.predicate}:null,$=So(j,p,m),B=e.useMemo(()=>{if(!y)return;const e=j.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[j,y]),L=e.useMemo(()=>e=>{const t={fillOpacity:x};return t.fill=p?at(e,p,$):Eo,t.r=y?ct(e,y,g,B):b,t},[p,$,y,g,B,b,x]),D=e.useMemo(()=>$o(L,z,O),[L,z,O]),T=void 0!==E?E:!!p,W=e.useMemo(()=>{if(T&&p)return yo({data:j,colorBy:p,colorScale:$,getColor:at})},[T,p,j,$]),R=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return W&&120>e.right&&(e.right=120),e},[i,W]),F=e.useCallback(e=>{P&&C.onHover(e)},[P,C]),H=e.useMemo(()=>{const e=Mo(c),t=Mo(l);return o=>{const n=o.data||o,r=t(n),i=e(n),s=p?"function"==typeof p?p(n):n[p]:null,a=y?"function"==typeof y?y(n):n[y]:null;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},r+""),v.createElement("div",{style:{marginTop:"4px"}},"number"==typeof i?i.toLocaleString():i+""),null!=s&&v.createElement("div",{style:{marginTop:"2px",opacity:.8}},"string"==typeof p?p:"color",": ",s+""),null!=a&&v.createElement("div",{style:{marginTop:"2px",opacity:.8}},"string"==typeof y?y:"size",": ","number"==typeof a?a.toLocaleString():a+""))}},[l,c,p,y]),I=jo({componentName:"SwarmPlot",data:j,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return v.createElement(Po,{componentName:"SwarmPlot",message:I,width:n,height:r});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:j,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:D,size:[n,r],margin:R,barPadding:k,enableHover:w,showAxes:!0,oLabel:d,rLabel:h,rFormat:f,showGrid:A},W&&{legend:W}),a&&{title:a}),s&&{className:s}),{tooltipContent:M?ko(M):H}),P&&{customHoverBehavior:F}),S);return v.createElement(Ee,Object.assign({},Y))}function dn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",categoryLabel:d,valueLabel:h,valueFormat:f,colorBy:p,colorScheme:m="category10",showOutliers:y=!0,categoryPadding:g=20,enableHover:b=!0,showGrid:x=!1,showLegend:k,tooltip:w,frameProps:A={},selection:E,linkedHover:M}=t,S=o||[],O=Co(M,p?["string"==typeof p?p:""]:["string"==typeof l?l:""]),P=Ro({name:(null==E?void 0:E.name)||"__unused__"}),j=Fo({name:(null==O?void 0:O.name)||"hover",fields:(null==O?void 0:O.fields)||[]}),N=E?{isActive:P.isActive,predicate:P.predicate}:null,_=So(S,p,m),C=e.useMemo(()=>e=>{const t=p?at(e,p,_):Eo;return{fill:t,stroke:t,fillOpacity:.8}},[p,_]),z=e.useMemo(()=>$o(C,N,E),[C,N,E]),$=void 0!==k?k:!!p,B=e.useMemo(()=>{if($&&p)return yo({data:S,colorBy:p,colorScale:_,getColor:at})},[$,p,S,_]),L=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return B&&120>e.right&&(e.right=120),e},[i,B]),D=e.useCallback(e=>{M&&j.onHover(e)},[M,j]),T=e.useMemo(()=>e=>{const t=e.data||e,o=t.stats||{};return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(t.category||e.category||"")+""),null!=o.median&&v.createElement(v.Fragment,null,v.createElement("div",null,"Median: ",o.median.toLocaleString()),v.createElement("div",null,"Q1: ",o.q1.toLocaleString()),v.createElement("div",null,"Q3: ",o.q3.toLocaleString()),v.createElement("div",null,"Min: ",o.min.toLocaleString()),v.createElement("div",null,"Max: ",o.max.toLocaleString())))},[]),W=jo({componentName:"BoxPlot",data:S,accessors:{categoryAccessor:l,valueAccessor:c}});if(W)return v.createElement(Po,{componentName:"BoxPlot",message:W,width:n,height:r});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:S,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:z,showOutliers:y,size:[n,r],margin:L,barPadding:g,enableHover:b,showAxes:!0,oLabel:d,rLabel:h,rFormat:f,showGrid:x},B&&{legend:B}),a&&{title:a}),s&&{className:s}),{tooltipContent:w?ko(w):T}),M&&{customHoverBehavior:D}),A);return v.createElement(Ee,Object.assign({},R))}function hn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",bins:u=25,relative:d=!1,categoryLabel:h,valueLabel:f,valueFormat:p,colorBy:m,colorScheme:y="category10",categoryPadding:g=20,enableHover:b=!0,showGrid:x=!1,showLegend:k,tooltip:w,frameProps:A={},selection:E,linkedHover:M}=t,S=o||[],O=Co(M,m?["string"==typeof m?m:""]:["string"==typeof l?l:""]),P=Ro({name:(null==E?void 0:E.name)||"__unused__"}),j=Fo({name:(null==O?void 0:O.name)||"hover",fields:(null==O?void 0:O.fields)||[]}),N=E?{isActive:P.isActive,predicate:P.predicate}:null,_=So(S,m,y),C=e.useMemo(()=>e=>{const t=m?at(e,m,_):Eo;return{fill:t,stroke:t,fillOpacity:.8}},[m,_]),z=e.useMemo(()=>$o(C,N,E),[C,N,E]),$=void 0!==k?k:!!m,B=e.useMemo(()=>{if($&&m)return yo({data:S,colorBy:m,colorScale:_,getColor:at})},[$,m,S,_]),L=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return B&&120>e.right&&(e.right=120),e},[i,B]),D=e.useCallback(e=>{M&&j.onHover(e)},[M,j]),T=e.useMemo(()=>e=>{const t=e.data||e,o=t.category||e.category||"",n=t.count,r=t.range;return v.createElement("div",{className:"semiotic-tooltip",style:go},o&&v.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=n&&v.createElement("div",null,"Count: ",n),r&&2===r.length&&v.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),W=jo({componentName:"Histogram",data:S,accessors:{categoryAccessor:l,valueAccessor:c}});if(W)return v.createElement(Po,{componentName:"Histogram",message:W,width:n,height:r});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:S,oAccessor:l,rAccessor:c,projection:"horizontal",summaryStyle:z,bins:u,normalize:d,size:[n,r],margin:L,barPadding:g,enableHover:b,showAxes:!0,oLabel:h,rLabel:f,rFormat:p,showGrid:x},B&&{legend:B}),a&&{title:a}),s&&{className:s}),{tooltipContent:w?ko(w):T}),M&&{customHoverBehavior:D}),A);return v.createElement(Ee,Object.assign({},R))}function fn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",bins:d=25,showIQR:h=!0,categoryLabel:f,valueLabel:p,valueFormat:m,colorBy:y,colorScheme:g="category10",categoryPadding:b=20,enableHover:x=!0,showGrid:k=!1,showLegend:w,tooltip:A,frameProps:E={},selection:M,linkedHover:S}=t,O=o||[],P=Co(S,y?["string"==typeof y?y:""]:["string"==typeof l?l:""]),j=Ro({name:(null==M?void 0:M.name)||"__unused__"}),N=Fo({name:(null==P?void 0:P.name)||"hover",fields:(null==P?void 0:P.fields)||[]}),_=M?{isActive:j.isActive,predicate:j.predicate}:null,C=So(O,y,g),z=e.useMemo(()=>e=>{const t=y?at(e,y,C):Eo;return{fill:t,stroke:t,fillOpacity:.6}},[y,C]),$=e.useMemo(()=>$o(z,_,M),[z,_,M]),B=void 0!==w?w:!!y,L=e.useMemo(()=>{if(B&&y)return yo({data:O,colorBy:y,colorScale:C,getColor:at})},[B,y,O,C]),D=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return L&&120>e.right&&(e.right=120),e},[i,L]),T=e.useCallback(e=>{S&&N.onHover(e)},[S,N]),W=e.useMemo(()=>e=>{const t=e.data||e,o=t.category||e.category||"",n=(Array.isArray(t)?t:[]).map(e=>{const t="function"==typeof c?c(e):e[c];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),r=n.length,i=r>0?n[Math.floor(r/2)]:null;return v.createElement("div",{className:"semiotic-tooltip",style:go},o&&v.createElement("div",{style:{fontWeight:"bold"}},o+""),r>0&&v.createElement("div",null,"n = ",r),null!=i&&v.createElement("div",null,"Median: ",i.toLocaleString()))},[c]),R=jo({componentName:"ViolinPlot",data:O,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return v.createElement(Po,{componentName:"ViolinPlot",message:R,width:n,height:r});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:O,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:$,bins:d,showIQR:h,size:[n,r],margin:D,barPadding:b,enableHover:x,showAxes:!0,oLabel:f,rLabel:p,rFormat:m,showGrid:k},L&&{legend:L}),a&&{title:a}),s&&{className:s}),{tooltipContent:A?ko(A):W}),S&&{customHoverBehavior:T}),E);return v.createElement(Ee,Object.assign({},F))}function pn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",bins:d=20,amplitude:h=1.5,categoryLabel:f,valueLabel:p,valueFormat:m,colorBy:y,colorScheme:g="category10",categoryPadding:b=5,enableHover:x=!0,showGrid:k=!1,showLegend:w,tooltip:A,frameProps:E={},selection:M,linkedHover:S}=t,O=o||[],P=Co(S,y?["string"==typeof y?y:""]:["string"==typeof l?l:""]),j=Ro({name:(null==M?void 0:M.name)||"__unused__"}),N=Fo({name:(null==P?void 0:P.name)||"hover",fields:(null==P?void 0:P.fields)||[]}),_=M?{isActive:j.isActive,predicate:j.predicate}:null,C=So(O,y,g),z=e.useMemo(()=>e=>{const t=y?at(e,y,C):Eo;return{fill:t,stroke:t,fillOpacity:.5}},[y,C]),$=e.useMemo(()=>$o(z,_,M),[z,_,M]),B=void 0!==w?w:!!y,L=e.useMemo(()=>{if(B&&y)return yo({data:O,colorBy:y,colorScale:C,getColor:at})},[B,y,O,C]),D=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:"horizontal"===u?120:70,right:40},i);return L&&120>e.right&&(e.right=120),e},[i,L,u]),T=e.useCallback(e=>{S&&N.onHover(e)},[S,N]),W=e.useMemo(()=>e=>v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},((e.data||e).category||e.category||"")+"")),[]),R=jo({componentName:"RidgelinePlot",data:O,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return v.createElement(Po,{componentName:"RidgelinePlot",message:R,width:n,height:r});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:O,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:$,bins:d,size:[n,r],margin:D,barPadding:b,enableHover:x,showAxes:!0,oLabel:f,rLabel:p,rFormat:m,showGrid:k,oSort:!1},L&&{legend:L}),a&&{title:a}),s&&{className:s}),{tooltipContent:A?ko(A):W}),S&&{customHoverBehavior:T}),E);return F.amplitude=h,v.createElement(Ee,Object.assign({},F))}function mn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",categoryLabel:d,valueLabel:h,valueFormat:f,colorBy:p,colorScheme:m="category10",sort:y=!0,dotRadius:g=5,categoryPadding:b=10,enableHover:x=!0,showGrid:k=!0,showLegend:w,tooltip:A,frameProps:E={},selection:M,linkedHover:S}=t,O=o||[],P=Co(S,p?["string"==typeof p?p:""]:["string"==typeof l?l:""]),j=Ro({name:(null==M?void 0:M.name)||"__unused__"}),N=Fo({name:(null==P?void 0:P.name)||"hover",fields:(null==P?void 0:P.fields)||[]}),_=M?{isActive:j.isActive,predicate:j.predicate}:null,C=Oo(O,y,c),z=So(O,p,m),$=e.useMemo(()=>e=>{const t={r:g,fillOpacity:.8};return t.fill=p?at(e,p,z):Eo,t},[p,z,g]),B=e.useMemo(()=>$o($,_,M),[$,_,M]),L=void 0!==w?w:!!p,D=e.useMemo(()=>{if(L&&p)return yo({data:C,colorBy:p,colorScale:z,getColor:at})},[L,p,C,z]),T=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:120,right:40},i);return D&&120>e.right&&(e.right=120),e},[i,D]),W=e.useCallback(e=>{S&&N.onHover(e)},[S,N]),R=e.useMemo(()=>e=>{const t=e.data||e,o="function"==typeof l?l(t):t[l],n="function"==typeof c?c(t):t[c];return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},o+""),v.createElement("div",{style:{marginTop:"4px"}},"number"==typeof n?n.toLocaleString():n+""))},[l,c]),F=jo({componentName:"DotPlot",data:O,accessors:{categoryAccessor:l,valueAccessor:c}});if(F)return v.createElement(Po,{componentName:"DotPlot",message:F,width:n,height:r});const H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:C,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:B,size:[n,r],margin:T,barPadding:b,enableHover:x,showAxes:!0,oLabel:d,rLabel:h,rFormat:f,showGrid:k,oSort:y},D&&{legend:D}),a&&{title:a}),s&&{className:s}),{tooltipContent:A?ko(A):R}),S&&{customHoverBehavior:W}),E);return v.createElement(Ee,Object.assign({},H))}function yn(t){const{data:o,width:n=400,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",colorBy:u,colorScheme:d="category10",startAngle:h=0,enableHover:f=!0,showLegend:p=!0,tooltip:m,frameProps:y={},selection:g,linkedHover:b}=t,x=o||[],k=u||l,w=Co(b,k?["string"==typeof k?k:""]:[]),A=Ro({name:(null==g?void 0:g.name)||"__unused__"}),E=Fo({name:(null==w?void 0:w.name)||"hover",fields:(null==w?void 0:w.fields)||[]}),M=g?{isActive:A.isActive,predicate:A.predicate}:null,S=So(x,k,d),O=e.useMemo(()=>e=>k?{fill:at(e,k,S)}:{fill:Eo},[k,S]),P=e.useMemo(()=>$o(O,M,g),[O,M,g]),j=e.useMemo(()=>{if(p)return yo({data:x,colorBy:k,colorScale:S,getColor:at})},[p,x,k,S]),N=e.useMemo(()=>{const e=Object.assign({top:20,bottom:20,left:20,right:20},i);return j&&120>e.right&&(e.right=120),e},[i,j]),_=e.useCallback(e=>{b&&E.onHover(e)},[b,E]),C=e.useMemo(()=>{const e=u&&u!==l;return t=>{var o;const n=(null===(o=t.data)||void 0===o?void 0:o[0])||t.data||t,r="function"==typeof l?l(n):n[l],i="function"==typeof c?c(n):n[c],s=e?"function"==typeof u?u(n):n[u]:null;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},r+""),v.createElement("div",{style:{marginTop:"4px"}},"number"==typeof i?i.toLocaleString():i+""),null!=s&&v.createElement("div",{style:{marginTop:"2px",opacity:.8}},"string"==typeof u?u:"group",": ",s+""))}},[l,c,u]),z=jo({componentName:"PieChart",data:x,accessors:{categoryAccessor:l,valueAccessor:c}});if(z)return v.createElement(Po,{componentName:"PieChart",message:z,width:n,height:r});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:x,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:P,startAngle:h,size:[n,r],margin:N,enableHover:f,showAxes:!1},j&&{legend:j}),a&&{title:a}),s&&{className:s}),{tooltipContent:m?ko(m):C}),b&&{customHoverBehavior:_}),y);return v.createElement(Ee,Object.assign({},$))}function gn(t){const{data:o,width:n=400,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",valueAccessor:c="value",innerRadius:u=60,centerContent:d,colorBy:h,colorScheme:f="category10",startAngle:p=0,enableHover:m=!0,showLegend:y=!0,tooltip:g,frameProps:b={},selection:x,linkedHover:k}=t,w=o||[],A=h||l,E=Co(k,A?["string"==typeof A?A:""]:[]),M=Ro({name:(null==x?void 0:x.name)||"__unused__"}),S=Fo({name:(null==E?void 0:E.name)||"hover",fields:(null==E?void 0:E.fields)||[]}),O=x?{isActive:M.isActive,predicate:M.predicate}:null,P=So(w,A,f),j=e.useMemo(()=>e=>A?{fill:at(e,A,P)}:{fill:Eo},[A,P]),N=e.useMemo(()=>$o(j,O,x),[j,O,x]),_=e.useMemo(()=>{if(y)return yo({data:w,colorBy:A,colorScale:P,getColor:at})},[y,w,A,P]),C=e.useMemo(()=>{const e=Object.assign({top:20,bottom:20,left:20,right:20},i);return _&&120>e.right&&(e.right=120),e},[i,_]),z=e.useCallback(e=>{k&&S.onHover(e)},[k,S]),$=e.useMemo(()=>{const e=h&&h!==l;return t=>{var o;const n=(null===(o=t.data)||void 0===o?void 0:o[0])||t.data||t,r="function"==typeof l?l(n):n[l],i="function"==typeof c?c(n):n[c],s=e?"function"==typeof h?h(n):n[h]:null;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},r+""),v.createElement("div",{style:{marginTop:"4px"}},"number"==typeof i?i.toLocaleString():i+""),null!=s&&v.createElement("div",{style:{marginTop:"2px",opacity:.8}},"string"==typeof h?h:"group",": ",s+""))}},[l,c,h]),B=jo({componentName:"DonutChart",data:w,accessors:{categoryAccessor:l,valueAccessor:c}});if(B)return v.createElement(Po,{componentName:"DonutChart",message:B,width:n,height:r});const L=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:w,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:N,innerRadius:u,startAngle:p,centerContent:d,size:[n,r],margin:C,enableHover:m,showAxes:!1},_&&{legend:_}),a&&{title:a}),s&&{className:s}),{tooltipContent:g?ko(g):$}),k&&{customHoverBehavior:z}),b);return v.createElement(Ee,Object.assign({},L))}function vn(t){const{data:o,width:n=600,height:r=400,margin:i,className:s,title:a,categoryAccessor:l="category",groupBy:c,valueAccessor:u="value",orientation:d="vertical",categoryLabel:h,valueLabel:f,valueFormat:p,colorBy:m,colorScheme:y="category10",barPadding:g=5,enableHover:b=!0,showGrid:x=!1,showLegend:k=!0,tooltip:w,frameProps:A={},selection:E,linkedHover:M}=t,S=o||[],O=m||c,P=Co(M,O?["string"==typeof O?O:""]:[]),j=Ro({name:(null==E?void 0:E.name)||"__unused__"}),N=Fo({name:(null==P?void 0:P.name)||"hover",fields:(null==P?void 0:P.fields)||[]}),_=E?{isActive:j.isActive,predicate:j.predicate}:null,C=So(S,O,y),z=e.useMemo(()=>e=>O?{fill:at(e,O,C)}:{fill:Eo},[O,C]),$=e.useMemo(()=>$o(z,_,E),[z,_,E]),B=e.useMemo(()=>{if(k)return yo({data:S,colorBy:O,colorScale:C,getColor:at})},[k,S,O,C]),L=e.useMemo(()=>{const e=Object.assign({top:50,bottom:60,left:70,right:40},i);return B&&120>e.right&&(e.right=120),e},[i,B]),D=e.useCallback(e=>{M&&N.onHover(e)},[M,N]),T=e.useMemo(()=>{const e=Mo(c),t=Mo(l),o=Mo(u);return n=>{const r=n.data||n;return v.createElement("div",{className:"semiotic-tooltip",style:go},v.createElement("div",{style:{fontWeight:"bold"}},e(r)+""),v.createElement("div",{style:{marginTop:"4px"}},t(r)+""," · ",Number(o(r)).toLocaleString()))}},[c,l,u]),W=jo({componentName:"GroupedBarChart",data:S,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{groupBy:c}});if(W)return v.createElement(Po,{componentName:"GroupedBarChart",message:W,width:n,height:r});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:S,oAccessor:l,rAccessor:u,groupBy:c,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:$,size:[n,r],margin:L,barPadding:g,enableHover:b,showAxes:!0,oLabel:h,rLabel:f,rFormat:p,showGrid:x},B&&{legend:B}),a&&{title:a}),s&&{className:s}),{tooltipContent:w?ko(w):T}),M&&{customHoverBehavior:D}),A);return v.createElement(Ee,Object.assign({},R))}function bn(t){const{nodes:o,edges:n,width:r=600,height:i=600,margin:s,className:a,title:l,nodeIDAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:p="category10",nodeSize:m=8,nodeSizeRange:y=[5,20],edgeWidth:g=1,edgeColor:b="#999",edgeOpacity:x=.6,iterations:k=300,forceStrength:w=.1,showLabels:A=!1,enableHover:E=!0,showLegend:M,tooltip:S,frameProps:O={}}=t,P=o||[],j=n||[],N=So(P,f,p),_=e.useMemo(()=>e=>{const t={};return t.fill=f?at(e.data||e,f,N):Eo,"number"==typeof m&&(t.r=m),t},[f,N,m]),C=e.useMemo(()=>e=>({stroke:b,strokeWidth:"number"==typeof g?g:"function"==typeof g?g(e):e[g]||1,opacity:x}),[g,b,x]),z=e.useMemo(()=>{if(A&&h)return"function"==typeof h?h:e=>e[h]},[A,h]),$=void 0!==M?M:!!f,B=e.useMemo(()=>{if($&&f)return yo({data:P,colorBy:f,colorScale:N,getColor:at})},[$,f,P,N]),L=e.useMemo(()=>{const e=Object.assign(Object.assign({},{top:20,bottom:20,left:20,right:20}),s);return B&&120>e.right&&(e.right=120),e},[s,B]),D=_o({componentName:"ForceDirectedGraph",nodes:o,edges:n,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:c}});return D?v.createElement(Po,{componentName:"ForceDirectedGraph",message:D,width:r,height:i}):v.createElement(yt,Object.assign({chartType:"force",nodes:P,edges:j,size:[r,i],margin:L,nodeIDAccessor:c,sourceAccessor:u,targetAccessor:d,iterations:k,forceStrength:w,nodeStyle:_,edgeStyle:C,colorBy:f,colorScheme:p,nodeSize:m,nodeSizeRange:y,nodeLabel:z,showLabels:A,enableHover:E,tooltipContent:S?e=>ko(S)(e.data):void 0,legend:B,className:a,title:l},O))}function xn(t){const{nodes:o,edges:n,width:r=600,height:i=600,margin:s={top:50,bottom:50,left:50,right:50},className:a,title:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",padAngle:y=.01,groupWidth:g=20,sortGroups:b,nodeLabel:x,showLabels:k=!0,enableHover:w=!0,edgeOpacity:A=.5,tooltip:E,frameProps:M={}}=t,S=n||[],O=e.useMemo(()=>{if(o&&o.length>0)return o;const e=new Set;return S.forEach(t=>{const o="function"==typeof c?c(t):t[c],n="function"==typeof u?u(t):t[u];e.add(o),e.add(n)}),Array.from(e).map(e=>({id:e}))},[o,S,c,u]),P=So(O,f,p),j=e.useMemo(()=>(e,t)=>{var o,n;const r={stroke:"black",strokeWidth:1};if(f)r.fill=at(e.data||e,f,P);else{const i=Array.isArray(p)?p:it[p]||st,s=Array.isArray(i)?i:st,a=null!==(n=null!==(o=e.index)&&void 0!==o?o:t)&&void 0!==n?n:0;r.fill=s[a%s.length]}return r},[f,P,p]),N=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:.5,fillOpacity:A,strokeOpacity:A};if("function"==typeof m)t.fill=m(e);else if("source"===m){const o="object"==typeof e.source?e.source:null;f&&o?t.fill=at(o.data||o,f,P):o&&(t.fill=j(o,o.index).fill)}else if("target"===m){const o="object"==typeof e.target?e.target:null;f&&o?t.fill=at(o.data||o,f,P):o&&(t.fill=j(o,o.index).fill)}return t},[m,f,P,j,A]),_=e.useMemo(()=>{if(!k)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[k,x,h]),C=_o({componentName:"ChordDiagram",edges:n,edgesRequired:!0});return C?v.createElement(Po,{componentName:"ChordDiagram",message:C,width:r,height:i}):v.createElement(yt,Object.assign({chartType:"chord",nodes:O,edges:S,size:[r,i],margin:s,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,padAngle:y,groupWidth:g,sortGroups:b,nodeStyle:j,edgeStyle:N,colorBy:f,colorScheme:p,edgeColorBy:m,edgeOpacity:A,nodeLabel:_,showLabels:k,enableHover:w,tooltipContent:E?e=>ko(E)(e.data):void 0,className:a,title:l},M))}function kn(t){const{nodes:o,edges:n,width:r=800,height:i=600,margin:s={top:50,bottom:50,left:50,right:50},className:a,title:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",orientation:y="horizontal",nodeAlign:g="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,showLabels:w=!0,enableHover:A=!0,edgeOpacity:E=.5,edgeSort:M,tooltip:S,frameProps:O={}}=t,P=n||[],j=e.useMemo(()=>{if(o&&o.length>0)return o;const e=new Set;return P.forEach(t=>{const o="function"==typeof c?c(t):t[c],n="function"==typeof u?u(t):t[u];e.add(o),e.add(n)}),Array.from(e).map(e=>({id:e}))},[o,P,c,u]),N=So(j,f,p),_=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?at(e.data||e,f,N):"#4d430c",t},[f,N]),C=e.useMemo(()=>e=>{const t={stroke:"none",strokeWidth:0,fillOpacity:E};if("function"==typeof m)t.fill=m(e);else if("source"===m){const o="object"==typeof e.source?e.source:null;f&&o?t.fill=at(o.data||o,f,N):o&&(t.fill=_(o).fill)}else if("target"===m){const o="object"==typeof e.target?e.target:null;f&&o?t.fill=at(o.data||o,f,N):o&&(t.fill=_(o).fill)}else"gradient"===m&&(t.fill="#999",t.fillOpacity=.7*E);return t},[m,f,N,_,E]),z=e.useMemo(()=>{if(!w)return;const e=k||h;return"function"==typeof e?e:t=>t[e]},[w,k,h]),$=e.useMemo(()=>{if("function"==typeof S)return S},[S]),B=_o({componentName:"SankeyDiagram",edges:n,edgesRequired:!0});return B?v.createElement(Po,{componentName:"SankeyDiagram",message:B,width:r,height:i}):v.createElement(yt,Object.assign({chartType:"sankey",nodes:j,edges:P,size:[r,i],margin:s,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,orientation:y,nodeAlign:g,nodePaddingRatio:b,nodeWidth:x,nodeStyle:_,edgeStyle:C,colorBy:f,colorScheme:p,edgeColorBy:m,edgeOpacity:E,edgeSort:M,nodeLabel:z,showLabels:w,enableHover:A,tooltipContent:$?e=>$(e.data):void 0,className:a,title:l},O))}function wn(t){const{data:o,width:n=600,height:r=600,margin:i={top:50,bottom:50,left:50,right:50},className:s,title:a,layout:l="tree",orientation:c="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:p="category10",colorByDepth:m=!1,edgeStyle:y="curve",nodeLabel:g,showLabels:b=!0,nodeSize:x=5,enableHover:k=!0,tooltip:w,frameProps:A={}}=t,E=e.useMemo(()=>{if(!o)return[];const e=[],t=o=>{e.push(o);const n="function"==typeof u?u(o):o[u];n&&Array.isArray(n)&&n.forEach(t)};return t(o),e},[o,u]),M=e.useMemo(()=>m?lt(E.map((e,t)=>({depth:t%5})),"depth",p):f&&"function"!=typeof f?lt(E,f,p):void 0,[E,f,m,p]),S=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=m?at({depth:e.depth||0},"depth",M):f?at(e.data||e,f,M):Eo,t},[f,m,M]),O=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),P=e.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return"function"==typeof d?d:e=>e[d]||1},[l,d]),j=No({componentName:"TreeDiagram",data:o});return j?v.createElement(Po,{componentName:"TreeDiagram",message:j,width:n,height:r}):v.createElement(yt,Object.assign({chartType:l,data:o,size:[n,r],margin:i,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:P,treeOrientation:c,edgeType:y,nodeStyle:S,edgeStyle:O,colorBy:f,colorScheme:p,colorByDepth:m,nodeSize:x,nodeLabel:b?g||h:void 0,showLabels:b,enableHover:k,tooltipContent:w?e=>ko(w)(e.data):void 0,className:s,title:a},A))}function An(t){const{data:o,width:n=600,height:r=600,margin:i={top:10,bottom:10,left:10,right:10},className:s,title:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,showLabels:p=!0,labelMode:m="leaf",nodeLabel:y,padding:g=4,paddingTop:b,enableHover:x=!0,tooltip:k,frameProps:w={}}=t,A=e.useMemo(()=>{if(!o)return[];const e=[],t=o=>{e.push(o);const n="function"==typeof l?l(o):o[l];n&&Array.isArray(n)&&n.forEach(t)};return t(o),e},[o,l]),E=e.useMemo(()=>{if(!f&&d&&"function"!=typeof d)return lt(A,d,h)},[A,d,f,h]),M=e.useMemo(()=>{const e=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];return t=>{const o={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return o.fill=f?e[(t.depth||0)%e.length]:d?at(t.data||t,d,E):Eo,o}},[d,f,E]),S=e.useMemo(()=>"function"==typeof c?c:e=>e[c]||1,[c]),O=void 0!==b?b:p&&"parent"===m?18:void 0,P=No({componentName:"Treemap",data:o});return P?v.createElement(Po,{componentName:"Treemap",message:P,width:n,height:r}):v.createElement(yt,Object.assign({chartType:"treemap",data:o,size:[n,r],margin:i,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:S,padding:g,paddingTop:O,nodeStyle:M,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:p?y||u:void 0,showLabels:p,enableHover:x,tooltipContent:k?e=>ko(k)(e.data):void 0,className:s,title:a},w))}function En(t){const{data:o,width:n=600,height:r=600,margin:i={top:10,bottom:10,left:10,right:10},className:s,title:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,showLabels:p=!0,nodeLabel:m,circleOpacity:y=.7,padding:g=4,enableHover:b=!0,tooltip:x,frameProps:k={}}=t,w=e.useMemo(()=>{if(!o)return[];const e=[],t=o=>{e.push(o);const n="function"==typeof l?l(o):o[l];n&&Array.isArray(n)&&n.forEach(t)};return t(o),e},[o,l]),A=e.useMemo(()=>{if(!f&&d&&"function"!=typeof d)return lt(w,d,h)},[w,d,f,h]),E=e.useMemo(()=>{const e=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];return t=>{const o={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return o.fill=f?e[(t.depth||0)%e.length]:d?at(t.data||t,d,A):Eo,o}},[d,f,A,y]),M=e.useMemo(()=>"function"==typeof c?c:e=>e[c]||1,[c]),S=No({componentName:"CirclePack",data:o});return S?v.createElement(Po,{componentName:"CirclePack",message:S,width:n,height:r}):v.createElement(yt,Object.assign({chartType:"circlepack",data:o,size:[n,r],margin:i,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:M,padding:g,nodeStyle:E,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:p?m||u:void 0,showLabels:p,enableHover:b,tooltipContent:x?e=>ko(x)(e.data):void 0,className:s,title:a},k))}rn.displayName="ScatterplotMatrix",an.displayName="MinimapChart",ln.displayName="BarChart",cn.displayName="StackedBarChart",un.displayName="SwarmPlot",dn.displayName="BoxPlot",hn.displayName="Histogram",fn.displayName="ViolinPlot",pn.displayName="RidgelinePlot",mn.displayName="DotPlot",yn.displayName="PieChart",gn.displayName="DonutChart",vn.displayName="GroupedBarChart",bn.displayName="ForceDirectedGraph",xn.displayName="ChordDiagram",kn.displayName="SankeyDiagram",wn.displayName="TreeDiagram",An.displayName="Treemap",En.displayName="CirclePack";const Mn=e.forwardRef(function(t,o){const{size:n,width:r,height:i,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:d,timeAccessor:h,valueAccessor:f,timeExtent:p,valueExtent:m,extentPadding:y,stroke:g="#007bff",strokeWidth:b=2,strokeDasharray:x,showAxes:k=!0,background:w,enableHover:A,tooltipContent:E,tooltip:M,onHover:S,annotations:O,svgAnnotationRules:P,tickFormatTime:j,tickFormatValue:N,decay:_,pulse:C,staleness:z,transition:$,linkedHover:B}=t,L=null!=r&&null!=i?[r,i]:n||[500,300],D=null!=E?E:M,T=e.useRef(null),W=Co(B),R=Fo({name:(null==W?void 0:W.name)||"hover",fields:(null==W?void 0:W.fields)||[]}),F=e.useCallback(e=>{S&&S(e),B&&R.onHover(e?e.data||e:null)},[S,B,R]);return e.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=T.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),v.createElement(ie,{ref:T,chartType:"line",runtimeMode:"streaming",size:L,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:d,timeAccessor:h,valueAccessor:f,xExtent:p,yExtent:m,extentPadding:y,lineStyle:{stroke:g,strokeWidth:b,strokeDasharray:x},showAxes:k,background:w,hoverAnnotation:A,tooltipContent:D,customHoverBehavior:F,annotations:O,svgAnnotationRules:P,tickFormatTime:j,tickFormatValue:N,decay:_,pulse:C,staleness:z,transition:$})});Mn.displayName="RealtimeLineChart";const Sn=e.forwardRef(function(t,o){const{binSize:n,size:r,width:i,height:s,margin:a,className:l,arrowOfTime:c="right",windowMode:u="sliding",windowSize:d=200,data:h,timeAccessor:f,valueAccessor:p,timeExtent:m,valueExtent:y,extentPadding:g,categoryAccessor:b,colors:x,fill:k,stroke:w,strokeWidth:A,gap:E,showAxes:M=!0,background:S,enableHover:O,tooltipContent:P,tooltip:j,onHover:N,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$,linkedHover:B}=t,L=null!=i&&null!=s?[i,s]:r||[500,300],D=null!=P?P:j,T=e.useRef(null),W=Co(B),R=Fo({name:(null==W?void 0:W.name)||"hover",fields:(null==W?void 0:W.fields)||[]}),F=e.useCallback(e=>{N&&N(e),B&&R.onHover(e?e.data||e:null)},[N,B,R]);e.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=T.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const H={};return null!=k&&(H.fill=k),null!=w&&(H.stroke=w),null!=A&&(H.strokeWidth=A),null!=E&&(H.gap=E),v.createElement(ie,{ref:T,chartType:"bar",runtimeMode:"streaming",size:L,margin:a,className:l,arrowOfTime:c,windowMode:u,windowSize:d,data:h,timeAccessor:f,valueAccessor:p,xExtent:m,yExtent:y,extentPadding:g,binSize:n,categoryAccessor:b,barColors:x,barStyle:H,showAxes:M,background:S,hoverAnnotation:O,tooltipContent:D,customHoverBehavior:F,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$})});Sn.displayName="RealtimeTemporalHistogram";const On=Sn,Pn=e.forwardRef(function(t,o){const{size:n,width:r,height:i,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:d,timeAccessor:h,valueAccessor:f,timeExtent:p,valueExtent:m,extentPadding:y,categoryAccessor:g,colors:b,radius:x,fill:k,opacity:w,stroke:A,strokeWidth:E,showAxes:M=!0,background:S,enableHover:O,tooltipContent:P,tooltip:j,onHover:N,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$,linkedHover:B}=t,L=null!=r&&null!=i?[r,i]:n||[500,300],D=null!=P?P:j,T=e.useRef(null),W=Co(B),R=Fo({name:(null==W?void 0:W.name)||"hover",fields:(null==W?void 0:W.fields)||[]}),F=e.useCallback(e=>{N&&N(e),B&&R.onHover(e?e.data||e:null)},[N,B,R]);e.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=T.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const H={};return null!=x&&(H.radius=x),null!=k&&(H.fill=k),null!=w&&(H.opacity=w),null!=A&&(H.stroke=A),null!=E&&(H.strokeWidth=E),v.createElement(ie,{ref:T,chartType:"swarm",runtimeMode:"streaming",size:L,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:d,timeAccessor:h,valueAccessor:f,xExtent:p,yExtent:m,extentPadding:y,categoryAccessor:g,barColors:b,swarmStyle:H,showAxes:M,background:S,hoverAnnotation:O,tooltipContent:D,customHoverBehavior:F,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$})});Pn.displayName="RealtimeSwarmChart";const jn=e.forwardRef(function(t,o){const{size:n,width:r,height:i,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:d,timeAccessor:h,valueAccessor:f,timeExtent:p,valueExtent:m,extentPadding:y,positiveColor:g,negativeColor:b,connectorStroke:x,connectorWidth:k,gap:w,stroke:A,strokeWidth:E,showAxes:M=!0,background:S,enableHover:O,tooltipContent:P,tooltip:j,onHover:N,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$,linkedHover:B}=t,L=null!=r&&null!=i?[r,i]:n||[500,300],D=null!=P?P:j,T=e.useRef(null),W=Co(B),R=Fo({name:(null==W?void 0:W.name)||"hover",fields:(null==W?void 0:W.fields)||[]}),F=e.useCallback(e=>{N&&N(e),B&&R.onHover(e?e.data||e:null)},[N,B,R]);e.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=T.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=T.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const H={};return null!=g&&(H.positiveColor=g),null!=b&&(H.negativeColor=b),null!=x&&(H.connectorStroke=x),null!=k&&(H.connectorWidth=k),null!=w&&(H.gap=w),null!=A&&(H.stroke=A),null!=E&&(H.strokeWidth=E),v.createElement(ie,{ref:T,chartType:"waterfall",runtimeMode:"streaming",size:L,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:d,timeAccessor:h,valueAccessor:f,xExtent:p,yExtent:m,extentPadding:y,waterfallStyle:H,showAxes:M,background:S,hoverAnnotation:O,tooltipContent:D,customHoverBehavior:F,annotations:_,svgAnnotationRules:C,tickFormatTime:z,tickFormatValue:$})});jn.displayName="RealtimeWaterfallChart";const Nn=e.forwardRef(function(t,o){const{size:n,width:r,height:i,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:d,timeAccessor:h,valueAccessor:f,categoryAccessor:p,timeExtent:m,valueExtent:y,extentPadding:g,heatmapXBins:b=20,heatmapYBins:x=20,aggregation:k="count",showAxes:w=!0,background:A,enableHover:E,tooltipContent:M,tooltip:S,onHover:O,annotations:P,svgAnnotationRules:j,tickFormatTime:N,tickFormatValue:_,decay:C,pulse:z,staleness:$}=t,B=null!=r&&null!=i?[r,i]:n||[500,300],L=null!=M?M:S,D=e.useRef(null);return e.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=D.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=D.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=D.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=D.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),v.createElement(ie,{ref:D,chartType:"heatmap",runtimeMode:"streaming",size:B,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:d,timeAccessor:h,valueAccessor:f,categoryAccessor:p,xExtent:m,yExtent:y,extentPadding:g,heatmapXBins:b,heatmapYBins:x,heatmapAggregation:k,showAxes:w,background:A,hoverAnnotation:E,tooltipContent:L,customHoverBehavior:O,annotations:P,svgAnnotationRules:j,tickFormatTime:N,tickFormatValue:_,decay:C,pulse:z,staleness:$})});Nn.displayName="RealtimeHeatmap";const _n={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Cn={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[zn,$n]=wt(e=>({theme:_n,setTheme(t){e(e=>"light"===t?{theme:_n}:"dark"===t?{theme:Cn}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function Bn({theme:e}){const t=$n(e=>e.setTheme);return v.useEffect(()=>{void 0!==e&&t(e)},[e,t]),null}function Ln({children:e}){const t=$n(e=>e.theme);return v.createElement("div",{style:{position:"relative","--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily}},e)}function Dn(e,t){var o;const n=e.children,r=t.children,i=window.getComputedStyle(e),s=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of s){const n=i.getPropertyValue(e);n&&"none"!==n&&""!==n&&(null===(o=t.style)||void 0===o||o.setProperty(e,n))}for(let e=0;Math.min(n.length,r.length)>e;e++)Dn(n[e],r[e])}function Tn(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}exports.Annotation=kt,exports.AnnotationLayer=function(t){const{legendSettings:o,margin:n,size:r,annotations:i,annotationHandling:s}=t,a=Mt(e=>e.tooltip);let l=null!=a?i.concat(a):i,c=Mt(e=>e.changeTooltip);const u=Object.assign(Object.assign({},t),{annotations:l,voronoiHover:e=>{c(e)}}),d="object"==typeof s?s:{layout:{type:s},dataVersion:""},{dataVersion:h=""}=d,[f,p]=e.useState([]),[m,y]=e.useState([]),[g,b]=e.useState([]),[x,k]=e.useState(""),[w,A]=e.useState(h),E=_t(u,l),M=E.filter(e=>e.props&&e.props.noteData&&!e.props.noteData.fixedPosition),S=Ot(M,d,r);let O;if(e.useEffect(()=>{const e=E.filter(e=>!e.props||!e.props.noteData||e.props.noteData.fixedPosition),t=Ct(u,{adjustedAnnotations:f,adjustedAnnotationsKey:x,adjustedAnnotationsDataVersion:w,adjustableAnnotations:M,fixedAnnotations:e});p(t.adjustedAnnotations),k(t.adjustedAnnotationsKey),A(t.adjustedAnnotationsDataVersion),y(t.svgAnnotations),b(t.htmlAnnotations)},[S,h,l.length,l.map(e=>function(e){const t=new Set;return JSON.stringify(e,(e,o)=>t.has(o)?"...":"object"==typeof o?(t.add(o),"note"===e?`${o.label}-${o.title}`:"connector"===e?`${o.end}-${o.type}`:"subject"===e?""+o.radius:"object"==typeof o.column?`${o.column.x}-${o.column.y}-${o.column.name}`:o.voronoiX||o.voronoiY||o.x||o.y||o.dx||o.dy||o.label||o.type||o.key||o.hierarchicalID||o.id||o.name?`${o.voronoiX}-${o.voronoiY}-${o.dx}-${o.dy}-${o.x}-${o.y}-${o.label}-${o.type}-${o.key}-${o.hierarchicalID}-${o.id}-${o.name}`:"..."):o)}(e)).join("-")]),o){const e={left:[15,15],right:[r[0]+15,15]},{position:t="right",title:n="Legend"}=o;O=v.createElement("g",{transform:`translate(${e[t].join(",")})`},v.createElement(I,Object.assign({},o,{title:n,position:t})))}return 0!==l.length||o?v.createElement("div",{className:"annotation-layer",style:{position:"absolute",pointerEvents:"none",background:"none"}},v.createElement("svg",{className:"annotation-layer-svg",height:r[1],width:r[0],style:{background:"none",pointerEvents:"none",position:"absolute",left:n.left+"px",top:n.top+"px",overflow:"visible"}},v.createElement("g",null,O,m)),v.createElement("div",{className:"annotation-layer-html",style:{background:"none",pointerEvents:"none",position:"absolute",height:r[1]+"px",width:r[0]+"px",left:n.left+"px",top:n.top+"px"}},g)):null},exports.AreaChart=Xo,exports.Axis=function(t){const{rotate:o,label:n,dynamicLabelPosition:r,orient:i="left",marginalSummaryType:s,tickFormat:a=(s?()=>"":qt),size:l,width:c=l&&l[0]||0,height:u=l&&l[1]||0,className:d,padding:h,tickValues:f,scale:p,ticks:m,footer:y,tickSize:g,tickLineGenerator:b,baseline:x=!0,margin:k={top:0,bottom:0,left:0,right:0},center:w=!1,annotationFunction:A,glyphFunction:E,xyPoints:M}=t,[S,O]=e.useState(0),[P,j]=e.useState(void 0),N=e.useRef(null);e.useEffect(()=>{if(!(null==n?void 0:n.position)&&r){const e=((e,t)=>{const o=e.current;if(!o)return 30;const n="left"===t||"right"===t?"width":"height";return Math.max(...[...o.querySelectorAll(".axis-label")].map(e=>e.getBBox&&e.getBBox()||{height:30,width:30}).map(e=>e[n]))+25})(N,i);e!==P&&j(e)}},[n,r]);let _,{axisParts:C,position:z=[0,0]}=t;if(C||(C=function({renderMode:e=()=>{},padding:t=5,scale:o,ticks:n,tickValues:r=Ht(void 0,n,o),orient:i="left",size:s,footer:a=!1,tickSize:l=(a?-10:["top","bottom"].find(e=>e===i)?s?s[1]:0:s?s[0]:0),jaggedBase:c}){let u,d,h,f,p,m,y=[],g=0,v=0,b="middle";switch(i){case"top":u="x1",d="x2",h="y1",f="y2",y=[0,l],p="tx",m="ty",g-=20-t;break;case"bottom":u="x1",d="x2",h="y2",f="y1",y=s?[s[1],s[1]-l]:[0,-l],p="tx",m="ty",g+=20+t;break;case"right":u="y2",d="y1",h="x2",f="x1",y=s?[s[0],s[0]-l]:[0,-l],p="ty",m="tx",g+=5+t,v+=5,b="start";break;default:u="y1",d="y2",h="x1",f="x2",y=[0,l],p="ty",m="tx",g-=5+t,v+=5,b="end"}let x=r instanceof Function?r({orient:i}):r;return c&&void 0===x.find(e=>e===o.domain()[0])&&(x=[o.domain()[0],...x]),x.map((t,n)=>{const r=o(t);return{[u]:r,[d]:r,[h]:y[0],[f]:y[1],[p]:r+v,[m]:y[0]+g,defaultAnchor:b,renderMode:e(t,n),value:t}})}({padding:h,tickValues:f,scale:p,ticks:m,orient:i,size:[c,u],footer:y,tickSize:g}),_=v.createElement("g",{className:"axis "+d},(({axisParts:e,orient:t,tickLineGenerator:o=Ft,className:n,jaggedBase:r,scale:i,showOutboundTickLines:s=!1})=>{const a=e.map((e,s)=>o({xy:e,orient:t,i:s,className:n,jaggedBase:r,scale:i})),l=s?e.map((e,o)=>(({xy:e,orient:t,i:o,className:n=""})=>{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}`),v.createElement("path",{key:o,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:r,className:`outbound-tick-line tick ${t} ${n}`})})({xy:e,orient:t,i:o,className:n})):[];return[...a,l]})({axisParts:C,orient:i,tickLineGenerator:b,className:d,scale:p}))),0===C.length)return null;let $,B,L,D,T=50,W=u,R=-50,F=0,H=0,I=0,Y=0,X=u,G=25,q=-25,V=18,U=c+25,K=0,Z=S,J=0,Q="y";switch(i){case"right":z=[z[0],z[1]],R=c,Y=H=c,J=k.top,U=-c-25,q=5,$=e=>{O(e.nativeEvent.offsetY-J)},!0===w&&(Y=H=c/2);break;case"top":z=[z[0],0],T=c,W=50,F=-50,R=0,J=k.left,Q="x",Y=c,X=0,!0===w&&(X=I=u/2),$=e=>{O(e.nativeEvent.offsetX-J)},G=S,Z=25,q=0,V=-10,U=0,K=u+25;break;case"bottom":z=[z[0],0],T=c,W=50,I=X=F=u,H=R=0,Y=c,J=k.left,$=e=>{O(e.nativeEvent.offsetX-J)},G=S,Z=25,q=0,V=15,U=0,K=-u-25,Q="x",!0===w&&(X=I=u/2);break;default:z=[z[0],z[1]],J=k.top,!0===w&&(Y=H=c/2),$=e=>{O(e.nativeEvent.offsetY-J)}}if(A){const e=function(e,t){return t.tickFormat?t.tickFormat(e):e.toString?""+e:e}(p.invert(S),t),o=E?E({lineHeight:K,lineWidth:U,value:p.invert(S)}):v.createElement("g",null,v.isValidElement(e)?v.createElement("g",{transform:`translate(${q},${V})`},e):v.createElement("text",{x:q,y:V},e),v.createElement("circle",{r:5}),v.createElement("line",{x1:U,y1:K,style:{stroke:"black"}})),n=S?v.createElement("g",{style:{pointerEvents:"none"},transform:`translate(${G},${Z})`},o):null;B=v.createElement("g",{className:"annotation-brush",transform:`translate(${R},${F})`},v.createElement("rect",{style:{fillOpacity:0},height:W,width:T,onMouseMove:$,onClick:e=>A({className:"dynamic-axis-annotation",type:Q,value:p.invert(S),e:e}),onMouseOut:()=>{O(void 0)}}),n)}if(s&&M){const e=Math.max(k[i]-6,5),t="string"==typeof s?{type:s}:s;void 0!==t.flip||"bottom"!==i&&"right"!==i||(t.flip=!0);const o=t.summaryStyle?()=>t.summaryStyle:()=>({fill:"black",fillOpacity:.5,stroke:"black",strokeDasharray:"0"}),n=t.renderMode?()=>t.renderMode:()=>{},r=t.summaryClass?()=>t.summaryClass:()=>"",a=t.filter||(()=>!0),c=M.filter(e=>void 0!==e.x&&void 0!==e.y&&a(e.data)).map(e=>Object.assign(Object.assign({},e),{xy:{x:"top"===i||"bottom"===i?p(e.x):0,y:"left"===i||"right"===i?p(e.y):0},piece:{scaledVerticalValue:p(e.y),scaledValue:p(e.x)},value:p("top"===i||"bottom"===i?e.y:e.x),scaledValue:p(e.x),scaledVerticalValue:p(e.y)})),u=function(e){const t=[];for(const o of e){const e=[],{elements:n,containerProps:r}=o;if(o.Mark)t.push(o.Mark);else{for(let t=0;n.length>t;t++){const o=n[t],{markType:r,style:i={}}=o,s=zt(o,["markType","style"]),a=Object.assign({},s);void 0!==i.fill&&(a.fill=i.fill),void 0!==i.stroke&&(a.stroke=i.stroke),void 0!==i.strokeWidth&&(a.strokeWidth=i.strokeWidth),void 0!==i.opacity&&(a.opacity=i.opacity),void 0!==i.fillOpacity&&(a.fillOpacity=i.fillOpacity),void 0!==i.strokeOpacity&&(a.strokeOpacity=i.strokeOpacity);const l=Object.assign({},i);delete l.fill,delete l.stroke,delete l.strokeWidth,delete l.opacity,delete l.fillOpacity,delete l.strokeOpacity,Object.keys(l).length>0&&(a.style=l),a.key=o.key||t,r&&e.push(v.createElement(r,a))}r?t.push(v.createElement("g",Object.assign({},r),e)):t.push(...e)}}return t}((({data:e,type:t,renderMode:o,eventListenersGenerator:n,styleFn:r,classFn:i,projection:s,adjustedSize:a,margin:l,axisCreator:c})=>{if(t&&t.type)return function({data:e,type:t,renderMode:o,eventListenersGenerator:n,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:l,margin:c,axisCreator:u}){return"function"==typeof t.type?t.type({data:e,type:t,renderMode:o,eventListenersGenerator:n,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:l,margin:c,axisCreator:u}):(console.error(`Invalid summary type: ${t.type} - Must be a function`),{})}({data:e,type:t="string"==typeof t?{type:t}:t,renderMode:o,eventListenersGenerator:n,styleFn:r,classFn:i,projection:s,adjustedSize:a,chartSize:"vertical"===s?a[1]:a[0],margin:l,axisCreator:c})})({data:{column:{middle:e/2,pieceData:c,width:e,xyData:c}},type:t,renderMode:n,eventListenersGenerator:t.eventListenersGenerator||(()=>({})),styleFn:o,classFn:r,projection:"top"===i||"bottom"===i?"horizontal":"vertical",adjustedSize:l,margin:{top:0,bottom:0,left:0,right:0}}).marks);let d;if(!0===t.showPoints){const o=((e,t,o)=>{const n="left"===e||"right"===e?t/2:0,r="bottom"===e||"top"===e?t/2:0;return o.map(e=>[e.xy.x+n,e.xy.y+r])})(i,e,c);d=o.map((e,o)=>v.createElement("circle",{key:"axis-summary-point-"+o,cx:e[0],cy:e[1],r:t.r||3,style:t.pointStyle||{fill:"black",fillOpacity:.1}}))}L=v.createElement(Xt,{translation:{left:[2-k.left,0],right:[l[0]+2,0],top:[0,2-k.top],bottom:[0,l[1]+2]},orient:i,decoratedSummaryType:t,summaryWidth:e,renderedSummary:u,points:d})}const ee=(({axisParts:e,tickFormat:t,rotate:o=0,center:n=!1,orient:r})=>{const i=e.map((e,o)=>({axisPart:e,i:o,formatted:t(e.value,o)})),s="left"===r||"right"===r;let a=i;if(!o&&i.length>1){const e=8,t=14,o=8,n=e=>"string"==typeof e?e:"number"==typeof e?e+"":null;if("top"===r||"bottom"===r){const t=[...i].sort((e,t)=>e.axisPart.tx-t.axisPart.tx);let r=-1/0;const s=new Set;for(const i of t){const t=n(i.formatted);if(!t){s.add(i.i);continue}const a=t.length*e/2;r+o>i.axisPart.tx-a||(s.add(i.i),r=i.axisPart.tx+a)}a=i.filter(e=>s.has(e.i))}else if(s){const e=[...i].sort((e,t)=>e.axisPart.ty-t.axisPart.ty);let n=-1/0;const r=new Set;for(const i of e)n+t+o>i.axisPart.ty||(r.add(i.i),n=i.axisPart.ty);a=i.filter(e=>r.has(e.i))}}return a.map(({axisPart:e,i:t,formatted:i})=>{("object"!=typeof i||i instanceof Date)&&(i=v.createElement("text",{textAnchor:e.defaultAnchor,className:"axis-label"},i.toString?""+i:i));let s=e.tx,a=e.ty;if(n)switch(r){case"right":s-=(e.x2-e.x1)/2;break;case"left":s+=(e.x2-e.x1)/2;break;case"top":a+=(e.y2-e.y1)/2;break;case"bottom":a-=(e.y2-e.y1)/2}return v.createElement("g",{key:t,pointerEvents:"none",transform:`translate(${s},${a}) rotate(${o})`,className:"axis-label"},i)})})({tickFormat:a,axisParts:C,orient:i,rotate:o,center:w});if(n){const e=n.name||n,t=n.position||{};let o=t.anchor||"middle";const r=n.locationDistance||P,s=t.rotation||{left:-90,right:90,top:0,bottom:0}[i],a={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=a[i][o],u=a[i][t.location||"outside"];c[0]=c[0]+u[0],c[1]=c[1]+u[1],"start"===o&&"right"===i?o="end":"end"===o&&"right"===i&&(o="start"),D=v.createElement(Gt,{className:d,translation:c,position:z,rotation:s,labelName:e,anchorMod:o})}const te=`${i} axis ${C&&C.length>0&&`from ${a(C[0].value,0)} to ${a(C[C.length-1].value,C.length-1)}`||"without ticks"}`;return v.createElement("g",{className:d,"aria-label":te,ref:N},B,ee,_,!0===x?v.createElement("line",{key:"baseline",className:"axis-baseline "+d,stroke:"black",strokeLinecap:"square",x1:H,x2:Y,y1:I,y2:X}):null,D,L)},exports.BarChart=ln,exports.BoxPlot=dn,exports.Brush=function(t){const{extent:n,selectedExtent:r}=t,i=e.useRef(null),s=Ut(n),a=Ut(r);e.useEffect(()=>{(null==i?void 0:i.current)&&((e,t)=>{const{svgBrush:n,selectedExtent:r}=t;if(o.select(e).call(n),r){let t=r;if(Array.isArray(r[0])){const e=[t[0][1],t[1][1]].sort((e,t)=>e-t);t=[[t[0][0],e[0]],[t[1][0],e[1]]]}o.select(e).call(n.move,t)}})(i.current,t)},[s,a,i]);const{position:l=[0,0]}=t;return v.createElement("g",{transform:`translate(${l})`,ref:i,className:"xybrush"})},exports.BubbleChart=Vo,exports.ChartErrorBoundary=class extends v.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var o,n;null===(n=(o=this.props).onError)||void 0===n||n.call(o,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:v.createElement(Po,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},exports.ChordDiagram=xn,exports.CirclePack=En,exports.DARK_THEME=Cn,exports.DividedLine=function(e){const t=(e=>{const{parameters:t,className:o,interpolate:n=l.curveLinear,customAccessors:r,lineDataAccessor:i,data:s,searchIterations:a}=e,c=zt(e,["parameters","className","interpolate","customAccessors","lineDataAccessor","data","searchIterations"]),{x:u,y:d}=r,h=Bt({data:s,lineDataAccessor:[i],xProp:"x",yProp:"y",xAccessor:[u],yAccessor:[d]});for(const e of h)e.data=e.data.map(e=>Object.assign(Object.assign({},e.data),e));const f=((e,t,o=10)=>{let n=e(t[0],0),r=[];const i=[{key:n,points:r}];return t.forEach((t,s)=>{const a=e(t,s);let l=a===n;const c=JSON.stringify(a),u=JSON.stringify(n);if("object"==typeof n&&(l=c===u),l)r.push(t);else{let s=r[r.length-1],l=t,u=c,d=0;for(;o>d&&c===u;){const t=Rt({pointA:s,pointB:l,currentParameters:n,parameters:e,keys:Object.keys(s)});s=t[0],l=t[1],u=JSON.stringify(e(l)),d++}r.push(l),r=[l,t],i.push({key:a,points:r}),n=a}}),i})(t,h[0].data,a),p=l.line().curve(n).x(e=>e.x).y(e=>e.y);return f.map((e,t)=>v.createElement("path",Object.assign({},c,{className:o,key:"DividedLine-"+t,style:e.key,d:p(e.points)})))})(e);return v.createElement("g",null,t)},exports.DonutChart=gn,exports.DotPlot=mn,exports.ForceDirectedGraph=bn,exports.GroupedBarChart=vn,exports.Heatmap=qo,exports.Histogram=hn,exports.IncrementalExtent=E,exports.LIGHT_THEME=_n,exports.Legend=I,exports.LineChart=Yo,exports.LinkedCharts=Ko,exports.MinimapChart=an,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:o,format:n,style:r={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(o){const t=vo(e,o);l.push({value:bo(t,n)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let o,r,i;"string"==typeof t?(o=t,r=t,i=n):(o=t.label,r=t.accessor||t.key||"",i=t.format||n);const a=bo(vo(e,r),i);l.push({label:s?o:void 0,value:a})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:s?t:void 0,value:bo(e[t],n)})});const c=Object.assign(Object.assign({},go),r);return Array.isArray(l)&&0!==l.length?v.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>v.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&v.createElement("strong",null,e.label,a),e.value))):null}},exports.PieChart=yn,exports.RealtimeHeatmap=Nn,exports.RealtimeHistogram=On,exports.RealtimeLineChart=Mn,exports.RealtimeSwarmChart=Pn,exports.RealtimeTemporalHistogram=Sn,exports.RealtimeWaterfallChart=jn,exports.RidgelinePlot=pn,exports.RingBuffer=A,exports.SankeyDiagram=kn,exports.Scatterplot=Io,exports.ScatterplotMatrix=rn,exports.StackedAreaChart=Go,exports.StackedBarChart=cn,exports.StreamNetworkFrame=yt,exports.StreamOrdinalFrame=Ee,exports.StreamXYFrame=ie,exports.SwarmPlot=un,exports.ThemeProvider=function({theme:e,children:t}){return v.createElement(zn,null,v.createElement(Bn,{theme:e}),v.createElement(Ln,null,t))},exports.Tooltip=xo,exports.TreeDiagram=wn,exports.Treemap=An,exports.ViolinPlot=fn,exports.calculateDataExtent=({lineDataAccessor:e,xAccessor:t,yAccessor:o,summaries:r,points:i,lines:s,lineType:a,showLinePoints:c,showSummaryPoints:u,xExtent:d,yExtent:h,invertX:f,invertY:m,summaryDataAccessor:y,summaryType:g,adjustedSize:v,margin:b,summaryStyleFn:k,summaryClassFn:w,summaryRenderModeFn:A,chartSize:E,filterRenderedLines:M,filterRenderedSummaries:S,filterRenderedPoints:O,defined:P=lo,annotations:j=[]})=>{let N=[],_=[],C=[],z=[],$=[];if(i){t.forEach((e,t)=>{o.forEach((o,n)=>{let r=0;for(const s of i){const i=e(s,r),a=o(s,r),l={x:i,y:a,data:s,xIndex:t,yIndex:n};Array.isArray(a)&&(l[eo]=Math.min(...a),l[Qt]=Math.max(...a),l[Jt]=(l[eo]+l[Qt])/2),Array.isArray(i)&&(l[no]=Math.min(...i),l[oo]=Math.max(...i),l[to]=(l[no]+l[oo])/2),C.push(l),r++}})});for(const e of C)N.push(Object.assign(Object.assign({},e),{[Kt]:e[oo]||e[no]||e.x,[Zt]:e[Qt]||e[eo]||e.y}))}if(s){_=Bt({data:s,lineDataAccessor:e,xProp:Kt,xPropTop:oo,xPropBottom:no,yProp:Zt,yPropTop:Qt,yPropBottom:eo,xAccessor:t,yAccessor:o}),z=function(e,t){return o=>ho[((e,t)=>!ho[e]||"difference"===e&&2!==t.length?"line":e)(e.type,o)](Object.assign(Object.assign(Object.assign({},e),t),{data:o}))}(a,{xProp:Kt,yProp:Zt,yPropMiddle:Jt,yPropTop:Qt,yPropBottom:eo,xPropMiddle:to,xPropTop:oo,xPropBottom:no})(_);for(const e of z)for(let t=0;e.data.length>t;t++){const o=e.data[t];if(!P(Object.assign({},o.data,o),t))continue;const n={parentLine:e,y:o.y,x:o.x,xTop:o.xTop,xMiddle:o.xMiddle,xBottom:o.xBottom,yTop:o.yTop,yMiddle:o.yMiddle,yBottom:o.yBottom,data:o.data};o.percent&&(n.percent=o.percent),N.push(n)}if(c){const e=!0===c?to:uo[c],t=!0===c?Jt:co[c];z.forEach(o=>{o.data.filter((e,t)=>{if(P(Object.assign({},e.data,e))){if("orphan"===c){const e=o.data[t-1],n=o.data[t+1];return!(e&&P(Object.assign({},e.data,e))||n&&P(Object.assign({},n.data,n)))}return!0}return!1}).forEach(n=>{C.push(Object.assign(Object.assign({},n),{parentLine:o,[Zt]:void 0!==n[t]?n[t]:void 0!==n[Jt]?n[Jt]:void 0!==n[eo]?n[eo]:n.y,[Kt]:void 0!==n[e]?n[e]:void 0!==n[to]?n[to]:void 0!==n[no]?n[no]:n.y}))})})}}r&&($=(({data:e,summaryDataAccessor:t,xAccessor:o,yAccessor:n})=>{const r=[];return t.forEach(t=>{o.forEach(o=>{n.forEach(n=>{const i=e=>t(e).map((e,t)=>[o(e,t),n(e,t)]);e.forEach(e=>{r.push(Object.assign(Object.assign({},e),{_baseData:t(e),_xyfCoordinates:i(e)}))})})})}),r})({data:r,summaryDataAccessor:y,xAccessor:t,yAccessor:o}),$.forEach(e=>{const t=e._baseData;e._xyfCoordinates.length>0&&e._xyfCoordinates[0][0][0]?e._xyfCoordinates[0].forEach(o=>{Array.isArray(o)&&o.map((o,n)=>Object.assign({parentSummary:e},t[n],{[Kt]:o[0],[Zt]:o[1]})).forEach(e=>{u&&C.push(Object.assign(Object.assign({x:0},e),{[Zt]:e[Qt]||e[eo]||e[Zt]})),N.push(Object.assign({x:0,y:0},e))})}):e._xyfCoordinates.length>0&&Array.isArray(e._xyfCoordinates)&&e._xyfCoordinates.map((o,n)=>Object.assign(Object.assign({parentSummary:e},t[n]),{[Kt]:o[0],[Zt]:o[1]})).forEach(e=>{u&&C.push(Object.assign(Object.assign({x:0},e),{[Zt]:e[Qt]||e[eo]||e[Zt]})),N.push(Object.assign({x:0,y:0},e))})}));let B,L,D,T,W=[],R=[];d&&!Array.isArray(d)&&!0===d.includeAnnotations&&t.forEach(e=>{j.forEach((t,o)=>{const n=e(t,o);isFinite(n)&&W.push({[Kt]:n})})}),h&&!Array.isArray(h)&&!0===h.includeAnnotations&&o.forEach(e=>{j.forEach((t,o)=>{const n=e(t,o);isFinite(n)&&R.push({[Zt]:n})})});for(const e of N){const t=void 0===e[no]?e[Kt]:Math.min(e[oo],e[no]),o=void 0===e[oo]?e[Kt]:Math.max(e[no],e[oo]),n=void 0===e[eo]?e[Zt]:Math.min(e[Qt],e[eo]),r=void 0===e[Qt]?e[Zt]:Math.max(e[eo],e[Qt]);void 0===t||void 0!==B&&t>=B||(B=t),void 0===o||void 0!==L&&L>=o||(L=o),void 0===n||void 0!==D&&n>=D||(D=n),void 0===r||void 0!==T&&T>=r||(T=r)}for(const e of W){const t=e[Kt];void 0===t||void 0!==B&&t>=B||(B=t),void 0===t||void 0!==L&&L>=t||(L=t)}for(const e of R){const t=e[Zt];void 0===t||void 0!==D&&t>=D||(D=t),void 0===t||void 0!==T&&T>=t||(T=t)}const F=[B,L],H=[D,T],I=ao(d),Y=ao(h);let X=[Y&&void 0!==Y[0]?Y[0]:H[0],Y&&void 0!==Y[1]?Y[1]:H[1]],G=[I&&void 0!==I[0]?I[0]:F[0],I&&void 0!==I[1]?I[1]:F[1]];if(!f||I&&2===I.length||(G=[G[1],G[0]]),"bumpline"!==a.type&&!m||Y&&2===Y.length||(X=[X[1],X[0]]),g.type&&"contour"===g.type)$=function({summaryType:e,data:t,finalXExtent:o,finalYExtent:r}){let i=[];e.type||(e={type:e});const{resolution:s=500,thresholds:a=10,bandwidth:l=20,neighborhood:c}=e,u=n.scaleLinear().domain(o).rangeRound([0,s]).nice(),d=n.scaleLinear().domain(r).rangeRound([s,0]).nice();return t.forEach(e=>{let t=p.contourDensity().size([s,s]).x(e=>u(e[0])).y(e=>d(e[1])).thresholds(a).bandwidth(l)(e._xyfCoordinates);c&&(t=[t[0]]);const o=Math.max(...t.map(e=>e.value));t.forEach(t=>{t.parentSummary=e,t.bounds=[],t.percent=t.value/o,t.coordinates.forEach(e=>{e.forEach((o,n)=>{e[n]=o.map(e=>[u.invert(e[0]),d.invert(e[1])]),0===n&&t.bounds.push(function(e){let t=[1/0,0],o=[-1/0,0],n=[0,1/0],r=[0,-1/0];return e.forEach(e=>{t=t[0]>e[0]?e:t,o=e[0]>o[0]?e:o,r=e[1]>r[1]?e:r,n=n[1]>e[1]?e:n}),{center:[(t[0]+o[0])/2,(n[1]+r[1])/2],top:n,left:t,right:o,bottom:r}}(e[n]))})})}),i=[...i,...t]}),i}({summaryType:g,data:$,finalXExtent:G,finalYExtent:X});else if(g.type&&"linebounds"===g.type){if($=function({summaryType:e,data:t,defined:o}){let n=[];e.type||(e={type:e});const{boundingAccessor:r,topBoundingAccessor:i=r,bottomBoundingAccessor:s=r}=e;return t.forEach(e=>{const t=e._baseData.map(o);let r=[],a=[];const l=[{xyf:a,base:r}];t.forEach((o,n)=>{!0===o?(r.push(e._baseData[n]),a.push(e._xyfCoordinates[n])):t[n+1]&&(r=[],a=[],l.push({xyf:a,base:r}))}),l.forEach(({xyf:t,base:o})=>{const r={data:e,parentSummary:e,_xyfCoordinates:io(t,o,i,s)};n=[...n,r]})}),n}({summaryType:g,data:$,defined:P}),!Y||2!==Y.length)for(const e of $)for(const t of e._xyfCoordinates){const e=t[1];void 0!==e&&isFinite(e)&&(X[0]>e&&(X[0]=e),e>X[1]&&(X[1]=e))}}else g.type&&"hexbin"===g.type?($=ro({summaryType:g,data:$[0],processedData:r&&!!r[0].processedData,preprocess:!1,finalXExtent:G,finalYExtent:X,size:v,margin:b,styleFn:k,classFn:w,renderFn:A,chartSize:E}),N=fo(N,$)):g.type&&"heatmap"===g.type?($=so({summaryType:g,data:$[0],processedData:r&&!!r[0].processedData,preprocess:!1,finalXExtent:G,finalYExtent:X,size:v,margin:b,styleFn:k,classFn:w,renderFn:A,chartSize:E}),N=fo(N,$)):g.type&&"trendline"===g.type&&($=function({preprocess:e=!1,summaryType:t,data:o,finalXExtent:r=[Math.min(...o.coordinates.map(e=>e.x)),Math.max(...o.coordinates.map(e=>e.x))],xScaleType:i=n.scaleLinear()}){if(e)return o[0].coordinates;let s,a=[];s=t.type?t:{type:s};const{regressionType:c="linear",order:u=2,precision:d=4,controlPoints:h=20,curve:f=l.curveCardinal}=s;let p=c;r[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`),p="linear"),o.coordinates&&!o._xyfCoordinates&&(o._xyfCoordinates=o.coordinates.map(e=>[e.x,e.y]));const m=Array.isArray(o)?o:[o],y=i.domain([0,1]).range(r);return a=[],m.forEach(e=>{const t=x.default[p](e._xyfCoordinates.map(e=>{let t=e[0],o=e[1];return"number"!=typeof t&&(t=t.getTime()),"number"!=typeof o&&(o=o.getTime()),[t,o]}),{order:u,precision:d}),o=1/h;let n=[0,1];if("linear"!==p){n=[];for(let e=0;1+o>e;e+=o)n.push(e)}const r=[];n.forEach(e=>{r.push(t.predict(y(e)))}),a.push({centroid:!1,customMark:void 0,data:e,parentSummary:e,value:t.string,r2:t.r2,curve:f,_xyfCoordinates:r})}),a}({summaryType:g,data:$[0],preprocess:r&&!!r[0].processedData,finalXExtent:G}),N=fo(N,$));return M&&(z=z.filter(M),N=N.filter((e,t)=>!e.parentLine||M(e.parentLine,t,[]))),O&&(N=N.filter(O)),S&&($=$.filter(S),N=N.filter((e,t)=>!e.parentSummary||S(e.parentSummary,t,[]))),{xExtent:G,yExtent:X,projectedLines:z,projectedPoints:C,projectedSummaries:$,fullDataset:N,calculatedXExtent:F,calculatedYExtent:H}},exports.exportChart=function(e,t){return o=this,n=void 0,i=function*(){const{format:o="svg",filename:n="chart",scale:r=2,background:i="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),l=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",l.width+""),a.getAttribute("height")||a.setAttribute("height",l.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),Dn(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);Tn(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const e=l.width*r,t=l.height*r,o=(new XMLSerializer).serializeToString(a),s=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(s),u=new Image;u.width=l.width,u.height=l.height,yield new Promise((o,s)=>{u.onload=()=>{const a=document.createElement("canvas");a.width=e,a.height=t;const l=a.getContext("2d");l.fillStyle=i,l.fillRect(0,0,e,t),l.scale(r,r),l.drawImage(u,0,0),a.toBlob(e=>{e?(Tn(e,n+".png"),o()):s(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(c)},u.onerror=()=>{URL.revokeObjectURL(c),s(Error("Failed to load SVG image"))},u.src=c})}},new((r=void 0)||(r=Promise))(function(e,t){function s(e){try{l(i.next(e))}catch(e){t(e)}}function a(e){try{l(i.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r(function(e){e(o)})).then(s,a)}l((i=i.apply(o,n||[])).next())});var o,n,r,i},exports.funnelize=function({data:e,steps:t,key:o}){const n=[];return Array.isArray(e)||(e=[e]),t||(t=e.map(e=>Object.keys(e)).reduce((e,t)=>e.concat(t),[])),e.forEach((e,r)=>{const i=o?e[o]:r;t.forEach(t=>{const o={funnelKey:i,stepName:"",stepValue:0};o.stepName=t,o.stepValue=e[t]?e[t]:0,n.push(o)})}),n},exports.heatmapping=so,exports.hexbinning=ro,exports.nodesEdgesFromHierarchy=(e,t=mo)=>{var o,n;const r=[],i=[],s=(e.descendants?e:d.hierarchy(e)).descendants();let a=0;for(const e of s)e.descendantIndex=a,a++;for(const e of s){const s=`${null!==(o=t(Object.assign(Object.assign({},e),e.data)))&&void 0!==o?o:mo(e)}-${e.parent?null!==(n=po(t,Object.assign(Object.assign({},e.parent),e.parent.data),""))&&void 0!==n?n:e.parent.name:"root"}`,a=Object.assign(e,e.data||{},{hierarchicalID:s});if(i.push(a),null!==e.parent){const t=Object.assign(e.parent,e.parent.data||{});r.push({source:t,target:a,depth:e.depth,weight:1,value:1,_NWFEdgeKey:s})}}return{edges:r,nodes:i}},exports.normalizeTooltip=ko,exports.smartTickFormat=qt,exports.useBrushSelection=Ho,exports.useFilteredData=function(t,o,n){const r=Wo(e=>e.selections.get(o));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=Lo(r,n);return t.filter(e)},[t,r,n])},exports.useLinkedHover=Fo,exports.useSelection=Ro,exports.useTheme=function(){return $n(e=>e.theme)};
1
+ "use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-array"),i=require("d3-hierarchy"),a=require("d3-interpolate"),s=require("d3-scale-chromatic"),l=require("d3-force"),c=require("d3-chord"),u=require("d3-shape");function d(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 h=d(e),g=5e3;class f{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,g),bounded:!0,totalSize:e.length});let t=g;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+g,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class y{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class p{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function v(e,t,n,o,r,i){const a=[],s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(a.push([t.x(e),t.y(i)]),s.push(i))}return{type:"line",path:a,rawValues:s,style:r,datum:e,group:i}}function b(e,t,n,o,r,i,a){const s=[],l=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=t.x(e);s.push([c,t.y(a)]),l.push([c,t.y(r)])}return{type:"area",topPath:s,bottomPath:l,style:i,datum:e,group:a}}function x(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function w(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function k(e,t,n,o,r,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i}}function A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class E{constructor(e){this.xExtent=new p,this.yExtent=new p,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new y(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=S(e.groupAccessor),this.getCategory=S(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=S(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getPointId=S(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new y(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,a,s;const{config:l,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,d=this.yExtent.extent;let h=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:u[0],null!==(n=l.xExtent[1])&&void 0!==n?n:u[1]]:u,g=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&c.size>0)if(l.normalize)g=[0,1+l.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);g=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(c,this.getX,this.getY,l.binSize,this.getCategory);g=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&g[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>g[1]&&(g[1]=e+n),g[0]>e-n&&(g[0]=e-n))}}const e=g[1]-g[0],t=e>0?e*l.extentPadding:1,n=null===(a=l.yExtent)||void 0===a?void 0:a[0],o=null===(s=l.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t]}if(h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(y=l.arrowOfTime)||"down"===y?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(h).range(t),y:o.scaleLinear().domain(g).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(g).range([0,e.width]),y:o.scaleLinear().domain(h).range(t)}}else this.scales={x:o.scaleLinear().domain(h).range([0,e.width]),y:o.scaleLinear().domain(g).range([e.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=v(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]);n.push(b(e.data,this.scales,this.getX,this.getY,o,t,e.key))}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const l=Array.from(s).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let n=0;for(const o of e)n+=(null===(a=c.get(o.key))||void 0===a?void 0:a.get(t))||0;u.set(t,n||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const n of e){const e=c.get(n.key),o=[],a=[];for(const n of l){let r=e.get(n)||0;const s=h.get(n);i&&(r/=u.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),h.set(n,s+r)}d.push({type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(a=r(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,l=x(o,this.scales,this.getX,this.getY,a,e,s);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=A(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const a=Array.from(r).sort((e,t)=>e-t),s=Array.from(i).sort((e,t)=>e-t);if(0===a.length||0===s.length)return n;const l=t.width/a.length,c=t.height/s.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const g=h-d||1;for(let e=0;a.length>e;e++)for(let t=0;s.length>t;t++){const o=u.get(`${a[e]}_${s[t]}`);if(!o)continue;const r=(o.val-d)/g;n.push(k(e*l,(s.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,g]=this.scales.y.domain(),f=(d-u||1)/a,y=(g-h||1)/s,p=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/f),a-1),r=Math.min(Math.floor((n-h)/y),s-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=p.get(i);l||(l={sum:0,count:0,data:[]},p.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of p){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/a,S=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,a=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=p.get(e);i.push(k(r*w,(s-1-a)*S,w,S,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=m(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[a,s]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,s);if(n>=l)continue;const c=i.x(n),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(o&&e.categories.size>0){let n=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=i.y(n),l=i.y(n+o);r.push(w(d,Math.min(s,l),h,Math.abs(s-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(w(d,Math.min(t,n),h,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],a=this.config.swarmStyle||{},s=null!==(t=a.radius)&&void 0!==t?t:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(o=a.opacity)&&void 0!==o?o:.7,u=a.stroke,d=a.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),a=this.scales.y(n);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}const g={type:"point",x:o,y:a,r:s,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],a=this.scales,s=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(r=null==s?void 0:s.gap)&&void 0!==r?r:1,h=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let f=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=f+r;let p;p=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=a.x(o),v=0!==p?a.x(o+p):m+t.width/10,b=Math.min(m,v)+d/2,x=Math.max(m,v)-d/2-b;if(0>=x){f=y;continue}const k=a.y(f),A=a.y(y);i.push(w(b,Math.min(k,A),x,Math.abs(k-A),{fill:0>r?u:c,stroke:h,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:f,cumEnd:y,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),f=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",a=o.wickColor||"#333",s=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([o,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:a,wickWidth:s,isUp:h,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),a=this.scales.x(e);if(i&&0!==i)n.push([a,this.scales.y(r+i)]),o.push([a,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([a,e]),o.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:a};else if("candlestick"===t.type)t._decayOpacity=a;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*a})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=a)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const a=this.scene[e],l=this.getNodeIdentity(a,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===a.type){const e={x:a.x,y:a.y,r:a.r};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=c.x,a.y=c.y,a.r=null!==(t=c.r)&&void 0!==t?t:a.r,s=!0)}else if("rect"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,s=!0)}else if("heatcell"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(r=c.w)&&void 0!==r?r:a.w,a.h=null!==(i=c.h)&&void 0!==i?i:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function L(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function O(e,t,n){if(0===e.path.length)return null;const o=D(e.path,t);if(0>o)return null;const[r,i]=e.path[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function M(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function P(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function j(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function N(e,t,n){if(0===e.topPath.length)return null;const o=D(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(a*a+s*s)}}function D(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const C={fill:e=>h.createElement("rect",{style:e,width:20,height:20}),line:e=>h.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function T(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,C[n])(o(e,t)),r}function B(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:r=100,height:i=20,orientation:a="vertical"}=e,s="vertical"===a?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const r=[];return e.forEach((e,i)=>{o+=5,r.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,r.push(h.createElement("text",{key:"legend-text-"+i,y:o,className:"legend-group-label"},e.label)),o+=10),r.push(h.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:r}=e,i=[];let a=0;return r.forEach((e,r)=>{const s=T(e,r,n,o);i.push(h.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${a})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,h.createElement("text",{y:15,x:30},e.label))),a+=25}),i})(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 i=[],a=!1===t?10:40;return e.forEach((t,s)=>{t.label&&(i.push(h.createElement("text",{key:"legend-text-"+s,transform:`translate(${r},${a}) 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,i=[];let a=0;return r.forEach((e,r)=>{const s=T(e,r,n,o);i.push(h.createElement("g",{key:"legend-item-"+r,transform:`translate(${a},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},s,h.createElement("text",{y:15,x:25},e.label))),a+=35,a+=8*e.label.length}),{items:i,offset:a}})(t,o);i.push(h.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(${r},${a})`},l.items)),r+=l.offset+5,e[s+1]&&i.push(h.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:r,y1:a-10,x2:r,y2:n+a+10})),r+=15}),h.createElement("g",null,!1!==t&&h.createElement("line",{x1:0,x2:r+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:o,height:i,customClickBehavior:n});return h.createElement("g",null,void 0!==o&&h.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:r/2,textAnchor:"horizontal"===a?"start":"middle"},o),s)}function R(e){return"string"==typeof e?{type:e}:e}function z({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=a-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:r,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,g=Math.min(.5*n,20),f=(n-g)/2+4;if(c){const e=i(r),n=i(s),o=i(a),c=i(u),y=i(d),p="top"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:c,y1:m+p*(f+g/2),x2:y,y2:m+p*(f+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:y,y1:m+p*f,x2:y,y2:m+p*(f+g),stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-f-g:m+f,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:o,y1:"top"===t?m-f-g:m+f,x2:o,y2:"top"===t?m-f:m+f+g,stroke:l.fill,strokeWidth:2}))}{const e=i(r),n=i(s),o=i(a),c=i(u),y=i(d),p="left"===t?-1:1,m=0;return h.createElement("g",{"data-testid":"marginal-boxplot-"+t},h.createElement("line",{x1:m+p*(f+g/2),y1:c,x2:m+p*(f+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:m+p*f,y1:y,x2:m+p*(f+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),h.createElement("rect",{x:"left"===t?m-f-g:m+f,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),h.createElement("line",{x1:"left"===t?m-f-g:m+f,y1:o,x2:"left"===t?m-f:m+f+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=r.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return h.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/d*n;if(c){const n=i(e.x0),a=i(e.x1)-i(e.x0);return h.createElement("rect",{key:o,x:n,y:"top"===t?-4-r:4,width:Math.max(a,.5),height:r,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=i(e.x0),a=i(e.x1)-i(e.x0);return h.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(n,n+a),width:r,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const a=r.length/d*(n/2),s=i((r.x0+r.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let r=u.length-1;r>=0;r--){const a=u[r];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return h.createElement("g",{"data-testid":"marginal-violin-"+t},h.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-r-4:r+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*n,a=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return h.createElement("g",{"data-testid":"marginal-ridgeline-"+t},h.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?h.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function W(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function _(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 H(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:g,disable:f,events:y={},"data-testid":p}=e,m=new Set(Array.isArray(f)?f:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return h.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":p},y),!m.has("connector")&&function(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.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&&(a.push(h.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,i=Math.atan2(t-l,e-s);a.push(h.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${s+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return h.createElement("g",{className:"annotation-connector"},a)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(h.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)&&a.push(h.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(h.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(h.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)?a.push(h.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)||a.push(h.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(h.createElement("path",{key:"bracket-path",d:_((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 h.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return h.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return h.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>t?"end":"start";const f=16,y=i?c?[i]:W(i,l):[],p=r?c?[r]:W(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(h.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},y.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e)))),v=y.length*f),p.length>0&&b.push(h.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:v},p.map((e,t)=>h.createElement("tspan",{key:t,x:m,dy:0===t?0:f},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=h.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=h.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const w=Math.max(0,y.length+p.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),h.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},h.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(s,v,b,d))}function $(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return h.createElement(H,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return h.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return h.createElement(H,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}function I(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function F(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Y(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function X(e){return function(e,t,n){var o,r,a,s,l,c,u,d,g,f,y,p,m,v,b,x,w,k,A,S,E,L,O,M,P,j,N,D,C,T,B,R;switch(e.type){case"label":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=I(e,n),r=F(e,n);return null==o||null==r?null:Y(o,r,n)?h.createElement($,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,r=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,r=t.y}else o=I(e,n),r=F(e,n);return null==o||null==r?null:Y(o,r,n)?h.createElement($,{key:"ann-"+t,noteData:{x:o,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=I(e,n);if(null==o)return null;const r=e.color||"#f97316";return h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=F(e,n);if(null==o)return null;const r=e.color||"#f97316";return h.createElement("g",{key:"ann-"+t},h.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:I(Object.assign(Object.assign({},e),{type:"point"}),n),y:F(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=i.packEnclose(o),a=e.padding||10;return h.createElement("g",{key:"ann-"+t},h.createElement("circle",{cx:r.x,cy:r.y,r:r.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&h.createElement("text",{x:r.x,y:r.y-r.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:I(Object.assign(Object.assign({},e),{type:"point"}),n),y:F(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),s=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:s,y:c,width:l-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&h.createElement("text",{x:(s+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return h.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=I(t,n),a=F(t,n);return null==r||null==a?null:h.createElement("circle",Object.assign({key:o,cx:r,cy:a,r:e.r||6},i))}))}case"bracket":{const o=I(e,n),r=F(e,n);return h.createElement($,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const i=n.data||[];if(2>i.length)return null;const d=n.xAccessor||"x",g=n.yAccessor||"y",f=i.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(a=n.scales)||void 0===a?void 0:a.time,p=null!==(l=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=n.scales)||void 0===c?void 0:c.value;if(!y||!p)return null;const m=e.method||"linear";let v;if("loess"===m)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*g-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*f-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(f,null!==(u=e.bandwidth)&&void 0!==u?u:.3);else{let t;try{const n=require("regression");t="polynomial"===m?n.polynomial(f,{order:e.order||2}):n.linear(f)}catch(e){return null}v=t.points}const b=v.map(([e,t])=>`${y(e)},${p(t)}`).join(" "),x=e.color||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&h.createElement("text",{x:y(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==g?g:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(y=null==o?void 0:o(e.y0))&&void 0!==y?y:0,i=null!==(p=null==o?void 0:o(e.y1))&&void 0!==p?p:n.height||0;return h.createElement("g",{key:"ann-"+t},h.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(v=null===(m=n.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(b=n.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(k=n.scales)||void 0===k?void 0:k.value;if(!i||!a)return null;const s=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-l,2),0)/s.length,u=Math.sqrt(c),d=null!==(A=e.threshold)&&void 0!==A?A:2,g=l-d*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=null!==(S=e.fillOpacity)&&void 0!==S?S:.1,L=e.anomalyColor||"#ef4444",O=null!==(E=e.anomalyRadius)&&void 0!==E?E:6,M=a(l+d*u),P=a(g),j=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return h.createElement("g",{key:"ann-"+t},f&&h.createElement("rect",{x:0,y:Math.min(M,P),width:n.width||0,height:Math.abs(P-M),fill:y,fillOpacity:p}),j.map((e,t)=>{const o=I(e,n),r=F(e,n);return null==o||null==r?null:h.createElement("circle",{key:t,cx:o,cy:r,r:O,fill:L,fillOpacity:.7,stroke:L,strokeWidth:1.5})}),e.label&&h.createElement("text",{x:(n.width||0)-4,y:Math.min(M,P)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(O=null===(L=n.scales)||void 0===L?void 0:L.x)&&void 0!==O?O:null===(M=n.scales)||void 0===M?void 0:M.time,s=null!==(j=null===(P=n.scales)||void 0===P?void 0:P.y)&&void 0!==j?j:null===(N=n.scales)||void 0===N?void 0:N.value;if(!a||!s)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(u-2,1)),f=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),p=null!==(D=e.confidence)&&void 0!==D?D:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(C=e.steps)&&void 0!==C?C:5,b=l[u-1][0],x=(b-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=c(e),n=g*Math.sqrt(1+1/u+(y>0?Math.pow(e-f,2)/y:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=k.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),E=`${a(b)},${s(c(b))}`,z=e.strokeColor||"#6366f1";return h.createElement("g",{key:"ann-"+t},h.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(T=e.fillOpacity)&&void 0!==T?T:.15,stroke:"none"}),h.createElement("polyline",{points:`${E} ${S}`,fill:"none",stroke:z,strokeWidth:null!==(B=e.strokeWidth)&&void 0!==B?B:2,strokeDasharray:null!==(R=e.strokeDasharray)&&void 0!==R?R:"6,3"}),e.label&&k.length>0&&h.createElement("text",{x:a(k[k.length-1].x)+4,y:s(k[k.length-1].yCenter)-4,fill:z,fontSize:11},e.label))}default:return null}}}function G(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function q(e){return Math.round(100*e)/100+""}function V(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,xLabel:u,yLabel:d,xFormat:g,yFormat:f,showGrid:y,title:p,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:x,yValues:w,annotations:k,svgAnnotationRules:A,annotationFrame:S,xAccessor:E,yAccessor:L,annotationData:O,pointNodes:M,children:P}=t,j=e.useMemo(()=>l&&s?s.x.ticks(5).map(e=>({value:e,pixel:s.x(e),label:(g||q)(e)})):[],[l,s,g]),N=e.useMemo(()=>l&&s?s.y.ticks(5).map(e=>({value:e,pixel:s.y(e),label:(f||q)(e)})):[],[l,s,f]),D=e.useMemo(()=>{if(!k||0===k.length)return null;const e=X(),t={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:E,yAccessor:L,width:n,height:o,data:O,frameType:"xy",pointNodes:M};return k.map((n,o)=>{if(A){const r=A(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[k,A,n,o,S,E,L,O]);return l||p||m||v||b||D&&D.length>0||y||P?h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&s&&h.createElement("g",{className:"stream-grid"},j.map((e,t)=>h.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),N.map((e,t)=>h.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&(()=>{const e=null==c?void 0:c.find(e=>"left"===e.orient),t=null==c?void 0:c.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,l="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, #666)",f="var(--semiotic-text, #333)";return h.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!s&&h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:l,strokeWidth:1}),s&&h.createElement("path",{d:G("bottom",n,o),fill:"none",stroke:l,strokeWidth:1}),j.map((e,t)=>h.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:l,strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},u),r&&!i&&h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:l,strokeWidth:1}),i&&h.createElement("path",{d:G("left",n,o),fill:"none",stroke:l,strokeWidth:1}),N.map((e,t)=>h.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:l,strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},e.label))),d&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},d))})(),D,b&&s&&x&&w&&h.createElement(h.Fragment,null,b.top&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(z,{orient:"top",config:R(b.top),values:x,scale:s.x,size:a.top,length:n})),b.bottom&&h.createElement("g",{transform:`translate(0, ${o})`},h.createElement(z,{orient:"bottom",config:R(b.bottom),values:x,scale:s.x,size:a.bottom,length:n})),b.left&&h.createElement("g",{transform:"translate(0, 0)"},h.createElement(z,{orient:"left",config:R(b.left),values:w,scale:s.y,size:a.left,length:o})),b.right&&h.createElement("g",{transform:`translate(${n}, 0)`},h.createElement(z,{orient:"right",config:R(b.right),values:w,scale:s.y,size:a.right,length:o}))),v,P),p&&h.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),m&&h.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!h.isValidElement(e)&&"legendGroups"in e}(m)?h.createElement(B,{legendGroups:m.legendGroups,title:"",width:100}):m)):null}function U(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}const Z=(e,t,n,o)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;if(e.globalAlpha=i,e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},Q=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"point"===e.type);for(const t of a){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},J=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?K(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function K(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.w)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}const ee={line:[Z,(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const a=i.style.stroke||"#007bff",s=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=s,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,g=null,f=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),f=!0}function p(){f&&(e.stroke(),f=!1)}for(let m=0;i.path.length>m;m++){const[v,b]=i.path[m],x=c[m],w=U(x,l,a);if(null!==u&&null!==g&&null!==h){if(w===g)e.lineTo(v,b);else{const k=[];for(const A of l){const S=A.value;(h>S||S>x)&&(S>h||x>S)||h===S||x===S||k.push({t:(S-h)/(x-h)})}k.sort((e,t)=>e.t-t.t);for(const E of k){const L=u+(v-u)*E.t,O=d+(b-d)*E.t,M=U(h+(x-h)*Math.min(E.t+1e-4,1),l,a);e.lineTo(L,O),p(),y(M,L,O)}e.lineTo(v,b)}u=v,d=b,h=x,g=w}else y(w,v,b),u=v,d=b,h=x,g=w}p()}else{e.beginPath(),e.strokeStyle=a;const[P,j]=i.path[0];e.moveTo(P,j);for(let N=1;i.path.length>N;N++)e.lineTo(i.path[N][0],i.path[N][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[D,C]=i.path[0];e.moveTo(D,C);for(let B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const T=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(T,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[Z],stackedarea:[Z],scatter:[Q],bubble:[Q],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[J],swarm:[Q],waterfall:[(e,t,n,o)=>{var r,i,a;J(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}}]},te={top:20,right:20,bottom:30,left:40},ne={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},oe={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({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return h.createElement("div",{className:"semiotic-tooltip",style:oe},h.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),h.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function ie({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u}){const d=e.useRef(null),g=e.useRef(null);return e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{if(!c)return;if(!e.selection)return void u(null);let t,n;if("x"===l){const[o,i]=e.selection;t=[c.x.invert(o),c.x.invert(i)],n=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,i]=e.selection;t=[c.x.invert(0),c.x.invert(o)],n=[c.y.invert(i),c.y.invert(r)]}else{const[[o,r],[i,a]]=e.selection;t=[c.x.invert(o),c.x.invert(i)],n=[c.y.invert(a),c.y.invert(r)]}u({x:t,y:n})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l,c,u]),h.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const ae=e.forwardRef(function(t,n){var o,r,i;const{chartType:a,runtimeMode:s,data:l,xAccessor:c,yAccessor:u,colorAccessor:d,sizeAccessor:g,groupAccessor:y,lineDataAccessor:p,normalize:m,binSize:v,valueAccessor:b,arrowOfTime:x="right",windowMode:w="sliding",windowSize:k=200,timeAccessor:A,xExtent:S,yExtent:D,extentPadding:C=.1,sizeRange:T,size:B=[500,300],margin:R,className:z,background:W,lineStyle:_,pointStyle:H,areaStyle:$,waterfallStyle:I,swarmStyle:F,barColors:Y,colorScheme:X,boundsAccessor:G,boundsStyle:q,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:J,candlestickStyle:K,showAxes:oe=!0,axes:ae,xLabel:se,yLabel:le,xFormat:ce,yFormat:ue,tickFormatTime:de,tickFormatValue:he,hoverAnnotation:ge,tooltipContent:fe,customHoverBehavior:ye,enableHover:pe,annotations:me,svgAnnotationRules:ve,showGrid:be,legend:xe,backgroundGraphics:we,foregroundGraphics:ke,title:Ae,categoryAccessor:Se,brush:Ee,onBrush:Le,decay:Oe,pulse:Me,transition:Pe,staleness:je,heatmapAggregation:Ne,heatmapXBins:De,heatmapYBins:Ce,marginalGraphics:Te,pointIdAccessor:Be}=t,Re=Object.assign(Object.assign({},te),R);if(Te){const e=60;Te.top&&e>Re.top&&(Re.top=e),Te.bottom&&e>Re.bottom&&(Re.bottom=e),Te.left&&e>Re.left&&(Re.left=e),Te.right&&e>Re.right&&(Re.right=e)}const ze=B[0]-Re.left-Re.right,We=B[1]-Re.top-Re.bottom,_e=null!=ge?ge:pe,He=e.useRef(null),$e=e.useRef(0),Ie=e.useRef(!1),[Fe,Ye]=e.useState(0),[Xe,Ge]=e.useState(null),qe=e.useRef(null),Ve=e.useRef(null),[Ue,Ze]=e.useState(null),[Qe,Je]=e.useState(!1),[Ke,et]=e.useState([]),[tt,nt]=e.useState([]),ot=e.useRef(()=>{}),rt="streaming"===s||["bar","swarm","waterfall"].includes(a),it=e.useMemo(()=>({chartType:a,runtimeMode:rt?"streaming":"bounded",windowSize:k,windowMode:w,arrowOfTime:rt?x:"right",extentPadding:C,xAccessor:rt?void 0:c,yAccessor:rt?void 0:u,timeAccessor:rt?A:void 0,valueAccessor:b,colorAccessor:d,sizeAccessor:g,groupAccessor:y,categoryAccessor:Se,lineDataAccessor:p,xExtent:S,yExtent:D,sizeRange:T,binSize:v,normalize:m,boundsAccessor:G,boundsStyle:q,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:J,candlestickStyle:K,lineStyle:_,pointStyle:H,areaStyle:$,swarmStyle:F,waterfallStyle:I,colorScheme:X,barColors:Y,annotations:me,decay:Oe,pulse:Me,transition:Pe,staleness:je,heatmapAggregation:Ne,heatmapXBins:De,heatmapYBins:Ce,pointIdAccessor:Be}),[a,k,w,x,C,c,u,A,b,d,g,y,Se,p,S,D,T,v,m,G,q,U,Z,Q,J,K,_,H,$,F,I,X,Y,me,Oe,Me,Pe,je,Ne,De,Ce,rt,Be]),at=e.useRef(null);at.current||(at.current=new E(it));const st=e.useCallback(()=>{$e.current||($e.current=requestAnimationFrame(()=>ot.current()))},[]);e.useEffect(()=>{var e;null===(e=at.current)||void 0===e||e.updateConfig(it),Ie.current=!0,st()},[it,st]);const lt=e.useRef(null);lt.current||(lt.current=new f(e=>{const t=at.current;t&&t.ingest(e)&&(Ie.current=!0,st())}));const ct=e.useCallback(e=>{var t;null===(t=lt.current)||void 0===t||t.push(e)},[]),ut=e.useCallback(e=>{var t;null===(t=lt.current)||void 0===t||t.pushMany(e)},[]),dt=e.useCallback(()=>{var e,t;null===(e=lt.current)||void 0===e||e.clear(),null===(t=at.current)||void 0===t||t.clear(),Ie.current=!0,st()},[st]);e.useImperativeHandle(n,()=>({push:ct,pushMany:ut,clear:dt,getData:()=>{var e,t;return null!==(t=null===(e=at.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=at.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=at.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[ct,ut,dt]),e.useEffect(()=>{var e;l&&(null===(e=lt.current)||void 0===e||e.setBoundedData(l))},[l]);const ht=e.useRef(()=>{}),gt=e.useRef(()=>{});ht.current=e=>{if(!_e)return;const t=He.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Re.left,r=e.clientY-n.top-Re.top;if(0>o||o>ze||0>r||r>We)return void(qe.current&&(qe.current=null,Ve.current=null,Ze(null),ye&&ye(null),st()));const i=at.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=L(i,t,n);break;case"line":e=O(i,t,n);break;case"rect":e=M(i,t,n);break;case"heatcell":e=P(i,t,n);break;case"area":if(!1===i.interactive)break;e=N(i,t,n);break;case"candlestick":e=j(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,o,r);if(!a)return void(qe.current&&(qe.current=null,Ve.current=null,Ze(null),ye&&ye(null),st()));const s={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};qe.current=s,Ve.current=a.node,Ze(s),ye&&ye(s),st()},gt.current=()=>{qe.current&&(qe.current=null,Ve.current=null,Ze(null),ye&&ye(null),st())};const ft=e.useCallback(e=>ht.current(e),[]),yt=e.useCallback(()=>gt.current(),[]);ot.current=()=>{var e,t;$e.current=0;const n=He.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=at.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i);s||r.computeScene({width:ze,height:We});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=B[0]*l,n.height=B[1]*l,n.style.width=B[0]+"px",n.style.height=B[1]+"px",o.scale(l,l),o.translate(Re.left,Re.top),o.clearRect(-Re.left,-Re.top,B[0],B[1]);const d=function(e){if(!e)return ne;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||ne.axisStroke,tickText:i||ne.tickText,crosshair:i?i+"66":ne.crosshair,hoverFill:l?l+"4D":ne.hoverFill,hoverStroke:i?i+"99":ne.hoverStroke,pointRing:l||ne.pointRing}:ne}(n),h=null!==(e=null==je?void 0:je.threshold)&&void 0!==e?e:5e3,g=je&&r.lastIngestTime>0&&i-r.lastIngestTime>h;g&&(o.globalAlpha=null!==(t=null==je?void 0:je.dimOpacity)&&void 0!==t?t:.5);const f=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",y=W||(f&&"transparent"!==f?f:null);y&&(o.fillStyle=y,o.fillRect(-Re.left,-Re.top,B[0],B[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,ze,We),o.clip());const p=ee[a];if(p&&r.scales)for(const e of p)e(o,r.scene,r.scales,{width:ze,height:We});if(o.restore(),g&&(o.globalAlpha=1),_e&&qe.current&&r.scales&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;e.save();const s="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=s.stroke||a.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}(o,qe.current,ze,We,"object"==typeof _e?_e:{},0,d),Ve.current&&Array.isArray(ge)){const e=ge.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(o,r.scene,Ve.current,e)}const m=Ie.current;if(Ie.current=!1,m&&r.scales&&(Ge(r.scales),Te)){const e=r.getData(),t="function"==typeof c?c:e=>e[c||"x"],n="function"==typeof u?u:e=>e[u||"y"];et(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),nt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}m&&me&&me.length>0&&Ye(e=>e+1),(null==je?void 0:je.showBadge)&&Je(!!g),(s||r.hasActivePulses)&&($e.current=requestAnimationFrame(()=>ot.current()))},e.useEffect(()=>(st(),()=>{$e.current&&cancelAnimationFrame($e.current)}),[st]),e.useEffect(()=>{Ie.current=!0,st()},[a,ze,We,oe,W,_,st]),e.useEffect(()=>{if(!je)return;const e=setInterval(()=>{var e;const t=at.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=je.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==Qe&&(Je(r),Ie.current=!0,st())},1e3);return()=>clearInterval(e)},[je,Qe,st]);const pt=_e&&Ue?fe?fe(Ue):h.createElement(re,{hover:Ue}):null,mt=pt?h.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Re.left+Ue.x,top:Re.top+Ue.y,transform:`translate(${Ue.x>.7*ze?"calc(-100% - 12px)":"12px"}, ${.3*We>Ue.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},pt):null;return h.createElement("div",{className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof Ae?Ae:"XY chart",style:{position:"relative",width:B[0],height:B[1]},onMouseMove:_e?ft:void 0,onMouseLeave:_e?yt:void 0},we&&h.createElement("svg",{style:{position:"absolute",left:0,top:0,width:B[0],height:B[1],pointerEvents:"none"}},we),h.createElement("canvas",{ref:He,style:{position:"absolute",left:0,top:0}}),h.createElement(V,{width:ze,height:We,totalWidth:B[0],totalHeight:B[1],margin:Re,scales:Xe,showAxes:oe,axes:ae,xLabel:se,yLabel:le,xFormat:ce||de,yFormat:ue||he,showGrid:be,title:Ae,legend:xe,foregroundGraphics:ke,marginalGraphics:Te,xValues:Ke,yValues:tt,annotations:me,svgAnnotationRules:ve,annotationFrame:Fe,xAccessor:"string"==typeof c?c:"string"==typeof A?A:void 0,yAccessor:"string"==typeof u?u:"string"==typeof b?b:void 0,annotationData:null===(o=at.current)||void 0===o?void 0:o.getData(),pointNodes:null===(r=at.current)||void 0===r?void 0:r.scene.filter(e=>"point"===e.type)}),(Ee||Le)&&h.createElement(ie,{width:ze,height:We,totalWidth:B[0],totalHeight:B[1],margin:Re,dimension:null!==(i=null==Ee?void 0:Ee.dimension)&&void 0!==i?i:"xy",scales:Xe,onBrush:null!=Le?Le:()=>{}}),(null==je?void 0:je.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===je.badgePosition?{top:4,left:4}:"bottom-left"===je.badgePosition?{bottom:4,left:4}:"bottom-right"===je.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Qe?"#dc3545":"#28a745",color:"white"})},Qe?"STALE":"LIVE"),mt)});function se(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function le(e){var t,n,o;const i=e.length,a=e[0],s=e[i-1];return{n:i,min:a,q1:null!==(t=r.quantile(e,.25))&&void 0!==t?t:a,median:null!==(n=r.quantile(e,.5))&&void 0!==n?n:(a+s)/2,q3:null!==(o=r.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}ae.displayName="StreamXYFrame";const ce={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const f=s(c.pieces[0],a?i:e.name),y=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const n=l(0>t?r:o+t),a=0>t?l(r+t)-l(r):l(o)-l(o+t);u.push(w(e.x,n,e.width,Math.abs(a),f,y,i)),0>t?r+=t:o+=t}else if(h){const n=l(0>t?r+t:o),a=0>t?l(r)-l(r+t):l(o+t)-l(o);u.push(w(n,e.x,Math.abs(a),e.width,f,y,i)),0>t?r+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;d.length>o;o++){const i=n.get(d[o])||[];for(const n of i){const i=r(n),l=a(n,e.name);if(u){const r=e.x+o*t,a=s(0),u=s(i);c.push(w(r,Math.min(a,u),t,Math.abs(a-u),l,n,d[o]))}else{const r=e.x+o*t,a=s(0),u=s(i);c.push(w(Math.min(a,u),r,Math.abs(u-a),t,l,n,d[o]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,f=s.length>0,y=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=f&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=p+(e.pctStart+e.pct/2)*y,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),f=c?a(s):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:o})}}return l},pie:se,donut:se,boxplot:function(e,t){var n,o,i,a,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:f}=l,y=[],p="vertical"===f,m=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(n=r.quantile(t,.25))&&void 0!==n?n:l,f=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(i=r.quantile(t,.75))&&void 0!==i?i:c,b=v-u,x=u-1.5*b,w=v+1.5*b,k=null!==(a=t.find(e=>e>=x))&&void 0!==a?a:l,A=null!==(s=[...t].reverse().find(e=>w>=e))&&void 0!==s?s:c,S=h(e.pieceData[0],e.name),E=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>w){const o=p?e.middle:g(n),r=p?g(n):e.middle;E.push({px:o,py:r,value:n,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(k),q1Pos:g(u),medianPos:g(f),q3Pos:g(v),maxPos:g(A),stats:{min:k,q1:u,median:f,q3:v,max:A},style:S,datum:e.pieceData,category:e.name,outliers:E}),m)for(const e of E)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:e.datum})}return y},violin:function(e,t){var n,o,i;const{scales:a,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=a,g=[],f="vertical"===h,y=l.bins||20,p=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const a=t[0],s=t[t.length-1],l=(s-a)/y||1,h=Array(y).fill(0);for(const e of t)h[Math.min(Math.floor((e-a)/l),y-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){for(let t=0;y>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=y-1;t>=0;t--){const n=d(a+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{for(let t=0;y>t;t++){const n=d(a+(t+.5)*l),o=h[t]/m*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=y-1;t>=0;t--)b+=` L ${d(a+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let w;if(p&&t.length>=4){const l=null!==(n=r.quantile(t,.25))&&void 0!==n?n:a,c=null!==(o=r.quantile(t,.5))&&void 0!==o?o:(a+s)/2,u=null!==(i=r.quantile(t,.75))&&void 0!==i?i:s;w={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const k=f?{x:e.x,y:Math.min(d(s),d(a)),width:e.width,height:Math.abs(d(s)-d(a))}:{x:Math.min(d(a),d(s)),y:e.x,width:Math.abs(d(s)-d(a)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:k,iqrLine:w,stats:le(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s}=n,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-n)/o),c-1)]++;const d=t.length,h=Math.max(...r,1),g=a(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,a=s(n+t*o),c=s(n+(t+1)*o);l.push(w(Math.min(a,c),e.x+e.width-i,Math.abs(c-a),i,g,{bin:t,count:r[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),d-1)]++;const f=Math.max(...c,1),y=s(e.pieceData[0],e.name),p=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/f*p}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/f*p} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:le(t),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(w(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(w(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class ue{constructor(e){this.rExtent=new p,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new y(e.windowSize),this.getO=S(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>A(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new p)):(this.getR=A(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=S(e.stackBy),this.getGroup=S(e.groupBy),this.getColor=S(e.colorAccessor),this.getConnector=S(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new y(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const r=n.toArray(),i=t.projection||"vertical",a=t.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,a),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=o.scaleBand().domain(a).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=o.scaleLinear().domain(s).range([r,n])}else l?(u=o.scaleBand().domain(a).range([0,e.height]).padding(c),d=o.scaleLinear().domain(s).range([0,e.width])):(u=o.scaleBand().domain(a).range([0,e.width]).padding(c),d=o.scaleLinear().domain(s).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{const a=this.rExtents[i];a.dirty&&a.recalculate(n,r);let[s,c]=a.extent;s===1/0&&(s=0,c=1);const u=c-s,d=u>0?u*(t.extentPadding||.05):1;return s-=d,c+=d,s>0&&(s=0),l?o.scaleLinear().domain([s,c]).range([0,e.width]):o.scaleLinear().domain([s,c]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,a,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let a=0,s=0;if("bar"===r&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>s&&(s=e);for(const e of n.values())a>e&&(a=e)}else if("bar"===r){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>s&&(s=e),a>e&&(a=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>s&&(s=e),a>e&&(a=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(a=e),t!==-1/0&&(s=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const l=s-a,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(a-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(s+=c),"bar"!==r&&"clusterbar"!==r||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=ce[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const r=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let s=null;if("point"===i.type?s="p:"+e:"rect"===i.type&&(s=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!s)continue;const l=this.prevPositionMap.get(s);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,a=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,r=this.prevPositionMap.get(t);if(!r)continue;e.x=r.x+(e._targetX-r.x)*i,e.y=r.y+(e._targetY-r.y)*i,void 0!==r.w&&(e.w=r.w+(e._targetW-r.w)*i,e.h=r.h+(e._targetH-r.h)*i)}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function de(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function he(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function ge(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function fe(e,t,n){const o=e.columnWidth/2,r=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:r}}else{const i=e.y-o,a=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>a))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:r}}return null}function ye(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function pe(e){return Math.round(100*e)/100+""}function me(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,oLabel:c,rLabel:u,oFormat:d,rFormat:g,showGrid:f,title:y,legend:p,foregroundGraphics:m,annotations:v,svgAnnotationRules:b,annotationFrame:x,xAccessor:w,yAccessor:k,annotationData:A,children:S}=t,E="radial"===(null==s?void 0:s.projection),L="horizontal"===(null==s?void 0:s.projection),O=e.useMemo(()=>l&&s&&!E?s.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=s.o(e))&&void 0!==t?t:0)+s.o.bandwidth()/2,label:d?d(e):e}}):[],[l,s,d,E]),M=e.useMemo(()=>l&&s&&!E?s.r.ticks(5).map(e=>({value:e,pixel:s.r(e),label:(g||pe)(e)})):[],[l,s,g,E]),P=e.useMemo(()=>{if(!v||0===v.length)return null;const e=X(),t={scales:s?{x:s.r,y:s.r,time:s.r,value:s.r}:null,timeAxis:"x",xAccessor:w,yAccessor:k,width:n,height:o,data:A,frameType:"ordinal"};return v.map((n,o)=>{if(b){const r=b(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[v,b,n,o,x,w,k,A]);return l||y||p||m||P&&P.length>0||f||S?h.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${a.left},${a.top})`},f&&s&&!E&&h.createElement("g",{className:"ordinal-grid"},M.map((e,t)=>h.createElement("line",{key:"grid-"+t,x1:L?e.pixel:0,y1:L?0:e.pixel,x2:L?e.pixel:n,y2:L?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),l&&s&&!E&&h.createElement("g",{className:"ordinal-axes"},L?h.createElement(h.Fragment,null,h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),O.map((e,t)=>h.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},c),h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),M.map((e,t)=>h.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u)):h.createElement(h.Fragment,null,h.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),O.map((e,t)=>h.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${o})`},h.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),c&&h.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},c),h.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),M.map((e,t)=>h.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},h.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),h.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),u&&h.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},u))),P,m,S),y&&h.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof y?y:null),p&&h.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},function(e){return"object"==typeof e&&null!==e&&!h.isValidElement(e)&&"legendGroups"in e}(p)?h.createElement(B,{legendGroups:p.legendGroups,title:"",width:100}):p)):null}const ve=(e,t,n,o)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},be=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},xe=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}},we=e=>[xe,...e],ke={bar:we([J]),clusterbar:we([J]),point:we([Q]),swarm:we([Q]),pie:[ve],donut:[ve],boxplot:we([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Q]),violin:we([be]),histogram:we([J]),ridgeline:we([be]),timeline:we([J])},Ae={top:50,right:40,bottom:60,left:70},Se={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ee({hover:e}){var t,n,o,r;const i=e.data||{},a=e.stats,s=e.category;if(Array.isArray(i)){const e=s||(null===(t=i[0])||void 0===t?void 0:t.category)||"";if(a)return h.createElement("div",{className:"semiotic-tooltip",style:Se},e&&h.createElement("div",{style:{fontWeight:"bold"}},e+""),h.createElement("div",null,"n = ",a.n),h.createElement("div",null,"Min: ",a.min.toLocaleString()),h.createElement("div",null,"Q1: ",a.q1.toLocaleString()),h.createElement("div",null,"Median: ",a.median.toLocaleString()),h.createElement("div",null,"Q3: ",a.q3.toLocaleString()),h.createElement("div",null,"Max: ",a.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=i.length;return h.createElement("div",{className:"semiotic-tooltip",style:Se},e&&h.createElement("div",{style:{fontWeight:"bold"}},e+""),h.createElement("div",null,n," items"))}if(null!=i.bin&&null!=i.count){const e=i.range||[];return h.createElement("div",{className:"semiotic-tooltip",style:Se},i.category&&h.createElement("div",{style:{fontWeight:"bold"}},i.category+""),h.createElement("div",null,"Count: ",i.count),2===e.length&&h.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const l=i.category||i.name||i.group||i.__rName||"",c=null!==(r=null!==(o=null!==(n=i.value)&&void 0!==n?n:i.__rValue)&&void 0!==o?o:i.pct)&&void 0!==r?r:"";if(!l&&""===c){const e=Object.entries(i).filter(([e])=>!e.startsWith("_")&&"data"!==e);return h.createElement("div",{className:"semiotic-tooltip",style:Se},e.map(([e,t])=>h.createElement("div",{key:e},h.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return h.createElement("div",{className:"semiotic-tooltip",style:Se},l&&h.createElement("div",{style:{fontWeight:"bold"}},l+""),""!==c&&h.createElement("div",null,"number"==typeof c?c.toLocaleString():c+""))}const Le=e.forwardRef(function(t,n){var o;const{chartType:r,runtimeMode:i,data:a,oAccessor:s="category",rAccessor:l="value",colorAccessor:c,stackBy:u,groupBy:d,multiAxis:g,timeAccessor:y,valueAccessor:p,categoryAccessor:m,projection:v="vertical",size:b=[600,400],margin:x,barPadding:w,innerRadius:k,normalize:A,startAngle:S,dynamicColumnWidth:E,bins:L,showOutliers:O,showIQR:M,amplitude:P,connectorAccessor:j,connectorStyle:N,rExtent:D,oExtent:C,extentPadding:T=.05,oSort:B,windowMode:R="sliding",windowSize:z=200,pieceStyle:W,summaryStyle:_,colorScheme:H,barColors:$,showAxes:I=!0,oLabel:F,rLabel:Y,oFormat:X,rFormat:G,enableHover:q=!0,hoverAnnotation:V,tooltipContent:U,customHoverBehavior:Z,annotations:Q,svgAnnotationRules:J,showGrid:K=!1,legend:ee,backgroundGraphics:te,foregroundGraphics:ne,title:oe,className:re,background:ie,centerContent:ae,decay:se,pulse:le,transition:ce,staleness:pe}=t,ve=e.useMemo(()=>Object.assign(Object.assign({},Ae),x),[x]),be=b[0]-ve.left-ve.right,xe=b[1]-ve.top-ve.bottom,we=e.useRef(null),Se=e.useRef(!0),Le=e.useRef(0),Oe=e.useRef(null),Me=e.useRef(()=>{}),[Pe,je]=e.useState(null),[Ne,De]=e.useState(null),[Ce,Te]=e.useState(0),[Be,Re]=e.useState(!1),ze=q||V,We="streaming"===i,_e=e.useMemo(()=>({chartType:r,runtimeMode:We?"streaming":"bounded",windowSize:z,windowMode:R,extentPadding:T,projection:v,oAccessor:We?void 0:s,rAccessor:We?void 0:l,colorAccessor:c,stackBy:u,groupBy:d,multiAxis:g,timeAccessor:We?y:void 0,valueAccessor:We?p||("string"==typeof l||"function"==typeof l?l:void 0):void 0,categoryAccessor:We?m||s:void 0,rExtent:D,oExtent:C,barPadding:w,innerRadius:k,normalize:A,startAngle:S,dynamicColumnWidth:E,bins:L,showOutliers:O,showIQR:M,amplitude:P,connectorAccessor:j,connectorStyle:N,oSort:B,pieceStyle:W,summaryStyle:_,colorScheme:H,barColors:$,decay:se,pulse:le,transition:ce,staleness:pe}),[r,z,R,T,v,s,l,c,u,d,g,y,p,m,D,C,w,k,A,S,E,L,O,M,P,j,N,B,W,_,H,$,se,le,ce,pe,We]),He=e.useRef(null);He.current||(He.current=new ue(_e));const $e=e.useCallback(()=>{Le.current||(Le.current=requestAnimationFrame(()=>Me.current()))},[]);e.useEffect(()=>{var e;null===(e=He.current)||void 0===e||e.updateConfig(_e),Se.current=!0,$e()},[_e,$e]);const Ie=e.useRef(null);Ie.current||(Ie.current=new f(e=>{const t=He.current;t&&t.ingest(e)&&(Se.current=!0,$e())}));const Fe=e.useCallback(e=>{var t;null===(t=Ie.current)||void 0===t||t.push(e)},[]),Ye=e.useCallback(e=>{var t;null===(t=Ie.current)||void 0===t||t.pushMany(e)},[]),Xe=e.useCallback(()=>{var e,t;null===(e=Ie.current)||void 0===e||e.clear(),null===(t=He.current)||void 0===t||t.clear(),Se.current=!0,$e()},[$e]);e.useImperativeHandle(n,()=>({push:Fe,pushMany:Ye,clear:Xe,getData:()=>{var e,t;return null!==(t=null===(e=He.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=He.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Fe,Ye,Xe]),e.useEffect(()=>{var e;a&&(null===(e=Ie.current)||void 0===e||e.setBoundedData(a))},[a]);const Ge=e.useRef(()=>{}),qe=e.useRef(()=>{});Ge.current=e=>{if(!ze)return;const t=we.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>xe)return void(Oe.current&&(Oe.current=null,je(null),Z&&Z(null),$e()));const i=He.current;if(!i||0===i.scene.length)return;const a="radial"===v,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=de(i,t,n);break;case"point":e=he(i,t,n);break;case"wedge":e=ge(i,t,n);break;case"boxplot":e=fe(i,t,n);break;case"violin":e=ye(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-be/2:o,a?r-xe/2:r);if(!s)return void(Oe.current&&(Oe.current=null,je(null),Z&&Z(null),$e()));const l=Object.assign(Object.assign({data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y},s.stats&&{stats:s.stats}),s.category&&{category:s.category});Oe.current=l,je(l),Z&&Z(l),$e()},qe.current=()=>{Oe.current&&(Oe.current=null,je(null),Z&&Z(null),$e())};const Ve=e.useCallback(e=>Ge.current(e),[]),Ue=e.useCallback(()=>qe.current(),[]);Me.current=()=>{var e,t;Le.current=0;const n=we.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=He.current;if(!i)return;const a="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(a),l=Se.current;l&&!s&&(i.computeScene({width:be,height:xe}),Se.current=!1);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=b[0]*c,n.height=b[1]*c,n.style.width=b[0]+"px",n.style.height=b[1]+"px",o.scale(c,c),o.clearRect(0,0,b[0],b[1]);const u=null!==(e=null==pe?void 0:pe.threshold)&&void 0!==e?e:5e3,d=pe&&i.lastIngestTime>0&&a-i.lastIngestTime>u;d&&(o.globalAlpha=null!==(t=null==pe?void 0:pe.dimOpacity)&&void 0!==t?t:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=ie||(h&&"transparent"!==h?h:null);g&&(o.fillStyle=g,o.fillRect(0,0,b[0],b[1]));const f="radial"===v;f?(o.save(),o.translate(ve.left+be/2,ve.top+xe/2)):o.translate(ve.left,ve.top);const y=ke[r]||[],p={width:be,height:xe};for(const e of y)e(o,i.scene,i.scales,p);f&&o.restore(),d&&(o.globalAlpha=1),l&&i.scales&&(De(i.scales),Te(e=>e+1)),(null==pe?void 0:pe.showBadge)&&Re(!!d),(s||i.hasActivePulses)&&(Le.current=requestAnimationFrame(()=>Me.current()))},e.useEffect(()=>($e(),()=>{Le.current&&cancelAnimationFrame(Le.current)}),[$e]),e.useEffect(()=>{Se.current=!0,$e()},[r,be,xe,I,ie,$e]),e.useEffect(()=>{if(!pe)return;const e=setInterval(()=>{var e;const t=He.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=pe.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==Be&&(Re(r),Se.current=!0,$e())},1e3);return()=>clearInterval(e)},[pe,Be,$e]);const Ze=ze&&Pe?U?U(Pe):h.createElement(Ee,{hover:Pe}):null,Qe="radial"===v,Je=Pe?Qe?Pe.x+be/2:Pe.x:0,Ke=Pe?Qe?Pe.y+xe/2:Pe.y:0,et=Ze?h.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:ve.left+Je,top:ve.top+Ke,transform:`translate(${Je>.7*be?"calc(-100% - 12px)":"12px"}, ${.3*xe>Ke?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Ze):null;return h.createElement("div",{className:"stream-ordinal-frame"+(re?" "+re:""),role:"img","aria-label":"string"==typeof oe?oe:"Ordinal chart",style:{position:"relative",width:b[0],height:b[1]},onMouseMove:ze?Ve:void 0,onMouseLeave:ze?Ue:void 0},te&&h.createElement("svg",{style:{position:"absolute",top:0,left:0,width:b[0],height:b[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${ve.left},${ve.top})`},te)),h.createElement("canvas",{ref:we,style:{position:"absolute",top:0,left:0,width:b[0],height:b[1]}}),h.createElement(me,{width:be,height:xe,totalWidth:b[0],totalHeight:b[1],margin:ve,scales:Ne,showAxes:I,oLabel:F,rLabel:Y,oFormat:X,rFormat:G,showGrid:K,title:oe,legend:ee,foregroundGraphics:ne,annotations:Q,svgAnnotationRules:J,annotationFrame:Ce,xAccessor:"string"==typeof s?s:void 0,yAccessor:"string"==typeof l?l:void 0,annotationData:null===(o=He.current)||void 0===o?void 0:o.getData()}),ae&&"radial"===v&&h.createElement("div",{style:{position:"absolute",left:ve.left+be/2,top:ve.top+xe/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ae),(null==pe?void 0:pe.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===pe.badgePosition?{top:4,left:4}:"bottom-left"===pe.badgePosition?{bottom:4,left:4}:"bottom-right"===pe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Be?"#dc3545":"#28a745",color:"white"})},Be?"STALE":"LIVE"),et)});Le.displayName="StreamOrdinalFrame";const Oe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Me={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Pe{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,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=je(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.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 je(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=Ne(l,c,u,d,s),g=d.x-l.x,f=d.y-l.y,y=Math.sqrt(g*g+f*f);if(y>.001){const e=g/y;h.x+=-f/y*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=Ne(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function Ne(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function De(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Ce(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var f=i[t];g.length>f;++f){var y=g[f];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||s[t].push(a[y])}i[t]=f}else{if(o[t]===n[t]){var p=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(r[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=f;break}}d.push(p);var x=Array(v);for(f=0;m.length>f;f++)for(var w=0;m[f].length>w;w++)x[--v]=m[f][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var y=1;f.length>y;y++)f[y]!==f[y-1]&&c.push(f[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var f=0;s.length>f;f++)for(var y=0;s[f].length>y;y++){var p=s[f][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return o}function Te(e){return e.y0-e.y1>0?"up":"down"}function Be(e,t){return t(e.source)==t(e.target)}function Re(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function ze(e){return e.target.x0-e.source.x1}function We(e,t){var n=He(e),o=ze(t)/Math.tan(n);return"up"==Te(e)?e.y1-o:e.y1+o}function _e(e,t){var n=He(e),o=ze(t)/Math.tan(n);return"up"==Te(e)?e.y1+o:e.y1-o}function He(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function $e(e,t){return t(e)}function Ie(e){return Ye(e.source)}function Fe(e){return Ye(e.target)}function Ye(e){return(e.y0+e.y1)/2}function Xe(e){return e.virtual?0:e.value}function Ge(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Be(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Be(e,t)?o+1:o}),n+o}function qe(e){return e.target.depth}function Ve(e,t){return e.sourceLinks.length?e.depth:t-1}function Ue(e,t){return e.y0-t.y0}function Ze(e,t){return t.y0-e.y0}function Qe(e,t){return e.y1-t.y1}function Je(e,t){return t.y1-e.y1}function Ke(e,t){return tt(e.source,t.source)||e.index-t.index}function et(e,t){return tt(e.target,t.target)||e.index-t.index}function tt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function nt(e,t){return ot(e)==ot(t)?"bottom"==e.circularLinkType?Ze(e,t):Ue(e,t):ot(t)-ot(e)}function ot(e){return e.target.column-e.source.column}function rt(e,t){return it(e)==it(t)}function it(e){return e.y0-e.y1>0?"up":"down"}function at(e,t,n,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),st(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),st(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,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,Be(e,t)&&Re(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+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-i-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,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?Ze:Ue);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?Je:Qe),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-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,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),a}function st(e,t,n){e.sort(nt);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Be(e,t)&&Re(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&lt(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function lt(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function ct(e){return function(){return e}}function ut(e){return e.index}function dt(e){return e.nodes}function ht(e){return e.links}function gt(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?Ge(t,n)-Ge(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==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Ge(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)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function ft(e,t,n,o,i,a){var s=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 l=1,c=a;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ge(i,n)>0){var c=r.mean(i.sourceLinks,Fe),u=r.mean(i.targetLinks,Ie),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ye(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var g=r.mean(i.sourceLinks,Fe),f=r.mean(i.targetLinks,Ie),y=((g&&f?(g+f)/2:g||f)-Ye(i))*t;i.y0+=y,i.y1+=y}})})}function d(){s.forEach(function(n){var r,a,s,l=e.y0,c=n.length;for(n.sort(t||tt),s=0;c>s;++s)(a=l-(r=n[s]).y0)>0&&(r.y0+=a,r.y1+=a),l=r.y1+o;if((a=l-o-e.y1)>0)for(l=r.y0-=a,r.y1-=a,s=c-2;s>=0;--s)(a=(r=n[s]).y1+i-l)>0&&(r.y0-=a,r.y1-=a),l=r.y0})}}function yt(e){e.nodes.forEach(function(e){e.sourceLinks.sort(et),e.targetLinks.sort(Ke)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function pt(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,l=ut,c=Ve,u=void 0,d=32,h=2,g=dt,f=ht;function y(){var y={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=n,g.y1=o,g.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 o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=De(n,o)),"object"!=typeof r&&(r=e.target=De(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(g,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=Ce(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(g,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){$e(e,t)!=$e(r.source,t)&&$e(e,t)!=$e(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Be(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,Xe),r.sum(e.targetLinks,Xe)),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)})})}(g),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(g,u,c);var f=a;if(null!==s){var y=r.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=r.max(y,function(e){return e.length});p>1&&(f=Math.max(1,(o-t)*s/(p-1)))}(function(e,t,n){var o=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 i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,f,i),gt(g,u,l),ft(g,u,l,f,f,d),yt(g),at(g,l,h,10,8),gt(g,u,l),ft(g,u,l,f,f,d),yt(g),at(g,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return $e(n.source,t)==$e(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!rt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=We(t,e);return e.y1-n}if(t.target.column>e.target.column)return We(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 i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(g,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return $e(n.target,t)==$e(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!rt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=_e(t,e);return e.y0-n}if(t.source.column>e.source.column)return _e(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 i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(g,l),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),s=r.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-a);function c(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(g),at(g,l,h,10,8)}(y),y}return y.update=function(e){return yt(e),at(e,l,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(a=+e,y):a},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(g="function"==typeof e?e:ct(e),y):g},y.links=function(e){return arguments.length?(f="function"==typeof e?e:ct(e),y):f},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:ct(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:ct(e),y):c},y.nodeSort=function(e){return arguments.length?(u=e,y):u},y.iterations=function(e){return arguments.length?(d=+e,y):d},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],y):[[e,t],[n,o]]},y.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],y):[n-e,o-t]},y}const mt=e=>{let t,n,o,r,i,s,l,c,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.y1,s=e.target.y0,l=a.interpolateNumber(i,s),c=l(.5),u=l(.5),`M${t},${i}C${t},${c} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${r},${c} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,l=a.interpolateNumber(t,n),o=l(.5),r=l(.5),i=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${s} ${n},${s}L${n},${c}C${r},${c} ${o},${u} ${t},${u}Z`)};function vt(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u},${l+h*n}L${u},${d-h*o}L${c},${d-h*o}L${c},${a+h*n}L${i},${a+h*n}Z`}const bt={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(qe))-1:0},justify:Ve},xt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,f=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=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 v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=pt().extent(v).links(m).nodes(p).nodeAlign(bt[h]||Ve).nodeId(e=>e.id).nodeWidth(g).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of p)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.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 w=new Map;for(const e of t)w.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 m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=w.get(`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,i,a,l;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:s.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=[],m=[],v=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(t):{},r={fill:o.fill||y.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,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,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";d?o=d(e).fill||o:"target"===g&&n?o=y.get(n.id)||o:t&&(o=y.get(t.id)||o);const r=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+s},${t.sourceY-n}L${t.sourceX+s},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+s}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let s;if(s=e.circular&&e.circularPathData?vt(e):mt(e),!s)continue;const c={fill:r.fill||o,fillOpacity:null!==(l=r.fillOpacity)&&void 0!==l?l:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:s,bezierCache:e.bezier,style:c,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,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,l;"down"===c?(a=n.x0+e/2,s=n.y1+14,l="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+r/2),v.push({x:a,y:s,text:i+"",anchor:l,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}},wt={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,c=o[0]/2,u=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=u+e*Math.sin(o)}}const d=kt(n.nodeSize,n.nodeSizeRange,e),h=l.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),g=o[1]/o[0],f=l.forceSimulation().force("charge",l.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",l.forceX(o[0]/2).strength(.1*g)).force("y",l.forceY(o[1]/2).strength(.1));if(f.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}));f.force("link",h),f.force("link").links(e)}.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;a>e;++e)f.tick();const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a;const l=n.nodeStyle,c=n.edgeStyle,u=kt(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:s.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],f=[],y=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),n=l?l(t):{},o={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,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),n="object"==typeof e.target?e.target:p.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=c?c(e):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:.6};f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||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=u(n);y.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:g,sceneEdges:f,labels:y}}};function kt(e,t,n){var i,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=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()=>s[0];const c=null!==(i=r.min(l))&&void 0!==i?i:0,u=null!==(a=r.max(l))&&void 0!==a?a:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).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?s[0]:d(o)}}const At=s.schemeCategory10,St={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,l=s-i,d=o[0]/2,h=o[1]/2,g=(f=n.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const p=e.length,m=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,n=y.get("string"==typeof e.source?e.source:e.source.id),o=y.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=c.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,w=u.arc().innerRadius(l).outerRadius(s);for(const t of x){const n=e[t.index],o=w.centroid(t);n.x=o[0]+d,n.y=o[1]+h,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=k.get("string"==typeof e.source?e.source:e.source.id),o=k.get(t);n&&(e.source=n),o&&(e.target=o)}const A=new Map;for(const e of t)A.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 n=e[t.source.index].id,o=e[t.target.index].id,r=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,u=l-a,d=o[0]/2,h=o[1]/2,g=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:At,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=c.ribbon().radius(u),b=[],x=[],w=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=g?g(n).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const a=g?g(n):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,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=v(t);if(!n)continue;const o=Et(n,d,h);let r="#999";if(f)r=f(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===y&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const a=f?f(e):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;w.push({x:d+Math.cos(a)*o,y:h+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:b,sceneEdges:x,labels:w}}};function Et(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const Lt={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const a=n.__hierarchyRoot;if(!a)return;const s=n.chartType,l=(c=n.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=i.hierarchy(a,l);d.sum(u),d.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[h,g]=o;switch(s){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.tree();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",a=i.cluster();a.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),a(e)}(d,n,h,g);break;case"treemap":!function(e,t,n,o){var r,a;const s=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(a=t.paddingTop)&&void 0!==a?a:0,c=i.treemap().size([n,o]).tile(i.treemapBinary).padding(s);l>0&&c.paddingTop(l),c(e)}(d,n,h,g);break;case"circlepack":!function(e,t,n,o){var r;const a=null!==(r=t.padding)&&void 0!==r?r:4;i.pack().size([n,o]).padding(a)(e)}(d,n,h,g);break;case"partition":!function(e,t,n,o){var r;i.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(d,n,h,g)}const f=d.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;f.length>t;t++){const o=f[t],i={id:Nt(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"===s||"cluster"===s?Ot(i,o,n):"treemap"===s||"partition"===s?Mt(i,o):"circlepack"===s&&Pt(i,o),i.__hierarchyNode=o,e.push(i),y.set(o,i)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const n=y.get(e.parent),o=y.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||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],f=n.treeOrientation||"vertical",y="radial"===f,p=o[0]/2,m=o[1]/2,v="number"==typeof(x=n.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,o=t.y;y&&(e+=p,o+=m);const i=r(t);let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const w=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,a=n.x,s=n.y;y&&(o+=p,r+=m,a+=p,s+=m);const u=jt(o,r,a,s,f),d=i(e),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:w};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Dt(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(y&&(a+=p,s+=m),y){const e=a-p,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===f?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Dt(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===(i=o.data)||void 0===i?void 0:i.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const a=n?n(o):o.id;a&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[],d=["#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=d[n.depth%d.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Dt(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);u.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:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ot(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 Mt(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 Pt(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 jt(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 Nt(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 Dt(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 Ct={sankey:xt,force:wt,chord:St,tree:Lt,cluster:Lt,treemap:Lt,circlepack:Lt,partition:Lt};function Tt(e){return Ct[e]}class Bt{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({},Oe),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Pe(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},Oe),e.tensionConfig),"sankey"===e.chartType&&e.showParticles?this.particlePool||(this.particlePool=new Pe(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:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&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({},Rt(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Rt(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Rt(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 i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,Rt(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Rt(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Tt(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)return;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});const r=new Set(this.nodes.keys()),i=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 r)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)r.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.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=r,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=Tt(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}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,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,i=n.y0,s=a.interpolateNumber(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,s=a.interpolateNumber(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/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)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;const l=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),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,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Rt(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 zt(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Wt(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=_t(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Wt(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(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,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;let a=Math.atan2(r,o);0>a&&(a+=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?a>=l||c>=a:a>=l&&c>=a,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 _t(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.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,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*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 Ht(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:l,foregroundGraphics:c,annotations:u,svgAnnotationRules:d}=e;return h.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},h.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>h.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)),u&&d&&u.map((e,o)=>{const r=d(e,o,{width:t,height:n});return r?h.createElement(h.Fragment,{key:"annotation-"+o},r):null}),c),s&&"string"==typeof s?h.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?h.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,l&&"object"==typeof l&&"legendGroups"in l?h.createElement("g",{transform:`translate(${o-i.right+10},${i.top})`},l.legendGroups.map((e,t)=>{var n;return h.createElement("g",{key:"legend-group-"+t},null===(n=e.items)||void 0===n?void 0:n.map((e,t)=>h.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},h.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),h.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):l?h.createElement("g",{transform:`translate(${o-i.right+10},${i.top})`},l):null)}function $t(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s=t.style.fill;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}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=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function It(e,t){var n,o;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(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o: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 Ft(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=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(a)),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!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),e.restore()}function Yt(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()}Ht.displayName="NetworkSVGOverlay";const Xt={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},Gt=s.schemeCategory10,qt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function Vt(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Gt[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+""))%Gt.length]}function Ut(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>e[t]))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const a=Xt[n]||Xt.category10;if(i&&"function"==typeof a)return e=>a(Number(e)/Math.max(...r.map(Number)));{const e=Array.isArray(a)?a:Gt;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function Zt(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const Qt={top:20,right:80,bottom:20,left:80},Jt={top:40,right:40,bottom:40,left:40},Kt=new Set(["chord","force","circlepack"]),en=[800,600],tn={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 nn({data:e}){var t,n,o,r,i,a;if("edge"===e.type){const t=e.data;return h.createElement("div",{className:"semiotic-tooltip",style:tn},h.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&&h.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 i=l;for(;i;){const a=null!==(r=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=i.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return h.createElement("div",{className:"semiotic-tooltip",style:tn},h.createElement("div",null,e.map((e,t)=>h.createElement("span",{key:t},t>0&&h.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?h.createElement("strong",null,e):h.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),u=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return h.createElement("div",{className:"semiotic-tooltip",style:tn},h.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&h.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const on=e.forwardRef(function(t,n){const{chartType:o,nodes:r,edges:i,data:a,initialEdges:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",childrenAccessor:g,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:m=.05,nodeWidth:v=15,iterations:b=300,forceStrength:x=.1,padAngle:w=.01,groupWidth:k=20,sortGroups:A,edgeSort:S,treeOrientation:E="vertical",edgeType:L="curve",padding:O,paddingTop:M,tensionConfig:P,showParticles:j=!1,particleStyle:N,nodeStyle:D,edgeStyle:C,colorBy:T,colorScheme:B="category10",edgeColorBy:R="source",edgeOpacity:z=.5,colorByDepth:W=!1,nodeSize:_=8,nodeSizeRange:H=[5,20],nodeLabel:$,showLabels:I=!0,size:F=en,margin:Y,className:X,background:G,enableHover:q=!0,tooltipContent:V,customHoverBehavior:U,customClickBehavior:Z,onObservation:Q,chartId:J,onTopologyChange:K,annotations:ee,svgAnnotationRules:te,legend:ne,title:oe,foregroundGraphics:re,backgroundGraphics:ie,decay:ae,pulse:se,staleness:le,thresholds:ce}=t,ue=Kt.has(o)?Jt:Qt,de=Object.assign(Object.assign({},ue),Y),he=F[0]-de.left-de.right,ge=F[1]-de.top-de.bottom,fe=e.useMemo(()=>Object.assign(Object.assign({},Oe),P),[P]),ye=e.useMemo(()=>Object.assign(Object.assign({},Me),N),[N]),pe=e.useMemo(()=>({chartType:o,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,valueAccessor:d,childrenAccessor:g,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:m,nodeWidth:v,iterations:b,forceStrength:x,padAngle:w,groupWidth:k,sortGroups:A,edgeSort:S,treeOrientation:E,edgeType:L,padding:O,paddingTop:M,tensionConfig:fe,showParticles:j,particleStyle:ye,nodeStyle:D,edgeStyle:C,nodeLabel:$,showLabels:I,colorBy:T,colorScheme:B,edgeColorBy:R,edgeOpacity:z,colorByDepth:W,nodeSize:_,nodeSizeRange:H,decay:ae,pulse:se,staleness:le,thresholds:ce}),[o,l,c,u,d,g,f,y,p,m,v,b,x,w,k,A,S,E,L,O,M,fe,j,ye,D,C,$,I,T,B,R,z,W,_,H,ae,se,le,ce]),me=e.useRef(null),ve=e.useRef(0),be=e.useRef(0),xe=e.useRef(!0),we=e.useRef(()=>{}),ke=e.useRef(null);ke.current||(ke.current=new Bt(pe));const[Ae,Se]=e.useState(null),[Ee,Le]=e.useState(0),[Pe,je]=e.useState(0),[Ne,De]=e.useState(!1),Ce=e.useRef(null),Te=e.useRef(new Map),Be=e.useRef(0),Re=e.useCallback(e=>{if("function"==typeof T)return T(e);if("string"==typeof T&&e.data){const t=e.data[T];if(void 0!==t){if(!Te.current.has(t+"")){const e=Array.isArray(B)?B:Gt;Te.current.set(t+"",e[Be.current++%e.length])}return Te.current.get(t+"")}}if(!Te.current.has(e.id)){const t=Array.isArray(B)?B:Gt;Te.current.set(e.id,t[Be.current++%t.length])}return Te.current.get(e.id)},[T,B]),ze=e.useCallback(e=>{if("function"==typeof R)return R(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===R&&n?Re(n):t?Re(t):"#999"},[R,Re]),We=e.useCallback(e=>{if(!(null==N?void 0:N.colorBy))return ze(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===ye.colorBy&&n?Re(n):t?Re(t):"#999"},[null==N?void 0:N.colorBy,ye.colorBy,Re,ze]),_e="sankey"===o&&j||!!se,He=e.useCallback(()=>{ve.current&&!_e||ve.current||(ve.current=requestAnimationFrame(()=>we.current()))},[_e]);e.useEffect(()=>{var e;null===(e=ke.current)||void 0===e||e.updateConfig(pe),xe.current=!0,He()},[pe,He]);const $e=e.useCallback(()=>{const e=ke.current;if(!e)return;e.runLayout([he,ge]),e.buildScene([he,ge]),xe.current=!0;const t=Array.isArray(B)?B:Gt,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];Te.current.has(o.id)||Te.current.set(o.id,t[e%t.length])}if(Be.current=n.length,Le(e.layoutVersion),K){const{nodes:t,edges:n}=e.getLayoutData();K(t,n)}},[he,ge,K,B]),Ie=e.useCallback(e=>{const t=ke.current;t&&(t.ingestEdge(e)&&$e(),He())},[$e,He]),Fe=e.useCallback(e=>{const t=ke.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&$e(),He()},[$e,He]),Ye=e.useCallback(()=>{var e;null===(e=ke.current)||void 0===e||e.clear(),Te.current.clear(),Be.current=0,Le(0),Se(null),Ce.current=null,xe.current=!0,He()},[He]),Xe=e.useCallback(()=>{const e=ke.current;e&&(e.tension+=999,$e(),He())},[$e,He]);e.useImperativeHandle(n,()=>({push:Ie,pushMany:Fe,clear:Ye,getTopology:()=>{var e,t;return null!==(t=null===(e=ke.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=ke.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:Xe,getTension:()=>{var e,t;return null!==(t=null===(e=ke.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Ie,Fe,Ye,Xe]);const Ge=["tree","cluster","treemap","circlepack","partition"].includes(o),qe=Ge?a||(Array.isArray(i)?void 0:i):void 0;e.useEffect(()=>{const e=ke.current;if(e)if(Ge&&qe)e.ingestHierarchy(qe,[he,ge]),e.buildScene([he,ge]),xe.current=!0,He();else{const t=r||[],n=Array.isArray(i)?i:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[he,ge]),e.buildScene([he,ge]);const o=Array.isArray(B)?B:Gt,a=Array.from(e.nodes.values());for(let e=0;a.length>e;e++){const t=a[e];Te.current.has(t.id)||Te.current.set(t.id,o[e%o.length])}Be.current=a.length,xe.current=!0,He()}},[r,i,a,qe,Ge,he,ge,pe,He,B]),e.useEffect(()=>{s&&s.length>0&&Fe(s)},[]);const Ve=e.useCallback(e=>{if(U&&U(e),Q){const t=Date.now();Q(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:J}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:J})}},[U,Q,J]),Ue=e.useCallback(e=>{if(Z&&Z(e),Q){const t=Date.now();Q(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:J}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:J})}},[Z,Q,J]),Ze=e.useRef(()=>{}),Qe=e.useRef(()=>{});Ze.current=e=>{if(!q)return;const t=me.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-de.left,r=e.clientY-n.top-de.top;if(0>o||o>he||0>r||r>ge)return void(Ce.current&&(Ce.current=null,Se(null),Ve&&Ve(null),He()));const i=ke.current;if(!i)return;const a=zt(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Ce.current&&(Ce.current=null,Se(null),Ve&&Ve(null),He()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};Ce.current=s,Se(s),Ve&&Ve(s),He()},Qe.current=()=>{Ce.current&&(Ce.current=null,Se(null),Ve&&Ve(null),He())};const Je=e.useRef(()=>{});Je.current=e=>{if(!Z&&!Q)return;const t=me.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-de.left,r=e.clientY-n.top-de.top;if(0>o||o>he||0>r||r>ge)return;const i=ke.current;if(!i)return;const a=zt(i.sceneNodes,i.sceneEdges,o,r);Ue(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)};const Ke=e.useCallback(e=>Ze.current(e),[]),et=e.useCallback(()=>Qe.current(),[]),tt=e.useCallback(e=>Je.current(e),[]);we.current=()=>{var e,t,n;ve.current=0;const o=me.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=ke.current;if(!i)return;const a=performance.now(),s=be.current?Math.min((a-be.current)/1e3,.1):.016;be.current=a;const l=i.advanceTransition(a);(l||xe.current)&&i.buildScene([he,ge]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=F[0]*c,o.height=F[1]*c,o.style.width=F[0]+"px",o.style.height=F[1]+"px",r.scale(c,c),r.translate(de.left,de.top),r.clearRect(-de.left,-de.top,F[0],F[1]),G&&(r.fillStyle=G,r.fillRect(0,0,he,ge)),ae&&i.applyDecay(),se&&i.applyPulse(a),ce&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==le?void 0:le.threshold)&&void 0!==e?e:5e3,d=le&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(r.globalAlpha=null!==(t=null==le?void 0:le.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":$t(e,n);break;case"line":It(e,n);break;case"ribbon":Ft(e,n);break;case"curved":Yt(e,n)}}(r,i.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;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)),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())}}(r,i.sceneNodes),function(e,t){var n,o,r,i;for(const a of t){if("circle"!==a.type)continue;const t=a;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!==(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()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(r,i.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;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()}}(r,i.sceneNodes),j&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:Me.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:Me.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(i.particlePool,e,s,ye);const t=.5*(null!==(n=ye.speedMultiplier)&&void 0!==n?n:1);let o;if(ye.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(s,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:Me.radius,l=null!==(a=o.opacity)&&void 0!==a?a:Me.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.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(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(r,i.particlePool,e,ye,We)}}d&&(r.globalAlpha=1);const h=xe.current;xe.current=!1,(h||l)&&je(e=>e+1),(_e||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(ve.current=requestAnimationFrame(()=>we.current()))},e.useEffect(()=>(He(),()=>{ve.current&&cancelAnimationFrame(ve.current)}),[He]),e.useEffect(()=>{xe.current=!0,He()},[o,he,ge,G,He]),e.useEffect(()=>{if(!le)return;const e=setInterval(()=>{var e;const t=ke.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=le.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==Ne&&(De(r),xe.current=!0,He())},1e3);return()=>clearInterval(e)},[le,Ne,He]);const nt=q&&Ae?h.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:de.left+Ae.x,top:de.top+Ae.y,transform:`translate(${Ae.x>.6*he?"calc(-100% - 12px)":"12px"}, ${.3*ge>Ae.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},V?V(Ae):h.createElement(nn,{data:Ae})):null,ot=ke.current;return h.createElement("div",{className:"stream-network-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof oe?oe:"Network chart",style:{position:"relative",width:F[0],height:F[1]},onMouseMove:q?Ke:void 0,onMouseLeave:q?et:void 0,onClick:Z||Q?tt:void 0},ie&&h.createElement("svg",{style:{position:"absolute",top:0,left:0,width:F[0],height:F[1],pointerEvents:"none"}},h.createElement("g",{transform:`translate(${de.left},${de.top})`},ie)),h.createElement("canvas",{ref:me,style:{position:"absolute",top:0,left:0}}),h.createElement(Ht,{width:he,height:ge,totalWidth:F[0],totalHeight:F[1],margin:de,labels:(null==ot?void 0:ot.labels)||[],title:oe,legend:ne,foregroundGraphics:re,annotations:ee,svgAnnotationRules:te,annotationFrame:Pe}),nt,(null==le?void 0:le.showBadge)&&h.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===le.badgePosition?{top:4,left:4}:"bottom-left"===le.badgePosition?{bottom:4,left:4}:"bottom-right"===le.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ne?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ne?"STALE":"LIVE"))});on.displayName="StreamNetworkFrame";const rn={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 an(e,t){return"function"==typeof t?t(e):e[t]}function sn(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 ln(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=an(e,n);a=sn(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=an(e,r);s.push({label:n,value:sn(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=sn(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=sn(e[t[0]],o))}}const l=Object.assign(Object.assign({},rn),r);return h.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&h.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>h.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&h.createElement("span",null,e.label,": "),e.value)))}}function cn(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||ln(e)))}function un(e){return"string"==typeof e?e:"value"}function dn(e){return null==e?"–":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():e+""}function hn(e,t){return"function"==typeof t?t(e):e[t]}function gn(e){return t=>{const n=t.data;return n?h.createElement("div",{className:"semiotic-tooltip",style:rn},e.map((e,t)=>{const o=dn(hn(n,e.accessor));return h.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},h.createElement("span",{style:{opacity:.8}},e.label,": "),h.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},o))})):null}}function fn({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1}){return i=>{var a;const s=r?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,l=hn(s,e),c=hn(s,t),u=n?hn(s,n):void 0;return h.createElement("div",{className:"semiotic-tooltip",style:rn},h.createElement("div",{style:{fontWeight:"bold"}},dn(l)),h.createElement("div",{style:{marginTop:4}},dn(c)),null!=u&&h.createElement("div",{style:{marginTop:2,opacity:.8}},o||un(n),": ",dn(u)))}}function yn(e){return e?"string"==typeof e?{name:e}:e:null}function pn(e,t,n){return t?o=>{var r,i;const a=Object.assign({},e(o));return t.isActive&&(t.predicate(o)?(null==n?void 0:n.selectedStyle)&&Object.assign(a,n.selectedStyle):(a.fillOpacity=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2,a.strokeOpacity=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2,(null==n?void 0:n.unselectedStyle)&&Object.assign(a,n.unselectedStyle))),a}:e}function mn(t){const n=e.createContext(null),o=vn(t);return[function({children:o}){const r=e.useMemo(()=>vn(t),[]);return h.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=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}(i.subscribe,()=>t(i.getState()))}]}function vn(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function bn(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function xn(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(bn(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function wn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[kn,An]=mn(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=wn(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=wn(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function Sn(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=An(e=>e.selections.get(r)),a=An(e=>e.setClause),s=An(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?xn(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:e.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}function En(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=Sn({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s]),predicate:r,isActive:i}}function Ln(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=Sn({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,r,s,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:l}}const[On,Mn]=mn(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),Pn="#007bff";function jn(e){return"function"==typeof e?e:t=>t[e]}function Nn(t,n,o="category10"){return e.useMemo(()=>{if(n&&"function"!=typeof n)return Ut(t,n,o)},[t,n,o])}function Dn(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=jn(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function Cn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s}){const l=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}(n,o),c=Sn({name:(null==t?void 0:t.name)||"__unused__"}),u=En({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||[]}),d=Mn(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,o;if(n){let t=e&&(e.data||e.datum)||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),d&&d(e)}}},[n,u,i,a,s,d]),customClickBehavior:e.useCallback(e=>{var t,n;if(i||d){const o={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,s])}}function Tn({data:t,colorBy:n,colorScale:o,showLegend:r,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=void 0!==r?r:!!n,l=e.useMemo(()=>{if(s&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:Vt})},[s,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),i);return l&&120>e.right&&(e.right=120),e},[a,i,l]);return{legend:l,margin:c}}const Bn={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 Rn(e,t,n){var o,r,i,a,s,l;const c=Bn[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.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:c.marginDefaults}}function zn({componentName:e,message:t,width:n,height:o}){return h.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"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400}},h.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),h.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function Wn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function _n({data:e,accessors:t,requiredProps:n}){if(n)for(const[e,t]of Object.entries(n))if(null==t)return e+" is required. Provide a field name or function.";if(!e||!Array.isArray(e)||0===e.length)return"No data provided. Pass a non-empty array to the data prop.";if(t)for(const n of Wn(e))if(n&&"object"==typeof n)for(const[e,o]of Object.entries(t))if(o&&"string"==typeof o&&!(o in n))return`${e} "${o}" not found in data. Available fields: ${Object.keys(n).join(", ")}.`;return null}function Hn({data:e,dataLabel:t="data"}){return null==e?`No ${t} provided. Pass a hierarchical data object to the ${t} prop.`:null}function $n({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)for(const t of Wn(e))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 In(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:f=[3,15],pointRadius:y=5,pointOpacity:p=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:S,onObservation:E,chartId:L}=t,O=n.width,M=n.height,P=n.enableHover,j=n.showGrid,N=n.showLegend,D=n.title,C=n.xLabel,T=n.yLabel,B=o||[],{activeSelectionHook:R,customHoverBehavior:z}=Cn({selection:k,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:E,chartType:"Scatterplot",chartId:L}),W=yn(S);Ln({name:(null==W?void 0:W.name)||"__unused_brush__",xField:(null==W?void 0:W.xField)||("string"==typeof l?l:void 0),yField:(null==W?void 0:W.yField)||("string"==typeof c?c:void 0)});const _=Nn(B,u,d),H=e.useMemo(()=>{if(!g||0===B.length)return;const e=B.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[B,g]),$=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=u?Vt(e,u,_):Pn,t.r=g?Zt(e,g,f,H):y,t},[u,_,g,f,H,y,p]),I=e.useMemo(()=>pn($,R,k),[$,R,k]),{legend:F,margin:Y}=Tn({data:B,colorBy:u,colorScale:_,showLegend:N,userMargin:r,defaults:n.marginDefaults}),X=e.useMemo(()=>gn([{label:C||un(l),accessor:l,role:"x"},{label:T||un(c),accessor:c,role:"y"},...u?[{label:un(u),accessor:u,role:"color"}]:[],...g?[{label:un(g),accessor:g,role:"size"}]:[]]),[l,c,C,T,u,g]),G=_n({componentName:"Scatterplot",data:B,accessors:{xAccessor:l,yAccessor:c}});if(G)return h.createElement(zn,{componentName:"Scatterplot",message:G,width:O,height:M});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:l,yAccessor:c,colorAccessor:u||void 0,sizeAccessor:g||void 0,sizeRange:f,pointStyle:I,colorScheme:d,size:[O,M],margin:Y,showAxes:n.showAxes,xLabel:C,yLabel:T,xFormat:a,yFormat:s,enableHover:P,showGrid:j},F&&{legend:F}),D&&{title:D}),i&&{className:i}),{tooltipContent:m?cn(m):X}),(A||E)&&{customHoverBehavior:z}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return h.createElement(ae,Object.assign({},q))}function Fn(t){var n,o;const r=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",lineBy:g,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:p="category10",curve:m="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:S,annotations:E,frameProps:L={},selection:O,linkedHover:M,onObservation:P,chartId:j}=t,N=r.width,D=r.height,C=r.enableHover,T=r.showGrid,B=r.showLegend,R=r.title,z=r.xLabel,W=r.yLabel,_=i||[],{activeSelectionHook:H,customHoverBehavior:$}=Cn({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,chartType:"LineChart",chartId:j}),I=void 0!==(null===(n=_[0])||void 0===n?void 0:n[f]),F=e.useMemo(()=>{if(I)return _;if(g){const e=_.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[f]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:_}]},[_,g,f,I]),Y=Nn(_,y,p),X=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=y?Vt(e,y,Y):Pn,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,Y,k,x,w]),G=e.useMemo(()=>pn(X,H,O),[X,H,O]),q=e.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?Vt(e.parentLine||e,y,Y):Pn,t}},[v,b,y,Y]),V=x?"area":"line",{legend:U,margin:Z}=Tn({data:F,colorBy:y,colorScale:Y,showLegend:B,userMargin:a,defaults:r.marginDefaults}),Q=g||y,J=e.useMemo(()=>gn([{label:z||un(u),accessor:u,role:"x"},{label:W||un(d),accessor:d,role:"y"},...Q?[{label:un(Q),accessor:Q,role:"group"}]:[]]),[u,d,z,W,Q]),K=_n({componentName:"LineChart",data:I?(null===(o=_[0])||void 0===o?void 0:o[f])||[]:_,accessors:{xAccessor:u,yAccessor:d}});if(K)return h.createElement(zn,{componentName:"LineChart",message:K,width:N,height:D});const ee=e.useMemo(()=>I||g?F.flatMap(e=>{const t=e[f]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):_,[F,f,I,g,_]),te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:V,data:ee,xAccessor:u,yAccessor:d,groupAccessor:g||void 0,curve:m,lineStyle:G},v&&{pointStyle:q}),{size:[N,D],margin:Z,showAxes:r.showAxes,xLabel:z,yLabel:W,xFormat:l,yFormat:c,enableHover:C,showGrid:T}),U&&{legend:U}),R&&{title:R}),s&&{className:s}),{tooltipContent:A?cn(A):J}),(M||P)&&{customHoverBehavior:$}),S&&{pointIdAccessor:S}),E&&E.length>0&&{annotations:E}),L);return h.createElement(ae,Object.assign({},te))}function Yn(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,lineDataAccessor:g="coordinates",colorBy:f,colorScheme:y="category10",curve:p="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:S,onObservation:E,chartId:L}=t,O=o.width,M=o.height,P=o.enableHover,j=o.showGrid,N=o.showLegend,D=o.title,C=o.xLabel,T=o.yLabel,B=r||[],{activeSelectionHook:R,customHoverBehavior:z}=Cn({selection:A,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:E,chartType:"AreaChart",chartId:L}),W=void 0!==(null===(n=B[0])||void 0===n?void 0:n[g]),_=e.useMemo(()=>{if(W)return B;if(d){const e=B.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[g]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:B}]},[B,d,g,W]),H=Nn(B,f,y),$=e.useMemo(()=>e=>{const t={},n=f?Vt(e,f,H):Pn;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[f,H,m,v,b]),I=e.useMemo(()=>pn($,R,A),[$,R,A]),{legend:F,margin:Y}=Tn({data:_,colorBy:f,colorScale:H,showLegend:N,userMargin:i,defaults:o.marginDefaults}),X=d||f,G=e.useMemo(()=>gn([{label:C||un(c),accessor:c,role:"x"},{label:T||un(u),accessor:u,role:"y"},...X?[{label:un(X),accessor:X,role:"group"}]:[]]),[c,u,C,T,X]),q=_n({componentName:"AreaChart",data:B,accessors:{xAccessor:c,yAccessor:u}});if(q)return h.createElement(zn,{componentName:"AreaChart",message:q,width:O,height:M});const V=e.useMemo(()=>W||d?_.flatMap(e=>{const t=e[g]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):B,[_,g,W,d,B]),U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:V,xAccessor:c,yAccessor:u,groupAccessor:d||void 0,curve:p,lineStyle:I,size:[O,M],margin:Y,showAxes:o.showAxes,xLabel:C,yLabel:T,xFormat:s,yFormat:l,enableHover:P,showGrid:j},F&&{legend:F}),D&&{title:D}),a&&{className:a}),{tooltipContent:x?cn(x):G}),(S||E)&&{customHoverBehavior:z}),w&&w.length>0&&{annotations:w}),k);return h.createElement(ae,Object.assign({},U))}function Xn(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:d,lineDataAccessor:g="coordinates",colorBy:f,colorScheme:y="category10",curve:p="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:S,linkedHover:E,onObservation:L,chartId:O}=t,M=o.width,P=o.height,j=o.enableHover,N=o.showGrid,D=o.showLegend,C=o.title,T=o.xLabel,B=o.yLabel,R=r||[],{activeSelectionHook:z,customHoverBehavior:W}=Cn({selection:S,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:L,chartType:"StackedAreaChart",chartId:O}),_=void 0!==(null===(n=R[0])||void 0===n?void 0:n[g]),H=e.useMemo(()=>{if(_)return R;if(d){const e=R.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[g]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:R}]},[R,d,g,_]),$=Nn(R,f,y),I=e.useMemo(()=>e=>{const t={},n=f?Vt(e,f,$):Pn;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[f,$,m,v,b]),F=e.useMemo(()=>pn(I,z,S),[I,z,S]),{legend:Y,margin:X}=Tn({data:H,colorBy:f,colorScale:$,showLegend:D,userMargin:i,defaults:o.marginDefaults}),G=d||f,q=e.useMemo(()=>gn([{label:T||un(c),accessor:c,role:"x"},{label:B||un(u),accessor:u,role:"y"},...G?[{label:un(G),accessor:G,role:"group"}]:[]]),[c,u,T,B,G]),V=_n({componentName:"StackedAreaChart",data:R,accessors:{xAccessor:c,yAccessor:u}});if(V)return h.createElement(zn,{componentName:"StackedAreaChart",message:V,width:M,height:P});const U=e.useMemo(()=>_||d?H.flatMap(e=>{const t=e[g]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):R,[H,g,_,d,R]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:c,yAccessor:u,groupAccessor:d||void 0,curve:p,normalize:x,lineStyle:F,size:[M,P],margin:X,showAxes:o.showAxes,xLabel:T,yLabel:B,xFormat:s,yFormat:l,enableHover:j,showGrid:N},Y&&{legend:Y}),C&&{title:C}),a&&{className:a}),{tooltipContent:w?cn(w):q}),(E||L)&&{customHoverBehavior:W}),k&&k.length>0&&{annotations:k}),A);return h.createElement(ae,Object.assign({},Z))}function Gn(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:i,className:a,xAccessor:l="x",yAccessor:c="y",valueAccessor:u="value",xFormat:d,yFormat:g,colorScheme:f="blues",customColorScale:y,showValues:p=!1,valueFormat:m,cellBorderColor:v="#fff",cellBorderWidth:b=1,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:S,onObservation:E,chartId:L}=t,O=n.width,M=n.height,P=n.enableHover,j=n.title,N=n.xLabel,D=n.yLabel,C=r||[],{margin:T}=Tn({data:C,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:B,customHoverBehavior:R}=Cn({selection:A,linkedHover:S,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:L}),z=e.useMemo(()=>"function"==typeof u?e=>u(e):e=>e[u],[u]),W=e.useMemo(()=>{const e=C.map(z);return[Math.min(...e),Math.max(...e)]},[C,z]),_=e.useMemo(()=>"custom"===f&&y?y:o.scaleSequential({blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis}[f]||s.interpolateBlues).domain(W),[f,y,W]);e.useMemo(()=>{const e=jn(l),t=jn(c);return{xBinCount:new Set(C.map(e)).size,yBinCount:new Set(C.map(t)).size}},[C,l,c]),e.useMemo(()=>({coordinates:C}),[C]);const H=e.useMemo(()=>e=>{const t=z(e);return{fill:_(t),stroke:v,strokeWidth:b}},[z,_,v,b]);e.useMemo(()=>pn(H,B,A),[H,B,A]),e.useMemo(()=>{if(!p)return;const e=(W[0]+W[1])/2;return(t,n)=>{const o=z(t),r=m?m(o):o+"";return h.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:z(t)>e?"#fff":"#000",fontSize:"12px"},r)}},[p,z,m,W]);const $=e.useMemo(()=>gn([{label:N||un(l),accessor:l,role:"x"},{label:D||un(c),accessor:c,role:"y"},{label:un(u),accessor:u,role:"value"}]),[l,c,N,D,u]),I=_n({componentName:"Heatmap",data:C,accessors:{xAccessor:l,yAccessor:c,valueAccessor:u}});if(I)return h.createElement(zn,{componentName:"Heatmap",message:I,width:O,height:M});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:C,xAccessor:l,yAccessor:c,valueAccessor:u,size:[O,M],margin:T,showAxes:n.showAxes,xLabel:N,yLabel:D,xFormat:d,yFormat:g,enableHover:P},j&&{title:j}),a&&{className:a}),{tooltipContent:x?cn(x):$}),(S||E)&&{customHoverBehavior:R}),w&&w.length>0&&{annotations:w}),k);return h.createElement(ae,Object.assign({},F))}function qn(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:r,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",sizeBy:u,sizeRange:d=[5,40],colorBy:g,colorScheme:f="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:p=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:S,linkedBrush:E,onObservation:L,chartId:O}=t,M=n.width,P=n.height,j=n.enableHover,N=n.showGrid,D=n.showLegend,C=n.title,T=n.xLabel,B=n.yLabel,R=o||[],{activeSelectionHook:z,customHoverBehavior:W}=Cn({selection:A,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:L,chartType:"BubbleChart",chartId:O}),_=yn(E);Ln({name:(null==_?void 0:_.name)||"__unused_brush__",xField:(null==_?void 0:_.xField)||("string"==typeof l?l:void 0),yField:(null==_?void 0:_.yField)||("string"==typeof c?c:void 0)});const H=Nn(R,g,f),$=e.useMemo(()=>{const e=R.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[R,u]),I=e.useMemo(()=>e=>{const t={fillOpacity:y,strokeWidth:p,stroke:m};return t.fill=g?Vt(e,g,H):Pn,t.r=Zt(e,u,d,$),t},[g,H,u,d,$,y,p,m]),F=e.useMemo(()=>pn(I,z,A),[I,z,A]),{legend:Y,margin:X}=Tn({data:R,colorBy:g,colorScale:H,showLegend:D,userMargin:r,defaults:n.marginDefaults}),G=e.useMemo(()=>gn([{label:T||un(l),accessor:l,role:"x"},{label:B||un(c),accessor:c,role:"y"},{label:un(u),accessor:u,role:"size"},...g?[{label:un(g),accessor:g,role:"color"}]:[]]),[l,c,T,B,u,g]),q=_n({componentName:"BubbleChart",data:R,accessors:{xAccessor:l,yAccessor:c},requiredProps:{sizeBy:u}});if(q)return h.createElement(zn,{componentName:"BubbleChart",message:q,width:M,height:P});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:R,xAccessor:l,yAccessor:c,colorAccessor:g||void 0,sizeAccessor:u,sizeRange:d,pointStyle:F,colorScheme:f,size:[M,P],margin:X,showAxes:n.showAxes,xLabel:T,yLabel:B,xFormat:a,yFormat:s,enableHover:j,showGrid:N},Y&&{legend:Y}),C&&{title:C}),i&&{className:i}),{tooltipContent:v?cn(v):G}),(S||L)&&{customHoverBehavior:W}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return h.createElement(ae,Object.assign({},V))}function Vn(t={}){const{limit:n=50,types:o,chartId:r}=t,i=Mn(e=>e.version),a=Mn(e=>e.observations),s=Mn(e=>e.clearObservations),l=e.useMemo(()=>{let e=a;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>n&&(e=e.slice(e.length-n)),e},[a,o,r,n,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}function Un({selections:t}){const n=An(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[]),null}function Zn({children:e,selections:t}){return h.createElement(kn,null,h.createElement(On,null,t&&h.createElement(Un,{selections:t}),e))}In.displayName="Scatterplot",Fn.displayName="LineChart",Yn.displayName="AreaChart",Xn.displayName="StackedAreaChart",Gn.displayName="Heatmap",qn.displayName="BubbleChart";const Qn="__splomIdx",Jn={top:4,bottom:4,left:4,right:4};function Kn({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-Jn.left-Jn.right,l=r-Jn.top-Jn.bottom;return e.useEffect(()=>{if(!a.current)return;const e=n.select(a.current).select(".brush-g"),r=t.brush().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(a)],[n.x.invert(s),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[s,l,o,i]),h.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},h.createElement("g",{className:"brush-g",transform:`translate(${Jn.left},${Jn.top})`}))}function eo({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:g,onPointHover:f}){const y=e.useRef(null),p=Sn({name:c,clientId:`splom-${n}-${o}`}),m=Ln({name:c,xField:n,yField:o}),v=Sn({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),w=e.useCallback(e=>{if(!e)return void(null==f||f(null));const t=e.data,n=null==t?void 0:t[Qn];void 0!==n&&(b({[Qn]:[n]}),null==f||f(t,e.x+Jn.left,e.y+Jn.top))},[b,f]),k=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?Vt(e,s,l):Pn,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):p.isActive&&!p.predicate(e)&&(t.opacity=d),t},[s,l,a,i,g,p.isActive,p.predicate,v.isActive,v.predicate,d]);return h.createElement("div",{style:{position:"relative",width:r,height:r}},h.createElement(ae,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:k,margin:Jn,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?w:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&h.createElement(Kn,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function to({data:t,field:n,label:o,cellSize:r,bins:i,brushSelectionName:a,hoverSelectionName:s,mode:l}){const c=Sn({name:a,clientId:"splom-diag-"+n}),u=Sn({name:s,clientId:`splom-diag-${n}-hover`}),d="hover"===l?u:c,g=d.isActive,f=d.predicate,y=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),a=(Math.max(...e)-o)/i||1,s=Array(i).fill(0),l=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/a),i-1);s[r]++,g&&!f(e)||l[r]++}const c=Math.max(...s,1);return{bars:s.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),selectedBars:l.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/c*(r-24),count:e})),max:c}},[t,n,i,r,g,f]);return h.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},h.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),y.bars.map((e,t)=>h.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:g?.3:.6})),g&&y.selectedBars.map((e,t)=>h.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Pn,opacity:.7})))}function no({label:e,cellSize:t}){return h.createElement("svg",{width:t,height:t},h.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function oo(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:a="category10",cellSize:s=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:y=!0,unselectedOpacity:p=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:w,onObservation:k,chartId:A}=t,S="splom",E="splom-hover",L=y?"hover":f?"brush":"hover",O=An(e=>e.clearSelection),[M,P]=e.useState(null),j=e.useCallback(()=>{O(E),P(null)},[O,E]),N=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Qn]?e:Object.assign(Object.assign({},e),{[Qn]:t})),[n]),D=Nn(N,i,a),C=void 0!==b?b:!!i,T=e.useMemo(()=>{if(!C||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(N.map(t=>t[e]))].map(e=>({label:e+"",color:D?D(e+""):Pn})):null},[C,i,N,D]),B=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,s,l,40]);return h.createElement("div",{className:w,style:{position:"relative"}},T&&h.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},T.map(e=>h.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},h.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),h.createElement("span",{style:{fontSize:11}},e.label)))),h.createElement("div",{style:B,onMouseLeave:"hover"===L?j:void 0},o.map((e,t)=>h.createElement(h.Fragment,{key:"row-"+e},h.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?h.createElement(no,{key:"diag-"+e,label:r[e]||e,cellSize:s}):h.createElement(to,{key:"diag-"+e,data:N,field:e,label:r[e]||e,cellSize:s,bins:g,colorBy:i,colorScale:D,brushSelectionName:S,hoverSelectionName:E,unselectedOpacity:p,mode:L}):h.createElement(eo,{key:`cell-${e}-${n}`,data:N,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:D,brushSelectionName:S,hoverSelectionName:E,unselectedOpacity:p,showGrid:m,tooltip:v,mode:L,onPointHover:"hover"===L?(r,i,a)=>{r?(P({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=a?a:0}),k&&k({type:"hover",datum:r,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(P(null),k&&k({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),h.createElement("div",null)," ",o.map(e=>h.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),M&&"hover"===L&&(()=>{const e=M.datum,t=r[M.xField]||M.xField,n=r[M.yField]||M.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[Qn];return h.createElement("div",{style:{position:"absolute",left:40+M.colIndex*(s+l)+M.px,top:M.rowIndex*(s+l)+M.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},h.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),h.createElement("div",null,t,": ",null!=e[M.xField]?Number(e[M.xField]).toFixed(1):"–"),h.createElement("div",null,n,": ",null!=e[M.yField]?Number(e[M.yField]).toFixed(1):"–"),null!=o&&h.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function ro(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),h.createElement(Zn,{selections:o},h.createElement(oo,Object.assign({},e)))}function io({width:o,height:r,margin:i,scales:a,brushDirection:s,extent:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),g=e.useRef(!1),f=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!a)return;const e=n.select(u.current).select(".brush-group"),i="x"===s?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[a,o,r,s,c]),e.useEffect(()=>{if(!d.current||!a||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===s?a.x:a.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);g.current=!1},[l,a,s]),h.createElement("svg",{ref:u,width:f,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},h.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function ao(t){var n,o;const{data:r,width:i=600,height:a=400,margin:s,className:l,title:c,xLabel:u,yLabel:d,xFormat:g,yFormat:f,xAccessor:y="x",yAccessor:p="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:w="linear",lineWidth:k=2,fillArea:A=!1,areaOpacity:S=.3,showPoints:E=!1,pointRadius:L=3,enableHover:O=!0,showGrid:M=!1,showLegend:P,tooltip:j,minimap:N={},renderBefore:D=!1,onBrush:C,brushExtent:T,frameProps:B={}}=t,R=r||[],[z,W]=e.useState(null),_=null!=T?T:z,H=e.useCallback(e=>{T||W(e),null==C||C(e)},[T,C]),$=e.useRef(null),[I,F]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=$.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?F(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const Y=void 0!==(null===(n=R[0])||void 0===n?void 0:n[v]),X=e.useMemo(()=>{if(Y)return R;if(m){const e=R.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:R}]},[R,m,v,Y]),G=e.useMemo(()=>Y||m?X.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):R,[X,v,Y,m,R]),q=Nn(R,b,x),V=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=b?Vt(e,b,q):Pn,A&&(t.fill=t.stroke,t.fillOpacity=S),t},[b,q,k,A,S]),U=e.useMemo(()=>N.lineStyle?N.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?Vt(e,b,q):Pn,t},[b,q,N.lineStyle]),Z=e.useMemo(()=>{if(E)return e=>{const t={r:L,fillOpacity:1};return t.fill=b?Vt(e.parentLine||e,b,q):Pn,t}},[E,L,b,q]),{legend:Q,margin:J}=Tn({data:X,colorBy:b,colorScale:q,showLegend:P,userMargin:s}),K=N.height||60,ee=e.useMemo(()=>{var e,t,n,o,r,i,a,s;return{top:null!==(t=null===(e=N.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=N.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=N.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:J.left,right:null!==(s=null===(a=N.margin)||void 0===a?void 0:a.right)&&void 0!==s?s:J.right}},[N.margin,J]),te=N.brushDirection||"x",ne=_n({componentName:"MinimapChart",data:R,accessors:{xAccessor:y,yAccessor:p}});if(ne)return h.createElement(zn,{componentName:"MinimapChart",message:ne,width:i,height:a});const oe=A?"area":"line",re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:oe,data:G,xAccessor:y,yAccessor:p,groupAccessor:m||void 0,curve:w,lineStyle:V},E&&{pointStyle:Z}),{size:[i,a],margin:J,showAxes:!0,xLabel:u,yLabel:d,xFormat:g,yFormat:f,enableHover:O,showGrid:M}),Q&&{legend:Q}),c&&{title:c}),j&&{tooltipContent:cn(j)}),_&&{xExtent:_}),B),ie={chartType:oe,data:G,xAccessor:y,yAccessor:p,groupAccessor:m||void 0,curve:w,lineStyle:U,size:[i,K+ee.top+ee.bottom],margin:ee,showAxes:null!==(o=N.showAxes)&&void 0!==o&&o,background:N.background,enableHover:!1},se=h.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},h.createElement(ae,Object.assign({ref:$},ie)),h.createElement(io,{width:i-ee.left-ee.right,height:K,margin:ee,scales:I,brushDirection:te,extent:_,onBrush:H})),le=h.createElement("div",{key:"main",style:{overflow:"hidden"}},h.createElement(ae,Object.assign({},re)));return h.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},D?se:le,D?le:se)}function so(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sort:g=!1,barPadding:f=5,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,S=n.enableHover,E=n.showGrid,L=n.showLegend,O=n.title,M=n.categoryLabel,P=n.valueLabel,j=o||[],{activeSelectionHook:N,customHoverBehavior:D}=Cn({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),C=Dn(j,g,s),T=Nn(j,u,d),B=e.useMemo(()=>e=>{const t={};return t.fill=u?Vt(e,u,T):Pn,t},[u,T]),R=e.useMemo(()=>pn(B,N,v),[B,N,v]),{legend:z,margin:W}=Tn({data:C,colorBy:u,colorScale:T,showLegend:L,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>fn({categoryAccessor:a,valueAccessor:s,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,s,u]),H=_n({componentName:"BarChart",data:j,accessors:{categoryAccessor:a,valueAccessor:s}});if(H)return h.createElement(zn,{componentName:"BarChart",message:H,width:k,height:A});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:R,size:[k,A],margin:W,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:M,rLabel:P,rFormat:c,showGrid:E,oSort:g},z&&{legend:z}),O&&{title:O}),i&&{className:i}),{tooltipContent:y?cn(y):_}),(b||x)&&{customHoverBehavior:D}),p&&p.length>0&&{annotations:p}),m);return h.createElement(Le,Object.assign({},$))}function lo(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",stackBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",normalize:f=!1,barPadding:y=5,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,S=n.height,E=n.enableHover,L=n.showGrid,O=n.showLegend,M=n.title,P=n.categoryLabel,j=n.valueLabel,N=o||[],D=d||s,{activeSelectionHook:C,customHoverBehavior:T}=Cn({selection:b,linkedHover:x,fallbackFields:D?["string"==typeof D?D:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),B=Nn(N,D,g),R=e.useMemo(()=>e=>D?{fill:Vt(e,D,B)}:{fill:Pn},[D,B]),z=e.useMemo(()=>pn(R,C,b),[R,C,b]),{legend:W,margin:_}=Tn({data:N,colorBy:D,colorScale:B,showLegend:O,userMargin:r,defaults:n.marginDefaults}),H=e.useMemo(()=>fn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),$=_n({componentName:"StackedBarChart",data:N,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:s}});if($)return h.createElement(zn,{componentName:"StackedBarChart",message:$,width:A,height:S});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:N,oAccessor:a,rAccessor:l,stackBy:s,normalize:f,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:z,size:[A,S],margin:_,barPadding:y,enableHover:E,showAxes:n.showAxes,oLabel:P,rLabel:j,rFormat:u,showGrid:L},W&&{legend:W}),M&&{title:M}),i&&{className:i}),{tooltipContent:p?cn(p):H}),(x||w)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Le,Object.assign({},I))}function co(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:f=[3,8],pointRadius:y=4,pointOpacity:p=.7,categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:S}=t,E=n.width,L=n.height,O=n.enableHover,M=n.showGrid,P=n.showLegend,j=n.title,N=n.categoryLabel,D=n.valueLabel,C=o||[],{activeSelectionHook:T,customHoverBehavior:B}=Cn({selection:w,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:S}),R=Nn(C,u,d),z=e.useMemo(()=>{if(!g)return;const e=C.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[C,g]),W=e.useMemo(()=>e=>{const t={fillOpacity:p};return t.fill=u?Vt(e,u,R):Pn,t.r=g?Zt(e,g,f,z):y,t},[u,R,g,f,z,y,p]),_=e.useMemo(()=>pn(W,T,w),[W,T,w]),{legend:H,margin:$}=Tn({data:C,colorBy:u,colorScale:R,showLegend:P,userMargin:r,defaults:n.marginDefaults}),I=e.useMemo(()=>fn({categoryAccessor:a,valueAccessor:s,groupAccessor:u||void 0}),[a,s,u]),F=_n({componentName:"SwarmPlot",data:C,accessors:{categoryAccessor:a,valueAccessor:s}});if(F)return h.createElement(zn,{componentName:"SwarmPlot",message:F,width:E,height:L});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:C,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:_,size:[E,L],margin:$,barPadding:m,enableHover:O,showAxes:n.showAxes,oLabel:N,rLabel:D,rFormat:c,showGrid:M},H&&{legend:H}),j&&{title:j}),i&&{className:i}),{tooltipContent:v?cn(v):I}),(k||A)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return h.createElement(Le,Object.assign({},Y))}function uo(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",valueFormat:c,colorBy:u,colorScheme:d="category10",showOutliers:g=!0,categoryPadding:f=20,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,S=n.enableHover,E=n.showGrid,L=n.showLegend,O=n.title,M=n.categoryLabel,P=n.valueLabel,j=o||[],{activeSelectionHook:N,customHoverBehavior:D}=Cn({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),C=Nn(j,u,d),T=e.useMemo(()=>e=>{const t=u?Vt(e,u,C):Pn;return{fill:t,stroke:t,fillOpacity:.8}},[u,C]),B=e.useMemo(()=>pn(T,N,v),[T,N,v]),{legend:R,margin:z}=Tn({data:j,colorBy:u,colorScale:C,showLegend:L,userMargin:r,defaults:n.marginDefaults}),W=e.useMemo(()=>e=>{const t=e.stats||(e.data||e).stats||{};return h.createElement("div",{className:"semiotic-tooltip",style:rn},h.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(e.category||(e.data||e).category||"")+""),null!=t.median&&h.createElement(h.Fragment,null,null!=t.n&&h.createElement("div",null,"n = ",t.n),h.createElement("div",null,"Median: ",t.median.toLocaleString()),h.createElement("div",null,"Q1: ",t.q1.toLocaleString()),h.createElement("div",null,"Q3: ",t.q3.toLocaleString()),h.createElement("div",null,"Min: ",t.min.toLocaleString()),h.createElement("div",null,"Max: ",t.max.toLocaleString())))},[]),_=_n({componentName:"BoxPlot",data:j,accessors:{categoryAccessor:a,valueAccessor:s}});if(_)return h.createElement(zn,{componentName:"BoxPlot",message:_,width:k,height:A});const H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:j,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[k,A],margin:z,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:M,rLabel:P,rFormat:c,showGrid:E},R&&{legend:R}),O&&{title:O}),i&&{className:i}),{tooltipContent:y?cn(y):W}),(b||x)&&{customHoverBehavior:D}),p&&p.length>0&&{annotations:p}),m);return h.createElement(Le,Object.assign({},H))}function ho(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",bins:l=25,relative:c=!1,valueFormat:u,colorBy:d,colorScheme:g="category10",categoryPadding:f=20,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,S=n.enableHover,E=n.showGrid,L=n.showLegend,O=n.title,M=n.categoryLabel,P=n.valueLabel,j=o||[],{activeSelectionHook:N,customHoverBehavior:D}=Cn({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),C=Nn(j,d,g),T=e.useMemo(()=>e=>{const t=d?Vt(e,d,C):Pn;return{fill:t,stroke:t,fillOpacity:.8}},[d,C]),B=e.useMemo(()=>pn(T,N,v),[T,N,v]),{legend:R,margin:z}=Tn({data:j,colorBy:d,colorScale:C,showLegend:L,userMargin:r,defaults:n.marginDefaults}),W=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return h.createElement("div",{className:"semiotic-tooltip",style:rn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&h.createElement("div",null,"Count: ",o),r&&2===r.length&&h.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),_=_n({componentName:"Histogram",data:j,accessors:{categoryAccessor:a,valueAccessor:s}});if(_)return h.createElement(zn,{componentName:"Histogram",message:_,width:k,height:A});const H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:j,oAccessor:a,rAccessor:s,projection:"horizontal",summaryStyle:B,bins:l,normalize:c,size:[k,A],margin:z,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:M,rLabel:P,rFormat:u,showGrid:E},R&&{legend:R}),O&&{title:O}),i&&{className:i}),{tooltipContent:y?cn(y):W}),(b||x)&&{customHoverBehavior:D}),p&&p.length>0&&{annotations:p}),m);return h.createElement(Le,Object.assign({},H))}function go(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="vertical",bins:c=25,showIQR:u=!0,valueFormat:d,colorBy:g,colorScheme:f="category10",categoryPadding:y=20,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,S=n.height,E=n.enableHover,L=n.showGrid,O=n.showLegend,M=n.title,P=n.categoryLabel,j=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=Cn({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),T=Nn(N,g,f),B=e.useMemo(()=>e=>{const t=g?Vt(e,g,T):Pn;return{fill:t,stroke:t,fillOpacity:.6}},[g,T]),R=e.useMemo(()=>pn(B,D,b),[B,D,b]),{legend:z,margin:W}=Tn({data:N,colorBy:g,colorScale:T,showLegend:O,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;if(o)return h.createElement("div",{className:"semiotic-tooltip",style:rn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),h.createElement("div",null,"n = ",o.n),h.createElement("div",null,"Min: ",o.min.toLocaleString()),h.createElement("div",null,"Q1: ",o.q1.toLocaleString()),h.createElement("div",null,"Median: ",o.median.toLocaleString()),h.createElement("div",null,"Q3: ",o.q3.toLocaleString()),h.createElement("div",null,"Max: ",o.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const r=(Array.isArray(e.data)?e.data:[]).map(e=>{const t="function"==typeof s?s(e):e[s];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),i=r.length,a=i>0?r[Math.floor(i/2)]:null;return h.createElement("div",{className:"semiotic-tooltip",style:rn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),i>0&&h.createElement("div",null,"n = ",i),null!=a&&h.createElement("div",null,"Median: ",a.toLocaleString()))},[s]),H=_n({componentName:"ViolinPlot",data:N,accessors:{categoryAccessor:a,valueAccessor:s}});if(H)return h.createElement(zn,{componentName:"ViolinPlot",message:H,width:A,height:S});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:N,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:R,bins:c,showIQR:u,size:[A,S],margin:W,barPadding:y,enableHover:E,showAxes:n.showAxes,oLabel:P,rLabel:j,rFormat:d,showGrid:L},z&&{legend:z}),M&&{title:M}),i&&{className:i}),{tooltipContent:p?cn(p):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Le,Object.assign({},$))}function fo(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",valueAccessor:s="value",orientation:l="horizontal",bins:c=20,amplitude:u=1.5,valueFormat:d,colorBy:g,colorScheme:f="category10",categoryPadding:y=5,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,S=n.height,E=n.enableHover,L=n.showGrid,O=n.showLegend,M=n.title,P=n.categoryLabel,j=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=Cn({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"RidgelinePlot",chartId:k}),T=Nn(N,g,f),B=e.useMemo(()=>e=>{const t=g?Vt(e,g,T):Pn;return{fill:t,stroke:t,fillOpacity:.5}},[g,T]),R=e.useMemo(()=>pn(B,D,b),[B,D,b]),{legend:z,margin:W}=Tn({data:N,colorBy:g,colorScale:T,showLegend:O,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>e=>{var t;const n=e.category||e.data&&(null===(t=e.data[0])||void 0===t?void 0:t.category)||"",o=e.stats;return o?h.createElement("div",{className:"semiotic-tooltip",style:rn},n&&h.createElement("div",{style:{fontWeight:"bold"}},n+""),h.createElement("div",null,"n = ",o.n),h.createElement("div",null,"Min: ",o.min.toLocaleString()),h.createElement("div",null,"Q1: ",o.q1.toLocaleString()),h.createElement("div",null,"Median: ",o.median.toLocaleString()),h.createElement("div",null,"Q3: ",o.q3.toLocaleString()),h.createElement("div",null,"Max: ",o.max.toLocaleString()),h.createElement("div",{style:{opacity:.8}},"Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):h.createElement("div",{className:"semiotic-tooltip",style:rn},h.createElement("div",{style:{fontWeight:"bold"}},n+""))},[]),H=_n({componentName:"RidgelinePlot",data:N,accessors:{categoryAccessor:a,valueAccessor:s}});if(H)return h.createElement(zn,{componentName:"RidgelinePlot",message:H,width:A,height:S});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:N,oAccessor:a,rAccessor:s,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:R,bins:c,size:[A,S],margin:W,barPadding:y,enableHover:E,showAxes:n.showAxes,oLabel:P,rLabel:j,rFormat:d,showGrid:L,oSort:!1},z&&{legend:z}),M&&{title:M}),i&&{className:i}),{tooltipContent:p?cn(p):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return $.amplitude=u,h.createElement(Le,Object.assign({},$))}function yo(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",valueFormat:u,colorBy:d,colorScheme:g="category10",sort:f=!0,dotRadius:y=5,categoryPadding:p=10,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,S=o.width,E=o.height,L=o.enableHover,O=o.showGrid,M=o.showLegend,P=o.title,j=o.categoryLabel,N=o.valueLabel,D=r||[],{activeSelectionHook:C,customHoverBehavior:T}=Cn({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),B=Dn(D,f,l),R=Nn(D,d,g),z=e.useMemo(()=>e=>{const t={r:y,fillOpacity:.8};return t.fill=d?Vt(e,d,R):Pn,t},[d,R,y]),W=e.useMemo(()=>pn(z,C,x),[z,C,x]),{legend:_,margin:H}=Tn({data:B,colorBy:d,colorScale:R,showLegend:M,userMargin:i,defaults:o.marginDefaults}),$=e.useMemo(()=>fn({categoryAccessor:s,valueAccessor:l}),[s,l]),I=_n({componentName:"DotPlot",data:D,accessors:{categoryAccessor:s,valueAccessor:l}});if(I)return h.createElement(zn,{componentName:"DotPlot",message:I,width:S,height:E});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[S,E],margin:H,barPadding:p,enableHover:L,showAxes:o.showAxes,oLabel:j,rLabel:N,rFormat:u,showGrid:O,oSort:f},_&&{legend:_}),P&&{title:P}),a&&{className:a}),{tooltipContent:m?cn(m):$}),(w||k)&&{customHoverBehavior:T}),v&&v.length>0&&{annotations:v}),b);return h.createElement(Le,Object.assign({},F))}function po(t){var n,o;const r=Rn(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",colorBy:u,colorScheme:d="category10",startAngle:g=0,tooltip:f,annotations:y,frameProps:p={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=r.width,k=r.height,A=r.enableHover,S=r.showLegend,E=r.title,L=i||[],O=u||l,{activeSelectionHook:M,customHoverBehavior:P}=Cn({selection:m,linkedHover:v,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),j=Nn(L,O,d),N=e.useMemo(()=>e=>O?{fill:Vt(e,O,j)}:{fill:Pn},[O,j]),D=e.useMemo(()=>pn(N,M,m),[N,M,m]),{legend:C,margin:T}=Tn({data:L,colorBy:O,colorScale:j,showLegend:S,userMargin:a,defaults:r.marginDefaults}),B=e.useMemo(()=>fn({categoryAccessor:l,valueAccessor:c,groupAccessor:u&&u!==l?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[l,c,u]),R=_n({componentName:"PieChart",data:L,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return h.createElement(zn,{componentName:"PieChart",message:R,width:w,height:k});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:L,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:D,startAngle:g,size:[w,k],margin:T,enableHover:A,showAxes:!1},C&&{legend:C}),E&&{title:E}),s&&{className:s}),{tooltipContent:f?cn(f):B}),(v||b)&&{customHoverBehavior:P}),y&&y.length>0&&{annotations:y}),p);return h.createElement(Le,Object.assign({},z))}function mo(t){var n,o;const r=Rn(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",innerRadius:u=60,centerContent:d,colorBy:g,colorScheme:f="category10",startAngle:y=0,tooltip:p,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=r.width,S=r.height,E=r.enableHover,L=r.showLegend,O=r.title,M=i||[],P=g||l,{activeSelectionHook:j,customHoverBehavior:N}=Cn({selection:b,linkedHover:x,fallbackFields:P?["string"==typeof P?P:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),D=Nn(M,P,f),C=e.useMemo(()=>e=>P?{fill:Vt(e,P,D)}:{fill:Pn},[P,D]),T=e.useMemo(()=>pn(C,j,b),[C,j,b]),{legend:B,margin:R}=Tn({data:M,colorBy:P,colorScale:D,showLegend:L,userMargin:a,defaults:r.marginDefaults}),z=e.useMemo(()=>fn({categoryAccessor:l,valueAccessor:c,groupAccessor:g&&g!==l?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[l,c,g]),W=_n({componentName:"DonutChart",data:M,accessors:{categoryAccessor:l,valueAccessor:c}});if(W)return h.createElement(zn,{componentName:"DonutChart",message:W,width:A,height:S});const _=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:M,oAccessor:l,rAccessor:c,projection:"radial",pieceStyle:T,innerRadius:u,startAngle:y,centerContent:d,size:[A,S],margin:R,enableHover:E,showAxes:!1},B&&{legend:B}),O&&{title:O}),s&&{className:s}),{tooltipContent:p?cn(p):z}),(x||w)&&{customHoverBehavior:N}),m&&m.length>0&&{annotations:m}),v);return h.createElement(Le,Object.assign({},_))}function vo(t){const n=Rn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:i,categoryAccessor:a="category",groupBy:s,valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",barPadding:f=5,tooltip:y,annotations:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,S=n.enableHover,E=n.showGrid,L=n.showLegend,O=n.title,M=n.categoryLabel,P=n.valueLabel,j=o||[],N=d||s,{activeSelectionHook:D,customHoverBehavior:C}=Cn({selection:v,linkedHover:b,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),T=Nn(j,N,g),B=e.useMemo(()=>e=>N?{fill:Vt(e,N,T)}:{fill:Pn},[N,T]),R=e.useMemo(()=>pn(B,D,v),[B,D,v]),{legend:z,margin:W}=Tn({data:j,colorBy:N,colorScale:T,showLegend:L,userMargin:r,defaults:n.marginDefaults}),_=e.useMemo(()=>fn({categoryAccessor:s,valueAccessor:l,groupAccessor:a}),[s,a,l]),H=_n({componentName:"GroupedBarChart",data:j,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:s}});if(H)return h.createElement(zn,{componentName:"GroupedBarChart",message:H,width:k,height:A});const $=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:j,oAccessor:a,rAccessor:l,groupBy:s,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:R,size:[k,A],margin:W,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:M,rLabel:P,rFormat:u,showGrid:E},z&&{legend:z}),O&&{title:O}),i&&{className:i}),{tooltipContent:y?cn(y):_}),(b||x)&&{customHoverBehavior:C}),p&&p.length>0&&{annotations:p}),m);return h.createElement(Le,Object.assign({},$))}function bo(t){var n;const o=Rn(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:r,edges:i,margin:a,className:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",nodeLabel:d,colorBy:g,colorScheme:f="category10",nodeSize:y=8,nodeSizeRange:p=[5,20],edgeWidth:m=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:w=.1,tooltip:k,frameProps:A={},onObservation:S,chartId:E}=t,L=o.width,O=o.height,M=o.enableHover,P=o.showLegend,j=null!==(n=o.showLabels)&&void 0!==n&&n,N=o.title,D=r||[],C=i||[],T=Nn(D,g,f),B=e.useMemo(()=>e=>{const t={};return t.fill=g?Vt(e.data||e,g,T):Pn,"number"==typeof y&&(t.r=y),t},[g,T,y]),R=e.useMemo(()=>e=>({stroke:v,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:b}),[m,v,b]),z=e.useMemo(()=>{if(j&&d)return"function"==typeof d?d:e=>e[d]},[j,d]),{legend:W,margin:_}=Tn({data:D,colorBy:g,colorScale:T,showLegend:P,userMargin:a,defaults:o.marginDefaults}),H=e.useCallback(e=>{if(!S)return;const t=Date.now();S(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ForceDirectedGraph",chartId:E}:{type:"hover-end",timestamp:t,chartType:"ForceDirectedGraph",chartId:E})},[S,E]),$=$n({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:l}});return $?h.createElement(zn,{componentName:"ForceDirectedGraph",message:$,width:L,height:O}):h.createElement(on,Object.assign({chartType:"force",nodes:D,edges:C,size:[L,O],margin:_,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,iterations:x,forceStrength:w,nodeStyle:B,edgeStyle:R,colorBy:g,colorScheme:f,nodeSize:y,nodeSizeRange:p,nodeLabel:z,showLabels:j,enableHover:M,tooltipContent:k?e=>cn(k)(e.data):void 0,customHoverBehavior:S?H:void 0,legend:W,className:s,title:N},A))}function xo(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function wo(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function ko(e){return"function"==typeof e?e:t=>t[e]||1}function Ao({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Vt(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Vt(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function So(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:g,colorScheme:f="category10",edgeColorBy:y="source",padAngle:p=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:A,chartId:S}=t,E=o.width,L=o.height,O=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,P=o.title,j=i||[],N=e.useMemo(()=>wo(r,j,l,c),[r,j,l,c]),D=Nn(N,g,f),C=e.useMemo(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=Vt(e.data||e,g,D);else{const i=Array.isArray(f)?f:Xt[f]||Gt,a=Array.isArray(i)?i:Gt,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r},[g,D,f]),T=e.useMemo(()=>Ao({edgeColorBy:y,colorBy:g,colorScale:D,nodeStyleFn:C,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[y,g,D,C,x]),B=e.useMemo(()=>{if(!M)return;const e=b||d;return"function"==typeof e?e:t=>t[e]},[M,b,d]),R=Object.assign(Object.assign({},o.marginDefaults),a),z=e.useCallback(e=>{if(!A)return;const t=Date.now();A(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"ChordDiagram",chartId:S}:{type:"hover-end",timestamp:t,chartType:"ChordDiagram",chartId:S})},[A,S]),W=$n({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return W?h.createElement(zn,{componentName:"ChordDiagram",message:W,width:E,height:L}):h.createElement(on,Object.assign({chartType:"chord",nodes:N,edges:j,size:[E,L],margin:R,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:p,groupWidth:m,sortGroups:v,nodeStyle:C,edgeStyle:T,colorBy:g,colorScheme:f,edgeColorBy:y,edgeOpacity:x,nodeLabel:B,showLabels:M,enableHover:O,tooltipContent:w?e=>cn(w)(e.data):void 0,customHoverBehavior:A?z:void 0,className:s,title:P},k))}function Eo(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:r,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:g,colorScheme:f="category10",edgeColorBy:y="source",orientation:p="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:w=.5,edgeSort:k,tooltip:A,frameProps:S={},onObservation:E,chartId:L}=t,O=o.width,M=o.height,P=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,N=o.title,D=i||[],C=e.useMemo(()=>wo(r,D,l,c),[r,D,l,c]),T=Nn(C,g,f),B=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Vt(e.data||e,g,T):"#4d430c",t},[g,T]),R=e.useMemo(()=>Ao({edgeColorBy:y,colorBy:g,colorScale:T,nodeStyleFn:B,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,g,T,B,w]),z=e.useMemo(()=>{if(!j)return;const e=x||d;return"function"==typeof e?e:t=>t[e]},[j,x,d]),W=Object.assign(Object.assign({},o.marginDefaults),a),_=Mn(e=>e.pushObservation),H=e.useCallback(e=>{const t=Date.now();if(e){const n={type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:L};E&&E(n),_&&_(n)}else{const e={type:"hover-end",timestamp:t,chartType:"SankeyDiagram",chartId:L};E&&E(e),_&&_(e)}},[E,L,_]),$=e.useCallback(e=>{const t=Date.now();if(e){const n={type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"SankeyDiagram",chartId:L};E&&E(n),_&&_(n)}else{const e={type:"click-end",timestamp:t,chartType:"SankeyDiagram",chartId:L};E&&E(e),_&&_(e)}},[E,L,_]),I=$n({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return I?h.createElement(zn,{componentName:"SankeyDiagram",message:I,width:O,height:M}):h.createElement(on,Object.assign({chartType:"sankey",nodes:C,edges:D,size:[O,M],margin:W,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:p,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:B,edgeStyle:R,colorBy:g,colorScheme:f,edgeColorBy:y,edgeOpacity:w,edgeSort:k,nodeLabel:z,showLabels:j,enableHover:P,tooltipContent:A?e=>cn(A)(e.data):void 0,customHoverBehavior:E?H:void 0,customClickBehavior:E?$:void 0,className:s,title:N},S))}function Lo(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:g,colorScheme:f="category10",colorByDepth:y=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:w,chartId:k}=t,A=o.width,S=o.height,E=o.enableHover,L=null===(n=o.showLabels)||void 0===n||n,O=o.title,M=e.useMemo(()=>xo(r,c),[r,c]),P=e.useMemo(()=>{if(!y&&g&&"function"!=typeof g)return Ut(M,g,f)},[M,g,y,f]),j=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?qt[(e.depth||0)%qt.length]:g?Vt(e.data||e,g,P):Pn,t},[g,y,P]),N=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),D=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return ko(u)},[s,u]),C=Object.assign(Object.assign({},o.marginDefaults),i),T=e.useCallback(e=>{if(!w)return;const t=Date.now();w(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"TreeDiagram",chartId:k}:{type:"hover-end",timestamp:t,chartType:"TreeDiagram",chartId:k})},[w,k]),B=Hn({componentName:"TreeDiagram",data:r});return B?h.createElement(zn,{componentName:"TreeDiagram",message:B,width:A,height:S}):h.createElement(on,Object.assign({chartType:s,data:r,size:[A,S],margin:C,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:D,treeOrientation:l,edgeType:p,nodeStyle:j,edgeStyle:N,colorBy:g,colorScheme:f,colorByDepth:y,nodeSize:v,nodeLabel:L?m||d:void 0,showLabels:L,enableHover:E,tooltipContent:b?e=>cn(b)(e.data):void 0,customHoverBehavior:w?T:void 0,className:a,title:O},x))}function Oo(t){var n;const o=Rn(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:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:g=!1,labelMode:f="leaf",nodeLabel:y,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,S=o.width,E=o.height,L=o.enableHover,O=null===(n=o.showLabels)||void 0===n||n,M=o.title,{activeSelectionHook:P,customHoverBehavior:j}=Cn({selection:x,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:k,chartType:"Treemap",chartId:A}),N=e.useCallback(e=>{if(!e)return j(null);const t=e.data||e;j({data:(null==t?void 0:t.data)||t})},[j]),D=e.useMemo(()=>xo(r,s),[r,s]),C=e.useMemo(()=>{if(g)return;if(!u||"function"==typeof u)return;const e=u;return Ut(D.filter(t=>null!=t[e]),e,d)},[D,u,g,d]),T=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=g?qt[(e.depth||0)%qt.length]:u?Vt(e.data||e,u,C):Pn,t},[u,g,C]),B=e.useMemo(()=>P?e=>{var t,n;const o=Object.assign({},T(e));return P.isActive&&(P.predicate(e.data||e)?(null==x?void 0:x.selectedStyle)&&Object.assign(o,x.selectedStyle):(o.fillOpacity=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2,o.strokeOpacity=null!==(n=null==x?void 0:x.unselectedOpacity)&&void 0!==n?n:.2,(null==x?void 0:x.unselectedStyle)&&Object.assign(o,x.unselectedStyle))),o}:T,[T,P,x]),R=e.useMemo(()=>ko(l),[l]),z=void 0!==m?m:O&&"parent"===f?18:void 0,W=Object.assign(Object.assign({},o.marginDefaults),i),_=Hn({componentName:"Treemap",data:r});return _?h.createElement(zn,{componentName:"Treemap",message:_,width:S,height:E}):h.createElement(on,Object.assign({chartType:"treemap",data:r,size:[S,E],margin:W,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:R,padding:p,paddingTop:z,nodeStyle:B,colorBy:u,colorScheme:d,colorByDepth:g,nodeLabel:O?y||c:void 0,showLabels:O,enableHover:L,tooltipContent:v?e=>cn(v)(e.data):void 0},(w||k)&&{customHoverBehavior:N},{className:a,title:M},b))}function Mo(t){var n;const o=Rn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d="category10",colorByDepth:g=!1,nodeLabel:f,circleOpacity:y=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x}=t,w=o.width,k=o.height,A=o.enableHover,S=null===(n=o.showLabels)||void 0===n||n,E=o.title,L=e.useMemo(()=>xo(r,s),[r,s]),O=e.useMemo(()=>{if(!g&&u&&"function"!=typeof u)return Ut(L,u,d)},[L,u,g,d]),M=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=g?qt[(e.depth||0)%qt.length]:u?Vt(e.data||e,u,O):Pn,t},[u,g,O,y]),P=e.useMemo(()=>ko(l),[l]),j=Object.assign(Object.assign({},o.marginDefaults),i),N=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]),D=Hn({componentName:"CirclePack",data:r});return D?h.createElement(zn,{componentName:"CirclePack",message:D,width:w,height:k}):h.createElement(on,Object.assign({chartType:"circlepack",data:r,size:[w,k],margin:j,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:P,padding:p,nodeStyle:M,colorBy:u,colorScheme:d,colorByDepth:g,nodeLabel:S?f||c:void 0,showLabels:S,enableHover:A,tooltipContent:m?e=>cn(m)(e.data):void 0,customHoverBehavior:b?N:void 0,className:a,title:E},v))}ro.displayName="ScatterplotMatrix",ao.displayName="MinimapChart",so.displayName="BarChart",lo.displayName="StackedBarChart",co.displayName="SwarmPlot",uo.displayName="BoxPlot",ho.displayName="Histogram",go.displayName="ViolinPlot",fo.displayName="RidgelinePlot",yo.displayName="DotPlot",po.displayName="PieChart",mo.displayName="DonutChart",vo.displayName="GroupedBarChart",bo.displayName="ForceDirectedGraph",So.displayName="ChordDiagram",Eo.displayName="SankeyDiagram",Lo.displayName="TreeDiagram",Oo.displayName="Treemap",Mo.displayName="CirclePack";const Po=e.forwardRef(function(t,n){var o,r,i,a;const s=Rn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:w="#007bff",strokeWidth:k=2,strokeDasharray:A,background:S,tooltipContent:E,tooltip:L,onHover:O,annotations:M,svgAnnotationRules:P,tickFormatTime:j,tickFormatValue:N,decay:D,pulse:C,staleness:T,transition:B,linkedHover:R,onObservation:z,chartId:W}=t,_=s.showAxes,H=s.enableHover,$=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=E?E:L,Y=e.useRef(null),{customHoverBehavior:X}=Cn({linkedHover:R,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:W}),G=e.useCallback(e=>{O&&O(e),X(e)},[O,X]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),h.createElement(ae,{ref:Y,chartType:"line",runtimeMode:"streaming",size:I,margin:$,className:u,arrowOfTime:d,windowMode:g,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:{stroke:w,strokeWidth:k,strokeDasharray:A},showAxes:_,background:S,hoverAnnotation:H,tooltipContent:F,customHoverBehavior:G,annotations:M,svgAnnotationRules:P,tickFormatTime:j,tickFormatValue:N,decay:D,pulse:C,staleness:T,transition:B})});Po.displayName="RealtimeLineChart";const jo=e.forwardRef(function(t,n){var o,r,i,a;const s=Rn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:l,size:c,margin:u,className:d,arrowOfTime:g="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,categoryAccessor:k,colors:A,fill:S,stroke:E,strokeWidth:L,gap:O,background:M,tooltipContent:P,tooltip:j,onHover:N,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B,linkedHover:R,decay:z,pulse:W,staleness:_,transition:H,onObservation:$,chartId:I}=t,F=s.showAxes,Y=s.enableHover,X=null!=u?u:s.marginDefaults,G=null!=c?c:[s.width,s.height],q=null!=P?P:j,V=e.useRef(null),{customHoverBehavior:U}=Cn({linkedHover:R,unwrapData:!0,onObservation:$,chartType:"RealtimeTemporalHistogram",chartId:I}),Z=e.useCallback(e=>{N&&N(e),U(e)},[N,U]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=V.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=V.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Q={};return null!=S&&(Q.fill=S),null!=E&&(Q.stroke=E),null!=L&&(Q.strokeWidth=L),null!=O&&(Q.gap=O),h.createElement(ae,{ref:V,chartType:"bar",runtimeMode:"streaming",size:G,margin:X,className:d,arrowOfTime:g,windowMode:f,windowSize:y,data:p,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:w,binSize:l,categoryAccessor:k,barColors:A,barStyle:Q,showAxes:F,background:M,hoverAnnotation:Y,tooltipContent:q,customHoverBehavior:Z,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B,decay:z,pulse:W,staleness:_,transition:H})});jo.displayName="RealtimeTemporalHistogram";const No=jo,Do=e.forwardRef(function(t,n){var o,r,i,a;const s=Rn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:w,colors:k,radius:A,fill:S,opacity:E,stroke:L,strokeWidth:O,background:M,tooltipContent:P,tooltip:j,onHover:N,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B,linkedHover:R,onObservation:z,chartId:W}=t,_=s.showAxes,H=s.enableHover,$=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=P?P:j,Y=e.useRef(null),{customHoverBehavior:X}=Cn({linkedHover:R,unwrapData:!0,onObservation:z,chartType:"RealtimeSwarmChart",chartId:W}),G=e.useCallback(e=>{N&&N(e),X(e)},[N,X]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const q={};return null!=A&&(q.radius=A),null!=S&&(q.fill=S),null!=E&&(q.opacity=E),null!=L&&(q.stroke=L),null!=O&&(q.strokeWidth=O),h.createElement(ae,{ref:Y,chartType:"swarm",runtimeMode:"streaming",size:I,margin:$,className:u,arrowOfTime:d,windowMode:g,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:w,barColors:k,swarmStyle:q,showAxes:_,background:M,hoverAnnotation:H,tooltipContent:F,customHoverBehavior:G,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B})});Do.displayName="RealtimeSwarmChart";const Co=e.forwardRef(function(t,n){var o,r,i,a;const s=Rn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:w,negativeColor:k,connectorStroke:A,connectorWidth:S,gap:E,stroke:L,strokeWidth:O,background:M,tooltipContent:P,tooltip:j,onHover:N,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B,linkedHover:R,onObservation:z,chartId:W}=t,_=s.showAxes,H=s.enableHover,$=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=P?P:j,Y=e.useRef(null),{customHoverBehavior:X}=Cn({linkedHover:R,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:W}),G=e.useCallback(e=>{N&&N(e),X(e)},[N,X]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const q={};return null!=w&&(q.positiveColor=w),null!=k&&(q.negativeColor=k),null!=A&&(q.connectorStroke=A),null!=S&&(q.connectorWidth=S),null!=E&&(q.gap=E),null!=L&&(q.stroke=L),null!=O&&(q.strokeWidth=O),h.createElement(ae,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:I,margin:$,className:u,arrowOfTime:d,windowMode:g,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:q,showAxes:_,background:M,hoverAnnotation:H,tooltipContent:F,customHoverBehavior:G,annotations:D,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:B})});Co.displayName="RealtimeWaterfallChart";const To=e.forwardRef(function(t,n){var o,r,i,a;const s=Rn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,heatmapXBins:k=20,heatmapYBins:A=20,aggregation:S="count",background:E,tooltipContent:L,tooltip:O,onHover:M,annotations:P,svgAnnotationRules:j,tickFormatTime:N,tickFormatValue:D,decay:C,pulse:T,staleness:B,linkedHover:R,onObservation:z,chartId:W}=t,_=s.showAxes,H=s.enableHover,$=null!=c?c:s.marginDefaults,I=null!=l?l:[s.width,s.height],F=null!=L?L:O,Y=e.useRef(null),{customHoverBehavior:X}=Cn({linkedHover:R,unwrapData:!0,onObservation:z,chartType:"RealtimeHeatmap",chartId:W}),G=e.useCallback(e=>{M&&M(e),X(e)},[M,X]);return e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Y.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),h.createElement(ae,{ref:Y,chartType:"heatmap",runtimeMode:"streaming",size:I,margin:$,className:u,arrowOfTime:d,windowMode:g,windowSize:f,data:y,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:w,heatmapXBins:k,heatmapYBins:A,heatmapAggregation:S,showAxes:_,background:E,hoverAnnotation:H,tooltipContent:F,customHoverBehavior:G,annotations:P,svgAnnotationRules:j,tickFormatTime:N,tickFormatValue:D,decay:C,pulse:T,staleness:B})});To.displayName="RealtimeHeatmap";const Bo={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ro={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[zo,Wo]=mn(e=>({theme:Bo,setTheme(t){e(e=>"light"===t?{theme:Bo}:"dark"===t?{theme:Ro}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function _o({theme:e}){const t=Wo(e=>e.setTheme);return h.useEffect(()=>{void 0!==e&&t(e)},[e,t]),null}function Ho({children:e}){const t=Wo(e=>e.theme);return h.createElement("div",{style:{position:"relative","--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily}},e)}function $o(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}function Io(e,t){return $o(this,void 0,void 0,function*(){const{format:n="svg",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Fo(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);Yo(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const e=l.width*r,t=l.height*r,n=(new XMLSerializer).serializeToString(s),a=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(a),u=new Image;u.width=l.width,u.height=l.height,yield new Promise((n,a)=>{u.onload=()=>{const s=document.createElement("canvas");s.width=e,s.height=t;const l=s.getContext("2d");l.fillStyle=i,l.fillRect(0,0,e,t),l.scale(r,r),l.drawImage(u,0,0),s.toBlob(e=>{e?(Yo(e,o+".png"),n()):a(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(c)},u.onerror=()=>{URL.revokeObjectURL(c),a(Error("Failed to load SVG image"))},u.src=c})}})}function Fo(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)Fo(o[e],r[e])}function Yo(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}"function"==typeof SuppressedError&&SuppressedError;const Xo={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["function","object"]},frameProps:{type:"object"}},Go={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},qo={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Vo=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Uo=["vertical","horizontal"],Zo={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Vo},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Vo},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Vo},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),Go),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xo),qo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Uo},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Xo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Xo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xo),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Uo},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xo),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}},Qo=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),Jo=new Set(["data","nodes","edges"]),Ko="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function er(e){return $o(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?tr(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function tr(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function nr(e){return"nominal"===e||"ordinal"===e}function or(e){return"quantitative"===e||"temporal"===e}const rr={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},ir={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},ar={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function sr(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function lr(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};return n.length>0&&(o.warnings=n),o}class cr extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:h.createElement(zn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}const ur={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function dr({height:e}){return h.createElement("div",{style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function hr({error:e}){return h.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},h.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const gr=h.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,controls:s,loading:l=!1,error:c,errorBoundary:u=!1,status:d,detailsPanel:g,className:f,style:y},p){const m=h.useRef(null),v=h.useRef(null),[b,x]=h.useState(!1),w=!1!==(null==i?void 0:i.export)&&void 0!==(null==i?void 0:i.export),k=!1!==(null==i?void 0:i.fullscreen)&&void 0!==(null==i?void 0:i.fullscreen),A=!1!==(null==i?void 0:i.copyConfig)&&void 0!==(null==i?void 0:i.copyConfig)&&a,S="object"==typeof(null==i?void 0:i.export)?i.export:{},E="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",L=h.useCallback(e=>$o(this,void 0,void 0,function*(){v.current&&(yield Io(v.current,Object.assign(Object.assign({},S),e)))}),[S]),O=h.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),M=h.useCallback(e=>$o(this,void 0,void 0,function*(){a&&(yield er(a,e||E||"json"))}),[a,E]);h.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),h.useImperativeHandle(p,()=>({export:L,toggleFullscreen:O,copyConfig:M,element:m.current}),[L,O,M]);const P=e||t||s||w||k||A||d,j=l?h.createElement(dr,{height:r}):c?h.createElement(hr,{error:c}):u?h.createElement(cr,null,n):n;return h.createElement(h.Fragment,null,h.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),h.createElement("div",{ref:m,className:"semiotic-chart-container"+(f?" "+f:""),style:Object.assign(Object.assign({width:o,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:8,overflow:"hidden",background:"var(--semiotic-bg, #fff)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y)},P&&h.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},h.createElement("div",{className:"semiotic-chart-title-area"},e&&h.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&h.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),h.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,w&&h.createElement("button",{className:"semiotic-chart-action",onClick:()=>L(),title:"Export chart",style:fr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),h.createElement("path",{d:"M2 12h10"}))),k&&h.createElement("button",{className:"semiotic-chart-action",onClick:O,title:b?"Exit fullscreen":"Fullscreen",style:fr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?h.createElement(h.Fragment,null,h.createElement("path",{d:"M9 1v4h4"}),h.createElement("path",{d:"M5 13V9H1"}),h.createElement("path",{d:"M13 5H9V1"}),h.createElement("path",{d:"M1 9h4v4"})):h.createElement(h.Fragment,null,h.createElement("path",{d:"M1 5V1h4"}),h.createElement("path",{d:"M13 9v4H9"}),h.createElement("path",{d:"M9 1h4v4"}),h.createElement("path",{d:"M5 13H1V9"})))),A&&h.createElement("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Copy config",style:fr},h.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),h.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&h.createElement("div",{className:"semiotic-chart-status",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:ur[d].bg,color:ur[d].color,lineHeight:"18px"}},d))),h.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden"},b?{flex:1}:{height:r})},j,g)))}),fr={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function yr({children:t,position:n="right",size:o=300,trigger:r="click",chartId:i,observation:a,dismissOnEmpty:s=!0,showClose:l=!0,onToggle:c,className:u,style:d}){const[g,f]=e.useState(null),[y,p]=e.useState(null),[m,v]=e.useState(!1),[b,x]=e.useState(!1),w=e.useRef(null),k=e.useRef(),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:S}=Vn({types:A,chartId:i,limit:1}),E=void 0!==a?a:S;e.useEffect(()=>{if(E)if("click"===E.type||"hover"===E.type){const e=E;f(e.datum),p(e),m||(v(!0),x(!0),clearTimeout(k.current),k.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==E.type&&"hover-end"!==E.type||L()},[E]),e.useEffect(()=>{null==c||c(m)},[m,c]);const L=e.useCallback(()=>{x(!0),v(!1),clearTimeout(k.current),k.current=setTimeout(()=>{x(!1),f(null),p(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(k.current),[]),!g&&!b)return null;const O=g&&y?t(g,y):null;if(null===O&&!b)return null;const M=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,o,m,b);return h.createElement("div",{ref:w,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},M),d)},l&&h.createElement("button",{className:"semiotic-details-close",onClick:L,"aria-label":"Close details",style:pr},h.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},h.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),h.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},O))}const pr={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};yr.displayName="DetailsPanel",exports.AreaChart=Yn,exports.BarChart=so,exports.BoxPlot=uo,exports.BubbleChart=qn,exports.ChartContainer=gr,exports.ChartErrorBoundary=cr,exports.ChordDiagram=So,exports.CirclePack=Mo,exports.DARK_THEME=Ro,exports.DetailsPanel=yr,exports.DonutChart=mo,exports.DotPlot=yo,exports.ForceDirectedGraph=bo,exports.GroupedBarChart=vo,exports.Heatmap=Gn,exports.Histogram=ho,exports.IncrementalExtent=p,exports.LIGHT_THEME=Bo,exports.LineChart=Fn,exports.LinkedCharts=Zn,exports.MinimapChart=ao,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=an(e,n);l.push({value:sn(t,o)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=sn(an(e,r),i);l.push({label:a?n:void 0,value:s})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:a?t:void 0,value:sn(e[t],o)})});const c=Object.assign(Object.assign({},rn),r);return Array.isArray(l)&&0!==l.length?h.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>h.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&h.createElement("strong",null,e.label,s),e.value))):null}},exports.PieChart=po,exports.RealtimeHeatmap=To,exports.RealtimeHistogram=No,exports.RealtimeLineChart=Po,exports.RealtimeSwarmChart=Do,exports.RealtimeTemporalHistogram=jo,exports.RealtimeWaterfallChart=Co,exports.RidgelinePlot=fo,exports.RingBuffer=y,exports.SankeyDiagram=Eo,exports.Scatterplot=In,exports.ScatterplotMatrix=ro,exports.StackedAreaChart=Xn,exports.StackedBarChart=lo,exports.StreamNetworkFrame=on,exports.StreamOrdinalFrame=Le,exports.StreamXYFrame=ae,exports.SwarmPlot=co,exports.ThemeProvider=function({theme:e,children:t}){return h.createElement(zo,null,h.createElement(_o,{theme:e}),h.createElement(Ho,null,t))},exports.Tooltip=ln,exports.TreeDiagram=Lo,exports.Treemap=Oo,exports.ViolinPlot=go,exports.configToJSX=tr,exports.copyConfig=er,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.exportChart=Io,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!Zo[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:Ko(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f;const y=[],{type:p,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(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}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,w=v.color,k=v.size,A=v.theta,S=v.opacity;let E;(null===(t=e.data)||void 0===t?void 0:t.values)?E=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&y.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&y.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite().");const L={};e.width&&(L.width=e.width),e.height&&(L.height=e.height);const O=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(O&&(L.title=O),(null==w?void 0:w.field)&&(L.colorBy=w.field,null===(o=w.scale)||void 0===o?void 0:o.scheme)){const e=rr[w.scale.scheme];e&&(L.colorScheme=e)}void 0!==(null==S?void 0:S.value)&&(L.pointOpacity=S.value);const M=null==b?void 0:b.aggregate,P=null==x?void 0:x.aggregate;if(E&&(M||P)){const e=P?x:b,t=P?b:x,n=ar[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)E=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(E,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&E){const e=new Map;for(const n of E){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}E=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";E&&(L.data=E),(null==b?void 0:b.bin)?(L.valueAccessor=b.field,(null==x?void 0:x.field)&&(L.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(L.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(L.valueAccessor=x.field,(null==b?void 0:b.field)&&(L.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(L.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(L.bins=t),lr(e,L,y)}let j;switch(p){case"bar":j=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",nr(null==e?void 0:e.type)&&or(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):or(null==e?void 0:e.type)&&nr(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,w,L,E,M,P);break;case"line":if(j="LineChart",sr(b,x,L,M,P),(null==w?void 0:w.field)&&(L.lineBy=w.field),m.interpolate){const e=ir[m.interpolate];e&&(L.curve=e)}!0===m.point&&(L.showPoints=!0),E&&(L.data=E);break;case"area":if((null==w?void 0:w.field)?(j="StackedAreaChart",L.areaBy=w.field):j="AreaChart",sr(b,x,L,M,P),m.interpolate){const e=ir[m.interpolate];e&&(L.curve=e)}void 0!==m.opacity&&(L.areaOpacity=m.opacity),E&&(L.data=E);break;case"point":case"circle":case"square":(null==k?void 0:k.field)?(j="BubbleChart",L.sizeBy=k.field,(null===(l=k.scale)||void 0===l?void 0:l.range)&&(L.sizeRange=k.scale.range)):j="Scatterplot",sr(b,x,L,M,P),E&&(L.data=E);break;case"rect":j="Heatmap",(null==b?void 0:b.field)&&(L.xAccessor=b.field),(null==x?void 0:x.field)&&(L.yAccessor=x.field),(null==w?void 0:w.field)&&(L.valueAccessor=w.field,delete L.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(L.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(L.yLabel=x.axis.title),E&&(L.data=E);break;case"arc":m.innerRadius&&m.innerRadius>0?(j="DonutChart",L.innerRadius=m.innerRadius):j="PieChart",(null==A?void 0:A.field)?L.valueAccessor=A.field:(null==x?void 0:x.field)&&(L.valueAccessor=P?"value":x.field),(null==w?void 0:w.field)&&(L.categoryAccessor=w.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(L.categoryAccessor=b.field),E&&(L.data=E);break;case"tick":j="DotPlot",nr(null==b?void 0:b.type)?(L.categoryAccessor=b.field,(null==x?void 0:x.field)&&(L.valueAccessor=P?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(L.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(L.valueLabel=x.axis.title)):nr(null==x?void 0:x.type)?(L.categoryAccessor=x.field,(null==b?void 0:b.field)&&(L.valueAccessor=M?"value":b.field),L.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(L.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(L.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(L.categoryAccessor=b.field),(null==x?void 0:x.field)&&(L.valueAccessor=P?"value":x.field)),E&&(L.data=E);break;default:y.push(`Unsupported mark type "${p}". Defaulting to Scatterplot.`),j="Scatterplot",sr(b,x,L,M,P),E&&(L.data=E)}return lr(j,L,y)},exports.normalizeTooltip=cn,exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.smartTickFormat=function(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"},exports.toConfig=function(e,t,n){if(!Zo[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(Zo).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(Qo.has(e)||!o&&Jo.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=Ko(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=Ln,exports.useChartObserver=Vn,exports.useFilteredData=function(t,n,o){const r=An(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=xn(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=En,exports.useSelection=Sn,exports.useTheme=function(){return Wo(e=>e.theme)};