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 t=require("react"),e=require("d3-brush"),n=require("d3-selection"),i=require("d3-scale"),o=require("d3-array"),r=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"),h=require("d3-hierarchy");function d(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const f=d(t),y=5e3;class g{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}setBoundedData(t){if(t===this.lastBoundedData)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,y),bounded:!0,totalSize:t.length});let e=y;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const i=Math.min(e+y,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(t){this.callback({inserts:[t],bounded:!1})}pushMany(t){0!==t.length&&this.callback({inserts:t,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class p{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class m{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function v(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/i)*i;let c=r.get(l);if(c||(c={start:l,end:l+i,total:0,categories:new Map},r.set(l,c)),c.total+=a,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function x(t,e,n,i,o,r){const s=[],a=[];for(const o of t){const t=n(o),r=i(o);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||(s.push([e.x(t),e.y(r)]),a.push(r))}return{type:"line",path:s,rawValues:a,style:o,datum:t,group:r}}function b(t,e,n,i,o,r,s){const a=[],l=[];for(const r of t){const t=n(r),s=i(r);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=e.x(t);a.push([c,e.y(s)]),l.push([c,e.y(o)])}return{type:"area",topPath:a,bottomPath:l,style:r,datum:t,group:s}}function k(t,e,n,i,o,r){const s=n(t),a=i(t);return null==s||null==a||Number.isNaN(s)||Number.isNaN(a)?null:{type:"point",x:e.x(s),y:e.y(a),r:o,style:r,datum:t}}function w(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function E(t,e,n,i,o,r){return{type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r}}function A(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function S(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class M{constructor(t){this.xExtent=new m,this.yExtent=new m,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new p(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=A(t.timeAccessor||t.xAccessor,"time"),this.getY=A(t.valueAccessor||t.yAccessor,"value")):(this.getX=A(t.xAccessor,"x"),this.getY=A(t.yAccessor,"y")),this.getGroup=S(t.groupAccessor),this.getCategory=S(t.categoryAccessor),this.getSize=t.sizeAccessor?A(t.sizeAccessor,"size"):void 0,this.getColor=S(t.colorAccessor),this.getBounds=t.boundsAccessor?A(t.boundsAccessor,"bounds"):void 0,"candlestick"===t.chartType&&(this.getOpen=A(t.openAccessor,"open"),this.getHigh=A(t.highAccessor,"high"),this.getLow=A(t.lowAccessor,"low"),this.getClose=A(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new p(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,o,r,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 t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let d=l.xExtent?[null!==(e=l.xExtent[0])&&void 0!==e?e:u[0],null!==(n=l.xExtent[1])&&void 0!==n?n:u[1]]:u,f=l.yExtent?[null!==(o=l.yExtent[0])&&void 0!==o?o:h[0],null!==(r=l.yExtent[1])&&void 0!==r?r:h[1]]:h;const y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&c.size>0)if(l.normalize)f=[0,1+l.extentPadding];else{const t=c.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||n.set(t,(n.get(t)||0)+i)}let i=0;for(const t of n.values())t>i&&(i=t);f=[0,i+(i>0?i*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,i,o){const r=v(t,e,n,i,o);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(c,this.getX,this.getY,l.binSize,this.getCategory);f=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&c.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(c,this.getY),n=e-t,i=n>0?n*l.extentPadding:1;f=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!y&&f[0]!==1/0){if(this.getBounds){const t=c.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}}const t=f[1]-f[0],e=t>0?t*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],i=null===(a=l.yExtent)||void 0===a?void 0:a[1];f=[null!=n?f[0]:f[0]-e,null!=i?f[1]:f[1]+e]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(g=l.arrowOfTime)||"down"===g?"y":"x")){const e="right"===l.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:i.scaleLinear().domain(d).range(e),y:i.scaleLinear().domain(f).range([t.height,0])}}else{const e="down"===l.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:i.scaleLinear().domain(f).range([0,t.width]),y:i.scaleLinear().domain(d).range(e)}}else this.scales={x:i.scaleLinear().domain(d).range([0,t.width]),y:i.scaleLinear().domain(f).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:i}=this;if(!i||0===n.size)return[];const o=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(o);case"area":return this.buildAreaScene(o);case"stackedarea":return this.buildStackedAreaScene(o);case"scatter":case"bubble":return this.buildPointScene(o);case"heatmap":return this.buildHeatmapScene(o,t);case"bar":return this.buildBarScene(o);case"swarm":return this.buildSwarmScene(o);case"waterfall":return this.buildWaterfallScene(o,t);case"candlestick":return this.buildCandlestickScene(o,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),i=[],o=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&i.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=x(t.data,this.scales,this.getX,this.getY,e,t.key);o&&o.length>0&&(n.colorThresholds=o),i.push(n)}return i}buildAreaScene(t){const e=this.groupData(t),n=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]);n.push(b(t.data,this.scales,this.getX,this.getY,i,e,t.key))}return n}buildStackedAreaScene(t){return function(t,e,n,i,o,r){var s;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const l=Array.from(a).sort((t,e)=>t-e),c=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||t.set(e,(t.get(e)||0)+r)}c.set(e.key,t)}let u;if(r){u=new Map;for(const e of l){let n=0;for(const i of t)n+=(null===(s=c.get(i.key))||void 0===s?void 0:s.get(e))||0;u.set(e,n||1)}}const h=[],d=new Map;for(const t of l)d.set(t,0);for(const n of t){const t=c.get(n.key),i=[],s=[];for(const n of l){let o=t.get(n)||0;const a=d.get(n);r&&(o/=u.get(n));const l=e.x(n);s.push([l,e.y(a)]),i.push([l,e.y(a+o)]),d.set(n,a+o)}h.push({type:"area",topPath:i,bottomPath:s,style:o(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(this.groupData(t),this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,i=this.config.sizeRange||[3,15];let o=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),n=Math.max(...e);o=e=>t===n?(i[0]+i[1])/2:i[0]+(e-t)/(n-t)*(i[1]-i[0])}}let r=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];r=new Map;let i=0;for(const t of e)r.set(t,n[i%n.length]),i++}for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},s=t.r||n;if(o&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(s=o(t))}if(r&&this.getColor){const e=this.getColor(i);e&&r.has(e)&&(t=Object.assign(Object.assign({},t),{fill:r.get(e)}))}const a=k(i,this.scales,this.getX,this.getY,s,t);a&&e.push(a)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const i=A(this.config.valueAccessor,"value"),o=new Set,r=new Set;for(const e of t)o.add(this.getX(e)),r.add(this.getY(e));const s=Array.from(o).sort((t,e)=>t-e),a=Array.from(r).sort((t,e)=>t-e);if(0===s.length||0===a.length)return n;const l=e.width/s.length,c=e.height/a.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:i(e),datum:e})}let h=1/0,d=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>d&&(d=t);const f=d-h||1;for(let t=0;s.length>t;t++)for(let e=0;a.length>e;e++){const i=u.get(`${s[t]}_${a[e]}`);if(!i)continue;const o=(i.val-h)/f;n.push(E(t*l,(a.length-1-e)*c,l,c,`rgb(${Math.round(220-180*o)},${Math.round(220-100*o)},${Math.round(255-50*o)})`,i.datum))}return n}buildStreamingHeatmapScene(t,e){var n,i,o;const r=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,l=null!==(o=this.config.heatmapAggregation)&&void 0!==o?o:"count",c=A(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return r;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/s,g=(f-d||1)/a,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),i=Math.min(Math.floor((t-u)/y),s-1),o=Math.min(Math.floor((n-d)/g),a-1);if(0>i||0>o)continue;const r=`${i}_${o}`;let l=p.get(r);l||(l={sum:0,count:0,data:[]},p.set(r,l)),l.count++,l.sum+=c(e),l.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(l){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),m>n&&(m=n),n>v&&(v=n)}const b=v-m||1,k=e.width/s,w=e.height/a;for(const[t,e]of x){const[n,i]=t.split("_"),o=+n,s=+i,l=(e-m)/b,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=p.get(t);r.push(E(o*k,(a-1-s)*w,k,w,c,{xi:o,yi:s,value:e,count:u.count,sum:u.sum,data:u.data}))}return r}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=v(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let i=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],o=new Set(e),r=Array.from(t).filter(t=>!o.has(t)).sort();i=[...e.filter(e=>t.has(e)),...r]}const o=[],r=this.scales,[s,a]=r.x.domain();for(const t of n.values()){const n=Math.max(t.start,s),l=Math.min(t.end,a);if(n>=l)continue;const c=r.x(n),u=r.x(l),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(i&&t.categories.size>0){let n=0;for(const s of i){const i=t.categories.get(s)||0;if(0===i)continue;const a=r.y(n),l=r.y(n+i);o.push(w(h,Math.min(a,l),d,Math.abs(a-l),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[s])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:i},s)),n+=i}}else{const e=r.y(0),n=r.y(t.total);o.push(w(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return o}buildSwarmScene(t){var e,n,i,o;const r=[],s=this.config.swarmStyle||{},a=null!==(e=s.radius)&&void 0!==e?e:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(i=s.opacity)&&void 0!==i?i:.7,u=s.stroke,h=s.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const i=this.scales.x(t),s=this.scales.y(n);let d=l;if(this.getCategory){const t=this.getCategory(e);d=(null===(o=this.config.barColors)||void 0===o?void 0:o[t])||d}r.push({type:"point",x:i,y:s,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e})}return r}buildWaterfallScene(t,e){const n=[],i=this.scales,o=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===o.length)return n;let r=0;for(let t=0;o.length>t;t++){const s=o[t],a=this.getX(s),l=this.getY(s),c=r+l;let u;u=o.length-1>t?this.getX(o[t+1])-a:t>0?a-this.getX(o[t-1]):0;const h=i.x(a),d=0!==u?i.x(a+u):h+e.width/10,f=Math.min(h,d)+.5,y=Math.max(h,d)-.5-f;if(0>=y){r=c;continue}const g=i.y(r),p=i.y(c);n.push(w(f,Math.min(g,p),y,Math.abs(g-p),{fill:0>l?"#dc3545":"#28a745"},Object.assign(Object.assign({},s),{baseline:r,cumEnd:c,delta:l}))),r=c}return n}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],i=this.config.candlestickStyle||{},o=i.upColor||"#28a745",r=i.downColor||"#dc3545",s=i.wickColor||"#333",a=i.wickWidth||1,l=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=i.bodyWidth||6;if(!i.bodyWidth&&l.length>1){let t=1/0;for(let e=1;l.length>e;e++){const n=Math.abs(this.scales.x(l[e])-this.scales.x(l[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const i=this.getOpen(e),l=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,l,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=i;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:o,downColor:r,wickColor:s,wickWidth:a,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],i=[];for(const e of t){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const r=this.getBounds(e),s=this.scales.x(t);if(r&&0!==r)n.push([s,this.scales.y(o+r)]),i.push([s,this.scales.y(o-r)]);else{const t=this.scales.y(o);n.push([s,t]),i.push([s,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var n,i,o;const r=this.config.decay;if(!r||1>=e)return 1;const s=null!==(n=r.minOpacity)&&void 0!==n?n:.1,a=e-1-t;switch(r.type){case"linear":return s+(1-a/(e-1))*(1-s);case"exponential":{const t=null!==(i=r.halfLife)&&void 0!==i?i:e/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(o=r.stepThreshold)&&void 0!==o?o:.5*e)>a?1:s;default:return 1}}applyDecay(t,e){var n,i;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const r=new Map;for(let t=0;e.length>t;t++)r.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,o);if("heatcell"===e.type)e.style={opacity:s};else if("candlestick"===e.type)e._decayOpacity=s;else{const t=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*s})}}}computePulseIntensity(t,e){var n;const i=this.config.pulse;if(!i)return 0;const o=null!==(n=i.duration)&&void 0!==n?n:500,r=e-t;return o>r?1-r/o:0}applyPulse(t,e){var n;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=new Map;for(let t=0;e.length>t;t++)r.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const s=this.computePulseIntensity(n,i);s>0&&(e._pulseIntensity=s,e._pulseColor=o)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&n>e-i}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeIdentity(e,t);n&&("point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(n,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var n,i,o,r;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(r=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(o=t.datum)||void 0===o?void 0:o.category)&&void 0!==r?r:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,n,i,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const s=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const s=this.scene[t],l=this.getNodeIdentity(s,t);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===s.type){const t={x:s.x,y:s.y,r:s.r};c.x===t.x&&c.y===t.y||(s._targetX=t.x,s._targetY=t.y,s._targetR=t.r,s.x=c.x,s.y=c.y,s.r=null!==(e=c.r)&&void 0!==e?e:s.r,a=!0)}else if("rect"===s.type){const t={x:s.x,y:s.y,w:s.w,h:s.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(s._targetX=t.x,s._targetY=t.y,s._targetW=t.w,s._targetH=t.h,s.x=c.x,s.y=c.y,s.w=null!==(n=c.w)&&void 0!==n?n:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,a=!0)}else if("heatcell"===s.type){const t={x:s.x,y:s.y,w:s.w,h:s.h};c.x===t.x&&c.y===t.y||(s._targetX=t.x,s._targetY=t.y,s._targetW=t.w,s._targetH=t.h,s.x=c.x,s.y=c.y,s.w=null!==(o=c.w)&&void 0!==o?o:s.w,s.h=null!==(r=c.h)&&void 0!==r?r:s.h,a=!0)}}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:s})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*i)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*i),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*i)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*i,t.y=n.y+(t._targetY-n.y)*i,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*i),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*i)}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const n=this.config.lineStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle)return this.config.areaStyle(e||{});const i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){Object.assign(this.config,t)}}function _(t,e,n){const i=e-t.x,o=n-t.y,r=Math.sqrt(i*i+o*o);return r>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:r}}function N(t,e,n){if(0===t.path.length)return null;const i=T(t.path,e);if(0>i)return null;const[o,r]=t.path[i],s=e-o,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:l}}function W(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function P(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function z(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function C(t,e,n){if(0===t.topPath.length)return null;const i=T(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,a=n-r;return{node:t,datum:t.datum,x:o,y:r,distance:Math.sqrt(s*s+a*a)}}function T(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}const O={fill:t=>f.createElement("rect",{style:t,width:20,height:20}),line:t=>f.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function $(t,e,n,i){let o;return o="function"==typeof n?n(t):(0,O[n])(i(t,e)),o}function R(t){const{legendGroups:e,customClickBehavior:n,title:i="Legend",width:o=100,height:r=20,orientation:s="vertical"}=t,a="vertical"===s?(({legendGroups:t,width:e,customClickBehavior:n})=>{let i=30;const o=[];return t.forEach((t,r)=>{i+=5,o.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:0,y1:i,x2:e,y2:i})),i+=10,t.label&&(i+=20,o.push(f.createElement("text",{key:"legend-text-"+r,y:i,className:"legend-group-label"},t.label)),i+=10),o.push(f.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(0,${i})`},((t,e)=>{const{type:n="fill",styleFn:i,items:o}=t,r=[];let s=0;return o.forEach((t,o)=>{const a=$(t,o,n,i);r.push(f.createElement("g",{key:"legend-item-"+o,transform:`translate(0,${s})`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},a,f.createElement("text",{y:15,x:30},t.label))),s+=25}),r})(t,n))),i+=25*t.items.length+10}),o})({legendGroups:e,width:o,customClickBehavior:n}):(({legendGroups:t,title:e,height:n,customClickBehavior:i})=>{let o=0;const r=[],s=!1===e?10:40;return t.forEach((e,a)=>{e.label&&(r.push(f.createElement("text",{key:"legend-text-"+a,transform:`translate(${o},${s}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},e.label)),o+=20);const l=((t,e)=>{const{type:n="fill",styleFn:i,items:o}=t,r=[];let s=0;return o.forEach((t,o)=>{const a=$(t,o,n,i);r.push(f.createElement("g",{key:"legend-item-"+o,transform:`translate(${s},0)`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},a,f.createElement("text",{y:15,x:25},t.label))),s+=35,s+=8*t.label.length}),{items:r,offset:s}})(e,i);r.push(f.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${o},${s})`},l.items)),o+=l.offset+5,t[a+1]&&r.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:o,y1:s-10,x2:o,y2:n+s+10})),o+=15}),f.createElement("g",null,!1!==e&&f.createElement("line",{x1:0,x2:o+10,y1:s-10,y2:s-10,stroke:"gray",className:"title-neatline"}),r)})({legendGroups:e,title:i,height:r,customClickBehavior:n});return f.createElement("g",null,void 0!==i&&f.createElement("text",{className:"legend-title",y:20,x:"horizontal"===s?0:o/2,textAnchor:"horizontal"===s?"start":"middle"},i),a)}function D(t){return"string"==typeof t?{type:t}:t}function Y({orient:e,config:n,values:i,scale:r,size:s,length:a}){const l=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=s-8;if("boxplot"===l.type){const t=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(i);if(!t)return null;const{q1:o,median:s,q3:a,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),y=(n-d)/2+4;if(c){const t=r(o),n=r(a),i=r(s),c=r(u),g=r(h),p="top"===e?-1:1,m=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+e},f.createElement("line",{x1:c,y1:m+p*(y+d/2),x2:g,y2:m+p*(y+d/2),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+d),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+d),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-y-d:m+y,width:Math.abs(n-t),height:d,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:i,y1:"top"===e?m-y-d:m+y,x2:i,y2:"top"===e?m-y:m+y+d,stroke:l.fill,strokeWidth:2}))}{const t=r(o),n=r(a),i=r(s),c=r(u),g=r(h),p="left"===e?-1:1,m=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+e},f.createElement("line",{x1:m+p*(y+d/2),y1:c,x2:m+p*(y+d/2),y2:g,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+d),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+d),y2:g,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:"left"===e?m-y-d:m+y,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:"left"===e?m-y-d:m+y,y1:i,x2:"left"===e?m-y:m+y+d,y2:i,stroke:l.fill,strokeWidth:2}))}}const u=o.bin().domain(t).thresholds(l.bins)(i);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===l.type)return f.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/h*n;if(c){const n=r(t.x0),s=r(t.x1)-r(t.x0);return f.createElement("rect",{key:i,x:n,y:"top"===e?-4-o:4,width:Math.max(s,.5),height:o,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(t.x0),s=r(t.x1)-r(t.x0);return f.createElement("rect",{key:i,x:"left"===e?-4-o:4,y:Math.min(n,n+s),width:o,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const t=n/2+4,i=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const s=o.length/h*(n/2),a=r((o.x0+o.x1)/2);i.push(c?`${a},${"top"===e?-(t-s):t-s}`:`${"left"===e?-(t-s):t-s},${a}`)}for(let o=u.length-1;o>=0;o--){const s=u[o];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);i.push(c?`${l},${"top"===e?-(t+a):t+a}`:`${"left"===e?-(t+a):t+a},${l}`)}return f.createElement("g",{"data-testid":"marginal-violin-"+e},f.createElement("polygon",{points:i.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const t=[];if(c){const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${o},${i}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,s=r((i.x0+i.x1)/2);t.push(`L${s},${"top"===e?-o-4:o+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;t.push(`L${s},${i}`),t.push("Z")}else{const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${i},${o}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,s=r((i.x0+i.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;t.push(`L${i},${s}`),t.push("Z")}return f.createElement("g",{"data-testid":"marginal-ridgeline-"+e},f.createElement("path",{d:t.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[i,r,l,s,a,e,c,4]);return u?f.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function B(t){return Math.round(100*t)/100+""}function L(e){const{width:n,height:i,totalWidth:o,totalHeight:r,margin:s,scales:a,showAxes:l,xLabel:c,yLabel:u,xFormat:h,yFormat:d,showGrid:y,title:g,legend:p,foregroundGraphics:m,marginalGraphics:v,xValues:x,yValues:b,annotations:k,svgAnnotationRules:w,annotationFrame:E,children:A}=e,S=t.useMemo(()=>l&&a?a.x.ticks(5).map(t=>({value:t,pixel:a.x(t),label:(h||B)(t)})):[],[l,a,h]),M=t.useMemo(()=>l&&a?a.y.ticks(5).map(t=>({value:t,pixel:a.y(t),label:(d||B)(t)})):[],[l,a,d]),_=t.useMemo(()=>k&&0!==k.length&&w?k.map((t,e)=>w(t,e,{scales:a?{time:a.x,value:a.y}:null,timeAxis:"x",width:n,height:i})).filter(Boolean):null,[k,w,n,i,E]);return l||g||p||m||v||_&&_.length>0||y||A?f.createElement("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&a&&f.createElement("g",{className:"stream-grid"},S.map((t,e)=>f.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"#e0e0e0",strokeWidth:1})),M.map((t,e)=>f.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"#e0e0e0",strokeWidth:1}))),l&&a&&f.createElement("g",{className:"stream-axes"},f.createElement("line",{x1:0,y1:i,x2:n,y2:i,stroke:"#ccc",strokeWidth:1}),S.map((t,e)=>f.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${i})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},t.label))),c&&f.createElement("text",{x:n/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},c),f.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"#ccc",strokeWidth:1}),M.map((t,e)=>f.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666",style:{userSelect:"none"}},t.label))),u&&f.createElement("text",{x:15-s.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-s.left}, ${i/2})`,style:{userSelect:"none"}},u)),_,v&&a&&x&&b&&f.createElement(f.Fragment,null,v.top&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(Y,{orient:"top",config:D(v.top),values:x,scale:a.x,size:s.top,length:n})),v.bottom&&f.createElement("g",{transform:`translate(0, ${i})`},f.createElement(Y,{orient:"bottom",config:D(v.bottom),values:x,scale:a.x,size:s.bottom,length:n})),v.left&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(Y,{orient:"left",config:D(v.left),values:b,scale:a.y,size:s.left,length:i})),v.right&&f.createElement("g",{transform:`translate(${n}, 0)`},f.createElement(Y,{orient:"right",config:D(v.right),values:b,scale:a.y,size:s.right,length:i}))),m,A),g&&f.createElement("text",{x:o/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof g?g:null),p&&f.createElement("g",{transform:`translate(${o-s.right+10}, ${s.top})`},"object"==typeof(N=p)&&null!==N&&!f.isValidElement(N)&&"legendGroups"in N?f.createElement(R,{legendGroups:p.legendGroups,title:"",width:100}):p)):null;var N}function X(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}const F=(t,e,n,i)=>{var o;const r=e.filter(t=>"area"===t.type);for(const e of r){if(2>e.topPath.length)continue;t.beginPath();const[n,i]=e.topPath[0];t.moveTo(n,i);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath();const r=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;if(t.globalAlpha=r,t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=1,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]),t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);t.stroke()}t.globalAlpha=1}},j=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;if(null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=4;t.beginPath(),t.arc(e.x,e.y,e.r+n*e._pulseIntensity,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.5*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},I=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?H(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1};function H(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.w)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}const G={line:[F,(t,e,n,i)=>{const o=e.filter(t=>"line"===t.type);for(const r of o){if(2>r.path.length)continue;const s=r.style.stroke||"#007bff",a=r.style.strokeWidth||2,l=r.colorThresholds,c=r.rawValues;if(t.setLineDash(r.style.strokeDasharray?r.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=r.style.opacity&&(t.globalAlpha=r.style.opacity),t.lineWidth=a,l&&0!==l.length&&c&&c.length===r.path.length){let u=null,h=null,d=null,f=null,y=!1;function g(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),y=!0}function p(){y&&(t.stroke(),y=!1)}for(let m=0;r.path.length>m;m++){const[v,x]=r.path[m],b=c[m],k=X(b,l,s);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(v,x);else{const w=[];for(const E of l){const A=E.value;(d>A||A>b)&&(A>d||b>A)||d===A||b===A||w.push({t:(A-d)/(b-d)})}w.sort((t,e)=>t.t-e.t);for(const S of w){const M=u+(v-u)*S.t,_=h+(x-h)*S.t,N=X(d+(b-d)*Math.min(S.t+1e-4,1),l,s);t.lineTo(M,_),p(),g(N,M,_)}t.lineTo(v,x)}u=v,h=x,d=b,f=k}else g(k,v,x),u=v,h=x,d=b,f=k}p()}else{t.beginPath(),t.strokeStyle=s;const[W,P]=r.path[0];t.moveTo(W,P);for(let z=1;r.path.length>z;z++)t.lineTo(r.path[z][0],r.path[z][1]);t.stroke()}if(r.style.fill&&r.style.fillOpacity&&r.style.fillOpacity>0){t.beginPath(),t.globalAlpha=r.style.fillOpacity,t.fillStyle=r.style.fill;const[C,T]=r.path[0];t.moveTo(C,T);for(let $=1;r.path.length>$;$++)t.lineTo(r.path[$][0],r.path[$][1]);const O=r.path[0][0];t.lineTo(r.path[r.path.length-1][0],i.height),t.lineTo(O,i.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[F],stackedarea:[F],scatter:[j],bubble:[j],heatmap:[(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);for(const e of o){const n=e.style;null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1}}],bar:[I],swarm:[j],waterfall:[(t,e,n,i)=>{var o,r;I(t,e);const s=e.filter(t=>"rect"===t.type);if(s.length>=2){t.save(),t.strokeStyle="#999",t.lineWidth=1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const i=s[e],a=s[e+1];if(!(null===(o=i.datum)||void 0===o?void 0:o.cumEnd)||!(null===(r=a.datum)||void 0===r?void 0:r.baseline))continue;const l=n.y(i.datum.cumEnd),c=i.x+i.w,u=a.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const i=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),r=e.isUp?e.upColor:e.downColor;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1))}}]},q={top:20,right:20,bottom:30,left:40},V={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"},Z={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 J({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return f.createElement("div",{className:"semiotic-tooltip",style:Z},f.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),f.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function K({width:i,height:o,totalWidth:r,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=t.useRef(null),d=t.useRef(null);return t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),r="x"===l?e.brushX():"y"===l?e.brushY():e.brush();return r.extent([[0,0],[i,o]]),r.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let e,n;if("x"===l){const[i,r]=t.selection;e=[c.x.invert(i),c.x.invert(r)],n=[c.y.invert(o),c.y.invert(0)]}else if("y"===l){const[o,r]=t.selection;e=[c.x.invert(0),c.x.invert(i)],n=[c.y.invert(r),c.y.invert(o)]}else{const[[i,o],[r,s]]=t.selection;e=[c.x.invert(i),c.x.invert(r)],n=[c.y.invert(s),c.y.invert(o)]}u({x:e,y:n})}),t.call(r),d.current=r,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),d.current=null}},[i,o,l,c,u]),f.createElement("svg",{ref:h,width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},f.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Q=t.forwardRef(function(e,n){var i;const{chartType:o,runtimeMode:r,data:s,xAccessor:a,yAccessor:l,colorAccessor:c,sizeAccessor:u,groupAccessor:h,lineDataAccessor:d,normalize:y,binSize:p,valueAccessor:m,arrowOfTime:v="right",windowMode:x="sliding",windowSize:b=200,timeAccessor:k,xExtent:w,yExtent:E,extentPadding:A=.1,sizeRange:S,size:T=[500,300],margin:O,className:$,background:R,lineStyle:D,pointStyle:Y,areaStyle:B,swarmStyle:X,barColors:F,colorScheme:j,boundsAccessor:I,boundsStyle:H,openAccessor:Z,highAccessor:Q,lowAccessor:U,closeAccessor:tt,candlestickStyle:et,showAxes:nt=!0,xLabel:it,yLabel:ot,xFormat:rt,yFormat:st,tickFormatTime:at,tickFormatValue:lt,hoverAnnotation:ct,tooltipContent:ut,customHoverBehavior:ht,enableHover:dt,annotations:ft,svgAnnotationRules:yt,showGrid:gt,legend:pt,backgroundGraphics:mt,foregroundGraphics:vt,title:xt,categoryAccessor:bt,brush:kt,onBrush:wt,decay:Et,pulse:At,transition:St,staleness:Mt,heatmapAggregation:_t,heatmapXBins:Nt,heatmapYBins:Wt,marginalGraphics:Pt}=e,zt=Object.assign(Object.assign({},q),O);if(Pt){const t=60;Pt.top&&t>zt.top&&(zt.top=t),Pt.bottom&&t>zt.bottom&&(zt.bottom=t),Pt.left&&t>zt.left&&(zt.left=t),Pt.right&&t>zt.right&&(zt.right=t)}const Ct=T[0]-zt.left-zt.right,Tt=T[1]-zt.top-zt.bottom,Ot=null!=ct?ct:dt,$t=t.useRef(null),Rt=t.useRef(0),Dt=t.useRef(!1),[Yt,Bt]=t.useState(0),[Lt,Xt]=t.useState(null),Ft=t.useRef(null),[jt,It]=t.useState(null),[Ht,Gt]=t.useState(!1),[qt,Vt]=t.useState([]),[Zt,Jt]=t.useState([]),Kt=t.useRef(()=>{}),Qt="streaming"===r||["bar","swarm","waterfall"].includes(o),Ut=t.useMemo(()=>({chartType:o,runtimeMode:Qt?"streaming":"bounded",windowSize:b,windowMode:x,arrowOfTime:Qt?v:"right",extentPadding:A,xAccessor:Qt?void 0:a,yAccessor:Qt?void 0:l,timeAccessor:Qt?k:void 0,valueAccessor:m,colorAccessor:c,sizeAccessor:u,groupAccessor:h,categoryAccessor:bt,lineDataAccessor:d,xExtent:w,yExtent:E,sizeRange:S,binSize:p,normalize:y,boundsAccessor:I,boundsStyle:H,openAccessor:Z,highAccessor:Q,lowAccessor:U,closeAccessor:tt,candlestickStyle:et,lineStyle:D,pointStyle:Y,areaStyle:B,swarmStyle:X,colorScheme:j,barColors:F,annotations:ft,decay:Et,pulse:At,transition:St,staleness:Mt,heatmapAggregation:_t,heatmapXBins:Nt,heatmapYBins:Wt}),[o,b,x,v,A,a,l,k,m,c,u,h,bt,d,w,E,S,p,y,I,H,Z,Q,U,tt,et,D,Y,B,X,j,F,ft,Et,At,St,Mt,_t,Nt,Wt,Qt]),te=t.useRef(null);te.current||(te.current=new M(Ut));const ee=t.useCallback(()=>{Rt.current||(Rt.current=requestAnimationFrame(()=>Kt.current()))},[]);t.useEffect(()=>{var t;null===(t=te.current)||void 0===t||t.updateConfig(Ut),Dt.current=!0,ee()},[Ut,ee]);const ne=t.useRef(null);ne.current||(ne.current=new g(t=>{const e=te.current;e&&e.ingest(t)&&(Dt.current=!0,ee())}));const ie=t.useCallback(t=>{var e;null===(e=ne.current)||void 0===e||e.push(t)},[]),oe=t.useCallback(t=>{var e;null===(e=ne.current)||void 0===e||e.pushMany(t)},[]),re=t.useCallback(()=>{var t,e;null===(t=ne.current)||void 0===t||t.clear(),null===(e=te.current)||void 0===e||e.clear(),Dt.current=!0,ee()},[ee]);t.useImperativeHandle(n,()=>({push:ie,pushMany:oe,clear:re,getData:()=>{var t,e;return null!==(e=null===(t=te.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=te.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=te.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[ie,oe,re]),t.useEffect(()=>{var t;s&&(null===(t=ne.current)||void 0===t||t.setBoundedData(s))},[s]);const se=t.useRef(()=>{}),ae=t.useRef(()=>{});se.current=t=>{if(!Ot)return;const e=$t.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-zt.left,o=t.clientY-n.top-zt.top;if(0>i||i>Ct||0>o||o>Tt)return void(Ft.current&&(Ft.current=null,It(null),ht&&ht(null),ee()));const r=te.current;if(!r||0===r.scene.length)return;const s=function(t,e,n,i=30){let o=null;for(const r of t){let t=null;switch(r.type){case"point":t=_(r,e,n);break;case"line":t=N(r,e,n);break;case"rect":t=W(r,e,n);break;case"heatcell":t=P(r,e,n);break;case"area":if(!1===r.interactive)break;t=C(r,e,n);break;case"candlestick":t=z(r,e,n)}t&&i>t.distance&&(o&&t.distance>=o.distance||(o=t))}return o}(r.scene,i,o);if(!s)return void(Ft.current&&(Ft.current=null,It(null),ht&&ht(null),ee()));const a={data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y};Ft.current=a,It(a),ht&&ht(a),ee()},ae.current=()=>{Ft.current&&(Ft.current=null,It(null),ht&&ht(null),ee())};const le=t.useCallback(t=>se.current(t),[]),ce=t.useCallback(()=>ae.current(),[]);Kt.current=()=>{var t,e;Rt.current=0;const n=$t.current;if(!n)return;const i=n.getContext("2d");if(!i)return;const r=te.current;if(!r)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=r.advanceTransition(s);c||r.computeScene({width:Ct,height:Tt});const u="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=T[0]*u,n.height=T[1]*u,n.style.width=T[0]+"px",n.style.height=T[1]+"px",i.scale(u,u),i.translate(zt.left,zt.top),i.clearRect(-zt.left,-zt.top,T[0],T[1]);const h=function(t){if(!t)return V;const e=getComputedStyle(t),n=e.getPropertyValue("--text-secondary").trim(),i=e.getPropertyValue("--text-primary").trim(),o=e.getPropertyValue("--surface-3").trim(),r=e.getPropertyValue("--surface-0").trim();return n||i?{axisStroke:o||V.axisStroke,tickText:n||V.tickText,crosshair:n?n+"66":V.crosshair,hoverFill:r?r+"4D":V.hoverFill,hoverStroke:n?n+"99":V.hoverStroke,pointRing:r||V.pointRing}:V}(n),d=null!==(t=null==Mt?void 0:Mt.threshold)&&void 0!==t?t:5e3,f=Mt&&r.lastIngestTime>0&&s-r.lastIngestTime>d;f&&(i.globalAlpha=null!==(e=null==Mt?void 0:Mt.dimOpacity)&&void 0!==e?e:.5),R&&(i.fillStyle=R,i.fillRect(0,0,Ct,Tt));const y=G[o];if(y&&r.scales)for(const t of y)t(i,r.scene,r.scales,{width:Ct,height:Tt});f&&(i.globalAlpha=1),Ot&&Ft.current&&r.scales&&function(t,e,n,i,o,r,s){if(!1===o.crosshair)return;t.save();const a="object"==typeof o.crosshair?o.crosshair:{};t.strokeStyle=a.stroke||s.crosshair,t.lineWidth=a.strokeWidth||1,t.setLineDash(a.strokeDasharray?a.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,i),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}(i,Ft.current,Ct,Tt,"object"==typeof Ot?Ot:{},0,h);const g=Dt.current;if(Dt.current=!1,g&&r.scales&&(Xt(r.scales),Pt)){const t=r.getData(),e="function"==typeof a?a:t=>t[a||"x"],n="function"==typeof l?l:t=>t[l||"y"];Vt(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Jt(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}g&&ft&&ft.length>0&&yt&&Bt(t=>t+1),(null==Mt?void 0:Mt.showBadge)&&Gt(!!f),(c||r.hasActivePulses)&&(Rt.current=requestAnimationFrame(()=>Kt.current()))},t.useEffect(()=>(ee(),()=>{Rt.current&&cancelAnimationFrame(Rt.current)}),[ee]),t.useEffect(()=>{Dt.current=!0,ee()},[o,Ct,Tt,nt,R,D,ee]),t.useEffect(()=>{if(!Mt)return;const t=setInterval(()=>{var t;const e=te.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=Mt.threshold)&&void 0!==t?t:5e3,o=n-e.lastIngestTime>i;o!==Ht&&(Gt(o),Dt.current=!0,ee())},1e3);return()=>clearInterval(t)},[Mt,Ht,ee]);const ue=Ot&&jt?ut?ut(jt):f.createElement(J,{hover:jt}):null,he=ue?f.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:zt.left+jt.x,top:zt.top+jt.y,transform:`translate(${jt.x>.7*Ct?"calc(-100% - 12px)":"12px"}, ${.3*Tt>jt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ue):null;return f.createElement("div",{className:"stream-xy-frame"+($?" "+$:""),style:{position:"relative",width:T[0],height:T[1]},onMouseMove:Ot?le:void 0,onMouseLeave:Ot?ce:void 0},mt&&f.createElement("svg",{style:{position:"absolute",left:0,top:0,width:T[0],height:T[1],pointerEvents:"none"}},mt),f.createElement("canvas",{ref:$t,style:{position:"absolute",left:0,top:0}}),f.createElement(L,{width:Ct,height:Tt,totalWidth:T[0],totalHeight:T[1],margin:zt,scales:Lt,showAxes:nt,xLabel:it,yLabel:ot,xFormat:rt||at,yFormat:st||lt,showGrid:gt,title:xt,legend:pt,foregroundGraphics:vt,marginalGraphics:Pt,xValues:qt,yValues:Zt,annotations:ft,svgAnnotationRules:yt,annotationFrame:Yt}),(kt||wt)&&f.createElement(K,{width:Ct,height:Tt,totalWidth:T[0],totalHeight:T[1],margin:zt,dimension:null!==(i=null==kt?void 0:kt.dimension)&&void 0!==i?i:"xy",scales:Lt,onBrush:null!=wt?wt:()=>{}}),(null==Mt?void 0:Mt.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Mt.badgePosition?{top:4,left:4}:"bottom-left"===Mt.badgePosition?{bottom:4,left:4}:"bottom-right"===Mt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ht?"#dc3545":"#28a745",color:"white"})},Ht?"STALE":"LIVE"),he)});Q.displayName="StreamXYFrame";const U={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},tt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class et{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n){for(let i=0;this.capacity>i;i++){const o=this.particles[i];if(!o.active)continue;const r=n[o.edgeIndex];if(!r||!r.bezier){o.active=!1;continue}if(o.t+=t*e,o.t>=1){o.active=!1;continue}const s=nt(r.bezier,o.t,o.offset);o.x=s.x,o.y=s.y}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function nt(t,e,n){if(t.circular&&t.segments)return function(t,e,n,i){const o=t.length,r=e*o,s=Math.min(Math.floor(r),o-1),a=r-s,[l,c,u,h]=t[s],d=it(l,c,u,h,a),f=h.x-l.x,y=h.y-l.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*i*2,d.y+=t*n*i*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[i,o,r,s]=t.points,a=it(i,o,r,s,e),l=s.x-i.x,c=s.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const e=l/u;a.x+=-c/u*n*t.halfWidth*2,a.y+=e*n*t.halfWidth*2}return a}function it(t,e,n,i,o){const r=1-o,s=r*r,a=s*r,l=o*o,c=l*o;return{x:a*t.x+3*s*o*e.x+3*r*l*n.x+c*i.x,y:a*t.y+3*s*o*e.y+3*r*l*n.y+c*i.y}}const ot=(t=1)=>(e,n)=>{const i=e[e.length-1];return i&&Math.round(i.x/t)===Math.round(n.x/t)&&Math.round(i.y/t)===Math.round(n.y/t)||e.push(n),e},rt=t=>{let e,n,i,o,s,a,l,c,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,s=t.source.y1,a=t.target.y0,l=r.interpolateNumber(s,a),c=l(.5),u=l(.5),`M${e},${s}C${e},${c} ${n},${u} ${n},${a}L${i},${a}C${i},${u} ${o},${c} ${o},${s}Z`):(e=t.source.x1,n=t.target.x0,l=r.interpolateNumber(e,n),i=l(.5),o=l(.5),s=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${s}C${i},${s} ${o},${a} ${n},${a}L${n},${c}C${o},${c} ${i},${u} ${e},${u}Z`)};function st(t){const e=function(){const t=l.line();let e=function(t){return t.x},n=function(t){return t.y},i=function(t){return t.r},o=l.curveLinearClosed;function r(r){if(r.multiple){const s=i,l=r.multiple.reduce((t,e)=>t+e.weight,0);i=()=>l;let c=a(r.points).filter(t=>"forward"===t.direction).reduce(ot(),[]);const u=[];return r.multiple.forEach((t,e)=>{i=()=>t.weight;const n=a(c);u.push(n);const o=r.multiple[e+1];if(o){const t=n.reverse().filter(t=>"back"===t.direction).reduce(ot(),[]);i=()=>o.weight;const e=a(t);c=e.reverse().filter(t=>"back"===t.direction).reduce(ot(),[])}}),i=s,u.map(i=>t.x(e).y(n).curve(o)(i))}const s=a(r).reduce(ot(),[]);return t.x(e).y(n).curve(o)(s)}return r.x=function(t){return arguments.length?(e=t,r):e},r.y=function(t){return arguments.length?(n=t,r):n},r.r=function(t){return arguments.length?(i=t,r):i},r.interpolate=function(t){return arguments.length?(o=t,r):o},r;function s(t){const o=n(t.target)-n(t.source),r=e(t.target)-e(t.source),s=Math.atan2(r,o)+Math.PI/2,a=s+.5*Math.PI,l=s+.5*Math.PI;return{x1:e(t.source)+i(t.source)*Math.cos(a),y1:n(t.source)-i(t.source)*Math.sin(a),x2:e(t.target)+i(t.target)*Math.cos(l),y2:n(t.target)-i(t.target)*Math.sin(l)}}function a(t){const e=[];let n=0,i={x1:0,y1:0,x2:0,y2:0};for(;t.length>n;){if(n!==t.length-1&&(i=s({source:t[n],target:t[n+1]}),e.push({x:i.x1,y:i.y1,direction:"forward"},{x:i.x2,y:i.y2,direction:"forward"}),e.length>3)){const t=e.length-1,n={a:e[t-3],b:e[t-2]},i={a:e[t-1],b:e[t]},o=c(n.a.x,n.a.y,n.b.x,n.b.y,i.a.x,i.a.y,i.b.x,i.b.y);!0===o.found&&(n.b.x=o.x,n.b.y=o.y,i.a.x=o.x,i.a.y=o.y)}n++}for(n--;n>=0;){if(0!==n&&(i=s({source:t[n],target:t[n-1]}),e.push({x:i.x1,y:i.y1,direction:"back"},{x:i.x2,y:i.y2,direction:"back"}),e.length>3)){const t=e.length-1,n={a:e[t-3],b:e[t-2]},i={a:e[t-1],b:e[t]},o=c(n.a.x,n.a.y,n.b.x,n.b.y,i.a.x,i.a.y,i.b.x,i.b.y);!0===o.found&&(n.b.x=o.x,n.b.y=o.y,i.a.x=o.x,i.a.y=o.y)}n--}return e}function c(t,e,n,i,o,r,s,a){let l,c;const u={x:null,y:null,found:!1},h=(a-r)*(n-t)-(s-o)*(i-e);if(0===h)return u;l=e-r,c=t-o;const d=(n-t)*l-(i-e)*c;return l=((s-o)*l-(a-r)*c)/h,c=d/h,u.x=t+l*(n-t),u.y=e+l*(i-e),l>0&&1>l&&c>0&&1>c&&(u.found=!0),u}}();return e.x(t=>t.x),e.y(t=>t.y),e.r(()=>t.sankeyWidth/2),e("down"===t.direction?[{x:t.circularPathData.sourceY,y:t.circularPathData.sourceX},{x:t.circularPathData.sourceY,y:t.circularPathData.leftFullExtent},{x:t.circularPathData.verticalFullExtent,y:t.circularPathData.leftFullExtent},{x:t.circularPathData.verticalFullExtent,y:t.circularPathData.rightFullExtent},{x:t.circularPathData.targetY,y:t.circularPathData.rightFullExtent},{x:t.circularPathData.targetY,y:t.circularPathData.targetX}]:[{x:t.circularPathData.sourceX,y:t.circularPathData.sourceY},{x:t.circularPathData.leftFullExtent,y:t.circularPathData.sourceY},{x:t.circularPathData.leftFullExtent,y:t.circularPathData.verticalFullExtent},{x:t.circularPathData.rightFullExtent,y:t.circularPathData.verticalFullExtent},{x:t.circularPathData.rightFullExtent,y:t.circularPathData.targetY},{x:t.circularPathData.targetX,y:t.circularPathData.targetY}])}const at={left:s.sankeyLeft,right:s.sankeyRight,center:s.sankeyCenter,justify:s.sankeyJustify},lt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,a,l;if(0===t.length)return;const c="vertical"===n.orientation?"down":"right",u=n.nodeAlign||"justify",h=null!==(o=n.nodeWidth)&&void 0!==o?o:15,d=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,f=null!==(a=n.iterations)&&void 0!==a?a:100,y=t.map(t=>Object.assign({},t)),g=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));let p;p="down"===c?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const m=s.sankeyCircular().extent(p).links(g).nodes(y).nodeAlign(at[u]||s.sankeyJustify).nodeId(t=>t.id).nodeWidth(h).iterations(f);m.nodePaddingRatio&&m.nodePaddingRatio(d),m();for(const e of y){const n=t.find(t=>t.id===e.id);n&&(n.x0=e.x0,n.x1=e.x1,n.y0=e.y0,n.y1=e.y1,n.value=e.value,n.depth=e.depth,n.sourceLinks=e.sourceLinks,n.targetLinks=e.targetLinks,n.width=e.x1-e.x0,n.height=e.y1-e.y0,n.x=e.x0+(e.x1-e.x0)/2,n.y=e.y0+(e.y1-e.y0)/2)}for(const n of g){const i=n.source,o=n.target,r="object"==typeof i&&null!==i?i.id:i+"",s="object"==typeof o&&null!==o?o.id:o+"",a=e.find(t=>("string"==typeof t.source?t.source:t.source.id)===r&&("string"==typeof t.target?t.target:t.target.id)===s);if(a){a.y0=n.y0,a.y1=n.y1,a.sankeyWidth=null!==(l=n.width)&&void 0!==l?l:0,a.circular=!!n.circular,a.circularPathData=n.circularPathData,a.direction=c;const e=t.find(t=>t.id===r),i=t.find(t=>t.id===s);e&&(a.source=e),i&&(a.target=i)}}},buildScene(t,e,n,i){var o,r;const s="vertical"===n.orientation?"down":"right",l=n.nodeStyle,c=n.edgeStyle,u=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,h=n.edgeColorBy||"source",d=Array.isArray(n.colorScheme)?n.colorScheme:a.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,d[e%d.length])});const y=[],g=[],p=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=l?l(e):{},o={fill:i.fill||f.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};y.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const m=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of m){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i;i=t.circular&&t.circularPathData?st(t):rt(t);let o="#999";c?o=c(t).fill||o:"target"===h&&n?o=f.get(n.id)||o:e&&(o=f.get(e.id)||o);const s=c?c(t):{},a={fill:o,fillOpacity:null!==(r=s.fillOpacity)&&void 0!==r?r:u,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};g.push({type:"bezier",pathD:i,bezierCache:t.bezier,style:a,datum:t})}if(!1!==n.showLabels){const e=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let a,l,c;"down"===s?(a=n.x0+t/2,l=n.y1+14,c="middle"):(i[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+o/2),p.push({x:a,y:l,text:r+"",anchor:c,baseline:"middle",fontSize:11})}}var v;return{sceneNodes:y,sceneEdges:g,labels:p}}},ct={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,l=i[0]/2,u=i[1]/2;for(let e=0;t.length>e;e++){const n=t[e];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(e+.5),i=2.399963229728653*e;n.x=l+t*Math.cos(i),n.y=u+t*Math.sin(i)}}const h=ht(n.nodeSize,n.nodeSizeRange,t),d=c.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),f=i[1]/i[0],y=c.forceSimulation().force("charge",c.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",c.forceX(i[0]/2).strength(.1*f)).force("y",c.forceY(i[1]/2).strength(.1));if(y.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));y.force("link",d),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;s>t;++t)y.tick();for(const n of e){if("string"==typeof n.source){const e=t.find(t=>t.id===n.source);e&&(n.source=e)}if("string"==typeof n.target){const e=t.find(t=>t.id===n.target);e&&(n.target=e)}}},buildScene(t,e,n,i){var o,r,s;const l=n.nodeStyle,c=n.edgeStyle,u=ht(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:a.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=l?l(e):{},i={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}for(const n of e){const e="object"==typeof n.source?n.source:ut(t,n.source),i="object"==typeof n.target?n.target:ut(t,n.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=c?c(n):{},a={stroke:o.stroke||"#999",strokeWidth:null!==(r=o.strokeWidth)&&void 0!==r?r:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:a,datum:n})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=u(n);g.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ut(t,e){return t.find(t=>t.id===e)}function ht(t,e,n){var r,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],l=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>a[0];const c=null!==(r=o.min(l))&&void 0!==r?r:0,u=null!==(s=o.max(l))&&void 0!==s?s:1;if(c===u)return()=>(a[0]+a[1])/2;const h=i.scaleLinear().domain([c,u]).range(a).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?a[0]:h(i)}}const dt=a.schemeCategory10,ft={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,c=a-r,h=i[0]/2,d=i[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),i=g.get(e);if(void 0===n||void 0===i)continue;const o=f(t);m[n][i]=o}const v=u.chord().padAngle(o);s&&v.sortGroups(s);const x=v(m),b=x.groups,k=l.arc().innerRadius(c).outerRadius(a);for(const e of b){const n=t[e.index],i=k.centroid(e);n.x=i[0]+h,n.y=i[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}for(const n of e){const e="string"==typeof n.source?n.source:n.source.id,i="string"==typeof n.target?n.target:n.target.id,o=t.find(t=>t.id===e),r=t.find(t=>t.id===i);o&&(n.source=o),r&&(n.target=r)}for(const n of x){const i=t[n.source.index].id,o=t[n.target.index].id,r=e.find(t=>{const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id;return e===i&&n===o||e===o&&n===i});r&&(r.chordData=n)}},buildScene(t,e,n,i){var o,r;const{groupWidth:s=20,edgeOpacity:a=.5}=n,l=Math.min(i[0],i[1])/2,c=l-s,h=i[0]/2,d=i[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:dt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=u.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let r;r=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const s=f?f(n):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:d,innerR:c,outerR:l,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=v({source:Object.assign(Object.assign({},e.source),{startAngle:e.source.startAngle-Math.PI/2,endAngle:e.source.endAngle-Math.PI/2}),target:Object.assign(Object.assign({},e.target),{startAngle:e.target.startAngle-Math.PI/2,endAngle:e.target.endAngle-Math.PI/2})});if(!n)continue;const i=yt(n,h,d);let o="#999";if(y)o=y(t).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?o=m.get(n.id)||o:e&&(o=m.get(e.id)||o)}const s=y?y(t):{},l={fill:o,fillOpacity:null!==(r=s.fillOpacity)&&void 0!==r?r:a,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"ribbon",pathD:i,style:l,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,i=l+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;k.push({x:h+Math.cos(s)*i,y:d+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function yt(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const gt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=(l=n.childrenAccessor)?"function"==typeof l?l:t=>t[l]:void 0;var l;const c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=h.hierarchy(r,a);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,f]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=h.tree();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,f);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=h.cluster();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,f);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=h.treemap().size([n,i]).tile(h.treemapBinary).padding(s);a>0&&l.paddingTop(a),l(t)}(u,n,d,f);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;h.pack().size([n,i]).padding(r)(t)}(u,n,d,f);break;case"partition":!function(t,e,n,i){var o;h.partition().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,f)}const y=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],r={id:bt(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?pt(r,i,n):"treemap"===s||"partition"===s?mt(r,i):"circlepack"===s&&vt(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===s||"cluster"===s)for(const t of y)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,a,l,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,m=i[1]/2,v="number"==typeof(x=n.nodeSize)?x:5;var x;for(const e of t){let t=e.x,n=e.y;g&&(t+=p,n+=m);const i=o(e),r={fill:i.fill||"#4d430c",stroke:i.stroke||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:i.opacity};h.push({type:"circle",cx:t,cy:n,r:v,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i=e.x,o=e.y,s=n.x,a=n.y;g&&(i+=p,o+=m,s+=p,a+=m);const u=xt(i,o,s,a,y),h=r(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(l=h.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:b};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=kt(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,a=n.y;if(g&&(s+=p,a+=m),g){const t=s-p,e=a-m,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=a+e/n*10,r=0>t?"end":"start"):(i=s,o=a-12,r="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(i=s-v-6,r="end"):(i=s+v+6,r="start"),o=a):(i=s,o=a+v+14,r="middle");f.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r;const s=[],a=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const a=i(n);let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};s.push({type:"rect",x:n.x0,y:n.y0,w:t,h:r,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=kt(e.nodeLabel);for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;if((null===(r=i.data)||void 0===r?void 0:r.children)&&i.data.children.length>0&&"partition"!==e.chartType)continue;const s=n?n(i):i.id;s&&(30>t||16>o||a.push({x:i.x0+t/2,y:i.y0+o/2,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,o)/6))}))}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,a,l;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(n);let l=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(l=h[n.depth%h.length]);const u={fill:l,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=kt(e.nodeLabel);for(const e of t){const t=null!==(a=e.__radius)&&void 0!==a?a:5,i=n?n(e):e.id;if(!i)continue;if(15>t)continue;const o=!((null===(l=e.data)||void 0===l?void 0:l.children)&&e.data.children.length>0);u.push({x:e.x,y:o?e.y:e.y-t+14,text:i+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pt(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function mt(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function vt(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function xt(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}function bt(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function kt(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}const wt={sankey:lt,force:ct,chord:ft,tree:gt,cluster:gt,treemap:gt,circlepack:gt,partition:gt};function Et(t){return wt[t]}class At{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},U),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new et(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},U),t.tensionConfig),"sankey"===t.chartType&&t.showParticles?this.particlePool||(this.particlePool=new et(2e3)):this.particlePool=null}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof i?i:t=>t[i],l="function"==typeof o?o:t=>t[o],c="function"==typeof r?r:t=>t[r],u="function"==typeof s?s:t=>{var e;return null!==(e=t[s])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear();for(const e of t){const t=a(e)+"";this.nodes.set(t,Object.assign(Object.assign({},St(t)),{data:e}))}for(const t of e){const e=l(t)+"",n=c(t)+"",i=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},St(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},St(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0,data:t})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,o=0===this.nodes.size;let r=!1;this.nodes.has(e)||(this.nodes.set(e,St(e)),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,St(n)),this.tension+=this.tensionConfig.newNode,r=!0);const s=this.edgeKey(e,n),a=this.edges.get(s);return a?(a.value+=i,this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.tension+=this.tensionConfig.newEdge,r=!0),o||r||this.tension>=this.tensionConfig.threshold}runLayout(t){const e=Et(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());if(0!==n.length||e.hierarchical){if(this.prepareForRelayout(),e.computeLayout(n,i,this.config,t),e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const t of n)this.nodes.set(t.id,t);for(const t of i)this.edges.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t)}this.finalizeLayout(),this.saveTargetPositions(),n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration}),this.layoutVersion++}}buildScene(t){const e=Et(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:r,labels:s}=e.buildScene(n,i,this.config,t);this.sceneNodes=o,this.sceneEdges=r,this.labels=s}advanceTransition(t){if(!this.transition)return!1;const e=Math.min((t-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-e,3);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0+(t._targetX0-t._prevX0)*n,t.x1=t._prevX1+(t._targetX1-t._prevX1)*n,t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n);for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n,t.sankeyWidth=t._prevSankeyWidth+(t._targetSankeyWidth-t._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const i=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.y1,s=n.y0,a=r.interpolateNumber(o,s);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:a(.5)},{x:t.y1,y:a(.5)},{x:t.y1,y:s}],halfWidth:i}}const o=e.x1,s=n.x0,a=r.interpolateNumber(o,s);return{circular:!1,points:[{x:o,y:t.y0},{x:a(.5),y:t.y0},{x:a(.5),y:t.y1},{x:s,y:t.y1}],halfWidth:i}}buildCircularBezier(t){const e=(t.sankeyWidth||1)/2,n=t.circularPathData;let i;i="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.targetY,y:n.rightFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.leftFullExtent,y:n.sourceY},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.rightFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],r=n.x-e.x,s=n.y-e.y;o.push([e,{x:e.x+r/3,y:e.y+s/3},{x:e.x+2*r/3,y:e.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.particlePool&&this.particlePool.clear()}}function St(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Mt(t,e,n){switch(t.type){case"circle":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);return r>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:r}}(t,e,n);case"rect":return function(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{type:"node",datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,o=n-t.cy,r=Math.sqrt(i*i+o*o);if(t.innerR-2>r||r>t.outerR+2)return null;let s=Math.atan2(o,i);0>s&&(s+=2*Math.PI);let a,l=t.startAngle,c=t.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 e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}function _t(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,o;if(!t.pathD)return null;try{const r=new Path2D(t.pathD),s=document.createElement("canvas").getContext("2d");if(!s)return null;if(s.isPointInPath(r,e,n)){const r="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,s="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:r&&s?(r.x1+s.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const i=t.x2-t.x1,o=t.y2-t.y1,r=i*i+o*o;if(0===r)return null;let s=((e-t.x1)*i+(n-t.y1)*o)/r;s=Math.max(0,Math.min(1,s));const a=t.x1+s*i,l=t.y1+s*o,c=Math.sqrt(Math.pow(e-a,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:t.datum,x:a,y:l,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const i=new Path2D(t.pathD),o=document.createElement("canvas").getContext("2d");if(!o)return null;if(o.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0}}catch(t){}return null}(t,e,n);default:return null}}function Nt(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,labels:s,title:a,legend:l,foregroundGraphics:c,annotations:u,svgAnnotationRules:h}=t;return f.createElement("svg",{width:i,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${r.left},${r.top})`},s.map((t,e)=>f.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),u&&h&&u.map((t,i)=>{const o=h(t,i,{width:e,height:n});return o?f.createElement(f.Fragment,{key:"annotation-"+i},o):null}),c),a&&"string"==typeof a?f.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},a):a?f.createElement("foreignObject",{x:0,y:0,width:i,height:r.top},a):null,l&&"object"==typeof l&&"legendGroups"in l?f.createElement("g",{transform:`translate(${i-r.right+10},${r.top})`},l.legendGroups.map((t,e)=>{var n;return f.createElement("g",{key:"legend-group-"+e},null===(n=t.items)||void 0===n?void 0:n.map((t,e)=>f.createElement("g",{key:"legend-item-"+e,transform:`translate(0,${20*e})`},f.createElement("rect",{x:0,y:0,width:12,height:12,fill:t.color,rx:2}),f.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},t.label))))})):l?f.createElement("g",{transform:`translate(${i-r.right+10},${r.top})`},l):null)}function Wt(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.5*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),t.restore()}function Pt(t,e){var n;t.save(),t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),t.restore()}function zt(t,e){var n,i,o,r;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(s)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(r=e.style.opacity)&&void 0!==r?r:1),t.stroke(s)),t.restore()}function Ct(t,e){var n,i;if(!e.pathD)return;t.save();const o=new Path2D(e.pathD);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(o)),t.restore()}Nt.displayName="NetworkSVGOverlay";const Tt=a.schemeCategory10,Ot={top:20,right:80,bottom:20,left:80},$t={top:40,right:40,bottom:40,left:40},Rt=new Set(["chord","force","circlepack"]),Dt=[800,600],Yt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Bt({data:t}){var e,n,i,o,r,s;if("edge"===t.type){const e=t.data;return f.createElement("div",{className:"semiotic-tooltip",style:Yt},f.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const a=t.data,l=null==a?void 0:a.__hierarchyNode;if(l){const t=[];let r=l;for(;r;){const s=null!==(o=null!==(n=null===(e=r.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(i=r.data)||void 0===i?void 0:i.id)&&void 0!==o?o:a.id;null!=s&&t.unshift(s+""),r=r.parent}t.length>1&&t.shift();const s=t.length-1;return f.createElement("div",{className:"semiotic-tooltip",style:Yt},f.createElement("div",null,t.map((t,e)=>f.createElement("span",{key:e},e>0&&f.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===s?f.createElement("strong",null,t):f.createElement("span",{style:{opacity:.7}},t)))),null!=a.value&&a.value>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof a.value?a.value.toLocaleString():a.value+""))}const c=((null===(r=a.sourceLinks)||void 0===r?void 0:r.length)||0)+((null===(s=a.targetLinks)||void 0===s?void 0:s.length)||0),u=(a.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(a.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return f.createElement("div",{className:"semiotic-tooltip",style:Yt},f.createElement("div",{style:{fontWeight:600}},a.id),null!=a.value&&a.value>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof a.value?a.value.toLocaleString():a.value+""),c>0&&f.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Lt=t.forwardRef(function(e,n){const{chartType:i,nodes:o,edges:r,data:s,initialEdges:a,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:h="value",childrenAccessor:d,hierarchySum:y,orientation:g="horizontal",nodeAlign:p="justify",nodePaddingRatio:m=.05,nodeWidth:v=15,iterations:x=300,forceStrength:b=.1,padAngle:k=.01,groupWidth:w=20,sortGroups:E,edgeSort:A,treeOrientation:S="vertical",edgeType:M="curve",padding:_,paddingTop:N,tensionConfig:W,showParticles:P=!1,particleStyle:z,nodeStyle:C,edgeStyle:T,colorBy:O,colorScheme:$="category10",edgeColorBy:R="source",edgeOpacity:D=.5,colorByDepth:Y=!1,nodeSize:B=8,nodeSizeRange:L=[5,20],nodeLabel:X,showLabels:F=!0,size:j=Dt,margin:I,className:H,background:G,enableHover:q=!0,tooltipContent:V,onTopologyChange:Z,annotations:J,svgAnnotationRules:K,legend:Q,title:et,foregroundGraphics:nt,backgroundGraphics:it}=e,ot=Rt.has(i)?$t:Ot,rt=Object.assign(Object.assign({},ot),I),st=j[0]-rt.left-rt.right,at=j[1]-rt.top-rt.bottom,lt=t.useMemo(()=>Object.assign(Object.assign({},U),W),[W]),ct=t.useMemo(()=>Object.assign(Object.assign({},tt),z),[z]),ut=t.useMemo(()=>({chartType:i,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,valueAccessor:h,childrenAccessor:d,hierarchySum:y,orientation:g,nodeAlign:p,nodePaddingRatio:m,nodeWidth:v,iterations:x,forceStrength:b,padAngle:k,groupWidth:w,sortGroups:E,edgeSort:A,treeOrientation:S,edgeType:M,padding:_,paddingTop:N,tensionConfig:lt,showParticles:P,particleStyle:ct,nodeStyle:C,edgeStyle:T,nodeLabel:X,showLabels:F,colorBy:O,colorScheme:$,edgeColorBy:R,edgeOpacity:D,colorByDepth:Y,nodeSize:B,nodeSizeRange:L}),[i,l,c,u,h,d,y,g,p,m,v,x,b,k,w,E,A,S,M,_,N,lt,P,ct,C,T,X,F,O,$,R,D,Y,B,L]),ht=t.useRef(null),dt=t.useRef(0),ft=t.useRef(0),yt=t.useRef(!0),gt=t.useRef(()=>{}),pt=t.useRef(null);pt.current||(pt.current=new At(ut));const[mt,vt]=t.useState(null),[xt,bt]=t.useState(0),[kt,wt]=t.useState(0),Et=t.useRef(null),St=t.useRef(new Map),Yt=t.useRef(0),Lt=t.useCallback(t=>{if("function"==typeof O)return O(t);if("string"==typeof O&&t.data){const e=t.data[O];if(void 0!==e){if(!St.current.has(e+"")){const t=Array.isArray($)?$:Tt;St.current.set(e+"",t[Yt.current++%t.length])}return St.current.get(e+"")}}if(!St.current.has(t.id)){const e=Array.isArray($)?$:Tt;St.current.set(t.id,e[Yt.current++%e.length])}return St.current.get(t.id)},[O,$]);t.useCallback(t=>{if("function"==typeof R)return R(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===R&&n?Lt(n):e?Lt(e):"#999"},[R,Lt]);const Xt=t.useCallback(t=>{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===(ct.colorBy||"source")&&n?Lt(n):e?Lt(e):"#999"},[ct.colorBy,Lt]),Ft="sankey"===i&&P,jt=t.useCallback(()=>{dt.current&&!Ft||dt.current||(dt.current=requestAnimationFrame(()=>gt.current()))},[Ft]);t.useEffect(()=>{var t;null===(t=pt.current)||void 0===t||t.updateConfig(ut),yt.current=!0,jt()},[ut,jt]);const It=t.useCallback(()=>{const t=pt.current;if(t&&(t.runLayout([st,at]),t.buildScene([st,at]),yt.current=!0,bt(t.layoutVersion),Z)){const{nodes:e,edges:n}=t.getLayoutData();Z(e,n)}},[st,at,Z]),Ht=t.useCallback(t=>{const e=pt.current;e&&(e.ingestEdge(t)&&It(),jt())},[It,jt]),Gt=t.useCallback(t=>{const e=pt.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&It(),jt()},[It,jt]),qt=t.useCallback(()=>{var t;null===(t=pt.current)||void 0===t||t.clear(),St.current.clear(),Yt.current=0,bt(0),vt(null),Et.current=null,yt.current=!0,jt()},[jt]),Vt=t.useCallback(()=>{const t=pt.current;t&&(t.tension+=999,It(),jt())},[It,jt]);t.useImperativeHandle(n,()=>({push:Ht,pushMany:Gt,clear:qt,getTopology:()=>{var t,e;return null!==(e=null===(t=pt.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},relayout:Vt,getTension:()=>{var t,e;return null!==(e=null===(t=pt.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ht,Gt,qt,Vt]);const Zt=["tree","cluster","treemap","circlepack","partition"].includes(i),Jt=Zt?s||(Array.isArray(r)?void 0:r):void 0;t.useEffect(()=>{const t=pt.current;if(t)if(Zt&&Jt)t.ingestHierarchy(Jt,[st,at]),t.buildScene([st,at]),yt.current=!0,jt();else{const e=o||[],n=Array.isArray(r)?r:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[st,at]),t.buildScene([st,at]),yt.current=!0,jt()}},[o,r,s,Jt,Zt,st,at,ut,jt]),t.useEffect(()=>{a&&a.length>0&&Gt(a)},[]);const Kt=t.useRef(()=>{}),Qt=t.useRef(()=>{});Kt.current=t=>{if(!q)return;const e=ht.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-rt.left,o=t.clientY-n.top-rt.top;if(0>i||i>st||0>o||o>at)return void(Et.current&&(Et.current=null,vt(null),jt()));const r=pt.current;if(!r)return;const s=function(t,e,n,i,o=30){let r=null,s=o,a=1/0;for(const e of t){const t=Mt(e,n,i);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(r=t,a=n)}else s>t.distance&&(r=t,s=t.distance)}if(r)return r;for(const t of e){const e=_t(t,n,i);e&&s>e.distance&&(r=e,s=e.distance)}return r}(r.sceneNodes,r.sceneEdges,i,o);if(!s)return void(Et.current&&(Et.current=null,vt(null),jt()));const a={type:s.type,data:s.datum,x:s.x,y:s.y};Et.current=a,vt(a),jt()},Qt.current=()=>{Et.current&&(Et.current=null,vt(null),jt())};const Ut=t.useCallback(t=>Kt.current(t),[]),te=t.useCallback(()=>Qt.current(),[]);gt.current=()=>{var t;dt.current=0;const e=ht.current;if(!e)return;const n=e.getContext("2d");if(!n)return;const i=pt.current;if(!i)return;const o=performance.now(),r=ft.current?Math.min((o-ft.current)/1e3,.1):.016;ft.current=o;const s=i.advanceTransition(o);(s||yt.current)&&i.buildScene([st,at]);const a="undefined"!=typeof window&&window.devicePixelRatio||1;if(e.width=j[0]*a,e.height=j[1]*a,e.style.width=j[0]+"px",e.style.height=j[1]+"px",n.scale(a,a),n.translate(rt.left,rt.top),n.clearRect(-rt.left,-rt.top,j[0],j[1]),G&&(n.fillStyle=G,n.fillRect(0,0,st,at)),function(t,e){for(const n of e)switch(n.type){case"bezier":Wt(t,n);break;case"line":Pt(t,n);break;case"ribbon":zt(t,n);break;case"curved":Ct(t,n)}}(n,i.sceneEdges),function(t,e){var n,i,o;for(const r of e){if("rect"!==r.type)continue;const e=r;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),t.restore())}}(n,i.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("circle"!==r.type)continue;const e=r;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore())}}(n,i.sceneNodes),function(t,e){var n,i,o;for(const r of e){if("arc"!==r.type)continue;const e=r;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(n,i.sceneNodes),P&&i.particlePool){const e=Array.from(i.edges.values());if(e.length>0){!function(t,e,n,i){var o,r;const s=null!==(o=i.spawnRate)&&void 0!==o?o:tt.spawnRate,a=null!==(r=i.maxPerEdge)&&void 0!==r?r:tt.maxPerEdge;for(let i=0;e.length>i;i++){const o=e[i];if(!o.bezier)continue;if(t.countForEdge(i)>=a)continue;const r=o.value*s*n,l=Math.floor(r),c=r-l;let u=l;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<a;e++)t.spawn(i)}}(i.particlePool,e,r,ct);const o=.5*(null!==(t=ct.speedMultiplier)&&void 0!==t?t:1);i.particlePool.step(r,o,e),function(t,e,n,i,o){var r,s;const a=null!==(r=i.radius)&&void 0!==r?r:tt.radius,l=null!==(s=i.opacity)&&void 0!==s?s:tt.opacity;t.globalAlpha=l;for(let r=0;e.particles.length>r;r++){const s=e.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(l){if("function"==typeof i.color){const e="object"==typeof l.source?l.source:null;t.fillStyle=e?i.color(l,e):"#666"}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:o(l);t.beginPath(),t.arc(s.x,s.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(n,i.particlePool,e,ct,Xt)}}const l=yt.current;yt.current=!1,(l||s)&&wt(t=>t+1),(Ft||s)&&(dt.current=requestAnimationFrame(()=>gt.current()))},t.useEffect(()=>(jt(),()=>{dt.current&&cancelAnimationFrame(dt.current)}),[jt]),t.useEffect(()=>{yt.current=!0,jt()},[i,st,at,G,jt]);const ee=q&&mt?f.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:rt.left+mt.x,top:rt.top+mt.y,transform:`translate(${mt.x>.6*st?"calc(-100% - 12px)":"12px"}, ${.3*at>mt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},V?V(mt):f.createElement(Bt,{data:mt})):null,ne=pt.current;return f.createElement("div",{className:"stream-network-frame"+(H?" "+H:""),style:{position:"relative",width:j[0],height:j[1]},onMouseMove:q?Ut:void 0,onMouseLeave:q?te:void 0},it&&f.createElement("svg",{style:{position:"absolute",top:0,left:0,width:j[0],height:j[1],pointerEvents:"none"}},f.createElement("g",{transform:`translate(${rt.left},${rt.top})`},it)),f.createElement("canvas",{ref:ht,style:{position:"absolute",top:0,left:0}}),f.createElement(Nt,{width:st,height:at,totalWidth:j[0],totalHeight:j[1],margin:rt,labels:(null==ne?void 0:ne.labels)||[],title:et,legend:Q,foregroundGraphics:nt,annotations:J,svgAnnotationRules:K,annotationFrame:kt}),ee)});function Xt(t,e){return t?!0===t?{name:"hover",fields:[]}:"string"==typeof t?{name:t,fields:[]}:{name:t.name||"hover",fields:t.fields}:null}function Ft(t){let e=new EventTarget,n=t(function(t){n=Object.assign(n,t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}function jt(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function It(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Lt.displayName="StreamNetworkFrame";const[Ht,Gt]=function(e){let n=t.createContext(null),i=Ft(e);return[function({children:i}){let o=t.useMemo(()=>Ft(e),[]);return f.createElement(n.Provider,{value:o,children:i})},e=>{var o;let r=null!==(o=t.useContext(n))&&void 0!==o?o:i;return function(e,n){const[i,o]=t.useState(n);return t.useLayoutEffect(()=>e(()=>o(n)),[e]),i}(r.subscribe,()=>e(r.getState()))}]}(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=It(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=It(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}}));function qt(e){const n=e.name||"hover",{fields:i}=e,{predicate:o,isActive:r,selectPoints:s,clear:a}=function(e){const n=t.useId(),i=e.clientId||n,{name:o}=e,r=Gt(t=>t.selections.get(o)),s=Gt(t=>t.setClause),a=Gt(t=>t.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(jt(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,i):()=>!0,[r,i]),isActive:l,selectPoints:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(o,{clientId:i,type:"point",fields:e})},[i,o,s]),selectInterval:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(o,{clientId:i,type:"interval",fields:e})},[i,o,s]),clear:t.useCallback(()=>{a(o,i)},[a,o,i]),clientId:i}}({name:n});return{onHover:t.useCallback(t=>{if(!t)return void a();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&s(e)},[i,s,a]),predicate:o,isActive:r}}const Vt=t.forwardRef(function(e,n){const{size:i,width:o,height:r,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:h,timeAccessor:d,valueAccessor:y,timeExtent:g,valueExtent:p,extentPadding:m,stroke:v="#007bff",strokeWidth:x=2,strokeDasharray:b,showAxes:k=!0,background:w,enableHover:E,tooltipContent:A,tooltip:S,onHover:M,annotations:_,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:P,decay:z,pulse:C,staleness:T,transition:O,linkedHover:$}=e,R=null!=o&&null!=r?[o,r]:i||[500,300],D=null!=A?A:S,Y=t.useRef(null),B=Xt($),L=qt({name:(null==B?void 0:B.name)||"hover",fields:(null==B?void 0:B.fields)||[]}),X=t.useCallback(t=>{M&&M(t),$&&L.onHover(t?t.data||t:null)},[M,$,L]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Y.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),f.createElement(Q,{ref:Y,chartType:"line",runtimeMode:"streaming",size:R,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:h,timeAccessor:d,valueAccessor:y,xExtent:g,yExtent:p,extentPadding:m,lineStyle:{stroke:v,strokeWidth:x,strokeDasharray:b},showAxes:k,background:w,hoverAnnotation:E,tooltipContent:D,customHoverBehavior:X,annotations:_,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:P,decay:z,pulse:C,staleness:T,transition:O})});Vt.displayName="RealtimeLineChart";const Zt=t.forwardRef(function(e,n){const{binSize:i,size:o,width:r,height:s,margin:a,className:l,arrowOfTime:c="right",windowMode:u="sliding",windowSize:h=200,data:d,timeAccessor:y,valueAccessor:g,timeExtent:p,valueExtent:m,extentPadding:v,categoryAccessor:x,colors:b,fill:k,stroke:w,strokeWidth:E,gap:A,showAxes:S=!0,background:M,enableHover:_,tooltipContent:N,tooltip:W,onHover:P,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O,linkedHover:$}=e,R=null!=r&&null!=s?[r,s]:o||[500,300],D=null!=N?N:W,Y=t.useRef(null),B=Xt($),L=qt({name:(null==B?void 0:B.name)||"hover",fields:(null==B?void 0:B.fields)||[]}),X=t.useCallback(t=>{P&&P(t),$&&L.onHover(t?t.data||t:null)},[P,$,L]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Y.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const F={};return null!=k&&(F.fill=k),null!=w&&(F.stroke=w),null!=E&&(F.strokeWidth=E),null!=A&&(F.gap=A),f.createElement(Q,{ref:Y,chartType:"bar",runtimeMode:"streaming",size:R,margin:a,className:l,arrowOfTime:c,windowMode:u,windowSize:h,data:d,timeAccessor:y,valueAccessor:g,xExtent:p,yExtent:m,extentPadding:v,binSize:i,categoryAccessor:x,barColors:b,barStyle:F,showAxes:S,background:M,hoverAnnotation:_,tooltipContent:D,customHoverBehavior:X,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O})});Zt.displayName="RealtimeTemporalHistogram";const Jt=Zt,Kt=t.forwardRef(function(e,n){const{size:i,width:o,height:r,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:h,timeAccessor:d,valueAccessor:y,timeExtent:g,valueExtent:p,extentPadding:m,categoryAccessor:v,colors:x,radius:b,fill:k,opacity:w,stroke:E,strokeWidth:A,showAxes:S=!0,background:M,enableHover:_,tooltipContent:N,tooltip:W,onHover:P,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O,linkedHover:$}=e,R=null!=o&&null!=r?[o,r]:i||[500,300],D=null!=N?N:W,Y=t.useRef(null),B=Xt($),L=qt({name:(null==B?void 0:B.name)||"hover",fields:(null==B?void 0:B.fields)||[]}),X=t.useCallback(t=>{P&&P(t),$&&L.onHover(t?t.data||t:null)},[P,$,L]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Y.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const F={};return null!=b&&(F.radius=b),null!=k&&(F.fill=k),null!=w&&(F.opacity=w),null!=E&&(F.stroke=E),null!=A&&(F.strokeWidth=A),f.createElement(Q,{ref:Y,chartType:"swarm",runtimeMode:"streaming",size:R,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:h,timeAccessor:d,valueAccessor:y,xExtent:g,yExtent:p,extentPadding:m,categoryAccessor:v,barColors:x,swarmStyle:F,showAxes:S,background:M,hoverAnnotation:_,tooltipContent:D,customHoverBehavior:X,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O})});Kt.displayName="RealtimeSwarmChart";const Qt=t.forwardRef(function(e,n){const{size:i,width:o,height:r,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:h,timeAccessor:d,valueAccessor:y,timeExtent:g,valueExtent:p,extentPadding:m,positiveColor:v,negativeColor:x,connectorStroke:b,connectorWidth:k,gap:w,stroke:E,strokeWidth:A,showAxes:S=!0,background:M,enableHover:_,tooltipContent:N,tooltip:W,onHover:P,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O,linkedHover:$}=e,R=null!=o&&null!=r?[o,r]:i||[500,300],D=null!=N?N:W,Y=t.useRef(null),B=Xt($),L=qt({name:(null==B?void 0:B.name)||"hover",fields:(null==B?void 0:B.fields)||[]}),X=t.useCallback(t=>{P&&P(t),$&&L.onHover(t?t.data||t:null)},[P,$,L]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Y.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Y.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Y.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const F={};return null!=v&&(F.positiveColor=v),null!=x&&(F.negativeColor=x),null!=b&&(F.connectorStroke=b),null!=k&&(F.connectorWidth=k),null!=w&&(F.gap=w),null!=E&&(F.stroke=E),null!=A&&(F.strokeWidth=A),f.createElement(Q,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:R,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:h,timeAccessor:d,valueAccessor:y,xExtent:g,yExtent:p,extentPadding:m,waterfallStyle:F,showAxes:S,background:M,hoverAnnotation:_,tooltipContent:D,customHoverBehavior:X,annotations:z,svgAnnotationRules:C,tickFormatTime:T,tickFormatValue:O})});Qt.displayName="RealtimeWaterfallChart";const Ut=t.forwardRef(function(e,n){const{size:i,width:o,height:r,margin:s,className:a,arrowOfTime:l="right",windowMode:c="sliding",windowSize:u=200,data:h,timeAccessor:d,valueAccessor:y,categoryAccessor:g,timeExtent:p,valueExtent:m,extentPadding:v,heatmapXBins:x=20,heatmapYBins:b=20,aggregation:k="count",showAxes:w=!0,background:E,enableHover:A,tooltipContent:S,tooltip:M,onHover:_,annotations:N,svgAnnotationRules:W,tickFormatTime:P,tickFormatValue:z,decay:C,pulse:T,staleness:O}=e,$=null!=o&&null!=r?[o,r]:i||[500,300],R=null!=S?S:M,D=t.useRef(null);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=D.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=D.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=D.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=D.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),f.createElement(Q,{ref:D,chartType:"heatmap",runtimeMode:"streaming",size:$,margin:s,className:a,arrowOfTime:l,windowMode:c,windowSize:u,data:h,timeAccessor:d,valueAccessor:y,categoryAccessor:g,xExtent:p,yExtent:m,extentPadding:v,heatmapXBins:x,heatmapYBins:b,heatmapAggregation:k,showAxes:w,background:E,hoverAnnotation:A,tooltipContent:R,customHoverBehavior:_,annotations:N,svgAnnotationRules:W,tickFormatTime:P,tickFormatValue:z,decay:C,pulse:T,staleness:O})});Ut.displayName="RealtimeHeatmap",exports.IncrementalExtent=m,exports.RealtimeHeatmap=Ut,exports.RealtimeHistogram=Jt,exports.RealtimeLineChart=Vt,exports.RealtimeSwarmChart=Kt,exports.RealtimeWaterfallChart=Qt,exports.RingBuffer=p,exports.StreamNetworkFrame=Lt,exports.StreamXYFrame=Q;
1
+ "use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),r=require("d3-scale"),i=require("d3-array"),o=require("d3-hierarchy"),a=require("d3-interpolate"),l=require("d3-scale-chromatic"),s=require("d3-force"),c=require("d3-chord"),u=require("d3-shape");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const d=h(t),f=5e3;class y{constructor(t){this.lastBoundedData=null,this.chunkTimer=0,this.callback=t}setBoundedData(t){if(t===this.lastBoundedData)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,f),bounded:!0,totalSize:t.length});let e=f;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+f,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(t){this.callback({inserts:[t],bounded:!1})}pushMany(t){0!==t.length&&this.callback({inserts:t,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class g{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class p{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function m(t,e,n,r,i){const o=new Map;for(const a of t){const t=e(a),l=n(a);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const s=Math.floor(t/r)*r;let c=o.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},o.set(s,c)),c.total+=l,i){const t=i(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}return o}function v(t,e,n,r,i,o){const a=[],l=[];for(const i of t){const t=n(i),o=r(i);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||(a.push([e.x(t),e.y(o)]),l.push(o))}return{type:"line",path:a,rawValues:l,style:i,datum:t,group:o}}function x(t,e,n,r,i,o,a){const l=[],s=[];for(const o of t){const t=n(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=e.x(t);l.push([c,e.y(a)]),s.push([c,e.y(i)])}return{type:"area",topPath:l,bottomPath:s,style:o,datum:t,group:a}}function b(t,e,n,r,i,o,a){const l=n(t),s=r(t);if(null==l||null==s||Number.isNaN(l)||Number.isNaN(s))return null;const c={type:"point",x:e.x(l),y:e.y(s),r:i,style:o,datum:t};return void 0!==a&&(c.pointId=a),c}function k(t,e,n,r,i,o,a){return{type:"rect",x:t,y:e,w:n,h:r,style:i,datum:o,group:a}}function w(t,e,n,r,i,o){return{type:"heatcell",x:t,y:e,w:n,h:r,fill:i,datum:o}}function E(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function A(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class S{constructor(t){this.xExtent=new p,this.yExtent=new p,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new g(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=E(t.timeAccessor||t.xAccessor,"time"),this.getY=E(t.valueAccessor||t.yAccessor,"value")):(this.getX=E(t.xAccessor,"x"),this.getY=E(t.yAccessor,"y")),this.getGroup=A(t.groupAccessor),this.getCategory=A(t.categoryAccessor),this.getSize=t.sizeAccessor?E(t.sizeAccessor,"size"):void 0,this.getColor=A(t.colorAccessor),this.getBounds=t.boundsAccessor?E(t.boundsAccessor,"bounds"):void 0,this.getPointId=A(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=E(t.openAccessor,"open"),this.getHigh=E(t.highAccessor,"high"),this.getLow=E(t.lowAccessor,"low"),this.getClose=E(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new g(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,i,o,a,l;const{config:s,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let d=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:u[0],null!==(n=s.xExtent[1])&&void 0!==n?n:u[1]]:u,f=s.yExtent?[null!==(i=s.yExtent[0])&&void 0!==i?i:h[0],null!==(o=s.yExtent[1])&&void 0!==o?o:h[1]]:h;const y=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!y&&c.size>0)if(s.normalize)f=[0,1+s.extentPadding];else{const t=c.toArray(),e=this.groupData(t),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);f=[0,r+(r>0?r*s.extentPadding:1)]}else if("bar"===s.chartType&&s.binSize&&!y&&c.size>0){const[,t]=function(t,e,n,r,i){const o=m(t,e,n,r,i);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(c,this.getX,this.getY,s.binSize,this.getCategory);f=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!y&&c.size>0){const[t,e]=function(t,e){let n=0,r=0,i=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>r&&(r=i))}return[n,r]}(c,this.getY),n=e-t,r=n>0?n*s.extentPadding:1;f=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&f[0]!==1/0){if(this.getBounds){const t=c.toArray();for(const e of t){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>f[1]&&(f[1]=t+n),f[0]>t-n&&(f[0]=t-n))}}const t=f[1]-f[0],e=t>0?t*s.extentPadding:1,n=null===(a=s.yExtent)||void 0===a?void 0:a[0],r=null===(l=s.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-e,null!=r?f[1]:f[1]+e]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==s.arrowOfTime)if("x"==("up"===(g=s.arrowOfTime)||"down"===g?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:r.scaleLinear().domain(d).range(e),y:r.scaleLinear().domain(f).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:r.scaleLinear().domain(f).range([0,t.width]),y:r.scaleLinear().domain(d).range(e)}}else this.scales={x:r.scaleLinear().domain(d).range([0,t.width]),y:r.scaleLinear().domain(f).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:r}=this;if(!r||0===n.size)return[];const i=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,t);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,t);case"candlestick":return this.buildCandlestickScene(i,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),r=[],i=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=v(t.data,this.scales,this.getX,this.getY,e,t.key);i&&i.length>0&&(n.colorThresholds=i),r.push(n)}return r}buildAreaScene(t){const e=this.groupData(t),n=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]);n.push(x(t.data,this.scales,this.getX,this.getY,r,e,t.key))}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,r,i,o){var a;const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||l.add(e)}const s=Array.from(l).sort((t,e)=>t-e),c=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),o=r(i);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}c.set(e.key,t)}let u;if(o){u=new Map;for(const e of s){let n=0;for(const r of t)n+=(null===(a=c.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,n||1)}}const h=[],d=new Map;for(const t of s)d.set(t,0);for(const n of t){const t=c.get(n.key),r=[],a=[];for(const n of s){let i=t.get(n)||0;const l=d.get(n);o&&(i/=u.get(n));const s=e.x(n);a.push([s,e.y(l)]),r.push([s,e.y(l+i)]),d.set(n,l+i)}h.push({type:"area",topPath:r,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let i=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),n=Math.max(...e);i=e=>t===n?(r[0]+r[1])/2:r[0]+(e-t)/(n-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,n[r%n.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||n;if(i&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=i(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const l=this.getPointId?this.getPointId(r)+"":void 0,s=b(r,this.scales,this.getX,this.getY,a,t,l);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=E(this.config.valueAccessor,"value"),i=new Set,o=new Set;for(const e of t)i.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(i).sort((t,e)=>t-e),l=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===l.length)return n;const s=e.width/a.length,c=e.height/l.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,d=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>d&&(d=t);const f=d-h||1;for(let t=0;a.length>t;t++)for(let e=0;l.length>e;e++){const r=u.get(`${a[t]}_${l[e]}`);if(!r)continue;const i=(r.val-h)/f;n.push(w(t*s,(l.length-1-e)*c,s,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,r.datum))}return n}buildStreamingHeatmapScene(t,e){var n,r,i;const o=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,s=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=E(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/a,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),i=Math.min(Math.floor((n-d)/g),l-1);if(0>r||0>i)continue;const o=`${r}_${i}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let m=1/0,v=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),m>n&&(m=n),n>v&&(v=n)}const b=v-m||1,k=e.width/a,A=e.height/l;for(const[t,e]of x){const[n,r]=t.split("_"),i=+n,a=+r,s=(e-m)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(w(i*k,(l-1-a)*A,k,A,c,{xi:i,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=m(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],i=new Set(e),o=Array.from(t).filter(t=>!i.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const i=[],o=this.scales,[a,l]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,a),s=Math.min(t.end,l);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(r&&t.categories.size>0){let n=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const l=o.y(n),s=o.y(n+r);i.push(k(h,Math.min(l,s),d,Math.abs(l-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),n+=r}}else{const e=o.y(0),n=o.y(t.total);i.push(k(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return i}buildSwarmScene(t){var e,n,r,i;const o=[],a=this.config.swarmStyle||{},l=null!==(e=a.radius)&&void 0!==e?e:3,s=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const r=this.scales.x(t),a=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[t])||d}const f={type:"point",x:r,y:a,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,r,i;const o=[],a=this.scales,l=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],r=this.getX(n),i=this.getY(n),g=y+i;let p;p=s.length-1>t?this.getX(s[t+1])-r:t>0?r-this.getX(s[t-1]):0;const m=a.x(r),v=0!==p?a.x(r+p):m+e.width/10,x=Math.min(m,v)+h/2,b=Math.max(m,v)-h/2-x;if(0>=b){y=g;continue}const w=a.y(y),E=a.y(g);o.push(k(x,Math.min(w,E),b,Math.abs(w-E),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],r=this.config.candlestickStyle||{},i=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",l=r.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=r.bodyWidth||6;if(!r.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=r;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:i,downColor:o,wickColor:a,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],r=[];for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)n.push([a,this.scales.y(i+o)]),r.push([a,this.scales.y(i-o)]);else{const t=this.scales.y(i);n.push([a,t]),r.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var n,r,i;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(n=o.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(o.type){case"linear":return a+(1-l/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(i=o.stepThreshold)&&void 0!==i?i:.5*e)>l?1:a;default:return 1}}applyDecay(t,e){var n,r;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,i);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var n;const r=this.config.pulse;if(!r)return 0;const i=null!==(n=r.duration)&&void 0!==n?n:500,o=e-t;return i>o?1-o/i:0}applyPulse(t,e){var n,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=l.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const r=this.computePulseIntensity(n,i);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&n>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeIdentity(e,t);n&&("point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(n,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var n,r,i,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,n,r,i,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let l=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],s=this.getNodeIdentity(a,t);if(!s)continue;const c=this.prevPositionMap.get(s);if(c)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=c.x,a.y=c.y,a.r=null!==(e=c.r)&&void 0!==e?e:a.r,l=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(r=c.h)&&void 0!==r?r:a.h,l=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};c.x===t.x&&c.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=c.x,a.y=c.y,a.w=null!==(i=c.w)&&void 0!==i?i:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*r,t.y=n.y+(t._targetY-n.y)*r,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*r),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*r)}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const n=this.config.lineStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){Object.assign(this.config,t)}}function M(t,e,n){const r=e-t.x,i=n-t.y,o=Math.sqrt(r*r+i*i);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function L(t,e,n){if(0===t.path.length)return null;const r=T(t.path,e);if(0>r)return null;const[i,o]=t.path[r],a=e-i,l=n-o,s=Math.sqrt(a*a+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:i,y:o,distance:s}}function P(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function D(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{node:t,datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}function _(t,e,n){const r=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,o=e-t.x,a=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(o*o+a*a)}}return null}function $(t,e,n){if(0===t.topPath.length)return null;const r=T(t.topPath,e);if(0>r)return null;const[i,o]=t.topPath[r],a=e-i,l=n-o;return{node:t,datum:t.datum,x:i,y:o,distance:Math.sqrt(a*a+l*l)}}function T(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const i=n+r>>1;e>t[i][0]?n=i+1:r=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}const N={fill:t=>d.createElement("rect",{style:t,width:20,height:20}),line:t=>d.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function W(t,e,n,r){let i;return i="function"==typeof n?n(t):(0,N[n])(r(t,e)),i}function C(t){const{legendGroups:e,customClickBehavior:n,title:r="Legend",width:i=100,height:o=20,orientation:a="vertical"}=t,l="vertical"===a?(({legendGroups:t,width:e,customClickBehavior:n})=>{let r=30;const i=[];return t.forEach((t,o)=>{r+=5,i.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:0,y1:r,x2:e,y2:r})),r+=10,t.label&&(r+=20,i.push(d.createElement("text",{key:"legend-text-"+o,y:r,className:"legend-group-label"},t.label)),r+=10),i.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(0,${r})`},((t,e)=>{const{type:n="fill",styleFn:r,items:i}=t,o=[];let a=0;return i.forEach((t,i)=>{const l=W(t,i,n,r);o.push(d.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${a})`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},l,d.createElement("text",{y:15,x:30},t.label))),a+=25}),o})(t,n))),r+=25*t.items.length+10}),i})({legendGroups:e,width:i,customClickBehavior:n}):(({legendGroups:t,title:e,height:n,customClickBehavior:r})=>{let i=0;const o=[],a=!1===e?10:40;return t.forEach((e,l)=>{e.label&&(o.push(d.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},e.label)),i+=20);const s=((t,e)=>{const{type:n="fill",styleFn:r,items:i}=t,o=[];let a=0;return i.forEach((t,i)=>{const l=W(t,i,n,r);o.push(d.createElement("g",{key:"legend-item-"+i,transform:`translate(${a},0)`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},l,d.createElement("text",{y:15,x:25},t.label))),a+=35,a+=8*t.label.length}),{items:o,offset:a}})(e,r);o.push(d.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${a})`},s.items)),i+=s.offset+5,t[l+1]&&o.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:a-10,x2:i,y2:n+a+10})),i+=15}),d.createElement("g",null,!1!==e&&d.createElement("line",{x1:0,x2:i+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),o)})({legendGroups:e,title:r,height:o,customClickBehavior:n});return d.createElement("g",null,void 0!==r&&d.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:i/2,textAnchor:"horizontal"===a?"start":"middle"},r),l)}function O(t){return"string"==typeof t?{type:t}:t}function R({orient:e,config:n,values:r,scale:o,size:a,length:l}){const s=function(t){var e,n,r,i,o;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=t.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(o=t.strokeWidth)&&void 0!==o?o:1}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===r.length)return null;const t=o.domain(),n=a-8;if("boxplot"===s.type){const t=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],o=e[Math.floor(.75*n)],a=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(e[0],r-1.5*a),whiskerHigh:Math.min(e[n-1],o+1.5*a)}}(r);if(!t)return null;const{q1:i,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,f=Math.min(.5*n,20),y=(n-f)/2+4;if(c){const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="top"===e?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+e},d.createElement("line",{x1:c,y1:m+p*(y+f/2),x2:g,y2:m+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("rect",{x:Math.min(t,n),y:"top"===e?m-y-f:m+y,width:Math.abs(n-t),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:r,y1:"top"===e?m-y-f:m+y,x2:r,y2:"top"===e?m-y:m+y+f,stroke:s.fill,strokeWidth:2}))}{const t=o(i),n=o(l),r=o(a),c=o(u),g=o(h),p="left"===e?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+e},d.createElement("line",{x1:m+p*(y+f/2),y1:c,x2:m+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),d.createElement("rect",{x:"left"===e?m-y-f:m+y,y:Math.min(t,n),width:f,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),d.createElement("line",{x1:"left"===e?m-y-f:m+y,y1:r,x2:"left"===e?m-y:m+y+f,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=i.bin().domain(t).thresholds(s.bins)(r);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,r)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/h*n;if(c){const n=o(t.x0),a=o(t.x1)-o(t.x0);return d.createElement("rect",{key:r,x:n,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=o(t.x0),a=o(t.x1)-o(t.x0);return d.createElement("rect",{key:r,x:"left"===e?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,r=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/h*(n/2),l=o((i.x0+i.x1)/2);r.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=o((a.x0+a.x1)/2);r.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${s}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+e},d.createElement("polygon",{points:r.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const t=[];if(c){const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${i},${r}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${a},${"top"===e?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${a},${r}`),t.push("Z")}else{const r=0,i=null!=u[0].x0?o(u[0].x0):0;t.push(`M${r},${i}`);for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*n,a=o((r.x0+r.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;t.push(`L${r},${a}`),t.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+e},d.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[r,o,s,a,l,e,c,4]);return u?d.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function z(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),o=[];let a="";for(const t of i)a&&a.length+1+t.length>r?(o.push(a),a=t):a=a?`${a} ${t}`:t;return a&&o.push(a),o}function I(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Y(t){const{x:e=0,y:n=0,dx:r,dy:i,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:f,disable:y,events:g={},"data-testid":p}=t,m=new Set(Array.isArray(y)?y:[]);let v=r||0,x=i||0;null!=o&&(v=o-e),null!=a&&(x=a-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===v&&0===x)if(void 0!==c.width){v=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;v=t+(0>t?-5:5),x=c.height/2}return d.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},g),!m.has("connector")&&function(t,e,n,r,i,o){const a=[];let l=0,s=0;if("callout-circle"!==i&&"label"!==i||!(null==o?void 0:o.radius)){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,a=t-i,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=r/2,d=t*h>e*u?u/t:h/e;l=i+a*d,s=o+c*d}}}else if("bracket"===i&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);l=Math.cos(r)*n,s=Math.sin(r)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(d.createElement("line",{key:"connector-line",x1:l,y1:s,x2:t,y2:e,stroke:r||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(d.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+i)},${s+n*Math.sin(o+i)}L${l+n*Math.cos(o-i)},${s+n*Math.sin(o-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},a)}(v,x,s,h,b,c),!m.has("subject")&&function(t,e,n,r,i){var o;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.push(d.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,r=(null==e?void 0:e.height)||0;(t>0||r>0)&&a.push(d.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&a.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,o=i||0;if(void 0!==(null==e?void 0:e.x)){const r=(e.x||0)-t;a.push(d.createElement("line",{key:"threshold-line",x1:r,y1:(e.y1||0)-o,x2:r,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const r=(e.y||0)-o;a.push(d.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?a.push(d.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||a.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(d.createElement("path",{key:"bracket-path",d:I((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},a)}(b,c,h,e,n),!m.has("note")&&function(t,e,n,r){if(!t)return d.createElement("g",{className:"annotation-note"});const{label:i,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!i&&!o)return d.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===u?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>e?"end":"start";const y=16,g=o?c?[o]:z(o,s):[],p=i?c?[i]:z(i,s):[],m="leftRight"===u?"end"===f?-4:4:0;let v=0;const x=[];g.length>0&&(x.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:f,fontWeight:"bold"},g.map((t,e)=>d.createElement("tspan",{key:e,x:m,dy:0===e?0:y},t)))),v=g.length*y),p.length>0&&x.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:f,y:v},p.map((t,e)=>d.createElement("tspan",{key:e,x:m,dy:0===e?0:y},t))));let b=null;if((o||i)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===f?(e=-t,n=0):"middle"===f&&(e=-t/2,n=t/2),b=d.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(g.length+p.length)*y+(p.length>0?y:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,v,x,h))}function B(t){var e,n;const{noteData:r}=t,{screenCoordinates:i}=r,o="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(e=r.dx)&&void 0!==e?e:0),a=r.ny||i[0][1]+(null!==(n=r.dy)&&void 0!==n?n:0),l=i.map((e,n)=>{const i=Object.assign({},r,{note:0===n?r.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return d.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:o}))});return d.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return d.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:a},r,{type:o}))}function j(t,e){var n,r,i;const o=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(i=e.scales)||void 0===i?void 0:i.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function F(t,e){var n,r,i;const o=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(i=e.scales)||void 0===i?void 0:i.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function X(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}function H(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,i="left"===t?-1:1,o=Math.ceil(e/8);let a="M0,"+r;for(let t=0;o>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${r+4*i}`,a+=`L${Math.min(n,e)},${r}`}return a}{const r="bottom"===t?0:e,i="bottom"===t?1:-1,o=Math.ceil(n/8);let a=`M${r},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${r+4*i},${Math.min(8*t+4,n)}`,a+=`L${r},${Math.min(e,n)}`}return a}}function G(t){return Math.round(100*t)/100+""}function q(e){const{width:n,height:r,totalWidth:i,totalHeight:a,margin:l,scales:s,showAxes:c,axes:u,xLabel:h,yLabel:f,xFormat:y,yFormat:g,showGrid:p,title:m,legend:v,foregroundGraphics:x,marginalGraphics:b,xValues:k,yValues:w,annotations:E,svgAnnotationRules:A,annotationFrame:S,xAccessor:M,yAccessor:L,annotationData:P,pointNodes:D,children:_}=e,$=t.useMemo(()=>c&&s?s.x.ticks(5).map(t=>({value:t,pixel:s.x(t),label:(y||G)(t)})):[],[c,s,y]),T=t.useMemo(()=>c&&s?s.y.ticks(5).map(t=>({value:t,pixel:s.y(t),label:(g||G)(t)})):[],[c,s,g]),N=t.useMemo(()=>{if(!E||0===E.length)return null;const t=function(t,e,n){var r,i,a,l,s,c,u,h,f,y,g,p,m,v,x,b,k,w,E,A,S,M,L,P,D,_,$,T,N,W,C,O;switch(t.type){case"label":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=j(t,n),i=F(t,n);return null==r||null==i?null:X(r,i,n)?d.createElement(B,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=j(t,n),i=F(t,n);return null==r||null==i?null:X(r,i,n)?d.createElement(B,{key:"ann-"+e,noteData:{x:r,y:i,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const r=j(t,n);if(null==r)return null;const i=t.color||"#f97316";return d.createElement("g",{key:"ann-"+e},d.createElement("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=F(t,n);if(null==r)return null;const i=t.color||"#f97316";return d.createElement("g",{key:"ann-"+e},d.createElement("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(t=>({x:j(Object.assign(Object.assign({},t),{type:"point"}),n),y:F(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=o.packEnclose(r),a=t.padding||10;return d.createElement("g",{key:"ann-"+e},d.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&d.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(t=>({x:j(Object.assign(Object.assign({},t),{type:"point"}),n),y:F(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const i=t.padding||10,o=r.map(t=>t.x),a=r.map(t=>t.y),l=Math.min(...o)-i,s=Math.max(...o)+i,c=Math.min(...a)-i,u=Math.max(...a)+i;return d.createElement("g",{key:"ann-"+e},d.createElement("rect",{x:l,y:c,width:s-l,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&d.createElement("text",{x:(l+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=n.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],o=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+e},i.map((e,r)=>{const i=j(e,n),a=F(e,n);return null==i||null==a?null:d.createElement("circle",Object.assign({key:r,cx:i,cy:a,r:t.r||6},o))}))}case"bracket":{const r=j(t,n),i=F(t,n);return d.createElement(B,{key:"ann-"+e,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const o=n.data||[];if(2>o.length)return null;const h=n.xAccessor||"x",f=n.yAccessor||"y",y=o.map(t=>[t[h],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(i=null===(r=n.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=n.scales)||void 0===a?void 0:a.time,p=null!==(s=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==s?s:null===(c=n.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const m=t.method||"linear";let v;if("loess"===m)v=function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),i=r.map(t=>t[0]),o=r.map(t=>t[1]),a=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=i[t],r=i.map(t=>Math.abs(t-e)),s=r.slice().sort((t,e)=>t-e)[Math.min(a-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:r[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*i[t],d+=e*o[t],f+=e*i[t]*i[t],y+=e*i[t]*o[t])}if(0===u){l.push([e,o[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([e,d/u]);else{const t=(u*y-h*d)/g;l.push([e,(d-t*h)/u+t*e])}}return l}(y,null!==(u=t.bandwidth)&&void 0!==u?u:.3);else{let e;try{const n=require("regression");e="polynomial"===m?n.polynomial(y,{order:t.order||2}):n.linear(y)}catch(t){return null}v=e.points}const x=v.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=t.color||"#6366f1";return d.createElement("g",{key:"ann-"+e},d.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&d.createElement("text",{x:g(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:b,fontSize:11},t.label))}case"band":{const r=null!==(f=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,i=null!==(g=null==r?void 0:r(t.y0))&&void 0!==g?g:0,o=null!==(p=null==r?void 0:r(t.y1))&&void 0!==p?p:n.height||0;return d.createElement("g",{key:"ann-"+e},d.createElement("rect",{x:0,y:Math.min(i,o),width:n.width||0,height:Math.abs(o-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(i,o)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const i=n.yAccessor||"y",o=null!==(v=null===(m=n.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(x=n.scales)||void 0===x?void 0:x.time,a=null!==(k=null===(b=n.scales)||void 0===b?void 0:b.y)&&void 0!==k?k:null===(w=n.scales)||void 0===w?void 0:w.value;if(!o||!a)return null;const l=r.map(t=>t[i]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),h=null!==(E=t.threshold)&&void 0!==E?E:2,f=s-h*u,y=!1!==t.showBand,g=t.fill||"#6366f1",p=null!==(A=t.fillOpacity)&&void 0!==A?A:.1,M=t.anomalyColor||"#ef4444",L=null!==(S=t.anomalyRadius)&&void 0!==S?S:6,P=a(s+h*u),D=a(f),_=r.filter(t=>{const e=t[i];return null!=e&&Math.abs(e-s)>h*u});return d.createElement("g",{key:"ann-"+e},y&&d.createElement("rect",{x:0,y:Math.min(P,D),width:n.width||0,height:Math.abs(D-P),fill:g,fillOpacity:p}),_.map((t,e)=>{const r=j(t,n),i=F(t,n);return null==r||null==i?null:d.createElement("circle",{key:e,cx:r,cy:i,r:L,fill:M,fillOpacity:.7,stroke:M,strokeWidth:1.5})}),t.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(P,D)-4,textAnchor:"end",fill:g,fontSize:11},t.label))}case"forecast":{const r=n.data||[];if(3>r.length)return null;const i=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(L=null===(M=n.scales)||void 0===M?void 0:M.x)&&void 0!==L?L:null===(P=n.scales)||void 0===P?void 0:P.time,l=null!==(_=null===(D=n.scales)||void 0===D?void 0:D.y)&&void 0!==_?_:null===($=n.scales)||void 0===$?void 0:$.value;if(!a||!l)return null;const s=r.map(t=>[t[i],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}catch(t){return null}else{const t=s.length;let e=0,n=0,r=0,i=0;for(const[t,o]of s)e+=t,n+=o,r+=t*t,i+=t*o;const o=t*r-e*e;if(1e-12>Math.abs(o))return null;const a=(t*i-e*n)/o,l=(n-a*e)/t;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(u-2,1)),y=s.reduce((t,e)=>t+e[0],0)/u,g=s.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(T=t.confidence)&&void 0!==T?T:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(N=t.steps)&&void 0!==N?N:5,x=s[u-1][0],b=(x-s[0][0])/Math.max(u-1,1),k=[];for(let t=1;v>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=c(t),n=f*Math.sqrt(1+1/u+(g>0?Math.pow(t-y,2)/g:0))*m;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const E=`M${w.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),S=`${a(x)},${l(c(x))}`,R=t.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+e},d.createElement("path",{d:E,fill:t.fill||"#6366f1",fillOpacity:null!==(W=t.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),d.createElement("polyline",{points:`${S} ${A}`,fill:"none",stroke:R,strokeWidth:null!==(C=t.strokeWidth)&&void 0!==C?C:2,strokeDasharray:null!==(O=t.strokeDasharray)&&void 0!==O?O:"6,3"}),t.label&&w.length>0&&d.createElement("text",{x:a(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:R,fontSize:11},t.label))}default:return null}},e={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:M,yAccessor:L,width:n,height:r,data:P,frameType:"xy",pointNodes:D};return E.map((n,r)=>{if(A){const i=A(n,r,e);return null!=i?i:t(n,r,e)}return t(n,r,e)}).filter(Boolean)},[E,A,n,r,S,M,L,P]);return c||m||v||x||b||N&&N.length>0||p||_?d.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${l.left},${l.top})`},p&&s&&d.createElement("g",{className:"stream-grid"},$.map((t,e)=>d.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),T.map((t,e)=>d.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&s&&(()=>{const t=null==u?void 0:u.find(t=>"left"===t.orient),e=null==u?void 0:u.find(t=>"bottom"===t.orient),i=!t||!1!==t.baseline,o=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,s="var(--semiotic-border, #ccc)",c="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},(!e||!1!==e.baseline)&&!a&&d.createElement("line",{x1:0,y1:r,x2:n,y2:r,stroke:s,strokeWidth:1}),a&&d.createElement("path",{d:H("bottom",n,r),fill:"none",stroke:s,strokeWidth:1}),$.map((t,e)=>d.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${r})`},d.createElement("line",{y2:5,stroke:s,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:c,style:{userSelect:"none"}},t.label))),h&&d.createElement("text",{x:n/2,y:r+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},h),i&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:s,strokeWidth:1}),o&&d.createElement("path",{d:H("left",n,r),fill:"none",stroke:s,strokeWidth:1}),T.map((t,e)=>d.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},d.createElement("line",{x2:-5,stroke:s,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:c,style:{userSelect:"none"}},t.label))),f&&d.createElement("text",{x:15-l.left,y:r/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${r/2})`,style:{userSelect:"none"}},f))})(),N,b&&s&&k&&w&&d.createElement(d.Fragment,null,b.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(R,{orient:"top",config:O(b.top),values:k,scale:s.x,size:l.top,length:n})),b.bottom&&d.createElement("g",{transform:`translate(0, ${r})`},d.createElement(R,{orient:"bottom",config:O(b.bottom),values:k,scale:s.x,size:l.bottom,length:n})),b.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(R,{orient:"left",config:O(b.left),values:w,scale:s.y,size:l.left,length:r})),b.right&&d.createElement("g",{transform:`translate(${n}, 0)`},d.createElement(R,{orient:"right",config:O(b.right),values:w,scale:s.y,size:l.right,length:r}))),x,_),m&&d.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof m?m:null),v&&d.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},function(t){return"object"==typeof t&&null!==t&&!d.isValidElement(t)&&"legendGroups"in t}(v)?d.createElement(C,{legendGroups:v.legendGroups,title:"",width:100}):v)):null}function V(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}const Z=(t,e,n,r)=>{var i;const o=e.filter(t=>"area"===t.type);for(const e of o){if(2>e.topPath.length)continue;t.beginPath();const[n,r]=e.topPath[0];t.moveTo(n,r);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath();const o=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;if(t.globalAlpha=o,t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=1,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]),t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);t.stroke()}t.globalAlpha=1}},K=(t,e,n,r)=>{var i,o;const a=e.filter(t=>"point"===t.type);for(const e of a){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(i=e.style.opacity)&&void 0!==i?i:e.style.fillOpacity;if(null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.x,e.y,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},U=(t,e,n,r)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?Q(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1};function Q(t,e){const n=e.style.icon,r=e.style.iconPadding||2,i=Math.min(e.w,e.w)-r;if(0>=i)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=i+r,a=e.x+(e.w-i)/2;for(let r=e.y+e.h-i;r>=e.y-i;r-=o)t.drawImage(n,a,r,i,i)}else{const o=i+r,a=e.y+(e.h-i)/2;for(let r=e.x;e.x+e.w>r;r+=o)t.drawImage(n,r,a,i,i)}t.restore()}const J={line:[Z,(t,e,n,r)=>{const i=e.filter(t=>"line"===t.type);for(const o of i){if(2>o.path.length)continue;const a=o.style.stroke||"#007bff",l=o.style.strokeWidth||2,s=o.colorThresholds,c=o.rawValues;if(t.setLineDash(o.style.strokeDasharray?o.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=o.style.opacity&&(t.globalAlpha=o.style.opacity),t.lineWidth=l,s&&0!==s.length&&c&&c.length===o.path.length){let u=null,h=null,d=null,f=null,y=!1;function g(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),y=!0}function p(){y&&(t.stroke(),y=!1)}for(let m=0;o.path.length>m;m++){const[v,x]=o.path[m],b=c[m],k=V(b,s,a);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(v,x);else{const w=[];for(const E of s){const A=E.value;(d>A||A>b)&&(A>d||b>A)||d===A||b===A||w.push({t:(A-d)/(b-d)})}w.sort((t,e)=>t.t-e.t);for(const S of w){const M=u+(v-u)*S.t,L=h+(x-h)*S.t,P=V(d+(b-d)*Math.min(S.t+1e-4,1),s,a);t.lineTo(M,L),p(),g(P,M,L)}t.lineTo(v,x)}u=v,h=x,d=b,f=k}else g(k,v,x),u=v,h=x,d=b,f=k}p()}else{t.beginPath(),t.strokeStyle=a;const[D,_]=o.path[0];t.moveTo(D,_);for(let $=1;o.path.length>$;$++)t.lineTo(o.path[$][0],o.path[$][1]);t.stroke()}if(o.style.fill&&o.style.fillOpacity&&o.style.fillOpacity>0){t.beginPath(),t.globalAlpha=o.style.fillOpacity,t.fillStyle=o.style.fill;const[T,N]=o.path[0];t.moveTo(T,N);for(let C=1;o.path.length>C;C++)t.lineTo(o.path[C][0],o.path[C][1]);const W=o.path[0][0];t.lineTo(o.path[o.path.length-1][0],r.height),t.lineTo(W,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[Z],stackedarea:[Z],scatter:[K],bubble:[K],heatmap:[(t,e,n,r)=>{const i=e.filter(t=>"heatcell"===t.type);for(const e of i){const n=e.style;null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1}}],bar:[U],swarm:[K],waterfall:[(t,e,n,r)=>{var i,o,a;U(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const s=l[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const r=l[e],i=l[e+1];if(!(null===(o=r.datum)||void 0===o?void 0:o.cumEnd)||!(null===(a=i.datum)||void 0===a?void 0:a.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=i.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const r=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(i,1))}}]},tt={top:20,right:20,bottom:30,left:40},et={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},nt={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 rt({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:nt},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function it({width:r,height:i,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),f=t.useRef(null);return t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[r,i]]),o.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let e,n;if("x"===s){const[r,o]=t.selection;e=[c.x.invert(r),c.x.invert(o)],n=[c.y.invert(i),c.y.invert(0)]}else if("y"===s){const[i,o]=t.selection;e=[c.x.invert(0),c.x.invert(r)],n=[c.y.invert(o),c.y.invert(i)]}else{const[[r,i],[o,a]]=t.selection;e=[c.x.invert(r),c.x.invert(o)],n=[c.y.invert(a),c.y.invert(i)]}u({x:e,y:n})}),t.call(o),f.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),f.current=null}},[r,i,s,c,u]),d.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const ot=t.forwardRef(function(e,n){var r,i,o;const{chartType:a,runtimeMode:l,data:s,xAccessor:c,yAccessor:u,colorAccessor:h,sizeAccessor:f,groupAccessor:g,lineDataAccessor:p,normalize:m,binSize:v,valueAccessor:x,arrowOfTime:b="right",windowMode:k="sliding",windowSize:w=200,timeAccessor:E,xExtent:A,yExtent:T,extentPadding:N=.1,sizeRange:W,size:C=[500,300],margin:O,className:R,background:z,lineStyle:I,pointStyle:Y,areaStyle:B,waterfallStyle:j,swarmStyle:F,barColors:X,colorScheme:H,boundsAccessor:G,boundsStyle:V,openAccessor:Z,highAccessor:K,lowAccessor:U,closeAccessor:Q,candlestickStyle:nt,showAxes:ot=!0,axes:at,xLabel:lt,yLabel:st,xFormat:ct,yFormat:ut,tickFormatTime:ht,tickFormatValue:dt,hoverAnnotation:ft,tooltipContent:yt,customHoverBehavior:gt,enableHover:pt,annotations:mt,svgAnnotationRules:vt,showGrid:xt,legend:bt,backgroundGraphics:kt,foregroundGraphics:wt,title:Et,categoryAccessor:At,brush:St,onBrush:Mt,decay:Lt,pulse:Pt,transition:Dt,staleness:_t,heatmapAggregation:$t,heatmapXBins:Tt,heatmapYBins:Nt,marginalGraphics:Wt,pointIdAccessor:Ct}=e,Ot=Object.assign(Object.assign({},tt),O);if(Wt){const t=60;Wt.top&&t>Ot.top&&(Ot.top=t),Wt.bottom&&t>Ot.bottom&&(Ot.bottom=t),Wt.left&&t>Ot.left&&(Ot.left=t),Wt.right&&t>Ot.right&&(Ot.right=t)}const Rt=C[0]-Ot.left-Ot.right,zt=C[1]-Ot.top-Ot.bottom,It=null!=ft?ft:pt,Yt=t.useRef(null),Bt=t.useRef(0),jt=t.useRef(!1),[Ft,Xt]=t.useState(0),[Ht,Gt]=t.useState(null),qt=t.useRef(null),Vt=t.useRef(null),[Zt,Kt]=t.useState(null),[Ut,Qt]=t.useState(!1),[Jt,te]=t.useState([]),[ee,ne]=t.useState([]),re=t.useRef(()=>{}),ie="streaming"===l||["bar","swarm","waterfall"].includes(a),oe=t.useMemo(()=>({chartType:a,runtimeMode:ie?"streaming":"bounded",windowSize:w,windowMode:k,arrowOfTime:ie?b:"right",extentPadding:N,xAccessor:ie?void 0:c,yAccessor:ie?void 0:u,timeAccessor:ie?E:void 0,valueAccessor:x,colorAccessor:h,sizeAccessor:f,groupAccessor:g,categoryAccessor:At,lineDataAccessor:p,xExtent:A,yExtent:T,sizeRange:W,binSize:v,normalize:m,boundsAccessor:G,boundsStyle:V,openAccessor:Z,highAccessor:K,lowAccessor:U,closeAccessor:Q,candlestickStyle:nt,lineStyle:I,pointStyle:Y,areaStyle:B,swarmStyle:F,waterfallStyle:j,colorScheme:H,barColors:X,annotations:mt,decay:Lt,pulse:Pt,transition:Dt,staleness:_t,heatmapAggregation:$t,heatmapXBins:Tt,heatmapYBins:Nt,pointIdAccessor:Ct}),[a,w,k,b,N,c,u,E,x,h,f,g,At,p,A,T,W,v,m,G,V,Z,K,U,Q,nt,I,Y,B,F,j,H,X,mt,Lt,Pt,Dt,_t,$t,Tt,Nt,ie,Ct]),ae=t.useRef(null);ae.current||(ae.current=new S(oe));const le=t.useCallback(()=>{Bt.current||(Bt.current=requestAnimationFrame(()=>re.current()))},[]);t.useEffect(()=>{var t;null===(t=ae.current)||void 0===t||t.updateConfig(oe),jt.current=!0,le()},[oe,le]);const se=t.useRef(null);se.current||(se.current=new y(t=>{const e=ae.current;e&&e.ingest(t)&&(jt.current=!0,le())}));const ce=t.useCallback(t=>{var e;null===(e=se.current)||void 0===e||e.push(t)},[]),ue=t.useCallback(t=>{var e;null===(e=se.current)||void 0===e||e.pushMany(t)},[]),he=t.useCallback(()=>{var t,e;null===(t=se.current)||void 0===t||t.clear(),null===(e=ae.current)||void 0===e||e.clear(),jt.current=!0,le()},[le]);t.useImperativeHandle(n,()=>({push:ce,pushMany:ue,clear:he,getData:()=>{var t,e;return null!==(e=null===(t=ae.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]},getScales:()=>{var t,e;return null!==(e=null===(t=ae.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=ae.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[ce,ue,he]),t.useEffect(()=>{var t;s&&(null===(t=se.current)||void 0===t||t.setBoundedData(s))},[s]);const de=t.useRef(()=>{}),fe=t.useRef(()=>{});de.current=t=>{if(!It)return;const e=Yt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Ot.left,i=t.clientY-n.top-Ot.top;if(0>r||r>Rt||0>i||i>zt)return void(qt.current&&(qt.current=null,Vt.current=null,Kt(null),gt&&gt(null),le()));const o=ae.current;if(!o||0===o.scene.length)return;const a=function(t,e,n,r=30){let i=null;for(const o of t){let t=null;switch(o.type){case"point":t=M(o,e,n);break;case"line":t=L(o,e,n);break;case"rect":t=P(o,e,n);break;case"heatcell":t=D(o,e,n);break;case"area":if(!1===o.interactive)break;t=$(o,e,n);break;case"candlestick":t=_(o,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(o.scene,r,i);if(!a)return void(qt.current&&(qt.current=null,Vt.current=null,Kt(null),gt&&gt(null),le()));const l={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};qt.current=l,Vt.current=a.node,Kt(l),gt&&gt(l),le()},fe.current=()=>{qt.current&&(qt.current=null,Vt.current=null,Kt(null),gt&&gt(null),le())};const ye=t.useCallback(t=>de.current(t),[]),ge=t.useCallback(()=>fe.current(),[]);re.current=()=>{var t,e;Bt.current=0;const n=Yt.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const i=ae.current;if(!i)return;const o="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(o);l||i.computeScene({width:Rt,height:zt});const s="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=C[0]*s,n.height=C[1]*s,n.style.width=C[0]+"px",n.style.height=C[1]+"px",r.scale(s,s),r.translate(Ot.left,Ot.top),r.clearRect(-Ot.left,-Ot.top,C[0],C[1]);const h=function(t){if(!t)return et;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),o=r||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=i||e.getPropertyValue("--surface-0").trim();return o||a||n?{axisStroke:l||et.axisStroke,tickText:o||et.tickText,crosshair:o?o+"66":et.crosshair,hoverFill:s?s+"4D":et.hoverFill,hoverStroke:o?o+"99":et.hoverStroke,pointRing:s||et.pointRing}:et}(n),d=null!==(t=null==_t?void 0:_t.threshold)&&void 0!==t?t:5e3,f=_t&&i.lastIngestTime>0&&o-i.lastIngestTime>d;f&&(r.globalAlpha=null!==(e=null==_t?void 0:_t.dimOpacity)&&void 0!==e?e:.5);const y=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=z||(y&&"transparent"!==y?y:null);g&&(r.fillStyle=g,r.fillRect(-Ot.left,-Ot.top,C[0],C[1])),r.save(),"function"==typeof r.rect&&(r.beginPath(),r.rect(0,0,Rt,zt),r.clip());const p=J[a];if(p&&i.scales)for(const t of p)t(r,i.scene,i.scales,{width:Rt,height:zt});if(r.restore(),f&&(r.globalAlpha=1),It&&qt.current&&i.scales&&function(t,e,n,r,i,o,a){if(!1===i.crosshair)return;t.save();const l="object"==typeof i.crosshair?i.crosshair:{};t.strokeStyle=l.stroke||a.crosshair,t.lineWidth=l.strokeWidth||1,t.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,r),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}(r,qt.current,Rt,zt,"object"==typeof It?It:{},0,h),Vt.current&&Array.isArray(ft)){const t=ft.find(t=>t&&"object"==typeof t&&"highlight"===t.type);t&&function(t,e,n,r){var i;if(!n)return;const o=n.group;if(void 0!==o)for(const n of e){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?r.style(n.datum):r.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||"#007bff",t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(i=e.opacity)&&void 0!==i?i:1,t.stroke(),t.restore()}}(r,i.scene,Vt.current,t)}const m=jt.current;if(jt.current=!1,m&&i.scales&&(Gt(i.scales),Wt)){const t=i.getData(),e="function"==typeof c?c:t=>t[c||"x"],n="function"==typeof u?u:t=>t[u||"y"];te(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),ne(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}m&&mt&&mt.length>0&&Xt(t=>t+1),(null==_t?void 0:_t.showBadge)&&Qt(!!f),(l||i.hasActivePulses)&&(Bt.current=requestAnimationFrame(()=>re.current()))},t.useEffect(()=>(le(),()=>{Bt.current&&cancelAnimationFrame(Bt.current)}),[le]),t.useEffect(()=>{jt.current=!0,le()},[a,Rt,zt,ot,z,I,le]),t.useEffect(()=>{if(!_t)return;const t=setInterval(()=>{var t;const e=ae.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=_t.threshold)&&void 0!==t?t:5e3,i=n-e.lastIngestTime>r;i!==Ut&&(Qt(i),jt.current=!0,le())},1e3);return()=>clearInterval(t)},[_t,Ut,le]);const pe=It&&Zt?yt?yt(Zt):d.createElement(rt,{hover:Zt}):null,me=pe?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ot.left+Zt.x,top:Ot.top+Zt.y,transform:`translate(${Zt.x>.7*Rt?"calc(-100% - 12px)":"12px"}, ${.3*zt>Zt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},pe):null;return d.createElement("div",{className:"stream-xy-frame"+(R?" "+R:""),role:"img","aria-label":"string"==typeof Et?Et:"XY chart",style:{position:"relative",width:C[0],height:C[1]},onMouseMove:It?ye:void 0,onMouseLeave:It?ge:void 0},kt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:C[0],height:C[1],pointerEvents:"none"}},kt),d.createElement("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0}}),d.createElement(q,{width:Rt,height:zt,totalWidth:C[0],totalHeight:C[1],margin:Ot,scales:Ht,showAxes:ot,axes:at,xLabel:lt,yLabel:st,xFormat:ct||ht,yFormat:ut||dt,showGrid:xt,title:Et,legend:bt,foregroundGraphics:wt,marginalGraphics:Wt,xValues:Jt,yValues:ee,annotations:mt,svgAnnotationRules:vt,annotationFrame:Ft,xAccessor:"string"==typeof c?c:"string"==typeof E?E:void 0,yAccessor:"string"==typeof u?u:"string"==typeof x?x:void 0,annotationData:null===(r=ae.current)||void 0===r?void 0:r.getData(),pointNodes:null===(i=ae.current)||void 0===i?void 0:i.scene.filter(t=>"point"===t.type)}),(St||Mt)&&d.createElement(it,{width:Rt,height:zt,totalWidth:C[0],totalHeight:C[1],margin:Ot,dimension:null!==(o=null==St?void 0:St.dimension)&&void 0!==o?o:"xy",scales:Ht,onBrush:null!=Mt?Mt:()=>{}}),(null==_t?void 0:_t.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===_t.badgePosition?{top:4,left:4}:"bottom-left"===_t.badgePosition?{bottom:4,left:4}:"bottom-right"===_t.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ut?"#dc3545":"#28a745",color:"white"})},Ut?"STALE":"LIVE"),me)});ot.displayName="StreamXYFrame";const at={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},lt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class st{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var i;for(let o=0;this.capacity>o;o++){const a=this.particles[o];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=r&&null!==(i=r[a.edgeIndex])&&void 0!==i?i:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=ct(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function ct(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const i=t.length,o=e*i,a=Math.min(Math.floor(o),i-1),l=o-a,[s,c,u,h]=t[a],d=ut(s,c,u,h,l),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*r*2,d.y+=t*n*r*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,i,o,a]=t.points,l=ut(r,i,o,a,e),s=a.x-r.x,c=a.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function ut(t,e,n,r,i){const o=1-i,a=o*o,l=a*o,s=i*i,c=s*i;return{x:l*t.x+3*a*i*e.x+3*o*s*n.x+c*r.x,y:l*t.y+3*a*i*e.y+3*o*s*n.y+c*r.y}}function ht(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function dt(t,e){var n,r=[],i=[],o=[],a={},l=[];function s(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&s(e)})}function c(t){var e,r,h=!1;for(i.push(t),o[t]=!0,e=0;l[t].length>e;e++)(r=l[t][e])===n?(u(n,i),h=!0):o[r]||(h=c(r));if(h)s(t);else for(e=0;l[t].length>e;e++){var d=a[r=l[t][e]];d||(a[r]=d={}),d[r]=!0}return i.pop(),h}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),i=Array(e),o=Array(e),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,i[s]=!1,o[s]=0,a[s]=-1,l[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=r[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>o[e]){for(var y=o[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,i[g]=!0,u+=1,s.push(g),c.push(g);break}i[g]&&(r[e]=0|Math.min(r[e],r[g])),0>a[g]||l[e].push(a[g])}o[e]=y}else{if(r[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(i[x]=!1,p.push(x),m.push(l[x]),v+=l[x].length,a[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[s];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);d[s]=c}}return{components:h,adjacencyList:d}}(t),i=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;i.length>a;a++)for(var l=0;i[a].length>l;l++)o>i[a][l]&&(o=i[a][l],n=a);var s=i[n];if(!s)return!1;var c=t.map(function(t,e){return-1===s.indexOf(e)?[]:t.filter(function(t){return-1!==s.indexOf(t)})});return{leastVertex:o,adjList:c}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];o[+p]=!1,a[p]={}}c(n),n+=1}else n=d}return r}function ft(t){return t.y0-t.y1>0?"up":"down"}function yt(t,e){return e(t.source)==e(t.target)}function gt(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function pt(t){return t.target.x0-t.source.x1}function mt(t,e){var n=xt(t),r=pt(e)/Math.tan(n);return"up"==ft(t)?t.y1-r:t.y1+r}function vt(t,e){var n=xt(t),r=pt(e)/Math.tan(n);return"up"==ft(t)?t.y1+r:t.y1-r}function xt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function bt(t,e){return e(t)}function kt(t){return Et(t.source)}function wt(t){return Et(t.target)}function Et(t){return(t.y0+t.y1)/2}function At(t){return t.virtual?0:t.value}function St(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!yt(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!yt(t,e)?r+1:r}),n+r}function Mt(t){return t.target.depth}function Lt(t,e){return t.sourceLinks.length?t.depth:e-1}function Pt(t,e){return t.y0-e.y0}function Dt(t,e){return e.y0-t.y0}function _t(t,e){return t.y1-e.y1}function $t(t,e){return e.y1-t.y1}function Tt(t,e){return Wt(t.source,e.source)||t.index-e.index}function Nt(t,e){return Wt(t.target,e.target)||t.index-e.index}function Wt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ct(t,e){return Ot(t)==Ot(e)?"bottom"==t.circularLinkType?Dt(t,e):Pt(t,e):Ot(e)-Ot(t)}function Ot(t){return t.target.column-t.source.column}function Rt(t,e){return zt(t)==zt(e)}function zt(t){return t.y0-t.y1>0?"up":"down"}function It(t,e,n,r,o){let a=t;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var s=i.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=a.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Yt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Yt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,yt(t,e)&&gt(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var i=t.source.column,l=t.circularLinkType,c=a.links.filter(function(t){return t.source.column==i&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Dt:Pt);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),i=t.target.column,(c=a.links.filter(function(t){return t.target.column==i&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?$t:_t),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,i=t.y1,o=(e+r)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(t)}),a}function Yt(t,e,n){t.sort(Ct);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(yt(t,e)&&gt(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var l=r[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Bt(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Bt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function jt(t){return function(){return t}}function Ft(t){return t.index}function Xt(t){return t.nodes}function Ht(t){return t.links}function Gt(t,e,n){var r=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(i){var o=i.length;i.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?St(e,n)-St(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0}),i.forEach(function(e,i){e.depth==r.length-1&&1==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==St(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/o*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+i,e.y1=e.y0+e.value*t.ky)})})}function qt(t,e,n,r,o,a){var l=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=a;c>0;--c)u(s*=.99,n),h();function u(e,n){var r=l.length;l.forEach(function(o){var a=o.length,l=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&St(o,n)>0){var c=i.mean(o.sourceLinks,wt),u=i.mean(o.targetLinks,kt),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-Et(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==a)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(l==r-1&&1==a)o.y0=t.y1/2-(s=o.y1-o.y0)/2,o.y1=t.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var f=i.mean(o.sourceLinks,wt),y=i.mean(o.targetLinks,kt),g=((f&&y?(f+y)/2:f||y)-Et(o))*e;o.y0+=g,o.y1+=g}})})}function h(){l.forEach(function(n){var i,a,l,s=t.y0,c=n.length;for(n.sort(e||Wt),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+r;if((a=s-r-t.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+o-s)>0&&(i.y0-=a,i.y1-=a),s=i.y0})}}function Vt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Nt),t.targetLinks.sort(Tt)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,i=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Zt(){var t=0,e=0,n=1,r=1,o=24,a=8,l=null,s=Ft,c=Lt,u=void 0,h=32,d=2,f=Xt,y=Ht;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=r,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return i.group(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,i=t.target;"object"!=typeof r&&(r=t.source=ht(n,r)),"object"!=typeof i&&(i=t.target=ht(n,i)),r.sourceLinks.push(t),i.targetLinks.push(t)})}(f,s),function(t,e){var n=0;if(null==e){for(var r=[],i=0;t.links.length>i;i++){var o=t.links[i],a=o.source.index,l=o.target.index;r[a]||(r[a]=[]),r[l]||(r[l]=[]),-1===r[a].indexOf(l)&&r[a].push(l)}var s=dt(r);s.sort(function(t,e){return t.length-e.length});var c={};for(i=0;s.length>i;i++){var u=s[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(f,u),function(t,e){var n=0,r=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:r>n?"top":"bottom","top"==i.circularLinkType?n++:r++,t.nodes.forEach(function(t){bt(t,e)!=bt(i.source,e)&&bt(t,e)!=bt(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),yt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(i.sum(t.sourceLinks,At),i.sum(t.targetLinks,At)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,n){var r,i,o;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var a=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==l?a:a+1,l=e(t)==l?l:e(t),t.column=a})}for(r=t.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(r=t.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,o):t.column})}(f,u,c);var y=a;if(null!==l){var g=i.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=i.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(r-e)*l/(p-1)))}(function(t,e,n){var r=i.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=i.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/i.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=i.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/a),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,y,o),Gt(f,u,s),qt(f,u,s,y,y,h),Vt(f),It(f,s,d,10,8),Gt(f,u,s),qt(f,u,s,y,y,h),Vt(f),It(f,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return bt(n.source,e)==bt(t,e)}),i=r.length;i>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Rt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=mt(e,t);return t.y1-n}if(e.target.column>t.target.column)return mt(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;i>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return bt(n.target,e)==bt(t,e)}),i=r.length;i>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Rt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=vt(e,t);return t.y0-n}if(e.source.column>t.source.column)return vt(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;i>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var a=i.min(e,function(t){return t.y0}),l=i.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-a);function c(e){return(e-a)/(l-a)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(f),It(f,s,d,10,8)}(g),g}return g.update=function(t){return Vt(t),It(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(a=+t,g):a},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:jt(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:jt(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:jt(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:jt(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],r=+i[1][1],g):[[t,e],[n,r]]},g.size=function(i){return arguments.length?(t=e=0,n=+i[0],r=+i[1],g):[n-t,r-e]},g}const Kt=t=>{let e,n,r,i,o,l,s,c,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,o=t.source.y1,l=t.target.y0,s=a.interpolateNumber(o,l),c=s(.5),u=s(.5),`M${e},${o}C${e},${c} ${n},${u} ${n},${l}L${r},${l}C${r},${u} ${i},${c} ${i},${o}Z`):(e=t.source.x1,n=t.target.x0,s=a.interpolateNumber(e,n),r=s(.5),i=s(.5),o=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${i},${l} ${n},${l}L${n},${c}C${i},${c} ${r},${u} ${e},${u}Z`)};function Ut(t){var e;const n=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,r=i.sourceY,o=i.targetX,a=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${e},${r-n}L${e+l},${r-n}L${e+l},${r+n}L${e},${r+n}ZM${o},${a-n}L${o-s},${a-n}L${o-s},${a+n}L${o},${a+n}Z`}const o=i.sourceX,a=i.sourceY,l=i.targetX,s=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,h=i.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${o},${a-d*n}L${c},${a-d*n}L${c+r},${a-d*n+d*f}L${c+r},${h+d*r-d*f}L${c+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${s-d*n+d*f}L${u-r+f},${s-d*n}L${l},${s-d*n}L${l},${s+d*n}L${u},${s+d*n}L${u},${h-d*r}L${c},${h-d*r}L${c},${a+d*n}L${o},${a+d*n}Z`}const Qt={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Mt))-1:0},justify:Lt},Jt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var i,o,a,l,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,y=null!==(o=n.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=n.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=Zt().extent(v).links(m).nodes(p).nodeAlign(Qt[d]||Lt).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>i&&(i=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(s=null!==(l=r._circularWidth)&&void 0!==l?l:r.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),n>o.verticalFullExtent-a&&(n=o.verticalFullExtent-a),o.verticalFullExtent+a>i&&(i=o.verticalFullExtent+a)}const o=e-t,a=i-n,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>n||e>u||i>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,i=-n*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of m)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,n=t.target,r="object"==typeof e&&null!==e?e.id:e+"",i="object"==typeof n&&null!==n?n.id:n+"",o=k.get(`${r}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(r),n=b.get(i);e&&(o.source=e),n&&(o.target=n)}}},buildScene(t,e,n,r){var i,o,a,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:l.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],v=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=u?u(e):{},i={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r="#999";h?r=h(t).fill||r:"target"===f&&n?r=g.get(n.id)||r:e&&(r=g.get(e.id)||r);const i=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,l=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=i.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+l},${e.sourceY-n}L${e.sourceX+l},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:d,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+l}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:i.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;if(l=t.circular&&t.circularPathData?Ut(t):Kt(t),!l)continue;const c={fill:i.fill||r,fillOpacity:null!==(s=i.fillOpacity)&&void 0!==s?s:d,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};m.push({type:"bezier",pathD:l,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const o=e?e(n):n.id;if(!o)continue;let a,l,s;"down"===c?(a=n.x0+t/2,l=n.y1+14,s="middle"):(r[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+i/2),v.push({x:a,y:l,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}},te={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){var i,o;if(0===t.length)return;const a=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,u=r[1]/2;for(let e=0;t.length>e;e++){const n=t[e];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;n.x=c+t*Math.cos(r),n.y=u+t*Math.sin(r)}}const h=ee(n.nodeSize,n.nodeSizeRange,t),d=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),f=r[1]/r[0],y=s.forceSimulation().force("charge",s.forceManyBody().strength(t=>-25*(t=>h(t))(t))).force("x",s.forceX(r[0]/2).strength(.1*f)).force("y",s.forceY(r[1]/2).strength(.1));if(y.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));y.force("link",d),y.force("link").links(t)}.1>y.alpha()&&y.alpha(1),y.stop();for(let t=0;a>t;++t)y.tick();const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var i,o,a;const s=n.nodeStyle,c=n.edgeStyle,u=ee(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:l.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},r={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=c?c(t):{},i={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:i,datum:t})}if(!1!==n.showLabels){const e=(m=n.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=u(n);g.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ee(t,e,n){var o,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const l=e||[5,20],s=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>l[0];const c=null!==(o=i.min(s))&&void 0!==o?o:0,u=null!==(a=i.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const h=r.scaleLinear().domain([c,u]).range(l).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?l[0]:h(r)}}const ne=l.schemeCategory10,re={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:a}=n,l=Math.min(r[0],r[1])/2,s=l-o,h=r[0]/2,d=r[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),r=g.get(e);if(void 0===n||void 0===r)continue;const i=f(t);m[n][r]=i}const v=c.chord().padAngle(i);a&&v.sortGroups(a);const x=v(m),b=x.groups,k=u.arc().innerRadius(s).outerRadius(l);for(const e of b){const n=t[e.index],r=k.centroid(e);n.x=r[0]+h,n.y=r[1]+d,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);n&&(t.source=n),r&&(t.target=r)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,r=t[e.target.index].id,i=E.get(`${n}\0${r}`)||E.get(`${r}\0${n}`);i&&(i.chordData=e)}},buildScene(t,e,n,r){var i,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(r[0],r[1])/2,u=s-a,h=r[0]/2,d=r[1]/2,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:ne,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=c.ribbon().radius(u),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let o;o=f?f(n).fill||m.get(n.id)||p[e%p.length]:m.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};x.push({type:"arc",cx:h,cy:d,innerR:u,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=v(e);if(!n)continue;const r=ie(n,h,d);let i="#999";if(y)i=y(t).fill||i;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?i=m.get(n.id)||i:e&&(i=m.get(e.id)||i)}const a=y?y(t):{},s={fill:i,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;k.push({x:h+Math.cos(a)*r,y:d+Math.sin(a)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function ie(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const i=[];let o=0;for(;r.length>o;){const t=r[o];if("M"===t||"L"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("C"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;3>t&&r.length>o&&!isNaN(Number(r[o]));t++)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("Q"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;2>t&&r.length>o&&!isNaN(Number(r[o]));t++)i.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("A"===t)for(i.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&(i.push(Number(r[o])+e+""),o++),r.length>o&&(i.push(Number(r[o])+n+""),o++);else"Z"===t||"z"===t?(i.push(t),o++):(i.push(r[o]),o++)}return i.join(" ")}const oe={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var i;const a=n.__hierarchyRoot;if(!a)return;const l=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=o.hierarchy(a,s);h.sum(u),h.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[d,f]=r;switch(l){case"tree":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.tree();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,r){const i=e.treeOrientation||"vertical",a=o.cluster();a.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),a(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,r){var i,a;const l=null!==(i=e.padding)&&void 0!==i?i:4,s=null!==(a=e.paddingTop)&&void 0!==a?a:0,c=o.treemap().size([n,r]).tile(o.treemapBinary).padding(l);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,r){var i;const a=null!==(i=e.padding)&&void 0!==i?i:4;o.pack().size([n,r]).padding(a)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,r){var i;o.partition().size([n,r]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const r=y[e],o={id:ue(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=r.value)&&void 0!==i?i:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?ae(o,r,n):"treemap"===l||"partition"===l?le(o,r):"circlepack"===l&&se(o,r),o.__hierarchyNode=r,t.push(o),g.set(r,o)}if("tree"===l||"cluster"===l)for(const t of y)if(t.parent){const n=g.get(t.parent),r=g.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,i,o){var a,l,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=i(e);let l=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=x[e.depth%x.length]);const s={fill:l,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r=e.x,i=e.y,a=n.x,l=n.y;g&&(r+=p,i+=m,a+=p,l+=m);const u=ce(r,i,a,l,y),h=o(t),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=he(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,i,o,a=n.x,l=n.y;if(g&&(a+=p,l+=m),g){const t=a-p,e=l-m,n=Math.sqrt(t*t+e*e);n>0?(r=a+t/n*10,i=l+e/n*10,o=0>t?"end":"start"):(r=a,i=l-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=a-v-6,o="end"):(r=a+v+6,o="start"),i=l):(r=a,i=l+v+14,o="middle");f.push({x:r,y:i,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,r,i,o);case"treemap":case"partition":return function(t,e,n,r){var i,o;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const l=r(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=he(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,i=r.y1-r.y0;if(0>=t||0>=i)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=n?n(r):r.id;a&&(30>t||16>i||l.push({x:r.x0+t/2,y:r.y0+i/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,i)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,i);case"circlepack":return function(t,e,n,r){var i,o,a,l,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=r(n);let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=he(e.nodeLabel);for(const e of t){const t=null!==(l=e.__radius)&&void 0!==l?l:5,r=n?n(e):e.id;if(!r)continue;if(15>t)continue;const i=!((null===(s=e.data)||void 0===s?void 0:s.children)&&e.data.children.length>0);u.push({x:e.x,y:i?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:i?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:i?void 0:"#000",stroke:i?void 0:"#fff",strokeWidth:i?void 0:3,paintOrder:i?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ae(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function le(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function se(t,e){var n;const r=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function ce(t,e,n,r,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${r} ${n},${r}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+r)/2} T ${n},${r}`}{const i=(e+r)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${r}`}}function ue(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function he(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}const de={sankey:Jt,force:te,chord:re,tree:oe,cluster:oe,treemap:oe,circlepack:oe,partition:oe};function fe(t){return de[t]}class ye{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=t,this.tensionConfig=Object.assign(Object.assign({},at),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new st(2e3))}updateConfig(t){this.config=t,this.tensionConfig=Object.assign(Object.assign({},at),t.tensionConfig),"sankey"===t.chartType&&t.showParticles?this.particlePool||(this.particlePool=new st(2e3)):this.particlePool=null}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:i="source",targetAccessor:o="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:t=>t[r],s="function"==typeof i?i:t=>t[i],c="function"==typeof o?o:t=>t[o],u="function"==typeof a?a:t=>{var e;return null!==(e=t[a])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear();for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},ge(t)),{data:e}))}for(const t of e){const e=s(t)+"",n=c(t)+"",r=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},ge(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},ge(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0,data:t})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,i=0===this.nodes.size;let o=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(e)||(this.nodes.set(e,ge(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,ge(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,o=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);return s?(s.value+=r,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,o=!0),i||o||this.tension>=this.tensionConfig.threshold}runLayout(t){const e=fe(this.config.chartType);if(!e)return;let n=Array.from(this.nodes.values()),r=Array.from(this.edges.values());if(0===n.length&&!e.hierarchical)return;if(this.prepareForRelayout(),e.computeLayout(n,r,this.config,t),e.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const t of n)this.nodes.set(t.id,t);for(const t of r)this.edges.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t)}this.finalizeLayout(),this.saveTargetPositions(),n.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const i=new Set(this.nodes.keys()),o=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of i)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)i.has(t)||this.removedNodes.add(t);for(const t of o)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)o.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=i,this.previousEdgeKeys=o,this.layoutVersion++}buildScene(t){const e=fe(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:o,labels:a}=e.buildScene(n,r,this.config,t);this.sceneNodes=i,this.sceneEdges=o,this.labels=a}advanceTransition(t){if(!this.transition)return!1;const e=Math.min((t-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-e,3);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0+(t._targetX0-t._prevX0)*n,t.x1=t._prevX1+(t._targetX1-t._prevX1)*n,t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n);for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0+(t._targetY0-t._prevY0)*n,t.y1=t._prevY1+(t._targetY1-t._prevY1)*n,t.sankeyWidth=t._prevSankeyWidth+(t._targetSankeyWidth-t._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const r=(t.sankeyWidth||1)/2;if("down"===t.direction){const i=e.y1,o=n.y0,l=a.interpolateNumber(i,o);return{circular:!1,points:[{x:t.y0,y:i},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:o}],halfWidth:r}}const i=e.x1,o=n.x0,l=a.interpolateNumber(i,o);return{circular:!1,points:[{x:i,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:o,y:t.y1}],halfWidth:r}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const i=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],o=n.x-e.x,a=n.y-e.y;i.push([e,{x:e.x+o/3,y:e.y+a/3},{x:e.x+2*o/3,y:e.y+2*a/3},n])}return{circular:!0,segments:i,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,r,i,o;const a=this.config.pulse;if(!a)return;const l=null!==(e=a.duration)&&void 0!==e?e:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=a.glowRadius)&&void 0!==r?r:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const i=t-r;l>i&&(e._pulseIntensity=1-i/l,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const r="object"==typeof n.source?null===(i=n.source)||void 0===i?void 0:i.id:n.source,a="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!r||!a)continue;const c=this.edgeTimestamps.get(`${r}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,r,i;const o=this.config.decay;if(!o)return;const a=null!==(t=o.minOpacity)&&void 0!==t?t:.1,l=this.nodeTimestamps.size;if(1>=l)return;const s=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]),c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const h=l-1-u;let d;switch(o.type){case"linear":d=a+(1-h/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:l/2;d=a+Math.pow(.5,h/t)*(1-a);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*l)>h?1:a;break;default:d=1}const f=null!==(i=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,r),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const r=this.config.thresholds;if(!r)return;const i=null!==(e=r.warningColor)&&void 0!==e?e:"#f59e0b",o=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=r.metric(l);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=i):c=o,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),a&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function ge(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function pe(t,e,n,r,i=30){let o=null,a=i,l=1/0;for(const e of t){const t=me(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(o=t,l=n)}else a>t.distance&&(o=t,a=t.distance)}if(o)return o;for(const t of e){const e=ve(t,n,r);e&&a>e.distance&&(o=e,a=e.distance)}return o}function me(t,e,n){switch(t.type){case"circle":return function(t,e,n){const r=e-t.cx,i=n-t.cy,o=Math.sqrt(r*r+i*i);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){return t.x>e||e>t.x+t.w||t.y>n||n>t.y+t.h?null:{type:"node",datum:t.datum,x:t.x+t.w/2,y:t.y+t.h/2,distance:0}}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,i=n-t.cy,o=Math.sqrt(r*r+i*i);if(t.innerR-2>o||o>t.outerR+2)return null;let a=Math.atan2(i,r);0>a&&(a+=2*Math.PI);let l,s=t.startAngle,c=t.endAngle;if(0>s&&(s+=2*Math.PI),0>c&&(c+=2*Math.PI),l=s>c?a>=s||c>=a:a>=s&&c>=a,l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}function ve(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,i;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(o,e,n)){const o="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,a="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:o&&a?(o.x1+a.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,i=t.y2-t.y1,o=r*r+i*i;if(0===o)return null;let a=((e-t.x1)*r+(n-t.y1)*i)/o;a=Math.max(0,Math.min(1,a));const l=t.x1+a*r,s=t.y1+a*i,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0}}catch(t){}return null}(t,e,n);default:return null}}function xe(t){const{width:e,height:n,totalWidth:r,totalHeight:i,margin:o,labels:a,title:l,legend:s,foregroundGraphics:c,annotations:u,svgAnnotationRules:h}=t;return d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${o.left},${o.top})`},a.map((t,e)=>d.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),u&&h&&u.map((t,r)=>{const i=h(t,r,{width:e,height:n});return i?d.createElement(d.Fragment,{key:"annotation-"+r},i):null}),c),l&&"string"==typeof l?d.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?d.createElement("foreignObject",{x:0,y:0,width:r,height:o.top},l):null,s&&"object"==typeof s&&"legendGroups"in s?d.createElement("g",{transform:`translate(${r-o.right+10},${o.top})`},s.legendGroups.map((t,e)=>{var n;return d.createElement("g",{key:"legend-group-"+e},null===(n=t.items)||void 0===n?void 0:n.map((t,e)=>d.createElement("g",{key:"legend-item-"+e,transform:`translate(0,${20*e})`},d.createElement("rect",{x:0,y:0,width:12,height:12,fill:t.color,rx:2}),d.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},t.label))))})):s?d.createElement("g",{transform:`translate(${r-o.right+10},${o.top})`},s):null)}function be(t,e){var n,r,i,o,a,l;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const a=e._gradient;if(a){const i=t.createLinearGradient(a.x0,0,a.x1,0),o=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,l=e.style.fill;i.addColorStop(0,1===a.from?l:"transparent"),i.addColorStop(1,1===a.to?l:"transparent"),t.fillStyle=i,t.globalAlpha=o}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(o=null!==(i=e.style.fillOpacity)&&void 0!==i?i:e.style.opacity)&&void 0!==o?o:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(a=e.style.strokeWidth)&&void 0!==a?a:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(s)),t.restore()}function ke(t,e){var n,r;t.save(),t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(r=e.style.strokeWidth)&&void 0!==r?r:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function we(t,e){var n,r,i,o;if(!e.pathD)return;t.save();const a=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,t.fill(a)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(i=e.style.strokeWidth)&&void 0!==i?i:.5,t.globalAlpha=.3*(null!==(o=e.style.opacity)&&void 0!==o?o:1),t.stroke(a)),t.restore()}function Ee(t,e){var n,r;if(!e.pathD)return;t.save();const i=new Path2D(e.pathD);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(i),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.1,t.fill(i)),t.restore()}xe.displayName="NetworkSVGOverlay";const Ae=l.schemeCategory10,Se={top:20,right:80,bottom:20,left:80},Me={top:40,right:40,bottom:40,left:40},Le=new Set(["chord","force","circlepack"]),Pe=[800,600],De={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 _e({data:t}){var e,n,r,i,o,a;if("edge"===t.type){const e=t.data;return d.createElement("div",{className:"semiotic-tooltip",style:De},d.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let o=s;for(;o;){const a=null!==(i=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(r=o.data)||void 0===r?void 0:r.id)&&void 0!==i?i:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return d.createElement("div",{className:"semiotic-tooltip",style:De},d.createElement("div",null,t.map((t,e)=>d.createElement("span",{key:e},e>0&&d.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===a?d.createElement("strong",null,t):d.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(o=l.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return d.createElement("div",{className:"semiotic-tooltip",style:De},d.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&d.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const $e=t.forwardRef(function(e,n){const{chartType:r,nodes:i,edges:o,data:a,initialEdges:l,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:h="value",childrenAccessor:f,hierarchySum:y,orientation:g="horizontal",nodeAlign:p="justify",nodePaddingRatio:m=.05,nodeWidth:v=15,iterations:x=300,forceStrength:b=.1,padAngle:k=.01,groupWidth:w=20,sortGroups:E,edgeSort:A,treeOrientation:S="vertical",edgeType:M="curve",padding:L,paddingTop:P,tensionConfig:D,showParticles:_=!1,particleStyle:$,nodeStyle:T,edgeStyle:N,colorBy:W,colorScheme:C="category10",edgeColorBy:O="source",edgeOpacity:R=.5,colorByDepth:z=!1,nodeSize:I=8,nodeSizeRange:Y=[5,20],nodeLabel:B,showLabels:j=!0,size:F=Pe,margin:X,className:H,background:G,enableHover:q=!0,tooltipContent:V,customHoverBehavior:Z,customClickBehavior:K,onObservation:U,chartId:Q,onTopologyChange:J,annotations:tt,svgAnnotationRules:et,legend:nt,title:rt,foregroundGraphics:it,backgroundGraphics:ot,decay:st,pulse:ct,staleness:ut,thresholds:ht}=e,dt=Le.has(r)?Me:Se,ft=Object.assign(Object.assign({},dt),X),yt=F[0]-ft.left-ft.right,gt=F[1]-ft.top-ft.bottom,pt=t.useMemo(()=>Object.assign(Object.assign({},at),D),[D]),mt=t.useMemo(()=>Object.assign(Object.assign({},lt),$),[$]),vt=t.useMemo(()=>({chartType:r,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:u,valueAccessor:h,childrenAccessor:f,hierarchySum:y,orientation:g,nodeAlign:p,nodePaddingRatio:m,nodeWidth:v,iterations:x,forceStrength:b,padAngle:k,groupWidth:w,sortGroups:E,edgeSort:A,treeOrientation:S,edgeType:M,padding:L,paddingTop:P,tensionConfig:pt,showParticles:_,particleStyle:mt,nodeStyle:T,edgeStyle:N,nodeLabel:B,showLabels:j,colorBy:W,colorScheme:C,edgeColorBy:O,edgeOpacity:R,colorByDepth:z,nodeSize:I,nodeSizeRange:Y,decay:st,pulse:ct,staleness:ut,thresholds:ht}),[r,s,c,u,h,f,y,g,p,m,v,x,b,k,w,E,A,S,M,L,P,pt,_,mt,T,N,B,j,W,C,O,R,z,I,Y,st,ct,ut,ht]),xt=t.useRef(null),bt=t.useRef(0),kt=t.useRef(0),wt=t.useRef(!0),Et=t.useRef(()=>{}),At=t.useRef(null);At.current||(At.current=new ye(vt));const[St,Mt]=t.useState(null),[Lt,Pt]=t.useState(0),[Dt,_t]=t.useState(0),[$t,Tt]=t.useState(!1),Nt=t.useRef(null),Wt=t.useRef(new Map),Ct=t.useRef(0),Ot=t.useCallback(t=>{if("function"==typeof W)return W(t);if("string"==typeof W&&t.data){const e=t.data[W];if(void 0!==e){if(!Wt.current.has(e+"")){const t=Array.isArray(C)?C:Ae;Wt.current.set(e+"",t[Ct.current++%t.length])}return Wt.current.get(e+"")}}if(!Wt.current.has(t.id)){const e=Array.isArray(C)?C:Ae;Wt.current.set(t.id,e[Ct.current++%e.length])}return Wt.current.get(t.id)},[W,C]),Rt=t.useCallback(t=>{if("function"==typeof O)return O(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===O&&n?Ot(n):e?Ot(e):"#999"},[O,Ot]),zt=t.useCallback(t=>{if(!(null==$?void 0:$.colorBy))return Rt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===mt.colorBy&&n?Ot(n):e?Ot(e):"#999"},[null==$?void 0:$.colorBy,mt.colorBy,Ot,Rt]),It="sankey"===r&&_||!!ct,Yt=t.useCallback(()=>{bt.current&&!It||bt.current||(bt.current=requestAnimationFrame(()=>Et.current()))},[It]);t.useEffect(()=>{var t;null===(t=At.current)||void 0===t||t.updateConfig(vt),wt.current=!0,Yt()},[vt,Yt]);const Bt=t.useCallback(()=>{const t=At.current;if(!t)return;t.runLayout([yt,gt]),t.buildScene([yt,gt]),wt.current=!0;const e=Array.isArray(C)?C:Ae,n=Array.from(t.nodes.values());for(let t=0;n.length>t;t++){const r=n[t];Wt.current.has(r.id)||Wt.current.set(r.id,e[t%e.length])}if(Ct.current=n.length,Pt(t.layoutVersion),J){const{nodes:e,edges:n}=t.getLayoutData();J(e,n)}},[yt,gt,J,C]),jt=t.useCallback(t=>{const e=At.current;e&&(e.ingestEdge(t)&&Bt(),Yt())},[Bt,Yt]),Ft=t.useCallback(t=>{const e=At.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Bt(),Yt()},[Bt,Yt]),Xt=t.useCallback(()=>{var t;null===(t=At.current)||void 0===t||t.clear(),Wt.current.clear(),Ct.current=0,Pt(0),Mt(null),Nt.current=null,wt.current=!0,Yt()},[Yt]),Ht=t.useCallback(()=>{const t=At.current;t&&(t.tension+=999,Bt(),Yt())},[Bt,Yt]);t.useImperativeHandle(n,()=>({push:jt,pushMany:Ft,clear:Xt,getTopology:()=>{var t,e;return null!==(e=null===(t=At.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=At.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Ht,getTension:()=>{var t,e;return null!==(e=null===(t=At.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[jt,Ft,Xt,Ht]);const Gt=["tree","cluster","treemap","circlepack","partition"].includes(r),qt=Gt?a||(Array.isArray(o)?void 0:o):void 0;t.useEffect(()=>{const t=At.current;if(t)if(Gt&&qt)t.ingestHierarchy(qt,[yt,gt]),t.buildScene([yt,gt]),wt.current=!0,Yt();else{const e=i||[],n=Array.isArray(o)?o:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[yt,gt]),t.buildScene([yt,gt]);const r=Array.isArray(C)?C:Ae,a=Array.from(t.nodes.values());for(let t=0;a.length>t;t++){const e=a[t];Wt.current.has(e.id)||Wt.current.set(e.id,r[t%r.length])}Ct.current=a.length,wt.current=!0,Yt()}},[i,o,a,qt,Gt,yt,gt,vt,Yt,C]),t.useEffect(()=>{l&&l.length>0&&Ft(l)},[]);const Vt=t.useCallback(t=>{if(Z&&Z(t),U){const e=Date.now();U(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Q}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Q})}},[Z,U,Q]),Zt=t.useCallback(t=>{if(K&&K(t),U){const e=Date.now();U(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:Q}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:Q})}},[K,U,Q]),Kt=t.useRef(()=>{}),Ut=t.useRef(()=>{});Kt.current=t=>{if(!q)return;const e=xt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ft.left,i=t.clientY-n.top-ft.top;if(0>r||r>yt||0>i||i>gt)return void(Nt.current&&(Nt.current=null,Mt(null),Vt&&Vt(null),Yt()));const o=At.current;if(!o)return;const a=pe(o.sceneNodes,o.sceneEdges,r,i);if(!a)return void(Nt.current&&(Nt.current=null,Mt(null),Vt&&Vt(null),Yt()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};Nt.current=l,Mt(l),Vt&&Vt(l),Yt()},Ut.current=()=>{Nt.current&&(Nt.current=null,Mt(null),Vt&&Vt(null),Yt())};const Qt=t.useRef(()=>{});Qt.current=t=>{if(!K&&!U)return;const e=xt.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ft.left,i=t.clientY-n.top-ft.top;if(0>r||r>yt||0>i||i>gt)return;const o=At.current;if(!o)return;const a=pe(o.sceneNodes,o.sceneEdges,r,i);Zt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)};const Jt=t.useCallback(t=>Kt.current(t),[]),te=t.useCallback(()=>Ut.current(),[]),ee=t.useCallback(t=>Qt.current(t),[]);Et.current=()=>{var t,e,n;bt.current=0;const r=xt.current;if(!r)return;const i=r.getContext("2d");if(!i)return;const o=At.current;if(!o)return;const a=performance.now(),l=kt.current?Math.min((a-kt.current)/1e3,.1):.016;kt.current=a;const s=o.advanceTransition(a);(s||wt.current)&&o.buildScene([yt,gt]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;r.width=F[0]*c,r.height=F[1]*c,r.style.width=F[0]+"px",r.style.height=F[1]+"px",i.scale(c,c),i.translate(ft.left,ft.top),i.clearRect(-ft.left,-ft.top,F[0],F[1]),G&&(i.fillStyle=G,i.fillRect(0,0,yt,gt)),st&&o.applyDecay(),ct&&o.applyPulse(a),ht&&o.applyThresholds(a),o.applyTopologyDiff(a);const u=null!==(t=null==ut?void 0:ut.threshold)&&void 0!==t?t:5e3,h=ut&&o.lastIngestTime>0&&a-o.lastIngestTime>u;if(h&&(i.globalAlpha=null!==(e=null==ut?void 0:ut.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":be(t,n);break;case"line":ke(t,n);break;case"ribbon":we(t,n);break;case"curved":Ee(t,n)}}(i,o.sceneEdges),function(t,e){var n,r,i;for(const o of e){if("rect"!==o.type)continue;const e=o;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.strokeRect(e.x,e.y,e.w,e.h)),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.restore())}}(i,o.sceneNodes),function(t,e){var n,r,i,o;for(const a of e){if("circle"!==a.type)continue;const e=a;if(e.r>0){if(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,r=e.r+n*e._pulseIntensity;t.beginPath(),t.arc(e.cx,e.cy,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.6*e._pulseIntensity,t.stroke()}t.restore()}}}(i,o.sceneNodes),function(t,e){var n,r,i;for(const o of e){if("arc"!==o.type)continue;const e=o;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(i=e.style.opacity)&&void 0!==i?i:1,t.stroke()),t.restore()}}(i,o.sceneNodes),_&&o.particlePool&&!h){const t=Array.from(o.edges.values());if(t.length>0){!function(t,e,n,r){var i,o;const a=null!==(i=r.spawnRate)&&void 0!==i?i:lt.spawnRate,l=null!==(o=r.maxPerEdge)&&void 0!==o?o:lt.maxPerEdge;for(let r=0;e.length>r;r++){const i=e[r];if(!i.bezier)continue;if(t.countForEdge(r)>=l)continue;const o=i.value*a*n*(i.bezier.circular?.3:1),s=Math.floor(o),c=o-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<l;e++)t.spawn(r)}}(o.particlePool,t,l,mt);const e=.5*(null!==(n=mt.speedMultiplier)&&void 0!==n?n:1);let r;if(mt.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}o.particlePool.step(l,e,t,r),function(t,e,n,r,i){var o,a;const l=null!==(o=r.radius)&&void 0!==o?o:lt.radius,s=null!==(a=r.opacity)&&void 0!==a?a:lt.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const a=e.particles[o];if(!a.active)continue;const s=n[a.edgeIndex];if(s){if("function"==typeof r.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?r.color(s,e):"#666"}else t.fillStyle=r.color&&"inherit"!==r.color?r.color:i(s);t.beginPath(),t.arc(a.x,a.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(i,o.particlePool,t,mt,zt)}}h&&(i.globalAlpha=1);const d=wt.current;wt.current=!1,(d||s)&&_t(t=>t+1),(It||s||o.hasActivePulses||o.hasActiveThresholds||o.hasActiveTopologyDiff)&&(bt.current=requestAnimationFrame(()=>Et.current()))},t.useEffect(()=>(Yt(),()=>{bt.current&&cancelAnimationFrame(bt.current)}),[Yt]),t.useEffect(()=>{wt.current=!0,Yt()},[r,yt,gt,G,Yt]),t.useEffect(()=>{if(!ut)return;const t=setInterval(()=>{var t;const e=At.current;if(!e||0===e.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=ut.threshold)&&void 0!==t?t:5e3,i=n-e.lastIngestTime>r;i!==$t&&(Tt(i),wt.current=!0,Yt())},1e3);return()=>clearInterval(t)},[ut,$t,Yt]);const ne=q&&St?d.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ft.left+St.x,top:ft.top+St.y,transform:`translate(${St.x>.6*yt?"calc(-100% - 12px)":"12px"}, ${.3*gt>St.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},V?V(St):d.createElement(_e,{data:St})):null,re=At.current;return d.createElement("div",{className:"stream-network-frame"+(H?" "+H:""),role:"img","aria-label":"string"==typeof rt?rt:"Network chart",style:{position:"relative",width:F[0],height:F[1]},onMouseMove:q?Jt:void 0,onMouseLeave:q?te:void 0,onClick:K||U?ee:void 0},ot&&d.createElement("svg",{style:{position:"absolute",top:0,left:0,width:F[0],height:F[1],pointerEvents:"none"}},d.createElement("g",{transform:`translate(${ft.left},${ft.top})`},ot)),d.createElement("canvas",{ref:xt,style:{position:"absolute",top:0,left:0}}),d.createElement(xe,{width:yt,height:gt,totalWidth:F[0],totalHeight:F[1],margin:ft,labels:(null==re?void 0:re.labels)||[],title:rt,legend:nt,foregroundGraphics:it,annotations:tt,svgAnnotationRules:et,annotationFrame:Dt}),ne,(null==ut?void 0:ut.showBadge)&&d.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ut.badgePosition?{top:4,left:4}:"bottom-left"===ut.badgePosition?{bottom:4,left:4}:"bottom-right"===ut.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:$t?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},$t?"STALE":"LIVE"))});function Te(e){const n=t.createContext(null),r=Ne(e);return[function({children:r}){const i=t.useMemo(()=>Ne(e),[]);return d.createElement(n.Provider,{value:i,children:r})},e=>{var i;const o=null!==(i=t.useContext(n))&&void 0!==i?i:r;return function(e,n){const[r,i]=t.useState(n);return t.useLayoutEffect(()=>e(()=>i(n)),[e]),r}(o.subscribe,()=>e(o.getState()))}]}function Ne(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}function We(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,i]=r.range;e.push(e=>{const r=e[n];return r>=t&&i>=r})}return t=>e.every(e=>e(t))}function Ce(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}$e.displayName="StreamNetworkFrame";const[Oe,Re]=Te(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),i=Ce(r,e),o=new Map(i.clauses);return o.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r)return{};const i=new Map(t.selections),o=new Map(r.clauses);return o.delete(n),i.set(e,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},setResolution(e,n){t(t=>{const r=new Map(t.selections),i=Ce(r,e);return r.set(e,Object.assign(Object.assign({},i),{resolution:n})),{selections:r}})},clearSelection(e){t(t=>{const n=new Map(t.selections),r=n.get(e);return r&&n.set(e,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}}));function ze(e){const n=t.useId(),r=e.clientId||n,{name:i}=e,o=Re(t=>t.selections.get(i)),a=Re(t=>t.setClause),l=Re(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,i]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(We(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,r):()=>!0,[o,r]),isActive:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};a(i,{clientId:r,type:"point",fields:e})},[r,i,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};a(i,{clientId:r,type:"interval",fields:e})},[r,i,a]),clear:t.useCallback(()=>{l(i,r)},[l,i,r]),clientId:r}}const[Ie,Ye]=Te(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Be({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:i=!1,onObservation:o,chartType:a,chartId:l}){const s=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields}:null}(n,r),c=ze({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:i,isActive:o,selectPoints:a,clear:l}=ze({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of r){const r=t[n];void 0!==r&&(e[n]=[r])}Object.keys(e).length>0&&a(e)},[r,a,l]),predicate:i,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||[]}),h=Ye(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,r;if(n){let e=t&&(t.data||t.datum)||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},r),{type:"click",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},r),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const je={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 Fe(t,e,n){var r,i,o,a,l,s;const c=je[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:c.width,height:null!==(i=e.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o:c.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||c.enableHover,showLegend:null!==(l=e.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:c.marginDefaults}}const Xe=t.forwardRef(function(e,n){var r,i,o,a;const l=Fe(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:S,tooltip:M,onHover:L,annotations:P,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:$,decay:T,pulse:N,staleness:W,transition:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,j=null!=s?s:[l.width,l.height],F=null!=S?S:M,X=t.useRef(null),{customHoverBehavior:H}=Be({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:z}),G=t.useCallback(t=>{L&&L(t),H(t)},[L,H]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),d.createElement(ot,{ref:X,chartType:"line",runtimeMode:"streaming",size:j,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,lineStyle:{stroke:k,strokeWidth:w,strokeDasharray:E},showAxes:I,background:A,hoverAnnotation:Y,tooltipContent:F,customHoverBehavior:G,annotations:P,svgAnnotationRules:D,tickFormatTime:_,tickFormatValue:$,decay:T,pulse:N,staleness:W,transition:C})});Xe.displayName="RealtimeLineChart";const He=t.forwardRef(function(e,n){var r,i,o,a;const l=Fe(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:f="right",windowMode:y="sliding",windowSize:g=200,data:p,timeAccessor:m,valueAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:S,strokeWidth:M,gap:L,background:P,tooltipContent:D,tooltip:_,onHover:$,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C,linkedHover:O,decay:R,pulse:z,staleness:I,transition:Y,onObservation:B,chartId:j}=e,F=l.showAxes,X=l.enableHover,H=null!=u?u:l.marginDefaults,G=null!=c?c:[l.width,l.height],q=null!=D?D:_,V=t.useRef(null),{customHoverBehavior:Z}=Be({linkedHover:O,unwrapData:!0,onObservation:B,chartType:"RealtimeTemporalHistogram",chartId:j}),K=t.useCallback(t=>{$&&$(t),Z(t)},[$,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=V.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=V.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=V.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=V.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const U={};return null!=A&&(U.fill=A),null!=S&&(U.stroke=S),null!=M&&(U.strokeWidth=M),null!=L&&(U.gap=L),d.createElement(ot,{ref:V,chartType:"bar",runtimeMode:"streaming",size:G,margin:H,className:h,arrowOfTime:f,windowMode:y,windowSize:g,data:p,timeAccessor:m,valueAccessor:v,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:U,showAxes:F,background:P,hoverAnnotation:X,tooltipContent:q,customHoverBehavior:K,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C,decay:R,pulse:z,staleness:I,transition:Y})});He.displayName="RealtimeTemporalHistogram";const Ge=He,qe=t.forwardRef(function(e,n){var r,i,o,a;const l=Fe(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:_,onHover:$,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,j=null!=s?s:[l.width,l.height],F=null!=D?D:_,X=t.useRef(null),{customHoverBehavior:H}=Be({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:z}),G=t.useCallback(t=>{$&&$(t),H(t)},[$,H]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const q={};return null!=E&&(q.radius=E),null!=A&&(q.fill=A),null!=S&&(q.opacity=S),null!=M&&(q.stroke=M),null!=L&&(q.strokeWidth=L),d.createElement(ot,{ref:X,chartType:"swarm",runtimeMode:"streaming",size:j,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:q,showAxes:I,background:P,hoverAnnotation:Y,tooltipContent:F,customHoverBehavior:G,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C})});qe.displayName="RealtimeSwarmChart";const Ve=t.forwardRef(function(e,n){var r,i,o,a;const l=Fe(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,timeExtent:v,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:S,stroke:M,strokeWidth:L,background:P,tooltipContent:D,tooltip:_,onHover:$,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,j=null!=s?s:[l.width,l.height],F=null!=D?D:_,X=t.useRef(null),{customHoverBehavior:H}=Be({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:z}),G=t.useCallback(t=>{$&&$(t),H(t)},[$,H]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const q={};return null!=k&&(q.positiveColor=k),null!=w&&(q.negativeColor=w),null!=E&&(q.connectorStroke=E),null!=A&&(q.connectorWidth=A),null!=S&&(q.gap=S),null!=M&&(q.stroke=M),null!=L&&(q.strokeWidth=L),d.createElement(ot,{ref:X,chartType:"waterfall",runtimeMode:"streaming",size:j,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,xExtent:v,yExtent:x,extentPadding:b,waterfallStyle:q,showAxes:I,background:P,hoverAnnotation:Y,tooltipContent:F,customHoverBehavior:G,annotations:T,svgAnnotationRules:N,tickFormatTime:W,tickFormatValue:C})});Ve.displayName="RealtimeWaterfallChart";const Ze=t.forwardRef(function(e,n){var r,i,o,a;const l=Fe(e.mode,{width:null!==(i=null===(r=e.size)||void 0===r?void 0:r[0])&&void 0!==i?i:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:f="sliding",windowSize:y=200,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:S,tooltipContent:M,tooltip:L,onHover:P,annotations:D,svgAnnotationRules:_,tickFormatTime:$,tickFormatValue:T,decay:N,pulse:W,staleness:C,linkedHover:O,onObservation:R,chartId:z}=e,I=l.showAxes,Y=l.enableHover,B=null!=c?c:l.marginDefaults,j=null!=s?s:[l.width,l.height],F=null!=M?M:L,X=t.useRef(null),{customHoverBehavior:H}=Be({linkedHover:O,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:z}),G=t.useCallback(t=>{P&&P(t),H(t)},[P,H]);return t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=X.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=X.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=X.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}})),d.createElement(ot,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:B,className:u,arrowOfTime:h,windowMode:f,windowSize:y,data:g,timeAccessor:p,valueAccessor:m,categoryAccessor:v,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:I,background:S,hoverAnnotation:Y,tooltipContent:F,customHoverBehavior:G,annotations:D,svgAnnotationRules:_,tickFormatTime:$,tickFormatValue:T,decay:N,pulse:W,staleness:C})});Ze.displayName="RealtimeHeatmap",exports.IncrementalExtent=p,exports.RealtimeHeatmap=Ze,exports.RealtimeHistogram=Ge,exports.RealtimeLineChart=Xe,exports.RealtimeSwarmChart=qe,exports.RealtimeWaterfallChart=Ve,exports.RingBuffer=g,exports.StreamNetworkFrame=$e,exports.StreamXYFrame=ot;