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
package/dist/xy.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-array"),s=require("d3-scale-chromatic"),i=require("labella"),a=require("d3-shape"),l=require("regression"),c=require("d3-contour"),u=require("d3-hexbin");function h(t){return t&&t.__esModule?t:{default:t}}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 o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const f=d(t),p=h(i),y=h(l),m=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,m),bounded:!0,totalSize:t.length});let e=m;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const o=Math.min(e+m,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(t){this.callback({inserts:[t],bounded:!1})}pushMany(t){0!==t.length&&this.callback({inserts:t,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class x{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class b{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,o,r){const s=new Map;for(const i of t){const t=e(i),a=n(i);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=s.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},s.set(l,c)),c.total+=a,r){const t=r(i);c.categories.set(t,(c.categories.get(t)||0)+a)}}return s}function k(t,e,n,o,r,s){const i=[],a=[];for(const r of t){const t=n(r),s=o(r);null==t||null==s||Number.isNaN(t)||Number.isNaN(s)||(i.push([e.x(t),e.y(s)]),a.push(s))}return{type:"line",path:i,rawValues:a,style:r,datum:t,group:s}}function E(t,e,n,o,r,s,i){const a=[],l=[];for(const s of t){const t=n(s),i=o(s);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const c=e.x(t);a.push([c,e.y(i)]),l.push([c,e.y(r)])}return{type:"area",topPath:a,bottomPath:l,style:s,datum:t,group:i}}function w(t,e,n,o,r,s){const i=n(t),a=o(t);return null==i||null==a||Number.isNaN(i)||Number.isNaN(a)?null:{type:"point",x:e.x(i),y:e.y(a),r:r,style:s,datum:t}}function M(t,e,n,o,r,s,i){return{type:"rect",x:t,y:e,w:n,h:o,style:r,datum:s,group:i}}function A(t,e,n,o,r,s){return{type:"heatcell",x:t,y:e,w:n,h:o,fill:r,datum:s}}function S(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function $(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}class P{constructor(t){this.xExtent=new b,this.yExtent=new b,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new x(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=S(t.timeAccessor||t.xAccessor,"time"),this.getY=S(t.valueAccessor||t.yAccessor,"value")):(this.getX=S(t.xAccessor,"x"),this.getY=S(t.yAccessor,"y")),this.getGroup=$(t.groupAccessor),this.getCategory=$(t.categoryAccessor),this.getSize=t.sizeAccessor?S(t.sizeAccessor,"size"):void 0,this.getColor=$(t.colorAccessor),this.getBounds=t.boundsAccessor?S(t.boundsAccessor,"bounds"):void 0,"candlestick"===t.chartType&&(this.getOpen=S(t.openAccessor,"open"),this.getHigh=S(t.highAccessor,"high"),this.getLow=S(t.lowAccessor,"low"),this.getClose=S(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new x(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,r,s,i,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!==(r=l.yExtent[0])&&void 0!==r?r:h[0],null!==(s=l.yExtent[1])&&void 0!==s?s:h[1]]:h;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&c.size>0)if(l.normalize)f=[0,1+l.extentPadding];else{const 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),o=this.getY(e);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||n.set(t,(n.get(t)||0)+o)}let o=0;for(const t of n.values())t>o&&(o=t);f=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!p&&c.size>0){const[,t]=function(t,e,n,o,r){const s=v(t,e,n,o,r);if(0===s.size)return[0,0];let i=0;for(const t of s.values())t.total>i&&(i=t.total);return[0,i]}(c,this.getX,this.getY,l.binSize,this.getCategory);f=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!p&&c.size>0){const[t,e]=function(t,e){let n=0,o=0,r=0;for(const s of t){const t=e(s);null==t||Number.isNaN(t)||(r+=t,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(c,this.getY),n=e-t,o=n>0?n*l.extentPadding:1;f=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!p&&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===(i=l.yExtent)||void 0===i?void 0:i[0],o=null===(a=l.yExtent)||void 0===a?void 0:a[1];f=[null!=n?f[0]:f[0]-e,null!=o?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"===(y=l.arrowOfTime)||"down"===y?"y":"x")){const e="right"===l.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:o.scaleLinear().domain(d).range(e),y:o.scaleLinear().domain(f).range([t.height,0])}}else{const e="down"===l.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:o.scaleLinear().domain(f).range([0,t.width]),y:o.scaleLinear().domain(d).range(e)}}else this.scales={x:o.scaleLinear().domain(d).range([0,t.width]),y:o.scaleLinear().domain(f).range([t.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const m=c.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(e.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,t);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,t);case"candlestick":return this.buildCandlestickScene(r,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),o=[],r=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&o.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=k(t.data,this.scales,this.getX,this.getY,e,t.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(t){const e=this.groupData(t),n=[],o=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]);n.push(E(t.data,this.scales,this.getX,this.getY,o,e,t.key))}return n}buildStackedAreaScene(t){return function(t,e,n,o,r,s){var i;const a=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||a.add(e)}const l=Array.from(a).sort((t,e)=>t-e),c=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=n(r),s=o(r);null==e||null==s||Number.isNaN(e)||Number.isNaN(s)||t.set(e,(t.get(e)||0)+s)}c.set(e.key,t)}let u;if(s){u=new Map;for(const e of l){let n=0;for(const o of t)n+=(null===(i=c.get(o.key))||void 0===i?void 0:i.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),o=[],i=[];for(const n of l){let r=t.get(n)||0;const a=d.get(n);s&&(r/=u.get(n));const l=e.x(n);i.push([l,e.y(a)]),o.push([l,e.y(a+r)]),d.set(n,a+r)}h.push({type:"area",topPath:o,bottomPath:i,style:r(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,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),n=Math.max(...e);r=e=>t===n?(o[0]+o[1])/2:o[0]+(e-t)/(n-t)*(o[1]-o[0])}}let s=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"];s=new Map;let o=0;for(const t of e)s.set(t,n[o%n.length]),o++}for(const o of t){let t=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},i=t.r||n;if(r&&this.getSize){const t=this.getSize(o);null==t||Number.isNaN(t)||(i=r(t))}if(s&&this.getColor){const e=this.getColor(o);e&&s.has(e)&&(t=Object.assign(Object.assign({},t),{fill:s.get(e)}))}const a=w(o,this.scales,this.getX,this.getY,i,t);a&&e.push(a)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const o=S(this.config.valueAccessor,"value"),r=new Set,s=new Set;for(const e of t)r.add(this.getX(e)),s.add(this.getY(e));const i=Array.from(r).sort((t,e)=>t-e),a=Array.from(s).sort((t,e)=>t-e);if(0===i.length||0===a.length)return n;const l=e.width/i.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:o(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;i.length>t;t++)for(let e=0;a.length>e;e++){const o=u.get(`${i[t]}_${a[e]}`);if(!o)continue;const r=(o.val-h)/f;n.push(A(t*l,(a.length-1-e)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(t,e){var n,o,r;const s=[],i=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=S(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return s;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),p=(h-u||1)/i,y=(f-d||1)/a,m=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),o=Math.min(Math.floor((t-u)/p),i-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const s=`${o}_${r}`;let l=m.get(s);l||(l={sum:0,count:0,data:[]},m.set(s,l)),l.count++,l.sum+=c(e),l.data.push(e)}let g=1/0,x=-1/0;const b=new Map;for(const[t,e]of m){let n;switch(l){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}b.set(t,n),g>n&&(g=n),n>x&&(x=n)}const v=x-g||1,k=e.width/i,E=e.height/a;for(const[t,e]of b){const[n,o]=t.split("_"),r=+n,i=+o,l=(e-g)/v,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=m.get(t);s.push(A(r*k,(a-1-i)*E,k,E,c,{xi:r,yi:i,value:e,count:u.count,sum:u.sum,data:u.data}))}return s}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 o=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(e),s=Array.from(t).filter(t=>!r.has(t)).sort();o=[...e.filter(e=>t.has(e)),...s]}const r=[],s=this.scales,[i,a]=s.x.domain();for(const t of n.values()){const n=Math.max(t.start,i),l=Math.min(t.end,a);if(n>=l)continue;const c=s.x(n),u=s.x(l),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(o&&t.categories.size>0){let n=0;for(const i of o){const o=t.categories.get(i)||0;if(0===o)continue;const a=s.y(n),l=s.y(n+o);r.push(M(h,Math.min(a,l),d,Math.abs(a-l),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[i])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:o},i)),n+=o}}else{const e=s.y(0),n=s.y(t.total);r.push(M(h,Math.min(e,n),d,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return r}buildSwarmScene(t){var e,n,o,r;const s=[],i=this.config.swarmStyle||{},a=null!==(e=i.radius)&&void 0!==e?e:3,l=null!==(n=i.fill)&&void 0!==n?n:"#007bff",c=null!==(o=i.opacity)&&void 0!==o?o:.7,u=i.stroke,h=i.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(t),i=this.scales.y(n);let d=l;if(this.getCategory){const t=this.getCategory(e);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[t])||d}s.push({type:"point",x:o,y:i,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e})}return s}buildWaterfallScene(t,e){const n=[],o=this.scales,r=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===r.length)return n;let s=0;for(let t=0;r.length>t;t++){const i=r[t],a=this.getX(i),l=this.getY(i),c=s+l;let u;u=r.length-1>t?this.getX(r[t+1])-a:t>0?a-this.getX(r[t-1]):0;const h=o.x(a),d=0!==u?o.x(a+u):h+e.width/10,f=Math.min(h,d)+.5,p=Math.max(h,d)-.5-f;if(0>=p){s=c;continue}const y=o.y(s),m=o.y(c);n.push(M(f,Math.min(y,m),p,Math.abs(y-m),{fill:0>l?"#dc3545":"#28a745"},Object.assign(Object.assign({},i),{baseline:s,cumEnd:c,delta:l}))),s=c}return n}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",s=o.downColor||"#dc3545",i=o.wickColor||"#333",a=o.wickWidth||1,l=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let t=1/0;for(let e=1;l.length>e;e++){const n=Math.abs(this.scales.x(l[e])-this.scales.x(l[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const o=this.getOpen(e),l=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([o,l,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:s,wickColor:i,wickWidth:a,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const s=this.getBounds(e),i=this.scales.x(t);if(s&&0!==s)n.push([i,this.scales.y(r+s)]),o.push([i,this.scales.y(r-s)]);else{const t=this.scales.y(r);n.push([i,t]),o.push([i,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var n,o,r;const s=this.config.decay;if(!s||1>=e)return 1;const i=null!==(n=s.minOpacity)&&void 0!==n?n:.1,a=e-1-t;switch(s.type){case"linear":return i+(1-a/(e-1))*(1-i);case"exponential":{const t=null!==(o=s.halfLife)&&void 0!==o?o:e/2;return i+Math.pow(.5,a/t)*(1-i)}case"step":return(null!==(r=s.stepThreshold)&&void 0!==r?r:.5*e)>a?1:i;default:return 1}}applyDecay(t,e){var n,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=s.get(e.datum);if(null==t)continue;const i=this.computeDecayOpacity(t,r);if("heatcell"===e.type)e.style={opacity:i};else if("candlestick"===e.type)e._decayOpacity=i;else{const t=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*i})}}}computePulseIntensity(t,e){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,s=e-t;return r>s?1-s/r:0}applyPulse(t,e){var n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=s.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const i=this.computePulseIntensity(n,o);i>0&&(e._pulseIntensity=i,e._pulseColor=r)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&n>e-o}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeIdentity(e,t);n&&("point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(n,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var n,o,r,s;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!==(s=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,n,o,r,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],l=this.getNodeIdentity(i,t);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===i.type){const t={x:i.x,y:i.y,r:i.r};c.x===t.x&&c.y===t.y||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=c.x,i.y=c.y,i.r=null!==(e=c.r)&&void 0!==e?e:i.r,a=!0)}else if("rect"===i.type){const t={x:i.x,y:i.y,w:i.w,h:i.h};c.x===t.x&&c.y===t.y&&c.w===t.w&&c.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=c.x,i.y=c.y,i.w=null!==(n=c.w)&&void 0!==n?n:i.w,i.h=null!==(o=c.h)&&void 0!==o?o:i.h,a=!0)}else if("heatcell"===i.type){const t={x:i.x,y:i.y,w:i.w,h:i.h};c.x===t.x&&c.y===t.y||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=c.x,i.y=c.y,i.w=null!==(r=c.w)&&void 0!==r?r:i.w,i.h=null!==(s=c.h)&&void 0!==s?s:i.h,a=!0)}}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==t._targetR&&void 0!==n.r&&(t.r=n.r+(t._targetR-n.r)*o)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*o)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o),void 0!==n.h&&(t.h=n.h+(t._targetH-n.h)*o)}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const n=this.config.lineStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle)return this.config.areaStyle(e||{});const o=this.config.lineStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){Object.assign(this.config,t)}}function N(t,e,n){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function _(t,e,n){if(0===t.path.length)return null;const o=C(t.path,e);if(0>o)return null;const[r,s]=t.path[o],i=e-r,a=n-s,l=Math.sqrt(i*i+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:r,y:s,distance:l}}function O(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 j(t,e,n){const o=t.bodyWidth/2,r=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=r+Math.max(Math.max(t.openY,t.closeY)-r,1)/2,s=e-t.x,i=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(s*s+i*i)}}return null}function T(t,e,n){if(0===t.topPath.length)return null;const o=C(t.topPath,e);if(0>o)return null;const[r,s]=t.topPath[o],i=e-r,a=n-s;return{node:t,datum:t.datum,x:r,y:s,distance:Math.sqrt(i*i+a*a)}}function C(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r][0]?n=r+1:o=r}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}const z={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 B(t,e,n,o){let r;return r="function"==typeof n?n(t):(0,z[n])(o(t,e)),r}function W(t){const{legendGroups:e,customClickBehavior:n,title:o="Legend",width:r=100,height:s=20,orientation:i="vertical"}=t,a="vertical"===i?(({legendGroups:t,width:e,customClickBehavior:n})=>{let o=30;const r=[];return t.forEach((t,s)=>{o+=5,r.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:o,x2:e,y2:o})),o+=10,t.label&&(o+=20,r.push(f.createElement("text",{key:"legend-text-"+s,y:o,className:"legend-group-label"},t.label)),o+=10),r.push(f.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${o})`},((t,e)=>{const{type:n="fill",styleFn:o,items:r}=t,s=[];let i=0;return r.forEach((t,r)=>{const a=B(t,r,n,o);s.push(f.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${i})`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},a,f.createElement("text",{y:15,x:30},t.label))),i+=25}),s})(t,n))),o+=25*t.items.length+10}),r})({legendGroups:e,width:r,customClickBehavior:n}):(({legendGroups:t,title:e,height:n,customClickBehavior:o})=>{let r=0;const s=[],i=!1===e?10:40;return t.forEach((e,a)=>{e.label&&(s.push(f.createElement("text",{key:"legend-text-"+a,transform:`translate(${r},${i}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},e.label)),r+=20);const l=((t,e)=>{const{type:n="fill",styleFn:o,items:r}=t,s=[];let i=0;return r.forEach((t,r)=>{const a=B(t,r,n,o);s.push(f.createElement("g",{key:"legend-item-"+r,transform:`translate(${i},0)`,onClick:e?()=>e(t):void 0,style:{cursor:e?"pointer":"default"}},a,f.createElement("text",{y:15,x:25},t.label))),i+=35,i+=8*t.label.length}),{items:s,offset:i}})(e,o);s.push(f.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${r},${i})`},l.items)),r+=l.offset+5,t[a+1]&&s.push(f.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:r,y1:i-10,x2:r,y2:n+i+10})),r+=15}),f.createElement("g",null,!1!==e&&f.createElement("line",{x1:0,x2:r+10,y1:i-10,y2:i-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:e,title:o,height:s,customClickBehavior:n});return f.createElement("g",null,void 0!==o&&f.createElement("text",{className:"legend-title",y:20,x:"horizontal"===i?0:r/2,textAnchor:"horizontal"===i?"start":"middle"},o),a)}function L(t){return"string"==typeof t?{type:t}:t}function F({orient:e,config:n,values:o,scale:s,size:i,length:a}){const l=function(t){var e,n,o,r,s;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=t.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(s=t.strokeWidth)&&void 0!==s?s:1}}(n),c="top"===e||"bottom"===e,u=t.useMemo(()=>{if(0===o.length)return null;const t=s.domain(),n=i-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 o=e[Math.floor(.25*n)],r=e[Math.floor(.5*n)],s=e[Math.floor(.75*n)],i=s-o;return{q1:o,median:r,q3:s,whiskerLow:Math.max(e[0],o-1.5*i),whiskerHigh:Math.min(e[n-1],s+1.5*i)}}(o);if(!t)return null;const{q1:r,median:i,q3:a,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),p=(n-d)/2+4;if(c){const t=s(r),n=s(a),o=s(i),c=s(u),y=s(h),m="top"===e?-1:1,g=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+e},f.createElement("line",{x1:c,y1:g+m*(p+d/2),x2:y,y2:g+m*(p+d/2),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:c,y1:g+m*p,x2:c,y2:g+m*(p+d),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:y,y1:g+m*p,x2:y,y2:g+m*(p+d),stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:Math.min(t,n),y:"top"===e?g-p-d:g+p,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:o,y1:"top"===e?g-p-d:g+p,x2:o,y2:"top"===e?g-p:g+p+d,stroke:l.fill,strokeWidth:2}))}{const t=s(r),n=s(a),o=s(i),c=s(u),y=s(h),m="left"===e?-1:1,g=0;return f.createElement("g",{"data-testid":"marginal-boxplot-"+e},f.createElement("line",{x1:g+m*(p+d/2),y1:c,x2:g+m*(p+d/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:g+m*p,y1:c,x2:g+m*(p+d),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("line",{x1:g+m*p,y1:y,x2:g+m*(p+d),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),f.createElement("rect",{x:"left"===e?g-p-d:g+p,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?g-p-d:g+p,y1:o,x2:"left"===e?g-p:g+p+d,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=r.bin().domain(t).thresholds(l.bins)(o);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,o)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/h*n;if(c){const n=s(t.x0),i=s(t.x1)-s(t.x0);return f.createElement("rect",{key:o,x:n,y:"top"===e?-4-r:4,width:Math.max(i,.5),height:r,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=s(t.x0),i=s(t.x1)-s(t.x0);return f.createElement("rect",{key:o,x:"left"===e?-4-r:4,y:Math.min(n,n+i),width:r,height:Math.abs(i),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const t=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/h*(n/2),a=s((r.x0+r.x1)/2);o.push(c?`${a},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${a}`)}for(let r=u.length-1;r>=0;r--){const i=u[r];if(null==i.x0||null==i.x1)continue;const a=i.length/h*(n/2),l=s((i.x0+i.x1)/2);o.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:o.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 o=0,r=null!=u[0].x0?s(u[0].x0):0;t.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,i=s((o.x0+o.x1)/2);t.push(`L${i},${"top"===e?-r-4:r+4}`)}const i=null!=u[u.length-1].x1?s(u[u.length-1].x1):a;t.push(`L${i},${o}`),t.push("Z")}else{const o=0,r=null!=u[0].x0?s(u[0].x0):0;t.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,i=s((o.x0+o.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${i}`)}const i=null!=u[u.length-1].x1?s(u[u.length-1].x1):a;t.push(`L${o},${i}`),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},[o,s,l,i,a,e,c,4]);return u?f.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function Y(t){return Math.round(100*t)/100+""}function R(e){const{width:n,height:o,totalWidth:r,totalHeight:s,margin:i,scales:a,showAxes:l,xLabel:c,yLabel:u,xFormat:h,yFormat:d,showGrid:p,title:y,legend:m,foregroundGraphics:g,marginalGraphics:x,xValues:b,yValues:v,annotations:k,svgAnnotationRules:E,annotationFrame:w,children:M}=e,A=t.useMemo(()=>l&&a?a.x.ticks(5).map(t=>({value:t,pixel:a.x(t),label:(h||Y)(t)})):[],[l,a,h]),S=t.useMemo(()=>l&&a?a.y.ticks(5).map(t=>({value:t,pixel:a.y(t),label:(d||Y)(t)})):[],[l,a,d]),$=t.useMemo(()=>k&&0!==k.length&&E?k.map((t,e)=>E(t,e,{scales:a?{time:a.x,value:a.y}:null,timeAxis:"x",width:n,height:o})).filter(Boolean):null,[k,E,n,o,w]);return l||y||m||g||x||$&&$.length>0||p||M?f.createElement("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},f.createElement("g",{transform:`translate(${i.left},${i.top})`},p&&a&&f.createElement("g",{className:"stream-grid"},A.map((t,e)=>f.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"#e0e0e0",strokeWidth:1})),S.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:o,x2:n,y2:o,stroke:"#ccc",strokeWidth:1}),A.map((t,e)=>f.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${o})`},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:o+40,textAnchor:"middle",fontSize:12,fill:"#333",style:{userSelect:"none"}},c),f.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"#ccc",strokeWidth:1}),S.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-i.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-i.left}, ${o/2})`,style:{userSelect:"none"}},u)),$,x&&a&&b&&v&&f.createElement(f.Fragment,null,x.top&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(F,{orient:"top",config:L(x.top),values:b,scale:a.x,size:i.top,length:n})),x.bottom&&f.createElement("g",{transform:`translate(0, ${o})`},f.createElement(F,{orient:"bottom",config:L(x.bottom),values:b,scale:a.x,size:i.bottom,length:n})),x.left&&f.createElement("g",{transform:"translate(0, 0)"},f.createElement(F,{orient:"left",config:L(x.left),values:v,scale:a.y,size:i.left,length:o})),x.right&&f.createElement("g",{transform:`translate(${n}, 0)`},f.createElement(F,{orient:"right",config:L(x.right),values:v,scale:a.y,size:i.right,length:o}))),g,M),y&&f.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333",style:{userSelect:"none"}},"string"==typeof y?y:null),m&&f.createElement("g",{transform:`translate(${r-i.right+10}, ${i.top})`},"object"==typeof(P=m)&&null!==P&&!f.isValidElement(P)&&"legendGroups"in P?f.createElement(W,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var P}function X(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}const I=(t,e,n,o)=>{var r;const s=e.filter(t=>"area"===t.type);for(const e of s){if(2>e.topPath.length)continue;t.beginPath();const[n,o]=e.topPath[0];t.moveTo(n,o);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath();const s=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.7;if(t.globalAlpha=s,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}},H=(t,e,n,o)=>{var r;const s=e.filter(t=>"point"===t.type);for(const e of s){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(r=e.style.opacity)&&void 0!==r?r:e.style.fillOpacity;if(null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),e._pulseIntensity&&e._pulseIntensity>0){const n=4;t.beginPath(),t.arc(e.x,e.y,e.r+n*e._pulseIntensity,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=.5*e._pulseIntensity,t.stroke()}t.globalAlpha=1}},V=(t,e,n,o)=>{const r=e.filter(t=>"rect"===t.type);for(const e of r)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?G(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 G(t,e){const n=e.style.icon,o=e.style.iconPadding||2,r=Math.min(e.w,e.w)-o;if(0>=r)return;const s=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),s){const s=r+o,i=e.x+(e.w-r)/2;for(let o=e.y+e.h-r;o>=e.y-r;o-=s)t.drawImage(n,i,o,r,r)}else{const s=r+o,i=e.y+(e.h-r)/2;for(let o=e.x;e.x+e.w>o;o+=s)t.drawImage(n,o,i,r,r)}t.restore()}const q={line:[I,(t,e,n,o)=>{const r=e.filter(t=>"line"===t.type);for(const s of r){if(2>s.path.length)continue;const i=s.style.stroke||"#007bff",a=s.style.strokeWidth||2,l=s.colorThresholds,c=s.rawValues;if(t.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(t.globalAlpha=s.style.opacity),t.lineWidth=a,l&&0!==l.length&&c&&c.length===s.path.length){let u=null,h=null,d=null,f=null,p=!1;function y(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),p=!0}function m(){p&&(t.stroke(),p=!1)}for(let g=0;s.path.length>g;g++){const[x,b]=s.path[g],v=c[g],k=X(v,l,i);if(null!==u&&null!==f&&null!==d){if(k===f)t.lineTo(x,b);else{const E=[];for(const w of l){const M=w.value;(d>M||M>v)&&(M>d||v>M)||d===M||v===M||E.push({t:(M-d)/(v-d)})}E.sort((t,e)=>t.t-e.t);for(const A of E){const S=u+(x-u)*A.t,$=h+(b-h)*A.t,P=X(d+(v-d)*Math.min(A.t+1e-4,1),l,i);t.lineTo(S,$),m(),y(P,S,$)}t.lineTo(x,b)}u=x,h=b,d=v,f=k}else y(k,x,b),u=x,h=b,d=v,f=k}m()}else{t.beginPath(),t.strokeStyle=i;const[N,_]=s.path[0];t.moveTo(N,_);for(let O=1;s.path.length>O;O++)t.lineTo(s.path[O][0],s.path[O][1]);t.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){t.beginPath(),t.globalAlpha=s.style.fillOpacity,t.fillStyle=s.style.fill;const[D,j]=s.path[0];t.moveTo(D,j);for(let C=1;s.path.length>C;C++)t.lineTo(s.path[C][0],s.path[C][1]);const T=s.path[0][0];t.lineTo(s.path[s.path.length-1][0],o.height),t.lineTo(T,o.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([])}}],area:[I],stackedarea:[I],scatter:[H],bubble:[H],heatmap:[(t,e,n,o)=>{const r=e.filter(t=>"heatcell"===t.type);for(const e of r){const n=e.style;null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),e._pulseIntensity&&e._pulseIntensity>0&&(t.globalAlpha=.3*e._pulseIntensity,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h)),t.globalAlpha=1}}],bar:[V],swarm:[H],waterfall:[(t,e,n,o)=>{var r,s;V(t,e);const i=e.filter(t=>"rect"===t.type);if(i.length>=2){t.save(),t.strokeStyle="#999",t.lineWidth=1,t.setLineDash([]);for(let e=0;i.length-1>e;e++){const o=i[e],a=i[e+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=a.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=a.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[(t,e,n,o)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const o=Math.min(e.openY,e.closeY),r=Math.abs(e.openY-e.closeY),s=e.isUp?e.upColor:e.downColor;t.fillStyle=s,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(r,1)),t.strokeStyle=s,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(r,1))}}]},J={top:20,right:20,bottom:30,left:40},K={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 U({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 Q({width:o,height:r,totalWidth:s,totalHeight:i,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"),s="x"===l?e.brushX():"y"===l?e.brushY():e.brush();return s.extent([[0,0],[o,r]]),s.on("brush end",t=>{if(!c)return;if(!t.selection)return void u(null);let e,n;if("x"===l){const[o,s]=t.selection;e=[c.x.invert(o),c.x.invert(s)],n=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,s]=t.selection;e=[c.x.invert(0),c.x.invert(o)],n=[c.y.invert(s),c.y.invert(r)]}else{const[[o,r],[s,i]]=t.selection;e=[c.x.invert(o),c.x.invert(s)],n=[c.y.invert(i),c.y.invert(r)]}u({x:e,y:n})}),t.call(s),d.current=s,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null),d.current=null}},[o,r,l,c,u]),f.createElement("svg",{ref:h,width:s,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},f.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const tt=t.forwardRef(function(e,n){var o;const{chartType:r,runtimeMode:s,data:i,xAccessor:a,yAccessor:l,colorAccessor:c,sizeAccessor:u,groupAccessor:h,lineDataAccessor:d,normalize:p,binSize:y,valueAccessor:m,arrowOfTime:x="right",windowMode:b="sliding",windowSize:v=200,timeAccessor:k,xExtent:E,yExtent:w,extentPadding:M=.1,sizeRange:A,size:S=[500,300],margin:$,className:C,background:z,lineStyle:B,pointStyle:W,areaStyle:L,swarmStyle:F,barColors:Y,colorScheme:X,boundsAccessor:I,boundsStyle:H,openAccessor:V,highAccessor:G,lowAccessor:Z,closeAccessor:tt,candlestickStyle:et,showAxes:nt=!0,xLabel:ot,yLabel:rt,xFormat:st,yFormat:it,tickFormatTime:at,tickFormatValue:lt,hoverAnnotation:ct,tooltipContent:ut,customHoverBehavior:ht,enableHover:dt,annotations:ft,svgAnnotationRules:pt,showGrid:yt,legend:mt,backgroundGraphics:gt,foregroundGraphics:xt,title:bt,categoryAccessor:vt,brush:kt,onBrush:Et,decay:wt,pulse:Mt,transition:At,staleness:St,heatmapAggregation:$t,heatmapXBins:Pt,heatmapYBins:Nt,marginalGraphics:_t}=e,Ot=Object.assign(Object.assign({},J),$);if(_t){const t=60;_t.top&&t>Ot.top&&(Ot.top=t),_t.bottom&&t>Ot.bottom&&(Ot.bottom=t),_t.left&&t>Ot.left&&(Ot.left=t),_t.right&&t>Ot.right&&(Ot.right=t)}const Dt=S[0]-Ot.left-Ot.right,jt=S[1]-Ot.top-Ot.bottom,Tt=null!=ct?ct:dt,Ct=t.useRef(null),zt=t.useRef(0),Bt=t.useRef(!1),[Wt,Lt]=t.useState(0),[Ft,Yt]=t.useState(null),Rt=t.useRef(null),[Xt,It]=t.useState(null),[Ht,Vt]=t.useState(!1),[Gt,qt]=t.useState([]),[Jt,Kt]=t.useState([]),Zt=t.useRef(()=>{}),Ut="streaming"===s||["bar","swarm","waterfall"].includes(r),Qt=t.useMemo(()=>({chartType:r,runtimeMode:Ut?"streaming":"bounded",windowSize:v,windowMode:b,arrowOfTime:Ut?x:"right",extentPadding:M,xAccessor:Ut?void 0:a,yAccessor:Ut?void 0:l,timeAccessor:Ut?k:void 0,valueAccessor:m,colorAccessor:c,sizeAccessor:u,groupAccessor:h,categoryAccessor:vt,lineDataAccessor:d,xExtent:E,yExtent:w,sizeRange:A,binSize:y,normalize:p,boundsAccessor:I,boundsStyle:H,openAccessor:V,highAccessor:G,lowAccessor:Z,closeAccessor:tt,candlestickStyle:et,lineStyle:B,pointStyle:W,areaStyle:L,swarmStyle:F,colorScheme:X,barColors:Y,annotations:ft,decay:wt,pulse:Mt,transition:At,staleness:St,heatmapAggregation:$t,heatmapXBins:Pt,heatmapYBins:Nt}),[r,v,b,x,M,a,l,k,m,c,u,h,vt,d,E,w,A,y,p,I,H,V,G,Z,tt,et,B,W,L,F,X,Y,ft,wt,Mt,At,St,$t,Pt,Nt,Ut]),te=t.useRef(null);te.current||(te.current=new P(Qt));const ee=t.useCallback(()=>{zt.current||(zt.current=requestAnimationFrame(()=>Zt.current()))},[]);t.useEffect(()=>{var t;null===(t=te.current)||void 0===t||t.updateConfig(Qt),Bt.current=!0,ee()},[Qt,ee]);const ne=t.useRef(null);ne.current||(ne.current=new g(t=>{const e=te.current;e&&e.ingest(t)&&(Bt.current=!0,ee())}));const oe=t.useCallback(t=>{var e;null===(e=ne.current)||void 0===e||e.push(t)},[]),re=t.useCallback(t=>{var e;null===(e=ne.current)||void 0===e||e.pushMany(t)},[]),se=t.useCallback(()=>{var t,e;null===(t=ne.current)||void 0===t||t.clear(),null===(e=te.current)||void 0===e||e.clear(),Bt.current=!0,ee()},[ee]);t.useImperativeHandle(n,()=>({push:oe,pushMany:re,clear:se,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}}),[oe,re,se]),t.useEffect(()=>{var t;i&&(null===(t=ne.current)||void 0===t||t.setBoundedData(i))},[i]);const ie=t.useRef(()=>{}),ae=t.useRef(()=>{});ie.current=t=>{if(!Tt)return;const e=Ct.current;if(!e)return;const n=e.getBoundingClientRect(),o=t.clientX-n.left-Ot.left,r=t.clientY-n.top-Ot.top;if(0>o||o>Dt||0>r||r>jt)return void(Rt.current&&(Rt.current=null,It(null),ht&&ht(null),ee()));const s=te.current;if(!s||0===s.scene.length)return;const i=function(t,e,n,o=30){let r=null;for(const s of t){let t=null;switch(s.type){case"point":t=N(s,e,n);break;case"line":t=_(s,e,n);break;case"rect":t=O(s,e,n);break;case"heatcell":t=D(s,e,n);break;case"area":if(!1===s.interactive)break;t=T(s,e,n);break;case"candlestick":t=j(s,e,n)}t&&o>t.distance&&(r&&t.distance>=r.distance||(r=t))}return r}(s.scene,o,r);if(!i)return void(Rt.current&&(Rt.current=null,It(null),ht&&ht(null),ee()));const a={data:i.datum,time:i.x,value:i.y,x:i.x,y:i.y};Rt.current=a,It(a),ht&&ht(a),ee()},ae.current=()=>{Rt.current&&(Rt.current=null,It(null),ht&&ht(null),ee())};const le=t.useCallback(t=>ie.current(t),[]),ce=t.useCallback(()=>ae.current(),[]);Zt.current=()=>{var t,e;zt.current=0;const n=Ct.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const s=te.current;if(!s)return;const i="undefined"!=typeof performance?performance.now():Date.now(),c=s.advanceTransition(i);c||s.computeScene({width:Dt,height:jt});const u="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=S[0]*u,n.height=S[1]*u,n.style.width=S[0]+"px",n.style.height=S[1]+"px",o.scale(u,u),o.translate(Ot.left,Ot.top),o.clearRect(-Ot.left,-Ot.top,S[0],S[1]);const h=function(t){if(!t)return K;const e=getComputedStyle(t),n=e.getPropertyValue("--text-secondary").trim(),o=e.getPropertyValue("--text-primary").trim(),r=e.getPropertyValue("--surface-3").trim(),s=e.getPropertyValue("--surface-0").trim();return n||o?{axisStroke:r||K.axisStroke,tickText:n||K.tickText,crosshair:n?n+"66":K.crosshair,hoverFill:s?s+"4D":K.hoverFill,hoverStroke:n?n+"99":K.hoverStroke,pointRing:s||K.pointRing}:K}(n),d=null!==(t=null==St?void 0:St.threshold)&&void 0!==t?t:5e3,f=St&&s.lastIngestTime>0&&i-s.lastIngestTime>d;f&&(o.globalAlpha=null!==(e=null==St?void 0:St.dimOpacity)&&void 0!==e?e:.5),z&&(o.fillStyle=z,o.fillRect(0,0,Dt,jt));const p=q[r];if(p&&s.scales)for(const t of p)t(o,s.scene,s.scales,{width:Dt,height:jt});f&&(o.globalAlpha=1),Tt&&Rt.current&&s.scales&&function(t,e,n,o,r,s,i){if(!1===r.crosshair)return;t.save();const a="object"==typeof r.crosshair?r.crosshair:{};t.strokeStyle=a.stroke||i.crosshair,t.lineWidth=a.strokeWidth||1,t.setLineDash(a.strokeDasharray?a.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,o),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=i.pointRing,t.lineWidth=2,t.stroke()}(o,Rt.current,Dt,jt,"object"==typeof Tt?Tt:{},0,h);const y=Bt.current;if(Bt.current=!1,y&&s.scales&&(Yt(s.scales),_t)){const t=s.getData(),e="function"==typeof a?a:t=>t[a||"x"],n="function"==typeof l?l:t=>t[l||"y"];qt(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Kt(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}y&&ft&&ft.length>0&&pt&&Lt(t=>t+1),(null==St?void 0:St.showBadge)&&Vt(!!f),(c||s.hasActivePulses)&&(zt.current=requestAnimationFrame(()=>Zt.current()))},t.useEffect(()=>(ee(),()=>{zt.current&&cancelAnimationFrame(zt.current)}),[ee]),t.useEffect(()=>{Bt.current=!0,ee()},[r,Dt,jt,nt,z,B,ee]),t.useEffect(()=>{if(!St)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(),o=null!==(t=St.threshold)&&void 0!==t?t:5e3,r=n-e.lastIngestTime>o;r!==Ht&&(Vt(r),Bt.current=!0,ee())},1e3);return()=>clearInterval(t)},[St,Ht,ee]);const ue=Tt&&Xt?ut?ut(Xt):f.createElement(U,{hover:Xt}):null,he=ue?f.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ot.left+Xt.x,top:Ot.top+Xt.y,transform:`translate(${Xt.x>.7*Dt?"calc(-100% - 12px)":"12px"}, ${.3*jt>Xt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},ue):null;return f.createElement("div",{className:"stream-xy-frame"+(C?" "+C:""),style:{position:"relative",width:S[0],height:S[1]},onMouseMove:Tt?le:void 0,onMouseLeave:Tt?ce:void 0},gt&&f.createElement("svg",{style:{position:"absolute",left:0,top:0,width:S[0],height:S[1],pointerEvents:"none"}},gt),f.createElement("canvas",{ref:Ct,style:{position:"absolute",left:0,top:0}}),f.createElement(R,{width:Dt,height:jt,totalWidth:S[0],totalHeight:S[1],margin:Ot,scales:Ft,showAxes:nt,xLabel:ot,yLabel:rt,xFormat:st||at,yFormat:it||lt,showGrid:yt,title:bt,legend:mt,foregroundGraphics:xt,marginalGraphics:_t,xValues:Gt,yValues:Jt,annotations:ft,svgAnnotationRules:pt,annotationFrame:Wt}),(kt||Et)&&f.createElement(Q,{width:Dt,height:jt,totalWidth:S[0],totalHeight:S[1],margin:Ot,dimension:null!==(o=null==kt?void 0:kt.dimension)&&void 0!==o?o:"xy",scales:Ft,onBrush:null!=Et?Et:()=>{}}),(null==St?void 0:St.showBadge)&&f.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===St.badgePosition?{top:4,left:4}:"bottom-left"===St.badgePosition?{bottom:4,left:4}:"bottom-right"===St.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)});tt.displayName="StreamXYFrame";const et={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},nt=s.schemeCategory10;function ot(t,e,n){if("function"==typeof e)return e(t);const o=t[e];return n?n(o):nt[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o+""))%nt.length]}const rt="#007bff";const st={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function it(t,e){return"function"==typeof e?e(t):t[e]}function at(t,e){return e?e(t):null==t?"":"number"==typeof t?t.toLocaleString():t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function lt(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:e,title:n,format:o,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let i;const a=[];if(n){const e=it(t,n);i=at(e,o)}if(e&&e.length>0)e.forEach(e=>{let n,r,s;"string"==typeof e?(n=e,r=e,s=o):(n=e.label,r=e.accessor||e.key||"",s=e.format||o);const i=it(t,r);a.push({label:n,value:at(i,s)})});else if(!n){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){i=at(t[n],o);break}if(!i){const e=Object.keys(t).filter(t=>!t.startsWith("_"));e.length>0&&(i=at(t[e[0]],o))}}const l=Object.assign(Object.assign({},st),r);return f.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:l},i&&f.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},i),a.map((t,e)=>f.createElement("div",{key:e,style:{marginTop:0===e&&i?"4px":0}},t.label&&f.createElement("span",null,t.label,": "),t.value)))}}(t)))}function ct({componentName:t,message:e,width:n,height:o}){return f.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},f.createElement("div",{style:{textAlign:"center",maxWidth:400}},f.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),f.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},e)))}function ut({width:o,height:r,margin:s,scales:i,brushDirection:a,extent:l,onBrush:c}){const u=t.useRef(null),h=t.useRef(null),d=t.useRef(!1),p=o+s.left+s.right,y=r+s.top+s.bottom;return t.useEffect(()=>{if(!u.current||!i)return;const t=n.select(u.current).select(".brush-group"),s="x"===a?e.brushX().extent([[0,0],[o,r]]):e.brushY().extent([[0,0],[o,r]]);return s.on("brush end",t=>{if(d.current)return;if(!t.sourceEvent)return;const e=t.selection;if(!e)return void c(null);const n=("x"===a?i.x:i.y).invert;if(!n)return;const o=[n(e[0]),n(e[1])];c(o)}),t.call(s),h.current=s,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[i,o,r,a,c]),t.useEffect(()=>{if(!h.current||!i||!u.current)return;const t=n.select(u.current).select(".brush-group"),e="x"===a?i.x:i.y;if(d.current=!0,l){const n=[e(l[0]),e(l[1])];t.call(h.current.move,n)}else t.call(h.current.move,null);d.current=!1},[l,i,a]),f.createElement("svg",{ref:u,width:p,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},f.createElement("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`}))}function ht(e){var n,r;const{data:s,width:i=600,height:a=400,margin:l,className:c,title:u,xLabel:h,yLabel:d,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:g="y",lineBy:x,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:k="category10",curve:E="linear",lineWidth:w=2,fillArea:M=!1,areaOpacity:A=.3,showPoints:S=!1,pointRadius:$=3,enableHover:P=!0,showGrid:N=!1,showLegend:_,tooltip:O,minimap:D={},renderBefore:j=!1,onBrush:T,brushExtent:C,frameProps:z={}}=e,B=s||[],[W,L]=t.useState(null),F=null!=C?C:W,Y=t.useCallback(t=>{C||L(t),null==T||T(t)},[C,T]),R=t.useRef(null),[X,I]=t.useState(null);t.useEffect(()=>{const t=()=>{var e,n;const o=null===(n=null===(e=R.current)||void 0===e?void 0:e.getScales)||void 0===n?void 0:n.call(e);o?I(o):requestAnimationFrame(t)};requestAnimationFrame(t)},[s]);const H=void 0!==(null===(n=B[0])||void 0===n?void 0:n[b]),V=t.useMemo(()=>{if(H)return B;if(x){const t=B.reduce((t,e)=>{const n="function"==typeof x?x(e):e[x];if(!t[n]){const e={[b]:[]};"string"==typeof x&&(e[x]=n),t[n]=e}return t[n][b].push(e),t},{});return Object.values(t)}return[{[b]:B}]},[B,x,b,H]),G=t.useMemo(()=>H||x?V.flatMap(t=>{const e=t[b]||[];return x&&"string"==typeof x?e.map(e=>Object.assign(Object.assign({},e),{[x]:t[x]})):e}):B,[V,b,H,x,B]),q=function(e,n,r="category10"){return t.useMemo(()=>{if(n&&"function"!=typeof n)return function(t,e,n="category10"){const r=Array.from(new Set(t.map(t=>t[e]))),s=r.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const i=et[n]||et.category10;if(s&&"function"==typeof i)return t=>i(Number(t)/Math.max(...r.map(Number)));{const t=Array.isArray(i)?i:nt;return o.scaleOrdinal().domain(r).range(t).unknown("#999")}}(e,n,r)},[e,n,r])}(B,v,k),J=t.useMemo(()=>t=>{const e={strokeWidth:w};return e.stroke=v?ot(t,v,q):rt,M&&(e.fill=e.stroke,e.fillOpacity=A),e},[v,q,w,M,A]),K=t.useMemo(()=>D.lineStyle?D.lineStyle:t=>{const e={strokeWidth:1};return e.stroke=v?ot(t,v,q):rt,e},[v,q,D.lineStyle]),Z=t.useMemo(()=>{if(S)return t=>{const e={r:$,fillOpacity:1};return e.fill=v?ot(t.parentLine||t,v,q):rt,e}},[S,$,v,q]),U=void 0!==_?_:V.length>1,Q=t.useMemo(()=>{if(U&&v)return function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:r,strokeWidth:s}){return{legendGroups:[{styleFn:t=>{const e={fill:t.color,stroke:t.color};return void 0!==r&&(e.stroke=r),void 0!==s&&(e.strokeWidth=s),e},type:"fill",items:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e]))).map(r=>{const s=t.find("function"==typeof e?t=>e(t)===r:t=>t[e]===r),i=s?o(s,e,n):n?n(r):"#000000";return{label:r+"",color:i}}),label:""}]}}({data:V,colorBy:v,colorScale:q,getColor:ot})},[U,v,V,q]),st=t.useMemo(()=>{const t=Object.assign(Object.assign({},{top:50,bottom:60,left:70,right:40}),l);return Q&&120>t.right&&(t.right=120),t},[l,Q]),it=D.height||60,at=t.useMemo(()=>{var t,e,n,o,r,s,i,a;return{top:null!==(e=null===(t=D.margin)||void 0===t?void 0:t.top)&&void 0!==e?e:0,bottom:null!==(o=null===(n=D.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(s=null===(r=D.margin)||void 0===r?void 0:r.left)&&void 0!==s?s:st.left,right:null!==(a=null===(i=D.margin)||void 0===i?void 0:i.right)&&void 0!==a?a:st.right}},[D.margin,st]),ht=D.brushDirection||"x",dt=function({data:t,accessors:e,requiredProps:n}){if(n)for(const[t,e]of Object.entries(n))if(null==e)return t+" is required. Provide a field name or function.";if(!t||!Array.isArray(t)||0===t.length)return"No data provided. Pass a non-empty array to the data prop.";if(e){const n=t[0];if(n&&"object"==typeof n)for(const[t,o]of Object.entries(e))if(o&&"string"==typeof o&&!(o in n))return`${t} "${o}" not found in data. Available fields: ${Object.keys(n).join(", ")}.`}return null}({componentName:"MinimapChart",data:B,accessors:{xAccessor:m,yAccessor:g}});if(dt)return f.createElement(ct,{componentName:"MinimapChart",message:dt,width:i,height:a});const ft=M?"area":"line",pt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ft,data:G,xAccessor:m,yAccessor:g,groupAccessor:x||void 0,curve:E,lineStyle:J},S&&{pointStyle:Z}),{size:[i,a],margin:st,showAxes:!0,xLabel:h,yLabel:d,xFormat:p,yFormat:y,enableHover:P,showGrid:N}),Q&&{legend:Q}),u&&{title:u}),O&&{tooltipContent:lt(O)}),F&&{xExtent:F}),z),yt={chartType:ft,data:G,xAccessor:m,yAccessor:g,groupAccessor:x||void 0,curve:E,lineStyle:K,size:[i,it+at.top+at.bottom],margin:at,showAxes:null!==(r=D.showAxes)&&void 0!==r&&r,background:D.background,enableHover:!1},mt=f.createElement("div",{key:"minimap",style:{position:"relative",width:i}},f.createElement(tt,Object.assign({ref:R},yt)),f.createElement(ut,{width:i-at.left-at.right,height:it,margin:at,scales:X,brushDirection:ht,extent:F,onBrush:Y})),gt=f.createElement("div",{key:"main"},f.createElement(tt,Object.assign({},pt)));return f.createElement("div",{className:"minimap-chart"+(c?" "+c:"")},j?mt:gt,j?gt:mt)}ht.displayName="MinimapChart";const dt=({xy:t,orient:e,i:n,className:o="",jaggedBase:r})=>{let s=`M${t.x1},${t.y1}L${t.x2},${t.y2}`;return r&&0===n&&(s=((t,e)=>{let n="";const{x1:o,x2:r,y1:s,y2:i}=e;if("left"===t||"right"===t){const e=Math.abs(r-o);n=((t,e,n,o)=>{const r=t/e;let s=0,i="M0,"+n;const a="right"===o?-1:1;for(;t>=s;)i+=`L${s},${n}`,t>s&&(i+=`L${s+r/2},${n+10*a}`),s+=r;return i})(e,Math.ceil(e/40),"right"===t?0:s,t)}else{const e=Math.abs(i-s);n=((t,e,n,o)=>{const r=t/e;let s=0,i=`M${n},0`;const a="bottom"===o?-1:1;for(;t>=s;)i+=`L${n},${s}`,t>s&&(i+=`L${n+10*a},${s+r/2}`),s+=r;return i})(e,Math.ceil(e/40),o,t)}return n})(e,t)),f.createElement("path",{key:n,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:s,className:`tick-line tick ${e} ${o}`})};function ft(t,e,n){const o=Math.abs(n.range()[1]-n.range()[0]);return t||(e||(e=Math.max(1,Math.floor(o/40))),t=n.ticks&&n.ticks(e)||n.domain()),t}function pt({t:t,o:e,w:n}){return"contour"!==t&&"boxplot"!==t||"left"!==e&&"right"!==e?0:n/2}function yt({t:t,o:e,w:n}){return"contour"!==t&&"boxplot"!==t||"top"!==e&&"bottom"!==e?0:n/2}function mt(t){const{translation:e,orient:n,decoratedSummaryType:o,summaryWidth:r,renderedSummary:s,points:i}=t;return f.default.createElement("g",{className:"marginal-graphics",transform:`translate(${e[n]})`},f.default.createElement("g",{transform:`translate(${pt({t:o.type,o:n,w:r})},${yt({t:o.type,o:n,w:r})})`},s),i)}function gt(t){const{className:e,translation:n,position:o,rotation:r,labelName:s,anchorMod:i}=t;return f.default.createElement("g",{className:"axis-title "+e,transform:`translate(${[n[0]+o[0],n[1]+o[1]]}) rotate(${r})`},f.default.isValidElement(s)?s:f.default.createElement("text",{textAnchor:i},s))}function xt(t){if(null==t)return"";if("number"!=typeof t)return t+"";if(!isFinite(t))return t+"";if(0===t)return"0";const e=parseFloat(t.toPrecision(12)),n=Math.abs(e);return 1e9>n?1e6>n?1e4>n?Number.isInteger(e)?e+"":parseFloat(e.toPrecision(6))+"":parseFloat((e/1e3).toPrecision(3))+"K":parseFloat((e/1e6).toPrecision(3))+"M":parseFloat((e/1e9).toPrecision(3))+"B"}function bt(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;function vt(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),r=t.split(/\s+/),s=[];let i="";for(const t of r)i&&i.length+1+t.length>o?(s.push(i),i=t):i=i?`${i} ${t}`:t;return i&&s.push(i),s}function kt(t,e,n,o){return"curly"===t?o?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Et(t){const{x:e=0,y:n=0,dx:o,dy:r,nx:s,ny:i,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:p,events:y={},"data-testid":m}=t,g=new Set(Array.isArray(p)?p:[]);let x=o||0,b=r||0;null!=s&&(x=s-e),null!=i&&(b=i-n);const v="string"==typeof u?u:"label";if("bracket"===v&&c&&0===x&&0===b)if(void 0!==c.width){x=c.width/2;const t=c.depth||30;b=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;x=t+(0>t?-5:5),b=c.height/2}return f.createElement("g",Object.assign({className:("annotation "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":m},y),!g.has("connector")&&function(t,e,n,o,r,s){const i=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const n=s.width||0,o=s.height||0;if(n>0||o>0){const r=n/2,s=o/2,i=t-r,c=e-s;if(0!==i||0!==c){const t=Math.abs(i),e=Math.abs(c),u=n/2,h=o/2,d=t*h>e*u?u/t:h/e;a=r+i*d,l=s+c*d}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(s.radius||0)+(s.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(e-l,2))>.5&&(i.push(f.createElement("line",{key:"connector-line",x1:a,y1:l,x2:t,y2:e,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,s=Math.atan2(e-l,t-a);i.push(f.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(s+r)},${l+n*Math.sin(s+r)}L${a+n*Math.cos(s-r)},${l+n*Math.sin(s-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return f.createElement("g",{className:"annotation-connector"},i)}(x,b,l,h,v,c),!g.has("subject")&&function(t,e,n,o,r){var s;const i=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&i.push(f.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,o=(null==e?void 0:e.height)||0;(t>0||o>0)&&i.push(f.createElement("rect",{key:"subject-rect",width:t,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&i.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=r||0;if(void 0!==(null==e?void 0:e.x)){const o=(e.x||0)-t;i.push(f.createElement("line",{key:"threshold-line",x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const o=(e.y||0)-s;i.push(f.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?i.push(f.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)||i.push(f.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(s=null==e?void 0:e.width)&&void 0!==s?s:null==e?void 0:e.height;void 0!==t&&i.push(f.createElement("path",{key:"bracket-path",d:kt((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 f.createElement("g",{className:"annotation-subject"},i)}(v,c,h,e,n),!g.has("note")&&function(t,e,n,o){if(!t)return f.createElement("g",{className:"annotation-note"});const{label:r,title:s,orientation:i,align:a,wrap:l=120,noWrap:c}=t;if(!r&&!s)return f.createElement("g",{className:"annotation-note"});let u=i;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const p=16,y=s?c?[s]:vt(s,l):[],m=r?c?[r]:vt(r,l):[],g="leftRight"===u?"end"===d?-4:4:0;let x=0;const b=[];y.length>0&&(b.push(f.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:d,fontWeight:"bold"},y.map((t,e)=>f.createElement("tspan",{key:e,x:g,dy:0===e?0:p},t)))),x=y.length*p),m.length>0&&b.push(f.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:d,y:x},m.map((t,e)=>f.createElement("tspan",{key:e,x:g,dy:p},t))));let v=null;if((s||r)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(l,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),v=f.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const t=(y.length+m.length)*p+(m.length>0?p:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),v=f.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:o||"currentColor"})}const k=(y.length+m.length)*p+(m.length>0?p:0);let E=0;return"topBottom"===u?0>n&&(E=-k):"leftRight"===u&&("middle"===h?E=-k/2:("bottom"===h||0>n)&&(E=-k)),f.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},f.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},b),v)}(a,x,b,h))}function wt(t){const{noteData:e}=t,{screenCoordinates:n}=e,o="string"==typeof e.type?e.type:"label",r=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+e.dx,r=e.ny||n[0][1]+e.dy,s=n.map((n,s)=>{const i=Object.assign({},e,{note:0===s?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:r});return f.createElement(Et,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+s},i,{type:o}))});return f.createElement("g",null,s)}const s=e.note||{title:"none",label:e.label};return f.createElement(Et,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${e.i}`,events:r},e,{type:o}))}const Mt=(t,e,n,o)=>{const r=(t.note.label||t.note.title).length;return[Math.min(t.note.wrap||120,r*e)+2*o,Math.ceil(r*e/120)*n+2*o]};function At(t){let e=new EventTarget,n=t(function(t){n=Object.assign(n,t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}let[St,$t]=function(e){let n=t.createContext(null),o=At(e);return[function({children:o}){let r=t.useMemo(()=>At(e),[]);return f.createElement(n.Provider,{value:r,children:o})},e=>{var r;let s=null!==(r=t.useContext(n))&&void 0!==r?r:o;return function(e,n){const[o,r]=t.useState(n);return t.useLayoutEffect(()=>e(()=>r(n)),[e]),o}(s.subscribe,()=>e(s.getState()))}]}(t=>({tooltip:null,changeTooltip(e){t(()=>({tooltip:e}))}}));function Pt(t,e,n){return"number"==typeof n?n:e&&e.find(e=>e.props.orient===t)?50:10}const Nt=(t,e,n)=>`${t.map(_t).join(",")}${JSON.stringify(e)}${n.join(",")}`;function _t(t){if(!t||!t.props||!t.props.noteData)return"";const{note:e={}}=t.props.noteData,{label:n,title:o}=e;return`${t.props.noteData.id||`${t.props.noteData.x}-${t.props.noteData.y}`}-${n}=${o}`}function Ot(t,e=8,n){const{noteWidth:o=n}=t;let r=o;"number"==typeof o&&(r=()=>o);const s=t.note&&t.note.wrap||120,i=t.note.label||t.note.label||"";return o&&r(t)||(f.default.isValidElement(t.note)?100:Math.min(s,i.length*e))}function Dt(t,e=8,n=20,o){const{noteHeight:r=o}=t;let s=r;"number"==typeof r&&(s=()=>r);const i=t.note&&t.note.wrap||120,a=t.note.label||t.note.title||"";return r&&s(t)||(f.default.isValidElement(t.note)?30:Math.ceil(a.length*e/i)*n+(t.note.label&&t.note.title?n:0))}const jt=(t,e)=>e.map((e,n)=>t.svgAnnotationRule(e,n,t)).filter(t=>null!=t),Tt=(t,e)=>{let n=e.adjustedAnnotations,o=e.adjustedAnnotationsKey,r=e.adjustableAnnotations,s=e.fixedAnnotations,i=[],a=[];const l=e.adjustedAnnotationsKey,c=e.adjustedAnnotationsDataVersion,{annotations:u,annotationHandling:h=!1,size:d,svgAnnotationRule:y,htmlAnnotationRule:m}=t,g="object"==typeof h?h:{layout:{type:h},dataVersion:""},{dataVersion:x=""}=g;if(y){const e=jt(t,u);o=Nt(e,g,d),!1===h&&(n=r),n=n.length!==r.length||l!==o||c!==x?((t,e,n)=>{const{layout:o={type:!1,noteHeight:void 0,noteWidth:void 0}}=e;if(!1===o.type)return t;const{noteWidth:r,noteHeight:s}=o;let{margin:i={top:0,bottom:0,left:0,right:0}}=n;const{size:a,axes:l=[]}=n;if(i="number"==typeof i?{top:i,left:i,right:i,bottom:i}:i,"bump"===o.type)return function(t,e,n,o,r){const{padding:s=1,characterWidth:i=8,lineHeight:a=20,iterations:l=500,pointSizeFunction:c=o,labelSizeFunction:u=r||Mt}=e,h=t.map((t,e)=>{const n=(t.props.noteData.x[0]||t.props.noteData.x)+(void 0!==t.props.noteData.dx?t.props.noteData.dx:-10*(e%3-1)),o=(t.props.noteData.y[0]||t.props.noteData.y)+(void 0!==t.props.noteData.dy?t.props.noteData.dy:10*(e%3-1)),[r,l]=u(t.props.noteData,i,a,s);return{x:n,y:o,above:t.props.noteData.y>o,left:t.props.noteData.x>n,width:r,height:l,type:"label",name:"",originalNote:t}}),d=t.map(t=>({x:t.props.noteData.x,y:t.props.noteData.y,fx:t.props.noteData.x,fy:t.props.noteData.y,r:c&&c(t.props.noteData)||5,type:"point",originalNote:t})),f=function(){let t,e=[],n=[],o=1,r=1,s={start:t=>{},width:t=>{},height:t=>{},label:t=>{},anchor:t=>{},alt_energy:t=>{},alt_schedule:t=>{}},i=!1;const a=function(t){let o=e.length,r=0,s=e[t].x-n[t].x,i=n[t].y-e[t].y,a=Math.sqrt(s*s+i*i);a>0&&(r+=.2*a),s/=a,i/=a,r+=s>0&&i>0?0:0>s&&i>0?3:0>s&&0>i?6:9;let l,c,h,d,f,p,y,m=e[t].x,g=e[t].y-e[t].height+2,x=e[t].x+e[t].width,b=e[t].y+2;for(let s=0;o>s;s++)s!==t&&(u(n[t].x,e[t].x,n[s].x,e[s].x,n[t].y,e[t].y,n[s].y,e[s].y)&&(r+=1),l=e[s].x,h=e[s].y-e[s].height+2,c=e[s].x+e[s].width,d=e[s].y+2,f=Math.max(0,Math.min(c,x)-Math.max(l,m)),p=Math.max(0,Math.min(d,b)-Math.max(h,g)),y=f*p,r+=30*y),l=n[s].x-n[s].r,h=n[s].y-n[s].r,c=n[s].x+n[s].r,d=n[s].y+n[s].r,f=Math.max(0,Math.min(c,x)-Math.max(l,m)),p=Math.max(0,Math.min(d,b)-Math.max(h,g)),y=f*p,r+=30*y;return r},l=function(s){let l,c,u=Math.floor(Math.random()*e.length),h=e[u].x,d=e[u].y;l=i?t(u,e,n):a(u),e[u].x+=5*(Math.random()-.5),e[u].y+=5*(Math.random()-.5),e[u].x>o&&(e[u].x=h),0>e[u].x&&(e[u].x=h),e[u].y>r&&(e[u].y=d),0>e[u].y&&(e[u].y=d),c=i?t(u,e,n):a(u);let f=c-l;Math.random()<Math.exp(-f/s)||(e[u].x=h,e[u].y=d)},c=function(s){let l,c=Math.floor(Math.random()*e.length),u=e[c].x,h=e[c].y;l=i?t(c,e,n):a(c);let d=.5*(Math.random()-.5),f=Math.sin(d),p=Math.cos(d);e[c].x-=n[c].x,e[c].y-=n[c].y;let y,m=e[c].x*f+e[c].y*p;e[c].x=e[c].x*p-e[c].y*f+n[c].x,e[c].y=m+n[c].y,e[c].x>o&&(e[c].x=u),0>e[c].x&&(e[c].x=u),e[c].y>r&&(e[c].y=h),0>e[c].y&&(e[c].y=h),y=i?t(c,e,n):a(c);let g=y-l;Math.random()<Math.exp(-g/s)||(e[c].x=u,e[c].y=h)},u=function(t,e,n,o,r,s,i,a){let l,c,u,h,d;return u=(a-i)*(e-t)-(o-n)*(s-r),h=(o-n)*(r-i)-(a-i)*(t-n),d=(e-t)*(r-i)-(s-r)*(t-n),l=h/u,c=d/u,!(0>l||l>1||0>c||c>1)},h=function(t,e,n){return t-e/n};return s.start=function(t){let n=e.length,o=1;for(let e=0;t>e;e++){for(let t=0;n>t;t++).5>Math.random()?l(o):c(o);o=h(o,1,t)}},s.width=function(t){return arguments.length?(o=t,s):o},s.height=function(t){return arguments.length?(r=t,s):r},s.label=function(t){return arguments.length?(e=t,s):e},s.anchor=function(t){return arguments.length?(n=t,s):n},s.alt_energy=function(e){return arguments.length?(t=e,i=!0,s):a},s.alt_schedule=function(t){return arguments.length?s:h},s}();return f.label(h),f.anchor(d),f.width(n[0]),f.height(n[1]),f.start(l),h.forEach(t=>{if("label"===t.type){const e=function(t,e,n){return t.y>e.y?[e.x+e.width/2+n/2,e.y-e.height+n/2]:[e.x+e.width/2,e.y]}(t.originalNote.props.noteData,t,s);t.originalNote.props.noteData.nx=e[0],t.originalNote.props.noteData.ny=e[1]}}),t}(t,o,a,n.pointSizeFunction,n.labelSizeFunction);if("marginalia"===o.type){const{marginOffset:e,orient:n="nearest",characterWidth:c=8,lineHeight:u=20,padding:h=2,axisMarginOverride:d={}}=o,y="nearest"===n?["left","right","top","bottom"]:Array.isArray(n)?n:[n],m=y.find(t=>"left"===t),g=y.find(t=>"right"===t),x=y.find(t=>"top"===t),b=y.find(t=>"bottom"===t),v=[],k=[],E=[],w=[];for(const e of t){const t=e.props.noteData,n=t.x[0]||t.x,o=t.y[0]||t.y,r=m?n:1/0,s=g?a[0]-n:1/0,i=x?o:1/0,l=Math.min(r,s,i,b?a[1]-o:1/0);r===l?v.push(e):s===l?k.push(e):i===l?E.push(e):w.push(e)}const M=new p.default.Force({minPos:void 0!==d.top?0+d.top:0-i.top,maxPos:void 0!==d.bottom?a[1]-d.bottom:b?a[1]:a[1]+i.bottom}).nodes(v.map(t=>new p.default.Node(t.props.noteData.y[0]||t.props.noteData.y,Dt(t.props.noteData,c,u,r)+h))).compute(),A=new p.default.Force({minPos:void 0!==d.top?0+d.top:x?0:0-i.top,maxPos:void 0!==d.bottom?a[1]-d.bottom:a[1]+i.bottom}).nodes(k.map(t=>new p.default.Node(t.props.noteData.y[0]||t.props.noteData.y,Dt(t.props.noteData,c,u,r)+h))).compute(),S=new p.default.Force({minPos:void 0!==d.left?0+d.left:m?0:0-i.left,maxPos:void 0!==d.right?a[0]-d.right:a[0]+i.right}).nodes(E.map(t=>new p.default.Node(t.props.noteData.x[0]||t.props.noteData.x,Ot(t.props.noteData,c,s)+h))).compute(),$=new p.default.Force({minPos:void 0!==d.left?0+d.left:0-i.left,maxPos:void 0!==d.right?a[0]-d.right:g?a[0]:a[0]+i.right}).nodes(w.map(t=>new p.default.Node(t.props.noteData.x[0]||t.props.noteData.x,Ot(t.props.noteData,c,s)+h))).compute(),P=Math.max(...w.map(t=>Dt(t.props.noteData,c,u,r)+h)),N=Math.max(...E.map(t=>Dt(t.props.noteData,c,u,r)+h)),_=Math.max(...v.map(t=>Ot(t.props.noteData,c,s)+h)),O=Math.max(...k.map(t=>Ot(t.props.noteData,c,s)+h)),D=M.nodes(),j=A.nodes(),T=S.nodes(),C=$.nodes();return v.forEach((t,n)=>{const o=0-D[n].layerIndex*_-Pt("left",l,e),r=D[n].currentPos;t.props.noteData.nx=o,t.props.noteData.ny=r,t.props.noteData.note&&!f.isValidElement(t)&&(t.props.noteData.note.orientation=t.props.noteData.note.orientation||"leftRight",t.props.noteData.note.align=t.props.noteData.note.align||"right")}),k.forEach((t,n)=>{const o=a[0]+j[n].layerIndex*O+Pt("right",l,e),r=j[n].currentPos;t.props.noteData.nx=o,t.props.noteData.ny=r,t.props.noteData.note&&!f.isValidElement(t)&&(t.props.noteData.note.orientation=t.props.noteData.note.orientation||"leftRight",t.props.noteData.note.align=t.props.noteData.note.align||"left")}),E.forEach((t,n)=>{const o=T[n].currentPos,r=0-T[n].layerIndex*N-Pt("top",l,e);t.props.noteData.nx=o,t.props.noteData.ny=r}),w.forEach((t,n)=>{const o=C[n].currentPos,r=a[1]+C[n].layerIndex*P+Pt("bottom",l,e);t.props.noteData.nx=o,t.props.noteData.ny=r}),t}return t})(r,g,t):r.map((t,e)=>{const o=Object.assign(Object.assign({},n[e].props.noteData),t.props.noteData);return f.createElement(wt,{key:t.key,noteData:o})}),i=[...n,...s]}return m&&(a=((t,e)=>e.map((e,n)=>t.htmlAnnotationRule(e,n,t)).filter(t=>null!=t))(t,u)),{svgAnnotations:i,htmlAnnotations:a,adjustedAnnotations:n,adjustedAnnotationsKey:o,adjustedAnnotationsDataVersion:x}},Ct=t=>t.reduce((t,e)=>t.concat(Array.isArray(e)?Ct(e.slice().sort((t,e)=>t-e)):e),[]);function zt(t=[]){if(!Array.isArray(t))return"not-array";let e=t.slice();return Array.isArray(e[0])||(e=e.slice().sort((t,e)=>t-e)),""+Ct(e).map(t=>t instanceof Date&&""+t||void 0!==t&&t.toFixed&&t.toFixed(2)||"empty")}const Bt=t=>t instanceof Date?t.getTime():t,Wt=({data:t,lineDataAccessor:e,xProp:n,xPropTop:o,xPropBottom:r,yProp:s,yPropTop:i,yPropBottom:a,xAccessor:l,yAccessor:c})=>{Array.isArray(t)||(t=[t]);const u=[];return e.forEach((e,h)=>{l.forEach((l,d)=>{c.forEach((c,f)=>{t.forEach(t=>{const p=Object.assign(Object.assign({},t),{xIndex:d,yIndex:f,lineIndex:h});p.data=e(t).map((t,e)=>{const u={data:t};return u[n]=l(t,e),u[o]=u[n],u[r]=u[n],u[s]=c(t,e),u[i]=u[s],u[a]=u[s],u}),p.key=p.key||u.length,u.push(p)})})})}),u},Lt=({type:t="stackedarea",data:e,xProp:n,yProp:o,yPropMiddle:s,sort:i,yPropTop:a,yPropBottom:l})=>{const c=new Map,u=e.map(()=>0);let h=0;for(const t of e){t.__lineIndex=h;for(const e of t.data){const t=Bt(e[n]);u[h]+=e[o],c.has(t)||c.set(t,[]),c.get(t)[h]=e}h++}let d=(t,e)=>u[e.key]-u[t.key];"stackedpercent-invert"!==t&&"stackedarea-invert"!==t||(d=(t,e)=>u[t.key]-u[e.key]),null!==(i=void 0===i?d:i)&&(e=e.sort(i));const f=e.map(t=>t.__lineIndex);for(const[,e]of c){let n=0,i=0;const c=r.sum(e,t=>(null==t?void 0:t[o])>0?t[o]:0),u=r.sum(e,t=>0>(null==t?void 0:t[o])?t[o]:0);for(const r of f){const h=e[r];if(h)if(0>h[o]){if("linepercent"===t||"stackedpercent"===t||"stackedpercent-invert"===t){const e=h[o]/u;if(h.percent=e,"linepercent"===t)h[l]=h[l]=h[a]=h[s]=e;else{const t=0>u?e:0;h[l]=0===u?0:-n/u,h[a]=h[l]-t,h[s]=h[l]-t/2}}else h[l]=n,h[a]=n+h[o],h[s]=n+h[o]/2;n+=h[o]}else{if("linepercent"===t||"stackedpercent"===t||"stackedpercent-invert"===t){const e=h[o]/c;if(h.percent=e,"linepercent"===t)h[l]=h[a]=h[s]=e;else{const t=c>0?e:0;h[l]=0===c?0:i/c,h[a]=h[l]+t,h[s]=h[l]+t/2}}else h[l]=i,h[a]=i+h[o],h[s]=i+h[o]/2;i+=h[o]}}}return e},Ft=({data:t,y1:e,x1:n,yPropTop:o,yPropMiddle:r,yPropBottom:s,xPropTop:i,xPropMiddle:a,xPropBottom:l})=>{if(e)for(const n of t)for(const t of n.data)t[s]=e(t),t[r]=t[o];if(n)for(const e of t)for(const t of e.data)t[l]=n(t),t[a]=(t[l]+t[i])/2;return t},Yt=({data:t,y1:e,yPropTop:n,yPropMiddle:o,yPropBottom:r,type:s="cumulative"})=>{for(const i of t){let t=0;const a="cumulative-reverse"===s?i.data.reverse():i.data;for(const s of a)t+=s[n],s[r]=s[n]=s[o]=t,e&&(s[r]=e(s),s[o]=s[r]+s[n]/2)}return t},Rt=({type:t="bumpline",data:e,xProp:n,yProp:o,yPropMiddle:r,yPropTop:s,yPropBottom:i})=>{const a=new Map;for(const t of e)for(const e of t.data){const t=Bt(e[n]);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=(t,e)=>t[o]>e[o]?1:-1;"bumparea-invert"!==t&&"bumpline-invert"!==t||(l=(t,e)=>e[o]>t[o]?1:-1);for(const[,e]of a){let n=0,a=0;e.sort(l);let c=1;for(const l of e)"bumparea"===t||"bumparea-invert"===t?0>l[o]?(l[s]=n+l[o],l[r]=n+l[o]/2,l[i]=n,n+=l[o]):(l[s]=a+l[o],l[r]=a+l[o]/2,l[i]=a,a+=l[o]):(l[o]=c,l[s]=c,l[i]=c),c++}return e};function Xt({pointA:t,pointB:e,currentParameters:n,parameters:o,keys:r}){const s={};return r.forEach(n=>{s[n]="number"==typeof t[n]?(t[n]+e[n])/2:void 0}),JSON.stringify(o(s))===JSON.stringify(n)?[s,e]:[t,s]}const It="x",Ht="y",Vt="yMiddle",Gt="yTop",qt="yBottom",Jt="xMiddle",Kt="xTop",Zt="xBottom";function Ut({preprocess:t=!0,processedData:e=!1,summaryType:n,data:r,finalXExtent:s,finalYExtent:i,size:a,xScaleType:l=o.scaleLinear(),yScaleType:c=o.scaleLinear(),margin:h,styleFn:d,classFn:p,renderFn:y,chartSize:m}){let g=s,x=i;if(!g){const t=r.coordinates.map(t=>t.x);g=[Math.min(...t),Math.max(...t)]}if(!x){const t=r.coordinates.map(t=>t.y);x=[Math.min(...t),Math.max(...t)]}if(e&&r)return r.coordinates;let b,v=[];b=n.type?n:{type:b};const{bins:k=.05,cellPx:E,binValue:w=t=>t.length,binMax:M,customMark:A}=b;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(t=>[t.x,t.y]));const S=Array.isArray(r)?r:[r],$=l.domain(g).range([0,a[0]]),P=c.domain(x).range([0,a[1]]),N=E&&E/2||(k>1?1/k:k)*a[0]/2,_=u.hexbin().x(t=>$(t._xyfPoint[0])).y(t=>P(t._xyfPoint[1])).radius(N).size(a);let O;const D=_.centers();return S.forEach(t=>{O=0;const e=_(t._xyfCoordinates.map((e,n)=>Object.assign({_xyfPoint:e},t.coordinates[n]))),n={};e.forEach(t=>{n[`${parseInt(t.x)}-${parseInt(t.y)}`]=!0}),D.forEach(t=>{if(!n[`${parseInt(t[0])}-${parseInt(t[1])}`]){const n=[];n.x=t[0],n.y=t[1],e.push(n)}}),O=Math.max(...e.map(t=>w(t))),M&&M(O);const o=[[0,-1],[.866,-.5],[.866,.5],[0,1],[-.866,.5],[-.866,-.5]],r=$.invert(N)-g[0],s=P.invert(N)-x[0],i=o.map(t=>[t[0]*r,t[1]*s]),l=e.map(e=>{const n=w(e),r=e.x,s=e.y;e.x=$.invert(e.x),e.y=P.invert(e.y);const l=n/O;return{customMark:A&&f.createElement("g",{transform:`translate(${r},${a[1]-s})`},A({d:Object.assign(Object.assign({},e),{binItems:e,percent:l,value:n,radius:N,hexCoordinates:o.map(t=>[t[0]*N,t[1]*N])}),margin:h,styleFn:d,classFn:p,renderFn:y,chartSize:m,adjustedSize:a})),_xyfCoordinates:i.map(t=>[t[0]+e.x,t[1]+e.y]),value:n,percent:l,data:e,parentSummary:t,centroid:!0}});v=[...v,...l]}),t?(v.forEach(t=>{t.x=t.data.x,t.y=t.data.y}),{type:"hexbin",processedData:!0,coordinates:v,binMax:O}):v}const Qt=(t,e,n,o)=>[...t.map((t,o)=>[t[0],t[1]+n(e[o])]),...t.map((t,n)=>[t[0],t[1]-o(e[n])]).reverse()];function te({preprocess:t=!0,processedData:e=!1,summaryType:n,data:r,finalXExtent:s=[Math.min(...r.coordinates.map(t=>t.x)),Math.max(...r.coordinates.map(t=>t.x))],finalYExtent:i=[Math.min(...r.coordinates.map(t=>t.y)),Math.max(...r.coordinates.map(t=>t.y))],size:a,xScaleType:l=o.scaleLinear(),yScaleType:c=o.scaleLinear(),margin:u,styleFn:h,classFn:d,renderFn:p,chartSize:y}){if(e&&r)return r.coordinates;r.coordinates&&!r._xyfCoordinates&&(r._xyfCoordinates=r.coordinates.map(t=>[t.x,t.y]));const m=Array.isArray(r)?r:[r];let g,x=[];g=n.type?n:{type:g};const{binValue:b=t=>t.length,xBins:v=g.yBins||.05,yBins:k=v,xCellPx:E=!g.xBins&&g.xCellPx,yCellPx:w=!g.yBins&&g.yCellPx,customMark:M,binMax:A}=g,S=1>v?v:1/v,$=1>k?k:1/k,P=l.domain(s).range([0,a[0]]),N=c.domain(i).range([a[1],0]),_=[Math.ceil((E&&E/a[0]||S)*a[0]*10)/10,Math.ceil((w&&w/a[1]||$)*a[1]*10)/10];let O=-1/0;return m.forEach(t=>{const e=[],n=[];let o,r;for(let s=0;a[0]>Math.ceil(s);s+=_[0]){const i=P.invert(s),l=P.invert(s+_[0]);r=[],e.push(r);for(let e=0;a[1]>Math.ceil(e);e+=_[1]){const a=N.invert(e),c=N.invert(e+_[1]);o={gx:s,gy:e,gw:_[0],gh:_[1],x:(i+l)/2,y:(a+c)/2,binItems:[],value:0,_xyfCoordinates:[[i,a],[l,a],[l,c],[i,c]],parentSummary:t},r.push(o),n.push(o)}r.push(o)}e.push(r),t._xyfCoordinates.forEach((n,o)=>{const r=P(n[0]),s=N(n[1]),i=Math.floor(r/_[0]),a=Math.floor(s/_[1]);e[i][a]&&e[i][a].binItems.push(t.coordinates[o])}),n.forEach(t=>{t.value=b(t.binItems),O=Math.max(O,t.value)}),n.forEach(t=>{t.percent=t.value/O,t.customMark=M&&f.createElement("g",{transform:`translate(${t.gx},${t.gy})`},M({d:t,margin:u,styleFn:h,classFn:d,renderFn:p,chartSize:y,adjustedSize:a}))}),x=[...x,...n]}),A&&A(O),t?{type:"heatmap",processedData:!0,_baseData:[],_xyfCoordinates:[],data:[],bounds:[],x:0,y:0,coordinates:x,binMax:O}:x}const ee=t=>t&&t.extent||Array.isArray(t)&&t||[],ne=()=>!0,oe={top:Gt,bottom:qt,orphan:Ht},re={top:Kt,bottom:Zt,orphan:It},se={stackedarea:Lt,"stackedarea-invert":Lt,stackedpercent:Lt,"stackedpercent-invert":Lt,linepercent:Lt,difference:({data:t,yProp:e,yPropTop:n,yPropBottom:o})=>(t.forEach((r,s)=>{r.data.forEach((r,i)=>{const a=0===s?1:0;r[e]>t[a].data[i][e]?(r[o]=t[a].data[i][e],r[n]=r[e]):(r[n]=r[e],r[o]=r[e])})}),t),bumparea:Rt,bumpline:Rt,"bumparea-invert":Rt,line:Ft,area:Ft,cumulative:Yt,"cumulative-reverse":Yt};function ie(t,e){const n=[];for(const t of e)n.push(Object.assign({},t));for(const e of t)e.parentSummary||n.push(e);return n}exports.Annotation=wt,exports.AnnotationLayer=function(e){const{legendSettings:n,margin:o,size:r,annotations:s,annotationHandling:i}=e,a=$t(t=>t.tooltip);let l=null!=a?s.concat(a):s,c=$t(t=>t.changeTooltip);const u=Object.assign(Object.assign({},e),{annotations:l,voronoiHover:t=>{c(t)}}),h="object"==typeof i?i:{layout:{type:i},dataVersion:""},{dataVersion:d=""}=h,[p,y]=t.useState([]),[m,g]=t.useState([]),[x,b]=t.useState([]),[v,k]=t.useState(""),[E,w]=t.useState(d),M=jt(u,l),A=M.filter(t=>t.props&&t.props.noteData&&!t.props.noteData.fixedPosition),S=Nt(A,h,r);let $;if(t.useEffect(()=>{const t=M.filter(t=>!t.props||!t.props.noteData||t.props.noteData.fixedPosition),e=Tt(u,{adjustedAnnotations:p,adjustedAnnotationsKey:v,adjustedAnnotationsDataVersion:E,adjustableAnnotations:A,fixedAnnotations:t});y(e.adjustedAnnotations),k(e.adjustedAnnotationsKey),w(e.adjustedAnnotationsDataVersion),g(e.svgAnnotations),b(e.htmlAnnotations)},[S,d,l.length,l.map(t=>function(t){const e=new Set;return JSON.stringify(t,(t,n)=>e.has(n)?"...":"object"==typeof n?(e.add(n),"note"===t?`${n.label}-${n.title}`:"connector"===t?`${n.end}-${n.type}`:"subject"===t?""+n.radius:"object"==typeof n.column?`${n.column.x}-${n.column.y}-${n.column.name}`:n.voronoiX||n.voronoiY||n.x||n.y||n.dx||n.dy||n.label||n.type||n.key||n.hierarchicalID||n.id||n.name?`${n.voronoiX}-${n.voronoiY}-${n.dx}-${n.dy}-${n.x}-${n.y}-${n.label}-${n.type}-${n.key}-${n.hierarchicalID}-${n.id}-${n.name}`:"..."):n)}(t)).join("-")]),n){const t={left:[15,15],right:[r[0]+15,15]},{position:e="right",title:o="Legend"}=n;$=f.createElement("g",{transform:`translate(${t[e].join(",")})`},f.createElement(W,Object.assign({},n,{title:o,position:e})))}return 0!==l.length||n?f.createElement("div",{className:"annotation-layer",style:{position:"absolute",pointerEvents:"none",background:"none"}},f.createElement("svg",{className:"annotation-layer-svg",height:r[1],width:r[0],style:{background:"none",pointerEvents:"none",position:"absolute",left:o.left+"px",top:o.top+"px",overflow:"visible"}},f.createElement("g",null,$,m)),f.createElement("div",{className:"annotation-layer-html",style:{background:"none",pointerEvents:"none",position:"absolute",height:r[1]+"px",width:r[0]+"px",left:o.left+"px",top:o.top+"px"}},x)):null},exports.Axis=function(e){const{rotate:n,label:o,dynamicLabelPosition:r,orient:s="left",marginalSummaryType:i,tickFormat:a=(i?()=>"":xt),size:l,width:c=l&&l[0]||0,height:u=l&&l[1]||0,className:h,padding:d,tickValues:p,scale:y,ticks:m,footer:g,tickSize:x,tickLineGenerator:b,baseline:v=!0,margin:k={top:0,bottom:0,left:0,right:0},center:E=!1,annotationFunction:w,glyphFunction:M,xyPoints:A}=e,[S,$]=t.useState(0),[P,N]=t.useState(void 0),_=t.useRef(null);t.useEffect(()=>{if(!(null==o?void 0:o.position)&&r){const t=((t,e)=>{const n=t.current;if(!n)return 30;const o="left"===e||"right"===e?"width":"height";return Math.max(...[...n.querySelectorAll(".axis-label")].map(t=>t.getBBox&&t.getBBox()||{height:30,width:30}).map(t=>t[o]))+25})(_,s);t!==P&&N(t)}},[o,r]);let O,{axisParts:D,position:j=[0,0]}=e;if(D||(D=function({renderMode:t=()=>{},padding:e=5,scale:n,ticks:o,tickValues:r=ft(void 0,o,n),orient:s="left",size:i,footer:a=!1,tickSize:l=(a?-10:["top","bottom"].find(t=>t===s)?i?i[1]:0:i?i[0]:0),jaggedBase:c}){let u,h,d,f,p,y,m=[],g=0,x=0,b="middle";switch(s){case"top":u="x1",h="x2",d="y1",f="y2",m=[0,l],p="tx",y="ty",g-=20-e;break;case"bottom":u="x1",h="x2",d="y2",f="y1",m=i?[i[1],i[1]-l]:[0,-l],p="tx",y="ty",g+=20+e;break;case"right":u="y2",h="y1",d="x2",f="x1",m=i?[i[0],i[0]-l]:[0,-l],p="ty",y="tx",g+=5+e,x+=5,b="start";break;default:u="y1",h="y2",d="x1",f="x2",m=[0,l],p="ty",y="tx",g-=5+e,x+=5,b="end"}let v=r instanceof Function?r({orient:s}):r;return c&&void 0===v.find(t=>t===n.domain()[0])&&(v=[n.domain()[0],...v]),v.map((e,o)=>{const r=n(e);return{[u]:r,[h]:r,[d]:m[0],[f]:m[1],[p]:r+x,[y]:m[0]+g,defaultAnchor:b,renderMode:t(e,o),value:e}})}({padding:d,tickValues:p,scale:y,ticks:m,orient:s,size:[c,u],footer:g,tickSize:x}),O=f.createElement("g",{className:"axis "+h},(({axisParts:t,orient:e,tickLineGenerator:n=dt,className:o,jaggedBase:r,scale:s,showOutboundTickLines:i=!1})=>{const a=t.map((t,i)=>n({xy:t,orient:e,i:i,className:o,jaggedBase:r,scale:s})),l=i?t.map((t,n)=>(({xy:t,orient:e,i:n,className:o=""})=>{let r=`M-4,${t.y1}L${t.x1},${t.y2}`;return"left"===e?r=`M${t.x1-8},${t.y1}L${t.x1},${t.y2}`:"right"===e?r=`M${t.x2},${t.y1}L${t.x2+8},${t.y2}`:"top"===e?r=`M${t.x1},${t.y1-8}L${t.x1},${t.y1}`:"bottom"===e&&(r=`M${t.x1},${t.y2}L${t.x1},${t.y2+8}`),f.createElement("path",{key:n,fill:"none",stroke:"currentColor",strokeWidth:"1px",d:r,className:`outbound-tick-line tick ${e} ${o}`})})({xy:t,orient:e,i:n,className:o})):[];return[...a,l]})({axisParts:D,orient:s,tickLineGenerator:b,className:h,scale:y}))),0===D.length)return null;let T,C,z,B,W=50,L=u,F=-50,Y=0,R=0,X=0,I=0,H=u,V=25,G=-25,q=18,J=c+25,K=0,Z=S,U=0,Q="y";switch(s){case"right":j=[j[0],j[1]],F=c,I=R=c,U=k.top,J=-c-25,G=5,T=t=>{$(t.nativeEvent.offsetY-U)},!0===E&&(I=R=c/2);break;case"top":j=[j[0],0],W=c,L=50,Y=-50,F=0,U=k.left,Q="x",I=c,H=0,!0===E&&(H=X=u/2),T=t=>{$(t.nativeEvent.offsetX-U)},V=S,Z=25,G=0,q=-10,J=0,K=u+25;break;case"bottom":j=[j[0],0],W=c,L=50,X=H=Y=u,R=F=0,I=c,U=k.left,T=t=>{$(t.nativeEvent.offsetX-U)},V=S,Z=25,G=0,q=15,J=0,K=-u-25,Q="x",!0===E&&(H=X=u/2);break;default:j=[j[0],j[1]],U=k.top,!0===E&&(I=R=c/2),T=t=>{$(t.nativeEvent.offsetY-U)}}if(w){const t=function(t,e){return e.tickFormat?e.tickFormat(t):t.toString?""+t:t}(y.invert(S),e),n=M?M({lineHeight:K,lineWidth:J,value:y.invert(S)}):f.createElement("g",null,f.isValidElement(t)?f.createElement("g",{transform:`translate(${G},${q})`},t):f.createElement("text",{x:G,y:q},t),f.createElement("circle",{r:5}),f.createElement("line",{x1:J,y1:K,style:{stroke:"black"}})),o=S?f.createElement("g",{style:{pointerEvents:"none"},transform:`translate(${V},${Z})`},n):null;C=f.createElement("g",{className:"annotation-brush",transform:`translate(${F},${Y})`},f.createElement("rect",{style:{fillOpacity:0},height:L,width:W,onMouseMove:T,onClick:t=>w({className:"dynamic-axis-annotation",type:Q,value:y.invert(S),e:t}),onMouseOut:()=>{$(void 0)}}),o)}if(i&&A){const t=Math.max(k[s]-6,5),e="string"==typeof i?{type:i}:i;void 0!==e.flip||"bottom"!==s&&"right"!==s||(e.flip=!0);const n=e.summaryStyle?()=>e.summaryStyle:()=>({fill:"black",fillOpacity:.5,stroke:"black",strokeDasharray:"0"}),o=e.renderMode?()=>e.renderMode:()=>{},r=e.summaryClass?()=>e.summaryClass:()=>"",a=e.filter||(()=>!0),c=A.filter(t=>void 0!==t.x&&void 0!==t.y&&a(t.data)).map(t=>Object.assign(Object.assign({},t),{xy:{x:"top"===s||"bottom"===s?y(t.x):0,y:"left"===s||"right"===s?y(t.y):0},piece:{scaledVerticalValue:y(t.y),scaledValue:y(t.x)},value:y("top"===s||"bottom"===s?t.y:t.x),scaledValue:y(t.x),scaledVerticalValue:y(t.y)})),u=function(t){const e=[];for(const n of t){const t=[],{elements:o,containerProps:r}=n;if(n.Mark)e.push(n.Mark);else{for(let e=0;o.length>e;e++){const n=o[e],{markType:r,style:s={}}=n,i=bt(n,["markType","style"]),a=Object.assign({},i);void 0!==s.fill&&(a.fill=s.fill),void 0!==s.stroke&&(a.stroke=s.stroke),void 0!==s.strokeWidth&&(a.strokeWidth=s.strokeWidth),void 0!==s.opacity&&(a.opacity=s.opacity),void 0!==s.fillOpacity&&(a.fillOpacity=s.fillOpacity),void 0!==s.strokeOpacity&&(a.strokeOpacity=s.strokeOpacity);const l=Object.assign({},s);delete l.fill,delete l.stroke,delete l.strokeWidth,delete l.opacity,delete l.fillOpacity,delete l.strokeOpacity,Object.keys(l).length>0&&(a.style=l),a.key=n.key||e,r&&t.push(f.createElement(r,a))}r?e.push(f.createElement("g",Object.assign({},r),t)):e.push(...t)}}return e}((({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:s,projection:i,adjustedSize:a,margin:l,axisCreator:c})=>{if(e&&e.type)return function({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:s,projection:i,adjustedSize:a,chartSize:l,margin:c,axisCreator:u}){return"function"==typeof e.type?e.type({data:t,type:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:s,projection:i,adjustedSize:a,chartSize:l,margin:c,axisCreator:u}):(console.error(`Invalid summary type: ${e.type} - Must be a function`),{})}({data:t,type:e="string"==typeof e?{type:e}:e,renderMode:n,eventListenersGenerator:o,styleFn:r,classFn:s,projection:i,adjustedSize:a,chartSize:"vertical"===i?a[1]:a[0],margin:l,axisCreator:c})})({data:{column:{middle:t/2,pieceData:c,width:t,xyData:c}},type:e,renderMode:o,eventListenersGenerator:e.eventListenersGenerator||(()=>({})),styleFn:n,classFn:r,projection:"top"===s||"bottom"===s?"horizontal":"vertical",adjustedSize:l,margin:{top:0,bottom:0,left:0,right:0}}).marks);let h;if(!0===e.showPoints){const n=((t,e,n)=>{const o="left"===t||"right"===t?e/2:0,r="bottom"===t||"top"===t?e/2:0;return n.map(t=>[t.xy.x+o,t.xy.y+r])})(s,t,c);h=n.map((t,n)=>f.createElement("circle",{key:"axis-summary-point-"+n,cx:t[0],cy:t[1],r:e.r||3,style:e.pointStyle||{fill:"black",fillOpacity:.1}}))}z=f.createElement(mt,{translation:{left:[2-k.left,0],right:[l[0]+2,0],top:[0,2-k.top],bottom:[0,l[1]+2]},orient:s,decoratedSummaryType:e,summaryWidth:t,renderedSummary:u,points:h})}const tt=(({axisParts:t,tickFormat:e,rotate:n=0,center:o=!1,orient:r})=>{const s=t.map((t,n)=>({axisPart:t,i:n,formatted:e(t.value,n)})),i="left"===r||"right"===r;let a=s;if(!n&&s.length>1){const t=8,e=14,n=8,o=t=>"string"==typeof t?t:"number"==typeof t?t+"":null;if("top"===r||"bottom"===r){const e=[...s].sort((t,e)=>t.axisPart.tx-e.axisPart.tx);let r=-1/0;const i=new Set;for(const s of e){const e=o(s.formatted);if(!e){i.add(s.i);continue}const a=e.length*t/2;r+n>s.axisPart.tx-a||(i.add(s.i),r=s.axisPart.tx+a)}a=s.filter(t=>i.has(t.i))}else if(i){const t=[...s].sort((t,e)=>t.axisPart.ty-e.axisPart.ty);let o=-1/0;const r=new Set;for(const s of t)o+e+n>s.axisPart.ty||(r.add(s.i),o=s.axisPart.ty);a=s.filter(t=>r.has(t.i))}}return a.map(({axisPart:t,i:e,formatted:s})=>{("object"!=typeof s||s instanceof Date)&&(s=f.createElement("text",{textAnchor:t.defaultAnchor,className:"axis-label"},s.toString?""+s:s));let i=t.tx,a=t.ty;if(o)switch(r){case"right":i-=(t.x2-t.x1)/2;break;case"left":i+=(t.x2-t.x1)/2;break;case"top":a+=(t.y2-t.y1)/2;break;case"bottom":a-=(t.y2-t.y1)/2}return f.createElement("g",{key:e,pointerEvents:"none",transform:`translate(${i},${a}) rotate(${n})`,className:"axis-label"},s)})})({tickFormat:a,axisParts:D,orient:s,rotate:n,center:E});if(o){const t=o.name||o,e=o.position||{};let n=e.anchor||"middle";const r=o.locationDistance||P,i=e.rotation||{left:-90,right:90,top:0,bottom:0}[s],a={left:{start:[0,l[1]],middle:[0,l[1]/2],end:[0,0],inside:[r||15,0],outside:[-(r||45),0]},right:{start:[l[0]+0,l[1]],middle:[l[0]+0,l[1]/2],end:[l[0]+0,0],inside:[-(r||15),0],outside:[r||45,0]},top:{start:[0,0],middle:[0+l[0]/2,0],end:[0+l[0],0],inside:[0,r||15],outside:[0,-(r||40)]},bottom:{start:[0,l[1]],middle:[0+l[0]/2,l[1]],end:[0+l[0],l[1]],inside:[0,-(r||5)],outside:[0,r||50]}},c=a[s][n],u=a[s][e.location||"outside"];c[0]=c[0]+u[0],c[1]=c[1]+u[1],"start"===n&&"right"===s?n="end":"end"===n&&"right"===s&&(n="start"),B=f.createElement(gt,{className:h,translation:c,position:j,rotation:i,labelName:t,anchorMod:n})}const et=`${s} axis ${D&&D.length>0&&`from ${a(D[0].value,0)} to ${a(D[D.length-1].value,D.length-1)}`||"without ticks"}`;return f.createElement("g",{className:h,"aria-label":et,ref:_},C,tt,O,!0===v?f.createElement("line",{key:"baseline",className:"axis-baseline "+h,stroke:"black",strokeLinecap:"square",x1:R,x2:I,y1:X,y2:H}):null,B,z)},exports.Brush=function(e){const{extent:o,selectedExtent:r}=e,s=t.useRef(null),i=zt(o),a=zt(r);t.useEffect(()=>{(null==s?void 0:s.current)&&((t,e)=>{const{svgBrush:o,selectedExtent:r}=e;if(n.select(t).call(o),r){let e=r;if(Array.isArray(r[0])){const t=[e[0][1],e[1][1]].sort((t,e)=>t-e);e=[[e[0][0],t[0]],[e[1][0],t[1]]]}n.select(t).call(o.move,e)}})(s.current,e)},[i,a,s]);const{position:l=[0,0]}=e;return f.createElement("g",{transform:`translate(${l})`,ref:s,className:"xybrush"})},exports.DividedLine=function(t){const e=(t=>{const{parameters:e,className:n,interpolate:o=a.curveLinear,customAccessors:r,lineDataAccessor:s,data:i,searchIterations:l}=t,c=bt(t,["parameters","className","interpolate","customAccessors","lineDataAccessor","data","searchIterations"]),{x:u,y:h}=r,d=Wt({data:i,lineDataAccessor:[s],xProp:"x",yProp:"y",xAccessor:[u],yAccessor:[h]});for(const t of d)t.data=t.data.map(t=>Object.assign(Object.assign({},t.data),t));const p=((t,e,n=10)=>{let o=t(e[0],0),r=[];const s=[{key:o,points:r}];return e.forEach((e,i)=>{const a=t(e,i);let l=a===o;const c=JSON.stringify(a),u=JSON.stringify(o);if("object"==typeof o&&(l=c===u),l)r.push(e);else{let i=r[r.length-1],l=e,u=c,h=0;for(;n>h&&c===u;){const e=Xt({pointA:i,pointB:l,currentParameters:o,parameters:t,keys:Object.keys(i)});i=e[0],l=e[1],u=JSON.stringify(t(l)),h++}r.push(l),r=[l,e],s.push({key:a,points:r}),o=a}}),s})(e,d[0].data,l),y=a.line().curve(o).x(t=>t.x).y(t=>t.y);return p.map((t,e)=>f.createElement("path",Object.assign({},c,{className:n,key:"DividedLine-"+e,style:t.key,d:y(t.points)})))})(t);return f.createElement("g",null,e)},exports.Legend=W,exports.MinimapChart=ht,exports.StreamXYFrame=tt,exports.calculateDataExtent=({lineDataAccessor:t,xAccessor:e,yAccessor:n,summaries:r,points:s,lines:i,lineType:l,showLinePoints:u,showSummaryPoints:h,xExtent:d,yExtent:f,invertX:p,invertY:m,summaryDataAccessor:g,summaryType:x,adjustedSize:b,margin:v,summaryStyleFn:k,summaryClassFn:E,summaryRenderModeFn:w,chartSize:M,filterRenderedLines:A,filterRenderedSummaries:S,filterRenderedPoints:$,defined:P=ne,annotations:N=[]})=>{let _=[],O=[],D=[],j=[],T=[];if(s){e.forEach((t,e)=>{n.forEach((n,o)=>{let r=0;for(const i of s){const s=t(i,r),a=n(i,r),l={x:s,y:a,data:i,xIndex:e,yIndex:o};Array.isArray(a)&&(l[qt]=Math.min(...a),l[Gt]=Math.max(...a),l[Vt]=(l[qt]+l[Gt])/2),Array.isArray(s)&&(l[Zt]=Math.min(...s),l[Kt]=Math.max(...s),l[Jt]=(l[Zt]+l[Kt])/2),D.push(l),r++}})});for(const t of D)_.push(Object.assign(Object.assign({},t),{[It]:t[Kt]||t[Zt]||t.x,[Ht]:t[Gt]||t[qt]||t.y}))}if(i){O=Wt({data:i,lineDataAccessor:t,xProp:It,xPropTop:Kt,xPropBottom:Zt,yProp:Ht,yPropTop:Gt,yPropBottom:qt,xAccessor:e,yAccessor:n}),j=function(t,e){return n=>se[((t,e)=>!se[t]||"difference"===t&&2!==e.length?"line":t)(t.type,n)](Object.assign(Object.assign(Object.assign({},t),e),{data:n}))}(l,{xProp:It,yProp:Ht,yPropMiddle:Vt,yPropTop:Gt,yPropBottom:qt,xPropMiddle:Jt,xPropTop:Kt,xPropBottom:Zt})(O);for(const t of j)for(let e=0;t.data.length>e;e++){const n=t.data[e];if(!P(Object.assign({},n.data,n),e))continue;const o={parentLine:t,y:n.y,x:n.x,xTop:n.xTop,xMiddle:n.xMiddle,xBottom:n.xBottom,yTop:n.yTop,yMiddle:n.yMiddle,yBottom:n.yBottom,data:n.data};n.percent&&(o.percent=n.percent),_.push(o)}if(u){const t=!0===u?Jt:re[u],e=!0===u?Vt:oe[u];j.forEach(n=>{n.data.filter((t,e)=>{if(P(Object.assign({},t.data,t))){if("orphan"===u){const t=n.data[e-1],o=n.data[e+1];return!(t&&P(Object.assign({},t.data,t))||o&&P(Object.assign({},o.data,o)))}return!0}return!1}).forEach(o=>{D.push(Object.assign(Object.assign({},o),{parentLine:n,[Ht]:void 0!==o[e]?o[e]:void 0!==o[Vt]?o[Vt]:void 0!==o[qt]?o[qt]:o.y,[It]:void 0!==o[t]?o[t]:void 0!==o[Jt]?o[Jt]:void 0!==o[Zt]?o[Zt]:o.y}))})})}}r&&(T=(({data:t,summaryDataAccessor:e,xAccessor:n,yAccessor:o})=>{const r=[];return e.forEach(e=>{n.forEach(n=>{o.forEach(o=>{const s=t=>e(t).map((t,e)=>[n(t,e),o(t,e)]);t.forEach(t=>{r.push(Object.assign(Object.assign({},t),{_baseData:e(t),_xyfCoordinates:s(t)}))})})})}),r})({data:r,summaryDataAccessor:g,xAccessor:e,yAccessor:n}),T.forEach(t=>{const e=t._baseData;t._xyfCoordinates.length>0&&t._xyfCoordinates[0][0][0]?t._xyfCoordinates[0].forEach(n=>{Array.isArray(n)&&n.map((n,o)=>Object.assign({parentSummary:t},e[o],{[It]:n[0],[Ht]:n[1]})).forEach(t=>{h&&D.push(Object.assign(Object.assign({x:0},t),{[Ht]:t[Gt]||t[qt]||t[Ht]})),_.push(Object.assign({x:0,y:0},t))})}):t._xyfCoordinates.length>0&&Array.isArray(t._xyfCoordinates)&&t._xyfCoordinates.map((n,o)=>Object.assign(Object.assign({parentSummary:t},e[o]),{[It]:n[0],[Ht]:n[1]})).forEach(t=>{h&&D.push(Object.assign(Object.assign({x:0},t),{[Ht]:t[Gt]||t[qt]||t[Ht]})),_.push(Object.assign({x:0,y:0},t))})}));let C,z,B,W,L=[],F=[];d&&!Array.isArray(d)&&!0===d.includeAnnotations&&e.forEach(t=>{N.forEach((e,n)=>{const o=t(e,n);isFinite(o)&&L.push({[It]:o})})}),f&&!Array.isArray(f)&&!0===f.includeAnnotations&&n.forEach(t=>{N.forEach((e,n)=>{const o=t(e,n);isFinite(o)&&F.push({[Ht]:o})})});for(const t of _){const e=void 0===t[Zt]?t[It]:Math.min(t[Kt],t[Zt]),n=void 0===t[Kt]?t[It]:Math.max(t[Zt],t[Kt]),o=void 0===t[qt]?t[Ht]:Math.min(t[Gt],t[qt]),r=void 0===t[Gt]?t[Ht]:Math.max(t[qt],t[Gt]);void 0===e||void 0!==C&&e>=C||(C=e),void 0===n||void 0!==z&&z>=n||(z=n),void 0===o||void 0!==B&&o>=B||(B=o),void 0===r||void 0!==W&&W>=r||(W=r)}for(const t of L){const e=t[It];void 0===e||void 0!==C&&e>=C||(C=e),void 0===e||void 0!==z&&z>=e||(z=e)}for(const t of F){const e=t[Ht];void 0===e||void 0!==B&&e>=B||(B=e),void 0===e||void 0!==W&&W>=e||(W=e)}const Y=[C,z],R=[B,W],X=ee(d),I=ee(f);let H=[I&&void 0!==I[0]?I[0]:R[0],I&&void 0!==I[1]?I[1]:R[1]],V=[X&&void 0!==X[0]?X[0]:Y[0],X&&void 0!==X[1]?X[1]:Y[1]];if(!p||X&&2===X.length||(V=[V[1],V[0]]),"bumpline"!==l.type&&!m||I&&2===I.length||(H=[H[1],H[0]]),x.type&&"contour"===x.type)T=function({summaryType:t,data:e,finalXExtent:n,finalYExtent:r}){let s=[];t.type||(t={type:t});const{resolution:i=500,thresholds:a=10,bandwidth:l=20,neighborhood:u}=t,h=o.scaleLinear().domain(n).rangeRound([0,i]).nice(),d=o.scaleLinear().domain(r).rangeRound([i,0]).nice();return e.forEach(t=>{let e=c.contourDensity().size([i,i]).x(t=>h(t[0])).y(t=>d(t[1])).thresholds(a).bandwidth(l)(t._xyfCoordinates);u&&(e=[e[0]]);const n=Math.max(...e.map(t=>t.value));e.forEach(e=>{e.parentSummary=t,e.bounds=[],e.percent=e.value/n,e.coordinates.forEach(t=>{t.forEach((n,o)=>{t[o]=n.map(t=>[h.invert(t[0]),d.invert(t[1])]),0===o&&e.bounds.push(function(t){let e=[1/0,0],n=[-1/0,0],o=[0,1/0],r=[0,-1/0];return t.forEach(t=>{e=e[0]>t[0]?t:e,n=t[0]>n[0]?t:n,r=t[1]>r[1]?t:r,o=o[1]>t[1]?t:o}),{center:[(e[0]+n[0])/2,(o[1]+r[1])/2],top:o,left:e,right:n,bottom:r}}(t[o]))})})}),s=[...s,...e]}),s}({summaryType:x,data:T,finalXExtent:V,finalYExtent:H});else if(x.type&&"linebounds"===x.type){if(T=function({summaryType:t,data:e,defined:n}){let o=[];t.type||(t={type:t});const{boundingAccessor:r,topBoundingAccessor:s=r,bottomBoundingAccessor:i=r}=t;return e.forEach(t=>{const e=t._baseData.map(n);let r=[],a=[];const l=[{xyf:a,base:r}];e.forEach((n,o)=>{!0===n?(r.push(t._baseData[o]),a.push(t._xyfCoordinates[o])):e[o+1]&&(r=[],a=[],l.push({xyf:a,base:r}))}),l.forEach(({xyf:e,base:n})=>{const r={data:t,parentSummary:t,_xyfCoordinates:Qt(e,n,s,i)};o=[...o,r]})}),o}({summaryType:x,data:T,defined:P}),!I||2!==I.length)for(const t of T)for(const e of t._xyfCoordinates){const t=e[1];void 0!==t&&isFinite(t)&&(H[0]>t&&(H[0]=t),t>H[1]&&(H[1]=t))}}else x.type&&"hexbin"===x.type?(T=Ut({summaryType:x,data:T[0],processedData:r&&!!r[0].processedData,preprocess:!1,finalXExtent:V,finalYExtent:H,size:b,margin:v,styleFn:k,classFn:E,renderFn:w,chartSize:M}),_=ie(_,T)):x.type&&"heatmap"===x.type?(T=te({summaryType:x,data:T[0],processedData:r&&!!r[0].processedData,preprocess:!1,finalXExtent:V,finalYExtent:H,size:b,margin:v,styleFn:k,classFn:E,renderFn:w,chartSize:M}),_=ie(_,T)):x.type&&"trendline"===x.type&&(T=function({preprocess:t=!1,summaryType:e,data:n,finalXExtent:r=[Math.min(...n.coordinates.map(t=>t.x)),Math.max(...n.coordinates.map(t=>t.x))],xScaleType:s=o.scaleLinear()}){if(t)return n[0].coordinates;let i,l=[];i=e.type?e:{type:i};const{regressionType:c="linear",order:u=2,precision:h=4,controlPoints:d=20,curve:f=a.curveCardinal}=i;let p=c;r[0]>=0||"logarithmic"!==c&&"power"!==c&&"exponential"!==c||(console.error(`Cannot use this ${c} regressionType type with value range that goes below 0, defaulting to linear`),p="linear"),n.coordinates&&!n._xyfCoordinates&&(n._xyfCoordinates=n.coordinates.map(t=>[t.x,t.y]));const m=Array.isArray(n)?n:[n],g=s.domain([0,1]).range(r);return l=[],m.forEach(t=>{const e=y.default[p](t._xyfCoordinates.map(t=>{let e=t[0],n=t[1];return"number"!=typeof e&&(e=e.getTime()),"number"!=typeof n&&(n=n.getTime()),[e,n]}),{order:u,precision:h}),n=1/d;let o=[0,1];if("linear"!==p){o=[];for(let t=0;1+n>t;t+=n)o.push(t)}const r=[];o.forEach(t=>{r.push(e.predict(g(t)))}),l.push({centroid:!1,customMark:void 0,data:t,parentSummary:t,value:e.string,r2:e.r2,curve:f,_xyfCoordinates:r})}),l}({summaryType:x,data:T[0],preprocess:r&&!!r[0].processedData,finalXExtent:V}),_=ie(_,T));return A&&(j=j.filter(A),_=_.filter((t,e)=>!t.parentLine||A(t.parentLine,e,[]))),$&&(_=_.filter($)),S&&(T=T.filter(S),_=_.filter((t,e)=>!t.parentSummary||S(t.parentSummary,e,[]))),{xExtent:V,yExtent:H,projectedLines:j,projectedPoints:D,projectedSummaries:T,fullDataset:_,calculatedXExtent:Y,calculatedYExtent:R}},exports.funnelize=function({data:t,steps:e,key:n}){const o=[];return Array.isArray(t)||(t=[t]),e||(e=t.map(t=>Object.keys(t)).reduce((t,e)=>t.concat(e),[])),t.forEach((t,r)=>{const s=n?t[n]:r;e.forEach(e=>{const n={funnelKey:s,stepName:"",stepValue:0};n.stepName=e,n.stepValue=t[e]?t[e]:0,o.push(n)})}),o},exports.heatmapping=te,exports.hexbinning=Ut;
1
+ "use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),i=require("d3-array"),s=require("d3-hierarchy"),r=require("d3-scale-chromatic");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const a=l(e),c=5e3;class u{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,c),bounded:!0,totalSize:e.length});let t=c;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+c,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class h{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class d{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function f(e,t,n,o,i){const s=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=s.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},s.set(a,c)),c.total+=l,i){const e=i(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return s}function m(e,t,n,o,i,s){const r=[],l=[];for(const i of e){const e=n(i),s=o(i);null==e||null==s||Number.isNaN(e)||Number.isNaN(s)||(r.push([t.x(e),t.y(s)]),l.push(s))}return{type:"line",path:r,rawValues:l,style:i,datum:e,group:s}}function g(e,t,n,o,i,s,r){const l=[],a=[];for(const s of e){const e=n(s),r=o(s);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const c=t.x(e);l.push([c,t.y(r)]),a.push([c,t.y(i)])}return{type:"area",topPath:l,bottomPath:a,style:s,datum:e,group:r}}function y(e,t,n,o,i,s,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:i,style:s,datum:e};return void 0!==r&&(c.pointId=r),c}function p(e,t,n,o,i,s,r){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:s,group:r}}function b(e,t,n,o,i,s){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:s}}function v(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function x(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class k{constructor(e){this.xExtent=new d,this.yExtent=new d,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new h(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=v(e.timeAccessor||e.xAccessor,"time"),this.getY=v(e.valueAccessor||e.yAccessor,"value")):(this.getX=v(e.xAccessor,"x"),this.getY=v(e.yAccessor,"y")),this.getGroup=x(e.groupAccessor),this.getCategory=x(e.categoryAccessor),this.getSize=e.sizeAccessor?v(e.sizeAccessor,"size"):void 0,this.getColor=x(e.colorAccessor),this.getBounds=e.boundsAccessor?v(e.boundsAccessor,"bounds"):void 0,this.getPointId=x(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=v(e.openAccessor,"open"),this.getHigh=v(e.highAccessor,"high"),this.getLow=v(e.lowAccessor,"low"),this.getClose=v(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new h(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):this.yExtent.push(this.getY(n)),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,i,s,r,l;const{config:a,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let d=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,m=a.yExtent?[null!==(i=a.yExtent[0])&&void 0!==i?i:h[0],null!==(s=a.yExtent[1])&&void 0!==s?s:h[1]]:h;const g=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!g&&c.size>0)if(a.normalize)m=[0,1+a.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);m=[0,o+(o>0?o*a.extentPadding:1)]}else if("bar"===a.chartType&&a.binSize&&!g&&c.size>0){const[,e]=function(e,t,n,o,i){const s=f(e,t,n,o,i);if(0===s.size)return[0,0];let r=0;for(const e of s.values())e.total>r&&(r=e.total);return[0,r]}(c,this.getX,this.getY,a.binSize,this.getCategory);m=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!g&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const s of e){const e=t(s);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;m=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!g&&m[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>m[1]&&(m[1]=e+n),m[0]>e-n&&(m[0]=e-n))}}const e=m[1]-m[0],t=e>0?e*a.extentPadding:1,n=null===(r=a.yExtent)||void 0===r?void 0:r[0],o=null===(l=a.yExtent)||void 0===l?void 0:l[1];m=[null!=n?m[0]:m[0]-t,null!=o?m[1]:m[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),m[0]!==1/0&&m[1]!==-1/0||(m=[0,1]),void 0!==a.arrowOfTime)if("x"==("up"===(y=a.arrowOfTime)||"down"===y?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(d).range(t),y:o.scaleLinear().domain(m).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(m).range([0,e.width]),y:o.scaleLinear().domain(d).range(t)}}else this.scales={x:o.scaleLinear().domain(d).range([0,e.width]),y:o.scaleLinear().domain(m).range([e.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const i=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,e);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,e);case"candlestick":return this.buildCandlestickScene(i,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],i=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=m(e.data,this.scales,this.getX,this.getY,t,e.key);i&&i.length>0&&(n.colorThresholds=i),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]);n.push(g(e.data,this.scales,this.getX,this.getY,o,t,e.key))}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,i,s){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),s=o(i);null==t||null==s||Number.isNaN(t)||Number.isNaN(s)||e.set(t,(e.get(t)||0)+s)}c.set(t.key,e)}let u;if(s){u=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;u.set(t,n||1)}}const h=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let i=e.get(n)||0;const l=d.get(n);s&&(i/=u.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+i)]),d.set(n,l+i)}h.push({type:"area",topPath:o,bottomPath:r,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let i=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let s=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];s=new Map;let o=0;for(const e of t)s.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=i(e))}if(s&&this.getColor){const t=this.getColor(o);t&&s.has(t)&&(e=Object.assign(Object.assign({},e),{fill:s.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=y(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=v(this.config.valueAccessor,"value"),i=new Set,s=new Set;for(const t of e)i.add(this.getX(t)),s.add(this.getY(t));const r=Array.from(i).sort((e,t)=>e-t),l=Array.from(s).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let h=1/0,d=-1/0;for(const{val:e}of u.values())h>e&&(h=e),e>d&&(d=e);const f=d-h||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=u.get(`${r[e]}_${l[t]}`);if(!o)continue;const i=(o.val-h)/f;n.push(b(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const s=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=v(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return s;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),m=(h-u||1)/r,g=(f-d||1)/l,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/m),r-1),i=Math.min(Math.floor((n-d)/g),l-1);if(0>o||0>i)continue;const s=`${o}_${i}`;let a=y.get(s);a||(a={sum:0,count:0,data:[]},y.set(s,a)),a.count++,a.sum+=c(t),a.data.push(t)}let p=1/0,x=-1/0;const k=new Map;for(const[e,t]of y){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}k.set(e,n),p>n&&(p=n),n>x&&(x=n)}const w=x-p||1,A=t.width/r,E=t.height/l;for(const[e,t]of k){const[n,o]=e.split("_"),i=+n,r=+o,a=(t-p)/w,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,u=y.get(e);s.push(b(i*A,(l-1-r)*E,A,E,c,{xi:i,yi:r,value:t,count:u.count,sum:u.sum,data:u.data}))}return s}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=f(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],i=new Set(t),s=Array.from(e).filter(e=>!i.has(e)).sort();o=[...t.filter(t=>e.has(t)),...s]}const i=[],s=this.scales,[r,l]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=s.x(n),u=s.x(a),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=s.y(n),a=s.y(n+o);i.push(p(h,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=s.y(0),n=s.y(e.total);i.push(p(h,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return i}buildSwarmScene(e){var t,n,o,i;const s=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,u=r.stroke,h=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),s.push(f)}return s}buildWaterfallScene(e,t){var n,o,i;const s=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return s;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#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 m=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),g=m+i;let y;y=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const b=r.x(o),v=0!==y?r.x(o+y):b+t.width/10,x=Math.min(b,v)+h/2,k=Math.max(b,v)-h/2-x;if(0>=k){m=g;continue}const w=r.y(m),A=r.y(g);s.push(p(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:m,cumEnd:g,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),m=g}return s}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},i=o.upColor||"#28a745",s=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,a,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(a),lowY:this.scales.y(u),bodyWidth:c,upColor:i,downColor:s,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const s=this.getBounds(t),r=this.scales.x(e);if(s&&0!==s)n.push([r,this.scales.y(i+s)]),o.push([r,this.scales.y(i-s)]);else{const e=this.scales.y(i);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,i;const s=this.config.decay;if(!s||1>=t)return 1;const r=null!==(n=s.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(s.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=s.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(i=s.stepThreshold)&&void 0!==i?i:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const i=null!==(n=o.duration)&&void 0!==n?n:500,s=t-e;return i>s?1-s/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=s,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,i,s;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,i,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(i=c.w)&&void 0!==i?i:r.w,r.h=null!==(s=c.h)&&void 0!==s?s:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function w(e,t,n){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function A(e,t,n){if(0===e.path.length)return null;const o=N(e.path,t);if(0>o)return null;const[i,s]=e.path[o],r=t-i,l=n-s,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function E(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function M(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function S(e,t,n){const o=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,s=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+r*r)}}return null}function O(e,t,n){if(0===e.topPath.length)return null;const o=N(e.topPath,t);if(0>o)return null;const[i,s]=e.topPath[o],r=t-i,l=n-s;return{node:e,datum:e.datum,x:i,y:s,distance:Math.sqrt(r*r+l*l)}}function N(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const L={fill:e=>a.createElement("rect",{style:e,width:20,height:20}),line:e=>a.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function j(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,L[n])(o(e,t)),i}function C(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:i=100,height:s=20,orientation:r="vertical"}=e,l="vertical"===r?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const i=[];return e.forEach((e,s)=>{o+=5,i.push(a.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,i.push(a.createElement("text",{key:"legend-text-"+s,y:o,className:"legend-group-label"},e.label)),o+=10),i.push(a.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:i}=e,s=[];let r=0;return i.forEach((e,i)=>{const l=j(e,i,n,o);s.push(a.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${r})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,a.createElement("text",{y:15,x:30},e.label))),r+=25}),s})(e,n))),o+=25*e.items.length+10}),i})({legendGroups:t,width:i,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let i=0;const s=[],r=!1===t?10:40;return e.forEach((t,l)=>{t.label&&(s.push(a.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${r}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),i+=20);const c=((e,t)=>{const{type:n="fill",styleFn:o,items:i}=e,s=[];let r=0;return i.forEach((e,i)=>{const l=j(e,i,n,o);s.push(a.createElement("g",{key:"legend-item-"+i,transform:`translate(${r},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,a.createElement("text",{y:15,x:25},e.label))),r+=35,r+=8*e.label.length}),{items:s,offset:r}})(t,o);s.push(a.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${r})`},c.items)),i+=c.offset+5,e[l+1]&&s.push(a.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:r-10,x2:i,y2:n+r+10})),i+=15}),a.createElement("g",null,!1!==t&&a.createElement("line",{x1:0,x2:i+10,y1:r-10,y2:r-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:t,title:o,height:s,customClickBehavior:n});return a.createElement("g",null,void 0!==o&&a.createElement("text",{className:"legend-title",y:20,x:"horizontal"===r?0:i/2,textAnchor:"horizontal"===r?"start":"middle"},o),l)}function _(e){return"string"==typeof e?{type:e}:e}function B({orient:t,config:n,values:o,scale:s,size:r,length:l}){const c=function(e){var t,n,o,i,s;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(s=e.strokeWidth)&&void 0!==s?s:1}}(n),u="top"===t||"bottom"===t,h=e.useMemo(()=>{if(0===o.length)return null;const e=s.domain(),n=r-8;if("boxplot"===c.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],r=s-o;return{q1:o,median:i,q3:s,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],s+1.5*r)}}(o);if(!e)return null;const{q1:i,median:r,q3:l,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*n,20),m=(n-f)/2+4;if(u){const e=s(i),n=s(l),o=s(r),u=s(h),g=s(d),y="top"===t?-1:1,p=0;return a.createElement("g",{"data-testid":"marginal-boxplot-"+t},a.createElement("line",{x1:u,y1:p+y*(m+f/2),x2:g,y2:p+y*(m+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:u,y1:p+y*m,x2:u,y2:p+y*(m+f),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:g,y1:p+y*m,x2:g,y2:p+y*(m+f),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("rect",{x:Math.min(e,n),y:"top"===t?p-m-f:p+m,width:Math.abs(n-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:o,y1:"top"===t?p-m-f:p+m,x2:o,y2:"top"===t?p-m:p+m+f,stroke:c.fill,strokeWidth:2}))}{const e=s(i),n=s(l),o=s(r),u=s(h),g=s(d),y="left"===t?-1:1,p=0;return a.createElement("g",{"data-testid":"marginal-boxplot-"+t},a.createElement("line",{x1:p+y*(m+f/2),y1:u,x2:p+y*(m+f/2),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:p+y*m,y1:u,x2:p+y*(m+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:p+y*m,y1:g,x2:p+y*(m+f),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("rect",{x:"left"===t?p-m-f:p+m,y:Math.min(e,n),width:f,height:Math.abs(n-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:"left"===t?p-m-f:p+m,y1:o,x2:"left"===t?p-m:p+m+f,y2:o,stroke:c.fill,strokeWidth:2}))}}const h=i.bin().domain(e).thresholds(c.bins)(o);if(0===h.length)return null;const d=Math.max(...h.map(e=>e.length));if(0===d)return null;if("histogram"===c.type)return a.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(u){const n=s(e.x0),r=s(e.x1)-s(e.x0);return a.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(r,.5),height:i,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth})}{const n=s(e.x0),r=s(e.x1)-s(e.x0);return a.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+r),width:i,height:Math.abs(r),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth})}}));if("violin"===c.type){const e=n/2+4,o=[];for(const i of h){if(null==i.x0||null==i.x1)continue;const r=i.length/d*(n/2),l=s((i.x0+i.x1)/2);o.push(u?`${l},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${l}`)}for(let i=h.length-1;i>=0;i--){const r=h[i];if(null==r.x0||null==r.x1)continue;const l=r.length/d*(n/2),a=s((r.x0+r.x1)/2);o.push(u?`${a},${"top"===t?-(e+l):e+l}`:`${"left"===t?-(e+l):e+l},${a}`)}return a.createElement("g",{"data-testid":"marginal-violin-"+t},a.createElement("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}))}if("ridgeline"===c.type){const e=[];if(u){const o=0,i=null!=h[0].x0?s(h[0].x0):0;e.push(`M${i},${o}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,r=s((o.x0+o.x1)/2);e.push(`L${r},${"top"===t?-i-4:i+4}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;e.push(`L${r},${o}`),e.push("Z")}else{const o=0,i=null!=h[0].x0?s(h[0].x0):0;e.push(`M${o},${i}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,r=s((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${r}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;e.push(`L${o},${r}`),e.push("Z")}return a.createElement("g",{"data-testid":"marginal-ridgeline-"+t},a.createElement("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}))}return null},[o,s,c,r,l,t,u,4]);return h?a.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function W(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),s=[];let r="";for(const e of i)r&&r.length+1+e.length>o?(s.push(r),r=e):r=r?`${r} ${e}`:e;return r&&s.push(r),s}function $(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function z(e){const{x:t=0,y:n=0,dx:o,dy:i,nx:s,ny:r,note:l,connector:c,subject:u,type:h,color:d,className:f,disable:m,events:g={},"data-testid":y}=e,p=new Set(Array.isArray(m)?m:[]);let b=o||0,v=i||0;null!=s&&(b=s-t),null!=r&&(v=r-n);const x="string"==typeof h?h:"label";if("bracket"===x&&u&&0===b&&0===v)if(void 0!==u.width){b=u.width/2;const e=u.depth||30;v=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;b=e+(0>e?-5:5),v=u.height/2}return a.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},g),!p.has("connector")&&function(e,t,n,o,i,s){const r=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==s?void 0:s.radius)){if("callout-rect"===i&&s){const n=s.width||0,o=s.height||0;if(n>0||o>0){const i=n/2,s=o/2,r=e-i,a=t-s;if(0!==r||0!==a){const e=Math.abs(r),t=Math.abs(a),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=i+r*d,c=s+a*d}}}else if("bracket"===i&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const n=(s.radius||0)+(s.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,c=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-c,2))>.5&&(r.push(a.createElement("line",{key:"connector-line",x1:l,y1:c,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,s=Math.atan2(t-c,e-l);r.push(a.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+n*Math.cos(s+i)},${c+n*Math.sin(s+i)}L${l+n*Math.cos(s-i)},${c+n*Math.sin(s-i)}Z`,fill:o||"currentColor",stroke:"none"}))}return a.createElement("g",{className:"annotation-connector"},r)}(b,v,c,d,x,u),!p.has("subject")&&function(e,t,n,o,i){var s;const r=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&r.push(a.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&r.push(a.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&r.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,s=i||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;r.push(a.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-s,x2:o,y2:(t.y2||0)-s,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-s;r.push(a.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?r.push(a.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||r.push(a.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(s=null==t?void 0:t.width)&&void 0!==s?s:null==t?void 0:t.height;void 0!==e&&r.push(a.createElement("path",{key:"bracket-path",d:$((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return a.createElement("g",{className:"annotation-subject"},r)}(x,u,d,t,n),!p.has("note")&&function(e,t,n,o){if(!e)return a.createElement("g",{className:"annotation-note"});const{label:i,title:s,orientation:r,align:l,wrap:c=120,noWrap:u}=e;if(!i&&!s)return a.createElement("g",{className:"annotation-note"});let h=r;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>t?"end":"start";const m=16,g=s?u?[s]:W(s,c):[],y=i?u?[i]:W(i,c):[],p="leftRight"===h?"end"===f?-4:4:0;let b=0;const v=[];g.length>0&&(v.push(a.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},g.map((e,t)=>a.createElement("tspan",{key:t,x:p,dy:0===t?0:m},e)))),b=g.length*m),y.length>0&&v.push(a.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:b},y.map((e,t)=>a.createElement("tspan",{key:t,x:p,dy:0===t?0:m},e))));let x=null;if((s||i)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(c,120);let t=0,n=e;"end"===f?(t=-e,n=0):"middle"===f&&(t=-e/2,n=e/2),x=a.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(g.length+y.length)*m+(y.length>0?m:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=a.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,g.length+y.length-1)*m;let w=0;return"topBottom"===h?w=0>n?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+m+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),a.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},a.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},v),x)}(l,b,v,d))}function P(e){var t,n;const{noteData:o}=e,{screenCoordinates:i}=o,s="string"==typeof o.type?o.type:"label",r=o.eventListeners||o.events||{};if(o.coordinates&&i){const e=o.nx||i[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),r=o.ny||i[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=i.map((t,n)=>{const i=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:r});return a.createElement(z,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:s}))});return a.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return a.createElement(z,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:r},o,{type:s}))}function H(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return s?null!=e.x?s(e.x):t.xAccessor&&null!=e[t.xAccessor]?s(e[t.xAccessor]):null:null}function T(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return s?null!=e.y?s(e.y):t.yAccessor&&null!=e[t.yAccessor]?s(e[t.yAccessor]):null:null}function I(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function F(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,s=Math.ceil(t/8);let r="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*i}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,s=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);r+=`L${o+4*i},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function D(e){return Math.round(100*e)/100+""}function R(t){const{width:n,height:o,totalWidth:i,totalHeight:r,margin:l,scales:c,showAxes:u,axes:h,xLabel:d,yLabel:f,xFormat:m,yFormat:g,showGrid:y,title:p,legend:b,foregroundGraphics:v,marginalGraphics:x,xValues:k,yValues:w,annotations:A,svgAnnotationRules:E,annotationFrame:M,xAccessor:S,yAccessor:O,annotationData:N,pointNodes:L,children:j}=t,W=e.useMemo(()=>u&&c?c.x.ticks(5).map(e=>({value:e,pixel:c.x(e),label:(m||D)(e)})):[],[u,c,m]),$=e.useMemo(()=>u&&c?c.y.ticks(5).map(e=>({value:e,pixel:c.y(e),label:(g||D)(e)})):[],[u,c,g]),z=e.useMemo(()=>{if(!A||0===A.length)return null;const e=function(e,t,n){var o,i,r,l,c,u,h,d,f,m,g,y,p,b,v,x,k,w,A,E,M,S,O,N,L,j,C,_,B,W,$,z;switch(e.type){case"label":{let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,i=t.y}else o=H(e,n),i=T(e,n);return null==o||null==i?null:I(o,i,n)?a.createElement(P,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,i=t.y}else o=H(e,n),i=T(e,n);return null==o||null==i?null:I(o,i,n)?a.createElement(P,{key:"ann-"+t,noteData:{x:o,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=H(e,n);if(null==o)return null;const i=e.color||"#f97316";return a.createElement("g",{key:"ann-"+t},a.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:o+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=T(e,n);if(null==o)return null;const i=e.color||"#f97316";return a.createElement("g",{key:"ann-"+t},a.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:H(Object.assign(Object.assign({},e),{type:"point"}),n),y:T(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const i=s.packEnclose(o),r=e.padding||10;return a.createElement("g",{key:"ann-"+t},a.createElement("circle",{cx:i.x,cy:i.y,r:i.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&a.createElement("text",{x:i.x,y:i.y-i.r-r-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:H(Object.assign(Object.assign({},e),{type:"point"}),n),y:T(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const i=e.padding||10,s=o.map(e=>e.x),r=o.map(e=>e.y),l=Math.min(...s)-i,c=Math.max(...s)+i,u=Math.min(...r)-i,h=Math.max(...r)+i;return a.createElement("g",{key:"ann-"+t},a.createElement("rect",{x:l,y:u,width:c-l,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&a.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],i="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],s=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return a.createElement("g",{key:"ann-"+t},i.map((t,o)=>{const i=H(t,n),r=T(t,n);return null==i||null==r?null:a.createElement("circle",Object.assign({key:o,cx:i,cy:r,r:e.r||6},s))}))}case"bracket":{const o=H(e,n),i=T(e,n);return a.createElement(P,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=i?i:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const s=n.data||[];if(2>s.length)return null;const d=n.xAccessor||"x",f=n.yAccessor||"y",m=s.map(e=>[e[d],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>m.length)return null;const g=null!==(i=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==i?i:null===(r=n.scales)||void 0===r?void 0:r.time,y=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!g||!y)return null;const p=e.method||"linear";let b;if("loess"===p)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),s=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,m=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*i[e],d+=t*s[e],f+=t*i[e]*i[e],m+=t*i[e]*s[e])}if(0===u){l.push([t,s[e]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([t,d/u]);else{const e=(u*m-h*d)/g;l.push([t,(d-e*h)/u+e*t])}}return l}(m,null!==(h=e.bandwidth)&&void 0!==h?h:.3);else{let t;try{const n=require("regression");t="polynomial"===p?n.polynomial(m,{order:e.order||2}):n.linear(m)}catch(e){return null}b=t.points}const v=b.map(([e,t])=>`${g(e)},${y(t)}`).join(" "),x=e.color||"#6366f1";return a.createElement("g",{key:"ann-"+t},a.createElement("polyline",{points:v,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:g(b[b.length-1][0])+4,y:y(b[b.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(m=n.scales)||void 0===m?void 0:m.value,i=null!==(g=null==o?void 0:o(e.y0))&&void 0!==g?g:0,s=null!==(y=null==o?void 0:o(e.y1))&&void 0!==y?y:n.height||0;return a.createElement("g",{key:"ann-"+t},a.createElement("rect",{x:0,y:Math.min(i,s),width:n.width||0,height:Math.abs(s-i),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:Math.min(i,s)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const i=n.yAccessor||"y",s=null!==(b=null===(p=n.scales)||void 0===p?void 0:p.x)&&void 0!==b?b:null===(v=n.scales)||void 0===v?void 0:v.time,r=null!==(k=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==k?k:null===(w=n.scales)||void 0===w?void 0:w.value;if(!s||!r)return null;const l=o.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,h=Math.sqrt(u),d=null!==(A=e.threshold)&&void 0!==A?A:2,f=c-d*h,m=!1!==e.showBand,g=e.fill||"#6366f1",y=null!==(E=e.fillOpacity)&&void 0!==E?E:.1,S=e.anomalyColor||"#ef4444",O=null!==(M=e.anomalyRadius)&&void 0!==M?M:6,N=r(c+d*h),L=r(f),j=o.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>d*h});return a.createElement("g",{key:"ann-"+t},m&&a.createElement("rect",{x:0,y:Math.min(N,L),width:n.width||0,height:Math.abs(L-N),fill:g,fillOpacity:y}),j.map((e,t)=>{const o=H(e,n),i=T(e,n);return null==o||null==i?null:a.createElement("circle",{key:t,cx:o,cy:i,r:O,fill:S,fillOpacity:.7,stroke:S,strokeWidth:1.5})}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:Math.min(N,L)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const i=n.xAccessor||"x",s=n.yAccessor||"y",r=null!==(O=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==O?O:null===(N=n.scales)||void 0===N?void 0:N.time,l=null!==(j=null===(L=n.scales)||void 0===L?void 0:L.y)&&void 0!==j?j:null===(C=n.scales)||void 0===C?void 0:C.value;if(!r||!l)return null;const c=o.map(e=>[e[i],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,s]of c)t+=e,n+=s,o+=e*e,i+=e*s;const s=e*o-t*t;if(1e-12>Math.abs(s))return null;const r=(e*i-t*n)/s,l=(n-r*t)/e;u=e=>l+r*e}const h=c.length,d=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(h-2,1)),m=c.reduce((e,t)=>e+t[0],0)/h,g=c.reduce((e,t)=>e+Math.pow(t[0]-m,2),0),y=null!==(_=e.confidence)&&void 0!==_?_:.95,p=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=null!==(B=e.steps)&&void 0!==B?B:5,v=c[h-1][0],x=(v-c[0][0])/Math.max(h-1,1),k=[];for(let e=1;b>=e;e++)k.push(v+e*x);const w=[];for(const e of k){const t=u(e),n=f*Math.sqrt(1+1/h+(g>0?Math.pow(e-m,2)/g:0))*p;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${r(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${r(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=w.map(e=>`${r(e.x)},${l(e.yCenter)}`).join(" "),M=`${r(v)},${l(u(v))}`,P=e.strokeColor||"#6366f1";return a.createElement("g",{key:"ann-"+t},a.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(W=e.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),a.createElement("polyline",{points:`${M} ${E}`,fill:"none",stroke:P,strokeWidth:null!==($=e.strokeWidth)&&void 0!==$?$:2,strokeDasharray:null!==(z=e.strokeDasharray)&&void 0!==z?z:"6,3"}),e.label&&w.length>0&&a.createElement("text",{x:r(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:P,fontSize:11},e.label))}default:return null}},t={scales:c?{x:c.x,y:c.y,time:c.x,value:c.y}:null,timeAxis:"x",xAccessor:S,yAccessor:O,width:n,height:o,data:N,frameType:"xy",pointNodes:L};return A.map((n,o)=>{if(E){const i=E(n,o,t);return null!=i?i:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[A,E,n,o,M,S,O,N]);return u||p||b||v||x||z&&z.length>0||y||j?a.createElement("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},a.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&c&&a.createElement("g",{className:"stream-grid"},W.map((e,t)=>a.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),$.map((e,t)=>a.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&(()=>{const e=null==h?void 0:h.find(e=>"left"===e.orient),t=null==h?void 0:h.find(e=>"bottom"===e.orient),i=!e||!1!==e.baseline,s=(null==e?void 0:e.jaggedBase)||!1,r=(null==t?void 0:t.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",u="var(--semiotic-text-secondary, #666)",m="var(--semiotic-text, #333)";return a.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!r&&a.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),r&&a.createElement("path",{d:F("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),W.map((e,t)=>a.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},a.createElement("line",{y2:5,stroke:c,strokeWidth:1}),a.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:u,style:{userSelect:"none"}},e.label))),d&&a.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:m,style:{userSelect:"none"}},d),i&&!s&&a.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),s&&a.createElement("path",{d:F("left",n,o),fill:"none",stroke:c,strokeWidth:1}),$.map((e,t)=>a.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},a.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),a.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:u,style:{userSelect:"none"}},e.label))),f&&a.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},f))})(),z,x&&c&&k&&w&&a.createElement(a.Fragment,null,x.top&&a.createElement("g",{transform:"translate(0, 0)"},a.createElement(B,{orient:"top",config:_(x.top),values:k,scale:c.x,size:l.top,length:n})),x.bottom&&a.createElement("g",{transform:`translate(0, ${o})`},a.createElement(B,{orient:"bottom",config:_(x.bottom),values:k,scale:c.x,size:l.bottom,length:n})),x.left&&a.createElement("g",{transform:"translate(0, 0)"},a.createElement(B,{orient:"left",config:_(x.left),values:w,scale:c.y,size:l.left,length:o})),x.right&&a.createElement("g",{transform:`translate(${n}, 0)`},a.createElement(B,{orient:"right",config:_(x.right),values:w,scale:c.y,size:l.right,length:o}))),v,j),p&&a.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof p?p:null),b&&a.createElement("g",{transform:`translate(${i-l.right+10}, ${l.top})`},"object"==typeof(R=b)&&null!==R&&!a.isValidElement(R)&&"legendGroups"in R?a.createElement(C,{legendGroups:b.legendGroups,title:"",width:100}):b)):null;var R}function G(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}const Y=(e,t,n,o)=>{var i;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const s=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;if(e.globalAlpha=s,e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},X=(e,t,n,o)=>{var i,s;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(s=t._pulseGlowRadius)&&void 0!==s?s:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},q=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?V(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function V(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=i+o,r=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=s)e.drawImage(n,r,o,i,i)}else{const s=i+o,r=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,r,i,i)}e.restore()}const U={line:[Y,(e,t,n,o)=>{const i=t.filter(e=>"line"===e.type);for(const s of i){if(2>s.path.length)continue;const r=s.style.stroke||"#007bff",l=s.style.strokeWidth||2,a=s.colorThresholds,c=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===s.path.length){let u=null,h=null,d=null,f=null,m=!1;function g(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),m=!0}function y(){m&&(e.stroke(),m=!1)}for(let p=0;s.path.length>p;p++){const[b,v]=s.path[p],x=c[p],k=G(x,a,r);if(null!==u&&null!==f&&null!==d){if(k===f)e.lineTo(b,v);else{const w=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||w.push({t:(E-d)/(x-d)})}w.sort((e,t)=>e.t-t.t);for(const M of w){const S=u+(b-u)*M.t,O=h+(v-h)*M.t,N=G(d+(x-d)*Math.min(M.t+1e-4,1),a,r);e.lineTo(S,O),y(),g(N,S,O)}e.lineTo(b,v)}u=b,h=v,d=x,f=k}else g(k,b,v),u=b,h=v,d=x,f=k}y()}else{e.beginPath(),e.strokeStyle=r;const[L,j]=s.path[0];e.moveTo(L,j);for(let C=1;s.path.length>C;C++)e.lineTo(s.path[C][0],s.path[C][1]);e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill;const[_,B]=s.path[0];e.moveTo(_,B);for(let $=1;s.path.length>$;$++)e.lineTo(s.path[$][0],s.path[$][1]);const W=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(W,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[Y],stackedarea:[Y],scatter:[X],bubble:[X],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);for(const t of i){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[q],swarm:[X],waterfall:[(e,t,n,o)=>{var i,s,r;q(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==a?void 0:a._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],i=l[t+1];if(!(null===(s=o.datum)||void 0===s?void 0:s.cumEnd)||!(null===(r=i.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(c,a),e.lineTo(u,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1))}}]},Z={top:20,right:20,bottom:30,left:40},J={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"},K={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 Q({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return a.createElement("div",{className:"semiotic-tooltip",style:K},a.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),a.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function ee({width:o,height:i,totalWidth:s,totalHeight:r,margin:l,dimension:c,scales:u,onBrush:h}){const d=e.useRef(null),f=e.useRef(null);return e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),s="x"===c?t.brushX():"y"===c?t.brushY():t.brush();return s.extent([[0,0],[o,i]]),s.on("brush end",e=>{if(!u)return;if(!e.selection)return void h(null);let t,n;if("x"===c){const[o,s]=e.selection;t=[u.x.invert(o),u.x.invert(s)],n=[u.y.invert(i),u.y.invert(0)]}else if("y"===c){const[i,s]=e.selection;t=[u.x.invert(0),u.x.invert(o)],n=[u.y.invert(s),u.y.invert(i)]}else{const[[o,i],[s,r]]=e.selection;t=[u.x.invert(o),u.x.invert(s)],n=[u.y.invert(r),u.y.invert(i)]}h({x:t,y:n})}),e.call(s),f.current=s,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null),f.current=null}},[o,i,c,u,h]),a.createElement("svg",{ref:d,width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},a.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const te=e.forwardRef(function(t,n){var o,i,s;const{chartType:r,runtimeMode:l,data:c,xAccessor:h,yAccessor:d,colorAccessor:f,sizeAccessor:m,groupAccessor:g,lineDataAccessor:y,normalize:p,binSize:b,valueAccessor:v,arrowOfTime:x="right",windowMode:N="sliding",windowSize:L=200,timeAccessor:j,xExtent:C,yExtent:_,extentPadding:B=.1,sizeRange:W,size:$=[500,300],margin:z,className:P,background:H,lineStyle:T,pointStyle:I,areaStyle:F,waterfallStyle:D,swarmStyle:G,barColors:Y,colorScheme:X,boundsAccessor:q,boundsStyle:V,openAccessor:K,highAccessor:te,lowAccessor:ne,closeAccessor:oe,candlestickStyle:ie,showAxes:se=!0,axes:re,xLabel:le,yLabel:ae,xFormat:ce,yFormat:ue,tickFormatTime:he,tickFormatValue:de,hoverAnnotation:fe,tooltipContent:me,customHoverBehavior:ge,enableHover:ye,annotations:pe,svgAnnotationRules:be,showGrid:ve,legend:xe,backgroundGraphics:ke,foregroundGraphics:we,title:Ae,categoryAccessor:Ee,brush:Me,onBrush:Se,decay:Oe,pulse:Ne,transition:Le,staleness:je,heatmapAggregation:Ce,heatmapXBins:_e,heatmapYBins:Be,marginalGraphics:We,pointIdAccessor:$e}=t,ze=Object.assign(Object.assign({},Z),z);if(We){const e=60;We.top&&e>ze.top&&(ze.top=e),We.bottom&&e>ze.bottom&&(ze.bottom=e),We.left&&e>ze.left&&(ze.left=e),We.right&&e>ze.right&&(ze.right=e)}const Pe=$[0]-ze.left-ze.right,He=$[1]-ze.top-ze.bottom,Te=null!=fe?fe:ye,Ie=e.useRef(null),Fe=e.useRef(0),De=e.useRef(!1),[Re,Ge]=e.useState(0),[Ye,Xe]=e.useState(null),qe=e.useRef(null),Ve=e.useRef(null),[Ue,Ze]=e.useState(null),[Je,Ke]=e.useState(!1),[Qe,et]=e.useState([]),[tt,nt]=e.useState([]),ot=e.useRef(()=>{}),it="streaming"===l||["bar","swarm","waterfall"].includes(r),st=e.useMemo(()=>({chartType:r,runtimeMode:it?"streaming":"bounded",windowSize:L,windowMode:N,arrowOfTime:it?x:"right",extentPadding:B,xAccessor:it?void 0:h,yAccessor:it?void 0:d,timeAccessor:it?j:void 0,valueAccessor:v,colorAccessor:f,sizeAccessor:m,groupAccessor:g,categoryAccessor:Ee,lineDataAccessor:y,xExtent:C,yExtent:_,sizeRange:W,binSize:b,normalize:p,boundsAccessor:q,boundsStyle:V,openAccessor:K,highAccessor:te,lowAccessor:ne,closeAccessor:oe,candlestickStyle:ie,lineStyle:T,pointStyle:I,areaStyle:F,swarmStyle:G,waterfallStyle:D,colorScheme:X,barColors:Y,annotations:pe,decay:Oe,pulse:Ne,transition:Le,staleness:je,heatmapAggregation:Ce,heatmapXBins:_e,heatmapYBins:Be,pointIdAccessor:$e}),[r,L,N,x,B,h,d,j,v,f,m,g,Ee,y,C,_,W,b,p,q,V,K,te,ne,oe,ie,T,I,F,G,D,X,Y,pe,Oe,Ne,Le,je,Ce,_e,Be,it,$e]),rt=e.useRef(null);rt.current||(rt.current=new k(st));const lt=e.useCallback(()=>{Fe.current||(Fe.current=requestAnimationFrame(()=>ot.current()))},[]);e.useEffect(()=>{var e;null===(e=rt.current)||void 0===e||e.updateConfig(st),De.current=!0,lt()},[st,lt]);const at=e.useRef(null);at.current||(at.current=new u(e=>{const t=rt.current;t&&t.ingest(e)&&(De.current=!0,lt())}));const ct=e.useCallback(e=>{var t;null===(t=at.current)||void 0===t||t.push(e)},[]),ut=e.useCallback(e=>{var t;null===(t=at.current)||void 0===t||t.pushMany(e)},[]),ht=e.useCallback(()=>{var e,t;null===(e=at.current)||void 0===e||e.clear(),null===(t=rt.current)||void 0===t||t.clear(),De.current=!0,lt()},[lt]);e.useImperativeHandle(n,()=>({push:ct,pushMany:ut,clear:ht,getData:()=>{var e,t;return null!==(t=null===(e=rt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=rt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=rt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[ct,ut,ht]),e.useEffect(()=>{var e;c&&(null===(e=at.current)||void 0===e||e.setBoundedData(c))},[c]);const dt=e.useRef(()=>{}),ft=e.useRef(()=>{});dt.current=e=>{if(!Te)return;const t=Ie.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-ze.left,i=e.clientY-n.top-ze.top;if(0>o||o>Pe||0>i||i>He)return void(qe.current&&(qe.current=null,Ve.current=null,Ze(null),ge&&ge(null),lt()));const s=rt.current;if(!s||0===s.scene.length)return;const r=function(e,t,n,o=30){let i=null;for(const s of e){let e=null;switch(s.type){case"point":e=w(s,t,n);break;case"line":e=A(s,t,n);break;case"rect":e=E(s,t,n);break;case"heatcell":e=M(s,t,n);break;case"area":if(!1===s.interactive)break;e=O(s,t,n);break;case"candlestick":e=S(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(s.scene,o,i);if(!r)return void(qe.current&&(qe.current=null,Ve.current=null,Ze(null),ge&&ge(null),lt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};qe.current=l,Ve.current=r.node,Ze(l),ge&&ge(l),lt()},ft.current=()=>{qe.current&&(qe.current=null,Ve.current=null,Ze(null),ge&&ge(null),lt())};const mt=e.useCallback(e=>dt.current(e),[]),gt=e.useCallback(()=>ft.current(),[]);ot.current=()=>{var e,t;Fe.current=0;const n=Ie.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=rt.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(s);l||i.computeScene({width:Pe,height:He});const a="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=$[0]*a,n.height=$[1]*a,n.style.width=$[0]+"px",n.style.height=$[1]+"px",o.scale(a,a),o.translate(ze.left,ze.top),o.clearRect(-ze.left,-ze.top,$[0],$[1]);const c=function(e){if(!e)return J;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return s||r||n?{axisStroke:l||J.axisStroke,tickText:s||J.tickText,crosshair:s?s+"66":J.crosshair,hoverFill:a?a+"4D":J.hoverFill,hoverStroke:s?s+"99":J.hoverStroke,pointRing:a||J.pointRing}:J}(n),u=null!==(e=null==je?void 0:je.threshold)&&void 0!==e?e:5e3,f=je&&i.lastIngestTime>0&&s-i.lastIngestTime>u;f&&(o.globalAlpha=null!==(t=null==je?void 0:je.dimOpacity)&&void 0!==t?t:.5);const m=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=H||(m&&"transparent"!==m?m:null);g&&(o.fillStyle=g,o.fillRect(-ze.left,-ze.top,$[0],$[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Pe,He),o.clip());const y=U[r];if(y&&i.scales)for(const e of y)e(o,i.scene,i.scales,{width:Pe,height:He});if(o.restore(),f&&(o.globalAlpha=1),Te&&qe.current&&i.scales&&function(e,t,n,o,i,s,r){if(!1===i.crosshair)return;e.save();const l="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(o,qe.current,Pe,He,"object"==typeof Te?Te:{},0,c),Ve.current&&Array.isArray(fe)){const e=fe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var i;if(!n)return;const s=n.group;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(o,i.scene,Ve.current,e)}const p=De.current;if(De.current=!1,p&&i.scales&&(Xe(i.scales),We)){const e=i.getData(),t="function"==typeof h?h:e=>e[h||"x"],n="function"==typeof d?d:e=>e[d||"y"];et(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),nt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}p&&pe&&pe.length>0&&Ge(e=>e+1),(null==je?void 0:je.showBadge)&&Ke(!!f),(l||i.hasActivePulses)&&(Fe.current=requestAnimationFrame(()=>ot.current()))},e.useEffect(()=>(lt(),()=>{Fe.current&&cancelAnimationFrame(Fe.current)}),[lt]),e.useEffect(()=>{De.current=!0,lt()},[r,Pe,He,se,H,T,lt]),e.useEffect(()=>{if(!je)return;const e=setInterval(()=>{var e;const t=rt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=je.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==Je&&(Ke(i),De.current=!0,lt())},1e3);return()=>clearInterval(e)},[je,Je,lt]);const yt=Te&&Ue?me?me(Ue):a.createElement(Q,{hover:Ue}):null,pt=yt?a.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:ze.left+Ue.x,top:ze.top+Ue.y,transform:`translate(${Ue.x>.7*Pe?"calc(-100% - 12px)":"12px"}, ${.3*He>Ue.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},yt):null;return a.createElement("div",{className:"stream-xy-frame"+(P?" "+P:""),role:"img","aria-label":"string"==typeof Ae?Ae:"XY chart",style:{position:"relative",width:$[0],height:$[1]},onMouseMove:Te?mt:void 0,onMouseLeave:Te?gt:void 0},ke&&a.createElement("svg",{style:{position:"absolute",left:0,top:0,width:$[0],height:$[1],pointerEvents:"none"}},ke),a.createElement("canvas",{ref:Ie,style:{position:"absolute",left:0,top:0}}),a.createElement(R,{width:Pe,height:He,totalWidth:$[0],totalHeight:$[1],margin:ze,scales:Ye,showAxes:se,axes:re,xLabel:le,yLabel:ae,xFormat:ce||he,yFormat:ue||de,showGrid:ve,title:Ae,legend:xe,foregroundGraphics:we,marginalGraphics:We,xValues:Qe,yValues:tt,annotations:pe,svgAnnotationRules:be,annotationFrame:Re,xAccessor:"string"==typeof h?h:"string"==typeof j?j:void 0,yAccessor:"string"==typeof d?d:"string"==typeof v?v:void 0,annotationData:null===(o=rt.current)||void 0===o?void 0:o.getData(),pointNodes:null===(i=rt.current)||void 0===i?void 0:i.scene.filter(e=>"point"===e.type)}),(Me||Se)&&a.createElement(ee,{width:Pe,height:He,totalWidth:$[0],totalHeight:$[1],margin:ze,dimension:null!==(s=null==Me?void 0:Me.dimension)&&void 0!==s?s:"xy",scales:Ye,onBrush:null!=Se?Se:()=>{}}),(null==je?void 0:je.showBadge)&&a.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===je.badgePosition?{top:4,left:4}:"bottom-left"===je.badgePosition?{bottom:4,left:4}:"bottom-right"===je.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Je?"#dc3545":"#28a745",color:"white"})},Je?"STALE":"LIVE"),pt)});te.displayName="StreamXYFrame";const ne={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},oe=r.schemeCategory10;function ie(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):oe[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%oe.length]}function se(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[s,r]=o,[l,a]=n;return r===s?(l+a)/2:l+(i-s)/(r-s)*(a-l)}function re(e){return e?"string"==typeof e?{name:e}:e:null}function le(e,t,n){return t?o=>{var i,s;const r=Object.assign({},e(o));return t.isActive&&(t.predicate(o)?(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle):(r.fillOpacity=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2,r.strokeOpacity=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle))),r}:e}function ae(t){const n=e.createContext(null),o=ce(t);return[function({children:o}){const i=e.useMemo(()=>ce(t),[]);return a.createElement(n.Provider,{value:i,children:o})},t=>{var i;const s=null!==(i=e.useContext(n))&&void 0!==i?i:o;return function(t,n){const[o,i]=e.useState(n);return e.useLayoutEffect(()=>t(()=>i(n)),[t]),o}(s.subscribe,()=>t(s.getState()))}]}function ce(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function ue(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function he(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[de,fe]=ae(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=he(o,t),s=new Map(i.clauses);return s.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:s})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),s=new Map(o.clauses);return s.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:s})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=he(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function me(t){const n=e.useId(),o=t.clientId||n,{name:i}=t,s=fe(e=>e.selections.get(i)),r=fe(e=>e.setClause),l=fe(e=>e.clearClause),a=e.useMemo(()=>!!s&&s.clauses.size>0,[s]);return{predicate:e.useMemo(()=>s&&0!==s.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(ue(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(s,o):()=>!0,[s,o]),isActive:a,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(i,{clientId:o,type:"point",fields:t})},[o,i,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(i,{clientId:o,type:"interval",fields:t})},[o,i,r]),clear:e.useCallback(()=>{l(i,o)},[l,i,o]),clientId:o}}function ge(t){const{name:n,xField:o,yField:i}=t,{predicate:s,isActive:r,selectInterval:l,clear:a}=me({name:n}),c=o&&i?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void a();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[c,o,i,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:s,isActive:r,clear:a}}const[ye,pe]=ae(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),be="#007bff";function ve(e){return"function"==typeof e?e:t=>t[e]}function xe(t,n,i="category10"){return e.useMemo(()=>{if(n&&"function"!=typeof n)return function(e,t,n="category10"){const i=Array.from(new Set(e.map(e=>e[t]))),s=i.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const r=ne[n]||ne.category10;if(s&&"function"==typeof r)return e=>r(Number(e)/Math.max(...i.map(Number)));{const e=Array.isArray(r)?r:oe;return o.scaleOrdinal().domain(i).range(e).unknown("#999")}}(t,n,i)},[t,n,i])}function ke({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:s,chartType:r,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=me({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:s,selectPoints:r,clear:l}=me({name:n});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&r(t)},[o,r,l]),predicate:i,isActive:s}}({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||[]}),h=pe(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,o;if(n){let t=e&&(e.data||e.datum)||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}if(s||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});s&&s(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});s&&s(e),h&&h(e)}}},[n,u,s,r,l,h]),customClickBehavior:e.useCallback(e=>{var t,n;if(s||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});s&&s(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});s&&s(e),h&&h(e)}}},[s,h,r,l])}}function we({data:t,colorBy:n,colorScale:o,showLegend:i,userMargin:s,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=void 0!==i?i:!!n,a=e.useMemo(()=>{if(l&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:s}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==s&&(t.strokeWidth=s),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),r=s?o(s,t,n):n?n(i):"#000000";return{label:i+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:ie})},[l,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),s);return a&&120>e.right&&(e.right=120),e},[r,s,a]);return{legend:a,margin:c}}const Ae={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 Ee(e,t,n){var o,i,s,r,l,a;const c=Ae[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Me={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Se(e,t){return"function"==typeof t?t(e):e[t]}function Oe(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ne(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:n,format:o,style:i={},className:s=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let r;const l=[];if(n){const t=Se(e,n);r=Oe(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,i,s;"string"==typeof t?(n=t,i=t,s=o):(n=t.label,i=t.accessor||t.key||"",s=t.format||o);const r=Se(e,i);l.push({label:n,value:Oe(r,s)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){r=Oe(e[n],o);break}if(!r){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(r=Oe(e[t[0]],o))}}const c=Object.assign(Object.assign({},Me),i);return a.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:c},r&&a.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},r),l.map((e,t)=>a.createElement("div",{key:t,style:{marginTop:0===t&&r?"4px":0}},e.label&&a.createElement("span",null,e.label,": "),e.value)))}}(e)))}function Le(e){return"string"==typeof e?e:"value"}function je(e){return t=>{const n=t.data;return n?a.createElement("div",{className:"semiotic-tooltip",style:Me},e.map((e,t)=>{const o=function(e,t){return"function"==typeof t?t(e):e[t]}(n,e.accessor),i=null==(s=o)?"–":"number"==typeof s?s.toLocaleString():s instanceof Date?s.toLocaleDateString():s+"";var s;return a.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},a.createElement("span",{style:{opacity:.8}},e.label,": "),a.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},i))})):null}}function Ce({componentName:e,message:t,width:n,height:o}){return a.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},a.createElement("div",{style:{textAlign:"center",maxWidth:400}},a.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),a.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}function _e({data:e,accessors:t,requiredProps:n}){if(n)for(const[e,t]of Object.entries(n))if(null==t)return e+" is required. Provide a field name or function.";if(!e||!Array.isArray(e)||0===e.length)return"No data provided. Pass a non-empty array to the data prop.";if(t)for(const n of function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(e))if(n&&"object"==typeof n)for(const[e,o]of Object.entries(t))if(o&&"string"==typeof o&&!(o in n))return`${e} "${o}" not found in data. Available fields: ${Object.keys(n).join(", ")}.`;return null}function Be(t){var n,o;const i=Ee(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:r,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:d="y",lineBy:f,lineDataAccessor:m="coordinates",colorBy:g,colorScheme:y="category10",curve:p="linear",showPoints:b=!1,pointRadius:v=3,fillArea:x=!1,areaOpacity:k=.3,lineWidth:w=2,tooltip:A,pointIdAccessor:E,annotations:M,frameProps:S={},selection:O,linkedHover:N,onObservation:L,chartId:j}=t,C=i.width,_=i.height,B=i.enableHover,W=i.showGrid,$=i.showLegend,z=i.title,P=i.xLabel,H=i.yLabel,T=s||[],{activeSelectionHook:I,customHoverBehavior:F}=ke({selection:O,linkedHover:N,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:L,chartType:"LineChart",chartId:j}),D=void 0!==(null===(n=T[0])||void 0===n?void 0:n[m]),R=e.useMemo(()=>{if(D)return T;if(f){const e=T.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[m]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:T}]},[T,f,m,D]),G=xe(T,g,y),Y=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=g?ie(e,g,G):be,x&&(t.fill=t.stroke,t.fillOpacity=k),t},[g,G,w,x,k]),X=e.useMemo(()=>le(Y,I,O),[Y,I,O]),q=e.useMemo(()=>{if(b)return e=>{const t={r:v,fillOpacity:1};return t.fill=g?ie(e.parentLine||e,g,G):be,t}},[b,v,g,G]),V=x?"area":"line",{legend:U,margin:Z}=we({data:R,colorBy:g,colorScale:G,showLegend:$,userMargin:r,defaults:i.marginDefaults}),J=f||g,K=e.useMemo(()=>je([{label:P||Le(h),accessor:h,role:"x"},{label:H||Le(d),accessor:d,role:"y"},...J?[{label:Le(J),accessor:J,role:"group"}]:[]]),[h,d,P,H,J]),Q=_e({componentName:"LineChart",data:D?(null===(o=T[0])||void 0===o?void 0:o[m])||[]:T,accessors:{xAccessor:h,yAccessor:d}});if(Q)return a.createElement(Ce,{componentName:"LineChart",message:Q,width:C,height:_});const ee=e.useMemo(()=>D||f?R.flatMap(e=>{const t=e[m]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):T,[R,m,D,f,T]),ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:V,data:ee,xAccessor:h,yAccessor:d,groupAccessor:f||void 0,curve:p,lineStyle:X},b&&{pointStyle:q}),{size:[C,_],margin:Z,showAxes:i.showAxes,xLabel:P,yLabel:H,xFormat:c,yFormat:u,enableHover:B,showGrid:W}),U&&{legend:U}),z&&{title:z}),l&&{className:l}),{tooltipContent:A?Ne(A):K}),(N||L)&&{customHoverBehavior:F}),E&&{pointIdAccessor:E}),M&&M.length>0&&{annotations:M}),S);return a.createElement(te,Object.assign({},ne))}function We(t){var n;const o=Ee(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:r,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:m,colorScheme:g="category10",curve:y="monotoneX",areaOpacity:p=.7,showLine:b=!0,lineWidth:v=2,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,onObservation:M,chartId:S}=t,O=o.width,N=o.height,L=o.enableHover,j=o.showGrid,C=o.showLegend,_=o.title,B=o.xLabel,W=o.yLabel,$=i||[],{activeSelectionHook:z,customHoverBehavior:P}=ke({selection:A,linkedHover:E,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:M,chartType:"AreaChart",chartId:S}),H=void 0!==(null===(n=$[0])||void 0===n?void 0:n[f]),T=e.useMemo(()=>{if(H)return $;if(d){const e=$.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:$}]},[$,d,f,H]),I=xe($,m,g),F=e.useMemo(()=>e=>{const t={},n=m?ie(e,m,I):be;return t.fill=n,t.fillOpacity=p,b?(t.stroke=n,t.strokeWidth=v):t.stroke="none",t},[m,I,p,b,v]),D=e.useMemo(()=>le(F,z,A),[F,z,A]),{legend:R,margin:G}=we({data:T,colorBy:m,colorScale:I,showLegend:C,userMargin:s,defaults:o.marginDefaults}),Y=d||m,X=e.useMemo(()=>je([{label:B||Le(u),accessor:u,role:"x"},{label:W||Le(h),accessor:h,role:"y"},...Y?[{label:Le(Y),accessor:Y,role:"group"}]:[]]),[u,h,B,W,Y]),q=_e({componentName:"AreaChart",data:$,accessors:{xAccessor:u,yAccessor:h}});if(q)return a.createElement(Ce,{componentName:"AreaChart",message:q,width:O,height:N});const V=e.useMemo(()=>H||d?T.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):$,[T,f,H,d,$]),U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:V,xAccessor:u,yAccessor:h,groupAccessor:d||void 0,curve:y,lineStyle:D,size:[O,N],margin:G,showAxes:o.showAxes,xLabel:B,yLabel:W,xFormat:l,yFormat:c,enableHover:L,showGrid:j},R&&{legend:R}),_&&{title:_}),r&&{className:r}),{tooltipContent:x?Ne(x):X}),(E||M)&&{customHoverBehavior:P}),k&&k.length>0&&{annotations:k}),w);return a.createElement(te,Object.assign({},U))}function $e(t){var n;const o=Ee(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:r,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:m,colorScheme:g="category10",curve:y="monotoneX",areaOpacity:p=.7,showLine:b=!0,lineWidth:v=2,normalize:x=!1,tooltip:k,annotations:w,frameProps:A={},selection:E,linkedHover:M,onObservation:S,chartId:O}=t,N=o.width,L=o.height,j=o.enableHover,C=o.showGrid,_=o.showLegend,B=o.title,W=o.xLabel,$=o.yLabel,z=i||[],{activeSelectionHook:P,customHoverBehavior:H}=ke({selection:E,linkedHover:M,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:S,chartType:"StackedAreaChart",chartId:O}),T=void 0!==(null===(n=z[0])||void 0===n?void 0:n[f]),I=e.useMemo(()=>{if(T)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:z}]},[z,d,f,T]),F=xe(z,m,g),D=e.useMemo(()=>e=>{const t={},n=m?ie(e,m,F):be;return t.fill=n,t.fillOpacity=p,b?(t.stroke=n,t.strokeWidth=v):t.stroke="none",t},[m,F,p,b,v]),R=e.useMemo(()=>le(D,P,E),[D,P,E]),{legend:G,margin:Y}=we({data:I,colorBy:m,colorScale:F,showLegend:_,userMargin:s,defaults:o.marginDefaults}),X=d||m,q=e.useMemo(()=>je([{label:W||Le(u),accessor:u,role:"x"},{label:$||Le(h),accessor:h,role:"y"},...X?[{label:Le(X),accessor:X,role:"group"}]:[]]),[u,h,W,$,X]),V=_e({componentName:"StackedAreaChart",data:z,accessors:{xAccessor:u,yAccessor:h}});if(V)return a.createElement(Ce,{componentName:"StackedAreaChart",message:V,width:N,height:L});const U=e.useMemo(()=>T||d?I.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[I,f,T,d,z]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:u,yAccessor:h,groupAccessor:d||void 0,curve:y,normalize:x,lineStyle:R,size:[N,L],margin:Y,showAxes:o.showAxes,xLabel:W,yLabel:$,xFormat:l,yFormat:c,enableHover:j,showGrid:C},G&&{legend:G}),B&&{title:B}),r&&{className:r}),{tooltipContent:k?Ne(k):q}),(M||S)&&{customHoverBehavior:H}),w&&w.length>0&&{annotations:w}),A);return a.createElement(te,Object.assign({},Z))}function ze(t){const n=Ee(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:s,xFormat:r,yFormat:l,xAccessor:c="x",yAccessor:u="y",colorBy:h,colorScheme:d="category10",sizeBy:f,sizeRange:m=[3,15],pointRadius:g=5,pointOpacity:y=.8,tooltip:p,marginalGraphics:b,pointIdAccessor:v,annotations:x,frameProps:k={},selection:w,linkedHover:A,linkedBrush:E,onObservation:M,chartId:S}=t,O=n.width,N=n.height,L=n.enableHover,j=n.showGrid,C=n.showLegend,_=n.title,B=n.xLabel,W=n.yLabel,$=o||[],{activeSelectionHook:z,customHoverBehavior:P}=ke({selection:w,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:M,chartType:"Scatterplot",chartId:S}),H=re(E);ge({name:(null==H?void 0:H.name)||"__unused_brush__",xField:(null==H?void 0:H.xField)||("string"==typeof c?c:void 0),yField:(null==H?void 0:H.yField)||("string"==typeof u?u:void 0)});const T=xe($,h,d),I=e.useMemo(()=>{if(!f||0===$.length)return;const e=$.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[$,f]),F=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=h?ie(e,h,T):be,t.r=f?se(e,f,m,I):g,t},[h,T,f,m,I,g,y]),D=e.useMemo(()=>le(F,z,w),[F,z,w]),{legend:R,margin:G}=we({data:$,colorBy:h,colorScale:T,showLegend:C,userMargin:i,defaults:n.marginDefaults}),Y=e.useMemo(()=>je([{label:B||Le(c),accessor:c,role:"x"},{label:W||Le(u),accessor:u,role:"y"},...h?[{label:Le(h),accessor:h,role:"color"}]:[],...f?[{label:Le(f),accessor:f,role:"size"}]:[]]),[c,u,B,W,h,f]),X=_e({componentName:"Scatterplot",data:$,accessors:{xAccessor:c,yAccessor:u}});if(X)return a.createElement(Ce,{componentName:"Scatterplot",message:X,width:O,height:N});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:$,xAccessor:c,yAccessor:u,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:m,pointStyle:D,colorScheme:d,size:[O,N],margin:G,showAxes:n.showAxes,xLabel:B,yLabel:W,xFormat:r,yFormat:l,enableHover:L,showGrid:j},R&&{legend:R}),_&&{title:_}),s&&{className:s}),{tooltipContent:p?Ne(p):Y}),(A||M)&&{customHoverBehavior:P}),b&&{marginalGraphics:b}),v&&{pointIdAccessor:v}),x&&x.length>0&&{annotations:x}),k);return a.createElement(te,Object.assign({},q))}function Pe(t){const n=Ee(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:s,xFormat:r,yFormat:l,xAccessor:c="x",yAccessor:u="y",sizeBy:h,sizeRange:d=[5,40],colorBy:f,colorScheme:m="category10",bubbleOpacity:g=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:p="white",tooltip:b,marginalGraphics:v,pointIdAccessor:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,linkedBrush:M,onObservation:S,chartId:O}=t,N=n.width,L=n.height,j=n.enableHover,C=n.showGrid,_=n.showLegend,B=n.title,W=n.xLabel,$=n.yLabel,z=o||[],{activeSelectionHook:P,customHoverBehavior:H}=ke({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:S,chartType:"BubbleChart",chartId:O}),T=re(M);ge({name:(null==T?void 0:T.name)||"__unused_brush__",xField:(null==T?void 0:T.xField)||("string"==typeof c?c:void 0),yField:(null==T?void 0:T.yField)||("string"==typeof u?u:void 0)});const I=xe(z,f,m),F=e.useMemo(()=>{const e=z.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[z,h]),D=e.useMemo(()=>e=>{const t={fillOpacity:g,strokeWidth:y,stroke:p};return t.fill=f?ie(e,f,I):be,t.r=se(e,h,d,F),t},[f,I,h,d,F,g,y,p]),R=e.useMemo(()=>le(D,P,A),[D,P,A]),{legend:G,margin:Y}=we({data:z,colorBy:f,colorScale:I,showLegend:_,userMargin:i,defaults:n.marginDefaults}),X=e.useMemo(()=>je([{label:W||Le(c),accessor:c,role:"x"},{label:$||Le(u),accessor:u,role:"y"},{label:Le(h),accessor:h,role:"size"},...f?[{label:Le(f),accessor:f,role:"color"}]:[]]),[c,u,W,$,h,f]),q=_e({componentName:"BubbleChart",data:z,accessors:{xAccessor:c,yAccessor:u},requiredProps:{sizeBy:h}});if(q)return a.createElement(Ce,{componentName:"BubbleChart",message:q,width:N,height:L});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:z,xAccessor:c,yAccessor:u,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:d,pointStyle:R,colorScheme:m,size:[N,L],margin:Y,showAxes:n.showAxes,xLabel:W,yLabel:$,xFormat:r,yFormat:l,enableHover:j,showGrid:C},G&&{legend:G}),B&&{title:B}),s&&{className:s}),{tooltipContent:b?Ne(b):X}),(E||S)&&{customHoverBehavior:H}),v&&{marginalGraphics:v}),x&&{pointIdAccessor:x}),k&&k.length>0&&{annotations:k}),w);return a.createElement(te,Object.assign({},V))}function He(t){const n=Ee(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:l,xAccessor:c="x",yAccessor:u="y",valueAccessor:h="value",xFormat:d,yFormat:f,colorScheme:m="blues",customColorScale:g,showValues:y=!1,valueFormat:p,cellBorderColor:b="#fff",cellBorderWidth:v=1,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,onObservation:M,chartId:S}=t,O=n.width,N=n.height,L=n.enableHover,j=n.title,C=n.xLabel,_=n.yLabel,B=i||[],{margin:W}=we({data:B,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:s,defaults:n.marginDefaults}),{activeSelectionHook:$,customHoverBehavior:z}=ke({selection:A,linkedHover:E,fallbackFields:[],onObservation:M,chartType:"Heatmap",chartId:S}),P=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),H=e.useMemo(()=>{const e=B.map(P);return[Math.min(...e),Math.max(...e)]},[B,P]),T=e.useMemo(()=>"custom"===m&&g?g:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[m]||r.interpolateBlues).domain(H),[m,g,H]);e.useMemo(()=>{const e=ve(c),t=ve(u);return{xBinCount:new Set(B.map(e)).size,yBinCount:new Set(B.map(t)).size}},[B,c,u]),e.useMemo(()=>({coordinates:B}),[B]);const I=e.useMemo(()=>e=>{const t=P(e);return{fill:T(t),stroke:b,strokeWidth:v}},[P,T,b,v]);e.useMemo(()=>le(I,$,A),[I,$,A]),e.useMemo(()=>{if(!y)return;const e=(H[0]+H[1])/2;return(t,n)=>{const o=P(t),i=p?p(o):o+"";return a.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:P(t)>e?"#fff":"#000",fontSize:"12px"},i)}},[y,P,p,H]);const F=e.useMemo(()=>je([{label:C||Le(c),accessor:c,role:"x"},{label:_||Le(u),accessor:u,role:"y"},{label:Le(h),accessor:h,role:"value"}]),[c,u,C,_,h]),D=_e({componentName:"Heatmap",data:B,accessors:{xAccessor:c,yAccessor:u,valueAccessor:h}});if(D)return a.createElement(Ce,{componentName:"Heatmap",message:D,width:O,height:N});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:B,xAccessor:c,yAccessor:u,valueAccessor:h,size:[O,N],margin:W,showAxes:n.showAxes,xLabel:C,yLabel:_,xFormat:d,yFormat:f,enableHover:L},j&&{title:j}),l&&{className:l}),{tooltipContent:x?Ne(x):F}),(E||M)&&{customHoverBehavior:z}),k&&k.length>0&&{annotations:k}),w);return a.createElement(te,Object.assign({},R))}function Te({selections:t}){const n=fe(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[]),null}function Ie({children:e,selections:t}){return a.createElement(de,null,a.createElement(ye,null,t&&a.createElement(Te,{selections:t}),e))}Be.displayName="LineChart",We.displayName="AreaChart",$e.displayName="StackedAreaChart",ze.displayName="Scatterplot",Pe.displayName="BubbleChart",He.displayName="Heatmap";const Fe="__splomIdx",De={top:4,bottom:4,left:4,right:4};function Re({frameRef:o,cellSize:i,onBrush:s}){const r=e.useRef(null),l=i-De.left-De.right,c=i-De.top-De.bottom;return e.useEffect(()=>{if(!r.current)return;const e=n.select(r.current).select(".brush-g"),i=t.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void s(null);const[[i,r],[l,a]]=e.selection,c=[[n.x.invert(i),n.y.invert(r)],[n.x.invert(l),n.y.invert(a)]];s(c)});return e.call(i),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[l,c,o,s]),a.createElement("svg",{ref:r,width:i,height:i,style:{position:"absolute",top:0,left:0}},a.createElement("g",{className:"brush-g",transform:`translate(${De.left},${De.top})`}))}function Ge({data:t,xField:n,yField:o,cellSize:i,pointRadius:s,pointOpacity:r,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:h,unselectedOpacity:d,mode:f,onPointHover:m}){const g=e.useRef(null),y=me({name:u,clientId:`splom-${n}-${o}`}),p=ge({name:u,xField:n,yField:o}),b=me({name:h,clientId:"splom-hover-source"}),v=b.selectPoints,x=e.useCallback(e=>{e?p.brushInteraction.during(e):p.brushInteraction.end(null)},[p.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==m||m(null));const t=e.data,n=null==t?void 0:t[Fe];void 0!==n&&(v({[Fe]:[n]}),null==m||m(t,e.x+De.left,e.y+De.top))},[v,m]),w=e.useCallback(e=>{const t={opacity:r,r:s};return t.fill=l?ie(e,l,c):be,"hover"===f?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*r):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[l,c,r,s,f,y.isActive,y.predicate,b.isActive,b.predicate,d]);return a.createElement("div",{style:{position:"relative",width:i,height:i}},a.createElement(te,{ref:g,chartType:"scatter",data:t,size:[i,i],xAccessor:n,yAccessor:o,pointStyle:w,margin:De,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?k:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&a.createElement(Re,{frameRef:g,cellSize:i,xField:n,yField:o,onBrush:x}))}function Ye({data:t,field:n,label:o,cellSize:i,bins:s,brushSelectionName:r,hoverSelectionName:l,mode:c}){const u=me({name:r,clientId:"splom-diag-"+n}),h=me({name:l,clientId:`splom-diag-${n}-hover`}),d="hover"===c?h:u,f=d.isActive,m=d.predicate,g=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),r=(Math.max(...e)-o)/s||1,l=Array(s).fill(0),a=Array(s).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const i=Math.min(Math.floor((t-o)/r),s-1);l[i]++,f&&!m(e)||a[i]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/s*i,w:i/s-1,h:e/c*(i-24),count:e})),selectedBars:a.map((e,t)=>({x:t/s*i,w:i/s-1,h:e/c*(i-24),count:e})),max:c}},[t,n,s,i,f,m]);return a.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},a.createElement("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),g.bars.map((e,t)=>a.createElement("rect",{key:"bg-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:f?.3:.6})),f&&g.selectedBars.map((e,t)=>a.createElement("rect",{key:"sel-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:be,opacity:.7})))}function Xe({label:e,cellSize:t}){return a.createElement("svg",{width:t,height:t},a.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function qe(t){const{data:n,fields:o,fieldLabels:i={},colorBy:s,colorScheme:r="category10",cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:h=.5,diagonal:d="histogram",histogramBins:f=20,brushMode:m="crossfilter",hoverMode:g=!0,unselectedOpacity:y=.1,showGrid:p=!1,tooltip:b,showLegend:v,idAccessor:x,className:k,onObservation:w,chartId:A}=t,E="splom",M="splom-hover",S=g?"hover":m?"brush":"hover",O=fe(e=>e.clearSelection),[N,L]=e.useState(null),j=e.useCallback(()=>{O(M),L(null)},[O,M]),C=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Fe]?e:Object.assign(Object.assign({},e),{[Fe]:t})),[n]),_=xe(C,s,r),B=void 0!==v?v:!!s,W=e.useMemo(()=>{if(!B||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(C.map(t=>t[e]))].map(e=>({label:e+"",color:_?_(e+""):be})):null},[B,s,C,_]),$=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>l+"px").join(" "),gridTemplateRows:o.map(()=>l+"px").join(" ")+" 40px",gap:c+"px",width:"fit-content"}),[o,l,c,40]);return a.createElement("div",{className:k,style:{position:"relative"}},W&&a.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},W.map(e=>a.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},a.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),a.createElement("span",{style:{fontSize:11}},e.label)))),a.createElement("div",{style:$,onMouseLeave:"hover"===S?j:void 0},o.map((e,t)=>a.createElement(a.Fragment,{key:"row-"+e},a.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},i[e]||e),o.map((n,o)=>t===o?"label"===d?a.createElement(Xe,{key:"diag-"+e,label:i[e]||e,cellSize:l}):a.createElement(Ye,{key:"diag-"+e,data:C,field:e,label:i[e]||e,cellSize:l,bins:f,colorBy:s,colorScale:_,brushSelectionName:E,hoverSelectionName:M,unselectedOpacity:y,mode:S}):a.createElement(Ge,{key:`cell-${e}-${n}`,data:C,xField:n,yField:e,fieldLabels:i,cellSize:l,pointRadius:u,pointOpacity:h,colorBy:s,colorScale:_,brushSelectionName:E,hoverSelectionName:M,unselectedOpacity:y,showGrid:p,tooltip:b,mode:S,onPointHover:"hover"===S?(i,s,r)=>{i?(L({datum:i,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=s?s:0,py:null!=r?r:0}),w&&w({type:"hover",datum:i,x:null!=s?s:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(L(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),a.createElement("div",null)," ",o.map(e=>a.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},i[e]||e))),N&&"hover"===S&&(()=>{const e=N.datum,t=i[N.xField]||N.xField,n=i[N.yField]||N.yField,o=s?"function"==typeof s?s(e):e[s]:null,r=x?"function"==typeof x?x(e):e[x]:"Row "+e[Fe];return a.createElement("div",{style:{position:"absolute",left:40+N.colIndex*(l+c)+N.px,top:N.rowIndex*(l+c)+N.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},a.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},r+""),a.createElement("div",null,t,": ",null!=e[N.xField]?Number(e[N.xField]).toFixed(1):"–"),a.createElement("div",null,n,": ",null!=e[N.yField]?Number(e[N.yField]).toFixed(1):"–"),null!=o&&a.createElement("div",{style:{opacity:.8}},"string"==typeof s?s:"group",": ",o+""))})())}function Ve(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),a.createElement(Ie,{selections:o},a.createElement(qe,Object.assign({},e)))}function Ue({width:o,height:i,margin:s,scales:r,brushDirection:l,extent:c,onBrush:u}){const h=e.useRef(null),d=e.useRef(null),f=e.useRef(!1),m=o+s.left+s.right,g=i+s.top+s.bottom;return e.useEffect(()=>{if(!h.current||!r)return;const e=n.select(h.current).select(".brush-group"),s="x"===l?t.brushX().extent([[0,0],[o,i]]):t.brushY().extent([[0,0],[o,i]]);return s.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const n=("x"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];u(o)}),e.call(s),d.current=s,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[r,o,i,l,u]),e.useEffect(()=>{if(!d.current||!r||!h.current)return;const e=n.select(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(f.current=!0,c){const n=[t(c[0]),t(c[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);f.current=!1},[c,r,l]),a.createElement("svg",{ref:h,width:m,height:g,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},a.createElement("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`}))}function Ze(t){var n,o;const{data:i,width:s=600,height:r=400,margin:l,className:c,title:u,xLabel:h,yLabel:d,xFormat:f,yFormat:m,xAccessor:g="x",yAccessor:y="y",lineBy:p,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:M=!1,pointRadius:S=3,enableHover:O=!0,showGrid:N=!1,showLegend:L,tooltip:j,minimap:C={},renderBefore:_=!1,onBrush:B,brushExtent:W,frameProps:$={}}=t,z=i||[],[P,H]=e.useState(null),T=null!=W?W:P,I=e.useCallback(e=>{W||H(e),null==B||B(e)},[W,B]),F=e.useRef(null),[D,R]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=F.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?R(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[i]);const G=void 0!==(null===(n=z[0])||void 0===n?void 0:n[b]),Y=e.useMemo(()=>{if(G)return z;if(p){const e=z.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[b]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:z}]},[z,p,b,G]),X=e.useMemo(()=>G||p?Y.flatMap(e=>{const t=e[b]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):z,[Y,b,G,p,z]),q=xe(z,v,x),V=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=v?ie(e,v,q):be,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[v,q,w,A,E]),U=e.useMemo(()=>C.lineStyle?C.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=v?ie(e,v,q):be,t},[v,q,C.lineStyle]),Z=e.useMemo(()=>{if(M)return e=>{const t={r:S,fillOpacity:1};return t.fill=v?ie(e.parentLine||e,v,q):be,t}},[M,S,v,q]),{legend:J,margin:K}=we({data:Y,colorBy:v,colorScale:q,showLegend:L,userMargin:l}),Q=C.height||60,ee=e.useMemo(()=>{var e,t,n,o,i,s,r,l;return{top:null!==(t=null===(e=C.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=C.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(s=null===(i=C.margin)||void 0===i?void 0:i.left)&&void 0!==s?s:K.left,right:null!==(l=null===(r=C.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:K.right}},[C.margin,K]),ne=C.brushDirection||"x",oe=_e({componentName:"MinimapChart",data:z,accessors:{xAccessor:g,yAccessor:y}});if(oe)return a.createElement(Ce,{componentName:"MinimapChart",message:oe,width:s,height:r});const se=A?"area":"line",re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:X,xAccessor:g,yAccessor:y,groupAccessor:p||void 0,curve:k,lineStyle:V},M&&{pointStyle:Z}),{size:[s,r],margin:K,showAxes:!0,xLabel:h,yLabel:d,xFormat:f,yFormat:m,enableHover:O,showGrid:N}),J&&{legend:J}),u&&{title:u}),j&&{tooltipContent:Ne(j)}),T&&{xExtent:T}),$),le={chartType:se,data:X,xAccessor:g,yAccessor:y,groupAccessor:p||void 0,curve:k,lineStyle:U,size:[s,Q+ee.top+ee.bottom],margin:ee,showAxes:null!==(o=C.showAxes)&&void 0!==o&&o,background:C.background,enableHover:!1},ae=a.createElement("div",{key:"minimap",style:{position:"relative",width:s,overflow:"hidden"}},a.createElement(te,Object.assign({ref:F},le)),a.createElement(Ue,{width:s-ee.left-ee.right,height:Q,margin:ee,scales:D,brushDirection:ne,extent:T,onBrush:I})),ce=a.createElement("div",{key:"main",style:{overflow:"hidden"}},a.createElement(te,Object.assign({},re)));return a.createElement("div",{className:"minimap-chart"+(c?" "+c:"")},_?ae:ce,_?ce:ae)}Ve.displayName="ScatterplotMatrix",Ze.displayName="MinimapChart",exports.AreaChart=We,exports.BubbleChart=Pe,exports.Heatmap=He,exports.LineChart=Be,exports.MinimapChart=Ze,exports.Scatterplot=ze,exports.ScatterplotMatrix=Ve,exports.StackedAreaChart=$e,exports.StreamXYFrame=te;